| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ecp_mont.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | const EC_METHOD *EC_GFp_mont_method(void) | - | ||||||
| 4 | { | - | ||||||
| 5 | static const EC_METHOD ret = { | - | ||||||
| 6 | 0x1, | - | ||||||
| 7 | 406, | - | ||||||
| 8 | ec_GFp_mont_group_init, | - | ||||||
| 9 | ec_GFp_mont_group_finish, | - | ||||||
| 10 | ec_GFp_mont_group_clear_finish, | - | ||||||
| 11 | ec_GFp_mont_group_copy, | - | ||||||
| 12 | ec_GFp_mont_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_mont_field_mul, | - | ||||||
| 39 | ec_GFp_mont_field_sqr, | - | ||||||
| 40 | 0 , | - | ||||||
| 41 | ec_GFp_mont_field_encode, | - | ||||||
| 42 | ec_GFp_mont_field_decode, | - | ||||||
| 43 | ec_GFp_mont_field_set_to_one, | - | ||||||
| 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 executed 8288 times by 2 tests: &ret;return &ret;Executed by:
executed 8288 times by 2 tests: return &ret;Executed by:
| 8288 | ||||||
| 61 | } | - | ||||||
| 62 | - | |||||||
| 63 | int ec_GFp_mont_group_init(EC_GROUP *group) | - | ||||||
| 64 | { | - | ||||||
| 65 | int ok; | - | ||||||
| 66 | - | |||||||
| 67 | ok = ec_GFp_simple_group_init(group); | - | ||||||
| 68 | group->field_data1 = | - | ||||||
| 69 | ((void *)0) | - | ||||||
| 70 | ; | - | ||||||
| 71 | group->field_data2 = | - | ||||||
| 72 | ((void *)0) | - | ||||||
| 73 | ; | - | ||||||
| 74 | return executed 50449 times by 2 tests: ok;return ok;Executed by:
executed 50449 times by 2 tests: return ok;Executed by:
| 50449 | ||||||
| 75 | } | - | ||||||
| 76 | - | |||||||
| 77 | void ec_GFp_mont_group_finish(EC_GROUP *group) | - | ||||||
| 78 | { | - | ||||||
| 79 | BN_MONT_CTX_free(group->field_data1); | - | ||||||
| 80 | group->field_data1 = | - | ||||||
| 81 | ((void *)0) | - | ||||||
| 82 | ; | - | ||||||
| 83 | BN_free(group->field_data2); | - | ||||||
| 84 | group->field_data2 = | - | ||||||
| 85 | ((void *)0) | - | ||||||
| 86 | ; | - | ||||||
| 87 | ec_GFp_simple_group_finish(group); | - | ||||||
| 88 | } executed 49744 times by 2 tests: end of blockExecuted by:
| 49744 | ||||||
| 89 | - | |||||||
| 90 | void ec_GFp_mont_group_clear_finish(EC_GROUP *group) | - | ||||||
| 91 | { | - | ||||||
| 92 | BN_MONT_CTX_free(group->field_data1); | - | ||||||
| 93 | group->field_data1 = | - | ||||||
| 94 | ((void *)0) | - | ||||||
| 95 | ; | - | ||||||
| 96 | BN_clear_free(group->field_data2); | - | ||||||
| 97 | group->field_data2 = | - | ||||||
| 98 | ((void *)0) | - | ||||||
| 99 | ; | - | ||||||
| 100 | ec_GFp_simple_group_clear_finish(group); | - | ||||||
| 101 | } executed 705 times by 1 test: end of blockExecuted by:
| 705 | ||||||
| 102 | - | |||||||
| 103 | int ec_GFp_mont_group_copy(EC_GROUP *dest, const EC_GROUP *src) | - | ||||||
| 104 | { | - | ||||||
| 105 | BN_MONT_CTX_free(dest->field_data1); | - | ||||||
| 106 | dest->field_data1 = | - | ||||||
| 107 | ((void *)0) | - | ||||||
| 108 | ; | - | ||||||
| 109 | BN_clear_free(dest->field_data2); | - | ||||||
| 110 | dest->field_data2 = | - | ||||||
| 111 | ((void *)0) | - | ||||||
| 112 | ; | - | ||||||
| 113 | - | |||||||
| 114 | if (!ec_GFp_simple_group_copy(dest, src)
| 0-24081 | ||||||
| 115 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 116 | - | |||||||
| 117 | if (src->field_data1 !=
| 0-24081 | ||||||
| 118 | ((void *)0)
| 0-24081 | ||||||
| 119 | ) { | - | ||||||
| 120 | dest->field_data1 = BN_MONT_CTX_new(); | - | ||||||
| 121 | if (dest->field_data1 ==
| 0-24081 | ||||||
| 122 | ((void *)0)
| 0-24081 | ||||||
| 123 | ) | - | ||||||
| 124 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 125 | if (!BN_MONT_CTX_copy(dest->field_data1, src->field_data1)
| 0-24081 | ||||||
| 126 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||
| 127 | } executed 24081 times by 2 tests: end of blockExecuted by:
| 24081 | ||||||
| 128 | if (src->field_data2 !=
| 0-24081 | ||||||
| 129 | ((void *)0)
| 0-24081 | ||||||
| 130 | ) { | - | ||||||
| 131 | dest->field_data2 = BN_dup(src->field_data2); | - | ||||||
| 132 | if (dest->field_data2 ==
| 0-24081 | ||||||
| 133 | ((void *)0)
| 0-24081 | ||||||
| 134 | ) | - | ||||||
| 135 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||
| 136 | } executed 24081 times by 2 tests: end of blockExecuted by:
| 24081 | ||||||
| 137 | - | |||||||
| 138 | return executed 24081 times by 2 tests: 1;return 1;Executed by:
executed 24081 times by 2 tests: return 1;Executed by:
| 24081 | ||||||
| 139 | - | |||||||
| 140 | err: | - | ||||||
| 141 | BN_MONT_CTX_free(dest->field_data1); | - | ||||||
| 142 | dest->field_data1 = | - | ||||||
| 143 | ((void *)0) | - | ||||||
| 144 | ; | - | ||||||
| 145 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 146 | } | - | ||||||
| 147 | - | |||||||
| 148 | int ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, | - | ||||||
| 149 | const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | - | ||||||
| 150 | { | - | ||||||
| 151 | BN_CTX *new_ctx = | - | ||||||
| 152 | ((void *)0) | - | ||||||
| 153 | ; | - | ||||||
| 154 | BN_MONT_CTX *mont = | - | ||||||
| 155 | ((void *)0) | - | ||||||
| 156 | ; | - | ||||||
| 157 | BIGNUM *one = | - | ||||||
| 158 | ((void *)0) | - | ||||||
| 159 | ; | - | ||||||
| 160 | int ret = 0; | - | ||||||
| 161 | - | |||||||
| 162 | BN_MONT_CTX_free(group->field_data1); | - | ||||||
| 163 | group->field_data1 = | - | ||||||
| 164 | ((void *)0) | - | ||||||
| 165 | ; | - | ||||||
| 166 | BN_free(group->field_data2); | - | ||||||
| 167 | group->field_data2 = | - | ||||||
| 168 | ((void *)0) | - | ||||||
| 169 | ; | - | ||||||
| 170 | - | |||||||
| 171 | if (ctx ==
| 901-25473 | ||||||
| 172 | ((void *)0)
| 901-25473 | ||||||
| 173 | ) { | - | ||||||
| 174 | ctx = new_ctx = BN_CTX_new(); | - | ||||||
| 175 | if (ctx ==
| 0-901 | ||||||
| 176 | ((void *)0)
| 0-901 | ||||||
| 177 | ) | - | ||||||
| 178 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 179 | } executed 901 times by 2 tests: end of blockExecuted by:
| 901 | ||||||
| 180 | - | |||||||
| 181 | mont = BN_MONT_CTX_new(); | - | ||||||
| 182 | if (mont ==
| 0-26374 | ||||||
| 183 | ((void *)0)
| 0-26374 | ||||||
| 184 | ) | - | ||||||
| 185 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||
| 186 | if (!BN_MONT_CTX_set(mont, p, ctx)
| 422-25952 | ||||||
| 187 | ERR_put_error(16,(189),(3),__FILE__,157); | - | ||||||
| 188 | goto executed 422 times by 1 test: err;goto err;Executed by:
executed 422 times by 1 test: goto err;Executed by:
| 422 | ||||||
| 189 | } | - | ||||||
| 190 | one = BN_new(); | - | ||||||
| 191 | if (one ==
| 0-25952 | ||||||
| 192 | ((void *)0)
| 0-25952 | ||||||
| 193 | ) | - | ||||||
| 194 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||
| 195 | if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)
| 0-25952 | ||||||
| 196 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||
| 197 | - | |||||||
| 198 | group->field_data1 = mont; | - | ||||||
| 199 | mont = | - | ||||||
| 200 | ((void *)0) | - | ||||||
| 201 | ; | - | ||||||
| 202 | group->field_data2 = one; | - | ||||||
| 203 | one = | - | ||||||
| 204 | ((void *)0) | - | ||||||
| 205 | ; | - | ||||||
| 206 | - | |||||||
| 207 | ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx); | - | ||||||
| 208 | - | |||||||
| 209 | if (!ret
| 0-25952 | ||||||
| 210 | BN_MONT_CTX_free(group->field_data1); | - | ||||||
| 211 | group->field_data1 = | - | ||||||
| 212 | ((void *)0) | - | ||||||
| 213 | ; | - | ||||||
| 214 | BN_free(group->field_data2); | - | ||||||
| 215 | group->field_data2 = | - | ||||||
| 216 | ((void *)0) | - | ||||||
| 217 | ; | - | ||||||
| 218 | } never executed: end of block | 0 | ||||||
| 219 | - | |||||||
| 220 | err: code before this statement executed 25952 times by 2 tests: err:Executed by:
| 25952 | ||||||
| 221 | BN_free(one); | - | ||||||
| 222 | BN_CTX_free(new_ctx); | - | ||||||
| 223 | BN_MONT_CTX_free(mont); | - | ||||||
| 224 | return executed 26374 times by 2 tests: ret;return ret;Executed by:
executed 26374 times by 2 tests: return ret;Executed by:
| 26374 | ||||||
| 225 | } | - | ||||||
| 226 | - | |||||||
| 227 | int ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | - | ||||||
| 228 | const BIGNUM *b, BN_CTX *ctx) | - | ||||||
| 229 | { | - | ||||||
| 230 | if (group->field_data1 ==
| 0-10812907 | ||||||
| 231 | ((void *)0)
| 0-10812907 | ||||||
| 232 | ) { | - | ||||||
| 233 | ERR_put_error(16,(131),(111),__FILE__,191); | - | ||||||
| 234 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 235 | } | - | ||||||
| 236 | - | |||||||
| 237 | return executed 10812907 times by 2 tests: BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx);return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx);Executed by:
executed 10812907 times by 2 tests: return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx);Executed by:
| 10812907 | ||||||
| 238 | } | - | ||||||
| 239 | - | |||||||
| 240 | int ec_GFp_mont_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, | - | ||||||
| 241 | BN_CTX *ctx) | - | ||||||
| 242 | { | - | ||||||
| 243 | if (group->field_data1 ==
| 0-5415687 | ||||||
| 244 | ((void *)0)
| 0-5415687 | ||||||
| 245 | ) { | - | ||||||
| 246 | ERR_put_error(16,(132),(111),__FILE__,202); | - | ||||||
| 247 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 248 | } | - | ||||||
| 249 | - | |||||||
| 250 | return executed 5415687 times by 2 tests: BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx);return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx);Executed by:
executed 5415687 times by 2 tests: return BN_mod_mul_montgomery(r, a, a, group->field_data1, ctx);Executed by:
| 5415687 | ||||||
| 251 | } | - | ||||||
| 252 | - | |||||||
| 253 | int ec_GFp_mont_field_encode(const EC_GROUP *group, BIGNUM *r, | - | ||||||
| 254 | const BIGNUM *a, BN_CTX *ctx) | - | ||||||
| 255 | { | - | ||||||
| 256 | if (group->field_data1 ==
| 0-150556 | ||||||
| 257 | ((void *)0)
| 0-150556 | ||||||
| 258 | ) { | - | ||||||
| 259 | ERR_put_error(16,(134),(111),__FILE__,213); | - | ||||||
| 260 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 261 | } | - | ||||||
| 262 | - | |||||||
| 263 | return executed 150556 times by 2 tests: BN_to_montgomery(r, a, (BN_MONT_CTX *)group->field_data1, ctx);return BN_to_montgomery(r, a, (BN_MONT_CTX *)group->field_data1, ctx);Executed by:
executed 150556 times by 2 tests: return BN_to_montgomery(r, a, (BN_MONT_CTX *)group->field_data1, ctx);Executed by:
| 150556 | ||||||
| 264 | } | - | ||||||
| 265 | - | |||||||
| 266 | int ec_GFp_mont_field_decode(const EC_GROUP *group, BIGNUM *r, | - | ||||||
| 267 | const BIGNUM *a, BN_CTX *ctx) | - | ||||||
| 268 | { | - | ||||||
| 269 | if (group->field_data1 ==
| 0-27487 | ||||||
| 270 | ((void *)0)
| 0-27487 | ||||||
| 271 | ) { | - | ||||||
| 272 | ERR_put_error(16,(133),(111),__FILE__,224); | - | ||||||
| 273 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 274 | } | - | ||||||
| 275 | - | |||||||
| 276 | return executed 27487 times by 2 tests: BN_from_montgomery(r, a, group->field_data1, ctx);return BN_from_montgomery(r, a, group->field_data1, ctx);Executed by:
executed 27487 times by 2 tests: return BN_from_montgomery(r, a, group->field_data1, ctx);Executed by:
| 27487 | ||||||
| 277 | } | - | ||||||
| 278 | - | |||||||
| 279 | int ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, | - | ||||||
| 280 | BN_CTX *ctx) | - | ||||||
| 281 | { | - | ||||||
| 282 | if (group->field_data2 ==
| 0-63607 | ||||||
| 283 | ((void *)0)
| 0-63607 | ||||||
| 284 | ) { | - | ||||||
| 285 | ERR_put_error(16,(209),(111),__FILE__,235); | - | ||||||
| 286 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 287 | } | - | ||||||
| 288 | - | |||||||
| 289 | if (!BN_copy(r, group->field_data2)
| 0-63607 | ||||||
| 290 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||
| 291 | return executed 63607 times by 2 tests: 1;return 1;Executed by:
executed 63607 times by 2 tests: return 1;Executed by:
| 63607 | ||||||
| 292 | } | - | ||||||
| Switch to Source code | Preprocessed file |