More macro preproc stuff

This commit is contained in:
Juliusz Sosinowicz
2020-01-16 20:06:30 +01:00
parent 48b39a34c7
commit f765b711bf
5 changed files with 31 additions and 15 deletions

View File

@ -16726,9 +16726,11 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
ctx->bufUsed = 0;
ctx->lastUsed = 0;
#ifdef HAVE_WOLFSSL_EVP_CIPHER_CTX_IV
if (!iv && ctx->ivSz) {
iv = ctx->iv;
}
#endif
#ifndef NO_AES
#ifdef HAVE_AES_CBC
@ -17170,12 +17172,14 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
ctx->keyLen = 0;
ctx->block_size = 16;
}
#ifdef HAVE_WOLFSSL_EVP_CIPHER_CTX_IV
ctx->ivSz = wolfSSL_EVP_CIPHER_CTX_iv_length(ctx);
if (iv && iv != ctx->iv) {
if (wolfSSL_StoreExternalIV(ctx) != WOLFSSL_SUCCESS) {
return WOLFSSL_FAILURE;
}
}
#endif
(void)ret; /* remove warning. If execution reaches this point, ret=0 */
return WOLFSSL_SUCCESS;
}
@ -31970,9 +31974,11 @@ WOLFSSL_EC_KEY* wolfSSL_EVP_PKEY_get1_EC_KEY(WOLFSSL_EVP_PKEY* key)
wolfSSL_EC_KEY_free(local);
local = NULL;
}
#ifdef OPENSSL_ALL
if (!local && key->ecc) {
local = wolfSSL_EC_KEY_dup(key->ecc);
}
#endif
return local;
}
#endif /* HAVE_ECC */
@ -32718,7 +32724,7 @@ int wolfSSL_PEM_write_bio_RSAPrivateKey(WOLFSSL_BIO* bio, WOLFSSL_RSA* key,
pkey->type = EVP_PKEY_RSA;
pkey->rsa = key;
pkey->ownRsa = 0;
#ifdef WOLFSSL_KEY_GEN
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && !defined(HAVE_USER_RSA)
/* similar to how wolfSSL_PEM_write_mem_RSAPrivateKey finds DER of key */
{
int derSz;
@ -46728,8 +46734,8 @@ int wolfSSL_BN_clear_bit(WOLFSSL_BIGNUM* bn, int n)
mp_int res[1];
mp_int tmp[1];
#else
mp_int* res = null;
mp_int* tmp = null;
mp_int* res = NULL;
mp_int* tmp = NULL;
#endif
if (bn == NULL || bn->internal == NULL) {
@ -46766,9 +46772,9 @@ int wolfSSL_BN_clear_bit(WOLFSSL_BIGNUM* bn, int n)
ret = WOLFSSL_SUCCESS;
cleanup:
#ifdef WOLFSSL_SMALL_STACK
if (res):
if (res)
XFREE(res, NULL, DYNAMIC_TYPE_BIGINT);
if (tmp):
if (tmp)
XFREE(tmp, NULL, DYNAMIC_TYPE_BIGINT);
#endif
return ret;
@ -47984,9 +47990,10 @@ static void InitwolfSSL_Rsa(WOLFSSL_RSA* rsa)
void wolfSSL_RSA_free(WOLFSSL_RSA* rsa)
{
WOLFSSL_ENTER("wolfSSL_RSA_free");
int doFree = 0;
if (rsa) {
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
int doFree = 0;
if (wc_LockMutex(&rsa->refMutex) != 0) {
WOLFSSL_MSG("Couldn't lock rsa mutex");
}
@ -48003,6 +48010,7 @@ void wolfSSL_RSA_free(WOLFSSL_RSA* rsa)
}
wc_FreeMutex(&rsa->refMutex);
#endif
if (rsa->internal) {
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && \
@ -48114,8 +48122,10 @@ WOLFSSL_RSA* wolfSSL_RSA_new(void)
external->internal = key;
external->inSet = 0;
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)
external->refCount = 1;
wc_InitMutex(&external->refMutex);
#endif
return external;
}
#endif /* !NO_RSA && (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */

View File

@ -1945,17 +1945,16 @@ static void test_wolfSSL_ECDSA_SIG(void)
static void test_ECDSA_size_sign(void)
{
#ifdef HAVE_ECC
#if defined(HAVE_ECC) && !defined(NO_ECC256) && !defined(NO_ECC_SECP)
EC_KEY *key;
int id;
byte hash[WC_SHA_DIGEST_SIZE];
byte hash[WC_MAX_DIGEST_SIZE];
byte sig[ECC_BUFSIZE];
unsigned int sigSz = sizeof(sig);
XMEMSET(hash, 123, sizeof(hash));
#if !defined(NO_ECC256) && !defined(NO_ECC_SECP)
id = wc_ecc_get_curve_id_from_name("SECP256R1");
AssertIntEQ(id, ECC_SECP256R1);
@ -1964,9 +1963,8 @@ static void test_ECDSA_size_sign(void)
AssertIntEQ(ECDSA_sign(0, hash, sizeof(hash), sig, &sigSz, key), 1);
AssertIntGE(ECDSA_size(key), sigSz);
EC_KEY_free(key);
#endif
#endif /* HAVE_ECC */
#endif /* HAVE_ECC && !NO_ECC256 && !NO_ECC_SECP */
}
#endif /* OPENSSL_EXTRA */

View File

@ -128,8 +128,8 @@ extern int wc_InitRsaHw(RsaKey* key);
#define ERROR_OUT(err, eLabel) { ret = (err); goto eLabel; }
#if defined(HAVE_SELFTEST) || !defined(NO_SKID)
#include <wolfssl/internal.h>
#if defined(HAVE_SELFTEST) || !defined(NO_SKID)
#ifndef WOLFSSL_AES_KEY_SIZE_ENUM
#define WOLFSSL_AES_KEY_SIZE_ENUM
enum Asn_Misc {

View File

@ -256,14 +256,17 @@ struct WOLFSSL_EVP_CIPHER_CTX {
#elif !defined(NO_DES3)
/* working iv pointer into cipher */
ALIGN16 unsigned char iv[DES_BLOCK_SIZE];
#elif defined(HAVE_IDEA)
/* working iv pointer into cipher */
ALIGN16 unsigned char iv[IDEA_BLOCK_SIZE];
#endif
WOLFSSL_Cipher cipher;
ALIGN16 byte buf[WOLFSSL_EVP_BUF_SIZE];
int bufUsed;
ALIGN16 byte lastBlock[WOLFSSL_EVP_BUF_SIZE];
int lastUsed;
#if defined(HAVE_AESGCM) || defined(HAVE_AES_CBC) || defined(WOLFSSL_AES_COUNTER) \
|| !defined(NO_DES3) || defined(HAVE_IDEA)
#if !defined(NO_AES) || !defined(NO_DES3) || defined(HAVE_IDEA)
#define HAVE_WOLFSSL_EVP_CIPHER_CTX_IV
int ivSz;
ALIGN16 unsigned char authTag[AES_BLOCK_SIZE];
int authTagSz;

View File

@ -775,8 +775,13 @@ wolfSSL_X509_STORE_set_verify_cb((WOLFSSL_X509_STORE *)(s), (WOLFSSL_X509_STORE_
#define ERR_reason_error_string wolfSSL_ERR_reason_error_string
#define ERR_load_BIO_strings wolfSSL_ERR_load_BIO_strings
#define PEMerr(func, reason) wolfSSL_ERR_put_error(ERR_LIB_PEM,\
#ifndef WOLFCRYPT_ONLY
#define PEMerr(func, reason) wolfSSL_ERR_put_error(ERR_LIB_PEM, \
(func), (reason), __FILE__, __LINE__)
#else
#define PEMerr(func, reason) WOLFSSL_ERROR_LINE((reason), \
NULL, __LINE__, __FILE__, NULL)
#endif
#define SSLv23_server_method wolfSSLv23_server_method
#define SSL_CTX_set_options wolfSSL_CTX_set_options