-
Notifications
You must be signed in to change notification settings - Fork 958
Improve QAT AES GCM tag checking #10143
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
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 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2214,9 +2214,7 @@ static void IntelQaSymCipherCallback(void *pCallbackTag, CpaStatus status, | |||||||||||||||||||||||||||||||||
| int ret = ASYNC_OP_E; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| (void)opData; | ||||||||||||||||||||||||||||||||||
| (void)verifyResult; | ||||||||||||||||||||||||||||||||||
| (void)pDstBuffer; | ||||||||||||||||||||||||||||||||||
| (void)operationType; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| #ifdef QAT_DEBUG | ||||||||||||||||||||||||||||||||||
| printf("IntelQaSymCipherCallback: dev %p, type %d, status %d, " | ||||||||||||||||||||||||||||||||||
|
|
@@ -2270,6 +2268,16 @@ static void IntelQaSymCipherCallback(void *pCallbackTag, CpaStatus status, | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /* mark event result */ | ||||||||||||||||||||||||||||||||||
| ret = 0; /* success */ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| /* check verify result for authenticated ciphers (GCM/CCM) */ | ||||||||||||||||||||||||||||||||||
| if (operationType == CPA_CY_SYM_OP_ALGORITHM_CHAINING && | ||||||||||||||||||||||||||||||||||
| verifyResult == CPA_FALSE) { | ||||||||||||||||||||||||||||||||||
| /* wipe output - do not return unauthenticated plaintext */ | ||||||||||||||||||||||||||||||||||
| if (dev->qat.out) { | ||||||||||||||||||||||||||||||||||
| ForceZero(dev->qat.out, dev->qat.outLen); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| ret = AES_GCM_AUTH_E; | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+2272
to
+2279
|
||||||||||||||||||||||||||||||||||
| /* check verify result for authenticated ciphers (GCM/CCM) */ | |
| if (operationType == CPA_CY_SYM_OP_ALGORITHM_CHAINING && | |
| verifyResult == CPA_FALSE) { | |
| /* wipe output - do not return unauthenticated plaintext */ | |
| if (dev->qat.out) { | |
| ForceZero(dev->qat.out, dev->qat.outLen); | |
| } | |
| ret = AES_GCM_AUTH_E; | |
| /* check verify result for authenticated algorithm chaining */ | |
| if (operationType == CPA_CY_SYM_OP_ALGORITHM_CHAINING && | |
| verifyResult == CPA_FALSE) { | |
| /* wipe output - do not return unauthenticated plaintext */ | |
| if (dev->qat.out) { | |
| ForceZero(dev->qat.out, dev->qat.outLen); | |
| } | |
| ret = MAC_CMP_FAILED_E; |
Copilot
AI
Apr 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setup.verifyDigest is only conditionally assigned here. If setup isn’t guaranteed to be fully zero-initialized on all paths before this block, verifyDigest could be left with an indeterminate/stale value for encrypt operations. To make the behavior deterministic and self-contained, explicitly set setup.verifyDigest = CPA_FALSE in the non-decrypt case (or set it unconditionally before the if).
| setup.digestIsAppended = CPA_TRUE; | |
| setup.digestIsAppended = CPA_TRUE; | |
| setup.verifyDigest = CPA_FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wipe targets
dev->qat.out/dev->qat.outLenrather than the callback-provided destination buffer (pDstBuffer). Ifdev->qat.outdoesn’t exactly correspond to the buffer QAT wrote into (or ifoutLendiffers from what was actually produced), this can fail to wipe the plaintext (data exposure) or wipe the wrong region (potential memory corruption). Prefer wiping the actual destination buffer provided to the callback (and using the actual produced length/message length associated with this operation). This also allows removing(void)pDstBuffersince it becomes used.