1 /*
2  * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7  #ifndef PKA_EC_EDW_GLOB_REGS_DEF_H
8  #define PKA_EC_EDW_GLOB_REGS_DEF_H
9 
10  /*! Note: Don't change registers ID-s ! */
11 
12  /*! Define global PKA registers ID-s used in EC Edwards operations */
13 
14  /*--------------------------*/
15  /* Common EC Edw. registers */
16  /*--------------------------*/
17  #define EDW_REG_N       PKA_REG_N  /* EC mod. */
18  #define EDW_REG_NP      PKA_REG_NP /* EC Barr.tag */
19  #define EDW_REG_T3      2 /* 4 temp regs. */
20  #define EDW_REG_T4      3
21  #define EDW_REG_T5      4
22  #define EDW_REG_T6      5
23  #define EDW_REG_N_4     6  /* from domain */
24  #define EDW_REG_D2      7  /* from domain */
25 
26  /*---------------------------------------------*/
27  /* EC Edw. registers for ScalarMultBase        */
28  /* and Signature functions                     */
29  /*---------------------------------------------*/
30  #define EDW_REG_XS      8 /* out point s */
31  #define EDW_REG_YS      9
32  #define EDW_REG_ZS     10
33  #define EDW_REG_TS     11
34  #define EDW_REG_SG4    12 /* precalc. point g4 */
35  #define EDW_REG_DG4    13
36  #define EDW_REG_PG4    14
37  #define EDW_REG_MPG4   15
38  /* for special scal.Mult only */
39  #define EDW_REG_SG8    16 /* precalc. point g8 */
40  #define EDW_REG_DG8    17
41  #define EDW_REG_PG8    18
42  #define EDW_REG_MPG8   19
43  #define EDW_REG_SG16   20 /* precalc. point g16 */
44  #define EDW_REG_DG16   21
45  #define EDW_REG_PG16   22
46  #define EDW_REG_MPG16  23
47 
48 /* Registers, used in EC EDW Sign and Verify */
49  #define EDW_REG_EPH_PRIV  EDW_REG_T3
50  #define EDW_REG_INTEGR    EDW_REG_T4
51  #define EDW_REG_USER_PRIV EDW_REG_T5
52  #define EDW_REG_SIGN      EDW_REG_T6
53 // #define EDW_REG_TMP       EDW_REG_N_4
54 
55   /*------------------------------*/
56   /* EC Edw. common registers for */
57   /*  ScalarMultBase functions    */
58   /*------------------------------*/
59 #define EDW_REG_SG    EDW_REG_SG8  /* pont g */
60 #define EDW_REG_DG    EDW_REG_DG8
61 #define EDW_REG_PG    EDW_REG_PG8
62 #define EDW_REG_MPG   EDW_REG_MPG8
63 #define EDW_REG_SG2   EDW_REG_SG16 /* pont g2 */
64 #define EDW_REG_DG2   EDW_REG_DG16
65 #define EDW_REG_PG2   EDW_REG_PG16
66 #define EDW_REG_MPG2  EDW_REG_MPG16
67 
68 /* for modified points g2, g4: x,y,z=1,t */
69 #define EDW_REG_XG2   EDW_REG_T3
70 #define EDW_REG_YG2   EDW_REG_T4
71 #define EDW_REG_TG2   EDW_REG_T5
72 #define EDW_REG_XG4   EDW_REG_T6
73 #define EDW_REG_YG4   28
74 #define EDW_REG_TG4   29
75 
76  /*-------------------------------------------------*/
77  /* EC Edw. registers for TwoScalarMultAdd function */
78  /*-------------------------------------------------*/
79  /*aff. input point P (xp,yp)*/
80  #define EDW_REG_XP      8
81  #define EDW_REG_YP      9
82  /*extended point P: sp,dp,pp*/
83  #define EDW_REG_SP     10
84  #define EDW_REG_DP     11
85  #define EDW_REG_PP     12
86 
87  /*extended result point R (xr,yr,zr,tr)*/
88  #define EDW_REG_XR     13
89  #define EDW_REG_YR     14
90  #define EDW_REG_ZR     15
91  #define EDW_REG_TR     16
92  /*modified form of base point G */
93  #define EDW_REG_XG     17
94  #define EDW_REG_YG     18
95  #define EDW_REG_ZG     19
96  #define EDW_REG_TG     20
97  /*precalculated form of base point G */
98  #define EDW_REG_SG1    21
99  #define EDW_REG_DG1    22
100  #define EDW_REG_PG1    23
101  /* modified point PG=P+G*/
102  #define EDW_REG_XPG    24 /*EDW_REG_ZG */
103  #define EDW_REG_YPG    25 /*EDW_REG_TG*/
104  #define EDW_REG_ZPG    26 /*EDW_REG_XG*/
105  #define EDW_REG_TPG    27 /*EDW_REG_TG*/
106 
107  /*Registers, used in decompression */
108  #define EDW_REG_T      28 /*temp reg.*/
109  /* parameters from domain */
110  #define EDW_REG_Q58    EDW_REG_XPG
111  #define EDW_REG_SQRTM1 EDW_REG_YPG
112  #define EDW_REG_D      EDW_REG_ZPG
113 
114 
115 // #define EC_EDW_PKA_REGS_USED 28 /* besides 2 PKA temp regs. 30,31 */
116 #endif
117 
118 // I n, np, t3, t4, t5, t6, n_4, d2, q58, sqrtm1; // 10 regs
119 //I xg,yg,zg,tg, xg32,yg32,zg32,tg32; // extended coordinates of G and 32G
120 //I sg, dg, pg, mpg; I sg4, dg4, pg4, mpg4; I sg8, dg8, pg8, mpg8; I sg16, dg16, pg16, mpg16; // precalculated coordinates: y+x, y-x, 2xy, -2xy of G, 4G, 8G, 16G
121 //void hwsmulg(I xs, I ys, I k)
122 
123