mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-04-29 18:03:23 +02:00
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/). * Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC. * wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify. * wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature. * wolfCrypt test and benchmark async support added for all HW acceleration. * wolfCrypt benchmark multi-threading support. * Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA. * Refactor to make sure “heap” is available for async dev init. * Added async support for all examples for connect, accept, read and write. * Added new WC_BIGINT (in wolfmath.c) for async hardware support. * Added async simulator tests for DES3 CBC, AES CBC/GCM. * Added QAT standalone build for unit testing. * Added int return code to SHA and MD5 functions. * Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer. * Combined duplicate code for async push/pop handling. * Refactor internal.c to add AllocKey / FreeKey. * Refactor of hash init/free in TLS to use InitHashes and FreeHashes. * Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*. * Suppress error message for WC_PENDING_E. * Implemented "wolfSSL_EVP_MD_CTX_init" to do memset. * Cleanup of the openssl compat CTX sizes when async is enabled. * Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability. * Cleanup of the OPAQUE_LEN. * Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret). * Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations) * Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding". * Updated RSA un-padding error message so its different than one above it for better debugging. * Added QAT async enables for each algorithm. * Refactor of the async init to use _ex. * Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing. * Reformatted the benchmark results: PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec" Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87 * Added min execution time for all benchmarks. * Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local. * Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark. * Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async. * Added NO_SW_BENCH option to only run HW bench. * Added support for PRNG to use hardware SHA256 if _wc devId provided. * Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size. * Added the wc_*GetHash calls to the wolfCrypt tests. * Added async hardware start/stop to wolfSSL init/cleanup. * Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos. * Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`. * Added arg checks on wc_*GetHash and wc_*Copy. * Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions. * Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator. * Added checks for all hashing to verify valid ->buffLen. * Fix for SHA512 scan-build warning about un-initialized “W_X”. * Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash. * Refactor of the benchmarking to use common function for start, check and finish of the stats. * Fixed issue with ECC cache loading in multi-threading. * Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned. * Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define. * Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
This commit is contained in:
+151
-106
@@ -1053,7 +1053,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
return UNSUPPORTED_SUITE;
|
||||
} /* switch */
|
||||
} /* if */
|
||||
if (ssl->options.cipherSuite0 != ECC_BYTE &&
|
||||
if (ssl->options.cipherSuite0 != ECC_BYTE &&
|
||||
ssl->options.cipherSuite0 != CHACHA_BYTE) { /* normal suites */
|
||||
switch (ssl->options.cipherSuite) {
|
||||
|
||||
@@ -1653,7 +1653,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BUILD_TLS_RSA_WITH_HC_128_SHA
|
||||
case TLS_RSA_WITH_HC_128_SHA :
|
||||
ssl->specs.bulk_cipher_algorithm = wolfssl_hc128;
|
||||
@@ -1667,7 +1667,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
ssl->specs.key_size = HC_128_KEY_SIZE;
|
||||
ssl->specs.block_size = 0;
|
||||
ssl->specs.iv_size = HC_128_IV_SIZE;
|
||||
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1684,7 +1684,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
ssl->specs.key_size = HC_128_KEY_SIZE;
|
||||
ssl->specs.block_size = 0;
|
||||
ssl->specs.iv_size = HC_128_IV_SIZE;
|
||||
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1701,7 +1701,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
ssl->specs.key_size = AES_128_KEY_SIZE;
|
||||
ssl->specs.iv_size = AES_IV_SIZE;
|
||||
ssl->specs.block_size = AES_BLOCK_SIZE;
|
||||
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1718,7 +1718,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
ssl->specs.key_size = AES_256_KEY_SIZE;
|
||||
ssl->specs.iv_size = AES_IV_SIZE;
|
||||
ssl->specs.block_size = AES_BLOCK_SIZE;
|
||||
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1827,7 +1827,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
|
||||
case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA :
|
||||
ssl->specs.bulk_cipher_algorithm = wolfssl_camellia;
|
||||
@@ -1978,7 +1978,7 @@ int SetCipherSpecs(WOLFSSL* ssl)
|
||||
ssl->specs.key_size = IDEA_KEY_SIZE;
|
||||
ssl->specs.block_size = IDEA_BLOCK_SIZE;
|
||||
ssl->specs.iv_size = IDEA_IV_SIZE;
|
||||
|
||||
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -2049,7 +2049,7 @@ static int SetPrefix(byte* sha_input, int idx)
|
||||
break;
|
||||
default:
|
||||
WOLFSSL_MSG("Set Prefix error, bad input");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -2070,22 +2070,20 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
dec->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec && dec->arc4 == NULL)
|
||||
return MEMORY_E;
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (devId != INVALID_DEVID) {
|
||||
if (enc) {
|
||||
if (wc_Arc4AsyncInit(enc->arc4, devId) != 0) {
|
||||
WOLFSSL_MSG("Arc4AsyncInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
if (dec) {
|
||||
if (wc_Arc4AsyncInit(dec->arc4, devId) != 0) {
|
||||
WOLFSSL_MSG("Arc4AsyncInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
if (wc_Arc4Init(enc->arc4, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("Arc4Init failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (dec) {
|
||||
if (wc_Arc4Init(dec->arc4, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("Arc4Init failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
|
||||
if (side == WOLFSSL_CLIENT_END) {
|
||||
if (enc)
|
||||
wc_Arc4SetKey(enc->arc4, keys->client_write_key, sz);
|
||||
@@ -2103,9 +2101,9 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* BUILD_ARC4 */
|
||||
|
||||
|
||||
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
/* Check that the max implicit iv size is suffecient */
|
||||
#if (AEAD_MAX_IMP_SZ < 12) /* CHACHA20_IMP_IV_SZ */
|
||||
@@ -2165,7 +2163,8 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_CHACHA && HAVE_POLY1305 */
|
||||
|
||||
|
||||
#ifdef HAVE_HC128
|
||||
/* check that buffer sizes are sufficient */
|
||||
@@ -2214,8 +2213,8 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_HC128 */
|
||||
|
||||
#ifdef BUILD_RABBIT
|
||||
/* check that buffer sizes are sufficient */
|
||||
#if (MAX_WRITE_IV_SZ < 8) /* RABBIT_IV_SIZE */
|
||||
@@ -2263,8 +2262,8 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BUILD_RABBIT */
|
||||
|
||||
#ifdef BUILD_DES3
|
||||
/* check that buffer sizes are sufficient */
|
||||
#if (MAX_WRITE_IV_SZ < 8) /* DES_IV_SIZE */
|
||||
@@ -2274,30 +2273,34 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (specs->bulk_cipher_algorithm == wolfssl_triple_des) {
|
||||
int desRet = 0;
|
||||
|
||||
if (enc && enc->des3 == NULL)
|
||||
enc->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc && enc->des3 == NULL)
|
||||
return MEMORY_E;
|
||||
if (dec && dec->des3 == NULL)
|
||||
dec->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec && dec->des3 == NULL)
|
||||
return MEMORY_E;
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (devId != INVALID_DEVID) {
|
||||
if (enc) {
|
||||
if (wc_Des3AsyncInit(enc->des3, devId) != 0) {
|
||||
WOLFSSL_MSG("Des3AsyncInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
if (dec) {
|
||||
if (wc_Des3AsyncInit(dec->des3, devId) != 0) {
|
||||
WOLFSSL_MSG("Des3AsyncInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
if (enc) {
|
||||
if (enc->des3 == NULL)
|
||||
enc->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc->des3 == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(enc->des3, 0, sizeof(Aes));
|
||||
}
|
||||
if (dec) {
|
||||
if (dec->des3 == NULL)
|
||||
dec->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec->des3 == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(dec->des3, 0, sizeof(Des3));
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
if (wc_Des3Init(enc->des3, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("Des3Init failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (dec) {
|
||||
if (wc_Des3Init(dec->des3, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("Des3Init failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
|
||||
if (side == WOLFSSL_CLIENT_END) {
|
||||
if (enc) {
|
||||
desRet = wc_Des3_SetKey(enc->des3, keys->client_write_key,
|
||||
@@ -2327,7 +2330,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* BUILD_DES3 */
|
||||
|
||||
#ifdef BUILD_AES
|
||||
/* check that buffer sizes are sufficient */
|
||||
@@ -2338,30 +2341,33 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (specs->bulk_cipher_algorithm == wolfssl_aes) {
|
||||
int aesRet = 0;
|
||||
|
||||
if (enc && enc->aes == NULL)
|
||||
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc && enc->aes == NULL)
|
||||
return MEMORY_E;
|
||||
if (dec && dec->aes == NULL)
|
||||
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec && dec->aes == NULL)
|
||||
return MEMORY_E;
|
||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||
if (devId != INVALID_DEVID) {
|
||||
if (enc) {
|
||||
if (wc_AesAsyncInit(enc->aes, devId) != 0) {
|
||||
WOLFSSL_MSG("AesAsyncInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
if (dec) {
|
||||
if (wc_AesAsyncInit(dec->aes, devId) != 0) {
|
||||
WOLFSSL_MSG("AesAsyncInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
if (enc) {
|
||||
if (enc->aes == NULL)
|
||||
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc->aes == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(enc->aes, 0, sizeof(Aes));
|
||||
}
|
||||
if (dec) {
|
||||
if (dec->aes == NULL)
|
||||
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec->aes == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(dec->aes, 0, sizeof(Aes));
|
||||
}
|
||||
if (enc) {
|
||||
if (wc_AesInit(enc->aes, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("AesInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (dec) {
|
||||
if (wc_AesInit(dec->aes, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("AesInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
|
||||
if (side == WOLFSSL_CLIENT_END) {
|
||||
if (enc) {
|
||||
aesRet = wc_AesSetKey(enc->aes, keys->client_write_key,
|
||||
@@ -2395,7 +2401,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* BUILD_AES */
|
||||
|
||||
#ifdef BUILD_AESGCM
|
||||
/* check that buffer sizes are sufficient */
|
||||
@@ -2412,14 +2418,33 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (specs->bulk_cipher_algorithm == wolfssl_aes_gcm) {
|
||||
int gcmRet;
|
||||
|
||||
if (enc && enc->aes == NULL)
|
||||
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc && enc->aes == NULL)
|
||||
return MEMORY_E;
|
||||
if (dec && dec->aes == NULL)
|
||||
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec && dec->aes == NULL)
|
||||
return MEMORY_E;
|
||||
if (enc) {
|
||||
if (enc->aes == NULL)
|
||||
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc->aes == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(enc->aes, 0, sizeof(Aes));
|
||||
}
|
||||
if (dec) {
|
||||
if (dec->aes == NULL)
|
||||
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec->aes == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(dec->aes, 0, sizeof(Aes));
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
if (wc_AesInit(enc->aes, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("AesInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
if (dec) {
|
||||
if (wc_AesInit(dec->aes, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("AesInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
|
||||
if (side == WOLFSSL_CLIENT_END) {
|
||||
if (enc) {
|
||||
@@ -2458,7 +2483,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* BUILD_AESGCM */
|
||||
|
||||
#ifdef HAVE_AESCCM
|
||||
/* check that buffer sizes are sufficient (CCM is same size as GCM) */
|
||||
@@ -2475,14 +2500,33 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (specs->bulk_cipher_algorithm == wolfssl_aes_ccm) {
|
||||
int CcmRet;
|
||||
|
||||
if (enc && enc->aes == NULL)
|
||||
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc && enc->aes == NULL)
|
||||
return MEMORY_E;
|
||||
if (dec && dec->aes == NULL)
|
||||
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec && dec->aes == NULL)
|
||||
return MEMORY_E;
|
||||
if (enc) {
|
||||
if (enc->aes == NULL)
|
||||
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (enc->aes == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(enc->aes, 0, sizeof(Aes));
|
||||
}
|
||||
if (dec) {
|
||||
if (dec->aes == NULL)
|
||||
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
||||
if (dec->aes == NULL)
|
||||
return MEMORY_E;
|
||||
XMEMSET(dec->aes, 0, sizeof(Aes));
|
||||
}
|
||||
|
||||
if (enc) {
|
||||
if (wc_AesInit(enc->aes, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("AesInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
if (dec) {
|
||||
if (wc_AesInit(dec->aes, heap, devId) != 0) {
|
||||
WOLFSSL_MSG("AesInit failed in SetKeys");
|
||||
return ASYNC_INIT_E;
|
||||
}
|
||||
}
|
||||
|
||||
if (side == WOLFSSL_CLIENT_END) {
|
||||
if (enc) {
|
||||
@@ -2529,7 +2573,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_AESCCM */
|
||||
|
||||
#ifdef HAVE_CAMELLIA
|
||||
/* check that buffer sizes are sufficient */
|
||||
@@ -2581,7 +2625,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_CAMELLIA */
|
||||
|
||||
#ifdef HAVE_IDEA
|
||||
/* check that buffer sizes are sufficient */
|
||||
@@ -2635,7 +2679,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
||||
if (dec)
|
||||
dec->setup = 1;
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_IDEA */
|
||||
|
||||
#ifdef HAVE_NULL_CIPHER
|
||||
if (specs->bulk_cipher_algorithm == wolfssl_cipher_null) {
|
||||
@@ -2686,6 +2730,7 @@ static int SetAuthKeys(OneTimeAuth* authentication, Keys* keys,
|
||||
(void)keys;
|
||||
(void)specs;
|
||||
(void)devId;
|
||||
(void)authentication;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2892,12 +2937,12 @@ int StoreKeys(WOLFSSL* ssl, const byte* keyData)
|
||||
#ifndef NO_OLD_TLS
|
||||
int DeriveKeys(WOLFSSL* ssl)
|
||||
{
|
||||
int length = 2 * ssl->specs.hash_size +
|
||||
int length = 2 * ssl->specs.hash_size +
|
||||
2 * ssl->specs.key_size +
|
||||
2 * ssl->specs.iv_size;
|
||||
int rounds = (length + MD5_DIGEST_SIZE - 1 ) / MD5_DIGEST_SIZE, i;
|
||||
int ret = 0;
|
||||
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
byte* shaOutput;
|
||||
byte* md5Input;
|
||||
@@ -2913,9 +2958,9 @@ int DeriveKeys(WOLFSSL* ssl)
|
||||
Md5 md5[1];
|
||||
Sha sha[1];
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
shaOutput = (byte*)XMALLOC(SHA_DIGEST_SIZE,
|
||||
shaOutput = (byte*)XMALLOC(SHA_DIGEST_SIZE,
|
||||
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
md5Input = (byte*)XMALLOC(SECRET_LEN + SHA_DIGEST_SIZE,
|
||||
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
@@ -2925,7 +2970,7 @@ int DeriveKeys(WOLFSSL* ssl)
|
||||
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
|
||||
if (shaOutput == NULL || md5Input == NULL || shaInput == NULL ||
|
||||
keyData == NULL || md5 == NULL || sha == NULL) {
|
||||
if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
@@ -2934,7 +2979,7 @@ int DeriveKeys(WOLFSSL* ssl)
|
||||
if (keyData) XFREE(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (md5) XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (sha) XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
|
||||
return MEMORY_E;
|
||||
}
|
||||
#endif
|
||||
@@ -3045,7 +3090,7 @@ static int MakeSslMasterSecret(WOLFSSL* ssl)
|
||||
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
|
||||
if (shaOutput == NULL || md5Input == NULL || shaInput == NULL ||
|
||||
md5 == NULL || sha == NULL) {
|
||||
if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
@@ -3053,15 +3098,15 @@ static int MakeSslMasterSecret(WOLFSSL* ssl)
|
||||
if (shaInput) XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (md5) XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (sha) XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
|
||||
return MEMORY_E;
|
||||
}
|
||||
#endif
|
||||
|
||||
wc_InitMd5(md5);
|
||||
|
||||
|
||||
ret = wc_InitSha(sha);
|
||||
|
||||
|
||||
if (ret == 0) {
|
||||
XMEMCPY(md5Input, ssl->arrays->preMasterSecret, pmsSz);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user