diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 4cf0bf5972..6bf7e47d7d 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.36 2022/03/31 13:00:58 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.37 2022/05/24 20:06:32 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -60,11 +60,13 @@ | |||
| 60 | 60 | ||
| 61 | #include <openssl/opensslconf.h> | 61 | #include <openssl/opensslconf.h> |
| 62 | 62 | ||
| 63 | #include "ec_lcl.h" | ||
| 64 | #include <openssl/err.h> | 63 | #include <openssl/err.h> |
| 65 | #include <openssl/asn1t.h> | 64 | #include <openssl/asn1t.h> |
| 66 | #include <openssl/objects.h> | 65 | #include <openssl/objects.h> |
| 67 | 66 | ||
| 67 | #include "asn1_locl.h" | ||
| 68 | #include "ec_lcl.h" | ||
| 69 | |||
| 68 | int | 70 | int |
| 69 | EC_GROUP_get_basis_type(const EC_GROUP * group) | 71 | EC_GROUP_get_basis_type(const EC_GROUP * group) |
| 70 | { | 72 | { |
| @@ -860,24 +862,24 @@ ec_asn1_group2curve(const EC_GROUP * group, X9_62_CURVE * curve) | |||
| 860 | ECerror(ERR_R_ASN1_LIB); | 862 | ECerror(ERR_R_ASN1_LIB); |
| 861 | goto err; | 863 | goto err; |
| 862 | } | 864 | } |
| 865 | |||
| 866 | ASN1_BIT_STRING_free(curve->seed); | ||
| 867 | curve->seed = NULL; | ||
| 868 | |||
| 863 | /* set the seed (optional) */ | 869 | /* set the seed (optional) */ |
| 864 | if (group->seed) { | 870 | if (group->seed != NULL) { |
| 865 | if (!curve->seed) | 871 | if ((curve->seed = ASN1_BIT_STRING_new()) == NULL) { |
| 866 | if ((curve->seed = ASN1_BIT_STRING_new()) == NULL) { | 872 | ECerror(ERR_R_MALLOC_FAILURE); |
| 867 | ECerror(ERR_R_MALLOC_FAILURE); | 873 | goto err; |
| 868 | goto err; | 874 | } |
| 869 | } | ||
| 870 | curve->seed->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); | ||
| 871 | curve->seed->flags |= ASN1_STRING_FLAG_BITS_LEFT; | ||
| 872 | if (!ASN1_BIT_STRING_set(curve->seed, group->seed, | 875 | if (!ASN1_BIT_STRING_set(curve->seed, group->seed, |
| 873 | (int) group->seed_len)) { | 876 | (int) group->seed_len)) { |
| 874 | ECerror(ERR_R_ASN1_LIB); | 877 | ECerror(ERR_R_ASN1_LIB); |
| 875 | goto err; | 878 | goto err; |
| 876 | } | 879 | } |
| 877 | } else { | 880 | if (!asn1_abs_set_unused_bits(curve->seed, 0)) { |
| 878 | if (curve->seed) { | 881 | ECerror(ERR_R_ASN1_LIB); |
| 879 | ASN1_BIT_STRING_free(curve->seed); | 882 | goto err; |
| 880 | curve->seed = NULL; | ||
| 881 | } | 883 | } |
| 882 | } | 884 | } |
| 883 | 885 | ||
| @@ -1481,10 +1483,11 @@ i2d_ECPrivateKey(EC_KEY * a, unsigned char **out) | |||
| 1481 | ECerror(ERR_R_EC_LIB); | 1483 | ECerror(ERR_R_EC_LIB); |
| 1482 | goto err; | 1484 | goto err; |
| 1483 | } | 1485 | } |
| 1484 | priv_key->publicKey->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07); | 1486 | if (!ASN1_STRING_set(priv_key->publicKey, buffer, buf_len)) { |
| 1485 | priv_key->publicKey->flags |= ASN1_STRING_FLAG_BITS_LEFT; | 1487 | ECerror(ERR_R_ASN1_LIB); |
| 1486 | if (!ASN1_STRING_set(priv_key->publicKey, buffer, | 1488 | goto err; |
| 1487 | buf_len)) { | 1489 | } |
| 1490 | if (!asn1_abs_set_unused_bits(priv_key->publicKey, 0)) { | ||
| 1488 | ECerror(ERR_R_ASN1_LIB); | 1491 | ECerror(ERR_R_ASN1_LIB); |
| 1489 | goto err; | 1492 | goto err; |
| 1490 | } | 1493 | } |
