• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef ASM_ECP_NISTP256_H
17 #define ASM_ECP_NISTP256_H
18 
19 #include "hitls_build.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define P256_BYTES      32
26 #define P256_SIZE       (P256_BYTES / sizeof(BN_UINT))
27 
28 typedef struct {
29     BN_UINT value[P256_SIZE];
30 } Coord;    // Point Coordinates
31 
32 typedef struct p256_point {
33     Coord x;
34     Coord y;
35     Coord z;
36 } P256_Point;
37 
38 typedef struct p256_pointaffine {
39     Coord x;
40     Coord y;
41 } P256_AffinePoint;
42 
43 #if defined(HITLS_CRYPTO_CURVE_NISTP256_ASM) && defined(HITLS_CRYPTO_NIST_ECC_ACCELERATE)
44 
45 typedef P256_AffinePoint ECP256_TableRow[64];
46 
47 const ECP256_TableRow *ECP256_GetPreCompTable(void);
48 
49 void ECP256_FromMont(Coord *r, const Coord *a);
50 
51 void ECP256_Mul(Coord *r, const Coord *a, const Coord *b);
52 
53 void ECP256_Sqr(Coord *r, const Coord *a);
54 
55 void ECP256_Neg(Coord *r, const Coord *a);
56 
57 void ECP256_OrdMul(Coord *r, const Coord *a, const Coord *b);
58 
59 void ECP256_OrdSqr(Coord *r, const Coord *a, int32_t repeat);
60 
61 void ECP256_PointDouble(P256_Point *r, const P256_Point *a);
62 
63 void ECP256_PointAdd(P256_Point *r, const P256_Point *a, const P256_Point *b);
64 
65 void ECP256_AddAffine(P256_Point *r, const P256_Point *a, const P256_AffinePoint *b);
66 
67 void ECP256_Scatterw5(P256_Point *table, const P256_Point *point, uint32_t index);
68 
69 void ECP256_Gatherw5(P256_Point *point, const P256_Point *table, uint32_t index);
70 
71 void ECP256_Gatherw7(P256_AffinePoint *point, const P256_AffinePoint *table, uint32_t index);
72 
73 #endif /* HITLS_CRYPTO_CURVE_NISTP256_ASM && HITLS_CRYPTO_NIST_ECC_ACCELERATE */
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 
80 #endif