Skip to content

Commit 16d355d

Browse files
committed
Fix for DH key gen. Transfer control of X to QAT (caller tries to free it).
1 parent 18c49a7 commit 16d355d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

wolfcrypt/src/port/intel/quickassist.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4050,6 +4050,8 @@ static void IntelQaDhKeyGenFree(WC_ASYNC_DEV* dev)
40504050
CpaFlatBuffer* pOut = &dev->qat.op.dh_gen.pOut;
40514051

40524052
if (opData) {
4053+
IntelQaFreeFlatBuffer(&opData->privateValueX, dev->heap);
4054+
40534055
XMEMSET(opData, 0, sizeof(CpaCyDhPhase1KeyGenOpData));
40544056
}
40554057

@@ -4130,13 +4132,16 @@ int IntelQaDhKeyGen(WC_ASYNC_DEV* dev, WC_BIGINT* p, WC_BIGINT* g,
41304132
/* setup operation data */
41314133
ret = IntelQaBigIntToFlatBuffer(p, &opData->primeP);
41324134
ret += IntelQaBigIntToFlatBuffer(g, &opData->baseG);
4135+
/* transfer control of big int buffer to opData structure */
41334136
ret += IntelQaBigIntToFlatBuffer(x, &opData->privateValueX);
4137+
/* don't let caller free x, do it in IntelQaDhKeyGenFree */
4138+
x->buf = NULL;
4139+
x->len = 0;
41344140
if (ret != 0) {
41354141
ret = BAD_FUNC_ARG; goto exit;
41364142
}
41374143
pOut->dataLenInBytes = p->len;
41384144
pOut->pData = XREALLOC(pub, p->len, dev->heap, DYNAMIC_TYPE_ASYNC_NUMA);
4139-
41404145
if (pOut->pData == NULL) {
41414146
ret = MEMORY_E; goto exit;
41424147
}

0 commit comments

Comments
 (0)