mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
29
src/ssl.c
29
src/ssl.c
@@ -17124,14 +17124,39 @@ int wolfSSL_EVP_MD_type(const WOLFSSL_EVP_MD *md)
|
|||||||
case AES_256_GCM_TYPE :
|
case AES_256_GCM_TYPE :
|
||||||
WOLFSSL_MSG("AES GCM");
|
WOLFSSL_MSG("AES GCM");
|
||||||
if (ctx->enc) {
|
if (ctx->enc) {
|
||||||
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, dst, src, len,
|
if (dst){
|
||||||
|
/* encrypt confidential data*/
|
||||||
|
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, dst, src, len,
|
||||||
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* authenticated, non-confidential data */
|
||||||
|
ret = wc_AesGcmEncrypt(&ctx->cipher.aes, NULL, NULL, 0,
|
||||||
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
|
src, len);
|
||||||
|
/* Reset partial authTag error for AAD*/
|
||||||
|
if (ret == AES_GCM_AUTH_E)
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, dst, src, len,
|
if (dst){
|
||||||
|
/* decrypt confidential data*/
|
||||||
|
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, dst, src, len,
|
||||||
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
ctx->iv, ctx->ivSz, ctx->authTag, ctx->authTagSz,
|
||||||
NULL, 0);
|
NULL, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* authenticated, non-confidential data*/
|
||||||
|
ret = wc_AesGcmDecrypt(&ctx->cipher.aes, NULL, NULL, 0,
|
||||||
|
ctx->iv, ctx->ivSz,
|
||||||
|
ctx->authTag, ctx->authTagSz,
|
||||||
|
src, len);
|
||||||
|
/* Reset partial authTag error for AAD*/
|
||||||
|
if (ret == AES_GCM_AUTH_E)
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* HAVE_AESGCM */
|
#endif /* HAVE_AESGCM */
|
||||||
|
Reference in New Issue
Block a user