aboutsummaryrefslogtreecommitdiff
path: root/test/hpke_test.c
diff options
context:
space:
mode:
authorStephen Farrell <stephen.farrell@cs.tcd.ie>2023-10-16 21:04:06 +0100
committerTomas Mraz <tomas@openssl.org>2023-11-03 09:10:19 +0100
commita1c0306895bf6cf28056aaf9cd22cb3b65d4bb0a (patch)
tree6d20524c464d7cf9a040a54d0024422d7a7b1c6c /test/hpke_test.c
parent04b53878ea498582a6c2cfa93c570584818bbe47 (diff)
downloadopenssl-a1c0306895bf6cf28056aaf9cd22cb3b65d4bb0a.zip
openssl-a1c0306895bf6cf28056aaf9cd22cb3b65d4bb0a.tar.gz
openssl-a1c0306895bf6cf28056aaf9cd22cb3b65d4bb0a.tar.bz2
Add additional internal HPKE hardening checks resulting from code audit.
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22493)
Diffstat (limited to 'test/hpke_test.c')
-rw-r--r--test/hpke_test.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/hpke_test.c b/test/hpke_test.c
index 4ca6768..a8bd1f8 100644
--- a/test/hpke_test.c
+++ b/test/hpke_test.c
@@ -1319,8 +1319,8 @@ static int test_hpke_oddcalls(void)
OSSL_HPKE_CTX *rctx = NULL;
unsigned char plain[] = "quick brown fox";
size_t plainlen = sizeof(plain);
- unsigned char enc[OSSL_HPKE_TSTSIZE];
- size_t enclen = sizeof(enc);
+ unsigned char enc[OSSL_HPKE_TSTSIZE], smallenc[10];
+ size_t enclen = sizeof(enc), smallenclen = sizeof(smallenc);
unsigned char cipher[OSSL_HPKE_TSTSIZE];
size_t cipherlen = sizeof(cipher);
unsigned char clear[OSSL_HPKE_TSTSIZE];
@@ -1471,6 +1471,15 @@ static int test_hpke_oddcalls(void)
/* encap with too big info */
if (!TEST_false(OSSL_HPKE_encap(ctx, enc, &enclen, pub, 1, info, -1)))
goto end;
+ /* encap with NULL info & non-zero infolen */
+ if (!TEST_false(OSSL_HPKE_encap(ctx, enc, &enclen, pub, 1, NULL, 1)))
+ goto end;
+ /* encap with non-NULL info & zero infolen */
+ if (!TEST_false(OSSL_HPKE_encap(ctx, enc, &enclen, pub, 1, info, 0)))
+ goto end;
+ /* encap with too small enc */
+ if (!TEST_false(OSSL_HPKE_encap(ctx, smallenc, &smallenclen, pub, 1, NULL, 0)))
+ goto end;
/* good encap */
if (!TEST_true(OSSL_HPKE_encap(ctx, enc, &enclen, pub, publen, NULL, 0)))
goto end;