Skip to content

Commit 044a5f8

Browse files
Merge pull request #10143 from dgarske/qat_aes_gcm
Improve QAT AES GCM tag checking
2 parents 3e0679e + 852ddcb commit 044a5f8

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

wolfcrypt/src/port/intel/quickassist.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,9 +2214,7 @@ static void IntelQaSymCipherCallback(void *pCallbackTag, CpaStatus status,
22142214
int ret = ASYNC_OP_E;
22152215

22162216
(void)opData;
2217-
(void)verifyResult;
22182217
(void)pDstBuffer;
2219-
(void)operationType;
22202218

22212219
#ifdef QAT_DEBUG
22222220
printf("IntelQaSymCipherCallback: dev %p, type %d, status %d, "
@@ -2270,6 +2268,18 @@ static void IntelQaSymCipherCallback(void *pCallbackTag, CpaStatus status,
22702268

22712269
/* mark event result */
22722270
ret = 0; /* success */
2271+
2272+
/* check verify result for authenticated ciphers (AES-GCM).
2273+
* Note: ALGORITHM_CHAINING is only used by AES-GCM in this
2274+
* code path. For encrypt verifyResult will be CPA_TRUE. */
2275+
if (operationType == CPA_CY_SYM_OP_ALGORITHM_CHAINING &&
2276+
verifyResult == CPA_FALSE) {
2277+
/* wipe output - do not return unauthenticated plaintext */
2278+
if (dev->qat.out) {
2279+
ForceZero(dev->qat.out, dev->qat.outLen);
2280+
}
2281+
ret = AES_GCM_AUTH_E;
2282+
}
22732283
}
22742284
}
22752285

@@ -2399,6 +2409,9 @@ static int IntelQaSymCipher(WC_ASYNC_DEV* dev, byte* out, const byte* in,
23992409
setup.hashSetupData.authModeSetupData.aadLenInBytes = authInSz;
24002410

24012411
setup.digestIsAppended = CPA_TRUE;
2412+
if (cipherDirection == CPA_CY_SYM_CIPHER_DIRECTION_DECRYPT) {
2413+
setup.verifyDigest = CPA_TRUE;
2414+
}
24022415
}
24032416

24042417
/* open session */

0 commit comments

Comments
 (0)