mirror of https://github.com/wolfSSL/wolfssl.git
Fixes for RSA verify only builds
parent
7aa159ca6d
commit
b24e122a0d
|
@ -4813,8 +4813,8 @@ void bench_ecc(int doAsync)
|
|||
#endif
|
||||
#if !defined(NO_ASN) && defined(HAVE_ECC_SIGN)
|
||||
DECLARE_ARRAY(sig, byte, BENCH_MAX_PENDING, ECC_MAX_SIG_SIZE, HEAP_HINT);
|
||||
#endif
|
||||
DECLARE_ARRAY(digest, byte, BENCH_MAX_PENDING, BENCH_ECC_SIZE, HEAP_HINT);
|
||||
#endif
|
||||
|
||||
/* clear for done cleanup */
|
||||
XMEMSET(&genKey, 0, sizeof(genKey));
|
||||
|
@ -4956,8 +4956,8 @@ exit:
|
|||
#endif
|
||||
#if !defined(NO_ASN) && defined(HAVE_ECC_SIGN)
|
||||
FREE_ARRAY(sig, BENCH_MAX_PENDING, HEAP_HINT);
|
||||
#endif
|
||||
FREE_ARRAY(digest, BENCH_MAX_PENDING, HEAP_HINT);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2993,7 +2993,8 @@ int wc_RsaPSS_Sign_ex(const byte* in, word32 inLen, byte* out, word32 outLen,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) || !defined(WOLFSSL_SP_MATH)
|
||||
#if !defined(WOLFSSL_RSA_VERIFY_ONLY) || !defined(WOLFSSL_SP_MATH) || \
|
||||
defined(WC_RSA_PSS)
|
||||
int wc_RsaEncryptSize(RsaKey* key)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -6735,7 +6735,8 @@ static WC_INLINE int sp_2048_mod_64_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_64_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -7008,7 +7009,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -7264,7 +7265,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
}
|
||||
#endif
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -7450,7 +7452,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -16266,7 +16268,8 @@ static WC_INLINE int sp_3072_mod_96_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_96_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -16539,7 +16542,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -16795,7 +16798,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
}
|
||||
#endif
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -16981,7 +16985,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
|
|
@ -4393,7 +4393,8 @@ static WC_INLINE int sp_2048_mod_32_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_32_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -4666,7 +4667,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -4920,7 +4921,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -5106,7 +5108,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -11427,7 +11429,8 @@ static WC_INLINE int sp_3072_mod_48_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_48_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -11700,7 +11703,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -11954,7 +11957,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -12140,7 +12144,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
|
|
@ -3909,7 +3909,8 @@ static WC_INLINE int sp_2048_mod_64_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_64_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -4182,7 +4183,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -4436,7 +4437,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -4622,7 +4624,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -9219,7 +9221,8 @@ static WC_INLINE int sp_3072_mod_96_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_96_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -9492,7 +9495,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -9746,7 +9749,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -9932,7 +9936,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
#ifndef WOLFSSL_SP_ASM
|
||||
#if SP_WORD_SIZE == 32
|
||||
#if (defined(WOLFSSL_SP_CACHE_RESISTANT) || defined(WOLFSSL_SP_SMALL)) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
#if (defined(WOLFSSL_SP_CACHE_RESISTANT) || defined(WOLFSSL_SP_SMALL)) && (defined(WOLFSSL_HAVE_SP_ECC) || !defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Mask for address to obfuscate which of the two address will be used. */
|
||||
static const size_t addr_mask[2] = { 0, (size_t)-1 };
|
||||
#endif
|
||||
|
@ -2660,7 +2660,8 @@ static int sp_2048_mod_90(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_90(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
* r A single precision number that is the result of the operation.
|
||||
|
@ -2960,7 +2961,7 @@ static int sp_2048_mod_exp_90(sp_digit* r, sp_digit* a, sp_digit* e, int bits,
|
|||
return err;
|
||||
#endif
|
||||
}
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D) && \
|
||||
!defined(RSA_LOW_MEM) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
|
@ -3436,7 +3437,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
|
||||
#endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -3850,7 +3852,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -5898,7 +5900,8 @@ static int sp_3072_mod_134(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_134(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
* r A single precision number that is the result of the operation.
|
||||
|
@ -6198,7 +6201,7 @@ static int sp_3072_mod_exp_134(sp_digit* r, sp_digit* a, sp_digit* e, int bits,
|
|||
return err;
|
||||
#endif
|
||||
}
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D) && \
|
||||
!defined(RSA_LOW_MEM) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
|
@ -6672,7 +6675,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
|
||||
#endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -7086,7 +7090,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
#ifndef WOLFSSL_SP_ASM
|
||||
#if SP_WORD_SIZE == 64
|
||||
#if (defined(WOLFSSL_SP_CACHE_RESISTANT) || defined(WOLFSSL_SP_SMALL)) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
#if (defined(WOLFSSL_SP_CACHE_RESISTANT) || defined(WOLFSSL_SP_SMALL)) && (defined(WOLFSSL_HAVE_SP_ECC) || !defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Mask for address to obfuscate which of the two address will be used. */
|
||||
static const size_t addr_mask[2] = { 0, (size_t)-1 };
|
||||
#endif
|
||||
|
@ -2194,7 +2194,8 @@ static int sp_2048_mod_36(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_36(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
* r A single precision number that is the result of the operation.
|
||||
|
@ -2494,7 +2495,7 @@ static int sp_2048_mod_exp_36(sp_digit* r, sp_digit* a, sp_digit* e, int bits,
|
|||
return err;
|
||||
#endif
|
||||
}
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D) && \
|
||||
!defined(RSA_LOW_MEM) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
|
@ -2967,7 +2968,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
|
||||
#endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -3381,7 +3383,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -5705,7 +5707,8 @@ static int sp_3072_mod_54(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_54(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
* r A single precision number that is the result of the operation.
|
||||
|
@ -6005,7 +6008,7 @@ static int sp_3072_mod_exp_54(sp_digit* r, sp_digit* a, sp_digit* e, int bits,
|
|||
return err;
|
||||
#endif
|
||||
}
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#if defined(WOLFSSL_HAVE_SP_RSA) && !defined(SP_RSA_PRIVATE_EXP_D) && \
|
||||
!defined(RSA_LOW_MEM) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
|
@ -6479,7 +6482,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
|
||||
#endif /* !WOLFSSL_RSA_PUBLIC_ONLY */
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -6893,7 +6897,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
|
|
@ -3306,35 +3306,32 @@ SP_NOINLINE static sp_digit div_2048_word_32(sp_digit d1, sp_digit d0,
|
|||
*/
|
||||
SP_NOINLINE static int32_t sp_2048_cmp_32(sp_digit* a, sp_digit* b)
|
||||
{
|
||||
sp_digit r = -1;
|
||||
sp_digit r = 0;
|
||||
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"mov r3, %[r]\n\t"
|
||||
"mov r6, #124\n\t"
|
||||
"mov r3, #0\n\t"
|
||||
"mvn r3, r3\n\t"
|
||||
"mov r6, #124\n\t"
|
||||
"1:\n\t"
|
||||
"ldr r4, [%[a], r6]\n\t"
|
||||
"ldr r7, [%[a], r6]\n\t"
|
||||
"ldr r5, [%[b], r6]\n\t"
|
||||
"and r4, r3\n\t"
|
||||
"and r7, r3\n\t"
|
||||
"and r5, r3\n\t"
|
||||
"subs r4, r5\n\t"
|
||||
"sbc r5, r5\n\t"
|
||||
"mov r7, r3\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"subs r4, #1\n\t"
|
||||
"sbc r4, r4\n\t"
|
||||
"orr r5, r4\n\t"
|
||||
"mvn r5, r5\n\t"
|
||||
"mov r7, #1\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"and r3, r4\n\t"
|
||||
"subs r6, #4\n\t"
|
||||
"bcc 1b\n\t"
|
||||
"eor %[r], r3\n\t"
|
||||
"mov r4, r7\n\t"
|
||||
"subs r7, r5\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"add %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"subs r5, r4\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"sub %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"sub r6, #4\n\t"
|
||||
"cmp r6, #0\n\t"
|
||||
"bge 1b\n\t"
|
||||
: [r] "+r" (r)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "r3", "r4", "r5", "r6", "r7"
|
||||
|
@ -3935,35 +3932,32 @@ static void sp_2048_mask_64(sp_digit* r, sp_digit* a, sp_digit m)
|
|||
*/
|
||||
SP_NOINLINE static int32_t sp_2048_cmp_64(sp_digit* a, sp_digit* b)
|
||||
{
|
||||
sp_digit r = -1;
|
||||
sp_digit r = 0;
|
||||
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"mov r3, %[r]\n\t"
|
||||
"mov r6, #252\n\t"
|
||||
"mov r3, #0\n\t"
|
||||
"mvn r3, r3\n\t"
|
||||
"mov r6, #252\n\t"
|
||||
"1:\n\t"
|
||||
"ldr r4, [%[a], r6]\n\t"
|
||||
"ldr r7, [%[a], r6]\n\t"
|
||||
"ldr r5, [%[b], r6]\n\t"
|
||||
"and r4, r3\n\t"
|
||||
"and r7, r3\n\t"
|
||||
"and r5, r3\n\t"
|
||||
"subs r4, r5\n\t"
|
||||
"sbc r5, r5\n\t"
|
||||
"mov r7, r3\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"subs r4, #1\n\t"
|
||||
"sbc r4, r4\n\t"
|
||||
"orr r5, r4\n\t"
|
||||
"mvn r5, r5\n\t"
|
||||
"mov r7, #1\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"and r3, r4\n\t"
|
||||
"subs r6, #4\n\t"
|
||||
"bcc 1b\n\t"
|
||||
"eor %[r], r3\n\t"
|
||||
"mov r4, r7\n\t"
|
||||
"subs r7, r5\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"add %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"subs r5, r4\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"sub %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"sub r6, #4\n\t"
|
||||
"cmp r6, #0\n\t"
|
||||
"bge 1b\n\t"
|
||||
: [r] "+r" (r)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "r3", "r4", "r5", "r6", "r7"
|
||||
|
@ -4073,7 +4067,8 @@ static WC_INLINE int sp_2048_mod_64_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_64_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -4346,7 +4341,7 @@ static int sp_2048_mod_exp_64(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -4600,7 +4595,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -4786,7 +4782,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -8774,35 +8770,32 @@ SP_NOINLINE static sp_digit div_3072_word_48(sp_digit d1, sp_digit d0,
|
|||
*/
|
||||
SP_NOINLINE static int32_t sp_3072_cmp_48(sp_digit* a, sp_digit* b)
|
||||
{
|
||||
sp_digit r = -1;
|
||||
sp_digit r = 0;
|
||||
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"mov r3, %[r]\n\t"
|
||||
"mov r6, #188\n\t"
|
||||
"mov r3, #0\n\t"
|
||||
"mvn r3, r3\n\t"
|
||||
"mov r6, #188\n\t"
|
||||
"1:\n\t"
|
||||
"ldr r4, [%[a], r6]\n\t"
|
||||
"ldr r7, [%[a], r6]\n\t"
|
||||
"ldr r5, [%[b], r6]\n\t"
|
||||
"and r4, r3\n\t"
|
||||
"and r7, r3\n\t"
|
||||
"and r5, r3\n\t"
|
||||
"subs r4, r5\n\t"
|
||||
"sbc r5, r5\n\t"
|
||||
"mov r7, r3\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"subs r4, #1\n\t"
|
||||
"sbc r4, r4\n\t"
|
||||
"orr r5, r4\n\t"
|
||||
"mvn r5, r5\n\t"
|
||||
"mov r7, #1\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"and r3, r4\n\t"
|
||||
"subs r6, #4\n\t"
|
||||
"bcc 1b\n\t"
|
||||
"eor %[r], r3\n\t"
|
||||
"mov r4, r7\n\t"
|
||||
"subs r7, r5\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"add %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"subs r5, r4\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"sub %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"sub r6, #4\n\t"
|
||||
"cmp r6, #0\n\t"
|
||||
"bge 1b\n\t"
|
||||
: [r] "+r" (r)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "r3", "r4", "r5", "r6", "r7"
|
||||
|
@ -9407,37 +9400,34 @@ static void sp_3072_mask_96(sp_digit* r, sp_digit* a, sp_digit m)
|
|||
*/
|
||||
SP_NOINLINE static int32_t sp_3072_cmp_96(sp_digit* a, sp_digit* b)
|
||||
{
|
||||
sp_digit r = -1;
|
||||
sp_digit r = 0;
|
||||
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"mov r3, %[r]\n\t"
|
||||
"mov r6, #1\n\t"
|
||||
"lsl r6, r6, #8\n\t"
|
||||
"add r6, #124\n\t"
|
||||
"mov r3, #0\n\t"
|
||||
"mvn r3, r3\n\t"
|
||||
"mov r6, #1\n\t"
|
||||
"lsl r6, r6, #8\n\t"
|
||||
"add r6, #124\n\t"
|
||||
"1:\n\t"
|
||||
"ldr r4, [%[a], r6]\n\t"
|
||||
"ldr r7, [%[a], r6]\n\t"
|
||||
"ldr r5, [%[b], r6]\n\t"
|
||||
"and r4, r3\n\t"
|
||||
"and r7, r3\n\t"
|
||||
"and r5, r3\n\t"
|
||||
"subs r4, r5\n\t"
|
||||
"sbc r5, r5\n\t"
|
||||
"mov r7, r3\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"subs r4, #1\n\t"
|
||||
"sbc r4, r4\n\t"
|
||||
"orr r5, r4\n\t"
|
||||
"mvn r5, r5\n\t"
|
||||
"mov r7, #1\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"and r3, r4\n\t"
|
||||
"subs r6, #4\n\t"
|
||||
"bcc 1b\n\t"
|
||||
"eor %[r], r3\n\t"
|
||||
"mov r4, r7\n\t"
|
||||
"subs r7, r5\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"add %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"subs r5, r4\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"sub %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"sub r6, #4\n\t"
|
||||
"cmp r6, #0\n\t"
|
||||
"bge 1b\n\t"
|
||||
: [r] "+r" (r)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "r3", "r4", "r5", "r6", "r7"
|
||||
|
@ -9547,7 +9537,8 @@ static WC_INLINE int sp_3072_mod_96_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_96_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef WOLFSSL_SP_SMALL
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -9820,7 +9811,7 @@ static int sp_3072_mod_exp_96(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_SP_SMALL */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -10074,7 +10065,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -10260,7 +10252,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
@ -10613,35 +10605,32 @@ static int sp_256_point_to_ecc_point_8(sp_point* p, ecc_point* pm)
|
|||
*/
|
||||
SP_NOINLINE static int32_t sp_256_cmp_8(sp_digit* a, sp_digit* b)
|
||||
{
|
||||
sp_digit r = -1;
|
||||
sp_digit r = 0;
|
||||
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"mov r3, %[r]\n\t"
|
||||
"mov r6, #28\n\t"
|
||||
"mov r3, #0\n\t"
|
||||
"mvn r3, r3\n\t"
|
||||
"mov r6, #28\n\t"
|
||||
"1:\n\t"
|
||||
"ldr r4, [%[a], r6]\n\t"
|
||||
"ldr r7, [%[a], r6]\n\t"
|
||||
"ldr r5, [%[b], r6]\n\t"
|
||||
"and r4, r3\n\t"
|
||||
"and r7, r3\n\t"
|
||||
"and r5, r3\n\t"
|
||||
"subs r4, r5\n\t"
|
||||
"sbc r5, r5\n\t"
|
||||
"mov r7, r3\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"subs r4, #1\n\t"
|
||||
"sbc r4, r4\n\t"
|
||||
"orr r5, r4\n\t"
|
||||
"mvn r5, r5\n\t"
|
||||
"mov r7, #1\n\t"
|
||||
"and r7, r5\n\t"
|
||||
"bic %[r], r5\n\t"
|
||||
"orr %[r], r7\n\t"
|
||||
"and r3, r4\n\t"
|
||||
"subs r6, #4\n\t"
|
||||
"bcc 1b\n\t"
|
||||
"eor %[r], r3\n\t"
|
||||
"mov r4, r7\n\t"
|
||||
"subs r7, r5\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"add %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"subs r5, r4\n\t"
|
||||
"sbc r7, r7\n\t"
|
||||
"sub %[r], r7\n\t"
|
||||
"mvn r7, r7\n\t"
|
||||
"and r3, r7\n\t"
|
||||
"sub r6, #4\n\t"
|
||||
"cmp r6, #0\n\t"
|
||||
"bge 1b\n\t"
|
||||
: [r] "+r" (r)
|
||||
: [a] "r" (a), [b] "r" (b)
|
||||
: "r3", "r4", "r5", "r6", "r7"
|
||||
|
|
|
@ -1037,7 +1037,8 @@ static WC_INLINE int sp_2048_mod_32_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_2048_div_32_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
* r A single precision number that is the result of the operation.
|
||||
|
@ -1181,7 +1182,7 @@ static int sp_2048_mod_exp_32(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
extern void sp_2048_mont_reduce_avx2_32(sp_digit* a, sp_digit* m, sp_digit mp);
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
|
@ -1218,7 +1219,8 @@ static void sp_2048_mont_sqr_avx2_32(sp_digit* r, sp_digit* a, sp_digit* m,
|
|||
}
|
||||
|
||||
#endif /* HAVE_INTEL_AVX2 */
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -1364,7 +1366,7 @@ static int sp_2048_mod_exp_avx2_32(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* HAVE_INTEL_AVX2 */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -1673,7 +1675,8 @@ int sp_RsaPrivate_2048(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -1879,7 +1882,7 @@ int sp_ModExp_1024(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_2048 */
|
||||
|
||||
|
@ -2870,7 +2873,8 @@ static WC_INLINE int sp_3072_mod_48_cond(sp_digit* r, sp_digit* a, sp_digit* m)
|
|||
return sp_3072_div_48_cond(a, m, NULL, r);
|
||||
}
|
||||
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
* r A single precision number that is the result of the operation.
|
||||
|
@ -3014,7 +3018,7 @@ static int sp_3072_mod_exp_48(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
|
||||
return err;
|
||||
}
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
extern void sp_3072_mont_reduce_avx2_48(sp_digit* a, sp_digit* m, sp_digit mp);
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
|
@ -3051,7 +3055,8 @@ static void sp_3072_mont_sqr_avx2_48(sp_digit* r, sp_digit* a, sp_digit* m,
|
|||
}
|
||||
|
||||
#endif /* HAVE_INTEL_AVX2 */
|
||||
#if defined(SP_RSA_PRIVATE_EXP_D) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(SP_RSA_PRIVATE_EXP_D) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
#ifdef HAVE_INTEL_AVX2
|
||||
/* Modular exponentiate a to the e mod m. (r = a^e mod m)
|
||||
*
|
||||
|
@ -3197,7 +3202,7 @@ static int sp_3072_mod_exp_avx2_48(sp_digit* r, sp_digit* a, sp_digit* e,
|
|||
return err;
|
||||
}
|
||||
#endif /* HAVE_INTEL_AVX2 */
|
||||
#endif /* SP_RSA_PRIVATE_EXP_D || WOLFSSL_HAVE_SP_DH */
|
||||
#endif /* (SP_RSA_PRIVATE_EXP_D && !WOLFSSL_RSA_PUBLIC_ONLY) || WOLFSSL_HAVE_SP_DH */
|
||||
|
||||
#ifdef WOLFSSL_HAVE_SP_RSA
|
||||
/* RSA public key operation.
|
||||
|
@ -3506,7 +3511,8 @@ int sp_RsaPrivate_3072(const byte* in, word32 inLen, mp_int* dm,
|
|||
return err;
|
||||
}
|
||||
#endif /* WOLFSSL_HAVE_SP_RSA */
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || defined(WOLFSSL_HAVE_SP_RSA)
|
||||
#if defined(WOLFSSL_HAVE_SP_DH) || (defined(WOLFSSL_HAVE_SP_RSA) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
/* Convert an array of sp_digit to an mp_int.
|
||||
*
|
||||
* a A single precision integer.
|
||||
|
@ -3712,7 +3718,7 @@ int sp_ModExp_1536(mp_int* base, mp_int* exp, mp_int* mod, mp_int* res)
|
|||
return err;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || WOLFSSL_HAVE_SP_RSA */
|
||||
#endif /* WOLFSSL_HAVE_SP_DH || (WOLFSSL_HAVE_SP_RSA && !WOLFSSL_RSA_PUBLIC_ONLY) */
|
||||
|
||||
#endif /* WOLFSSL_SP_NO_3072 */
|
||||
|
||||
|
|
|
@ -3537,7 +3537,8 @@ static int fp_prime_miller_rabin_ex(fp_int * a, fp_int * b, int *result,
|
|||
|
||||
/* compute y = b**r mod a */
|
||||
fp_zero(y);
|
||||
#if defined(WOLFSSL_HAVE_SP_RSA) || defined(WOLFSSL_HAVE_SP_DH)
|
||||
#if (defined(WOLFSSL_HAVE_SP_RSA) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)) || \
|
||||
defined(WOLFSSL_HAVE_SP_DH)
|
||||
if (fp_count_bits(a) == 1024)
|
||||
sp_ModExp_1024(b, r, a, y);
|
||||
else if (fp_count_bits(a) == 2048)
|
||||
|
@ -4067,7 +4068,7 @@ int mp_add_d(fp_int *a, fp_digit b, fp_int *c)
|
|||
|
||||
#if !defined(NO_DSA) || defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || \
|
||||
defined(HAVE_COMP_KEY) || defined(WOLFSSL_DEBUG_MATH) || \
|
||||
defined(DEBUG_WOLFSSL) || defined(OPENSSL_EXTRA)
|
||||
defined(DEBUG_WOLFSSL) || defined(OPENSSL_EXTRA) || defined(WC_MP_TO_RADIX)
|
||||
|
||||
/* chars used in radix conversions */
|
||||
static const char* const fp_s_rmap = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
|
|
@ -1023,7 +1023,7 @@ initDefaultName();
|
|||
printf( "mp test passed!\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_PUBLIC_MP
|
||||
#if defined(WOLFSSL_PUBLIC_MP) && !defined(WOLFSSL_SP_MATH)
|
||||
if ( (ret = prime_test()) != 0)
|
||||
return err_sys("prime test failed!\n", ret);
|
||||
else
|
||||
|
@ -10283,6 +10283,7 @@ int rsa_no_pad_test(void)
|
|||
ERROR_OUT(-6905, exit_rsa_nopadding);
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
inLen = wc_RsaEncryptSize(&key);
|
||||
XMEMSET(tmp, 7, inLen);
|
||||
do {
|
||||
|
@ -10320,6 +10321,7 @@ int rsa_no_pad_test(void)
|
|||
if (XMEMCMP(plain, tmp, inLen) != 0) {
|
||||
ERROR_OUT(-6909, exit_rsa_nopadding);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WC_RSA_BLINDING
|
||||
ret = wc_RsaSetRNG(NULL, &rng);
|
||||
|
@ -11012,6 +11014,9 @@ int rsa_test(void)
|
|||
word32 inLen = (word32)XSTRLEN((char*)inStr);
|
||||
const word32 outSz = RSA_TEST_BYTES;
|
||||
const word32 plainSz = RSA_TEST_BYTES;
|
||||
#ifndef NO_SIG_WRAPPER
|
||||
int modLen;
|
||||
#endif
|
||||
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) \
|
||||
&& !defined(NO_FILESYSTEM)
|
||||
XFILE file;
|
||||
|
@ -11095,6 +11100,9 @@ int rsa_test(void)
|
|||
if (ret != 0) {
|
||||
ERROR_OUT(-7004, exit_rsa);
|
||||
}
|
||||
#ifndef NO_SIG_WRAPPER
|
||||
modLen = wc_RsaEncryptSize(&key);
|
||||
#endif
|
||||
#elif defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
#ifdef USE_CERT_BUFFERS_2048
|
||||
ret = mp_read_unsigned_bin(&key.n, &tmp[12], 256);
|
||||
|
@ -11105,6 +11113,9 @@ int rsa_test(void)
|
|||
if (ret != 0) {
|
||||
ERROR_OUT(-7004, exit_rsa);
|
||||
}
|
||||
#ifndef NO_SIG_WRAPPER
|
||||
modLen = 2048;
|
||||
#endif
|
||||
#else
|
||||
#error Not supported yet!
|
||||
#endif
|
||||
|
@ -11122,7 +11133,7 @@ int rsa_test(void)
|
|||
#endif
|
||||
|
||||
#ifndef NO_SIG_WRAPPER
|
||||
ret = rsa_sig_test(&key, sizeof(RsaKey), wc_RsaEncryptSize(&key), &rng);
|
||||
ret = rsa_sig_test(&key, sizeof(RsaKey), modLen, &rng);
|
||||
if (ret != 0)
|
||||
goto exit_rsa;
|
||||
#endif
|
||||
|
@ -11272,6 +11283,7 @@ int rsa_test(void)
|
|||
ERROR_OUT(-7015, exit_rsa);
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
#ifndef WC_NO_RSA_OAEP
|
||||
/* OAEP padding testing */
|
||||
#if !defined(HAVE_FAST_RSA) && !defined(HAVE_USER_RSA) && \
|
||||
|
@ -11280,7 +11292,6 @@ int rsa_test(void)
|
|||
#ifndef NO_SHA
|
||||
XMEMSET(plain, 0, plainSz);
|
||||
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
|
@ -11446,6 +11457,7 @@ int rsa_test(void)
|
|||
}
|
||||
#endif /* WOLFSSL_RSA_PUBLIC_ONLY */
|
||||
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
#ifndef NO_SHA
|
||||
/* check fail using mismatch hash algorithms */
|
||||
XMEMSET(plain, 0, plainSz);
|
||||
|
@ -11462,7 +11474,6 @@ int rsa_test(void)
|
|||
if (ret < 0) {
|
||||
ERROR_OUT(-7030, exit_rsa);
|
||||
}
|
||||
#endif /* WOLFSSL_RSA_VERIFY_ONLY */
|
||||
|
||||
/* TODO: investigate why Cavium Nitrox doesn't detect decrypt error here */
|
||||
#if !defined(HAVE_CAVIUM) && !defined(WOLFSSL_RSA_PUBLIC_ONLY)
|
||||
|
@ -11492,7 +11503,6 @@ int rsa_test(void)
|
|||
BAD_FUNC_ARG is returned when this case is not met */
|
||||
if (wc_RsaEncryptSize(&key) > ((int)WC_SHA512_DIGEST_SIZE * 2) + 2) {
|
||||
XMEMSET(plain, 0, plainSz);
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
|
@ -11505,7 +11515,6 @@ int rsa_test(void)
|
|||
if (ret < 0) {
|
||||
ERROR_OUT(-7032, exit_rsa);
|
||||
}
|
||||
#endif /* WOLFSSL_RSA_VERIFY_ONLY */
|
||||
|
||||
idx = ret;
|
||||
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
|
||||
|
@ -11531,7 +11540,6 @@ int rsa_test(void)
|
|||
|
||||
/* check using pkcsv15 padding with _ex API */
|
||||
XMEMSET(plain, 0, plainSz);
|
||||
#ifndef WOLFSSL_RSA_VERIFY_ONLY
|
||||
do {
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT)
|
||||
ret = wc_AsyncWait(ret, &key.asyncDev, WC_ASYNC_FLAG_CALL_AGAIN);
|
||||
|
@ -11544,7 +11552,6 @@ int rsa_test(void)
|
|||
if (ret < 0) {
|
||||
ERROR_OUT(-7035, exit_rsa);
|
||||
}
|
||||
#endif /* WOLFSSL_RSA_VERIFY_ONLY */
|
||||
|
||||
idx = (word32)ret;
|
||||
#ifndef WOLFSSL_RSA_PUBLIC_ONLY
|
||||
|
@ -11567,6 +11574,8 @@ int rsa_test(void)
|
|||
#endif /* WOLFSSL_RSA_PUBLIC_ONLY */
|
||||
#endif /* !HAVE_FAST_RSA && !HAVE_FIPS */
|
||||
#endif /* WC_NO_RSA_OAEP */
|
||||
#endif
|
||||
#endif /* WOLFSSL_RSA_VERIFY_ONLY */
|
||||
|
||||
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && !defined(NO_ASN) \
|
||||
&& !defined(WOLFSSL_RSA_VERIFY_ONLY)
|
||||
|
@ -22598,7 +22607,7 @@ done:
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_PUBLIC_MP
|
||||
#if defined(WOLFSSL_PUBLIC_MP) && !defined(WOLFSSL_SP_MATH)
|
||||
|
||||
typedef struct pairs_t {
|
||||
const unsigned char* coeff;
|
||||
|
|
Loading…
Reference in New Issue