mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
@@ -7927,10 +7927,11 @@ static int test_wc_RsaKeyToDer (void)
|
|||||||
RsaKey genKey;
|
RsaKey genKey;
|
||||||
WC_RNG rng;
|
WC_RNG rng;
|
||||||
byte* der;
|
byte* der;
|
||||||
|
word32 derSz = 611;
|
||||||
|
|
||||||
/* (2 x 128) + 2 (possible leading 00) + (5 x 64) + 5 (possible leading 00)
|
/* (2 x 128) + 2 (possible leading 00) + (5 x 64) + 5 (possible leading 00)
|
||||||
+ 3 (e) + 8 (ASN tag) + 10 (ASN length) + 4 seqSz + 3 version */
|
+ 3 (e) + 8 (ASN tag) + 10 (ASN length) + 4 seqSz + 3 version */
|
||||||
der = (byte*)XMALLOC(611, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
der = (byte*)XMALLOC(derSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (der == NULL) {
|
if (der == NULL) {
|
||||||
ret = WOLFSSL_FATAL_ERROR;
|
ret = WOLFSSL_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
@@ -7952,7 +7953,7 @@ static int test_wc_RsaKeyToDer (void)
|
|||||||
printf(testingFmt, "wc_RsaKeyToDer()");
|
printf(testingFmt, "wc_RsaKeyToDer()");
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = wc_RsaKeyToDer(&genKey, der, 610);
|
ret = wc_RsaKeyToDer(&genKey, der, derSz);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -206,7 +206,8 @@ static int bench_asym_algs = 0;
|
|||||||
/* Other cryptographic algorithms to benchmark. */
|
/* Other cryptographic algorithms to benchmark. */
|
||||||
static int bench_other_algs = 0;
|
static int bench_other_algs = 0;
|
||||||
|
|
||||||
#ifndef WOLFSSL_BENCHMARK_ALL
|
#if !defined(WOLFSSL_BENCHMARK_ALL) && !defined(NO_MAIN_DRIVER)
|
||||||
|
|
||||||
/* The mapping of command line option to bit values. */
|
/* The mapping of command line option to bit values. */
|
||||||
typedef struct bench_alg {
|
typedef struct bench_alg {
|
||||||
/* Command line option string. */
|
/* Command line option string. */
|
||||||
@@ -215,8 +216,8 @@ typedef struct bench_alg {
|
|||||||
int val;
|
int val;
|
||||||
} bench_alg;
|
} bench_alg;
|
||||||
|
|
||||||
/* All recoginized cipher algorithm choosing command line options. */
|
/* All recognized cipher algorithm choosing command line options. */
|
||||||
static bench_alg bench_cipher_opt[] = {
|
static const bench_alg bench_cipher_opt[] = {
|
||||||
{ "-cipher", -1 },
|
{ "-cipher", -1 },
|
||||||
#ifdef HAVE_AES_CBC
|
#ifdef HAVE_AES_CBC
|
||||||
{ "-aes_cbc", BENCH_AES_CBC },
|
{ "-aes_cbc", BENCH_AES_CBC },
|
||||||
@@ -263,8 +264,8 @@ static bench_alg bench_cipher_opt[] = {
|
|||||||
{ NULL, 0}
|
{ NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All recoginized digest algorithm choosing command line options. */
|
/* All recognized digest algorithm choosing command line options. */
|
||||||
static bench_alg bench_digest_opt[] = {
|
static const bench_alg bench_digest_opt[] = {
|
||||||
{ "-digest", -1 },
|
{ "-digest", -1 },
|
||||||
#ifndef NO_MD5
|
#ifndef NO_MD5
|
||||||
{ "-md5", BENCH_MD5 },
|
{ "-md5", BENCH_MD5 },
|
||||||
@@ -315,8 +316,8 @@ static bench_alg bench_digest_opt[] = {
|
|||||||
{ NULL, 0}
|
{ NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All recoginized MAC algorithm choosing command line options. */
|
/* All recognized MAC algorithm choosing command line options. */
|
||||||
static bench_alg bench_mac_opt[] = {
|
static const bench_alg bench_mac_opt[] = {
|
||||||
{ "-mac", -1 },
|
{ "-mac", -1 },
|
||||||
#ifdef WOLFSSL_CMAC
|
#ifdef WOLFSSL_CMAC
|
||||||
{ "-cmac", BENCH_CMAC },
|
{ "-cmac", BENCH_CMAC },
|
||||||
@@ -345,8 +346,8 @@ static bench_alg bench_mac_opt[] = {
|
|||||||
{ NULL, 0}
|
{ NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All recoginized asymmetric algorithm choosing command line options. */
|
/* All recognized asymmetric algorithm choosing command line options. */
|
||||||
static bench_alg bench_asym_opt[] = {
|
static const bench_alg bench_asym_opt[] = {
|
||||||
{ "-asym", -1 },
|
{ "-asym", -1 },
|
||||||
#ifndef NO_RSA
|
#ifndef NO_RSA
|
||||||
#ifdef WOLFSSL_KEY_GEN
|
#ifdef WOLFSSL_KEY_GEN
|
||||||
@@ -381,9 +382,9 @@ static bench_alg bench_asym_opt[] = {
|
|||||||
{ NULL, 0}
|
{ NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* All recoginized other cryptographic algorithm choosing command line options.
|
/* All recognized other cryptographic algorithm choosing command line options.
|
||||||
*/
|
*/
|
||||||
static bench_alg bench_other_opt[] = {
|
static const bench_alg bench_other_opt[] = {
|
||||||
{ "-other", -1 },
|
{ "-other", -1 },
|
||||||
#ifndef WC_NO_RNG
|
#ifndef WC_NO_RNG
|
||||||
{ "-rng", BENCH_RNG },
|
{ "-rng", BENCH_RNG },
|
||||||
|
@@ -648,9 +648,13 @@ static int CheckBitString(const byte* input, word32* inOutIdx, int* len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* RSA (with CertGen or KeyGen) OR ECC OR ED25519 (with CertGen or KeyGen) */
|
||||||
#if (!defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
|
#if (!defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
|
||||||
(defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN))) || \
|
(defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN))) || \
|
||||||
defined(HAVE_ECC) || defined(HAVE_ED25519)
|
defined(HAVE_ECC) || \
|
||||||
|
(defined(HAVE_ED25519) && \
|
||||||
|
(defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN)))
|
||||||
|
|
||||||
/* Set the DER/BER encoding of the ASN.1 BIT_STRING header.
|
/* Set the DER/BER encoding of the ASN.1 BIT_STRING header.
|
||||||
*
|
*
|
||||||
* len Length of data to encode.
|
* len Length of data to encode.
|
||||||
|
@@ -5315,15 +5315,15 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (key == NULL || priv == NULL)
|
||||||
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
/* public optional, NULL if only importing private */
|
/* public optional, NULL if only importing private */
|
||||||
if (pub != NULL) {
|
if (pub != NULL) {
|
||||||
ret = wc_ecc_import_x963_ex(pub, pubSz, key, curve_id);
|
ret = wc_ecc_import_x963_ex(pub, pubSz, key, curve_id);
|
||||||
key->type = ECC_PRIVATEKEY;
|
key->type = ECC_PRIVATEKEY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (key == NULL || priv == NULL)
|
|
||||||
return BAD_FUNC_ARG;
|
|
||||||
|
|
||||||
/* make sure required variables are reset */
|
/* make sure required variables are reset */
|
||||||
wc_ecc_reset(key);
|
wc_ecc_reset(key);
|
||||||
|
|
||||||
@@ -5335,7 +5335,6 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
|
|||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
||||||
#ifdef WOLFSSL_ATECC508A
|
#ifdef WOLFSSL_ATECC508A
|
||||||
/* TODO: Implement equiv call to ATECC508A */
|
/* TODO: Implement equiv call to ATECC508A */
|
||||||
return BAD_COND_E;
|
return BAD_COND_E;
|
||||||
|
Reference in New Issue
Block a user