Download raw body.
[PATCH] libressl: mlkem_unittest: check return value of decap()
Previously, the return value of mlkem{768,1024}_decap() was not
checked. This patch ensures that decapsulation succeeds before
comparing shared secrets.
---
src/regress/lib/libcrypto/mlkem/mlkem_unittest.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c b/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c
index 23b3d8b..a700d99 100644
--- a/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c
+++ b/src/regress/lib/libcrypto/mlkem/mlkem_unittest.c
@@ -161,16 +161,22 @@ MlKemUnitTest(struct unittest_ctx *ctx)
tmp_buf = NULL;
ctx->encap(ctx->ciphertext, shared_secret1, ctx->pub);
- ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len,
- ctx->priv);
+ if (!ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len,
+ ctx->priv)) {
+ warnx("decap() failed using priv");
+ failed |= 1;
+ }
if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES,
"shared secrets with priv") != 0) {
warnx("compare_data");
failed |= 1;
}
- ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len,
- ctx->priv2);
+ if (!ctx->decap(shared_secret2, ctx->ciphertext, ctx->ciphertext_len,
+ ctx->priv2)) {
+ warnx("decap() failed using priv2");
+ failed |= 1;
+ }
if (compare_data(shared_secret1, shared_secret2, MLKEM_SHARED_SECRET_BYTES,
"shared secrets with priv2") != 0) {
warnx("compare_data");
--
2.39.5 (Apple Git-154)
[PATCH] libressl: mlkem_unittest: check return value of decap()