Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix for Intel QAT handling cofactor for point multiply #54

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions wolfcrypt/src/port/intel/quickassist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3525,20 +3525,11 @@ int IntelQaEccPointMul(WC_ASYNC_DEV* dev, WC_BIGINT* k,
}

/* setup cofactor */
/* for this point multiply the cofactor should not be used, so always pass 1 */
/* if using default value 1 then use shared global */
opData->h.dataLenInBytes = 4;
if (cofactor == 1) {
opData->h.pData = g_qatEcdhCofactor1;
}
else {
/* if not default value 1, then use own buffer */
opData->h.pData = XMALLOC(opData->h.dataLenInBytes, dev->heap,
DYNAMIC_TYPE_ASYNC_NUMA);
if (opData->h.pData == NULL) {
ret = MEMORY_E; goto exit;
}
*((word32*)opData->h.pData) = OS_HOST_TO_NW_32(cofactor);
}
opData->h.pData = g_qatEcdhCofactor1;
(void)cofactor;

ret = IntelQaAllocFlatBuffer(pXk, q->len, dev->heap);
ret += IntelQaAllocFlatBuffer(pYk, q->len, dev->heap);
Expand Down Expand Up @@ -3714,20 +3705,11 @@ int IntelQaEcdh(WC_ASYNC_DEV* dev, WC_BIGINT* k, WC_BIGINT* xG,
}

/* setup cofactor */
/* for this point multiply the cofactor should not be used, so always pass 1 */
/* if using default value 1 then use shared global */
opData->h.dataLenInBytes = 4;
if (cofactor == 1) {
opData->h.pData = g_qatEcdhCofactor1;
}
else {
/* if not default value 1, then use own buffer */
opData->h.pData = XMALLOC(opData->h.dataLenInBytes, dev->heap,
DYNAMIC_TYPE_ASYNC_NUMA);
if (opData->h.pData == NULL) {
ret = MEMORY_E; goto exit;
}
*((word32*)opData->h.pData) = OS_HOST_TO_NW_32(cofactor);
}
opData->h.pData = g_qatEcdhCofactor1;
(void)cofactor;

pXk->dataLenInBytes = q->len; /* bytes key size / 8 (aligned) */
pXk->pData = XREALLOC(out, pXk->dataLenInBytes, dev->heap,
Expand Down