aboutsummaryrefslogtreecommitdiff
path: root/test/evp_extra_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/evp_extra_test.c')
-rw-r--r--test/evp_extra_test.c1533
1 files changed, 1446 insertions, 87 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index c5fbbf8a8309..d6d973d5b925 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2015-2024 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2025 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -32,10 +32,14 @@
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/proverr.h>
+#include <openssl/rand.h>
+# include <crypto/ml_kem.h>
#include "testutil.h"
#include "internal/nelem.h"
#include "internal/sizes.h"
#include "crypto/evp.h"
+#include "fake_rsaprov.h"
+#include "fake_pipelineprov.h"
#ifdef STATIC_LEGACY
OSSL_provider_init_fn ossl_legacy_provider_init;
@@ -106,8 +110,187 @@ static const unsigned char kExampleRSAKeyDER[] = {
0x2d, 0x86, 0x9d, 0xa5, 0x20, 0x1b, 0xe5, 0xdf,
};
+/* An invalid key whose prime factors exceed modulus n. */
+static const unsigned char kInvalidRSAKeyDER[] = {
+ 0x30, 0x80, 0x02, 0x00, 0x02, 0x02, 0xb6, 0x00, 0x02, 0x02, 0x04, 0x80,
+ 0x02, 0x00, 0x02, 0x82, 0x08, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x01, 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2b,
+ 0x31, 0xff, 0x44, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x29, 0xaa, 0xaa, 0xaa, 0xd9, 0xd9, 0xbf, 0x02, 0x01,
+ 0xc8, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xee,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15, 0x15,
+ 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x15, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x29, 0x0f, 0x07, 0x07, 0x4d, 0x00, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x14, 0x15, 0x15,
+ 0xec, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0xe6, 0x15, 0x15, 0x15, 0x15, 0xff, 0x03, 0x00, 0x0a, 0x00, 0x00,
+ 0x00, 0x00, 0x55, 0x15, 0x15, 0x15, 0x15, 0x11, 0x05, 0x15, 0x15, 0x15,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x4d, 0xf9, 0xf8, 0xf9,
+ 0x02, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15, 0x15,
+ 0x00, 0x02, 0x00, 0x6d, 0x61, 0x78, 0x00, 0x02, 0x00, 0x02, 0x15, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x51, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0xa5, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x5d, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15,
+ 0x15, 0x15, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
+ 0x00, 0x22, 0x00, 0x15, 0x15, 0x15, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xea,
+ 0xea, 0xf1, 0x15, 0x15, 0x15, 0x15, 0x15, 0x40, 0x55, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x05, 0x15, 0x15, 0x30, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x00, 0x00, 0x00, 0x4d, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x15, 0x15, 0x15, 0x15, 0x00, 0x02, 0x00, 0x02, 0x00,
+ 0x02, 0x00, 0x02, 0x00, 0x02, 0x15, 0x07, 0x07, 0x07, 0x07, 0x07, 0x29,
+ 0x07, 0x07, 0x07, 0x4d, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x15, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x55, 0x15, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x02, 0x02, 0xb6, 0x00, 0x02, 0x02, 0x04, 0x80, 0x02,
+ 0x00, 0x02, 0x82, 0x08, 0x01, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x01, 0x04, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2b, 0x31,
+ 0xff, 0x44, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0x29, 0xaa, 0xaa, 0xaa, 0xd9, 0xd9, 0xbf, 0x02, 0x01, 0xc8,
+ 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88, 0xee, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15, 0x15, 0x00,
+ 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x15, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x29, 0x0f, 0x07, 0x07, 0x4d, 0x00, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x14, 0x15, 0x15, 0xec,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0xe6, 0x15, 0x15, 0x15, 0x15, 0xff, 0x03, 0x00, 0x0a, 0x00, 0x00, 0x00,
+ 0x00, 0x55, 0x15, 0x15, 0x15, 0x15, 0x11, 0x05, 0x15, 0x15, 0x15, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x4d, 0xf9, 0xf8, 0xf9, 0x02,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15, 0x15, 0x00,
+ 0x02, 0x00, 0x6d, 0x61, 0x78, 0x00, 0x02, 0x00, 0x02, 0x15, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x51, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0xa5, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x5d,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15,
+ 0x15, 0x00, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
+ 0x22, 0x00, 0x15, 0x15, 0x15, 0xeb, 0xea, 0xea, 0xea, 0xea, 0xea, 0xea,
+ 0xf1, 0x15, 0x15, 0x15, 0x15, 0x15, 0x40, 0x55, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x05, 0x15, 0x15, 0x30, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00,
+ 0x00, 0x00, 0x4d, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x11, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x15, 0x15, 0x15, 0x15, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02,
+ 0x00, 0x02, 0x00, 0x02, 0x15, 0x07, 0x07, 0x07, 0x07, 0x07, 0x29, 0x07,
+ 0x07, 0x07, 0x4d, 0x00, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x15, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x55, 0x15, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x06, 0xce, 0x15, 0x00, 0xfe, 0xf7, 0x52, 0x53, 0x41,
+ 0x31, 0x01, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0x2b, 0x31, 0xff, 0x44, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xd9, 0xd9, 0xbf, 0x02,
+ 0x01, 0xc8, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x88, 0x88, 0x88,
+ 0xee, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15,
+ 0x15, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x15,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x29, 0x07, 0x07, 0x07, 0x4d, 0x00, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x14, 0x15,
+ 0x15, 0xec, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x55, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, 0x15, 0x15,
+ 0x15, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x4d, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x15, 0x15, 0x15,
+ 0x15, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x15,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,
+ 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x8f,
+ 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f,
+ 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f,
+ 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8f,
+ 0x8f, 0x8f, 0x8f, 0x8f, 0x59, 0x59, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x3d, 0xc1, 0xc1,
+ 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1,
+ 0xc1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00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, 0x10, 0x10, 0x10, 0x10, 0x10,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xa5, 0x02,
+ 0x02, 0x42, 0x02, 0x02, 0x51, 0x01, 0x02, 0x02, 0xd2, 0x42, 0x02, 0x02,
+ 0x02, 0x42, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x21, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x32, 0x80, 0x02, 0x02,
+ 0x7f, 0x1b, 0x02, 0x00, 0x1f, 0x04, 0xff, 0x80, 0x02, 0x02, 0x02, 0x02,
+ 0x42, 0x02, 0x12, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x47,
+ 0x4f, 0x53, 0x54, 0x20, 0x52, 0x20, 0x33, 0x34, 0x2e, 0x31, 0x31, 0x2d,
+ 0x32, 0x30, 0x31, 0x32, 0x20, 0x77, 0x69, 0x74, 0x68, 0x30, 0x80, 0x60,
+ 0x02, 0x82, 0x24, 0x02, 0x02, 0x41, 0x52, 0x49, 0x41, 0x2d, 0x31, 0x32,
+ 0x38, 0x2d, 0x43, 0x46, 0x42, 0x38, 0xff, 0xff, 0xff, 0x3a, 0x5b, 0xff,
+ 0xff, 0x7f, 0x49, 0x74, 0x84, 0x00, 0x00, 0x70, 0x65, 0x00, 0x00, 0x30,
+ 0x80, 0x60, 0x02, 0x82, 0x24, 0x02, 0x02, 0x41, 0x52, 0x49, 0x41, 0x2d,
+ 0x31, 0x32, 0x38, 0x2d, 0x43, 0x46, 0x42, 0x38, 0xff, 0xff, 0xff, 0x3a,
+ 0x5b, 0xff, 0xff, 0x7f, 0x49, 0x74, 0x84, 0x00, 0x00, 0x70, 0x65, 0x33,
+ 0x28, 0xc8, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x55, 0x15, 0x15, 0x15, 0x15,
+ 0x15, 0x05, 0x15, 0x95, 0x15, 0x07, 0x07, 0x07, 0x07, 0x07, 0x00, 0x00,
+ 0x00, 0x4d, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x0b, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
+ 0x07, 0x15, 0x15, 0x15, 0x15, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
+ 0x02, 0x00, 0x25, 0x02, 0x02, 0x22, 0x3a, 0x02, 0x02, 0x02, 0x42, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0xe2, 0x80,
+};
+
/*
-* kExampleDSAKeyDER is a DSA private key in ASN.1, DER format. Of course, you
+ * kExampleDSAKeyDER is a DSA private key in ASN.1, DER format. Of course, you
* should never use this key anywhere but in an example.
*/
#ifndef OPENSSL_NO_DSA
@@ -276,7 +459,7 @@ static const unsigned char kSignature[] = {
};
/*
- * kExampleRSAKeyPKCS8 is kExampleRSAKeyDER encoded in a PKCS #8
+ * kExampleRSAKeyPKCS8 is kExampleRSAKeyDER encoded in a PKCS#8 v1
* PrivateKeyInfo.
*/
static const unsigned char kExampleRSAKeyPKCS8[] = {
@@ -335,6 +518,79 @@ static const unsigned char kExampleRSAKeyPKCS8[] = {
0x08, 0xf1, 0x2d, 0x86, 0x9d, 0xa5, 0x20, 0x1b, 0xe5, 0xdf,
};
+/*
+ * kExampleRSAKeyPKCS8 is kExampleRSAKeyDER encoded in a PKCS#8 v2
+ * PrivateKeyInfo (with an optional public key).
+ */
+static const unsigned char kExampleRSAKeyPKCS8_v2[] = {
+ 0x30, 0x82, 0x03, 0x06, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a,
+ 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82,
+ 0x02, 0x60, 0x30, 0x82, 0x02, 0x5c, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81,
+ 0x00, 0xf8, 0xb8, 0x6c, 0x83, 0xb4, 0xbc, 0xd9, 0xa8, 0x57, 0xc0, 0xa5,
+ 0xb4, 0x59, 0x76, 0x8c, 0x54, 0x1d, 0x79, 0xeb, 0x22, 0x52, 0x04, 0x7e,
+ 0xd3, 0x37, 0xeb, 0x41, 0xfd, 0x83, 0xf9, 0xf0, 0xa6, 0x85, 0x15, 0x34,
+ 0x75, 0x71, 0x5a, 0x84, 0xa8, 0x3c, 0xd2, 0xef, 0x5a, 0x4e, 0xd3, 0xde,
+ 0x97, 0x8a, 0xdd, 0xff, 0xbb, 0xcf, 0x0a, 0xaa, 0x86, 0x92, 0xbe, 0xb8,
+ 0x50, 0xe4, 0xcd, 0x6f, 0x80, 0x33, 0x30, 0x76, 0x13, 0x8f, 0xca, 0x7b,
+ 0xdc, 0xec, 0x5a, 0xca, 0x63, 0xc7, 0x03, 0x25, 0xef, 0xa8, 0x8a, 0x83,
+ 0x58, 0x76, 0x20, 0xfa, 0x16, 0x77, 0xd7, 0x79, 0x92, 0x63, 0x01, 0x48,
+ 0x1a, 0xd8, 0x7b, 0x67, 0xf1, 0x52, 0x55, 0x49, 0x4e, 0xd6, 0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, 0xd3, 0x37,
+ 0xeb, 0x41, 0xfd, 0x83, 0xf9, 0xf0, 0xa6, 0x85, 0x15, 0x34, 0x75, 0x71,
+ 0x5a, 0x84, 0xa8, 0x3c, 0xd2, 0xef, 0x5a, 0x4e, 0xd3, 0xde, 0x97, 0x8a,
+ 0xdd, 0xff, 0xbb, 0xcf, 0x0a, 0xaa, 0x86, 0x92, 0xbe, 0xb8, 0x50, 0xe4,
+ 0xcd, 0x6f, 0x80, 0x33, 0x30, 0x76, 0x13, 0x8f, 0xca, 0x7b, 0xdc, 0xec,
+ 0x5a, 0xca, 0x63, 0xc7, 0x03, 0x25, 0xef, 0xa8, 0x8a, 0x83, 0x58, 0x76,
+ 0x20, 0xfa, 0x16, 0x77, 0xd7, 0x79, 0x92, 0x63, 0x01, 0x48, 0x1a, 0xd8,
+ 0x7b, 0x67, 0xf1, 0x52, 0x55, 0x49, 0x4e, 0xd6, 0x6e, 0x4a, 0x5c, 0xd7,
+ 0x7a, 0x37, 0x36, 0x0c, 0xde, 0xdd, 0x8f, 0x44, 0xe8, 0xc2, 0xa7, 0x2c,
+ 0x2b, 0xb5, 0xaf, 0x64, 0x4b, 0x61, 0x07, 0x02, 0x03, 0x01, 0x00, 0x01
+};
+
#ifndef OPENSSL_NO_EC
/*
* kExampleECKeyDER is a sample EC private key encoded as an ECPrivateKey
@@ -354,6 +610,28 @@ static const unsigned char kExampleECKeyDER[] = {
0xc1,
};
+static const unsigned char kExampleECKeyPKCS8_v2[] = {
+ 0x30, 0x81, 0xcb, 0x02, 0x01, 0x01, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
+ 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d,
+ 0x03, 0x01, 0x07, 0x04, 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04, 0x20,
+ 0x07, 0x0f, 0x08, 0x72, 0x7a, 0xd4, 0xa0, 0x4a, 0x9c, 0xdd, 0x59, 0xc9,
+ 0x4d, 0x89, 0x68, 0x77, 0x08, 0xb5, 0x6f, 0xc9, 0x5d, 0x30, 0x77, 0x0e,
+ 0xe8, 0xd1, 0xc9, 0xce, 0x0a, 0x8b, 0xb4, 0x6a, 0xa1, 0x44, 0x03, 0x42,
+ 0x00, 0x04, 0xe6, 0x2b, 0x69, 0xe2, 0xbf, 0x65, 0x9f, 0x97, 0xbe, 0x2f,
+ 0x1e, 0x0d, 0x94, 0x8a, 0x4c, 0xd5, 0x97, 0x6b, 0xb7, 0xa9, 0x1e, 0x0d,
+ 0x46, 0xfb, 0xdd, 0xa9, 0xa9, 0x1e, 0x9d, 0xdc, 0xba, 0x5a, 0x01, 0xe7,
+ 0xd6, 0x97, 0xa8, 0x0a, 0x18, 0xf9, 0xc3, 0xc4, 0xa3, 0x1e, 0x56, 0xe2,
+ 0x7c, 0x83, 0x48, 0xdb, 0x16, 0x1a, 0x1c, 0xf5, 0x1d, 0x7e, 0xf1, 0x94,
+ 0x2d, 0x4b, 0xcf, 0x72, 0x22, 0xc1,
+ /* Optional implicit public key BIT STRING */
+ 0x81, 0x42, 0x00, 0x04, 0xe6, 0x2b, 0x69, 0xe2, 0xbf, 0x65, 0x9f, 0x97,
+ 0xbe, 0x2f, 0x1e, 0x0d, 0x94, 0x8a, 0x4c, 0xd5, 0x97, 0x6b, 0xb7, 0xa9,
+ 0x1e, 0x0d, 0x46, 0xfb, 0xdd, 0xa9, 0xa9, 0x1e, 0x9d, 0xdc, 0xba, 0x5a,
+ 0x01, 0xe7, 0xd6, 0x97, 0xa8, 0x0a, 0x18, 0xf9, 0xc3, 0xc4, 0xa3, 0x1e,
+ 0x56, 0xe2, 0x7c, 0x83, 0x48, 0xdb, 0x16, 0x1a, 0x1c, 0xf5, 0x1d, 0x7e,
+ 0xf1, 0x94, 0x2d, 0x4b, 0xcf, 0x72, 0x22, 0xc1
+};
+
/*
* kExampleBadECKeyDER is a sample EC private key encoded as an ECPrivateKey
* structure. The private key is equal to the order and will fail to import
@@ -401,6 +679,7 @@ static const unsigned char pExampleECParamDER[] = {
0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07
};
+# ifndef OPENSSL_NO_ECX
static const unsigned char kExampleED25519KeyDER[] = {
0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70,
0x04, 0x22, 0x04, 0x20, 0xba, 0x7b, 0xba, 0x20, 0x1b, 0x02, 0x75, 0x3a,
@@ -422,6 +701,7 @@ static const unsigned char kExampleX25519KeyDER[] = {
0x7b, 0x96, 0x0b, 0xd4, 0x8f, 0xd1, 0xee, 0x67, 0xf2, 0x9b, 0x88, 0xac,
0x50, 0xce, 0x97, 0x36, 0xdd, 0xaf, 0x25, 0xf6, 0x10, 0x34, 0x96, 0x6e
};
+# endif
# endif
#endif
@@ -580,6 +860,13 @@ static APK_DATA keydata[] = {
#endif
};
+static APK_DATA keydata_v2[] = {
+ {kExampleRSAKeyPKCS8_v2, sizeof(kExampleRSAKeyPKCS8_v2), "RSA", EVP_PKEY_RSA},
+#ifndef OPENSSL_NO_EC
+ {kExampleECKeyPKCS8_v2, sizeof(kExampleECKeyPKCS8_v2), "EC", EVP_PKEY_EC}
+#endif
+};
+
static APK_DATA keycheckdata[] = {
{kExampleRSAKeyDER, sizeof(kExampleRSAKeyDER), "RSA", EVP_PKEY_RSA, 1, 1, 1,
0},
@@ -594,10 +881,12 @@ static APK_DATA keycheckdata[] = {
1, 1},
{pExampleECParamDER, sizeof(pExampleECParamDER), "EC", EVP_PKEY_EC, 0, 0, 1,
2},
+# ifndef OPENSSL_NO_ECX
{kExampleED25519KeyDER, sizeof(kExampleED25519KeyDER), "ED25519",
EVP_PKEY_ED25519, 1, 1, 1, 0},
{kExampleED25519PubKeyDER, sizeof(kExampleED25519PubKeyDER), "ED25519",
EVP_PKEY_ED25519, 0, 1, 1, 1},
+# endif
#endif
};
@@ -647,7 +936,7 @@ static EVP_PKEY *load_example_dh_key(void)
}
# endif
-# ifndef OPENSSL_NO_EC
+# ifndef OPENSSL_NO_ECX
static EVP_PKEY *load_example_ed25519_key(void)
{
return load_example_key("ED25519", kExampleED25519KeyDER,
@@ -679,11 +968,33 @@ static EVP_PKEY *load_example_hmac_key(void)
return pkey;
}
+static int test_EVP_set_config_properties(void)
+{
+ char *fetched_properties = NULL;
+ const char test_propq[] = "test.fizzbuzz=buzzfizz";
+ int res = 0;
+
+ fetched_properties = EVP_get1_default_properties(OSSL_LIB_CTX_get0_global_default());
+ if (!TEST_ptr(fetched_properties)
+ || !TEST_str_eq(fetched_properties, test_propq))
+ goto err;
+ OPENSSL_free(fetched_properties);
+ fetched_properties = NULL;
+
+ res = 1;
+err:
+ OPENSSL_free(fetched_properties);
+ return res;
+}
+
static int test_EVP_set_default_properties(void)
{
OSSL_LIB_CTX *ctx;
EVP_MD *md = NULL;
int res = 0;
+ char *fetched_properties = NULL;
+ const char test_propq[] = "provider=fizzbang";
+ const char test_fips_propq[] = "fips=yes,provider=fizzbang";
if (!TEST_ptr(ctx = OSSL_LIB_CTX_new())
|| !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", NULL)))
@@ -691,18 +1002,38 @@ static int test_EVP_set_default_properties(void)
EVP_MD_free(md);
md = NULL;
- if (!TEST_true(EVP_set_default_properties(ctx, "provider=fizzbang"))
+ if (!TEST_true(EVP_set_default_properties(ctx, test_propq))
|| !TEST_ptr_null(md = EVP_MD_fetch(ctx, "sha256", NULL))
|| !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", "-provider")))
goto err;
EVP_MD_free(md);
md = NULL;
+ fetched_properties = EVP_get1_default_properties(ctx);
+ if (!TEST_ptr(fetched_properties)
+ || !TEST_str_eq(fetched_properties, test_propq))
+ goto err;
+ OPENSSL_free(fetched_properties);
+ fetched_properties = NULL;
+
+ if (!TEST_true(EVP_default_properties_enable_fips(ctx, 1)))
+ goto err;
+ fetched_properties = EVP_get1_default_properties(ctx);
+ if (!TEST_ptr(fetched_properties)
+ || !TEST_str_eq(fetched_properties, test_fips_propq))
+ goto err;
+ OPENSSL_free(fetched_properties);
+ fetched_properties = NULL;
+
+ if (!TEST_true(EVP_default_properties_enable_fips(ctx, 0)))
+ goto err;
+
if (!TEST_true(EVP_set_default_properties(ctx, NULL))
|| !TEST_ptr(md = EVP_MD_fetch(ctx, "sha256", NULL)))
goto err;
res = 1;
err:
+ OPENSSL_free(fetched_properties);
EVP_MD_free(md);
OSSL_LIB_CTX_free(ctx);
return res;
@@ -716,7 +1047,9 @@ static EVP_PKEY *make_key_fromdata(char *keytype, OSSL_PARAM *params)
if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, keytype, testpropq)))
goto err;
- if (!TEST_int_gt(EVP_PKEY_fromdata_init(pctx), 0)
+ /* Check that premature EVP_PKEY_CTX_set_params() fails gracefully */
+ if (!TEST_int_eq(EVP_PKEY_CTX_set_params(pctx, params), 0)
+ || !TEST_int_gt(EVP_PKEY_fromdata_init(pctx), 0)
|| !TEST_int_gt(EVP_PKEY_fromdata(pctx, &tmp_pkey, EVP_PKEY_KEYPAIR,
params), 0))
goto err;
@@ -1071,6 +1404,65 @@ static int test_EC_priv_pub(void)
return ret;
}
+/* Also test that we can read the EC PUB affine coordinates */
+static int test_evp_get_ec_pub(void)
+{
+ OSSL_PARAM_BLD *bld = NULL;
+ OSSL_PARAM *params = NULL;
+ unsigned char *pad = NULL;
+ EVP_PKEY *keypair = NULL;
+ BIGNUM *priv = NULL;
+ BIGNUM *x = NULL;
+ BIGNUM *y = NULL;
+ int ret = 0;
+
+ if (!TEST_ptr(priv = BN_bin2bn(ec_priv, sizeof(ec_priv), NULL)))
+ goto err;
+
+ if (!TEST_ptr(bld = OSSL_PARAM_BLD_new())
+ || !TEST_true(OSSL_PARAM_BLD_push_utf8_string(bld,
+ OSSL_PKEY_PARAM_GROUP_NAME,
+ "P-256", 0))
+ || !TEST_true(OSSL_PARAM_BLD_push_octet_string(bld,
+ OSSL_PKEY_PARAM_PUB_KEY,
+ ec_pub, sizeof(ec_pub)))
+ || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_PRIV_KEY,
+ priv)))
+ goto err;
+
+ if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld))
+ || !TEST_ptr(keypair = make_key_fromdata("EC", params)))
+ goto err;
+
+ if (!test_selection(keypair, EVP_PKEY_KEYPAIR))
+ goto err;
+
+ if (!EVP_PKEY_get_bn_param(keypair, OSSL_PKEY_PARAM_EC_PUB_X, &x)
+ || !EVP_PKEY_get_bn_param(keypair, OSSL_PKEY_PARAM_EC_PUB_Y, &y))
+ goto err;
+
+ if (!TEST_ptr(pad = OPENSSL_zalloc(sizeof(ec_pub))))
+ goto err;
+
+ pad[0] = ec_pub[0];
+ BN_bn2bin(x, &pad[1]);
+ BN_bn2bin(y, &pad[33]);
+ if (!TEST_true(memcmp(ec_pub, pad, sizeof(ec_pub)) == 0))
+ goto err;
+
+ ret = 1;
+
+err:
+ OSSL_PARAM_free(params);
+ OSSL_PARAM_BLD_free(bld);
+ EVP_PKEY_free(keypair);
+ OPENSSL_free(pad);
+ BN_free(priv);
+ BN_free(x);
+ BN_free(y);
+ return ret;
+}
+
/* Test that using a legacy EC key with only a private key in it works */
# ifndef OPENSSL_NO_DEPRECATED_3_0
static int test_EC_priv_only_legacy(void)
@@ -1138,6 +1530,76 @@ static int test_EC_priv_only_legacy(void)
return ret;
}
+
+static int test_evp_get_ec_pub_legacy(void)
+{
+ OSSL_LIB_CTX *libctx = NULL;
+ unsigned char *pad = NULL;
+ EVP_PKEY *pkey = NULL;
+ EC_KEY *eckey = NULL;
+ BIGNUM *priv = NULL;
+ BIGNUM *x = NULL;
+ BIGNUM *y = NULL;
+ int ret = 0;
+
+ if (!TEST_ptr(libctx = OSSL_LIB_CTX_new()))
+ goto err;
+
+ /* Create the legacy key */
+ if (!TEST_ptr(eckey = EC_KEY_new_by_curve_name_ex(libctx, NULL,
+ NID_X9_62_prime256v1)))
+ goto err;
+
+ if (!TEST_ptr(priv = BN_bin2bn(ec_priv, sizeof(ec_priv), NULL)))
+ goto err;
+
+ if (!TEST_true(EC_KEY_set_private_key(eckey, priv)))
+ goto err;
+
+ if (!TEST_ptr(x = BN_bin2bn(&ec_pub[1], 32, NULL)))
+ goto err;
+
+ if (!TEST_ptr(y = BN_bin2bn(&ec_pub[33], 32, NULL)))
+ goto err;
+
+ if (!TEST_true(EC_KEY_set_public_key_affine_coordinates(eckey, x, y)))
+ goto err;
+
+ if (!TEST_ptr(pkey = EVP_PKEY_new()))
+ goto err;
+
+ /* Transfer the legacy key */
+ if (!TEST_true(EVP_PKEY_assign_EC_KEY(pkey, eckey)))
+ goto err;
+ eckey = NULL;
+
+ if (!TEST_true(EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_EC_PUB_X, &x))
+ || !TEST_true(EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_EC_PUB_Y, &y)))
+ goto err;
+
+ if (!TEST_ptr(pad = OPENSSL_zalloc(sizeof(ec_pub))))
+ goto err;
+
+ pad[0] = ec_pub[0];
+ BN_bn2bin(x, &pad[1]);
+ BN_bn2bin(y, &pad[33]);
+
+ if (!TEST_true(memcmp(ec_pub, pad, sizeof(ec_pub)) == 0))
+ goto err;
+
+ ret = 1;
+
+err:
+ OSSL_LIB_CTX_free(libctx);
+ EVP_PKEY_free(pkey);
+ EC_KEY_free(eckey);
+ OPENSSL_free(pad);
+ BN_free(priv);
+ BN_free(x);
+ BN_free(y);
+
+ return ret;
+}
# endif /* OPENSSL_NO_DEPRECATED_3_0 */
#endif /* OPENSSL_NO_EC */
@@ -1153,7 +1615,7 @@ static int test_EVP_PKEY_sign(int tst)
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13
};
- if (tst == 0 ) {
+ if (tst == 0) {
if (!TEST_ptr(pkey = load_example_rsa_key()))
goto out;
} else if (tst == 1) {
@@ -1555,6 +2017,46 @@ static int test_EVP_DigestVerifyInit(void)
return ret;
}
+#ifndef OPENSSL_NO_EC
+static int test_ecdsa_digestsign_keccak(void)
+{
+ int ret = 0;
+ EVP_PKEY *pkey = NULL;
+ EVP_MD_CTX *ctx = NULL;
+ EVP_MD *md = NULL;
+
+ if (nullprov != NULL)
+ return TEST_skip("Test does not support a non-default library context");
+
+ pkey = load_example_ec_key();
+ if (!TEST_ptr(pkey))
+ goto err;
+
+ /* This would not work with FIPS provider so just use NULL libctx */
+ md = EVP_MD_fetch(NULL, "KECCAK-256", NULL);
+ if (!TEST_ptr(md))
+ goto err;
+
+ ctx = EVP_MD_CTX_new();
+ if (!TEST_ptr(ctx))
+ goto err;
+
+ /*
+ * Just check EVP_DigestSignInit_ex() works.
+ */
+ if (!TEST_true(EVP_DigestSignInit(ctx, NULL, md, NULL, pkey)))
+ goto err;
+
+ ret = 1;
+ err:
+ EVP_MD_CTX_free(ctx);
+ EVP_PKEY_free(pkey);
+ EVP_MD_free(md);
+
+ return ret;
+}
+#endif
+
#ifndef OPENSSL_NO_SIPHASH
/* test SIPHASH MAC via EVP_PKEY with non-default parameters and reinit */
static int test_siphash_digestsign(void)
@@ -1768,7 +2270,6 @@ static int test_invalide_ec_char2_pub_range_decode(int id)
return ret;
}
-/* Tests loading a bad key in PKCS8 format */
static int test_EVP_PKCS82PKEY(void)
{
int ret = 0;
@@ -1797,6 +2298,30 @@ static int test_EVP_PKCS82PKEY(void)
}
#endif
+
+static int test_EVP_PKCS82PKEY_v2(int i)
+{
+ int ret = 0;
+ const unsigned char *p;
+ const APK_DATA *ak = &keydata_v2[i];
+ const unsigned char *input = ak->kder;
+ size_t input_len = ak->size;
+ PKCS8_PRIV_KEY_INFO *p8inf = NULL;
+
+ /* Can we parse PKCS#8 v2, ignoring the public key for now? */
+ p = input;
+ p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, input_len);
+ if (!TEST_ptr(p8inf)
+ || !TEST_true(p == input + input_len))
+ goto done;
+
+ ret = 1;
+ done:
+ PKCS8_PRIV_KEY_INFO_free(p8inf);
+ return ret;
+}
+
+/* Tests loading a bad key in PKCS8 format */
static int test_EVP_PKCS82PKEY_wrong_tag(void)
{
EVP_PKEY *pkey = NULL;
@@ -2216,66 +2741,456 @@ done:
#endif
+#ifndef OPENSSL_NO_ML_KEM
+static const uint8_t ml_kem_seed[] = {
+ 0x7c, 0x99, 0x35, 0xa0, 0xb0, 0x76, 0x94, 0xaa, 0x0c, 0x6d, 0x10, 0xe4,
+ 0xdb, 0x6b, 0x1a, 0xdd, 0x2f, 0xd8, 0x1a, 0x25, 0xcc, 0xb1, 0x48, 0x03,
+ 0x2d, 0xcd, 0x73, 0x99, 0x36, 0x73, 0x7f, 0x2d, 0x86, 0x26, 0xed, 0x79,
+ 0xd4, 0x51, 0x14, 0x08, 0x00, 0xe0, 0x3b, 0x59, 0xb9, 0x56, 0xf8, 0x21,
+ 0x0e, 0x55, 0x60, 0x67, 0x40, 0x7d, 0x13, 0xdc, 0x90, 0xfa, 0x9e, 0x8b,
+ 0x87, 0x2b, 0xfb, 0x8f
+};
+static const uint8_t ml_kem_512_pubkey[] = {
+ 0x40, 0x08, 0x65, 0xed, 0x10, 0xb6, 0x19, 0xaa, 0x58, 0x11, 0x13, 0x9b,
+ 0xc0, 0x86, 0x82, 0x57, 0x82, 0xb2, 0xb7, 0x12, 0x4f, 0x75, 0x7c, 0x83,
+ 0xae, 0x79, 0x44, 0x44, 0xbc, 0x78, 0xa4, 0x78, 0x96, 0xac, 0xf1, 0x26,
+ 0x2c, 0x81, 0x35, 0x10, 0x77, 0x89, 0x3b, 0xfc, 0x56, 0xf9, 0x04, 0x49,
+ 0xc2, 0xfa, 0x5f, 0x6e, 0x58, 0x6d, 0xd3, 0x7c, 0x0b, 0x9b, 0x58, 0x19,
+ 0x92, 0x63, 0x8c, 0xb7, 0xe7, 0xbc, 0xbb, 0xb9, 0x9a, 0xfe, 0x47, 0x81,
+ 0xd8, 0x0a, 0x50, 0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73, 0x54, 0x42, 0x85, 0x1e, 0x32, 0x16, 0x16,
+ 0xd4, 0x00, 0x98, 0x10, 0x77, 0x7b, 0x6b, 0xd4, 0x6f, 0xa7, 0x22, 0x44,
+ 0x61, 0xa5, 0xcc, 0x27, 0x40, 0x5d, 0xfb, 0xac, 0x0d, 0x39, 0xb0, 0x02,
+ 0xca, 0xb3, 0x34, 0x33, 0xf2, 0xa8, 0x6e, 0xb8, 0xce, 0x91, 0xc1, 0x34,
+ 0xa6, 0x38, 0x6f, 0x86, 0x0a, 0x19, 0x94, 0xeb, 0x4b, 0x68, 0x75, 0xa4,
+ 0x6d, 0x19, 0x55, 0x81, 0xd1, 0x73, 0x85, 0x4b, 0x53, 0xd2, 0x29, 0x3d,
+ 0xf3, 0xe9, 0xa8, 0x22, 0x75, 0x6c, 0xd8, 0xf2, 0x12, 0xb3, 0x25, 0xca,
+ 0x29, 0xb4, 0xf9, 0xf8, 0xcf, 0xba, 0xdf, 0x2e, 0x41, 0x86, 0x9a, 0xbf,
+ 0xba, 0xd1, 0x07, 0x38, 0xad, 0x04, 0xcc, 0x75, 0x2b, 0xc2, 0x0c, 0x39,
+ 0x47, 0x46, 0x85, 0x0e, 0x0c, 0x48, 0x47, 0xdb
+};
+#endif
+
static struct keys_st {
int type;
- char *priv;
- char *pub;
+ const uint8_t *priv;
+ const uint8_t *pub;
+ /* If "name" is non-NULL, create via non-legacy _ex() API */
+ char *name;
+ int privlen;
+ int publen;
} keys[] = {
{
- EVP_PKEY_HMAC, "0123456789", NULL
+ EVP_PKEY_HMAC,
+ (const uint8_t *)"0123456789",
+ NULL,
+ NULL, 10, 0
},
{
- EVP_PKEY_HMAC, "", NULL
+ EVP_PKEY_HMAC, (const uint8_t *)"", NULL,
+ NULL, 0, 0
#ifndef OPENSSL_NO_POLY1305
}, {
- EVP_PKEY_POLY1305, "01234567890123456789012345678901", NULL
+ EVP_PKEY_POLY1305,
+ (const uint8_t *)"01234567890123456789012345678901",
+ NULL,
+ NULL, 32, 0
#endif
#ifndef OPENSSL_NO_SIPHASH
}, {
- EVP_PKEY_SIPHASH, "0123456789012345", NULL
+ EVP_PKEY_SIPHASH,
+ (const uint8_t *)"0123456789012345",
+ NULL,
+ NULL, 16, 0
#endif
},
-#ifndef OPENSSL_NO_EC
+#ifndef OPENSSL_NO_ECX
{
- EVP_PKEY_X25519, "01234567890123456789012345678901",
- "abcdefghijklmnopqrstuvwxyzabcdef"
+ EVP_PKEY_X25519,
+ (const uint8_t *)"01234567890123456789012345678901",
+ (const unsigned char *)"abcdefghijklmnopqrstuvwxyzabcdef",
+ NULL, 32, 32
}, {
- EVP_PKEY_ED25519, "01234567890123456789012345678901",
- "abcdefghijklmnopqrstuvwxyzabcdef"
+ EVP_PKEY_ED25519,
+ (const uint8_t *)"01234567890123456789012345678901",
+ (const uint8_t *)"abcdefghijklmnopqrstuvwxyzabcdef",
+ NULL, 32, 32
}, {
EVP_PKEY_X448,
- "01234567890123456789012345678901234567890123456789012345",
- "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd"
+ (const uint8_t *)"01234567890123456789012345678901234567890123456789012345",
+ (const uint8_t *)"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd",
+ NULL, 56, 56
}, {
EVP_PKEY_ED448,
- "012345678901234567890123456789012345678901234567890123456",
- "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde"
- }
+ (const uint8_t *)"012345678901234567890123456789012345678901234567890123456",
+ (const uint8_t *)"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde",
+ NULL, 57, 57
+ },
+#endif
+#ifndef OPENSSL_NO_ML_KEM
+ {
+ NID_undef, ml_kem_seed, ml_kem_512_pubkey,
+ "ML-KEM-512", ML_KEM_SEED_BYTES, sizeof(ml_kem_512_pubkey)
+ }, {
+ NID_undef, ml_kem_seed, ml_kem_768_pubkey,
+ "ML-KEM-768", ML_KEM_SEED_BYTES, sizeof(ml_kem_768_pubkey)
+ }, {
+ NID_undef, ml_kem_seed, ml_kem_1024_pubkey,
+ "ML-KEM-1024", ML_KEM_SEED_BYTES, sizeof(ml_kem_1024_pubkey)
+ },
#endif
};
+#ifndef OPENSSL_NO_ML_KEM
+static int
+ml_kem_seed_to_priv(const char *alg, const unsigned char *seed, int seedlen,
+ unsigned char **ret, size_t *retlen)
+{
+ OSSL_PARAM parr[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
+ EVP_PKEY_CTX *ctx = NULL;
+ EVP_PKEY *pkey = NULL;
+ const OSSL_PARAM *p;
+ OSSL_PARAM *params = NULL;
+ int selection = OSSL_KEYMGMT_SELECT_PRIVATE_KEY;
+ int ok = 0;
+
+ /* Import the seed to generate a key */
+ ctx = EVP_PKEY_CTX_new_from_name(testctx, alg, NULL);
+ if (!TEST_ptr(ctx)
+ || !TEST_int_gt(EVP_PKEY_fromdata_init(ctx), 0))
+ goto done;
+ parr[0] = OSSL_PARAM_construct_octet_string(
+ OSSL_PKEY_PARAM_ML_KEM_SEED, (unsigned char *)seed, seedlen);
+ if (!TEST_int_gt(EVP_PKEY_fromdata(ctx, &pkey, selection, parr), 0))
+ goto done;
+
+ /* Export the key to get the encoded form */
+ if (!TEST_true(EVP_PKEY_todata(pkey, OSSL_KEYMGMT_SELECT_PRIVATE_KEY, &params)))
+ goto done;
+
+ p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PRIV_KEY);
+ if (!TEST_ptr(p)
+ || !TEST_true(OSSL_PARAM_get_octet_string(p, (void **)ret, 0, retlen)))
+ goto done;
+ ok = 1;
+
+ done:
+ EVP_PKEY_free(pkey);
+ OSSL_PARAM_free(params);
+ EVP_PKEY_CTX_free(ctx);
+ return ok;
+}
+#endif
+
static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
{
int ret = 0;
- unsigned char buf[80];
- unsigned char *in;
- size_t inlen, len = 0, shortlen = 1;
- EVP_PKEY *pkey;
+ uint8_t *buf = NULL;
+ const uint8_t *in;
+ uint8_t shortbuf[1];
+ size_t inlen, len = 0, shortlen = sizeof(shortbuf);
+ EVP_PKEY *pkey = NULL;
+ unsigned char *privalloc = NULL;
+ const char *name;
/* Check if this algorithm supports public keys */
if (pub && keys[tst].pub == NULL)
return 1;
- memset(buf, 0, sizeof(buf));
+ name = keys[tst].name ? keys[tst].name : OBJ_nid2sn(keys[tst].type);
if (pub) {
#ifndef OPENSSL_NO_EC
- inlen = strlen(keys[tst].pub);
- in = (unsigned char *)keys[tst].pub;
- if (uselibctx) {
+ inlen = keys[tst].publen;
+ in = keys[tst].pub;
+ if (uselibctx || keys[tst].name != NULL) {
pkey = EVP_PKEY_new_raw_public_key_ex(
testctx,
- OBJ_nid2sn(keys[tst].type),
+ name,
NULL,
in,
inlen);
@@ -2289,11 +3204,20 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
return 1;
#endif
} else {
- inlen = strlen(keys[tst].priv);
- in = (unsigned char *)keys[tst].priv;
- if (uselibctx) {
+ inlen = keys[tst].privlen;
+ in = keys[tst].priv;
+#ifndef OPENSSL_NO_ML_KEM
+ if (in == ml_kem_seed) {
+ if (!TEST_true(ml_kem_seed_to_priv(name, in, inlen,
+ &privalloc, &inlen)))
+ goto done;
+ in = privalloc;
+ }
+#endif
+ if (uselibctx || keys[tst].name != NULL) {
pkey = EVP_PKEY_new_raw_private_key_ex(
- testctx, OBJ_nid2sn(keys[tst].type),
+ testctx,
+ name,
NULL,
in,
inlen);
@@ -2316,12 +3240,14 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
* Test that supplying a buffer that is too small fails. Doesn't apply
* to HMAC with a zero length key
*/
- if ((!pub && !TEST_false(EVP_PKEY_get_raw_private_key(pkey, buf,
+ if ((!pub && !TEST_false(EVP_PKEY_get_raw_private_key(pkey, shortbuf,
&shortlen)))
- || (pub && !TEST_false(EVP_PKEY_get_raw_public_key(pkey, buf,
+ || (pub && !TEST_false(EVP_PKEY_get_raw_public_key(pkey, shortbuf,
&shortlen))))
goto done;
}
+ if (!TEST_ptr(buf = OPENSSL_zalloc(len <= 80 ? 80 : len)))
+ goto done;
if ((!pub && !TEST_true(EVP_PKEY_get_raw_private_key(pkey, buf, &len)))
|| (pub && !TEST_true(EVP_PKEY_get_raw_public_key(pkey, buf, &len)))
|| !TEST_mem_eq(in, inlen, buf, len))
@@ -2329,6 +3255,8 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx)
ret = 1;
done:
+ OPENSSL_free(privalloc);
+ OPENSSL_free(buf);
EVP_PKEY_free(pkey);
return ret;
}
@@ -2398,7 +3326,9 @@ static int test_EVP_PKEY_check(int i)
#ifndef OPENSSL_NO_DEPRECATED_3_0
ctx2 = EVP_PKEY_CTX_new_id(0xdefaced, NULL);
/* assign the pkey directly, as an internal test */
- EVP_PKEY_up_ref(pkey);
+ if (!EVP_PKEY_up_ref(pkey))
+ goto done;
+
ctx2->pkey = pkey;
if (!TEST_int_eq(EVP_PKEY_check(ctx2), 0xbeef))
@@ -2470,7 +3400,7 @@ static int test_CMAC_keygen(void)
if (!TEST_int_gt(EVP_PKEY_keygen_init(kctx), 0)
|| !TEST_int_gt(EVP_PKEY_CTX_ctrl(kctx, -1, EVP_PKEY_OP_KEYGEN,
EVP_PKEY_CTRL_CIPHER,
- 0, (void *)EVP_aes_256_ecb()), 0)
+ 0, (void *)EVP_aes_256_cbc()), 0)
|| !TEST_int_gt(EVP_PKEY_CTX_ctrl(kctx, -1, EVP_PKEY_OP_KEYGEN,
EVP_PKEY_CTRL_SET_MAC_KEY,
sizeof(key), (void *)key), 0)
@@ -2486,7 +3416,7 @@ static int test_CMAC_keygen(void)
* Test a CMAC key using the direct method, and compare with the mac
* created above.
*/
- pkey = EVP_PKEY_new_CMAC_key(NULL, key, sizeof(key), EVP_aes_256_ecb());
+ pkey = EVP_PKEY_new_CMAC_key(NULL, key, sizeof(key), EVP_aes_256_cbc());
if (!TEST_ptr(pkey)
|| !TEST_true(get_cmac_val(pkey, mac2))
|| !TEST_mem_eq(mac, sizeof(mac), mac2, sizeof(mac2)))
@@ -3005,6 +3935,70 @@ static int test_RSA_OAEP_set_null_label(void)
return ret;
}
+#ifndef OPENSSL_NO_DEPRECATED_3_0
+static int test_RSA_legacy(void)
+{
+ int ret = 0;
+ BIGNUM *p = NULL;
+ BIGNUM *q = NULL;
+ BIGNUM *n = NULL;
+ BIGNUM *e = NULL;
+ BIGNUM *d = NULL;
+ const EVP_MD *md = EVP_sha256();
+ EVP_MD_CTX *ctx = NULL;
+ EVP_PKEY *pkey = NULL;
+ RSA *rsa = NULL;
+
+ if (nullprov != NULL)
+ return TEST_skip("Test does not support a non-default library context");
+
+ if (!TEST_ptr(p = BN_dup(BN_value_one()))
+ || !TEST_ptr(q = BN_dup(BN_value_one()))
+ || !TEST_ptr(n = BN_dup(BN_value_one()))
+ || !TEST_ptr(e = BN_dup(BN_value_one()))
+ || !TEST_ptr(d = BN_dup(BN_value_one())))
+ goto err;
+
+ if (!TEST_ptr(rsa = RSA_new())
+ || !TEST_ptr(pkey = EVP_PKEY_new())
+ || !TEST_ptr(ctx = EVP_MD_CTX_new()))
+ goto err;
+
+ if (!TEST_true(RSA_set0_factors(rsa, p, q)))
+ goto err;
+ p = NULL;
+ q = NULL;
+
+ if (!TEST_true(RSA_set0_key(rsa, n, e, d)))
+ goto err;
+ n = NULL;
+ e = NULL;
+ d = NULL;
+
+ if (!TEST_true(EVP_PKEY_assign_RSA(pkey, rsa)))
+ goto err;
+
+ rsa = NULL;
+
+ if (!TEST_true(EVP_DigestSignInit(ctx, NULL, md, NULL, pkey)))
+ goto err;
+
+ ret = 1;
+
+err:
+ RSA_free(rsa);
+ EVP_MD_CTX_free(ctx);
+ EVP_PKEY_free(pkey);
+ BN_free(p);
+ BN_free(q);
+ BN_free(n);
+ BN_free(e);
+ BN_free(d);
+
+ return ret;
+}
+#endif
+
#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
static int test_decrypt_null_chunks(void)
{
@@ -3223,9 +4217,9 @@ static int test_pkey_ctx_fail_without_provider(int tst)
/*
* We check for certain algos in the null provider.
- * If an algo is expected to have a provider keymgmt, contructing an
+ * If an algo is expected to have a provider keymgmt, constructing an
* EVP_PKEY_CTX is expected to fail (return NULL).
- * Otherwise, if it's expected to have legacy support, contructing an
+ * Otherwise, if it's expected to have legacy support, constructing an
* EVP_PKEY_CTX is expected to succeed (return non-NULL).
*/
switch (tst) {
@@ -3306,28 +4300,43 @@ static int test_evp_iv_aes(int idx)
{
int ret = 0;
EVP_CIPHER_CTX *ctx = NULL;
- unsigned char key[16] = {0x4c, 0x43, 0xdb, 0xdd, 0x42, 0x73, 0x47, 0xd1,
- 0xe5, 0x62, 0x7d, 0xcd, 0x4d, 0x76, 0x4d, 0x57};
- unsigned char init_iv[EVP_MAX_IV_LENGTH] =
- {0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b, 0x98, 0x82,
- 0x5a, 0x55, 0x91, 0x81, 0x42, 0xa8, 0x89, 0x34};
- static const unsigned char msg[] = { 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16 };
+ unsigned char key[16] = {
+ 0x4c, 0x43, 0xdb, 0xdd, 0x42, 0x73, 0x47, 0xd1,
+ 0xe5, 0x62, 0x7d, 0xcd, 0x4d, 0x76, 0x4d, 0x57
+ };
+ unsigned char init_iv[EVP_MAX_IV_LENGTH] = {
+ 0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b, 0x98, 0x82,
+ 0x5a, 0x55, 0x91, 0x81, 0x42, 0xa8, 0x89, 0x34
+ };
+ static const unsigned char msg[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16
+ };
unsigned char ciphertext[32], oiv[16], iv[16];
unsigned char *ref_iv;
- unsigned char cbc_state[16] = {0x10, 0x2f, 0x05, 0xcc, 0xc2, 0x55, 0x72, 0xb9,
- 0x88, 0xe6, 0x4a, 0x17, 0x10, 0x74, 0x22, 0x5e};
-
- unsigned char ofb_state[16] = {0x76, 0xe6, 0x66, 0x61, 0xd0, 0x8a, 0xe4, 0x64,
- 0xdd, 0x66, 0xbf, 0x00, 0xf0, 0xe3, 0x6f, 0xfd};
- unsigned char cfb_state[16] = {0x77, 0xe4, 0x65, 0x65, 0xd5, 0x8c, 0xe3, 0x6c,
- 0xd4, 0x6c, 0xb4, 0x0c, 0xfd, 0xed, 0x60, 0xed};
- unsigned char gcm_state[12] = {0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b,
- 0x98, 0x82, 0x5a, 0x55, 0x91, 0x81};
- unsigned char ccm_state[7] = {0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b, 0x98};
+ unsigned char cbc_state[16] = {
+ 0x10, 0x2f, 0x05, 0xcc, 0xc2, 0x55, 0x72, 0xb9,
+ 0x88, 0xe6, 0x4a, 0x17, 0x10, 0x74, 0x22, 0x5e
+ };
+
+ unsigned char ofb_state[16] = {
+ 0x76, 0xe6, 0x66, 0x61, 0xd0, 0x8a, 0xe4, 0x64,
+ 0xdd, 0x66, 0xbf, 0x00, 0xf0, 0xe3, 0x6f, 0xfd
+ };
+ unsigned char cfb_state[16] = {
+ 0x77, 0xe4, 0x65, 0x65, 0xd5, 0x8c, 0xe3, 0x6c,
+ 0xd4, 0x6c, 0xb4, 0x0c, 0xfd, 0xed, 0x60, 0xed
+ };
+ unsigned char gcm_state[12] = {
+ 0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b,
+ 0x98, 0x82, 0x5a, 0x55, 0x91, 0x81
+ };
+ unsigned char ccm_state[7] = { 0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b, 0x98 };
#ifndef OPENSSL_NO_OCB
- unsigned char ocb_state[12] = {0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b,
- 0x98, 0x82, 0x5a, 0x55, 0x91, 0x81};
+ unsigned char ocb_state[12] = {
+ 0x57, 0x71, 0x7d, 0xad, 0xdb, 0x9b,
+ 0x98, 0x82, 0x5a, 0x55, 0x91, 0x81
+ };
#endif
int len = sizeof(ciphertext);
size_t ivlen, ref_len;
@@ -3337,7 +4346,7 @@ static int test_evp_iv_aes(int idx)
if (nullprov != NULL && idx < 6)
return TEST_skip("Test does not support a non-default library context");
- switch(idx) {
+ switch (idx) {
case 0:
type = EVP_aes_128_cbc();
/* FALLTHROUGH */
@@ -3415,6 +4424,10 @@ static int test_evp_iv_aes(int idx)
|| !TEST_true(EVP_EncryptFinal_ex(ctx, ciphertext, &len)))
goto err;
ivlen = EVP_CIPHER_CTX_get_iv_length(ctx);
+
+ if (!TEST_int_gt(ivlen, 0))
+ goto err;
+
if (!TEST_mem_eq(init_iv, ivlen, oiv, ivlen)
|| !TEST_mem_eq(ref_iv, ref_len, iv, ivlen))
goto err;
@@ -3452,8 +4465,10 @@ static int test_evp_iv_des(int idx)
static const unsigned char init_iv[8] = {
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
};
- static const unsigned char msg[] = { 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 11, 12, 13, 14, 15, 16 };
+ static const unsigned char msg[] = {
+ 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16
+ };
unsigned char ciphertext[32], oiv[8], iv[8];
unsigned const char *ref_iv;
static const unsigned char cbc_state_des[8] = {
@@ -3481,7 +4496,7 @@ static int test_evp_iv_des(int idx)
if (lgcyprov == NULL && idx < 3)
return TEST_skip("Test requires legacy provider to be loaded");
- switch(idx) {
+ switch (idx) {
case 0:
type = EVP_CIPHER_fetch(testctx, "des-cbc", testpropq);
ref_iv = cbc_state_des;
@@ -3526,6 +4541,10 @@ static int test_evp_iv_des(int idx)
|| !TEST_true(EVP_EncryptFinal_ex(ctx, ciphertext, &len)))
goto err;
ivlen = EVP_CIPHER_CTX_get_iv_length(ctx);
+
+ if (!TEST_int_gt(ivlen, 0))
+ goto err;
+
if (!TEST_mem_eq(init_iv, ivlen, oiv, ivlen)
|| !TEST_mem_eq(ref_iv, ref_len, iv, ivlen))
goto err;
@@ -3692,6 +4711,19 @@ static int test_EVP_rsa_pss_set_saltlen(void)
return ret;
}
+static int test_EVP_rsa_invalid_key(void)
+{
+ int ret = 0;
+ EVP_PKEY *pkey = NULL;
+
+ pkey = load_example_key("RSA", kInvalidRSAKeyDER, sizeof(kInvalidRSAKeyDER));
+ /* we expect to fail to load bogus key */
+ ret = !TEST_ptr(pkey);
+ EVP_PKEY_free(pkey);
+
+ return ret;
+}
+
static int success = 1;
static void md_names(const char *name, void *vctx)
{
@@ -3830,7 +4862,7 @@ static const EVP_INIT_TEST_st evp_reinit_tests[] = {
static int evp_init_seq_set_iv(EVP_CIPHER_CTX *ctx, const EVP_INIT_TEST_st *t)
{
int res = 0;
-
+
if (t->ivlen != 0) {
if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, t->ivlen, NULL), 0))
goto err;
@@ -4140,7 +5172,8 @@ static int test_evp_updated_iv(int idx)
errmsg = "CIPHER_CTX_GET_UPDATED_IV";
goto err;
}
- if (!TEST_true(iv_len = EVP_CIPHER_CTX_get_iv_length(ctx))) {
+ iv_len = EVP_CIPHER_CTX_get_iv_length(ctx);
+ if (!TEST_int_ge(iv_len,0)) {
errmsg = "CIPHER_CTX_GET_IV_LEN";
goto err;
}
@@ -4513,7 +5546,7 @@ static int test_custom_pmeth(int idx)
if (testctx != NULL)
return 1;
- switch(idx) {
+ switch (idx) {
case 0:
case 6:
id = EVP_PKEY_RSA;
@@ -4539,7 +5572,7 @@ static int test_custom_pmeth(int idx)
# endif
case 3:
case 9:
-# ifndef OPENSSL_NO_EC
+# ifndef OPENSSL_NO_ECX
id = EVP_PKEY_ED25519;
md = NULL;
pkey = load_example_ed25519_key();
@@ -4559,7 +5592,7 @@ static int test_custom_pmeth(int idx)
# endif
case 5:
case 11:
-# ifndef OPENSSL_NO_EC
+# ifndef OPENSSL_NO_ECX
id = EVP_PKEY_X25519;
doderive = 1;
pkey = load_example_x25519_key();
@@ -4720,6 +5753,7 @@ static int custom_md_cleanup(EVP_MD_CTX *ctx)
static int test_custom_md_meth(void)
{
+ ASN1_OBJECT *o = NULL;
EVP_MD_CTX *mdctx = NULL;
EVP_MD *tmp = NULL;
char mess[] = "Test Message\n";
@@ -4765,8 +5799,21 @@ static int test_custom_md_meth(void)
|| !TEST_int_eq(custom_md_cleanup_called, 1))
goto err;
+ if (!TEST_int_eq(OBJ_create("1.3.6.1.4.1.16604.998866.1",
+ "custom-md", "custom-md"), NID_undef)
+ || !TEST_int_eq(ERR_GET_LIB(ERR_peek_error()), ERR_LIB_OBJ)
+ || !TEST_int_eq(ERR_GET_REASON(ERR_get_error()), OBJ_R_OID_EXISTS))
+ goto err;
+
+ o = ASN1_OBJECT_create(nid, (unsigned char *)
+ "\53\6\1\4\1\201\201\134\274\373\122\1", 12,
+ "custom-md", "custom-md");
+ if (!TEST_int_eq(OBJ_add_object(o), nid))
+ goto err;
+
testresult = 1;
err:
+ ASN1_OBJECT_free(o);
EVP_MD_CTX_free(mdctx);
EVP_MD_meth_free(tmp);
return testresult;
@@ -4883,6 +5930,11 @@ static int test_signatures_with_engine(int tst)
if (tst <= 1)
return 1;
# endif
+# ifdef OPENSSL_NO_ECX
+ /* Skip ECX tests in a no-ecx build */
+ if (tst == 2)
+ return 1;
+# endif
if (!TEST_ptr(e = ENGINE_by_id(engine_id)))
return 0;
@@ -4996,6 +6048,7 @@ static int test_cipher_with_engine(void)
# endif /* OPENSSL_NO_DYNAMIC_ENGINE */
#endif /* OPENSSL_NO_DEPRECATED_3_0 */
+#ifndef OPENSSL_NO_ECX
static int ecxnids[] = {
NID_X25519,
NID_X448,
@@ -5019,11 +6072,13 @@ static int test_ecx_short_keys(int tst)
return 1;
}
+#endif
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
OPT_CONTEXT,
+ OPT_CONFIG_FILE,
OPT_TEST_ENUM
} OPTION_CHOICE;
@@ -5032,12 +6087,14 @@ const OPTIONS *test_get_options(void)
static const OPTIONS options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
{ "context", OPT_CONTEXT, '-', "Explicitly use a non-default library context" },
+ { "config", OPT_CONFIG_FILE, '<',
+ "The configuration file to use for the libctx" },
{ NULL }
};
return options;
}
-#ifndef OPENSSL_NO_EC
+#ifndef OPENSSL_NO_ECX
/* Test that trying to sign with a public key errors out gracefully */
static int test_ecx_not_private_key(int tst)
{
@@ -5048,21 +6105,22 @@ static int test_ecx_not_private_key(int tst)
EVP_MD_CTX *ctx = NULL;
unsigned char *mac = NULL;
size_t maclen = 0;
- unsigned char *pubkey;
+ const uint8_t *pubkey;
size_t pubkeylen;
switch (keys[tst].type) {
case NID_X25519:
case NID_X448:
- return TEST_skip("signing not supported for X25519/X448");
+ case NID_undef:
+ return TEST_skip("signing not supported for X25519/X448/ML-KEM");
}
/* Check if this algorithm supports public keys */
if (keys[tst].pub == NULL)
return TEST_skip("no public key present");
- pubkey = (unsigned char *)keys[tst].pub;
- pubkeylen = strlen(keys[tst].pub);
+ pubkey = keys[tst].pub;
+ pubkeylen = keys[tst].publen;
pkey = EVP_PKEY_new_raw_public_key_ex(testctx, OBJ_nid2sn(keys[tst].type),
NULL, pubkey, pubkeylen);
@@ -5102,7 +6160,66 @@ static int test_ecx_not_private_key(int tst)
return testresult;
}
-#endif /* OPENSSL_NO_EC */
+#endif /* OPENSSL_NO_ECX */
+
+static int test_sign_continuation(void)
+{
+ OSSL_PROVIDER *fake_rsa = NULL;
+ int testresult = 0;
+ EVP_PKEY *pkey = NULL;
+ EVP_PKEY_CTX *pctx = NULL;
+ EVP_MD_CTX *mctx = NULL;
+ const char sigbuf[] = "To Be Signed";
+ unsigned char signature[256];
+ size_t siglen = 256;
+ static int nodupnum = 1;
+ static const OSSL_PARAM nodup_params[] = {
+ OSSL_PARAM_int("NO_DUP", &nodupnum),
+ OSSL_PARAM_END
+ };
+
+ if (!TEST_ptr(fake_rsa = fake_rsa_start(testctx)))
+ return 0;
+
+ /* Construct a pkey using precise propq to use our provider */
+ if (!TEST_ptr(pctx = EVP_PKEY_CTX_new_from_name(testctx, "RSA",
+ "provider=fake-rsa"))
+ || !TEST_true(EVP_PKEY_fromdata_init(pctx))
+ || !TEST_true(EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_KEYPAIR, NULL))
+ || !TEST_ptr(pkey))
+ goto end;
+
+ /* First test it continues (classic behavior) */
+ if (!TEST_ptr(mctx = EVP_MD_CTX_new())
+ || !TEST_true(EVP_DigestSignInit_ex(mctx, NULL, NULL, testctx,
+ NULL, pkey, NULL))
+ || !TEST_true(EVP_DigestSignUpdate(mctx, sigbuf, sizeof(sigbuf)))
+ || !TEST_true(EVP_DigestSignFinal(mctx, signature, &siglen))
+ || !TEST_true(EVP_DigestSignUpdate(mctx, sigbuf, sizeof(sigbuf)))
+ || !TEST_true(EVP_DigestSignFinal(mctx, signature, &siglen)))
+ goto end;
+
+ EVP_MD_CTX_free(mctx);
+
+ /* try again but failing the continuation */
+ if (!TEST_ptr(mctx = EVP_MD_CTX_new())
+ || !TEST_true(EVP_DigestSignInit_ex(mctx, NULL, NULL, testctx,
+ NULL, pkey, nodup_params))
+ || !TEST_true(EVP_DigestSignUpdate(mctx, sigbuf, sizeof(sigbuf)))
+ || !TEST_true(EVP_DigestSignFinal(mctx, signature, &siglen))
+ || !TEST_false(EVP_DigestSignUpdate(mctx, sigbuf, sizeof(sigbuf)))
+ || !TEST_false(EVP_DigestSignFinal(mctx, signature, &siglen)))
+ goto end;
+
+ testresult = 1;
+
+end:
+ EVP_MD_CTX_free(mctx);
+ EVP_PKEY_free(pkey);
+ EVP_PKEY_CTX_free(pctx);
+ fake_rsa_finish(fake_rsa);
+ return testresult;
+}
static int aes_gcm_encrypt(const unsigned char *gcm_key, size_t gcm_key_s,
const unsigned char *gcm_iv, size_t gcm_ivlen,
@@ -5370,8 +6487,223 @@ static int test_invalid_ctx_for_digest(void)
return ret;
}
+static int test_evp_cipher_pipeline(void)
+{
+ OSSL_PROVIDER *fake_pipeline = NULL;
+ int testresult = 0;
+ EVP_CIPHER *cipher = NULL;
+ EVP_CIPHER *pipeline_cipher = NULL;
+ EVP_CIPHER_CTX *ctx = NULL;
+ unsigned char key[32];
+ size_t keylen = 32;
+ size_t ivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_FIXED_IV_LEN;
+ size_t taglen = EVP_GCM_TLS_TAG_LEN;
+ unsigned char *iv_array[EVP_MAX_PIPES], *tag_array[EVP_MAX_PIPES];
+ unsigned char *plaintext_array[EVP_MAX_PIPES];
+ unsigned char *ciphertext_array_p[EVP_MAX_PIPES];
+ void **aead_tags = (void **)&tag_array;
+ unsigned char *temp[EVP_MAX_PIPES];
+ size_t outsize_array[EVP_MAX_PIPES], outlen_array[EVP_MAX_PIPES];
+ size_t ciphertextlen_array[EVP_MAX_PIPES];
+ size_t inlen_array[EVP_MAX_PIPES];
+ OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END };
+ unsigned char *ciphertext, *exp_plaintext, *tag;
+ size_t numpipes, plaintextlen, i;
+
+ if (!TEST_ptr(fake_pipeline = fake_pipeline_start(testctx)))
+ return 0;
+ if (!TEST_ptr(pipeline_cipher = EVP_CIPHER_fetch(testctx, "AES-256-GCM",
+ "provider=fake-pipeline"))
+ || !TEST_ptr(cipher = EVP_CIPHER_fetch(testctx, "AES-256-GCM",
+ "provider!=fake-pipeline"))
+ || !TEST_ptr(ctx = EVP_CIPHER_CTX_new()))
+ goto end;
+ memset(key, 0x01, sizeof(key));
+
+ /* Negative tests */
+ if (!TEST_false(EVP_CIPHER_can_pipeline(cipher, 1)))
+ goto end;
+ if (!TEST_false(EVP_CIPHER_can_pipeline(EVP_aes_256_gcm(), 1)))
+ goto end;
+ if (!TEST_false(EVP_CipherPipelineEncryptInit(ctx, pipeline_cipher,
+ key, keylen,
+ EVP_MAX_PIPES + 1, NULL, 0)))
+ goto end;
+
+ /* Positive tests */
+ for (numpipes = 1; numpipes <= EVP_MAX_PIPES; numpipes++) {
+ for (plaintextlen = 1; plaintextlen <= 256; plaintextlen++) {
+ size_t ciphertextlen = 0;
+ int outlen = 0;
+
+ /* Cleanup to be able to error out */
+ memset(iv_array, 0, sizeof(iv_array));
+ memset(plaintext_array, 0, sizeof(plaintext_array));
+ memset(ciphertext_array_p, 0, sizeof(ciphertext_array_p));
+ memset(tag_array, 0, sizeof(tag_array));
+ ciphertext = NULL;
+ exp_plaintext = NULL;
+ tag = NULL;
+
+ /* Allocate fresh buffers with exact size to catch buffer overwrites */
+ for (i = 0; i < numpipes; i++) {
+ if (!TEST_ptr(iv_array[i] = OPENSSL_malloc(ivlen))
+ || !TEST_ptr(plaintext_array[i] = OPENSSL_malloc(plaintextlen))
+ || !TEST_ptr(ciphertext_array_p[i] =
+ OPENSSL_malloc(plaintextlen + EVP_MAX_BLOCK_LENGTH))
+ || !TEST_ptr(tag_array[i] = OPENSSL_malloc(taglen)))
+ goto err;
+
+ memset(iv_array[i], i + 33, ivlen);
+ memset(plaintext_array[i], i + 1, plaintextlen);
+ inlen_array[i] = plaintextlen;
+ outlen_array[i] = 0;
+ ciphertextlen_array[i] = 0;
+ outsize_array[i] = plaintextlen + EVP_MAX_BLOCK_LENGTH;
+ }
+ if (!TEST_ptr(ciphertext =
+ OPENSSL_malloc(plaintextlen + EVP_MAX_BLOCK_LENGTH))
+ || !TEST_ptr(tag = OPENSSL_malloc(taglen))
+ || !TEST_ptr(exp_plaintext = OPENSSL_malloc(plaintextlen)))
+ goto err;
+
+ /* Encrypt using pipeline API */
+ if (!TEST_true(EVP_CIPHER_CTX_reset(ctx))
+ || !TEST_true(EVP_CIPHER_can_pipeline(pipeline_cipher, 1))
+ || !TEST_true(EVP_CipherPipelineEncryptInit(ctx, pipeline_cipher,
+ key, keylen, numpipes,
+ (const unsigned char **)iv_array,
+ ivlen))
+ /* reuse plaintext for AAD as it won't affect test */
+ || !TEST_true(EVP_CipherPipelineUpdate(ctx, NULL, outlen_array, NULL,
+ (const unsigned char **)plaintext_array,
+ inlen_array))
+ || !TEST_true(EVP_CipherPipelineUpdate(ctx, ciphertext_array_p,
+ outlen_array, outsize_array,
+ (const unsigned char **)plaintext_array,
+ inlen_array)))
+ goto err;
+
+ for (i = 0; i < numpipes; i++) {
+ ciphertextlen_array[i] = outlen_array[i];
+ temp[i] = ciphertext_array_p[i] + ciphertextlen_array[i];
+ outsize_array[i] = outsize_array[i] - ciphertextlen_array[i];
+ }
+
+ if (!TEST_true(EVP_CipherPipelineFinal(ctx, temp, outlen_array, outsize_array)))
+ goto err;
+
+ for (i = 0; i < numpipes; i++)
+ ciphertextlen_array[i] += outlen_array[i];
+
+ params[0] = OSSL_PARAM_construct_octet_ptr(OSSL_CIPHER_PARAM_PIPELINE_AEAD_TAG,
+ (void **)&aead_tags, taglen);
+ if (!TEST_true(EVP_CIPHER_CTX_get_params(ctx, params)))
+ goto err;
+
+ /* Encrypt using non-pipeline API and compare */
+ if (!TEST_true(EVP_CIPHER_CTX_reset(ctx)))
+ goto err;
+
+ for (i = 0; i < numpipes; i++) {
+ if (!TEST_true(EVP_EncryptInit(ctx, cipher, key, iv_array[i]))
+ || !TEST_true(EVP_EncryptUpdate(ctx, NULL, &outlen,
+ plaintext_array[i],
+ plaintextlen))
+ || !TEST_true(EVP_EncryptUpdate(ctx, ciphertext, &outlen,
+ plaintext_array[i],
+ plaintextlen)))
+ goto err;
+ ciphertextlen = outlen;
+
+ if (!TEST_true(EVP_EncryptFinal_ex(ctx, ciphertext + outlen, &outlen)))
+ goto err;
+ ciphertextlen += outlen;
+
+ params[0] = OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_AEAD_TAG,
+ (void *)tag, taglen);
+ if (!TEST_true(EVP_CIPHER_CTX_get_params(ctx, params)))
+ goto err;
+
+ if (!TEST_mem_eq(ciphertext_array_p[i], ciphertextlen_array[i],
+ ciphertext, ciphertextlen)
+ || !TEST_mem_eq(tag_array[i], taglen, tag, taglen))
+ goto err;
+ }
+
+ for (i = 0; i < numpipes; i++)
+ outsize_array[i] = plaintextlen;
+
+ /* Decrypt using pipeline API and compare */
+ params[0] = OSSL_PARAM_construct_octet_ptr(OSSL_CIPHER_PARAM_PIPELINE_AEAD_TAG,
+ (void **)&aead_tags, taglen);
+ if (!TEST_true(EVP_CIPHER_CTX_reset(ctx))
+ || !TEST_true(EVP_CIPHER_can_pipeline(pipeline_cipher, 0))
+ || !TEST_true(EVP_CipherPipelineDecryptInit(ctx, pipeline_cipher,
+ key, keylen, numpipes,
+ (const unsigned char **)iv_array,
+ ivlen))
+ || !TEST_true(EVP_CIPHER_CTX_set_params(ctx, params))
+ || !TEST_true(EVP_CipherPipelineUpdate(ctx, NULL, outlen_array, NULL,
+ (const unsigned char **)plaintext_array,
+ inlen_array))
+ || !TEST_true(EVP_CipherPipelineUpdate(ctx, plaintext_array,
+ outlen_array, outsize_array,
+ (const unsigned char **)ciphertext_array_p,
+ ciphertextlen_array)))
+ goto err;
+
+ for (i = 0; i < numpipes; i++) {
+ temp[i] = plaintext_array[i] + outlen_array[i];
+ outsize_array[i] = outsize_array[i] - outlen_array[i];
+ }
+
+ if (!TEST_true(EVP_CipherPipelineFinal(ctx, temp, outlen_array, outsize_array)))
+ goto err;
+
+ for (i = 0; i < numpipes; i++) {
+ memset(exp_plaintext, i + 1, plaintextlen);
+ if (!TEST_mem_eq(plaintext_array[i], plaintextlen,
+ exp_plaintext, plaintextlen))
+ goto err;
+ }
+
+ for (i = 0; i < numpipes; i++) {
+ OPENSSL_free(iv_array[i]);
+ OPENSSL_free(plaintext_array[i]);
+ OPENSSL_free(ciphertext_array_p[i]);
+ OPENSSL_free(tag_array[i]);
+ }
+ OPENSSL_free(exp_plaintext);
+ OPENSSL_free(ciphertext);
+ OPENSSL_free(tag);
+ }
+ }
+
+ testresult = 1;
+ goto end;
+
+err:
+ for (i = 0; i < numpipes; i++) {
+ OPENSSL_free(iv_array[i]);
+ OPENSSL_free(plaintext_array[i]);
+ OPENSSL_free(ciphertext_array_p[i]);
+ OPENSSL_free(tag_array[i]);
+ }
+ OPENSSL_free(exp_plaintext);
+ OPENSSL_free(ciphertext);
+ OPENSSL_free(tag);
+end:
+ EVP_CIPHER_CTX_free(ctx);
+ EVP_CIPHER_free(cipher);
+ EVP_CIPHER_free(pipeline_cipher);
+ fake_pipeline_finish(fake_pipeline);
+ return testresult;
+}
+
int setup_tests(void)
{
+ char *config_file = NULL;
OPTION_CHOICE o;
while ((o = opt_next()) != OPT_EOF) {
@@ -5382,18 +6714,25 @@ int setup_tests(void)
if (!TEST_ptr(testctx))
return 0;
#ifdef STATIC_LEGACY
- /*
- * This test is always statically linked against libcrypto. We must not
- * attempt to load legacy.so that might be dynamically linked against
- * libcrypto. Instead we use a built-in version of the legacy provider.
- */
- if (!OSSL_PROVIDER_add_builtin(testctx, "legacy", ossl_legacy_provider_init))
- return 0;
+ /*
+ * This test is always statically linked against libcrypto. We must not
+ * attempt to load legacy.so that might be dynamically linked against
+ * libcrypto. Instead we use a built-in version of the legacy provider.
+ */
+ if (!OSSL_PROVIDER_add_builtin(testctx, "legacy", ossl_legacy_provider_init))
+ return 0;
#endif
/* Swap the libctx to test non-default context only */
nullprov = OSSL_PROVIDER_load(NULL, "null");
deflprov = OSSL_PROVIDER_load(testctx, "default");
+#ifndef OPENSSL_SYS_TANDEM
lgcyprov = OSSL_PROVIDER_load(testctx, "legacy");
+#endif
+ break;
+ case OPT_CONFIG_FILE:
+ config_file = opt_arg();
+ if (!test_get_libctx(&testctx, &nullprov, config_file, NULL, NULL))
+ return 0;
break;
case OPT_TEST_CASES:
break;
@@ -5402,9 +6741,17 @@ int setup_tests(void)
}
}
+ if (config_file != NULL) {
+ ADD_TEST(test_EVP_set_config_properties);
+ return 1;
+ }
+
ADD_TEST(test_EVP_set_default_properties);
ADD_ALL_TESTS(test_EVP_DigestSignInit, 30);
ADD_TEST(test_EVP_DigestVerifyInit);
+#ifndef OPENSSL_NO_EC
+ ADD_TEST(test_ecdsa_digestsign_keccak);
+#endif
#ifndef OPENSSL_NO_SIPHASH
ADD_TEST(test_siphash_digestsign);
#endif
@@ -5418,6 +6765,7 @@ int setup_tests(void)
ADD_ALL_TESTS(test_d2i_AutoPrivateKey, OSSL_NELEM(keydata));
ADD_TEST(test_privatekey_to_pkcs8);
ADD_TEST(test_EVP_PKCS82PKEY_wrong_tag);
+ ADD_ALL_TESTS(test_EVP_PKCS82PKEY_v2, OSSL_NELEM(keydata_v2));
#ifndef OPENSSL_NO_EC
ADD_TEST(test_EVP_PKCS82PKEY);
#endif
@@ -5459,6 +6807,9 @@ int setup_tests(void)
ADD_TEST(test_RSA_get_set_params);
ADD_TEST(test_RSA_OAEP_set_get_params);
ADD_TEST(test_RSA_OAEP_set_null_label);
+#ifndef OPENSSL_NO_DEPRECATED_3_0
+ ADD_TEST(test_RSA_legacy);
+#endif
#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
ADD_TEST(test_decrypt_null_chunks);
#endif
@@ -5470,8 +6821,10 @@ int setup_tests(void)
#endif
#ifndef OPENSSL_NO_EC
ADD_TEST(test_EC_priv_pub);
+ ADD_TEST(test_evp_get_ec_pub);
# ifndef OPENSSL_NO_DEPRECATED_3_0
ADD_TEST(test_EC_priv_only_legacy);
+ ADD_TEST(test_evp_get_ec_pub_legacy);
# endif
#endif
ADD_ALL_TESTS(test_keygen_with_empty_template, 2);
@@ -5487,6 +6840,7 @@ int setup_tests(void)
#endif
ADD_TEST(test_EVP_rsa_pss_with_keygen_bits);
ADD_TEST(test_EVP_rsa_pss_set_saltlen);
+ ADD_TEST(test_EVP_rsa_invalid_key);
#ifndef OPENSSL_NO_EC
ADD_ALL_TESTS(test_ecpub, OSSL_NELEM(ecpub_nids));
#endif
@@ -5521,12 +6875,13 @@ int setup_tests(void)
# endif
#endif
+#ifndef OPENSSL_NO_ECX
ADD_ALL_TESTS(test_ecx_short_keys, OSSL_NELEM(ecxnids));
-
-#ifndef OPENSSL_NO_EC
ADD_ALL_TESTS(test_ecx_not_private_key, OSSL_NELEM(keys));
#endif
+ ADD_TEST(test_sign_continuation);
+
/* Test cases for CVE-2023-5363 */
ADD_TEST(test_aes_gcm_ivlen_change_cve_2023_5363);
#ifndef OPENSSL_NO_RC4
@@ -5535,6 +6890,8 @@ int setup_tests(void)
ADD_TEST(test_invalid_ctx_for_digest);
+ ADD_TEST(test_evp_cipher_pipeline);
+
return 1;
}
@@ -5542,6 +6899,8 @@ void cleanup_tests(void)
{
OSSL_PROVIDER_unload(nullprov);
OSSL_PROVIDER_unload(deflprov);
+#ifndef OPENSSL_SYS_TANDEM
OSSL_PROVIDER_unload(lgcyprov);
+#endif
OSSL_LIB_CTX_free(testctx);
}