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