libdecaf
ed448.h
Go to the documentation of this file.
1 
15 #ifndef __DECAF_ED448_H__
16 #define __DECAF_ED448_H__ 1
17 
18 #include <decaf/point_448.h>
19 #include <decaf/shake.h>
20 #include <decaf/sha512.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
27 #define DECAF_EDDSA_448_PUBLIC_BYTES 57
28 
30 #define DECAF_EDDSA_448_PRIVATE_BYTES DECAF_EDDSA_448_PUBLIC_BYTES
31 
33 #define DECAF_EDDSA_448_SIGNATURE_BYTES (DECAF_EDDSA_448_PUBLIC_BYTES + DECAF_EDDSA_448_PRIVATE_BYTES)
34 
36 #if defined _MSC_VER /* Different syntax for exposing API */
37 #define DECAF_EDDSA_448_SUPPORTS_CONTEXTLESS_SIGS 0
38 
39 #else
40 #define DECAF_EDDSA_448_SUPPORTS_CONTEXTLESS_SIGS 0
41 
42 #endif
43 
45 #define decaf_ed448_prehash_ctx_s decaf_shake256_ctx_s
46 
48 #define decaf_ed448_prehash_ctx_t decaf_shake256_ctx_t
49 
51 #define decaf_ed448_prehash_update decaf_shake256_update
52 
54 #define decaf_ed448_prehash_destroy decaf_shake256_destroy
55 
57 #define DECAF_448_EDDSA_ENCODE_RATIO 4
58 
60 #define DECAF_448_EDDSA_DECODE_RATIO (4 / 4)
61 
62 #ifndef DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED
63 
64 #define DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED 0
65 #endif
66 
69 typedef struct decaf_eddsa_448_keypair_s {
70  uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES];
71  uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES];
72 } decaf_eddsa_448_keypair_s, decaf_eddsa_448_keypair_t[1];
82 void DECAF_API_VIS decaf_ed448_derive_public_key (
83  uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
84  const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES]
85 ) DECAF_NONNULL DECAF_NOINLINE;
86 
94 void DECAF_API_VIS decaf_ed448_derive_keypair (
95  decaf_eddsa_448_keypair_t keypair,
96  const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES]
97 ) DECAF_NONNULL DECAF_NOINLINE;
98 
105 void DECAF_API_VIS decaf_ed448_keypair_extract_public_key (
106  uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
107  const decaf_eddsa_448_keypair_t keypair
108 ) DECAF_NONNULL DECAF_NOINLINE;
109 
116 void DECAF_API_VIS decaf_ed448_keypair_extract_private_key (
117  uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES],
118  const decaf_eddsa_448_keypair_t keypair
119 ) DECAF_NONNULL DECAF_NOINLINE;
120 
125 void DECAF_API_VIS decaf_ed448_keypair_destroy (
126  decaf_eddsa_448_keypair_t keypair
127 ) DECAF_NONNULL DECAF_NOINLINE;
128 
150 void DECAF_API_VIS decaf_ed448_sign (
151  uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
152  const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES],
153  const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
154  const uint8_t *message,
155  size_t message_len,
156  uint8_t prehashed,
157  const uint8_t *context,
158  uint8_t context_len
159 ) __attribute__((nonnull(1,2,3))) DECAF_NOINLINE
160 #if DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED
161  __attribute__((deprecated("Passing the pubkey and privkey separately is unsafe",
162  "decaf_ed448_keypair_sign")))
163 #endif
164 ;
165 
180 void DECAF_API_VIS decaf_ed448_sign_prehash (
181  uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
182  const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES],
183  const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
184  const decaf_ed448_prehash_ctx_t hash,
185  const uint8_t *context,
186  uint8_t context_len
187 ) __attribute__((nonnull(1,2,3,4))) DECAF_NOINLINE
188 #if DECAF_EDDSA_NON_KEYPAIR_API_IS_DEPRECATED
189  __attribute__((deprecated("Passing the pubkey and privkey separately is unsafe",
190  "decaf_ed448_keypair_sign_prehash")))
191 #endif
192 ;
193 
205 void DECAF_API_VIS decaf_ed448_keypair_sign (
206  uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
207  const decaf_eddsa_448_keypair_t keypair,
208  const uint8_t *message,
209  size_t message_len,
210  uint8_t prehashed,
211  const uint8_t *context,
212  uint8_t context_len
213 ) __attribute__((nonnull(1,2,3))) DECAF_NOINLINE;
214 
224 void DECAF_API_VIS decaf_ed448_keypair_sign_prehash (
225  uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
226  const decaf_eddsa_448_keypair_t keypair,
227  const decaf_ed448_prehash_ctx_t hash,
228  const uint8_t *context,
229  uint8_t context_len
230 ) __attribute__((nonnull(1,2,3,4))) DECAF_NOINLINE;
231 
237 void DECAF_API_VIS decaf_ed448_prehash_init (
239 ) __attribute__((nonnull(1))) DECAF_NOINLINE;
240 
259 decaf_error_t DECAF_API_VIS decaf_ed448_verify (
260  const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
261  const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
262  const uint8_t *message,
263  size_t message_len,
264  uint8_t prehashed,
265  const uint8_t *context,
266  uint8_t context_len
267 ) __attribute__((nonnull(1,2))) DECAF_NOINLINE;
268 
286  const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES],
287  const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES],
288  const decaf_ed448_prehash_ctx_t hash,
289  const uint8_t *context,
290  uint8_t context_len
291 ) __attribute__((nonnull(1,2))) DECAF_NOINLINE;
292 
318  uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES],
319  const decaf_448_point_t p
320 ) DECAF_NONNULL DECAF_NOINLINE;
321 
333  const uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES]
334 ) DECAF_NONNULL DECAF_NOINLINE;
335 
347 void DECAF_API_VIS decaf_ed448_convert_public_key_to_x448 (
348  uint8_t x[DECAF_X448_PUBLIC_BYTES],
349  const uint8_t ed[DECAF_EDDSA_448_PUBLIC_BYTES]
350 ) DECAF_NONNULL DECAF_NOINLINE;
351 
360 void DECAF_API_VIS decaf_ed448_convert_private_key_to_x448 (
361  uint8_t x[DECAF_X448_PRIVATE_BYTES],
362  const uint8_t ed[DECAF_EDDSA_448_PRIVATE_BYTES]
363 ) DECAF_NONNULL DECAF_NOINLINE;
364 
365 #ifdef __cplusplus
366 } /* extern "C" */
367 #endif
368 
369 #endif /* __DECAF_ED448_H__ */
DECAF_EDDSA_448_PRIVATE_BYTES
#define DECAF_EDDSA_448_PRIVATE_BYTES
Number of bytes in an EdDSA private key.
Definition: ed448.h:30
shake.h
SHA2-512.
decaf_ed448_sign_prehash
void DECAF_API_VIS decaf_ed448_sign_prehash(uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES], const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES], const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES], const decaf_ed448_prehash_ctx_t hash, const uint8_t *context, uint8_t context_len) DECAF_NOINLINE
EdDSA signing with prehash.
decaf_ed448_sign
void DECAF_API_VIS decaf_ed448_sign(uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES], const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES], const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES], const uint8_t *message, size_t message_len, uint8_t prehashed, const uint8_t *context, uint8_t context_len) DECAF_NOINLINE
EdDSA signing.
decaf_ed448_prehash_ctx_t
#define decaf_ed448_prehash_ctx_t
Prehash context, array[1] form.
Definition: ed448.h:48
decaf_ed448_keypair_extract_private_key
void DECAF_API_VIS decaf_ed448_keypair_extract_private_key(uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES], const decaf_eddsa_448_keypair_t keypair) DECAF_NONNULL DECAF_NOINLINE
Extract the private key from an EdDSA keypair.
decaf_ed448_verify_prehash
decaf_error_t DECAF_API_VIS decaf_ed448_verify_prehash(const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES], const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES], const decaf_ed448_prehash_ctx_t hash, const uint8_t *context, uint8_t context_len) DECAF_NOINLINE
EdDSA signature verification.
decaf_ed448_convert_public_key_to_x448
void DECAF_API_VIS decaf_ed448_convert_public_key_to_x448(uint8_t x[DECAF_X448_PUBLIC_BYTES], const uint8_t ed[DECAF_EDDSA_448_PUBLIC_BYTES]) DECAF_NONNULL DECAF_NOINLINE
EdDSA to ECDH public key conversion Deserialize the point to get y on Edwards curve,...
Definition: decaf.c:1335
decaf_ed448_derive_public_key
void DECAF_API_VIS decaf_ed448_derive_public_key(uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES], const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES]) DECAF_NONNULL DECAF_NOINLINE
EdDSA key generation.
decaf_ed448_keypair_extract_public_key
void DECAF_API_VIS decaf_ed448_keypair_extract_public_key(uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES], const decaf_eddsa_448_keypair_t keypair) DECAF_NONNULL DECAF_NOINLINE
Extract the public key from an EdDSA keypair.
decaf_448_point_mul_by_ratio_and_encode_like_eddsa
void DECAF_API_VIS decaf_448_point_mul_by_ratio_and_encode_like_eddsa(uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES], const decaf_448_point_t p) DECAF_NONNULL DECAF_NOINLINE
EdDSA point encoding.
point_448.h
A group of prime order p, based on Ed448-Goldilocks.
DECAF_EDDSA_448_PUBLIC_BYTES
#define DECAF_EDDSA_448_PUBLIC_BYTES
Number of bytes in an EdDSA public key.
Definition: ed448.h:27
decaf_ed448_keypair_sign_prehash
void DECAF_API_VIS decaf_ed448_keypair_sign_prehash(uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES], const decaf_eddsa_448_keypair_t keypair, const decaf_ed448_prehash_ctx_t hash, const uint8_t *context, uint8_t context_len) DECAF_NOINLINE
EdDSA signing with prehash.
decaf_error_t
decaf_error_t
Another boolean type used to indicate success or failure.
Definition: common.h:120
decaf_448_point_t
struct decaf_448_point_s decaf_448_point_t[1]
Representation of a point on the elliptic curve.
DECAF_X448_PRIVATE_BYTES
#define DECAF_X448_PRIVATE_BYTES
Number of bytes in an x448 private key.
Definition: point_448.h:65
decaf_ed448_prehash_init
void DECAF_API_VIS decaf_ed448_prehash_init(decaf_ed448_prehash_ctx_t hash) DECAF_NOINLINE
Prehash initialization, with contexts if supported.
DECAF_EDDSA_448_SIGNATURE_BYTES
#define DECAF_EDDSA_448_SIGNATURE_BYTES
Number of bytes in an EdDSA private key.
Definition: ed448.h:33
decaf_448_point_decode_like_eddsa_and_mul_by_ratio
decaf_error_t DECAF_API_VIS decaf_448_point_decode_like_eddsa_and_mul_by_ratio(decaf_448_point_t p, const uint8_t enc[DECAF_EDDSA_448_PUBLIC_BYTES]) DECAF_NONNULL DECAF_NOINLINE
EdDSA point decoding.
DECAF_X448_PUBLIC_BYTES
#define DECAF_X448_PUBLIC_BYTES
Number of bytes in an x448 public key.
Definition: point_448.h:62
decaf_ed448_keypair_destroy
void DECAF_API_VIS decaf_ed448_keypair_destroy(decaf_eddsa_448_keypair_t keypair) DECAF_NONNULL DECAF_NOINLINE
EdDSA keypair destructor.
decaf_ed448_convert_private_key_to_x448
void DECAF_API_VIS decaf_ed448_convert_private_key_to_x448(uint8_t x[DECAF_X448_PRIVATE_BYTES], const uint8_t ed[DECAF_EDDSA_448_PRIVATE_BYTES]) DECAF_NONNULL DECAF_NOINLINE
EdDSA to ECDH private key conversion Using the appropriate hash function, hash the EdDSA private key ...
decaf_ed448_keypair_sign
void DECAF_API_VIS decaf_ed448_keypair_sign(uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES], const decaf_eddsa_448_keypair_t keypair, const uint8_t *message, size_t message_len, uint8_t prehashed, const uint8_t *context, uint8_t context_len) DECAF_NOINLINE
EdDSA signing.
decaf_ed448_derive_keypair
void DECAF_API_VIS decaf_ed448_derive_keypair(decaf_eddsa_448_keypair_t keypair, const uint8_t privkey[DECAF_EDDSA_448_PRIVATE_BYTES]) DECAF_NONNULL DECAF_NOINLINE
EdDSA keypair scheduling.
decaf_ed448_verify
decaf_error_t DECAF_API_VIS decaf_ed448_verify(const uint8_t signature[DECAF_EDDSA_448_SIGNATURE_BYTES], const uint8_t pubkey[DECAF_EDDSA_448_PUBLIC_BYTES], const uint8_t *message, size_t message_len, uint8_t prehashed, const uint8_t *context, uint8_t context_len) DECAF_NOINLINE
EdDSA signature verification.