diff options
Diffstat (limited to 'src/lib/libcrypto/ec/ec_asn1.c')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index ef87b599f2..c54f6593d5 100644 --- a/src/lib/libcrypto/ec/ec_asn1.c +++ b/src/lib/libcrypto/ec/ec_asn1.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_asn1.c,v 1.9 2014/07/10 22:45:57 jsing Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.10 2014/07/12 16:03:37 miod Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -404,8 +404,8 @@ ec_asn1_group2fieldid(const EC_GROUP * group, X9_62_FIELDID * field) | |||
| 404 | 404 | ||
| 405 | ok = 1; | 405 | ok = 1; |
| 406 | 406 | ||
| 407 | err: if (tmp) | 407 | err: |
| 408 | BN_free(tmp); | 408 | BN_free(tmp); |
| 409 | return (ok); | 409 | return (ok); |
| 410 | } | 410 | } |
| 411 | 411 | ||
| @@ -509,12 +509,11 @@ ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) | |||
| 509 | 509 | ||
| 510 | ok = 1; | 510 | ok = 1; |
| 511 | 511 | ||
| 512 | err: free(buffer_1); | 512 | err: |
| 513 | free(buffer_1); | ||
| 513 | free(buffer_2); | 514 | free(buffer_2); |
| 514 | if (tmp_1) | 515 | BN_free(tmp_1); |
| 515 | BN_free(tmp_1); | 516 | BN_free(tmp_2); |
| 516 | if (tmp_2) | ||
| 517 | BN_free(tmp_2); | ||
| 518 | return (ok); | 517 | return (ok); |
| 519 | } | 518 | } |
| 520 | 519 | ||
| @@ -608,8 +607,7 @@ err: if (!ok) { | |||
| 608 | ECPARAMETERS_free(ret); | 607 | ECPARAMETERS_free(ret); |
| 609 | ret = NULL; | 608 | ret = NULL; |
| 610 | } | 609 | } |
| 611 | if (tmp) | 610 | BN_free(tmp); |
| 612 | BN_free(tmp); | ||
| 613 | free(buffer); | 611 | free(buffer); |
| 614 | return (ret); | 612 | return (ret); |
| 615 | } | 613 | } |
| @@ -849,10 +847,8 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) | |||
| 849 | } | 847 | } |
| 850 | /* extract the cofactor (optional) */ | 848 | /* extract the cofactor (optional) */ |
| 851 | if (params->cofactor == NULL) { | 849 | if (params->cofactor == NULL) { |
| 852 | if (b) { | 850 | BN_free(b); |
| 853 | BN_free(b); | 851 | b = NULL; |
| 854 | b = NULL; | ||
| 855 | } | ||
| 856 | } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) { | 852 | } else if ((b = ASN1_INTEGER_to_BN(params->cofactor, b)) == NULL) { |
| 857 | ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); | 853 | ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_ASN1_LIB); |
| 858 | goto err; | 854 | goto err; |
| @@ -865,18 +861,13 @@ ec_asn1_parameters2group(const ECPARAMETERS * params) | |||
| 865 | ok = 1; | 861 | ok = 1; |
| 866 | 862 | ||
| 867 | err: if (!ok) { | 863 | err: if (!ok) { |
| 868 | if (ret) | 864 | EC_GROUP_clear_free(ret); |
| 869 | EC_GROUP_clear_free(ret); | ||
| 870 | ret = NULL; | 865 | ret = NULL; |
| 871 | } | 866 | } |
| 872 | if (p) | 867 | BN_free(p); |
| 873 | BN_free(p); | 868 | BN_free(a); |
| 874 | if (a) | 869 | BN_free(b); |
| 875 | BN_free(a); | 870 | EC_POINT_free(point); |
| 876 | if (b) | ||
| 877 | BN_free(b); | ||
| 878 | if (point) | ||
| 879 | EC_POINT_free(point); | ||
| 880 | return (ret); | 871 | return (ret); |
| 881 | } | 872 | } |
| 882 | 873 | ||
| @@ -992,8 +983,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) | |||
| 992 | ret = *a; | 983 | ret = *a; |
| 993 | 984 | ||
| 994 | if (priv_key->parameters) { | 985 | if (priv_key->parameters) { |
| 995 | if (ret->group) | 986 | EC_GROUP_clear_free(ret->group); |
| 996 | EC_GROUP_clear_free(ret->group); | ||
| 997 | ret->group = ec_asn1_pkparameters2group(priv_key->parameters); | 987 | ret->group = ec_asn1_pkparameters2group(priv_key->parameters); |
| 998 | } | 988 | } |
| 999 | if (ret->group == NULL) { | 989 | if (ret->group == NULL) { |
| @@ -1022,8 +1012,7 @@ d2i_ECPrivateKey(EC_KEY ** a, const unsigned char **in, long len) | |||
| 1022 | const unsigned char *pub_oct; | 1012 | const unsigned char *pub_oct; |
| 1023 | size_t pub_oct_len; | 1013 | size_t pub_oct_len; |
| 1024 | 1014 | ||
| 1025 | if (ret->pub_key) | 1015 | EC_POINT_clear_free(ret->pub_key); |
| 1026 | EC_POINT_clear_free(ret->pub_key); | ||
| 1027 | ret->pub_key = EC_POINT_new(ret->group); | 1016 | ret->pub_key = EC_POINT_new(ret->group); |
| 1028 | if (ret->pub_key == NULL) { | 1017 | if (ret->pub_key == NULL) { |
| 1029 | ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); | 1018 | ECerr(EC_F_D2I_ECPRIVATEKEY, ERR_R_EC_LIB); |
