Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ec_lcl.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | struct ec_method_st { | - | ||||||
4 | - | |||||||
5 | int flags; | - | ||||||
6 | - | |||||||
7 | int field_type; | - | ||||||
8 | - | |||||||
9 | - | |||||||
10 | - | |||||||
11 | - | |||||||
12 | int (*group_init) (EC_GROUP *); | - | ||||||
13 | void (*group_finish) (EC_GROUP *); | - | ||||||
14 | void (*group_clear_finish) (EC_GROUP *); | - | ||||||
15 | int (*group_copy) (EC_GROUP *, const EC_GROUP *); | - | ||||||
16 | - | |||||||
17 | int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a, | - | ||||||
18 | const BIGNUM *b, BN_CTX *); | - | ||||||
19 | int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, | - | ||||||
20 | BN_CTX *); | - | ||||||
21 | - | |||||||
22 | int (*group_get_degree) (const EC_GROUP *); | - | ||||||
23 | int (*group_order_bits) (const EC_GROUP *); | - | ||||||
24 | - | |||||||
25 | int (*group_check_discriminant) (const EC_GROUP *, BN_CTX *); | - | ||||||
26 | - | |||||||
27 | - | |||||||
28 | - | |||||||
29 | - | |||||||
30 | int (*point_init) (EC_POINT *); | - | ||||||
31 | void (*point_finish) (EC_POINT *); | - | ||||||
32 | void (*point_clear_finish) (EC_POINT *); | - | ||||||
33 | int (*point_copy) (EC_POINT *, const EC_POINT *); | - | ||||||
34 | int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *); | - | ||||||
35 | int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *, | - | ||||||
36 | EC_POINT *, const BIGNUM *x, | - | ||||||
37 | const BIGNUM *y, | - | ||||||
38 | const BIGNUM *z, BN_CTX *); | - | ||||||
39 | int (*point_get_Jprojective_coordinates_GFp) (const EC_GROUP *, | - | ||||||
40 | const EC_POINT *, BIGNUM *x, | - | ||||||
41 | BIGNUM *y, BIGNUM *z, | - | ||||||
42 | BN_CTX *); | - | ||||||
43 | int (*point_set_affine_coordinates) (const EC_GROUP *, EC_POINT *, | - | ||||||
44 | const BIGNUM *x, const BIGNUM *y, | - | ||||||
45 | BN_CTX *); | - | ||||||
46 | int (*point_get_affine_coordinates) (const EC_GROUP *, const EC_POINT *, | - | ||||||
47 | BIGNUM *x, BIGNUM *y, BN_CTX *); | - | ||||||
48 | int (*point_set_compressed_coordinates) (const EC_GROUP *, EC_POINT *, | - | ||||||
49 | const BIGNUM *x, int y_bit, | - | ||||||
50 | BN_CTX *); | - | ||||||
51 | - | |||||||
52 | size_t (*point2oct) (const EC_GROUP *, const EC_POINT *, | - | ||||||
53 | point_conversion_form_t form, unsigned char *buf, | - | ||||||
54 | size_t len, BN_CTX *); | - | ||||||
55 | int (*oct2point) (const EC_GROUP *, EC_POINT *, const unsigned char *buf, | - | ||||||
56 | size_t len, BN_CTX *); | - | ||||||
57 | - | |||||||
58 | int (*add) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a, | - | ||||||
59 | const EC_POINT *b, BN_CTX *); | - | ||||||
60 | int (*dbl) (const EC_GROUP *, EC_POINT *r, const EC_POINT *a, BN_CTX *); | - | ||||||
61 | int (*invert) (const EC_GROUP *, EC_POINT *, BN_CTX *); | - | ||||||
62 | - | |||||||
63 | - | |||||||
64 | - | |||||||
65 | int (*is_at_infinity) (const EC_GROUP *, const EC_POINT *); | - | ||||||
66 | int (*is_on_curve) (const EC_GROUP *, const EC_POINT *, BN_CTX *); | - | ||||||
67 | int (*point_cmp) (const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, | - | ||||||
68 | BN_CTX *); | - | ||||||
69 | - | |||||||
70 | int (*make_affine) (const EC_GROUP *, EC_POINT *, BN_CTX *); | - | ||||||
71 | int (*points_make_affine) (const EC_GROUP *, size_t num, EC_POINT *[], | - | ||||||
72 | BN_CTX *); | - | ||||||
73 | int (*mul) (const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | - | ||||||
74 | size_t num, const EC_POINT *points[], const BIGNUM *scalars[], | - | ||||||
75 | BN_CTX *); | - | ||||||
76 | int (*precompute_mult) (EC_GROUP *group, BN_CTX *); | - | ||||||
77 | int (*have_precompute_mult) (const EC_GROUP *group); | - | ||||||
78 | - | |||||||
79 | - | |||||||
80 | - | |||||||
81 | - | |||||||
82 | - | |||||||
83 | - | |||||||
84 | - | |||||||
85 | int (*field_mul) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
86 | const BIGNUM *b, BN_CTX *); | - | ||||||
87 | int (*field_sqr) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, BN_CTX *); | - | ||||||
88 | int (*field_div) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
89 | const BIGNUM *b, BN_CTX *); | - | ||||||
90 | - | |||||||
91 | int (*field_encode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
92 | BN_CTX *); | - | ||||||
93 | - | |||||||
94 | int (*field_decode) (const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
95 | BN_CTX *); | - | ||||||
96 | int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *); | - | ||||||
97 | - | |||||||
98 | size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len); | - | ||||||
99 | int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len); | - | ||||||
100 | int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key); | - | ||||||
101 | int (*keygen)(EC_KEY *eckey); | - | ||||||
102 | int (*keycheck)(const EC_KEY *eckey); | - | ||||||
103 | int (*keygenpub)(EC_KEY *eckey); | - | ||||||
104 | int (*keycopy)(EC_KEY *dst, const EC_KEY *src); | - | ||||||
105 | void (*keyfinish)(EC_KEY *eckey); | - | ||||||
106 | - | |||||||
107 | int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen, | - | ||||||
108 | const EC_POINT *pub_key, const EC_KEY *ecdh); | - | ||||||
109 | - | |||||||
110 | int (*field_inverse_mod_ord)(const EC_GROUP *, BIGNUM *r, | - | ||||||
111 | const BIGNUM *x, BN_CTX *); | - | ||||||
112 | int (*blind_coordinates)(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); | - | ||||||
113 | int (*ladder_pre)(const EC_GROUP *group, | - | ||||||
114 | EC_POINT *r, EC_POINT *s, | - | ||||||
115 | EC_POINT *p, BN_CTX *ctx); | - | ||||||
116 | int (*ladder_step)(const EC_GROUP *group, | - | ||||||
117 | EC_POINT *r, EC_POINT *s, | - | ||||||
118 | EC_POINT *p, BN_CTX *ctx); | - | ||||||
119 | int (*ladder_post)(const EC_GROUP *group, | - | ||||||
120 | EC_POINT *r, EC_POINT *s, | - | ||||||
121 | EC_POINT *p, BN_CTX *ctx); | - | ||||||
122 | }; | - | ||||||
123 | - | |||||||
124 | - | |||||||
125 | - | |||||||
126 | - | |||||||
127 | typedef struct nistp224_pre_comp_st NISTP224_PRE_COMP; | - | ||||||
128 | typedef struct nistp256_pre_comp_st NISTP256_PRE_COMP; | - | ||||||
129 | typedef struct nistp521_pre_comp_st NISTP521_PRE_COMP; | - | ||||||
130 | typedef struct nistz256_pre_comp_st NISTZ256_PRE_COMP; | - | ||||||
131 | typedef struct ec_pre_comp_st EC_PRE_COMP; | - | ||||||
132 | - | |||||||
133 | struct ec_group_st { | - | ||||||
134 | const EC_METHOD *meth; | - | ||||||
135 | EC_POINT *generator; | - | ||||||
136 | BIGNUM *order, *cofactor; | - | ||||||
137 | int curve_name; | - | ||||||
138 | int asn1_flag; | - | ||||||
139 | point_conversion_form_t asn1_form; | - | ||||||
140 | unsigned char *seed; | - | ||||||
141 | - | |||||||
142 | size_t seed_len; | - | ||||||
143 | BIGNUM *field; | - | ||||||
144 | - | |||||||
145 | - | |||||||
146 | - | |||||||
147 | - | |||||||
148 | - | |||||||
149 | - | |||||||
150 | - | |||||||
151 | int poly[6]; | - | ||||||
152 | - | |||||||
153 | - | |||||||
154 | - | |||||||
155 | - | |||||||
156 | - | |||||||
157 | - | |||||||
158 | - | |||||||
159 | BIGNUM *a, *b; | - | ||||||
160 | - | |||||||
161 | int a_is_minus3; | - | ||||||
162 | - | |||||||
163 | void *field_data1; | - | ||||||
164 | - | |||||||
165 | void *field_data2; | - | ||||||
166 | - | |||||||
167 | int (*field_mod_func) (BIGNUM *, const BIGNUM *, const BIGNUM *, | - | ||||||
168 | BN_CTX *); | - | ||||||
169 | - | |||||||
170 | BN_MONT_CTX *mont_data; | - | ||||||
171 | - | |||||||
172 | - | |||||||
173 | - | |||||||
174 | - | |||||||
175 | - | |||||||
176 | - | |||||||
177 | enum { | - | ||||||
178 | PCT_none, | - | ||||||
179 | PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256, | - | ||||||
180 | PCT_ec | - | ||||||
181 | } pre_comp_type; | - | ||||||
182 | union { | - | ||||||
183 | NISTP224_PRE_COMP *nistp224; | - | ||||||
184 | NISTP256_PRE_COMP *nistp256; | - | ||||||
185 | NISTP521_PRE_COMP *nistp521; | - | ||||||
186 | NISTZ256_PRE_COMP *nistz256; | - | ||||||
187 | EC_PRE_COMP *ec; | - | ||||||
188 | } pre_comp; | - | ||||||
189 | }; | - | ||||||
190 | - | |||||||
191 | - | |||||||
192 | - | |||||||
193 | - | |||||||
194 | - | |||||||
195 | - | |||||||
196 | struct ec_key_st { | - | ||||||
197 | const EC_KEY_METHOD *meth; | - | ||||||
198 | ENGINE *engine; | - | ||||||
199 | int version; | - | ||||||
200 | EC_GROUP *group; | - | ||||||
201 | EC_POINT *pub_key; | - | ||||||
202 | BIGNUM *priv_key; | - | ||||||
203 | unsigned int enc_flag; | - | ||||||
204 | point_conversion_form_t conv_form; | - | ||||||
205 | CRYPTO_REF_COUNT references; | - | ||||||
206 | int flags; | - | ||||||
207 | CRYPTO_EX_DATA ex_data; | - | ||||||
208 | CRYPTO_RWLOCK *lock; | - | ||||||
209 | }; | - | ||||||
210 | - | |||||||
211 | struct ec_point_st { | - | ||||||
212 | const EC_METHOD *meth; | - | ||||||
213 | - | |||||||
214 | int curve_name; | - | ||||||
215 | - | |||||||
216 | - | |||||||
217 | - | |||||||
218 | - | |||||||
219 | BIGNUM *X; | - | ||||||
220 | BIGNUM *Y; | - | ||||||
221 | BIGNUM *Z; | - | ||||||
222 | - | |||||||
223 | int Z_is_one; | - | ||||||
224 | - | |||||||
225 | }; | - | ||||||
226 | - | |||||||
227 | static inline int ec_point_is_compat(const EC_POINT *point, | - | ||||||
228 | const EC_GROUP *group) | - | ||||||
229 | { | - | ||||||
230 | if (group->meth != point->meth
| 0-1949088 | ||||||
231 | || (group->curve_name != 0
| 246684-1702404 | ||||||
232 | && point->curve_name != 0
| 2-1702402 | ||||||
233 | && group->curve_name != point->curve_name
| 0-1702402 | ||||||
234 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
235 | - | |||||||
236 | return executed 1949088 times by 2 tests: 1;return 1; Executed by:
executed 1949088 times by 2 tests: return 1; Executed by:
| 1949088 | ||||||
237 | } | - | ||||||
238 | - | |||||||
239 | NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *); | - | ||||||
240 | NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *); | - | ||||||
241 | NISTP521_PRE_COMP *EC_nistp521_pre_comp_dup(NISTP521_PRE_COMP *); | - | ||||||
242 | NISTZ256_PRE_COMP *EC_nistz256_pre_comp_dup(NISTZ256_PRE_COMP *); | - | ||||||
243 | NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *); | - | ||||||
244 | EC_PRE_COMP *EC_ec_pre_comp_dup(EC_PRE_COMP *); | - | ||||||
245 | - | |||||||
246 | void EC_pre_comp_free(EC_GROUP *group); | - | ||||||
247 | void EC_nistp224_pre_comp_free(NISTP224_PRE_COMP *); | - | ||||||
248 | void EC_nistp256_pre_comp_free(NISTP256_PRE_COMP *); | - | ||||||
249 | void EC_nistp521_pre_comp_free(NISTP521_PRE_COMP *); | - | ||||||
250 | void EC_nistz256_pre_comp_free(NISTZ256_PRE_COMP *); | - | ||||||
251 | void EC_ec_pre_comp_free(EC_PRE_COMP *); | - | ||||||
252 | - | |||||||
253 | - | |||||||
254 | - | |||||||
255 | - | |||||||
256 | - | |||||||
257 | int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | - | ||||||
258 | size_t num, const EC_POINT *points[], const BIGNUM *scalars[], | - | ||||||
259 | BN_CTX *); | - | ||||||
260 | int ec_wNAF_precompute_mult(EC_GROUP *group, BN_CTX *); | - | ||||||
261 | int ec_wNAF_have_precompute_mult(const EC_GROUP *group); | - | ||||||
262 | - | |||||||
263 | - | |||||||
264 | int ec_GFp_simple_group_init(EC_GROUP *); | - | ||||||
265 | void ec_GFp_simple_group_finish(EC_GROUP *); | - | ||||||
266 | void ec_GFp_simple_group_clear_finish(EC_GROUP *); | - | ||||||
267 | int ec_GFp_simple_group_copy(EC_GROUP *, const EC_GROUP *); | - | ||||||
268 | int ec_GFp_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, | - | ||||||
269 | const BIGNUM *a, const BIGNUM *b, BN_CTX *); | - | ||||||
270 | int ec_GFp_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, | - | ||||||
271 | BIGNUM *b, BN_CTX *); | - | ||||||
272 | int ec_GFp_simple_group_get_degree(const EC_GROUP *); | - | ||||||
273 | int ec_GFp_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); | - | ||||||
274 | int ec_GFp_simple_point_init(EC_POINT *); | - | ||||||
275 | void ec_GFp_simple_point_finish(EC_POINT *); | - | ||||||
276 | void ec_GFp_simple_point_clear_finish(EC_POINT *); | - | ||||||
277 | int ec_GFp_simple_point_copy(EC_POINT *, const EC_POINT *); | - | ||||||
278 | int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); | - | ||||||
279 | int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *, | - | ||||||
280 | EC_POINT *, const BIGNUM *x, | - | ||||||
281 | const BIGNUM *y, | - | ||||||
282 | const BIGNUM *z, BN_CTX *); | - | ||||||
283 | int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *, | - | ||||||
284 | const EC_POINT *, BIGNUM *x, | - | ||||||
285 | BIGNUM *y, BIGNUM *z, | - | ||||||
286 | BN_CTX *); | - | ||||||
287 | int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, | - | ||||||
288 | const BIGNUM *x, | - | ||||||
289 | const BIGNUM *y, BN_CTX *); | - | ||||||
290 | int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *, | - | ||||||
291 | const EC_POINT *, BIGNUM *x, | - | ||||||
292 | BIGNUM *y, BN_CTX *); | - | ||||||
293 | int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, | - | ||||||
294 | const BIGNUM *x, int y_bit, | - | ||||||
295 | BN_CTX *); | - | ||||||
296 | size_t ec_GFp_simple_point2oct(const EC_GROUP *, const EC_POINT *, | - | ||||||
297 | point_conversion_form_t form, | - | ||||||
298 | unsigned char *buf, size_t len, BN_CTX *); | - | ||||||
299 | int ec_GFp_simple_oct2point(const EC_GROUP *, EC_POINT *, | - | ||||||
300 | const unsigned char *buf, size_t len, BN_CTX *); | - | ||||||
301 | int ec_GFp_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, | - | ||||||
302 | const EC_POINT *b, BN_CTX *); | - | ||||||
303 | int ec_GFp_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, | - | ||||||
304 | BN_CTX *); | - | ||||||
305 | int ec_GFp_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); | - | ||||||
306 | int ec_GFp_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); | - | ||||||
307 | int ec_GFp_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); | - | ||||||
308 | int ec_GFp_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, | - | ||||||
309 | BN_CTX *); | - | ||||||
310 | int ec_GFp_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); | - | ||||||
311 | int ec_GFp_simple_points_make_affine(const EC_GROUP *, size_t num, | - | ||||||
312 | EC_POINT *[], BN_CTX *); | - | ||||||
313 | int ec_GFp_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
314 | const BIGNUM *b, BN_CTX *); | - | ||||||
315 | int ec_GFp_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
316 | BN_CTX *); | - | ||||||
317 | int ec_GFp_simple_blind_coordinates(const EC_GROUP *group, EC_POINT *p, | - | ||||||
318 | BN_CTX *ctx); | - | ||||||
319 | int ec_GFp_simple_ladder_pre(const EC_GROUP *group, | - | ||||||
320 | EC_POINT *r, EC_POINT *s, | - | ||||||
321 | EC_POINT *p, BN_CTX *ctx); | - | ||||||
322 | int ec_GFp_simple_ladder_step(const EC_GROUP *group, | - | ||||||
323 | EC_POINT *r, EC_POINT *s, | - | ||||||
324 | EC_POINT *p, BN_CTX *ctx); | - | ||||||
325 | int ec_GFp_simple_ladder_post(const EC_GROUP *group, | - | ||||||
326 | EC_POINT *r, EC_POINT *s, | - | ||||||
327 | EC_POINT *p, BN_CTX *ctx); | - | ||||||
328 | - | |||||||
329 | - | |||||||
330 | int ec_GFp_mont_group_init(EC_GROUP *); | - | ||||||
331 | int ec_GFp_mont_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, | - | ||||||
332 | const BIGNUM *b, BN_CTX *); | - | ||||||
333 | void ec_GFp_mont_group_finish(EC_GROUP *); | - | ||||||
334 | void ec_GFp_mont_group_clear_finish(EC_GROUP *); | - | ||||||
335 | int ec_GFp_mont_group_copy(EC_GROUP *, const EC_GROUP *); | - | ||||||
336 | int ec_GFp_mont_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
337 | const BIGNUM *b, BN_CTX *); | - | ||||||
338 | int ec_GFp_mont_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
339 | BN_CTX *); | - | ||||||
340 | int ec_GFp_mont_field_encode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
341 | BN_CTX *); | - | ||||||
342 | int ec_GFp_mont_field_decode(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
343 | BN_CTX *); | - | ||||||
344 | int ec_GFp_mont_field_set_to_one(const EC_GROUP *, BIGNUM *r, BN_CTX *); | - | ||||||
345 | - | |||||||
346 | - | |||||||
347 | int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src); | - | ||||||
348 | int ec_GFp_nist_group_set_curve(EC_GROUP *, const BIGNUM *p, const BIGNUM *a, | - | ||||||
349 | const BIGNUM *b, BN_CTX *); | - | ||||||
350 | int ec_GFp_nist_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
351 | const BIGNUM *b, BN_CTX *); | - | ||||||
352 | int ec_GFp_nist_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
353 | BN_CTX *); | - | ||||||
354 | - | |||||||
355 | - | |||||||
356 | int ec_GF2m_simple_group_init(EC_GROUP *); | - | ||||||
357 | void ec_GF2m_simple_group_finish(EC_GROUP *); | - | ||||||
358 | void ec_GF2m_simple_group_clear_finish(EC_GROUP *); | - | ||||||
359 | int ec_GF2m_simple_group_copy(EC_GROUP *, const EC_GROUP *); | - | ||||||
360 | int ec_GF2m_simple_group_set_curve(EC_GROUP *, const BIGNUM *p, | - | ||||||
361 | const BIGNUM *a, const BIGNUM *b, | - | ||||||
362 | BN_CTX *); | - | ||||||
363 | int ec_GF2m_simple_group_get_curve(const EC_GROUP *, BIGNUM *p, BIGNUM *a, | - | ||||||
364 | BIGNUM *b, BN_CTX *); | - | ||||||
365 | int ec_GF2m_simple_group_get_degree(const EC_GROUP *); | - | ||||||
366 | int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *, BN_CTX *); | - | ||||||
367 | int ec_GF2m_simple_point_init(EC_POINT *); | - | ||||||
368 | void ec_GF2m_simple_point_finish(EC_POINT *); | - | ||||||
369 | void ec_GF2m_simple_point_clear_finish(EC_POINT *); | - | ||||||
370 | int ec_GF2m_simple_point_copy(EC_POINT *, const EC_POINT *); | - | ||||||
371 | int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *, EC_POINT *); | - | ||||||
372 | int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *, EC_POINT *, | - | ||||||
373 | const BIGNUM *x, | - | ||||||
374 | const BIGNUM *y, BN_CTX *); | - | ||||||
375 | int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *, | - | ||||||
376 | const EC_POINT *, BIGNUM *x, | - | ||||||
377 | BIGNUM *y, BN_CTX *); | - | ||||||
378 | int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *, EC_POINT *, | - | ||||||
379 | const BIGNUM *x, int y_bit, | - | ||||||
380 | BN_CTX *); | - | ||||||
381 | size_t ec_GF2m_simple_point2oct(const EC_GROUP *, const EC_POINT *, | - | ||||||
382 | point_conversion_form_t form, | - | ||||||
383 | unsigned char *buf, size_t len, BN_CTX *); | - | ||||||
384 | int ec_GF2m_simple_oct2point(const EC_GROUP *, EC_POINT *, | - | ||||||
385 | const unsigned char *buf, size_t len, BN_CTX *); | - | ||||||
386 | int ec_GF2m_simple_add(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, | - | ||||||
387 | const EC_POINT *b, BN_CTX *); | - | ||||||
388 | int ec_GF2m_simple_dbl(const EC_GROUP *, EC_POINT *r, const EC_POINT *a, | - | ||||||
389 | BN_CTX *); | - | ||||||
390 | int ec_GF2m_simple_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); | - | ||||||
391 | int ec_GF2m_simple_is_at_infinity(const EC_GROUP *, const EC_POINT *); | - | ||||||
392 | int ec_GF2m_simple_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); | - | ||||||
393 | int ec_GF2m_simple_cmp(const EC_GROUP *, const EC_POINT *a, const EC_POINT *b, | - | ||||||
394 | BN_CTX *); | - | ||||||
395 | int ec_GF2m_simple_make_affine(const EC_GROUP *, EC_POINT *, BN_CTX *); | - | ||||||
396 | int ec_GF2m_simple_points_make_affine(const EC_GROUP *, size_t num, | - | ||||||
397 | EC_POINT *[], BN_CTX *); | - | ||||||
398 | int ec_GF2m_simple_field_mul(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
399 | const BIGNUM *b, BN_CTX *); | - | ||||||
400 | int ec_GF2m_simple_field_sqr(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
401 | BN_CTX *); | - | ||||||
402 | int ec_GF2m_simple_field_div(const EC_GROUP *, BIGNUM *r, const BIGNUM *a, | - | ||||||
403 | const BIGNUM *b, BN_CTX *); | - | ||||||
404 | int ec_group_simple_order_bits(const EC_GROUP *group); | - | ||||||
405 | - | |||||||
406 | - | |||||||
407 | - | |||||||
408 | - | |||||||
409 | - | |||||||
410 | - | |||||||
411 | const EC_METHOD *EC_GFp_nistz256_method(void); | - | ||||||
412 | - | |||||||
413 | - | |||||||
414 | size_t ec_key_simple_priv2oct(const EC_KEY *eckey, | - | ||||||
415 | unsigned char *buf, size_t len); | - | ||||||
416 | int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len); | - | ||||||
417 | int ec_key_simple_generate_key(EC_KEY *eckey); | - | ||||||
418 | int ec_key_simple_generate_public_key(EC_KEY *eckey); | - | ||||||
419 | int ec_key_simple_check_key(const EC_KEY *eckey); | - | ||||||
420 | - | |||||||
421 | - | |||||||
422 | - | |||||||
423 | struct ec_key_method_st { | - | ||||||
424 | const char *name; | - | ||||||
425 | int32_t flags; | - | ||||||
426 | int (*init)(EC_KEY *key); | - | ||||||
427 | void (*finish)(EC_KEY *key); | - | ||||||
428 | int (*copy)(EC_KEY *dest, const EC_KEY *src); | - | ||||||
429 | int (*set_group)(EC_KEY *key, const EC_GROUP *grp); | - | ||||||
430 | int (*set_private)(EC_KEY *key, const BIGNUM *priv_key); | - | ||||||
431 | int (*set_public)(EC_KEY *key, const EC_POINT *pub_key); | - | ||||||
432 | int (*keygen)(EC_KEY *key); | - | ||||||
433 | int (*compute_key)(unsigned char **pout, size_t *poutlen, | - | ||||||
434 | const EC_POINT *pub_key, const EC_KEY *ecdh); | - | ||||||
435 | int (*sign)(int type, const unsigned char *dgst, int dlen, unsigned char | - | ||||||
436 | *sig, unsigned int *siglen, const BIGNUM *kinv, | - | ||||||
437 | const BIGNUM *r, EC_KEY *eckey); | - | ||||||
438 | int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | - | ||||||
439 | BIGNUM **rp); | - | ||||||
440 | ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, int dgst_len, | - | ||||||
441 | const BIGNUM *in_kinv, const BIGNUM *in_r, | - | ||||||
442 | EC_KEY *eckey); | - | ||||||
443 | - | |||||||
444 | int (*verify)(int type, const unsigned char *dgst, int dgst_len, | - | ||||||
445 | const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); | - | ||||||
446 | int (*verify_sig)(const unsigned char *dgst, int dgst_len, | - | ||||||
447 | const ECDSA_SIG *sig, EC_KEY *eckey); | - | ||||||
448 | }; | - | ||||||
449 | - | |||||||
450 | - | |||||||
451 | - | |||||||
452 | int ossl_ec_key_gen(EC_KEY *eckey); | - | ||||||
453 | int ossl_ecdh_compute_key(unsigned char **pout, size_t *poutlen, | - | ||||||
454 | const EC_POINT *pub_key, const EC_KEY *ecdh); | - | ||||||
455 | int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen, | - | ||||||
456 | const EC_POINT *pub_key, const EC_KEY *ecdh); | - | ||||||
457 | - | |||||||
458 | struct ECDSA_SIG_st { | - | ||||||
459 | BIGNUM *r; | - | ||||||
460 | BIGNUM *s; | - | ||||||
461 | }; | - | ||||||
462 | - | |||||||
463 | int ossl_ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | - | ||||||
464 | BIGNUM **rp); | - | ||||||
465 | int ossl_ecdsa_sign(int type, const unsigned char *dgst, int dlen, | - | ||||||
466 | unsigned char *sig, unsigned int *siglen, | - | ||||||
467 | const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey); | - | ||||||
468 | ECDSA_SIG *ossl_ecdsa_sign_sig(const unsigned char *dgst, int dgst_len, | - | ||||||
469 | const BIGNUM *in_kinv, const BIGNUM *in_r, | - | ||||||
470 | EC_KEY *eckey); | - | ||||||
471 | int ossl_ecdsa_verify(int type, const unsigned char *dgst, int dgst_len, | - | ||||||
472 | const unsigned char *sigbuf, int sig_len, EC_KEY *eckey); | - | ||||||
473 | int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, | - | ||||||
474 | const ECDSA_SIG *sig, EC_KEY *eckey); | - | ||||||
475 | - | |||||||
476 | int ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len, | - | ||||||
477 | const uint8_t public_key[32], const uint8_t private_key[32]); | - | ||||||
478 | int ED25519_verify(const uint8_t *message, size_t message_len, | - | ||||||
479 | const uint8_t signature[64], const uint8_t public_key[32]); | - | ||||||
480 | void ED25519_public_from_private(uint8_t out_public_key[32], | - | ||||||
481 | const uint8_t private_key[32]); | - | ||||||
482 | - | |||||||
483 | int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32], | - | ||||||
484 | const uint8_t peer_public_value[32]); | - | ||||||
485 | void X25519_public_from_private(uint8_t out_public_value[32], | - | ||||||
486 | const uint8_t private_key[32]); | - | ||||||
487 | int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r, | - | ||||||
488 | const BIGNUM *scalar, const EC_POINT *point, | - | ||||||
489 | BN_CTX *ctx); | - | ||||||
490 | - | |||||||
491 | int ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx); | - | ||||||
492 | - | |||||||
493 | static inline int ec_point_ladder_pre(const EC_GROUP *group, | - | ||||||
494 | EC_POINT *r, EC_POINT *s, | - | ||||||
495 | EC_POINT *p, BN_CTX *ctx) | - | ||||||
496 | { | - | ||||||
497 | if (group->meth->ladder_pre !=
| 0-4130 | ||||||
498 | ((void *)0)
| 0-4130 | ||||||
499 | ) | - | ||||||
500 | return executed 4130 times by 2 tests: group->meth->ladder_pre(group, r, s, p, ctx);return group->meth->ladder_pre(group, r, s, p, ctx); Executed by:
executed 4130 times by 2 tests: return group->meth->ladder_pre(group, r, s, p, ctx); Executed by:
| 4130 | ||||||
501 | - | |||||||
502 | if (!EC_POINT_copy(s, p)
| 0 | ||||||
503 | || !EC_POINT_dbl(group, r, s, ctx)
| 0 | ||||||
504 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
505 | - | |||||||
506 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
507 | } | - | ||||||
508 | - | |||||||
509 | static inline int ec_point_ladder_step(const EC_GROUP *group, | - | ||||||
510 | EC_POINT *r, EC_POINT *s, | - | ||||||
511 | EC_POINT *p, BN_CTX *ctx) | - | ||||||
512 | { | - | ||||||
513 | if (group->meth->ladder_step !=
| 0-1193659 | ||||||
514 | ((void *)0)
| 0-1193659 | ||||||
515 | ) | - | ||||||
516 | return executed 1193659 times by 2 tests: group->meth->ladder_step(group, r, s, p, ctx);return group->meth->ladder_step(group, r, s, p, ctx); Executed by:
executed 1193659 times by 2 tests: return group->meth->ladder_step(group, r, s, p, ctx); Executed by:
| 1193659 | ||||||
517 | - | |||||||
518 | if (!EC_POINT_add(group, s, r, s, ctx)
| 0 | ||||||
519 | || !EC_POINT_dbl(group, r, r, ctx)
| 0 | ||||||
520 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||
521 | - | |||||||
522 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
523 | - | |||||||
524 | } | - | ||||||
525 | - | |||||||
526 | static inline int ec_point_ladder_post(const EC_GROUP *group, | - | ||||||
527 | EC_POINT *r, EC_POINT *s, | - | ||||||
528 | EC_POINT *p, BN_CTX *ctx) | - | ||||||
529 | { | - | ||||||
530 | if (group->meth->ladder_post !=
| 0-4130 | ||||||
531 | ((void *)0)
| 0-4130 | ||||||
532 | ) | - | ||||||
533 | return executed 4130 times by 2 tests: group->meth->ladder_post(group, r, s, p, ctx);return group->meth->ladder_post(group, r, s, p, ctx); Executed by:
executed 4130 times by 2 tests: return group->meth->ladder_post(group, r, s, p, ctx); Executed by:
| 4130 | ||||||
534 | - | |||||||
535 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||
536 | } | - | ||||||
Switch to Source code | Preprocessed file |