Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/ec/ecp_nist.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | const EC_METHOD * | - | ||||||||||||||||||||||||
4 | EC_GFp_nist_method(void) | - | ||||||||||||||||||||||||
5 | { | - | ||||||||||||||||||||||||
6 | static const EC_METHOD ret = { | - | ||||||||||||||||||||||||
7 | .flags = 0x1, | - | ||||||||||||||||||||||||
8 | .field_type = 406, | - | ||||||||||||||||||||||||
9 | .group_init = ec_GFp_simple_group_init, | - | ||||||||||||||||||||||||
10 | .group_finish = ec_GFp_simple_group_finish, | - | ||||||||||||||||||||||||
11 | .group_clear_finish = ec_GFp_simple_group_clear_finish, | - | ||||||||||||||||||||||||
12 | .group_copy = ec_GFp_nist_group_copy, | - | ||||||||||||||||||||||||
13 | .group_set_curve = ec_GFp_nist_group_set_curve, | - | ||||||||||||||||||||||||
14 | .group_get_curve = ec_GFp_simple_group_get_curve, | - | ||||||||||||||||||||||||
15 | .group_get_degree = ec_GFp_simple_group_get_degree, | - | ||||||||||||||||||||||||
16 | .group_check_discriminant = | - | ||||||||||||||||||||||||
17 | ec_GFp_simple_group_check_discriminant, | - | ||||||||||||||||||||||||
18 | .point_init = ec_GFp_simple_point_init, | - | ||||||||||||||||||||||||
19 | .point_finish = ec_GFp_simple_point_finish, | - | ||||||||||||||||||||||||
20 | .point_clear_finish = ec_GFp_simple_point_clear_finish, | - | ||||||||||||||||||||||||
21 | .point_copy = ec_GFp_simple_point_copy, | - | ||||||||||||||||||||||||
22 | .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, | - | ||||||||||||||||||||||||
23 | .point_set_Jprojective_coordinates_GFp = | - | ||||||||||||||||||||||||
24 | ec_GFp_simple_set_Jprojective_coordinates_GFp, | - | ||||||||||||||||||||||||
25 | .point_get_Jprojective_coordinates_GFp = | - | ||||||||||||||||||||||||
26 | ec_GFp_simple_get_Jprojective_coordinates_GFp, | - | ||||||||||||||||||||||||
27 | .point_set_affine_coordinates = | - | ||||||||||||||||||||||||
28 | ec_GFp_simple_point_set_affine_coordinates, | - | ||||||||||||||||||||||||
29 | .point_get_affine_coordinates = | - | ||||||||||||||||||||||||
30 | ec_GFp_simple_point_get_affine_coordinates, | - | ||||||||||||||||||||||||
31 | .add = ec_GFp_simple_add, | - | ||||||||||||||||||||||||
32 | .dbl = ec_GFp_simple_dbl, | - | ||||||||||||||||||||||||
33 | .invert = ec_GFp_simple_invert, | - | ||||||||||||||||||||||||
34 | .is_at_infinity = ec_GFp_simple_is_at_infinity, | - | ||||||||||||||||||||||||
35 | .is_on_curve = ec_GFp_simple_is_on_curve, | - | ||||||||||||||||||||||||
36 | .point_cmp = ec_GFp_simple_cmp, | - | ||||||||||||||||||||||||
37 | .make_affine = ec_GFp_simple_make_affine, | - | ||||||||||||||||||||||||
38 | .points_make_affine = ec_GFp_simple_points_make_affine, | - | ||||||||||||||||||||||||
39 | .mul_generator_ct = ec_GFp_simple_mul_generator_ct, | - | ||||||||||||||||||||||||
40 | .mul_single_ct = ec_GFp_simple_mul_single_ct, | - | ||||||||||||||||||||||||
41 | .mul_double_nonct = ec_GFp_simple_mul_double_nonct, | - | ||||||||||||||||||||||||
42 | .field_mul = ec_GFp_nist_field_mul, | - | ||||||||||||||||||||||||
43 | .field_sqr = ec_GFp_nist_field_sqr | - | ||||||||||||||||||||||||
44 | }; | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | return never executed: &ret;return &ret; never executed: return &ret; | 0 | ||||||||||||||||||||||||
47 | } | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | int | - | ||||||||||||||||||||||||
50 | ec_GFp_nist_group_copy(EC_GROUP * dest, const EC_GROUP * src) | - | ||||||||||||||||||||||||
51 | { | - | ||||||||||||||||||||||||
52 | dest->field_mod_func = src->field_mod_func; | - | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | return never executed: ec_GFp_simple_group_copy(dest, src);return ec_GFp_simple_group_copy(dest, src); never executed: return ec_GFp_simple_group_copy(dest, src); | 0 | ||||||||||||||||||||||||
55 | } | - | ||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | int | - | ||||||||||||||||||||||||
58 | ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p, | - | ||||||||||||||||||||||||
59 | const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
60 | { | - | ||||||||||||||||||||||||
61 | int ret = 0; | - | ||||||||||||||||||||||||
62 | BN_CTX *new_ctx = | - | ||||||||||||||||||||||||
63 | ((void *)0) | - | ||||||||||||||||||||||||
64 | ; | - | ||||||||||||||||||||||||
65 | BIGNUM *tmp_bn; | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | if (ctx ==
| 0 | ||||||||||||||||||||||||
68 | ((void *)0)
| 0 | ||||||||||||||||||||||||
69 | ) | - | ||||||||||||||||||||||||
70 | if ((
| 0 | ||||||||||||||||||||||||
71 | ((void *)0)
| 0 | ||||||||||||||||||||||||
72 | ) | - | ||||||||||||||||||||||||
73 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||
75 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
76 | if ((
| 0 | ||||||||||||||||||||||||
77 | ((void *)0)
| 0 | ||||||||||||||||||||||||
78 | ) | - | ||||||||||||||||||||||||
79 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | if (BN_ucmp(BN_get0_nist_prime_192(), p) == 0
| 0 | ||||||||||||||||||||||||
82 | group->field_mod_func = BN_nist_mod_192; never executed: group->field_mod_func = BN_nist_mod_192; | 0 | ||||||||||||||||||||||||
83 | else if (BN_ucmp(BN_get0_nist_prime_224(), p) == 0
| 0 | ||||||||||||||||||||||||
84 | group->field_mod_func = BN_nist_mod_224; never executed: group->field_mod_func = BN_nist_mod_224; | 0 | ||||||||||||||||||||||||
85 | else if (BN_ucmp(BN_get0_nist_prime_256(), p) == 0
| 0 | ||||||||||||||||||||||||
86 | group->field_mod_func = BN_nist_mod_256; never executed: group->field_mod_func = BN_nist_mod_256; | 0 | ||||||||||||||||||||||||
87 | else if (BN_ucmp(BN_get0_nist_prime_384(), p) == 0
| 0 | ||||||||||||||||||||||||
88 | group->field_mod_func = BN_nist_mod_384; never executed: group->field_mod_func = BN_nist_mod_384; | 0 | ||||||||||||||||||||||||
89 | else if (BN_ucmp(BN_get0_nist_prime_521(), p) == 0
| 0 | ||||||||||||||||||||||||
90 | group->field_mod_func = BN_nist_mod_521; never executed: group->field_mod_func = BN_nist_mod_521; | 0 | ||||||||||||||||||||||||
91 | else { | - | ||||||||||||||||||||||||
92 | ERR_put_error(16,(0xfff),(135),__FILE__,151); | - | ||||||||||||||||||||||||
93 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
94 | } | - | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); | - | ||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||
98 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
99 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||
100 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||||||||
101 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | - | |||||||||||||||||||||||||
105 | int | - | ||||||||||||||||||||||||
106 | ec_GFp_nist_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | - | ||||||||||||||||||||||||
107 | const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
108 | { | - | ||||||||||||||||||||||||
109 | int ret = 0; | - | ||||||||||||||||||||||||
110 | BN_CTX *ctx_new = | - | ||||||||||||||||||||||||
111 | ((void *)0) | - | ||||||||||||||||||||||||
112 | ; | - | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | if (!group
| 0 | ||||||||||||||||||||||||
115 | ERR_put_error(16,(0xfff),((3|64)),__FILE__,172); | - | ||||||||||||||||||||||||
116 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
117 | } | - | ||||||||||||||||||||||||
118 | if (!ctx
| 0 | ||||||||||||||||||||||||
119 | if ((
| 0 | ||||||||||||||||||||||||
120 | ((void *)0)
| 0 | ||||||||||||||||||||||||
121 | ) | - | ||||||||||||||||||||||||
122 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | if (!BN_mul(r, a, b, ctx)
| 0 | ||||||||||||||||||||||||
125 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
126 | if (!group->field_mod_func(r, r, &group->field, ctx)
| 0 | ||||||||||||||||||||||||
127 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | ret = 1; | - | ||||||||||||||||||||||||
130 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
131 | BN_CTX_free(ctx_new); | - | ||||||||||||||||||||||||
132 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
133 | } | - | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | - | |||||||||||||||||||||||||
136 | int | - | ||||||||||||||||||||||||
137 | ec_GFp_nist_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, | - | ||||||||||||||||||||||||
138 | BN_CTX * ctx) | - | ||||||||||||||||||||||||
139 | { | - | ||||||||||||||||||||||||
140 | int ret = 0; | - | ||||||||||||||||||||||||
141 | BN_CTX *ctx_new = | - | ||||||||||||||||||||||||
142 | ((void *)0) | - | ||||||||||||||||||||||||
143 | ; | - | ||||||||||||||||||||||||
144 | - | |||||||||||||||||||||||||
145 | if (!group
| 0 | ||||||||||||||||||||||||
146 | ERR_put_error(16,(0xfff),(134),__FILE__,199); | - | ||||||||||||||||||||||||
147 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
148 | } | - | ||||||||||||||||||||||||
149 | if (!ctx
| 0 | ||||||||||||||||||||||||
150 | if ((
| 0 | ||||||||||||||||||||||||
151 | ((void *)0)
| 0 | ||||||||||||||||||||||||
152 | ) | - | ||||||||||||||||||||||||
153 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
154 | - | |||||||||||||||||||||||||
155 | if (!BN_sqr(r, a, ctx)
| 0 | ||||||||||||||||||||||||
156 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
157 | if (!group->field_mod_func(r, r, &group->field, ctx)
| 0 | ||||||||||||||||||||||||
158 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | ret = 1; | - | ||||||||||||||||||||||||
161 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
162 | BN_CTX_free(ctx_new); | - | ||||||||||||||||||||||||
163 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||
164 | } | - | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |