Repository navigation
Require fresh IVs for EVP ARIA GCM #11594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
17f20f7
02ee068
36f06ce
76f0533
d11376a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1480,6 +1480,15 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out, | |
| case WC_ARIA_128_GCM_TYPE: | ||
| case WC_ARIA_192_GCM_TYPE: | ||
| case WC_ARIA_256_GCM_TYPE: | ||
| if (ctx->enc && (ctx->cipher.aria.nonceSz == 0 || | ||
| ctx->authIvUsed)) { | ||
| XFREE(ctx->authBuffer, NULL, DYNAMIC_TYPE_OPENSSL); | ||
| ctx->authBuffer = NULL; | ||
| ctx->authBufferLen = 0; | ||
| *outl = 0; | ||
| ret = WOLFSSL_FAILURE; | ||
| break; | ||
| } | ||
| if ((ctx->authBuffer && ctx->authBufferLen > 0) | ||
| || (ctx->authBufferLen == 0)) { | ||
| if (ctx->enc) | ||
|
|
@@ -1520,8 +1529,9 @@ int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx, unsigned char *out, | |
| ctx->authIncIv = 0; | ||
| } | ||
| else { | ||
| /* Clear IV, since IV reuse is not recommended for AES GCM. */ | ||
| /* Clear IV since ARIA GCM must not reuse an IV. */ | ||
| XMEMSET(ctx->iv, 0, ARIA_BLOCK_SIZE); | ||
| ctx->authIvUsed = 1; | ||
| } | ||
| if (wolfSSL_StoreExternalIV(ctx) != WOLFSSL_SUCCESS) { | ||
| ret = WOLFSSL_FAILURE; | ||
|
|
@@ -7635,6 +7645,9 @@ void wolfSSL_EVP_init(void) | |
| const byte* iv, int enc) | ||
| { | ||
| int ret = 0; | ||
| #ifdef HAVE_ARIA | ||
| int ivProvided = (iv != NULL); | ||
| #endif | ||
| (void)key; | ||
| (void)iv; | ||
| (void)enc; | ||
|
|
@@ -8454,9 +8467,12 @@ void wolfSSL_EVP_init(void) | |
| != WOLFSSL_SUCCESS) { | ||
| return WOLFSSL_FAILURE; | ||
| } | ||
| if (ivProvided) | ||
| ctx->authIvUsed = 0; | ||
|
aidangarske marked this conversation as resolved.
Resolved
|
||
| else if (type != NULL) | ||
| ctx->authIvUsed = 1; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pre-existing, but while we're here could you correct this endif comment #endif /* HAVE_AESGCM && ((!HAVE_FIPS && !HAVE_SELFTEST) ||
* HAVE_FIPS_VERSION >= 2 */comment to match the opening #if defined(HAVE_ARIA)
Also, this branch is 795 commits behind master, and it's a good excuse to rebase just to be safe.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed the endif comment to HAVE_ARIA and rebased on current master. |
||
| #endif /* HAVE_AESGCM && ((!HAVE_FIPS && !HAVE_SELFTEST) || | ||
| * HAVE_FIPS_VERSION >= 2 */ | ||
| #endif /* HAVE_ARIA */ | ||
|
|
||
|
|
||
| #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) | ||
|
|
@@ -9177,9 +9193,13 @@ void wolfSSL_EVP_init(void) | |
| case WC_ARIA_256_GCM_TYPE : | ||
| WOLFSSL_MSG("ARIA GCM"); | ||
| if (ctx->enc) { | ||
| if (ctx->cipher.aria.nonceSz == 0 || ctx->authIvUsed) | ||
| return WC_NO_ERR_TRACE(BAD_STATE_E); | ||
| ret = wc_AriaEncrypt(&ctx->cipher.aria, dst, src, len, | ||
| ctx->iv, ctx->ivSz, NULL, 0, | ||
| ctx->authTag, ctx->authTagSz); | ||
| if (ret == 0) | ||
| ctx->authIvUsed = 1; | ||
| } | ||
| else { | ||
| ret = wc_AriaDecrypt(&ctx->cipher.aria, dst, src, len, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.