summaryrefslogtreecommitdiff
path: root/test/keymgmt_internal_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/keymgmt_internal_test.c')
-rw-r--r--test/keymgmt_internal_test.c84
1 files changed, 43 insertions, 41 deletions
diff --git a/test/keymgmt_internal_test.c b/test/keymgmt_internal_test.c
index 8d5aa22dab3e..3cc4bf542ad9 100644
--- a/test/keymgmt_internal_test.c
+++ b/test/keymgmt_internal_test.c
@@ -24,7 +24,7 @@
#include <openssl/core_names.h>
#include "internal/core.h"
#include "internal/nelem.h"
-#include "crypto/evp.h" /* For the internal API */
+#include "crypto/evp.h" /* For the internal API */
#include "testutil.h"
typedef struct {
@@ -55,10 +55,10 @@ static FIXTURE *set_up(const char *testcase_name)
if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))
|| !TEST_ptr(fixture->ctx1 = OSSL_LIB_CTX_new())
|| !TEST_ptr(fixture->prov1 = OSSL_PROVIDER_load(fixture->ctx1,
- "default"))
+ "default"))
|| !TEST_ptr(fixture->ctx2 = OSSL_LIB_CTX_new())
|| !TEST_ptr(fixture->prov2 = OSSL_PROVIDER_load(fixture->ctx2,
- "default"))) {
+ "default"))) {
tear_down(fixture);
return NULL;
}
@@ -66,17 +66,17 @@ static FIXTURE *set_up(const char *testcase_name)
}
/* Array indexes */
-#define N 0
-#define E 1
-#define D 2
-#define P 3
-#define Q 4
-#define F3 5 /* Extra factor */
-#define DP 6
-#define DQ 7
-#define E3 8 /* Extra exponent */
-#define QINV 9
-#define C2 10 /* Extra coefficient */
+#define N 0
+#define E 1
+#define D 2
+#define P 3
+#define Q 4
+#define F3 5 /* Extra factor */
+#define DP 6
+#define DQ 7
+#define E3 8 /* Extra exponent */
+#define QINV 9
+#define C2 10 /* Extra coefficient */
/*
* We have to do this because OSSL_PARAM_get_ulong() can't handle params
@@ -89,7 +89,7 @@ static FIXTURE *set_up(const char *testcase_name)
static int get_ulong_via_BN(const OSSL_PARAM *p, unsigned long *goal)
{
BIGNUM *n = NULL;
- int ret = 1; /* Ever so hopeful */
+ int ret = 1; /* Ever so hopeful */
if (!TEST_true(OSSL_PARAM_get_BN(p, &n))
|| !TEST_int_ge(BN_bn2nativepad(n, (unsigned char *)goal, sizeof(*goal)), 0))
@@ -159,20 +159,22 @@ static int test_pass_rsa(FIXTURE *fixture)
* openssl genrsa 32 | openssl rsa -text
*/
static BN_ULONG expected[] = {
- 0xbc747fc5, /* N */
- 0x10001, /* E */
- 0x7b133399, /* D */
- 0xe963, /* P */
- 0xceb7, /* Q */
- 1, /* F3 */
- 0x8599, /* DP */
- 0xbd87, /* DQ */
- 2, /* E3 */
- 0xcc3b, /* QINV */
- 3, /* C3 */
- 0 /* Extra, should remain zero */
+ 0xbc747fc5, /* N */
+ 0x10001, /* E */
+ 0x7b133399, /* D */
+ 0xe963, /* P */
+ 0xceb7, /* Q */
+ 1, /* F3 */
+ 0x8599, /* DP */
+ 0xbd87, /* DQ */
+ 2, /* E3 */
+ 0xcc3b, /* QINV */
+ 3, /* C3 */
+ 0 /* Extra, should remain zero */
+ };
+ static unsigned long keydata[OSSL_NELEM(expected)] = {
+ 0,
};
- static unsigned long keydata[OSSL_NELEM(expected)] = { 0, };
if (!TEST_ptr(rsa = RSA_new()))
goto err;
@@ -210,7 +212,7 @@ static int test_pass_rsa(FIXTURE *fixture)
|| !TEST_ptr(bn_coeffs[0] = BN_new())
|| !TEST_true(BN_set_word(bn_coeffs[0], expected[C2]))
|| !TEST_true(RSA_set0_multi_prime_params(rsa, bn_primes, bn_exps,
- bn_coeffs, 1)))
+ bn_coeffs, 1)))
goto err;
if (!TEST_ptr(pk = EVP_PKEY_new())
@@ -229,15 +231,15 @@ static int test_pass_rsa(FIXTURE *fixture)
km = km3;
/* Check that we can't export an RSA key into an RSA-PSS keymanager */
if (!TEST_ptr_null(provkey2 = evp_pkey_export_to_provider(pk, NULL,
- &km,
- NULL)))
+ &km,
+ NULL)))
goto err;
if (!TEST_ptr(provkey = evp_pkey_export_to_provider(pk, NULL, &km1,
- NULL))
+ NULL))
|| !TEST_true(evp_keymgmt_export(km2, provkey,
- OSSL_KEYMGMT_SELECT_KEYPAIR,
- &export_cb, keydata)))
+ OSSL_KEYMGMT_SELECT_KEYPAIR,
+ &export_cb, keydata)))
goto err;
/*
@@ -269,7 +271,7 @@ static int test_pass_rsa(FIXTURE *fixture)
goto err;
}
- err:
+err:
RSA_free(rsa);
BN_free(bn1);
BN_free(bn2);
@@ -306,7 +308,7 @@ static int test_evp_pkey_export_to_provider(int n)
int ret = 0;
if (!TEST_ptr(libctx = OSSL_LIB_CTX_new())
- || !TEST_ptr(prov = OSSL_PROVIDER_load(libctx, "default")))
+ || !TEST_ptr(prov = OSSL_PROVIDER_load(libctx, "default")))
goto end;
if ((bio = BIO_new_file(cert_filename, "r")) == NULL) {
@@ -317,7 +319,7 @@ static int test_evp_pkey_export_to_provider(int n)
if ((cert = PEM_read_bio_X509(bio, NULL, NULL, NULL)) == NULL) {
TEST_error("'%s' doesn't appear to be a X.509 certificate in PEM format\n",
- cert_filename);
+ cert_filename);
TEST_openssl_errors();
goto end;
}
@@ -327,22 +329,22 @@ static int test_evp_pkey_export_to_provider(int n)
if (n == 0) {
if (!TEST_ptr(keydata = evp_pkey_export_to_provider(pkey, NULL,
- NULL, NULL)))
+ NULL, NULL)))
goto end;
} else if (n == 1) {
if (!TEST_ptr(keydata = evp_pkey_export_to_provider(pkey, NULL,
- &keymgmt, NULL)))
+ &keymgmt, NULL)))
goto end;
} else {
keymgmt = EVP_KEYMGMT_fetch(libctx, "RSA", NULL);
if (!TEST_ptr(keydata = evp_pkey_export_to_provider(pkey, NULL,
- &keymgmt, NULL)))
+ &keymgmt, NULL)))
goto end;
}
ret = 1;
- end:
+end:
BIO_free(bio);
X509_free(cert);
EVP_KEYMGMT_free(keymgmt);