| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#include "owndefs.h" |
| 18 |
|
| 19 |
#if (_IPP32E >= _IPP32E_K1) |
| 20 |
|
| 21 |
#include "gfpec/pcpgfpecstuff.h" |
| 22 |
#include "gfpec/pcpgfpstuff.h" |
| 23 |
|
| 24 |
#include "gfpec/ecnist/ifma_defs.h" |
| 25 |
#include "gfpec/ecnist/ifma_ecpoint_p256.h" |
| 26 |
#include "gfpec/ecnist/ifma_arith_method.h" |
| 27 |
|
| 28 |
|
| 29 |
IPP_OWN_DEFN(int, gfec_SharedSecretDH_nistp256_avx512, (IppsGFpECPoint* pR, |
| 30 |
const IppsGFpECPoint* pP, |
| 31 |
const BNU_CHUNK_T* pScalar, |
| 32 |
int scalarLen, |
| 33 |
IppsGFpECState* pEC, |
| 34 |
Ipp8u* pScratchBuffer)) |
| 35 |
|
| 36 |
{ |
| 37 |
FIX_BNU(pScalar, scalarLen); |
| 38 |
{ |
| 39 |
IPP_UNREFERENCED_PARAMETER(pScratchBuffer); |
| 40 |
|
| 41 |
gsModEngine* pME = GFP_PMA(ECP_GFP(pEC)); |
| 42 |
|
| 43 |
const int orderBits = ECP_ORDBITSIZE(pEC); |
| 44 |
const int orderLen = BITS_BNU_CHUNK(orderBits); |
| 45 |
|
| 46 |
ifmaArithMethod* pmeth = (ifmaArithMethod*)GFP_METHOD_ALT(pME); |
| 47 |
|
| 48 |
ifma_export from_radix52 = pmeth->export_to64; |
| 49 |
|
| 50 |
|
| 51 |
ifma_decode p_from_mont = pmeth->decode; |
| 52 |
|
| 53 |
|
| 54 |
BNU_CHUNK_T* pExtendedScalar = cpGFpGetPool(2, pME); |
| 55 |
cpGFpElementCopyPad(pExtendedScalar, orderLen + 1, pScalar, scalarLen); |
| 56 |
|
| 57 |
__ALIGN64 P256_POINT_IFMA P52, R52; |
| 58 |
BNU_CHUNK_T* pPool = cpGFpGetPool(3, pME); |
| 59 |
|
| 60 |
|
| 61 |
recode_point_to_mont52(&P52, ECP_POINT_DATA(pP), pPool, pmeth, pME); |
| 62 |
|
| 63 |
ifma_ec_nistp256_mul_point(&R52, &P52, (Ipp8u*)pExtendedScalar, orderBits); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
const mask8 is_zero_z = is_zero_i64(R52.z); |
| 68 |
int finite_point = ((mask8)0xFF != is_zero_z); |
| 69 |
|
| 70 |
|
| 71 |
ifma_ec_nistp256_get_affine_coords(&(R52.x), NULL, &R52); |
| 72 |
|
| 73 |
R52.x = p_from_mont(R52.x); |
| 74 |
from_radix52(ECP_POINT_X(pR), R52.x); |
| 75 |
|
| 76 |
cpGFpReleasePool(5, pME); |
| 77 |
|
| 78 |
return finite_point; |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
#endif |