OLD | NEW |
1 /* crypto/ec/ec_key.c */ | 1 /* crypto/ec/ec_key.c */ |
2 /* | 2 /* |
3 * Written by Nils Larsch for the OpenSSL project. | 3 * Written by Nils Larsch for the OpenSSL project. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 int ok = 0; | 297 int ok = 0; |
298 BN_CTX *ctx = NULL; | 298 BN_CTX *ctx = NULL; |
299 const BIGNUM *order = NULL; | 299 const BIGNUM *order = NULL; |
300 EC_POINT *point = NULL; | 300 EC_POINT *point = NULL; |
301 | 301 |
302 if (!eckey || !eckey->group || !eckey->pub_key) | 302 if (!eckey || !eckey->group || !eckey->pub_key) |
303 { | 303 { |
304 ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); | 304 ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); |
305 return 0; | 305 return 0; |
306 } | 306 } |
307 » | 307 |
| 308 » if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) |
| 309 » » { |
| 310 » » ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY); |
| 311 » » goto err; |
| 312 » » } |
| 313 |
308 if ((ctx = BN_CTX_new()) == NULL) | 314 if ((ctx = BN_CTX_new()) == NULL) |
309 goto err; | 315 goto err; |
310 if ((point = EC_POINT_new(eckey->group)) == NULL) | 316 if ((point = EC_POINT_new(eckey->group)) == NULL) |
311 goto err; | 317 goto err; |
312 | 318 |
313 /* testing whether the pub_key is on the elliptic curve */ | 319 /* testing whether the pub_key is on the elliptic curve */ |
314 if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx)) | 320 if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx)) |
315 { | 321 { |
316 ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE); | 322 ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE); |
317 goto err; | 323 goto err; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 if (key->group != NULL) | 454 if (key->group != NULL) |
449 EC_GROUP_set_asn1_flag(key->group, flag); | 455 EC_GROUP_set_asn1_flag(key->group, flag); |
450 } | 456 } |
451 | 457 |
452 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx) | 458 int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx) |
453 { | 459 { |
454 if (key->group == NULL) | 460 if (key->group == NULL) |
455 return 0; | 461 return 0; |
456 return EC_GROUP_precompute_mult(key->group, ctx); | 462 return EC_GROUP_precompute_mult(key->group, ctx); |
457 } | 463 } |
OLD | NEW |