| 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/pcpgfpstuff.h" |
| 22 |
#include "gfpec/pcpgfpecstuff.h" |
| 23 |
|
| 24 |
#include "gfpec/ecnist/ifma_ecpoint_p521.h" |
| 25 |
#include "gfpec/ecnist/ifma_arith_p521.h" |
| 26 |
#include "gfpec/ecnist/ifma_arith_method_p521.h" |
| 27 |
|
| 28 |
|
| 29 |
IPP_OWN_DEFN(IppsGFpECPoint*, gfec_PubKey_nist521_avx512, (IppsGFpECPoint* pR, |
| 30 |
const BNU_CHUNK_T* pScalar, |
| 31 |
int scalarLen, |
| 32 |
IppsGFpECState* pEC, |
| 33 |
Ipp8u* pScratchBuffer)) |
| 34 |
|
| 35 |
{ |
| 36 |
FIX_BNU(pScalar, scalarLen); |
| 37 |
{ |
| 38 |
IPP_UNREFERENCED_PARAMETER(pScratchBuffer); |
| 39 |
|
| 40 |
gsModEngine* pME = GFP_PMA(ECP_GFP(pEC)); |
| 41 |
gsModEngine* nME = ECP_MONT_R(pEC); |
| 42 |
|
| 43 |
const int orderBits = ECP_ORDBITSIZE(pEC); |
| 44 |
const int orderLen = BITS_BNU_CHUNK(orderBits); |
| 45 |
|
| 46 |
ifmaArithMethod_p521* pmeth = (ifmaArithMethod_p521*)GFP_METHOD_ALT(pME); |
| 47 |
|
| 48 |
BNU_CHUNK_T* pPool = cpGFpGetPool(5, nME); |
| 49 |
BNU_CHUNK_T* pExtendedScalar = pPool; |
| 50 |
BNU_CHUNK_T* pPointPool = pExtendedScalar + 2 * GFP_FELEN(pME); |
| 51 |
|
| 52 |
|
| 53 |
cpGFpElementCopyPad(pExtendedScalar, orderLen + 1, pScalar, scalarLen); |
| 54 |
|
| 55 |
__ALIGN64 P521_POINT_IFMA R; |
| 56 |
FE521_SET(R.x) = FE521_SET(R.y) = FE521_SET(R.z) = m256_setzero_i64(); |
| 57 |
|
| 58 |
if (ECP_PREMULBP(pEC)) { |
| 59 |
ifma_ec_nistp521_mul_pointbase(&R, (Ipp8u*)pExtendedScalar, orderBits); |
| 60 |
} else { |
| 61 |
|
| 62 |
__ALIGN64 P521_POINT_IFMA G52; |
| 63 |
recode_point_to_mont52(&G52, ECP_G(pEC), pPointPool , pmeth, pME); |
| 64 |
|
| 65 |
ifma_ec_nistp521_mul_point(&R, &G52, (Ipp8u*)pExtendedScalar, orderBits); |
| 66 |
} |
| 67 |
|
| 68 |
recode_point_to_mont64(pR, &R, pPointPool , pmeth, pME); |
| 69 |
|
| 70 |
cpGFpReleasePool(5, nME); |
| 71 |
|
| 72 |
ECP_POINT_FLAGS(pR) = gfec_IsPointAtInfinity(pR) ? 0 : ECP_FINITE_POINT; |
| 73 |
return pR; |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
#endif |