Debian Codegraph @

sources/ippcp/gfpec/ecnist/ifma_ec_pubkey_p521.c

raw symbols SCIP
1 /*************************************************************************
2 * Copyright (C) 2021 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 /* clang-format off */
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 /* clang-format on */
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 /* Copy scalar */
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 /* Convert base point to a new Montgomery domain */
62 __ALIGN64 P521_POINT_IFMA G52;
63 recode_point_to_mont52(&G52, ECP_G(pEC), pPointPool /* 3 elem */, pmeth, pME);
64
65 ifma_ec_nistp521_mul_point(&R, &G52, (Ipp8u*)pExtendedScalar, orderBits);
66 }
67
68 recode_point_to_mont64(pR, &R, pPointPool /* 3 elem */, 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 // (_IPP32E >= _IPP32E_K1)