|
@@ -10920,7 +10920,7 @@ int wolfSSL_cmp_peer_cert_to_file(WOLFSSL* ssl, const char *fname)
|
|
|
#endif
|
|
|
|
|
|
|
|
|
-static RNG globalRNG;
|
|
|
+static WC_RNG globalRNG;
|
|
|
static int initGlobalRNG = 0;
|
|
|
|
|
|
/* SSL_SUCCESS on ok */
|
|
@@ -10947,19 +10947,19 @@ int wolfSSL_RAND_seed(const void* seed, int len)
|
|
|
/* SSL_SUCCESS on ok */
|
|
|
int wolfSSL_RAND_bytes(unsigned char* buf, int num)
|
|
|
{
|
|
|
- int ret = 0;
|
|
|
- int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
+ int ret = 0;
|
|
|
+ int initTmpRng = 0;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("wolfSSL_RAND_bytes");
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return ret;
|
|
|
#endif
|
|
@@ -11285,12 +11285,12 @@ int wolfSSL_BN_rand(WOLFSSL_BIGNUM* bn, int bits, int top, int bottom)
|
|
|
int ret = 0;
|
|
|
int len = bits / 8;
|
|
|
int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
byte* buff = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
byte buff[1024];
|
|
|
#endif
|
|
|
|
|
@@ -11303,7 +11303,7 @@ int wolfSSL_BN_rand(WOLFSSL_BIGNUM* bn, int bits, int top, int bottom)
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
buff = (byte*)XMALLOC(1024, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
- tmpRNG = (RNG*) XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*) XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (buff == NULL || tmpRNG == NULL) {
|
|
|
XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
@@ -11926,23 +11926,23 @@ int wolfSSL_DH_generate_key(WOLFSSL_DH* dh)
|
|
|
word32 pubSz = 768;
|
|
|
word32 privSz = 768;
|
|
|
int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
unsigned char* pub = NULL;
|
|
|
unsigned char* priv = NULL;
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
#else
|
|
|
unsigned char pub [768];
|
|
|
unsigned char priv[768];
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_MSG("wolfSSL_DH_generate_key");
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
- pub = (unsigned char*)XMALLOC(pubSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
- priv = (unsigned char*)XMALLOC(privSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ pub = (unsigned char*)XMALLOC(pubSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ priv = (unsigned char*)XMALLOC(privSz, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
|
if (tmpRNG == NULL || pub == NULL || priv == NULL) {
|
|
|
XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
@@ -12530,13 +12530,13 @@ int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA* rsa, int bits, WOLFSSL_BIGNUM* bn,
|
|
|
#ifdef WOLFSSL_KEY_GEN
|
|
|
{
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* rng = NULL;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#else
|
|
|
- RNG rng[1];
|
|
|
+ WC_RNG rng[1];
|
|
|
#endif
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- rng = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ rng = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (rng == NULL)
|
|
|
return SSL_FAILURE;
|
|
|
#endif
|
|
@@ -12651,15 +12651,15 @@ int wolfSSL_DSA_generate_key(WOLFSSL_DSA* dsa)
|
|
|
#ifdef WOLFSSL_KEY_GEN
|
|
|
{
|
|
|
int initTmpRng = 0;
|
|
|
- RNG *rng = NULL;
|
|
|
+ WC_RNG *rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG *tmpRNG = NULL;
|
|
|
+ WC_RNG *tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return SSL_FATAL_ERROR;
|
|
|
#endif
|
|
@@ -12724,15 +12724,15 @@ int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA* dsa, int bits,
|
|
|
#ifdef WOLFSSL_KEY_GEN
|
|
|
{
|
|
|
int initTmpRng = 0;
|
|
|
- RNG *rng = NULL;
|
|
|
+ WC_RNG *rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG *tmpRNG = NULL;
|
|
|
+ WC_RNG *tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return SSL_FATAL_ERROR;
|
|
|
#endif
|
|
@@ -12776,13 +12776,13 @@ int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA* dsa, int bits,
|
|
|
int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet,
|
|
|
WOLFSSL_DSA* dsa)
|
|
|
{
|
|
|
- int ret = SSL_FATAL_ERROR;
|
|
|
- int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
+ int ret = SSL_FATAL_ERROR;
|
|
|
+ int initTmpRng = 0;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("wolfSSL_DSA_do_sign");
|
|
@@ -12803,7 +12803,7 @@ int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet,
|
|
|
}
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return SSL_FATAL_ERROR;
|
|
|
#endif
|
|
@@ -12875,17 +12875,17 @@ int wolfSSL_RSA_sign(int type, const unsigned char* m,
|
|
|
unsigned int mLen, unsigned char* sigRet,
|
|
|
unsigned int* sigLen, WOLFSSL_RSA* rsa)
|
|
|
{
|
|
|
- word32 outLen;
|
|
|
- word32 signSz;
|
|
|
- int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
- int ret = 0;
|
|
|
+ word32 outLen;
|
|
|
+ word32 signSz;
|
|
|
+ int initTmpRng = 0;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
+ int ret = 0;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
- byte* encodedSig = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
+ byte* encodedSig = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
- byte encodedSig[MAX_ENCODED_SIG_SZ];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
+ byte encodedSig[MAX_ENCODED_SIG_SZ];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_MSG("wolfSSL_RSA_sign");
|
|
@@ -12913,7 +12913,7 @@ int wolfSSL_RSA_sign(int type, const unsigned char* m,
|
|
|
outLen = (word32)wolfSSL_BN_num_bytes(rsa->n);
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return 0;
|
|
|
|
|
@@ -14024,12 +14024,12 @@ int wolfSSL_EC_KEY_set_group(WOLFSSL_EC_KEY *key, WOLFSSL_EC_GROUP *group)
|
|
|
|
|
|
int wolfSSL_EC_KEY_generate_key(WOLFSSL_EC_KEY *key)
|
|
|
{
|
|
|
- int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
+ int initTmpRng = 0;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("wolfSSL_EC_KEY_generate_key");
|
|
@@ -14041,7 +14041,7 @@ int wolfSSL_EC_KEY_generate_key(WOLFSSL_EC_KEY *key)
|
|
|
}
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return 0;
|
|
|
#endif
|
|
@@ -14659,12 +14659,12 @@ WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_do_sign(const unsigned char *d, int dlen,
|
|
|
WOLFSSL_EC_KEY *key)
|
|
|
{
|
|
|
WOLFSSL_ECDSA_SIG *sig = NULL;
|
|
|
- int initTmpRng = 0;
|
|
|
- RNG* rng = NULL;
|
|
|
+ int initTmpRng = 0;
|
|
|
+ WC_RNG* rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG* tmpRNG = NULL;
|
|
|
+ WC_RNG* tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("wolfSSL_ECDSA_do_sign");
|
|
@@ -14686,7 +14686,7 @@ WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_do_sign(const unsigned char *d, int dlen,
|
|
|
}
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return NULL;
|
|
|
#endif
|
|
@@ -16347,11 +16347,11 @@ int wolfSSL_EC25519_generate_key(unsigned char *priv, unsigned int *privSz,
|
|
|
#else /* WOLFSSL_KEY_GEN */
|
|
|
int ret = SSL_FAILURE;
|
|
|
int initTmpRng = 0;
|
|
|
- RNG *rng = NULL;
|
|
|
+ WC_RNG *rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG *tmpRNG = NULL;
|
|
|
+ WC_RNG *tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("wolfSSL_EC25519_generate_key");
|
|
@@ -16363,7 +16363,7 @@ int wolfSSL_EC25519_generate_key(unsigned char *priv, unsigned int *privSz,
|
|
|
}
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return SSL_FAILURE;
|
|
|
#endif
|
|
@@ -16485,11 +16485,11 @@ int wolfSSL_ED25519_generate_key(unsigned char *priv, unsigned int *privSz,
|
|
|
#else /* WOLFSSL_KEY_GEN */
|
|
|
int ret = SSL_FAILURE;
|
|
|
int initTmpRng = 0;
|
|
|
- RNG *rng = NULL;
|
|
|
+ WC_RNG *rng = NULL;
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- RNG *tmpRNG = NULL;
|
|
|
+ WC_RNG *tmpRNG = NULL;
|
|
|
#else
|
|
|
- RNG tmpRNG[1];
|
|
|
+ WC_RNG tmpRNG[1];
|
|
|
#endif
|
|
|
|
|
|
WOLFSSL_ENTER("wolfSSL_ED25519_generate_key");
|
|
@@ -16501,7 +16501,7 @@ int wolfSSL_ED25519_generate_key(unsigned char *priv, unsigned int *privSz,
|
|
|
}
|
|
|
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
|
|
- tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
+ tmpRNG = (WC_RNG*)XMALLOC(sizeof(WC_RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
if (tmpRNG == NULL)
|
|
|
return SSL_FATAL_ERROR;
|
|
|
#endif
|