mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Shorten variable names
This commit is contained in:
@@ -46081,7 +46081,7 @@ static int test_evp_cipher_aes_gcm(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The call to EVP_CipherInit below (with NULL key) should clear the
|
* The call to EVP_CipherInit below (with NULL key) should clear the
|
||||||
* gcmccmIvGenEnable flag set by EVP_CTRL_GCM_SET_IV_FIXED. As such, a
|
* ivGenEnable flag set by EVP_CTRL_GCM_SET_IV_FIXED. As such, a
|
||||||
* subsequent EVP_CTRL_GCM_IV_GEN should fail. This matches OpenSSL
|
* subsequent EVP_CTRL_GCM_IV_GEN should fail. This matches OpenSSL
|
||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
|
@@ -584,12 +584,12 @@ static int evpCipherBlock(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
static int wolfSSL_EVP_CipherUpdate_GCM_AAD(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
static int wolfSSL_EVP_CipherUpdate_GCM_AAD(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||||
const unsigned char *in, int inl) {
|
const unsigned char *in, int inl) {
|
||||||
if (in && inl > 0) {
|
if (in && inl > 0) {
|
||||||
byte* tmp = (byte*)XREALLOC(ctx->gcmccmAuthIn,
|
byte* tmp = (byte*)XREALLOC(ctx->authIn,
|
||||||
ctx->gcmccmAuthInSz + inl, NULL, DYNAMIC_TYPE_OPENSSL);
|
ctx->authInSz + inl, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ctx->gcmccmAuthIn = tmp;
|
ctx->authIn = tmp;
|
||||||
XMEMCPY(ctx->gcmccmAuthIn + ctx->gcmccmAuthInSz, in, inl);
|
XMEMCPY(ctx->authIn + ctx->authInSz, in, inl);
|
||||||
ctx->gcmccmAuthInSz += inl;
|
ctx->authInSz += inl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("realloc error");
|
WOLFSSL_MSG("realloc error");
|
||||||
@@ -612,13 +612,13 @@ static int wolfSSL_EVP_CipherUpdate_GCM(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
/* Buffer input for one-shot API */
|
/* Buffer input for one-shot API */
|
||||||
if (inl > 0) {
|
if (inl > 0) {
|
||||||
byte* tmp;
|
byte* tmp;
|
||||||
tmp = (byte*)XREALLOC(ctx->gcmccmBuffer,
|
tmp = (byte*)XREALLOC(ctx->buffer,
|
||||||
ctx->gcmccmBufferLen + inl, NULL,
|
ctx->bufferLen + inl, NULL,
|
||||||
DYNAMIC_TYPE_OPENSSL);
|
DYNAMIC_TYPE_OPENSSL);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
XMEMCPY(tmp + ctx->gcmccmBufferLen, in, inl);
|
XMEMCPY(tmp + ctx->bufferLen, in, inl);
|
||||||
ctx->gcmccmBufferLen += inl;
|
ctx->bufferLen += inl;
|
||||||
ctx->gcmccmBuffer = tmp;
|
ctx->buffer = tmp;
|
||||||
*outl = 0;
|
*outl = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -677,12 +677,12 @@ static int wolfSSL_EVP_CipherUpdate_GCM(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
static int wolfSSL_EVP_CipherUpdate_CCM_AAD(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
static int wolfSSL_EVP_CipherUpdate_CCM_AAD(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||||
const unsigned char *in, int inl) {
|
const unsigned char *in, int inl) {
|
||||||
if (in && inl > 0) {
|
if (in && inl > 0) {
|
||||||
byte* tmp = (byte*)XREALLOC(ctx->gcmccmAuthIn,
|
byte* tmp = (byte*)XREALLOC(ctx->authIn,
|
||||||
ctx->gcmccmAuthInSz + inl, NULL, DYNAMIC_TYPE_OPENSSL);
|
ctx->authInSz + inl, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
ctx->gcmccmAuthIn = tmp;
|
ctx->authIn = tmp;
|
||||||
XMEMCPY(ctx->gcmccmAuthIn + ctx->gcmccmAuthInSz, in, inl);
|
XMEMCPY(ctx->authIn + ctx->authInSz, in, inl);
|
||||||
ctx->gcmccmAuthInSz += inl;
|
ctx->authInSz += inl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WOLFSSL_MSG("realloc error");
|
WOLFSSL_MSG("realloc error");
|
||||||
@@ -703,13 +703,13 @@ static int wolfSSL_EVP_CipherUpdate_CCM(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
|||||||
/* Buffer input for one-shot API */
|
/* Buffer input for one-shot API */
|
||||||
if (inl > 0) {
|
if (inl > 0) {
|
||||||
byte* tmp;
|
byte* tmp;
|
||||||
tmp = (byte*)XREALLOC(ctx->gcmccmBuffer,
|
tmp = (byte*)XREALLOC(ctx->buffer,
|
||||||
ctx->gcmccmBufferLen + inl, NULL,
|
ctx->bufferLen + inl, NULL,
|
||||||
DYNAMIC_TYPE_OPENSSL);
|
DYNAMIC_TYPE_OPENSSL);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
XMEMCPY(tmp + ctx->gcmccmBufferLen, in, inl);
|
XMEMCPY(tmp + ctx->bufferLen, in, inl);
|
||||||
ctx->gcmccmBufferLen += inl;
|
ctx->bufferLen += inl;
|
||||||
ctx->gcmccmBuffer = tmp;
|
ctx->buffer = tmp;
|
||||||
*outl = 0;
|
*outl = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -957,36 +957,36 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||||||
case AES_192_GCM_TYPE:
|
case AES_192_GCM_TYPE:
|
||||||
case AES_256_GCM_TYPE:
|
case AES_256_GCM_TYPE:
|
||||||
#ifndef WOLFSSL_AESGCM_STREAM
|
#ifndef WOLFSSL_AESGCM_STREAM
|
||||||
if ((ctx->gcmccmBuffer && ctx->gcmccmBufferLen > 0)
|
if ((ctx->buffer && ctx->bufferLen > 0)
|
||||||
|| (ctx->gcmccmBufferLen == 0)) {
|
|| (ctx->bufferLen == 0)) {
|
||||||
if (ctx->enc)
|
if (ctx->enc)
|
||||||
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, out,
|
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, out,
|
||||||
ctx->gcmccmBuffer, ctx->gcmccmBufferLen,
|
ctx->buffer, ctx->bufferLen,
|
||||||
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
ctx->gcmccmAuthIn, ctx->gcmccmAuthInSz);
|
ctx->authIn, ctx->authInSz);
|
||||||
else
|
else
|
||||||
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, out,
|
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, out,
|
||||||
ctx->gcmccmBuffer, ctx->gcmccmBufferLen,
|
ctx->buffer, ctx->bufferLen,
|
||||||
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
ctx->gcmccmAuthIn, ctx->gcmccmAuthInSz);
|
ctx->authIn, ctx->authInSz);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = WOLFSSL_SUCCESS;
|
ret = WOLFSSL_SUCCESS;
|
||||||
*outl = ctx->gcmccmBufferLen;
|
*outl = ctx->bufferLen;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = WOLFSSL_FAILURE;
|
ret = WOLFSSL_FAILURE;
|
||||||
*outl = 0;
|
*outl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFREE(ctx->gcmccmBuffer, NULL, DYNAMIC_TYPE_OPENSSL);
|
XFREE(ctx->buffer, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
ctx->gcmccmBuffer = NULL;
|
ctx->buffer = NULL;
|
||||||
ctx->gcmccmBufferLen = 0;
|
ctx->bufferLen = 0;
|
||||||
|
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
IncCtr((byte*)ctx->cipher.aes.reg,
|
IncCtr((byte*)ctx->cipher.aes.reg,
|
||||||
ctx->cipher.aes.nonceSz);
|
ctx->cipher.aes.nonceSz);
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1002,7 +1002,7 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||||||
else {
|
else {
|
||||||
ret = wc_AesGcmDecryptFinal(&ctx->cipher.aes, ctx->authTag,
|
ret = wc_AesGcmDecryptFinal(&ctx->cipher.aes, ctx->authTag,
|
||||||
ctx->authTagSz);
|
ctx->authTagSz);
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
IncCtr((byte*)ctx->cipher.aes.reg, ctx->cipher.aes.nonceSz);
|
IncCtr((byte*)ctx->cipher.aes.reg, ctx->cipher.aes.nonceSz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1023,8 +1023,8 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||||||
}
|
}
|
||||||
#endif /* WOLFSSL_AESGCM_STREAM */
|
#endif /* WOLFSSL_AESGCM_STREAM */
|
||||||
if (ret == WOLFSSL_SUCCESS) {
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Clear IV, since IV reuse is not recommended for AES GCM. */
|
/* Clear IV, since IV reuse is not recommended for AES GCM. */
|
||||||
@@ -1042,44 +1042,44 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||||||
case AES_128_CCM_TYPE:
|
case AES_128_CCM_TYPE:
|
||||||
case AES_192_CCM_TYPE:
|
case AES_192_CCM_TYPE:
|
||||||
case AES_256_CCM_TYPE:
|
case AES_256_CCM_TYPE:
|
||||||
if ((ctx->gcmccmBuffer && ctx->gcmccmBufferLen > 0)
|
if ((ctx->buffer && ctx->bufferLen > 0)
|
||||||
|| (ctx->gcmccmBufferLen == 0)) {
|
|| (ctx->bufferLen == 0)) {
|
||||||
if (ctx->enc)
|
if (ctx->enc)
|
||||||
ret = wc_AesCcmEncrypt(&ctx->cipher.aes, out,
|
ret = wc_AesCcmEncrypt(&ctx->cipher.aes, out,
|
||||||
ctx->gcmccmBuffer, ctx->gcmccmBufferLen,
|
ctx->buffer, ctx->bufferLen,
|
||||||
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
ctx->gcmccmAuthIn, ctx->gcmccmAuthInSz);
|
ctx->authIn, ctx->authInSz);
|
||||||
else
|
else
|
||||||
ret = wc_AesCcmDecrypt(&ctx->cipher.aes, out,
|
ret = wc_AesCcmDecrypt(&ctx->cipher.aes, out,
|
||||||
ctx->gcmccmBuffer, ctx->gcmccmBufferLen,
|
ctx->buffer, ctx->bufferLen,
|
||||||
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
ctx->gcmccmAuthIn, ctx->gcmccmAuthInSz);
|
ctx->authIn, ctx->authInSz);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = WOLFSSL_SUCCESS;
|
ret = WOLFSSL_SUCCESS;
|
||||||
*outl = ctx->gcmccmBufferLen;
|
*outl = ctx->bufferLen;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = WOLFSSL_FAILURE;
|
ret = WOLFSSL_FAILURE;
|
||||||
*outl = 0;
|
*outl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFREE(ctx->gcmccmBuffer, NULL, DYNAMIC_TYPE_OPENSSL);
|
XFREE(ctx->buffer, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
ctx->gcmccmBuffer = NULL;
|
ctx->buffer = NULL;
|
||||||
ctx->gcmccmBufferLen = 0;
|
ctx->bufferLen = 0;
|
||||||
|
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
IncCtr((byte*)ctx->cipher.aes.reg,
|
IncCtr((byte*)ctx->cipher.aes.reg,
|
||||||
ctx->cipher.aes.nonceSz);
|
ctx->cipher.aes.nonceSz);
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*outl = 0;
|
*outl = 0;
|
||||||
}
|
}
|
||||||
if (ret == WOLFSSL_SUCCESS) {
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Clear IV, since IV reuse is not recommended for AES CCM. */
|
/* Clear IV, since IV reuse is not recommended for AES CCM. */
|
||||||
@@ -1184,7 +1184,7 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||||||
ctx->cipherType == AES_256_CCM_TYPE
|
ctx->cipherType == AES_256_CCM_TYPE
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
tmp = ctx->gcmccmIvGenEnable;
|
tmp = ctx->ivGenEnable;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1205,7 +1205,7 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||||||
ctx->cipherType == AES_256_CCM_TYPE
|
ctx->cipherType == AES_256_CCM_TYPE
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
ctx->gcmccmIvGenEnable = tmp;
|
ctx->ivGenEnable = tmp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -5866,7 +5866,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
* command be issued before a EVP_CTRL_GCM_IV_GEN command.
|
* command be issued before a EVP_CTRL_GCM_IV_GEN command.
|
||||||
* This flag is used to enforce that.
|
* This flag is used to enforce that.
|
||||||
*/
|
*/
|
||||||
ctx->gcmccmIvGenEnable = 1;
|
ctx->ivGenEnable = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /* !WC_NO_RNG */
|
#endif /* !WC_NO_RNG */
|
||||||
@@ -5883,7 +5883,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
case EVP_CTRL_GCM_IV_GEN:
|
case EVP_CTRL_GCM_IV_GEN:
|
||||||
if ((ctx->flags & WOLFSSL_EVP_CIPH_FLAG_AEAD_CIPHER) == 0)
|
if ((ctx->flags & WOLFSSL_EVP_CIPH_FLAG_AEAD_CIPHER) == 0)
|
||||||
break;
|
break;
|
||||||
if (!ctx->gcmccmIvGenEnable) {
|
if (!ctx->ivGenEnable) {
|
||||||
WOLFSSL_MSG("Must use EVP_CTRL_AEAD_SET_IV_FIXED before "
|
WOLFSSL_MSG("Must use EVP_CTRL_AEAD_SET_IV_FIXED before "
|
||||||
"EVP_CTRL_GCM_IV_GEN");
|
"EVP_CTRL_GCM_IV_GEN");
|
||||||
break;
|
break;
|
||||||
@@ -5911,7 +5911,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
* The gcmIncIV flag indicates that the IV should be incremented
|
* The gcmIncIV flag indicates that the IV should be incremented
|
||||||
* after the next cipher operation.
|
* after the next cipher operation.
|
||||||
*/
|
*/
|
||||||
ctx->gcmccmIncIv = 1;
|
ctx->incIv = 1;
|
||||||
ret = WOLFSSL_SUCCESS;
|
ret = WOLFSSL_SUCCESS;
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_AESGCM && !_WIN32 && !HAVE_SELFTEST && (!HAVE_FIPS ||
|
#endif /* HAVE_AESGCM && !_WIN32 && !HAVE_SELFTEST && (!HAVE_FIPS ||
|
||||||
@@ -6004,18 +6004,18 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
#endif
|
#endif
|
||||||
ctx->keyLen = 0;
|
ctx->keyLen = 0;
|
||||||
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
||||||
if (ctx->gcmccmBuffer) {
|
if (ctx->buffer) {
|
||||||
XFREE(ctx->gcmccmBuffer, NULL, DYNAMIC_TYPE_OPENSSL);
|
XFREE(ctx->buffer, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
ctx->gcmccmBuffer = NULL;
|
ctx->buffer = NULL;
|
||||||
}
|
}
|
||||||
ctx->gcmccmBufferLen = 0;
|
ctx->bufferLen = 0;
|
||||||
if (ctx->gcmccmAuthIn) {
|
if (ctx->authIn) {
|
||||||
XFREE(ctx->gcmccmAuthIn, NULL, DYNAMIC_TYPE_OPENSSL);
|
XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
ctx->gcmccmAuthIn = NULL;
|
ctx->authIn = NULL;
|
||||||
}
|
}
|
||||||
ctx->gcmccmAuthInSz = 0;
|
ctx->authInSz = 0;
|
||||||
ctx->gcmccmIvGenEnable = 0;
|
ctx->ivGenEnable = 0;
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6134,11 +6134,11 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
{
|
{
|
||||||
int ret = WOLFSSL_SUCCESS;
|
int ret = WOLFSSL_SUCCESS;
|
||||||
|
|
||||||
if (ctx->gcmccmAuthIn) {
|
if (ctx->authIn) {
|
||||||
XFREE(ctx->gcmccmAuthIn, NULL, DYNAMIC_TYPE_OPENSSL);
|
XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
ctx->gcmccmAuthIn = NULL;
|
ctx->authIn = NULL;
|
||||||
}
|
}
|
||||||
ctx->gcmccmAuthInSz = 0;
|
ctx->authInSz = 0;
|
||||||
|
|
||||||
ctx->block_size = AES_BLOCK_SIZE;
|
ctx->block_size = AES_BLOCK_SIZE;
|
||||||
ctx->authTagSz = AES_BLOCK_SIZE;
|
ctx->authTagSz = AES_BLOCK_SIZE;
|
||||||
@@ -6210,7 +6210,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
* If a key is provided, the flag retains its value.
|
* If a key is provided, the flag retains its value.
|
||||||
*/
|
*/
|
||||||
if (ret == WOLFSSL_SUCCESS && key == NULL) {
|
if (ret == WOLFSSL_SUCCESS && key == NULL) {
|
||||||
ctx->gcmccmIvGenEnable = 0;
|
ctx->ivGenEnable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -6230,19 +6230,19 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
if (ctx->enc) {
|
if (ctx->enc) {
|
||||||
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, dst, src,
|
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, dst, src,
|
||||||
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
||||||
ctx->authTagSz, ctx->gcmccmAuthIn,
|
ctx->authTagSz, ctx->authIn,
|
||||||
ctx->gcmccmAuthInSz);
|
ctx->authInSz);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, dst, src,
|
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, dst, src,
|
||||||
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
||||||
ctx->authTagSz, ctx->gcmccmAuthIn,
|
ctx->authTagSz, ctx->authIn,
|
||||||
ctx->gcmccmAuthInSz);
|
ctx->authInSz);
|
||||||
}
|
}
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
IncCtr((byte*)ctx->cipher.aes.reg,
|
IncCtr((byte*)ctx->cipher.aes.reg,
|
||||||
ctx->cipher.aes.nonceSz);
|
ctx->cipher.aes.nonceSz);
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -6291,7 +6291,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
/* Calculate authentication tag and compare. */
|
/* Calculate authentication tag and compare. */
|
||||||
ret = wc_AesGcmDecryptFinal(&ctx->cipher.aes,
|
ret = wc_AesGcmDecryptFinal(&ctx->cipher.aes,
|
||||||
ctx->authTag, ctx->authTagSz);
|
ctx->authTag, ctx->authTagSz);
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
IncCtr((byte*)ctx->cipher.aes.reg,
|
IncCtr((byte*)ctx->cipher.aes.reg,
|
||||||
ctx->cipher.aes.nonceSz);
|
ctx->cipher.aes.nonceSz);
|
||||||
}
|
}
|
||||||
@@ -6303,7 +6303,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
WOLFSSL_MSG("wc_AesGcmInit failed");
|
WOLFSSL_MSG("wc_AesGcmInit failed");
|
||||||
return WOLFSSL_FATAL_ERROR;
|
return WOLFSSL_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
#endif /* WOLFSSL_AESGCM_STREAM */
|
#endif /* WOLFSSL_AESGCM_STREAM */
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
@@ -6311,10 +6311,10 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
* Clear any leftover AAD on final (final is when src is
|
* Clear any leftover AAD on final (final is when src is
|
||||||
* NULL).
|
* NULL).
|
||||||
*/
|
*/
|
||||||
if (ctx->gcmccmAuthIn != NULL) {
|
if (ctx->authIn != NULL) {
|
||||||
XMEMSET(ctx->gcmccmAuthIn, 0, ctx->gcmccmAuthInSz);
|
XMEMSET(ctx->authIn, 0, ctx->authInSz);
|
||||||
}
|
}
|
||||||
ctx->gcmccmAuthInSz = 0;
|
ctx->authInSz = 0;
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = len;
|
ret = len;
|
||||||
@@ -6334,11 +6334,11 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
{
|
{
|
||||||
int ret = WOLFSSL_SUCCESS;
|
int ret = WOLFSSL_SUCCESS;
|
||||||
|
|
||||||
if (ctx->gcmccmAuthIn) {
|
if (ctx->authIn) {
|
||||||
XFREE(ctx->gcmccmAuthIn, NULL, DYNAMIC_TYPE_OPENSSL);
|
XFREE(ctx->authIn, NULL, DYNAMIC_TYPE_OPENSSL);
|
||||||
ctx->gcmccmAuthIn = NULL;
|
ctx->authIn = NULL;
|
||||||
}
|
}
|
||||||
ctx->gcmccmAuthInSz = 0;
|
ctx->authInSz = 0;
|
||||||
|
|
||||||
ctx->block_size = AES_BLOCK_SIZE;
|
ctx->block_size = AES_BLOCK_SIZE;
|
||||||
ctx->authTagSz = AES_BLOCK_SIZE;
|
ctx->authTagSz = AES_BLOCK_SIZE;
|
||||||
@@ -6394,7 +6394,7 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
* If a key is provided, the flag retains its value.
|
* If a key is provided, the flag retains its value.
|
||||||
*/
|
*/
|
||||||
if (ret == WOLFSSL_SUCCESS && key == NULL) {
|
if (ret == WOLFSSL_SUCCESS && key == NULL) {
|
||||||
ctx->gcmccmIvGenEnable = 0;
|
ctx->ivGenEnable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -6413,19 +6413,19 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
if (ctx->enc) {
|
if (ctx->enc) {
|
||||||
ret = wc_AesCcmEncrypt(&ctx->cipher.aes, dst, src,
|
ret = wc_AesCcmEncrypt(&ctx->cipher.aes, dst, src,
|
||||||
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
||||||
ctx->authTagSz, ctx->gcmccmAuthIn,
|
ctx->authTagSz, ctx->authIn,
|
||||||
ctx->gcmccmAuthInSz);
|
ctx->authInSz);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_AesCcmDecrypt(&ctx->cipher.aes, dst, src,
|
ret = wc_AesCcmDecrypt(&ctx->cipher.aes, dst, src,
|
||||||
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
len, ctx->iv, ctx->ivSz, ctx->authTag,
|
||||||
ctx->authTagSz, ctx->gcmccmAuthIn,
|
ctx->authTagSz, ctx->authIn,
|
||||||
ctx->gcmccmAuthInSz);
|
ctx->authInSz);
|
||||||
}
|
}
|
||||||
if (ctx->gcmccmIncIv) {
|
if (ctx->incIv) {
|
||||||
IncCtr((byte*)ctx->cipher.aes.reg,
|
IncCtr((byte*)ctx->cipher.aes.reg,
|
||||||
ctx->cipher.aes.nonceSz);
|
ctx->cipher.aes.nonceSz);
|
||||||
ctx->gcmccmIncIv = 0;
|
ctx->incIv = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
@@ -6433,10 +6433,10 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD* type)
|
|||||||
* Clear any leftover AAD on final (final is when src is
|
* Clear any leftover AAD on final (final is when src is
|
||||||
* NULL).
|
* NULL).
|
||||||
*/
|
*/
|
||||||
if (ctx->gcmccmAuthIn != NULL) {
|
if (ctx->authIn != NULL) {
|
||||||
XMEMSET(ctx->gcmccmAuthIn, 0, ctx->gcmccmAuthInSz);
|
XMEMSET(ctx->authIn, 0, ctx->authInSz);
|
||||||
}
|
}
|
||||||
ctx->gcmccmAuthInSz = 0;
|
ctx->authInSz = 0;
|
||||||
}
|
}
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = len;
|
ret = len;
|
||||||
|
@@ -436,10 +436,10 @@ struct WOLFSSL_EVP_CIPHER_CTX {
|
|||||||
#define HAVE_WOLFSSL_EVP_CIPHER_CTX_IV
|
#define HAVE_WOLFSSL_EVP_CIPHER_CTX_IV
|
||||||
int ivSz;
|
int ivSz;
|
||||||
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
||||||
byte* gcmccmBuffer;
|
byte* buffer;
|
||||||
int gcmccmBufferLen;
|
int bufferLen;
|
||||||
byte* gcmccmAuthIn;
|
byte* authIn;
|
||||||
int gcmccmAuthInSz;
|
int authInSz;
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||||
byte* key; /* used in partial Init()s */
|
byte* key; /* used in partial Init()s */
|
||||||
@@ -453,8 +453,8 @@ struct WOLFSSL_EVP_CIPHER_CTX {
|
|||||||
int authTagSz;
|
int authTagSz;
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
#if defined(HAVE_AESGCM) || defined(HAVE_AESCCM)
|
||||||
byte gcmccmIvGenEnable:1;
|
byte ivGenEnable:1;
|
||||||
byte gcmccmIncIv:1;
|
byte incIv:1;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user