forked from wolfSSL/wolfssl
tests/api.c: add test_wc_curve25519_make_pub(); fix some old stray tabs; remove weird extra string-terminating null in test_wolfSSL_sk_CIPHER_description().
This commit is contained in:
73
tests/api.c
73
tests/api.c
@ -17099,6 +17099,74 @@ static int test_wc_curve25519_shared_secret_ex (void)
|
|||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
} /*END test_wc_curve25519_shared_secret_ex*/
|
} /*END test_wc_curve25519_shared_secret_ex*/
|
||||||
|
/*
|
||||||
|
* Testing wc_curve25519_make_pub
|
||||||
|
*/
|
||||||
|
static int test_wc_curve25519_make_pub (void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
#if defined(HAVE_CURVE25519)
|
||||||
|
WC_RNG rng;
|
||||||
|
curve25519_key key;
|
||||||
|
byte out[CURVE25519_KEYSIZE];
|
||||||
|
|
||||||
|
printf(testingFmt, "wc_curve25519_make_pub()");
|
||||||
|
|
||||||
|
ret = wc_curve25519_init(&key);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_InitRng(&rng);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_key(&rng, CURVE25519_KEYSIZE, &key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point, key.k.point, (int)sizeof out, out);
|
||||||
|
}
|
||||||
|
/*test bad cases*/
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point - 1, key.k.point, (int)sizeof out, out);
|
||||||
|
if (ret == ECC_BAD_ARG_E) {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point, NULL, (int)sizeof out, out);
|
||||||
|
if (ret == ECC_BAD_ARG_E) {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point, key.k.point, (int)sizeof out - 1, out);
|
||||||
|
if (ret == ECC_BAD_ARG_E) {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point, key.k.point, (int)sizeof out, NULL);
|
||||||
|
if (ret == ECC_BAD_ARG_E) {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ret == 0) {
|
||||||
|
/* verify clamping test */
|
||||||
|
key.k.point[0] |= ~248;
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point, key.k.point, (int)sizeof out, out);
|
||||||
|
if (ret == ECC_BAD_ARG_E) {
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
key.k.point[0] &= 248;
|
||||||
|
}
|
||||||
|
/* repeat the expected-to-succeed test. */
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_make_pub((int)sizeof key.k.point, key.k.point, (int)sizeof out, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(resultFmt, ret == 0 ? passed : failed);
|
||||||
|
wc_curve25519_free(&key);
|
||||||
|
wc_FreeRng(&rng);
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
} /*END test_wc_curve25519_make_pub */
|
||||||
/*
|
/*
|
||||||
* Testing test_wc_curve25519_export_public_ex
|
* Testing test_wc_curve25519_export_public_ex
|
||||||
*/
|
*/
|
||||||
@ -30385,8 +30453,8 @@ static void test_wolfSSL_sk_CIPHER_description(void)
|
|||||||
SSL_CTX *ctx = NULL;
|
SSL_CTX *ctx = NULL;
|
||||||
SSL *ssl = NULL;
|
SSL *ssl = NULL;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
char test_str[9] = "0000000\0";
|
char test_str[9] = "0000000";
|
||||||
const char badStr[] = "unknown\0";
|
const char badStr[] = "unknown";
|
||||||
const char certPath[] = "./certs/client-cert.pem";
|
const char certPath[] = "./certs/client-cert.pem";
|
||||||
XMEMSET(buf, 0, sizeof(buf));
|
XMEMSET(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
@ -35974,6 +36042,7 @@ void ApiTest(void)
|
|||||||
AssertIntEQ(test_wc_curve25519_size (), 0);
|
AssertIntEQ(test_wc_curve25519_size (), 0);
|
||||||
AssertIntEQ(test_wc_curve25519_make_key (), 0);
|
AssertIntEQ(test_wc_curve25519_make_key (), 0);
|
||||||
AssertIntEQ(test_wc_curve25519_shared_secret_ex (), 0);
|
AssertIntEQ(test_wc_curve25519_shared_secret_ex (), 0);
|
||||||
|
AssertIntEQ(test_wc_curve25519_make_pub (), 0);
|
||||||
AssertIntEQ(test_wc_curve25519_export_public_ex (), 0);
|
AssertIntEQ(test_wc_curve25519_export_public_ex (), 0);
|
||||||
AssertIntEQ(test_wc_curve25519_export_private_raw_ex (), 0);
|
AssertIntEQ(test_wc_curve25519_export_private_raw_ex (), 0);
|
||||||
AssertIntEQ(test_wc_curve25519_import_private_raw_ex (), 0);
|
AssertIntEQ(test_wc_curve25519_import_private_raw_ex (), 0);
|
||||||
|
Reference in New Issue
Block a user