diff options
author | tb <> | 2025-05-03 08:34:55 +0000 |
---|---|---|
committer | tb <> | 2025-05-03 08:34:55 +0000 |
commit | fc21b851ac33eee00c01418efd611d44ed0afa1b (patch) | |
tree | 7ba40a30b36cda9d88b8dde724f60742ac44f29d /src | |
parent | a33eeafb58c71f17faf33e686a61447dac216970 (diff) | |
download | openbsd-fc21b851ac33eee00c01418efd611d44ed0afa1b.tar.gz openbsd-fc21b851ac33eee00c01418efd611d44ed0afa1b.tar.bz2 openbsd-fc21b851ac33eee00c01418efd611d44ed0afa1b.zip |
mlkem_unittest: check return value of decap()
From Kenjiro Nakayama
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/mlkem/mlkem_unittest.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c b/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c index 23b3d8b261..597297b8cc 100644 --- a/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c +++ b/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: mlkem_unittest.c,v 1.6 2024/12/26 12:35:25 tb Exp $ */ | 1 | /* $OpenBSD: mlkem_unittest.c,v 1.7 2025/05/03 08:34:55 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2024 Google Inc. | 3 | * Copyright (c) 2024 Google Inc. |
4 | * Copyright (c) 2024 Bob Beck <beck@obtuse.com> | 4 | * Copyright (c) 2024 Bob Beck <beck@obtuse.com> |
@@ -161,16 +161,22 @@ MlKemUnitTest(struct unittest_ctx *ctx) | |||
161 | tmp_buf = NULL; | 161 | tmp_buf = NULL; |
162 | 162 | ||
163 | ctx->encap(ctx->ciphertext, shared_secret1, ctx->pub); | 163 | ctx->encap(ctx->ciphertext, shared_secret1, ctx->pub); |
164 | ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len, | 164 | if (!ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len, |
165 | ctx->priv); | 165 | ctx->priv)) { |
166 | warnx("decap() failed using priv"); | ||
167 | failed |= 1; | ||
168 | } | ||
166 | if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES, | 169 | if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES, |
167 | "shared secrets with priv") != 0) { | 170 | "shared secrets with priv") != 0) { |
168 | warnx("compare_data"); | 171 | warnx("compare_data"); |
169 | failed |= 1; | 172 | failed |= 1; |
170 | } | 173 | } |
171 | 174 | ||
172 | ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len, | 175 | if (!ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len, |
173 | ctx->priv2); | 176 | ctx->priv2)) { |
177 | warnx("decap() failed using priv2"); | ||
178 | failed |= 1; | ||
179 | } | ||
174 | if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES, | 180 | if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES, |
175 | "shared secrets with priv2") != 0) { | 181 | "shared secrets with priv2") != 0) { |
176 | warnx("compare_data"); | 182 | warnx("compare_data"); |