@@ -126,6 +126,27 @@ static const p521_limb_t p521_felem_p[P521_NLIMBS] = {
126
126
127
127
#endif // EC_NISTP_USE_S2N_BIGNUM
128
128
129
+ // The wrapper functions are needed for FIPS static build.
130
+ // Otherwise, initializing ec_nistp_meth with pointers to s2n-bignum
131
+ // functions directly generates :got: references that are also thought
132
+ // to be local_target by the delocator.
133
+ static inline void p521_felem_add_wrapper (ec_nistp_felem_limb * c ,
134
+ const ec_nistp_felem_limb * a ,
135
+ const ec_nistp_felem_limb * b ) {
136
+ p521_felem_add (c , a , b );
137
+ }
138
+
139
+ static inline void p521_felem_sub_wrapper (ec_nistp_felem_limb * c ,
140
+ const ec_nistp_felem_limb * a ,
141
+ const ec_nistp_felem_limb * b ) {
142
+ p521_felem_sub (c , a , b );
143
+ }
144
+
145
+ static inline void p521_felem_neg_wrapper (ec_nistp_felem_limb * c ,
146
+ const ec_nistp_felem_limb * a ) {
147
+ p521_felem_opp (c , a );
148
+ }
149
+
129
150
static p521_limb_t p521_felem_nz (const p521_limb_t in1 [P521_NLIMBS ]) {
130
151
p521_limb_t is_not_zero = 0 ;
131
152
for (int i = 0 ; i < P521_NLIMBS ; i ++ ) {
@@ -289,11 +310,11 @@ static void p521_point_add(p521_felem x3, p521_felem y3, p521_felem z3,
289
310
DEFINE_METHOD_FUNCTION (ec_nistp_meth , p521_methods ) {
290
311
out -> felem_num_limbs = P521_NLIMBS ;
291
312
out -> felem_num_bits = 521 ;
292
- out -> felem_add = bignum_add_p521 ;
293
- out -> felem_sub = bignum_sub_p521 ;
313
+ out -> felem_add = p521_felem_add_wrapper ;
314
+ out -> felem_sub = p521_felem_sub_wrapper ;
294
315
out -> felem_mul = bignum_mul_p521_selector ;
295
316
out -> felem_sqr = bignum_sqr_p521_selector ;
296
- out -> felem_neg = bignum_neg_p521 ;
317
+ out -> felem_neg = p521_felem_neg_wrapper ;
297
318
out -> felem_nz = p521_felem_nz ;
298
319
out -> felem_one = p521_felem_one ;
299
320
out -> point_dbl = p521_point_double ;
0 commit comments