| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/ec2_smpl.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||
| 9 | int ec_GF2m_simple_group_init(EC_GROUP *group) | - | ||||||||||||||||||||||||
| 10 | { | - | ||||||||||||||||||||||||
| 11 | group->field = BN_new(); | - | ||||||||||||||||||||||||
| 12 | group->a = BN_new(); | - | ||||||||||||||||||||||||
| 13 | group->b = BN_new(); | - | ||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||
| 15 | if (group->field ==
| 0-19489 | ||||||||||||||||||||||||
| 16 | ((void *)0)
| 0-19489 | ||||||||||||||||||||||||
| 17 | || group->a ==
| 0-19489 | ||||||||||||||||||||||||
| 18 | ((void *)0)
| 0-19489 | ||||||||||||||||||||||||
| 19 | || group->b ==
| 0-19489 | ||||||||||||||||||||||||
| 20 | ((void *)0)
| 0-19489 | ||||||||||||||||||||||||
| 21 | ) { | - | ||||||||||||||||||||||||
| 22 | BN_free(group->field); | - | ||||||||||||||||||||||||
| 23 | BN_free(group->a); | - | ||||||||||||||||||||||||
| 24 | BN_free(group->b); | - | ||||||||||||||||||||||||
| 25 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 26 | } | - | ||||||||||||||||||||||||
| 27 | return executed 19489 times by 1 test: 1;return 1;Executed by:
executed 19489 times by 1 test: return 1;Executed by:
| 19489 | ||||||||||||||||||||||||
| 28 | } | - | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | void ec_GF2m_simple_group_finish(EC_GROUP *group) | - | ||||||||||||||||||||||||
| 35 | { | - | ||||||||||||||||||||||||
| 36 | BN_free(group->field); | - | ||||||||||||||||||||||||
| 37 | BN_free(group->a); | - | ||||||||||||||||||||||||
| 38 | BN_free(group->b); | - | ||||||||||||||||||||||||
| 39 | } executed 19488 times by 1 test: end of blockExecuted by:
| 19488 | ||||||||||||||||||||||||
| 40 | - | |||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | - | |||||||||||||||||||||||||
| 45 | void ec_GF2m_simple_group_clear_finish(EC_GROUP *group) | - | ||||||||||||||||||||||||
| 46 | { | - | ||||||||||||||||||||||||
| 47 | BN_clear_free(group->field); | - | ||||||||||||||||||||||||
| 48 | BN_clear_free(group->a); | - | ||||||||||||||||||||||||
| 49 | BN_clear_free(group->b); | - | ||||||||||||||||||||||||
| 50 | group->poly[0] = 0; | - | ||||||||||||||||||||||||
| 51 | group->poly[1] = 0; | - | ||||||||||||||||||||||||
| 52 | group->poly[2] = 0; | - | ||||||||||||||||||||||||
| 53 | group->poly[3] = 0; | - | ||||||||||||||||||||||||
| 54 | group->poly[4] = 0; | - | ||||||||||||||||||||||||
| 55 | group->poly[5] = -1; | - | ||||||||||||||||||||||||
| 56 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | - | |||||||||||||||||||||||||
| 62 | int ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) | - | ||||||||||||||||||||||||
| 63 | { | - | ||||||||||||||||||||||||
| 64 | if (!BN_copy(dest->field, src->field)
| 0-9858 | ||||||||||||||||||||||||
| 65 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 66 | if (!BN_copy(dest->a, src->a)
| 0-9858 | ||||||||||||||||||||||||
| 67 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 68 | if (!BN_copy(dest->b, src->b)
| 0-9858 | ||||||||||||||||||||||||
| 69 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 70 | dest->poly[0] = src->poly[0]; | - | ||||||||||||||||||||||||
| 71 | dest->poly[1] = src->poly[1]; | - | ||||||||||||||||||||||||
| 72 | dest->poly[2] = src->poly[2]; | - | ||||||||||||||||||||||||
| 73 | dest->poly[3] = src->poly[3]; | - | ||||||||||||||||||||||||
| 74 | dest->poly[4] = src->poly[4]; | - | ||||||||||||||||||||||||
| 75 | dest->poly[5] = src->poly[5]; | - | ||||||||||||||||||||||||
| 76 | if (bn_wexpand(dest->a, (int)(dest->poly[0] + (8 * 8) - 1) / (8 * 8)) ==
| 0-9858 | ||||||||||||||||||||||||
| 77 |
| 0-9858 | ||||||||||||||||||||||||
| 78 | ((void *)0)
| 0-9858 | ||||||||||||||||||||||||
| 79 | ) | - | ||||||||||||||||||||||||
| 80 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 81 | if (bn_wexpand(dest->b, (int)(dest->poly[0] + (8 * 8) - 1) / (8 * 8)) ==
| 0-9858 | ||||||||||||||||||||||||
| 82 |
| 0-9858 | ||||||||||||||||||||||||
| 83 | ((void *)0)
| 0-9858 | ||||||||||||||||||||||||
| 84 | ) | - | ||||||||||||||||||||||||
| 85 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 86 | bn_set_all_zero(dest->a); | - | ||||||||||||||||||||||||
| 87 | bn_set_all_zero(dest->b); | - | ||||||||||||||||||||||||
| 88 | return executed 9858 times by 1 test: 1;return 1;Executed by:
executed 9858 times by 1 test: return 1;Executed by:
| 9858 | ||||||||||||||||||||||||
| 89 | } | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | int ec_GF2m_simple_group_set_curve(EC_GROUP *group, | - | ||||||||||||||||||||||||
| 93 | const BIGNUM *p, const BIGNUM *a, | - | ||||||||||||||||||||||||
| 94 | const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 95 | { | - | ||||||||||||||||||||||||
| 96 | int ret = 0, i; | - | ||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | if (!BN_copy(group->field, p)
| 0-9631 | ||||||||||||||||||||||||
| 100 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 101 | i = BN_GF2m_poly2arr(group->field, group->poly, 6) - 1; | - | ||||||||||||||||||||||||
| 102 | if ((
| 0-5435 | ||||||||||||||||||||||||
| 103 | ERR_put_error(16,(195),(131),__FILE__,106); | - | ||||||||||||||||||||||||
| 104 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 105 | } | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||
| 108 | if (!BN_GF2m_mod_arr(group->a, a, group->poly)
| 0-9631 | ||||||||||||||||||||||||
| 109 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 110 | if (bn_wexpand(group->a, (int)(group->poly[0] + (8 * 8) - 1) / (8 * 8))
| 0-9631 | ||||||||||||||||||||||||
| 111 | ==
| 0-9631 | ||||||||||||||||||||||||
| 112 | ((void *)0)
| 0-9631 | ||||||||||||||||||||||||
| 113 | ) | - | ||||||||||||||||||||||||
| 114 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 115 | bn_set_all_zero(group->a); | - | ||||||||||||||||||||||||
| 116 | - | |||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | if (!BN_GF2m_mod_arr(group->b, b, group->poly)
| 0-9631 | ||||||||||||||||||||||||
| 119 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 120 | if (bn_wexpand(group->b, (int)(group->poly[0] + (8 * 8) - 1) / (8 * 8))
| 0-9631 | ||||||||||||||||||||||||
| 121 | ==
| 0-9631 | ||||||||||||||||||||||||
| 122 | ((void *)0)
| 0-9631 | ||||||||||||||||||||||||
| 123 | ) | - | ||||||||||||||||||||||||
| 124 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 125 | bn_set_all_zero(group->b); | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | ret = 1; | - | ||||||||||||||||||||||||
| 128 | err: code before this statement executed 9631 times by 1 test: err:Executed by:
| 9631 | ||||||||||||||||||||||||
| 129 | return executed 9631 times by 1 test: ret;return ret;Executed by:
executed 9631 times by 1 test: return ret;Executed by:
| 9631 | ||||||||||||||||||||||||
| 130 | } | - | ||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||
| 136 | int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, | - | ||||||||||||||||||||||||
| 137 | BIGNUM *a, BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 138 | { | - | ||||||||||||||||||||||||
| 139 | int ret = 0; | - | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | if (p !=
| 0-2025 | ||||||||||||||||||||||||
| 142 | ((void *)0)
| 0-2025 | ||||||||||||||||||||||||
| 143 | ) { | - | ||||||||||||||||||||||||
| 144 | if (!BN_copy(p, group->field)
| 0-2025 | ||||||||||||||||||||||||
| 145 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 146 | } executed 2025 times by 1 test: end of blockExecuted by:
| 2025 | ||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | if (a !=
| 0-2025 | ||||||||||||||||||||||||
| 149 | ((void *)0)
| 0-2025 | ||||||||||||||||||||||||
| 150 | ) { | - | ||||||||||||||||||||||||
| 151 | if (!BN_copy(a, group->a)
| 0-2025 | ||||||||||||||||||||||||
| 152 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 153 | } executed 2025 times by 1 test: end of blockExecuted by:
| 2025 | ||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||
| 155 | if (b !=
| 0-2025 | ||||||||||||||||||||||||
| 156 | ((void *)0)
| 0-2025 | ||||||||||||||||||||||||
| 157 | ) { | - | ||||||||||||||||||||||||
| 158 | if (!BN_copy(b, group->b)
| 0-2025 | ||||||||||||||||||||||||
| 159 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 160 | } executed 2025 times by 1 test: end of blockExecuted by:
| 2025 | ||||||||||||||||||||||||
| 161 | - | |||||||||||||||||||||||||
| 162 | ret = 1; | - | ||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | err: code before this statement executed 2025 times by 1 test: err:Executed by:
| 2025 | ||||||||||||||||||||||||
| 165 | return executed 2025 times by 1 test: ret;return ret;Executed by:
executed 2025 times by 1 test: return ret;Executed by:
| 2025 | ||||||||||||||||||||||||
| 166 | } | - | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | int ec_GF2m_simple_group_get_degree(const EC_GROUP *group) | - | ||||||||||||||||||||||||
| 173 | { | - | ||||||||||||||||||||||||
| 174 | return executed 9626 times by 1 test: BN_num_bits(group->field) - 1;return BN_num_bits(group->field) - 1;Executed by:
executed 9626 times by 1 test: return BN_num_bits(group->field) - 1;Executed by:
| 9626 | ||||||||||||||||||||||||
| 175 | } | - | ||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||
| 181 | int ec_GF2m_simple_group_check_discriminant(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 182 | BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 183 | { | - | ||||||||||||||||||||||||
| 184 | int ret = 0; | - | ||||||||||||||||||||||||
| 185 | BIGNUM *b; | - | ||||||||||||||||||||||||
| 186 | BN_CTX *new_ctx = | - | ||||||||||||||||||||||||
| 187 | ((void *)0) | - | ||||||||||||||||||||||||
| 188 | ; | - | ||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | if (ctx ==
| 0-122 | ||||||||||||||||||||||||
| 191 | ((void *)0)
| 0-122 | ||||||||||||||||||||||||
| 192 | ) { | - | ||||||||||||||||||||||||
| 193 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 194 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 195 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 196 | ) { | - | ||||||||||||||||||||||||
| 197 | ERR_put_error(16,(159),((1|64)),__FILE__,185) | - | ||||||||||||||||||||||||
| 198 | ; | - | ||||||||||||||||||||||||
| 199 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 200 | } | - | ||||||||||||||||||||||||
| 201 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 202 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
| 203 | b = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 204 | if (b ==
| 0-122 | ||||||||||||||||||||||||
| 205 | ((void *)0)
| 0-122 | ||||||||||||||||||||||||
| 206 | ) | - | ||||||||||||||||||||||||
| 207 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 208 | - | |||||||||||||||||||||||||
| 209 | if (!BN_GF2m_mod_arr(b, group->b, group->poly)
| 0-122 | ||||||||||||||||||||||||
| 210 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | - | |||||||||||||||||||||||||
| 214 | - | |||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||
| 216 | if (BN_is_zero(b)
| 0-122 | ||||||||||||||||||||||||
| 217 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 218 | - | |||||||||||||||||||||||||
| 219 | ret = 1; | - | ||||||||||||||||||||||||
| 220 | - | |||||||||||||||||||||||||
| 221 | err: code before this statement executed 122 times by 1 test: err:Executed by:
| 122 | ||||||||||||||||||||||||
| 222 | if (ctx !=
| 0-122 | ||||||||||||||||||||||||
| 223 | ((void *)0)
| 0-122 | ||||||||||||||||||||||||
| 224 | ) | - | ||||||||||||||||||||||||
| 225 | BN_CTX_end(ctx); executed 122 times by 1 test: BN_CTX_end(ctx);Executed by:
| 122 | ||||||||||||||||||||||||
| 226 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||||||||
| 227 | return executed 122 times by 1 test: ret;return ret;Executed by:
executed 122 times by 1 test: return ret;Executed by:
| 122 | ||||||||||||||||||||||||
| 228 | } | - | ||||||||||||||||||||||||
| 229 | - | |||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||
| 231 | int ec_GF2m_simple_point_init(EC_POINT *point) | - | ||||||||||||||||||||||||
| 232 | { | - | ||||||||||||||||||||||||
| 233 | point->X = BN_new(); | - | ||||||||||||||||||||||||
| 234 | point->Y = BN_new(); | - | ||||||||||||||||||||||||
| 235 | point->Z = BN_new(); | - | ||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||
| 237 | if (point->X ==
| 0-49398 | ||||||||||||||||||||||||
| 238 | ((void *)0)
| 0-49398 | ||||||||||||||||||||||||
| 239 | || point->Y ==
| 0-49398 | ||||||||||||||||||||||||
| 240 | ((void *)0)
| 0-49398 | ||||||||||||||||||||||||
| 241 | || point->Z ==
| 0-49398 | ||||||||||||||||||||||||
| 242 | ((void *)0)
| 0-49398 | ||||||||||||||||||||||||
| 243 | ) { | - | ||||||||||||||||||||||||
| 244 | BN_free(point->X); | - | ||||||||||||||||||||||||
| 245 | BN_free(point->Y); | - | ||||||||||||||||||||||||
| 246 | BN_free(point->Z); | - | ||||||||||||||||||||||||
| 247 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 248 | } | - | ||||||||||||||||||||||||
| 249 | return executed 49398 times by 1 test: 1;return 1;Executed by:
executed 49398 times by 1 test: return 1;Executed by:
| 49398 | ||||||||||||||||||||||||
| 250 | } | - | ||||||||||||||||||||||||
| 251 | - | |||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | void ec_GF2m_simple_point_finish(EC_POINT *point) | - | ||||||||||||||||||||||||
| 254 | { | - | ||||||||||||||||||||||||
| 255 | BN_free(point->X); | - | ||||||||||||||||||||||||
| 256 | BN_free(point->Y); | - | ||||||||||||||||||||||||
| 257 | BN_free(point->Z); | - | ||||||||||||||||||||||||
| 258 | } executed 44814 times by 1 test: end of blockExecuted by:
| 44814 | ||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | - | |||||||||||||||||||||||||
| 261 | void ec_GF2m_simple_point_clear_finish(EC_POINT *point) | - | ||||||||||||||||||||||||
| 262 | { | - | ||||||||||||||||||||||||
| 263 | BN_clear_free(point->X); | - | ||||||||||||||||||||||||
| 264 | BN_clear_free(point->Y); | - | ||||||||||||||||||||||||
| 265 | BN_clear_free(point->Z); | - | ||||||||||||||||||||||||
| 266 | point->Z_is_one = 0; | - | ||||||||||||||||||||||||
| 267 | } executed 4584 times by 1 test: end of blockExecuted by:
| 4584 | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | - | |||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||
| 273 | int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src) | - | ||||||||||||||||||||||||
| 274 | { | - | ||||||||||||||||||||||||
| 275 | if (!BN_copy(dest->X, src->X)
| 0-26238 | ||||||||||||||||||||||||
| 276 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 277 | if (!BN_copy(dest->Y, src->Y)
| 0-26238 | ||||||||||||||||||||||||
| 278 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 279 | if (!BN_copy(dest->Z, src->Z)
| 0-26238 | ||||||||||||||||||||||||
| 280 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 281 | dest->Z_is_one = src->Z_is_one; | - | ||||||||||||||||||||||||
| 282 | dest->curve_name = src->curve_name; | - | ||||||||||||||||||||||||
| 283 | - | |||||||||||||||||||||||||
| 284 | return executed 26238 times by 1 test: 1;return 1;Executed by:
executed 26238 times by 1 test: return 1;Executed by:
| 26238 | ||||||||||||||||||||||||
| 285 | } | - | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 292 | EC_POINT *point) | - | ||||||||||||||||||||||||
| 293 | { | - | ||||||||||||||||||||||||
| 294 | point->Z_is_one = 0; | - | ||||||||||||||||||||||||
| 295 | (BN_set_word((point->Z),0)); | - | ||||||||||||||||||||||||
| 296 | return executed 831 times by 1 test: 1;return 1;Executed by:
executed 831 times by 1 test: return 1;Executed by:
| 831 | ||||||||||||||||||||||||
| 297 | } | - | ||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||
| 303 | int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 304 | EC_POINT *point, | - | ||||||||||||||||||||||||
| 305 | const BIGNUM *x, | - | ||||||||||||||||||||||||
| 306 | const BIGNUM *y, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 307 | { | - | ||||||||||||||||||||||||
| 308 | int ret = 0; | - | ||||||||||||||||||||||||
| 309 | if (x ==
| 0-80606 | ||||||||||||||||||||||||
| 310 | ((void *)0)
| 0-80606 | ||||||||||||||||||||||||
| 311 | || y ==
| 0-80606 | ||||||||||||||||||||||||
| 312 | ((void *)0)
| 0-80606 | ||||||||||||||||||||||||
| 313 | ) { | - | ||||||||||||||||||||||||
| 314 | ERR_put_error(16,(163),((3|64)),__FILE__,288) | - | ||||||||||||||||||||||||
| 315 | ; | - | ||||||||||||||||||||||||
| 316 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | if (!BN_copy(point->X, x)
| 0-80606 | ||||||||||||||||||||||||
| 320 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 321 | BN_set_negative(point->X, 0); | - | ||||||||||||||||||||||||
| 322 | if (!BN_copy(point->Y, y)
| 0-80606 | ||||||||||||||||||||||||
| 323 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 324 | BN_set_negative(point->Y, 0); | - | ||||||||||||||||||||||||
| 325 | if (!BN_copy(point->Z, BN_value_one())
| 0-80606 | ||||||||||||||||||||||||
| 326 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 327 | BN_set_negative(point->Z, 0); | - | ||||||||||||||||||||||||
| 328 | point->Z_is_one = 1; | - | ||||||||||||||||||||||||
| 329 | ret = 1; | - | ||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||
| 331 | err: code before this statement executed 80606 times by 1 test: err:Executed by:
| 80606 | ||||||||||||||||||||||||
| 332 | return executed 80606 times by 1 test: ret;return ret;Executed by:
executed 80606 times by 1 test: return ret;Executed by:
| 80606 | ||||||||||||||||||||||||
| 333 | } | - | ||||||||||||||||||||||||
| 334 | - | |||||||||||||||||||||||||
| 335 | - | |||||||||||||||||||||||||
| 336 | - | |||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||
| 339 | int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 340 | const EC_POINT *point, | - | ||||||||||||||||||||||||
| 341 | BIGNUM *x, BIGNUM *y, | - | ||||||||||||||||||||||||
| 342 | BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 343 | { | - | ||||||||||||||||||||||||
| 344 | int ret = 0; | - | ||||||||||||||||||||||||
| 345 | - | |||||||||||||||||||||||||
| 346 | if (EC_POINT_is_at_infinity(group, point)
| 0-826 | ||||||||||||||||||||||||
| 347 | ERR_put_error(16,(162),(106),__FILE__,321) | - | ||||||||||||||||||||||||
| 348 | ; | - | ||||||||||||||||||||||||
| 349 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 350 | } | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | if (BN_cmp(point->Z, BN_value_one())
| 0-826 | ||||||||||||||||||||||||
| 353 | ERR_put_error(16,(162),((2|64)),__FILE__,327) | - | ||||||||||||||||||||||||
| 354 | ; | - | ||||||||||||||||||||||||
| 355 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 356 | } | - | ||||||||||||||||||||||||
| 357 | if (x !=
| 0-826 | ||||||||||||||||||||||||
| 358 | ((void *)0)
| 0-826 | ||||||||||||||||||||||||
| 359 | ) { | - | ||||||||||||||||||||||||
| 360 | if (!BN_copy(x, point->X)
| 0-826 | ||||||||||||||||||||||||
| 361 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 362 | BN_set_negative(x, 0); | - | ||||||||||||||||||||||||
| 363 | } executed 826 times by 1 test: end of blockExecuted by:
| 826 | ||||||||||||||||||||||||
| 364 | if (y !=
| 100-726 | ||||||||||||||||||||||||
| 365 | ((void *)0)
| 100-726 | ||||||||||||||||||||||||
| 366 | ) { | - | ||||||||||||||||||||||||
| 367 | if (!BN_copy(y, point->Y)
| 0-100 | ||||||||||||||||||||||||
| 368 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 369 | BN_set_negative(y, 0); | - | ||||||||||||||||||||||||
| 370 | } executed 100 times by 1 test: end of blockExecuted by:
| 100 | ||||||||||||||||||||||||
| 371 | ret = 1; | - | ||||||||||||||||||||||||
| 372 | - | |||||||||||||||||||||||||
| 373 | err: code before this statement executed 826 times by 1 test: err:Executed by:
| 826 | ||||||||||||||||||||||||
| 374 | return executed 826 times by 1 test: ret;return ret;Executed by:
executed 826 times by 1 test: return ret;Executed by:
| 826 | ||||||||||||||||||||||||
| 375 | } | - | ||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||
| 377 | - | |||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | - | |||||||||||||||||||||||||
| 380 | - | |||||||||||||||||||||||||
| 381 | int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | - | ||||||||||||||||||||||||
| 382 | const EC_POINT *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 383 | { | - | ||||||||||||||||||||||||
| 384 | BN_CTX *new_ctx = | - | ||||||||||||||||||||||||
| 385 | ((void *)0) | - | ||||||||||||||||||||||||
| 386 | ; | - | ||||||||||||||||||||||||
| 387 | BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t; | - | ||||||||||||||||||||||||
| 388 | int ret = 0; | - | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | if (EC_POINT_is_at_infinity(group, a)
| 3765-85790 | ||||||||||||||||||||||||
| 391 | if (!EC_POINT_copy(r, b)
| 0-3765 | ||||||||||||||||||||||||
| 392 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 393 | return executed 3765 times by 1 test: 1;return 1;Executed by:
executed 3765 times by 1 test: return 1;Executed by:
| 3765 | ||||||||||||||||||||||||
| 394 | } | - | ||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||
| 396 | if (EC_POINT_is_at_infinity(group, b)
| 19856-65934 | ||||||||||||||||||||||||
| 397 | if (!EC_POINT_copy(r, a)
| 0-19856 | ||||||||||||||||||||||||
| 398 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 399 | return executed 19856 times by 1 test: 1;return 1;Executed by:
executed 19856 times by 1 test: return 1;Executed by:
| 19856 | ||||||||||||||||||||||||
| 400 | } | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | if (ctx ==
| 0-65934 | ||||||||||||||||||||||||
| 403 | ((void *)0)
| 0-65934 | ||||||||||||||||||||||||
| 404 | ) { | - | ||||||||||||||||||||||||
| 405 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 406 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 407 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 408 | ) | - | ||||||||||||||||||||||||
| 409 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 410 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 411 | - | |||||||||||||||||||||||||
| 412 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
| 413 | x0 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 414 | y0 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 415 | x1 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 416 | y1 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 417 | x2 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 418 | y2 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 419 | s = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 420 | t = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 421 | if (t ==
| 0-65934 | ||||||||||||||||||||||||
| 422 | ((void *)0)
| 0-65934 | ||||||||||||||||||||||||
| 423 | ) | - | ||||||||||||||||||||||||
| 424 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||
| 426 | if (a->Z_is_one
| 0-65934 | ||||||||||||||||||||||||
| 427 | if (!BN_copy(x0, a->X)
| 0-65934 | ||||||||||||||||||||||||
| 428 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 429 | if (!BN_copy(y0, a->Y)
| 0-65934 | ||||||||||||||||||||||||
| 430 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 431 | } executed 65934 times by 1 test: else {end of blockExecuted by:
| 65934 | ||||||||||||||||||||||||
| 432 | if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx)
| 0 | ||||||||||||||||||||||||
| 433 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 434 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 435 | if (b->Z_is_one
| 0-65934 | ||||||||||||||||||||||||
| 436 | if (!BN_copy(x1, b->X)
| 0-65934 | ||||||||||||||||||||||||
| 437 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 438 | if (!BN_copy(y1, b->Y)
| 0-65934 | ||||||||||||||||||||||||
| 439 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 440 | } executed 65934 times by 1 test: else {end of blockExecuted by:
| 65934 | ||||||||||||||||||||||||
| 441 | if (!EC_POINT_get_affine_coordinates(group, b, x1, y1, ctx)
| 0 | ||||||||||||||||||||||||
| 442 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | if (BN_ucmp((x0), (x1))
| 11764-54170 | ||||||||||||||||||||||||
| 446 | if (!BN_GF2m_add(t, x0, x1)
| 0-11764 | ||||||||||||||||||||||||
| 447 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 448 | if (!BN_GF2m_add(s, y0, y1)
| 0-11764 | ||||||||||||||||||||||||
| 449 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 450 | if (!group->meth->field_div(group, s, s, t, ctx)
| 0-11764 | ||||||||||||||||||||||||
| 451 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 452 | if (!group->meth->field_sqr(group, x2, s, ctx)
| 0-11764 | ||||||||||||||||||||||||
| 453 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 454 | if (!BN_GF2m_add(x2, x2, group->a)
| 0-11764 | ||||||||||||||||||||||||
| 455 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 456 | if (!BN_GF2m_add(x2, x2, s)
| 0-11764 | ||||||||||||||||||||||||
| 457 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 458 | if (!BN_GF2m_add(x2, x2, t)
| 0-11764 | ||||||||||||||||||||||||
| 459 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 460 | } executed 11764 times by 1 test: else {end of blockExecuted by:
| 11764 | ||||||||||||||||||||||||
| 461 | if (BN_ucmp((y0), (y1))
| 0-53885 | ||||||||||||||||||||||||
| 462 | if (!EC_POINT_set_to_infinity(group, r)
| 0-285 | ||||||||||||||||||||||||
| 463 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 464 | ret = 1; | - | ||||||||||||||||||||||||
| 465 | goto executed 285 times by 1 test: err;goto err;Executed by:
executed 285 times by 1 test: goto err;Executed by:
| 285 | ||||||||||||||||||||||||
| 466 | } | - | ||||||||||||||||||||||||
| 467 | if (!group->meth->field_div(group, s, y1, x1, ctx)
| 0-53885 | ||||||||||||||||||||||||
| 468 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 469 | if (!BN_GF2m_add(s, s, x1)
| 0-53885 | ||||||||||||||||||||||||
| 470 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 471 | - | |||||||||||||||||||||||||
| 472 | if (!group->meth->field_sqr(group, x2, s, ctx)
| 0-53885 | ||||||||||||||||||||||||
| 473 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 474 | if (!BN_GF2m_add(x2, x2, s)
| 0-53885 | ||||||||||||||||||||||||
| 475 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 476 | if (!BN_GF2m_add(x2, x2, group->a)
| 0-53885 | ||||||||||||||||||||||||
| 477 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 478 | } executed 53885 times by 1 test: end of blockExecuted by:
| 53885 | ||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||
| 480 | if (!BN_GF2m_add(y2, x1, x2)
| 0-65649 | ||||||||||||||||||||||||
| 481 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 482 | if (!group->meth->field_mul(group, y2, y2, s, ctx)
| 0-65649 | ||||||||||||||||||||||||
| 483 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 484 | if (!BN_GF2m_add(y2, y2, x2)
| 0-65649 | ||||||||||||||||||||||||
| 485 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 486 | if (!BN_GF2m_add(y2, y2, y1)
| 0-65649 | ||||||||||||||||||||||||
| 487 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 488 | - | |||||||||||||||||||||||||
| 489 | if (!EC_POINT_set_affine_coordinates(group, r, x2, y2, ctx)
| 0-65649 | ||||||||||||||||||||||||
| 490 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | ret = 1; | - | ||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||
| 494 | err: code before this statement executed 65649 times by 1 test: err:Executed by:
| 65649 | ||||||||||||||||||||||||
| 495 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||
| 496 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||||||||
| 497 | return executed 65934 times by 1 test: ret;return ret;Executed by:
executed 65934 times by 1 test: return ret;Executed by:
| 65934 | ||||||||||||||||||||||||
| 498 | } | - | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | - | |||||||||||||||||||||||||
| 501 | - | |||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||
| 504 | int ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | - | ||||||||||||||||||||||||
| 505 | BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 506 | { | - | ||||||||||||||||||||||||
| 507 | return executed 55015 times by 1 test: ec_GF2m_simple_add(group, r, a, a, ctx);return ec_GF2m_simple_add(group, r, a, a, ctx);Executed by:
executed 55015 times by 1 test: return ec_GF2m_simple_add(group, r, a, a, ctx);Executed by:
| 55015 | ||||||||||||||||||||||||
| 508 | } | - | ||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||
| 510 | int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 511 | { | - | ||||||||||||||||||||||||
| 512 | if (EC_POINT_is_at_infinity(group, point)
| 0-6230 | ||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | return executed 86 times by 1 test: 1;return 1;Executed by:
executed 86 times by 1 test: return 1;Executed by:
| 86 | ||||||||||||||||||||||||
| 515 | - | |||||||||||||||||||||||||
| 516 | if (!EC_POINT_make_affine(group, point, ctx)
| 0-6230 | ||||||||||||||||||||||||
| 517 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 518 | return executed 6230 times by 1 test: BN_GF2m_add(point->Y, point->X, point->Y);return BN_GF2m_add(point->Y, point->X, point->Y);Executed by:
executed 6230 times by 1 test: return BN_GF2m_add(point->Y, point->X, point->Y);Executed by:
| 6230 | ||||||||||||||||||||||||
| 519 | } | - | ||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | int ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 523 | const EC_POINT *point) | - | ||||||||||||||||||||||||
| 524 | { | - | ||||||||||||||||||||||||
| 525 | return executed 273149 times by 1 test: BN_is_zero(point->Z);return BN_is_zero(point->Z);Executed by:
executed 273149 times by 1 test: return BN_is_zero(point->Z);Executed by:
| 273149 | ||||||||||||||||||||||||
| 526 | } | - | ||||||||||||||||||||||||
| 527 | - | |||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||
| 531 | - | |||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| 533 | int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, | - | ||||||||||||||||||||||||
| 534 | BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 535 | { | - | ||||||||||||||||||||||||
| 536 | int ret = -1; | - | ||||||||||||||||||||||||
| 537 | BN_CTX *new_ctx = | - | ||||||||||||||||||||||||
| 538 | ((void *)0) | - | ||||||||||||||||||||||||
| 539 | ; | - | ||||||||||||||||||||||||
| 540 | BIGNUM *lh, *y2; | - | ||||||||||||||||||||||||
| 541 | int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, | - | ||||||||||||||||||||||||
| 542 | const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||||||||
| 543 | int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); | - | ||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | if (EC_POINT_is_at_infinity(group, point)
| 0-80774 | ||||||||||||||||||||||||
| 546 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||
| 548 | field_mul = group->meth->field_mul; | - | ||||||||||||||||||||||||
| 549 | field_sqr = group->meth->field_sqr; | - | ||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | - | |||||||||||||||||||||||||
| 552 | if (!point->Z_is_one
| 0-80774 | ||||||||||||||||||||||||
| 553 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | if (ctx ==
| 0-80774 | ||||||||||||||||||||||||
| 556 | ((void *)0)
| 0-80774 | ||||||||||||||||||||||||
| 557 | ) { | - | ||||||||||||||||||||||||
| 558 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 559 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 560 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 561 | ) | - | ||||||||||||||||||||||||
| 562 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 563 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||
| 565 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
| 566 | y2 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 567 | lh = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 568 | if (lh ==
| 0-80774 | ||||||||||||||||||||||||
| 569 | ((void *)0)
| 0-80774 | ||||||||||||||||||||||||
| 570 | ) | - | ||||||||||||||||||||||||
| 571 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 572 | - | |||||||||||||||||||||||||
| 573 | - | |||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | - | |||||||||||||||||||||||||
| 577 | - | |||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||
| 579 | if (!BN_GF2m_add(lh, point->X, group->a)
| 0-80774 | ||||||||||||||||||||||||
| 580 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 581 | if (!field_mul(group, lh, lh, point->X, ctx)
| 0-80774 | ||||||||||||||||||||||||
| 582 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 583 | if (!BN_GF2m_add(lh, lh, point->Y)
| 0-80774 | ||||||||||||||||||||||||
| 584 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 585 | if (!field_mul(group, lh, lh, point->X, ctx)
| 0-80774 | ||||||||||||||||||||||||
| 586 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 587 | if (!BN_GF2m_add(lh, lh, group->b)
| 0-80774 | ||||||||||||||||||||||||
| 588 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 589 | if (!field_sqr(group, y2, point->Y, ctx)
| 0-80774 | ||||||||||||||||||||||||
| 590 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 591 | if (!BN_GF2m_add(lh, lh, y2)
| 0-80774 | ||||||||||||||||||||||||
| 592 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 593 | ret = BN_is_zero(lh); | - | ||||||||||||||||||||||||
| 594 | - | |||||||||||||||||||||||||
| 595 | err: code before this statement executed 80774 times by 1 test: err:Executed by:
| 80774 | ||||||||||||||||||||||||
| 596 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||
| 597 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||||||||
| 598 | return executed 80774 times by 1 test: ret;return ret;Executed by:
executed 80774 times by 1 test: return ret;Executed by:
| 80774 | ||||||||||||||||||||||||
| 599 | } | - | ||||||||||||||||||||||||
| 600 | int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, | - | ||||||||||||||||||||||||
| 601 | const EC_POINT *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 602 | { | - | ||||||||||||||||||||||||
| 603 | BIGNUM *aX, *aY, *bX, *bY; | - | ||||||||||||||||||||||||
| 604 | BN_CTX *new_ctx = | - | ||||||||||||||||||||||||
| 605 | ((void *)0) | - | ||||||||||||||||||||||||
| 606 | ; | - | ||||||||||||||||||||||||
| 607 | int ret = -1; | - | ||||||||||||||||||||||||
| 608 | - | |||||||||||||||||||||||||
| 609 | if (EC_POINT_is_at_infinity(group, a)
| 0-2033 | ||||||||||||||||||||||||
| 610 | return never executed: EC_POINT_is_at_infinity(group, b)return EC_POINT_is_at_infinity(group, b) ? 0 : 1;
never executed: return EC_POINT_is_at_infinity(group, b) ? 0 : 1; | 0 | ||||||||||||||||||||||||
| 611 | } | - | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | if (EC_POINT_is_at_infinity(group, b)
| 0-2033 | ||||||||||||||||||||||||
| 614 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||
| 615 | - | |||||||||||||||||||||||||
| 616 | if (a->Z_is_one
| 0-2033 | ||||||||||||||||||||||||
| 617 | return executed 2033 times by 1 test: ((return ((BN_cmp(a->X, b->X) == 0) && BN_cmp(a->Y, b->Y) == 0) ? 0 : 1;Executed by:
executed 2033 times by 1 test: return ((BN_cmp(a->X, b->X) == 0) && BN_cmp(a->Y, b->Y) == 0) ? 0 : 1;Executed by:
| 0-2033 | ||||||||||||||||||||||||
| 618 | } | - | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 621 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 622 | ) { | - | ||||||||||||||||||||||||
| 623 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 624 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 625 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 626 | ) | - | ||||||||||||||||||||||||
| 627 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 628 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 629 | - | |||||||||||||||||||||||||
| 630 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
| 631 | aX = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 632 | aY = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 633 | bX = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 634 | bY = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 635 | if (bY ==
| 0 | ||||||||||||||||||||||||
| 636 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 637 | ) | - | ||||||||||||||||||||||||
| 638 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | if (!EC_POINT_get_affine_coordinates(group, a, aX, aY, ctx)
| 0 | ||||||||||||||||||||||||
| 641 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 642 | if (!EC_POINT_get_affine_coordinates(group, b, bX, bY, ctx)
| 0 | ||||||||||||||||||||||||
| 643 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 644 | ret = ((
| 0 | ||||||||||||||||||||||||
| 645 | - | |||||||||||||||||||||||||
| 646 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
| 647 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||
| 648 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||||||||
| 649 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 650 | } | - | ||||||||||||||||||||||||
| 651 | - | |||||||||||||||||||||||||
| 652 | - | |||||||||||||||||||||||||
| 653 | int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, | - | ||||||||||||||||||||||||
| 654 | BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 655 | { | - | ||||||||||||||||||||||||
| 656 | BN_CTX *new_ctx = | - | ||||||||||||||||||||||||
| 657 | ((void *)0) | - | ||||||||||||||||||||||||
| 658 | ; | - | ||||||||||||||||||||||||
| 659 | BIGNUM *x, *y; | - | ||||||||||||||||||||||||
| 660 | int ret = 0; | - | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | if (point->Z_is_one
| 0-7950 | ||||||||||||||||||||||||
| 663 | return executed 10814 times by 1 test: 1;return 1;Executed by:
executed 10814 times by 1 test: return 1;Executed by:
| 10814 | ||||||||||||||||||||||||
| 664 | - | |||||||||||||||||||||||||
| 665 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 666 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 667 | ) { | - | ||||||||||||||||||||||||
| 668 | ctx = new_ctx = BN_CTX_new(); | - | ||||||||||||||||||||||||
| 669 | if (ctx ==
| 0 | ||||||||||||||||||||||||
| 670 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 671 | ) | - | ||||||||||||||||||||||||
| 672 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 673 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 674 | - | |||||||||||||||||||||||||
| 675 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
| 676 | x = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 677 | y = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 678 | if (y ==
| 0 | ||||||||||||||||||||||||
| 679 | ((void *)0)
| 0 | ||||||||||||||||||||||||
| 680 | ) | - | ||||||||||||||||||||||||
| 681 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 682 | - | |||||||||||||||||||||||||
| 683 | if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)
| 0 | ||||||||||||||||||||||||
| 684 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 685 | if (!BN_copy(point->X, x)
| 0 | ||||||||||||||||||||||||
| 686 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 687 | if (!BN_copy(point->Y, y)
| 0 | ||||||||||||||||||||||||
| 688 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 689 | if (!(BN_set_word((point->Z),1))
| 0 | ||||||||||||||||||||||||
| 690 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 691 | point->Z_is_one = 1; | - | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | ret = 1; | - | ||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||
| 695 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
| 696 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||
| 697 | BN_CTX_free(new_ctx); | - | ||||||||||||||||||||||||
| 698 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||||||||
| 699 | } | - | ||||||||||||||||||||||||
| 700 | - | |||||||||||||||||||||||||
| 701 | - | |||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | - | |||||||||||||||||||||||||
| 704 | int ec_GF2m_simple_points_make_affine(const EC_GROUP *group, size_t num, | - | ||||||||||||||||||||||||
| 705 | EC_POINT *points[], BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 706 | { | - | ||||||||||||||||||||||||
| 707 | size_t i; | - | ||||||||||||||||||||||||
| 708 | - | |||||||||||||||||||||||||
| 709 | for (i = 0; i < num
| 212-4584 | ||||||||||||||||||||||||
| 710 | if (!group->meth->make_affine(group, points[i], ctx)
| 0-4584 | ||||||||||||||||||||||||
| 711 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 712 | } executed 4584 times by 1 test: end of blockExecuted by:
| 4584 | ||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||
| 714 | return executed 212 times by 1 test: 1;return 1;Executed by:
executed 212 times by 1 test: return 1;Executed by:
| 212 | ||||||||||||||||||||||||
| 715 | } | - | ||||||||||||||||||||||||
| 716 | - | |||||||||||||||||||||||||
| 717 | - | |||||||||||||||||||||||||
| 718 | int ec_GF2m_simple_field_mul(const EC_GROUP *group, BIGNUM *r, | - | ||||||||||||||||||||||||
| 719 | const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 720 | { | - | ||||||||||||||||||||||||
| 721 | return executed 3593851 times by 1 test: BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx);return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx);Executed by:
executed 3593851 times by 1 test: return BN_GF2m_mod_mul_arr(r, a, b, group->poly, ctx);Executed by:
| 3593851 | ||||||||||||||||||||||||
| 722 | } | - | ||||||||||||||||||||||||
| 723 | - | |||||||||||||||||||||||||
| 724 | - | |||||||||||||||||||||||||
| 725 | int ec_GF2m_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, | - | ||||||||||||||||||||||||
| 726 | const BIGNUM *a, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 727 | { | - | ||||||||||||||||||||||||
| 728 | return executed 2941761 times by 1 test: BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx);return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx);Executed by:
executed 2941761 times by 1 test: return BN_GF2m_mod_sqr_arr(r, a, group->poly, ctx);Executed by:
| 2941761 | ||||||||||||||||||||||||
| 729 | } | - | ||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | - | |||||||||||||||||||||||||
| 732 | int ec_GF2m_simple_field_div(const EC_GROUP *group, BIGNUM *r, | - | ||||||||||||||||||||||||
| 733 | const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 734 | { | - | ||||||||||||||||||||||||
| 735 | return executed 71165 times by 1 test: BN_GF2m_mod_div(r, a, b, group->field, ctx);return BN_GF2m_mod_div(r, a, b, group->field, ctx);Executed by:
executed 71165 times by 1 test: return BN_GF2m_mod_div(r, a, b, group->field, ctx);Executed by:
| 71165 | ||||||||||||||||||||||||
| 736 | } | - | ||||||||||||||||||||||||
| 737 | - | |||||||||||||||||||||||||
| 738 | - | |||||||||||||||||||||||||
| 739 | - | |||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||
| 744 | static | - | ||||||||||||||||||||||||
| 745 | int ec_GF2m_simple_ladder_pre(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 746 | EC_POINT *r, EC_POINT *s, | - | ||||||||||||||||||||||||
| 747 | EC_POINT *p, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 748 | { | - | ||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||
| 750 | if (p->Z_is_one == 0
| 0-2126 | ||||||||||||||||||||||||
| 751 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | do { | - | ||||||||||||||||||||||||
| 755 | if (!BN_priv_rand(s->Z, BN_num_bits(group->field) - 1,
| 0-2126 | ||||||||||||||||||||||||
| 756 | -1, 0)
| 0-2126 | ||||||||||||||||||||||||
| 757 | ERR_put_error(16,(288),(3),__FILE__,702); | - | ||||||||||||||||||||||||
| 758 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 759 | } | - | ||||||||||||||||||||||||
| 760 | } executed 2126 times by 1 test: while (BN_is_zero(s->Z)end of blockExecuted by:
| 0-2126 | ||||||||||||||||||||||||
| 761 | - | |||||||||||||||||||||||||
| 762 | - | |||||||||||||||||||||||||
| 763 | if ((group->meth->field_encode !=
| 0-2126 | ||||||||||||||||||||||||
| 764 | ((void *)0)
| 0-2126 | ||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||
| 766 | && !group->meth->field_encode(group, s->Z, s->Z, ctx)
| 0 | ||||||||||||||||||||||||
| 767 | || !group->meth->field_mul(group, s->X, p->X, s->Z, ctx)
| 0-2126 | ||||||||||||||||||||||||
| 768 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||
| 771 | do { | - | ||||||||||||||||||||||||
| 772 | if (!BN_priv_rand(r->Y, BN_num_bits(group->field) - 1,
| 0-2126 | ||||||||||||||||||||||||
| 773 | -1, 0)
| 0-2126 | ||||||||||||||||||||||||
| 774 | ERR_put_error(16,(288),(3),__FILE__,717); | - | ||||||||||||||||||||||||
| 775 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 776 | } | - | ||||||||||||||||||||||||
| 777 | } executed 2126 times by 1 test: while (BN_is_zero(r->Y)end of blockExecuted by:
| 0-2126 | ||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||
| 779 | if ((group->meth->field_encode !=
| 0-2126 | ||||||||||||||||||||||||
| 780 | ((void *)0)
| 0-2126 | ||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | && !group->meth->field_encode(group, r->Y, r->Y, ctx)
| 0 | ||||||||||||||||||||||||
| 783 | || !group->meth->field_sqr(group, r->Z, p->X, ctx)
| 0-2126 | ||||||||||||||||||||||||
| 784 | || !group->meth->field_sqr(group, r->X, r->Z, ctx)
| 0-2126 | ||||||||||||||||||||||||
| 785 | || !BN_GF2m_add(r->X, r->X, group->b)
| 0-2126 | ||||||||||||||||||||||||
| 786 | || !group->meth->field_mul(group, r->Z, r->Z, r->Y, ctx)
| 0-2126 | ||||||||||||||||||||||||
| 787 | || !group->meth->field_mul(group, r->X, r->X, r->Y, ctx)
| 0-2126 | ||||||||||||||||||||||||
| 788 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 789 | - | |||||||||||||||||||||||||
| 790 | s->Z_is_one = 0; | - | ||||||||||||||||||||||||
| 791 | r->Z_is_one = 0; | - | ||||||||||||||||||||||||
| 792 | - | |||||||||||||||||||||||||
| 793 | return executed 2126 times by 1 test: 1;return 1;Executed by:
executed 2126 times by 1 test: return 1;Executed by:
| 2126 | ||||||||||||||||||||||||
| 794 | } | - | ||||||||||||||||||||||||
| 795 | - | |||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||
| 798 | - | |||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||
| 800 | - | |||||||||||||||||||||||||
| 801 | static | - | ||||||||||||||||||||||||
| 802 | int ec_GF2m_simple_ladder_step(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 803 | EC_POINT *r, EC_POINT *s, | - | ||||||||||||||||||||||||
| 804 | EC_POINT *p, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 805 | { | - | ||||||||||||||||||||||||
| 806 | if (!group->meth->field_mul(group, r->Y, r->Z, s->X, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 807 | || !group->meth->field_mul(group, s->X, r->X, s->Z, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 808 | || !group->meth->field_sqr(group, s->Y, r->Z, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 809 | || !group->meth->field_sqr(group, r->Z, r->X, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 810 | || !BN_GF2m_add(s->Z, r->Y, s->X)
| 0-556906 | ||||||||||||||||||||||||
| 811 | || !group->meth->field_sqr(group, s->Z, s->Z, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 812 | || !group->meth->field_mul(group, s->X, r->Y, s->X, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 813 | || !group->meth->field_mul(group, r->Y, s->Z, p->X, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 814 | || !BN_GF2m_add(s->X, s->X, r->Y)
| 0-556906 | ||||||||||||||||||||||||
| 815 | || !group->meth->field_sqr(group, r->Y, r->Z, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 816 | || !group->meth->field_mul(group, r->Z, r->Z, s->Y, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 817 | || !group->meth->field_sqr(group, s->Y, s->Y, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 818 | || !group->meth->field_mul(group, s->Y, s->Y, group->b, ctx)
| 0-556906 | ||||||||||||||||||||||||
| 819 | || !BN_GF2m_add(r->X, r->Y, s->Y)
| 0-556906 | ||||||||||||||||||||||||
| 820 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 821 | - | |||||||||||||||||||||||||
| 822 | return executed 556906 times by 1 test: 1;return 1;Executed by:
executed 556906 times by 1 test: return 1;Executed by:
| 556906 | ||||||||||||||||||||||||
| 823 | } | - | ||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||
| 826 | - | |||||||||||||||||||||||||
| 827 | - | |||||||||||||||||||||||||
| 828 | - | |||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | static | - | ||||||||||||||||||||||||
| 832 | int ec_GF2m_simple_ladder_post(const EC_GROUP *group, | - | ||||||||||||||||||||||||
| 833 | EC_POINT *r, EC_POINT *s, | - | ||||||||||||||||||||||||
| 834 | EC_POINT *p, BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 835 | { | - | ||||||||||||||||||||||||
| 836 | int ret = 0; | - | ||||||||||||||||||||||||
| 837 | BIGNUM *t0, *t1, *t2 = | - | ||||||||||||||||||||||||
| 838 | ((void *)0) | - | ||||||||||||||||||||||||
| 839 | ; | - | ||||||||||||||||||||||||
| 840 | - | |||||||||||||||||||||||||
| 841 | if (BN_is_zero(r->Z)
| 348-1778 | ||||||||||||||||||||||||
| 842 | return executed 348 times by 1 test: EC_POINT_set_to_infinity(group, r);return EC_POINT_set_to_infinity(group, r);Executed by:
executed 348 times by 1 test: return EC_POINT_set_to_infinity(group, r);Executed by:
| 348 | ||||||||||||||||||||||||
| 843 | - | |||||||||||||||||||||||||
| 844 | if (BN_is_zero(s->Z)
| 156-1622 | ||||||||||||||||||||||||
| 845 | if (!EC_POINT_copy(r, p)
| 0-156 | ||||||||||||||||||||||||
| 846 | || !EC_POINT_invert(group, r, ctx)
| 0-156 | ||||||||||||||||||||||||
| 847 | ERR_put_error(16,(285),(16),__FILE__,786); | - | ||||||||||||||||||||||||
| 848 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 849 | } | - | ||||||||||||||||||||||||
| 850 | return executed 156 times by 1 test: 1;return 1;Executed by:
executed 156 times by 1 test: return 1;Executed by:
| 156 | ||||||||||||||||||||||||
| 851 | } | - | ||||||||||||||||||||||||
| 852 | - | |||||||||||||||||||||||||
| 853 | BN_CTX_start(ctx); | - | ||||||||||||||||||||||||
| 854 | t0 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 855 | t1 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 856 | t2 = BN_CTX_get(ctx); | - | ||||||||||||||||||||||||
| 857 | if (t2 ==
| 0-1622 | ||||||||||||||||||||||||
| 858 | ((void *)0)
| 0-1622 | ||||||||||||||||||||||||
| 859 | ) { | - | ||||||||||||||||||||||||
| 860 | ERR_put_error(16,(285),((1|64)),__FILE__,797); | - | ||||||||||||||||||||||||
| 861 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 862 | } | - | ||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | if (!group->meth->field_mul(group, t0, r->Z, s->Z, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 865 | || !group->meth->field_mul(group, t1, p->X, r->Z, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 866 | || !BN_GF2m_add(t1, r->X, t1)
| 0-1622 | ||||||||||||||||||||||||
| 867 | || !group->meth->field_mul(group, t2, p->X, s->Z, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 868 | || !group->meth->field_mul(group, r->Z, r->X, t2, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 869 | || !BN_GF2m_add(t2, t2, s->X)
| 0-1622 | ||||||||||||||||||||||||
| 870 | || !group->meth->field_mul(group, t1, t1, t2, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 871 | || !group->meth->field_sqr(group, t2, p->X, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 872 | || !BN_GF2m_add(t2, p->Y, t2)
| 0-1622 | ||||||||||||||||||||||||
| 873 | || !group->meth->field_mul(group, t2, t2, t0, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 874 | || !BN_GF2m_add(t1, t2, t1)
| 0-1622 | ||||||||||||||||||||||||
| 875 | || !group->meth->field_mul(group, t2, p->X, t0, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 876 | || !BN_GF2m_mod_inv(t2, t2, group->field, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 877 | || !group->meth->field_mul(group, t1, t1, t2, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 878 | || !group->meth->field_mul(group, r->X, r->Z, t2, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 879 | || !BN_GF2m_add(t2, p->X, r->X)
| 0-1622 | ||||||||||||||||||||||||
| 880 | || !group->meth->field_mul(group, t2, t2, t1, ctx)
| 0-1622 | ||||||||||||||||||||||||
| 881 | || !BN_GF2m_add(r->Y, p->Y, t2)
| 0-1622 | ||||||||||||||||||||||||
| 882 | || !(BN_set_word((r->Z),1))
| 0-1622 | ||||||||||||||||||||||||
| 883 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 884 | - | |||||||||||||||||||||||||
| 885 | r->Z_is_one = 1; | - | ||||||||||||||||||||||||
| 886 | - | |||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||
| 888 | BN_set_negative(r->X, 0); | - | ||||||||||||||||||||||||
| 889 | BN_set_negative(r->Y, 0); | - | ||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||
| 891 | ret = 1; | - | ||||||||||||||||||||||||
| 892 | - | |||||||||||||||||||||||||
| 893 | err: code before this statement executed 1622 times by 1 test: err:Executed by:
| 1622 | ||||||||||||||||||||||||
| 894 | BN_CTX_end(ctx); | - | ||||||||||||||||||||||||
| 895 | return executed 1622 times by 1 test: ret;return ret;Executed by:
executed 1622 times by 1 test: return ret;Executed by:
| 1622 | ||||||||||||||||||||||||
| 896 | } | - | ||||||||||||||||||||||||
| 897 | - | |||||||||||||||||||||||||
| 898 | static | - | ||||||||||||||||||||||||
| 899 | int ec_GF2m_simple_points_mul(const EC_GROUP *group, EC_POINT *r, | - | ||||||||||||||||||||||||
| 900 | const BIGNUM *scalar, size_t num, | - | ||||||||||||||||||||||||
| 901 | const EC_POINT *points[], | - | ||||||||||||||||||||||||
| 902 | const BIGNUM *scalars[], | - | ||||||||||||||||||||||||
| 903 | BN_CTX *ctx) | - | ||||||||||||||||||||||||
| 904 | { | - | ||||||||||||||||||||||||
| 905 | int ret = 0; | - | ||||||||||||||||||||||||
| 906 | EC_POINT *t = | - | ||||||||||||||||||||||||
| 907 | ((void *)0) | - | ||||||||||||||||||||||||
| 908 | ; | - | ||||||||||||||||||||||||
| 909 | if (num > 1
| 0-1956 | ||||||||||||||||||||||||
| 910 | return executed 212 times by 1 test: ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);Executed by:
executed 212 times by 1 test: return ec_wNAF_mul(group, r, scalar, num, points, scalars, ctx);Executed by:
| 212 | ||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||
| 912 | if (scalar !=
| 905-1051 | ||||||||||||||||||||||||
| 913 | ((void *)0)
| 905-1051 | ||||||||||||||||||||||||
| 914 | && num == 0
| 170-735 | ||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||
| 916 | return executed 735 times by 1 test: ec_scalar_mul_ladder(group, r, scalar, return ec_scalar_mul_ladder(group, r, scalar, ((void *)0) , ctx);Executed by:
executed 735 times by 1 test: return ec_scalar_mul_ladder(group, r, scalar, ((void *)0) , ctx);Executed by:
| 735 | ||||||||||||||||||||||||
| 917 | ((void *)0) executed 735 times by 1 test: return ec_scalar_mul_ladder(group, r, scalar, ((void *)0) , ctx);Executed by:
| 735 | ||||||||||||||||||||||||
| 918 | , ctx); executed 735 times by 1 test: return ec_scalar_mul_ladder(group, r, scalar, ((void *)0) , ctx);Executed by:
| 735 | ||||||||||||||||||||||||
| 919 | - | |||||||||||||||||||||||||
| 920 | if (scalar ==
| 170-1051 | ||||||||||||||||||||||||
| 921 | ((void *)0)
| 170-1051 | ||||||||||||||||||||||||
| 922 | && num == 1
| 0-1051 | ||||||||||||||||||||||||
| 923 | - | |||||||||||||||||||||||||
| 924 | return executed 1051 times by 1 test: ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx);return ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx);Executed by:
executed 1051 times by 1 test: return ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx);Executed by:
| 1051 | ||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||
| 926 | - | |||||||||||||||||||||||||
| 927 | - | |||||||||||||||||||||||||
| 928 | - | |||||||||||||||||||||||||
| 929 | - | |||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||
| 931 | if ((
| 0-170 | ||||||||||||||||||||||||
| 932 | ((void *)0)
| 0-170 | ||||||||||||||||||||||||
| 933 | ) { | - | ||||||||||||||||||||||||
| 934 | ERR_put_error(16,(289),((1|64)),__FILE__,876); | - | ||||||||||||||||||||||||
| 935 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 936 | } | - | ||||||||||||||||||||||||
| 937 | - | |||||||||||||||||||||||||
| 938 | if (!ec_scalar_mul_ladder(group, t, scalar,
| 0-170 | ||||||||||||||||||||||||
| 939 | ((void *)0)
| 0-170 | ||||||||||||||||||||||||
| 940 | , ctx)
| 0-170 | ||||||||||||||||||||||||
| 941 | || !ec_scalar_mul_ladder(group, r, scalars[0], points[0], ctx)
| 0-170 | ||||||||||||||||||||||||
| 942 | || !EC_POINT_add(group, r, t, r, ctx)
| 0-170 | ||||||||||||||||||||||||
| 943 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 944 | - | |||||||||||||||||||||||||
| 945 | ret = 1; | - | ||||||||||||||||||||||||
| 946 | - | |||||||||||||||||||||||||
| 947 | err: code before this statement executed 170 times by 1 test: err:Executed by:
| 170 | ||||||||||||||||||||||||
| 948 | EC_POINT_free(t); | - | ||||||||||||||||||||||||
| 949 | return executed 170 times by 1 test: ret;return ret;Executed by:
executed 170 times by 1 test: return ret;Executed by:
| 170 | ||||||||||||||||||||||||
| 950 | } | - | ||||||||||||||||||||||||
| 951 | - | |||||||||||||||||||||||||
| 952 | const EC_METHOD *EC_GF2m_simple_method(void) | - | ||||||||||||||||||||||||
| 953 | { | - | ||||||||||||||||||||||||
| 954 | static const EC_METHOD ret = { | - | ||||||||||||||||||||||||
| 955 | 0x1, | - | ||||||||||||||||||||||||
| 956 | 407, | - | ||||||||||||||||||||||||
| 957 | ec_GF2m_simple_group_init, | - | ||||||||||||||||||||||||
| 958 | ec_GF2m_simple_group_finish, | - | ||||||||||||||||||||||||
| 959 | ec_GF2m_simple_group_clear_finish, | - | ||||||||||||||||||||||||
| 960 | ec_GF2m_simple_group_copy, | - | ||||||||||||||||||||||||
| 961 | ec_GF2m_simple_group_set_curve, | - | ||||||||||||||||||||||||
| 962 | ec_GF2m_simple_group_get_curve, | - | ||||||||||||||||||||||||
| 963 | ec_GF2m_simple_group_get_degree, | - | ||||||||||||||||||||||||
| 964 | ec_group_simple_order_bits, | - | ||||||||||||||||||||||||
| 965 | ec_GF2m_simple_group_check_discriminant, | - | ||||||||||||||||||||||||
| 966 | ec_GF2m_simple_point_init, | - | ||||||||||||||||||||||||
| 967 | ec_GF2m_simple_point_finish, | - | ||||||||||||||||||||||||
| 968 | ec_GF2m_simple_point_clear_finish, | - | ||||||||||||||||||||||||
| 969 | ec_GF2m_simple_point_copy, | - | ||||||||||||||||||||||||
| 970 | ec_GF2m_simple_point_set_to_infinity, | - | ||||||||||||||||||||||||
| 971 | 0, | - | ||||||||||||||||||||||||
| 972 | 0, | - | ||||||||||||||||||||||||
| 973 | ec_GF2m_simple_point_set_affine_coordinates, | - | ||||||||||||||||||||||||
| 974 | ec_GF2m_simple_point_get_affine_coordinates, | - | ||||||||||||||||||||||||
| 975 | 0, | - | ||||||||||||||||||||||||
| 976 | 0, | - | ||||||||||||||||||||||||
| 977 | 0, | - | ||||||||||||||||||||||||
| 978 | ec_GF2m_simple_add, | - | ||||||||||||||||||||||||
| 979 | ec_GF2m_simple_dbl, | - | ||||||||||||||||||||||||
| 980 | ec_GF2m_simple_invert, | - | ||||||||||||||||||||||||
| 981 | ec_GF2m_simple_is_at_infinity, | - | ||||||||||||||||||||||||
| 982 | ec_GF2m_simple_is_on_curve, | - | ||||||||||||||||||||||||
| 983 | ec_GF2m_simple_cmp, | - | ||||||||||||||||||||||||
| 984 | ec_GF2m_simple_make_affine, | - | ||||||||||||||||||||||||
| 985 | ec_GF2m_simple_points_make_affine, | - | ||||||||||||||||||||||||
| 986 | ec_GF2m_simple_points_mul, | - | ||||||||||||||||||||||||
| 987 | 0, | - | ||||||||||||||||||||||||
| 988 | 0, | - | ||||||||||||||||||||||||
| 989 | ec_GF2m_simple_field_mul, | - | ||||||||||||||||||||||||
| 990 | ec_GF2m_simple_field_sqr, | - | ||||||||||||||||||||||||
| 991 | ec_GF2m_simple_field_div, | - | ||||||||||||||||||||||||
| 992 | 0, | - | ||||||||||||||||||||||||
| 993 | 0, | - | ||||||||||||||||||||||||
| 994 | 0, | - | ||||||||||||||||||||||||
| 995 | ec_key_simple_priv2oct, | - | ||||||||||||||||||||||||
| 996 | ec_key_simple_oct2priv, | - | ||||||||||||||||||||||||
| 997 | 0, | - | ||||||||||||||||||||||||
| 998 | ec_key_simple_generate_key, | - | ||||||||||||||||||||||||
| 999 | ec_key_simple_check_key, | - | ||||||||||||||||||||||||
| 1000 | ec_key_simple_generate_public_key, | - | ||||||||||||||||||||||||
| 1001 | 0, | - | ||||||||||||||||||||||||
| 1002 | 0, | - | ||||||||||||||||||||||||
| 1003 | ecdh_simple_compute_key, | - | ||||||||||||||||||||||||
| 1004 | 0, | - | ||||||||||||||||||||||||
| 1005 | 0, | - | ||||||||||||||||||||||||
| 1006 | ec_GF2m_simple_ladder_pre, | - | ||||||||||||||||||||||||
| 1007 | ec_GF2m_simple_ladder_step, | - | ||||||||||||||||||||||||
| 1008 | ec_GF2m_simple_ladder_post | - | ||||||||||||||||||||||||
| 1009 | }; | - | ||||||||||||||||||||||||
| 1010 | - | |||||||||||||||||||||||||
| 1011 | return executed 9631 times by 1 test: &ret;return &ret;Executed by:
executed 9631 times by 1 test: return &ret;Executed by:
| 9631 | ||||||||||||||||||||||||
| 1012 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |