summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/mlkem/mlkem.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/mlkem/mlkem.h26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/lib/libcrypto/mlkem/mlkem.h b/src/lib/libcrypto/mlkem/mlkem.h
index a5645facc6..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.4 2024/12/19 23:52:26 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 @@
25extern "C" { 25extern "C" {
26#endif 26#endif
27 27
28/* Hack for now */
29struct cbs_st;
30struct cbb_st;
31
32/* 28/*
33 * ML-KEM-768 29 * ML-KEM-768
34 * 30 *
@@ -78,10 +74,10 @@ struct MLKEM768_private_key {
78/* 74/*
79 * MLKEM_generate_key generates a random public/private key pair, writes the 75 * MLKEM_generate_key generates a random public/private key pair, writes the
80 * encoded public key to |out_encoded_public_key| and sets |out_private_key| to 76 * encoded public key to |out_encoded_public_key| and sets |out_private_key| to
81 * the private key. If |optional_out_seed| us not NULL then te seed used to 77 * the private key. If |optional_out_seed| is not NULL then the seed used to
82 * generate te private key is written to it. 78 * generate the private key is written to it.
83 */ 79 */
84void MLKEM768_generate_key( 80int 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 */
140int MLKEM768_marshal_public_key(struct cbb_st *out, 136int 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 */
149int MLKEM768_parse_public_key(struct MLKEM768_public_key *out_public_key, 145int 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 */
159int MLKEM768_parse_private_key(struct MLKEM768_private_key *out_private_key, 155int 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 */
203void MLKEM1024_generate_key( 199int 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 */
259int MLKEM1024_marshal_public_key(struct cbb_st *out, 255int 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 */
268int MLKEM1024_parse_public_key(struct MLKEM1024_public_key *out_public_key, 264int 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 */
278int MLKEM1024_parse_private_key(struct MLKEM1024_private_key *out_private_key, 274int 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}