fix for build with cryptonly + rsapub

This commit is contained in:
Jacob Barthelmeh
2018-12-19 15:30:22 -07:00
parent 92d59c7df4
commit 165a80d02d
3 changed files with 34 additions and 8 deletions

View File

@@ -3865,7 +3865,7 @@ void bench_rsaKeyGen_size(int doAsync, int keySz)
#define RSA_BUF_SIZE 384 /* for up to 3072 bit */
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
#if !defined(WOLFSSL_RSA_VERIFY_INLINE) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
#elif defined(USE_CERT_BUFFERS_2048)
static unsigned char rsa_2048_sig[] = {
0x8c, 0x9e, 0x37, 0xbf, 0xc3, 0xa6, 0xba, 0x1c,
@@ -3961,33 +3961,36 @@ static void bench_rsa_helper(int doAsync, RsaKey rsaKey[BENCH_MAX_PENDING],
{
int ret = 0, i, times, count = 0, pending = 0;
word32 idx = 0;
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
#ifndef WOLFSSL_RSA_VERIFY_ONLY
const char* messageStr = "Everyone gets Friday off.";
const int len = (int)XSTRLEN((char*)messageStr);
#endif
double start = 0.0f;
const char**desc = bench_desc_words[lng_index];
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
#ifndef WOLFSSL_RSA_VERIFY_ONLY
DECLARE_VAR_INIT(message, byte, len, messageStr, HEAP_HINT);
#endif
#ifdef USE_CERT_BUFFERS_1024
DECLARE_ARRAY(enc, byte, BENCH_MAX_PENDING, 128, HEAP_HINT);
#ifndef WOLFSSL_RSA_VERIFY_INLINE
#if !defined(WOLFSSL_RSA_VERIFY_INLINE) && \
!defined(WOLFSSL_RSA_PUBLIC_ONLY)
DECLARE_ARRAY(out, byte, BENCH_MAX_PENDING, 128, HEAP_HINT);
#else
byte* out[BENCH_MAX_PENDING];
#endif
#elif defined(USE_CERT_BUFFERS_2048)
DECLARE_ARRAY(enc, byte, BENCH_MAX_PENDING, 256, HEAP_HINT);
#ifndef WOLFSSL_RSA_VERIFY_INLINE
#if !defined(WOLFSSL_RSA_VERIFY_INLINE) && \
!defined(WOLFSSL_RSA_PUBLIC_ONLY)
DECLARE_ARRAY(out, byte, BENCH_MAX_PENDING, 256, HEAP_HINT);
#else
byte* out[BENCH_MAX_PENDING];
#endif
#elif defined(USE_CERT_BUFFERS_3072)
DECLARE_ARRAY(enc, byte, BENCH_MAX_PENDING, 384, HEAP_HINT);
#ifndef WOLFSSL_RSA_VERIFY_INLINE
#if !defined(WOLFSSL_RSA_VERIFY_INLINE) && \
!defined(WOLFSSL_RSA_PUBLIC_ONLY)
DECLARE_ARRAY(out, byte, BENCH_MAX_PENDING, 384, HEAP_HINT);
#else
byte* out[BENCH_MAX_PENDING];
@@ -4106,7 +4109,8 @@ exit_rsa_sign:
for (i = 0; i < BENCH_MAX_PENDING; i++) {
if (bench_async_check(&ret, BENCH_ASYNC_GET_DEV(&rsaKey[i]),
1, &times, ntimes, &pending)) {
#ifndef WOLFSSL_RSA_VERIFY_INLINE
#if !defined(WOLFSSL_RSA_VERIFY_INLINE) && \
!defined(WOLFSSL_RSA_PUBLIC_ONLY)
ret = wc_RsaSSL_Verify(enc[i], idx, out[i],
rsaKeySz/8, &rsaKey[i]);
#elif defined(USE_CERT_BUFFERS_2048)

View File

@@ -2896,12 +2896,25 @@ int wc_RsaExportKey(RsaKey* key,
ret = RsaGetValue(&key->e, e, eSz);
if (ret == 0)
ret = RsaGetValue(&key->n, n, nSz);
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
if (ret == 0)
ret = RsaGetValue(&key->d, d, dSz);
if (ret == 0)
ret = RsaGetValue(&key->p, p, pSz);
if (ret == 0)
ret = RsaGetValue(&key->q, q, qSz);
#else
/* no private parts to key */
if (d == NULL || p == NULL || q == NULL || dSz == NULL || pSz == NULL
|| qSz == NULL) {
ret = BAD_FUNC_ARG;
}
else {
*dSz = 0;
*pSz = 0;
*qSz = 0;
}
#endif /* WOLFSSL_RSA_PUBLIC_ONLY */
return ret;
}

View File

@@ -9175,6 +9175,7 @@ static int rsa_export_key_test(RsaKey* key)
ret = wc_RsaExportKey(key, e, &eSz, n, &zero, d, &dSz, p, &pSz, q, &qSz);
if (ret != RSA_BUFFER_E)
return -6749;
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
ret = wc_RsaExportKey(key, e, &eSz, n, &nSz, d, &zero, p, &pSz, q, &qSz);
if (ret != RSA_BUFFER_E)
return -6750;
@@ -9184,6 +9185,7 @@ static int rsa_export_key_test(RsaKey* key)
ret = wc_RsaExportKey(key, e, &eSz, n, &nSz, d, &dSz, p, &pSz, q, &zero);
if (ret != RSA_BUFFER_E)
return -6752;
#endif /* WOLFSSL_RSA_PUBLIC_ONLY */
ret = wc_RsaExportKey(key, e, &eSz, n, &nSz, d, &dSz, p, &pSz, q, &qSz);
if (ret != 0)
@@ -9265,6 +9267,8 @@ static int rsa_sig_test(RsaKey* key, word32 keyLen, int modLen, WC_RNG* rng)
!defined(WC_RSA_BLINDING)
/* FIPS140 implementation does not do blinding */
if (ret != 0)
#elif defined(WOLFSSL_RSA_PUBLIC_ONLY)
if (ret != SIG_TYPE_E)
#else
if (ret != MISSING_RNG_E)
#endif
@@ -9315,6 +9319,7 @@ static int rsa_sig_test(RsaKey* key, word32 keyLen, int modLen, WC_RNG* rng)
return -6772;
sigSz = (word32)ret;
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
ret = wc_SignatureGenerate(WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_RSA, in,
inLen, out, &sigSz, key, keyLen, rng);
if (ret != 0)
@@ -9365,6 +9370,10 @@ static int rsa_sig_test(RsaKey* key, word32 keyLen, int modLen, WC_RNG* rng)
hashEnc, (int)sizeof(hashEnc), out, (word32)modLen, key, keyLen);
if (ret != 0)
return -6781;
#else
(void)hash;
(void)hashEnc;
#endif /* WOLFSSL_RSA_PUBLIC_ONLY */
return 0;
}
@@ -10921,7 +10930,7 @@ int rsa_test(void)
goto exit_rsa;
#endif
#ifndef WOLFSSL_RSA_VERIFY_ONLY
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
do {
#if defined(WOLFSSL_ASYNC_CRYPT)
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);