summaryrefslogtreecommitdiffstats
path: root/test
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:50 +0100
commit2a4f8da45c73cff771ae45de46ef73095a6ca29e (patch)
tree11529a01d3586f9fda24f189ddc1ede71f35f1ab /test
parent96e58e32ffd7deaf5184d5e502b476554d39216b (diff)
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) (cherry picked from commit a1c0306895bf6cf28056aaf9cd22cb3b65d4bb0a)
Diffstat (limited to 'test')
-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 4ca67682a3..a8bd1f8f64 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;