diff options
Diffstat (limited to 'src/lib/libcrypto/mlkem/mlkem.h')
| -rw-r--r-- | src/lib/libcrypto/mlkem/mlkem.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/lib/libcrypto/mlkem/mlkem.h b/src/lib/libcrypto/mlkem/mlkem.h index 055d92290e..a2c5d7fed0 100644 --- a/src/lib/libcrypto/mlkem/mlkem.h +++ b/src/lib/libcrypto/mlkem/mlkem.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: mlkem.h,v 1.5 2025/03/28 12:17:16 tb Exp $ */ | 1 | /* $OpenBSD: mlkem.h,v 1.6 2025/05/19 06:47:40 beck Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2024, Google Inc. | 3 | * Copyright (c) 2024, Google Inc. |
| 4 | * | 4 | * |
| @@ -25,10 +25,6 @@ | |||
| 25 | extern "C" { | 25 | extern "C" { |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | /* Hack for now */ | ||
| 29 | struct cbs_st; | ||
| 30 | struct cbb_st; | ||
| 31 | |||
| 32 | /* | 28 | /* |
| 33 | * ML-KEM-768 | 29 | * ML-KEM-768 |
| 34 | * | 30 | * |
| @@ -81,7 +77,7 @@ struct MLKEM768_private_key { | |||
| 81 | * the private key. If |optional_out_seed| is not NULL then the seed used to | 77 | * the private key. If |optional_out_seed| is not NULL then the seed used to |
| 82 | * generate the private key is written to it. | 78 | * generate the private key is written to it. |
| 83 | */ | 79 | */ |
| 84 | void MLKEM768_generate_key( | 80 | int MLKEM768_generate_key( |
| 85 | uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES], | 81 | uint8_t out_encoded_public_key[MLKEM768_PUBLIC_KEY_BYTES], |
| 86 | uint8_t optional_out_seed[MLKEM_SEED_BYTES], | 82 | uint8_t optional_out_seed[MLKEM_SEED_BYTES], |
| 87 | struct MLKEM768_private_key *out_private_key); | 83 | struct MLKEM768_private_key *out_private_key); |
| @@ -137,7 +133,7 @@ int MLKEM768_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], | |||
| 137 | * format for ML-KEM public keys. It returns one on success or zero on allocation | 133 | * format for ML-KEM public keys. It returns one on success or zero on allocation |
| 138 | * error. | 134 | * error. |
| 139 | */ | 135 | */ |
| 140 | int MLKEM768_marshal_public_key(struct cbb_st *out, | 136 | int MLKEM768_marshal_public_key(uint8_t **output, size_t *output_len, |
| 141 | const struct MLKEM768_public_key *public_key); | 137 | const struct MLKEM768_public_key *public_key); |
| 142 | 138 | ||
| 143 | /* | 139 | /* |
| @@ -147,7 +143,7 @@ int MLKEM768_marshal_public_key(struct cbb_st *out, | |||
| 147 | * there are trailing bytes in |in|. | 143 | * there are trailing bytes in |in|. |
| 148 | */ | 144 | */ |
| 149 | int MLKEM768_parse_public_key(struct MLKEM768_public_key *out_public_key, | 145 | int MLKEM768_parse_public_key(struct MLKEM768_public_key *out_public_key, |
| 150 | struct cbs_st *in); | 146 | const uint8_t *input, size_t input_len); |
| 151 | 147 | ||
| 152 | /* | 148 | /* |
| 153 | * MLKEM_parse_private_key parses a private key, in the format generated by | 149 | * MLKEM_parse_private_key parses a private key, in the format generated by |
| @@ -157,7 +153,7 @@ int MLKEM768_parse_public_key(struct MLKEM768_public_key *out_public_key, | |||
| 157 | * Private keys should be stored as seeds and parsed using |MLKEM768_private_key_from_seed|. | 153 | * Private keys should be stored as seeds and parsed using |MLKEM768_private_key_from_seed|. |
| 158 | */ | 154 | */ |
| 159 | int MLKEM768_parse_private_key(struct MLKEM768_private_key *out_private_key, | 155 | int MLKEM768_parse_private_key(struct MLKEM768_private_key *out_private_key, |
| 160 | struct cbs_st *in); | 156 | const uint8_t *input, size_t input_len); |
| 161 | 157 | ||
| 162 | /* | 158 | /* |
| 163 | * ML-KEM-1024 | 159 | * ML-KEM-1024 |
| @@ -200,7 +196,7 @@ struct MLKEM1024_private_key { | |||
| 200 | * the private key. If |optional_out_seed| is not NULL then the seed used to | 196 | * the private key. If |optional_out_seed| is not NULL then the seed used to |
| 201 | * generate the private key is written to it. | 197 | * generate the private key is written to it. |
| 202 | */ | 198 | */ |
| 203 | void MLKEM1024_generate_key( | 199 | int MLKEM1024_generate_key( |
| 204 | uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES], | 200 | uint8_t out_encoded_public_key[MLKEM1024_PUBLIC_KEY_BYTES], |
| 205 | uint8_t optional_out_seed[MLKEM_SEED_BYTES], | 201 | uint8_t optional_out_seed[MLKEM_SEED_BYTES], |
| 206 | struct MLKEM1024_private_key *out_private_key); | 202 | struct MLKEM1024_private_key *out_private_key); |
| @@ -256,7 +252,7 @@ int MLKEM1024_decap(uint8_t out_shared_secret[MLKEM_SHARED_SECRET_BYTES], | |||
| 256 | * format for ML-KEM-1024 public keys. It returns one on success or zero on | 252 | * format for ML-KEM-1024 public keys. It returns one on success or zero on |
| 257 | * allocation error. | 253 | * allocation error. |
| 258 | */ | 254 | */ |
| 259 | int MLKEM1024_marshal_public_key(struct cbb_st *out, | 255 | int MLKEM1024_marshal_public_key(uint8_t **output, size_t *output_len, |
| 260 | const struct MLKEM1024_public_key *public_key); | 256 | const struct MLKEM1024_public_key *public_key); |
| 261 | 257 | ||
| 262 | /* | 258 | /* |
| @@ -266,7 +262,7 @@ int MLKEM1024_marshal_public_key(struct cbb_st *out, | |||
| 266 | * there are trailing bytes in |in|. | 262 | * there are trailing bytes in |in|. |
| 267 | */ | 263 | */ |
| 268 | int MLKEM1024_parse_public_key(struct MLKEM1024_public_key *out_public_key, | 264 | int MLKEM1024_parse_public_key(struct MLKEM1024_public_key *out_public_key, |
| 269 | struct cbs_st *in); | 265 | const uint8_t *input, size_t input_len); |
| 270 | 266 | ||
| 271 | /* | 267 | /* |
| 272 | * MLKEM1024_parse_private_key parses a private key, in NIST's format for | 268 | * MLKEM1024_parse_private_key parses a private key, in NIST's format for |
| @@ -276,7 +272,7 @@ int MLKEM1024_parse_public_key(struct MLKEM1024_public_key *out_public_key, | |||
| 276 | * stored as seeds and parsed using |MLKEM1024_private_key_from_seed|. | 272 | * stored as seeds and parsed using |MLKEM1024_private_key_from_seed|. |
| 277 | */ | 273 | */ |
| 278 | int MLKEM1024_parse_private_key(struct MLKEM1024_private_key *out_private_key, | 274 | int MLKEM1024_parse_private_key(struct MLKEM1024_private_key *out_private_key, |
| 279 | struct cbs_st *in); | 275 | const uint8_t *input, size_t input_len); |
| 280 | 276 | ||
| 281 | #if defined(__cplusplus) | 277 | #if defined(__cplusplus) |
| 282 | } | 278 | } |
