diff options
author | tb <> | 2024-10-11 06:13:09 +0000 |
---|---|---|
committer | tb <> | 2024-10-11 06:13:09 +0000 |
commit | f8ad3a37492a13165ccab6bc62ca867432fbd88f (patch) | |
tree | 0a4d6fba68fde3b717b9793e9785a7adaf28e377 /src | |
parent | b95100d93674afc2296d41736de4c76893204cb4 (diff) | |
download | openbsd-f8ad3a37492a13165ccab6bc62ca867432fbd88f.tar.gz openbsd-f8ad3a37492a13165ccab6bc62ca867432fbd88f.tar.bz2 openbsd-f8ad3a37492a13165ccab6bc62ca867432fbd88f.zip |
Clean up i2d_ECPKParameters()
Use better variable names and turn it into single-exit. This changes the
behavior slightly in that an error is pushed onto the stack also for
i2d_ECPKPARAMETERS() return values < 0.
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 825f4f3892..d6b92fb16d 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.57 2024/10/03 05:07:49 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.58 2024/10/11 06:13:09 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -1034,21 +1034,24 @@ d2i_ECPKParameters(EC_GROUP **a, const unsigned char **in, long len) | |||
1034 | LCRYPTO_ALIAS(d2i_ECPKParameters); | 1034 | LCRYPTO_ALIAS(d2i_ECPKParameters); |
1035 | 1035 | ||
1036 | int | 1036 | int |
1037 | i2d_ECPKParameters(const EC_GROUP *a, unsigned char **out) | 1037 | i2d_ECPKParameters(const EC_GROUP *group, unsigned char **out_der) |
1038 | { | 1038 | { |
1039 | ECPKPARAMETERS *parameters; | ||
1039 | int ret = 0; | 1040 | int ret = 0; |
1040 | ECPKPARAMETERS *tmp = ec_asn1_group2pkparameters(a, NULL); | 1041 | |
1041 | if (tmp == NULL) { | 1042 | if ((parameters = ec_asn1_group2pkparameters(group, NULL)) == NULL) { |
1042 | ECerror(EC_R_GROUP2PKPARAMETERS_FAILURE); | 1043 | ECerror(EC_R_GROUP2PKPARAMETERS_FAILURE); |
1043 | return 0; | 1044 | goto err; |
1044 | } | 1045 | } |
1045 | if ((ret = i2d_ECPKPARAMETERS(tmp, out)) == 0) { | 1046 | if ((ret = i2d_ECPKPARAMETERS(parameters, out_der)) <= 0) { |
1046 | ECerror(EC_R_I2D_ECPKPARAMETERS_FAILURE); | 1047 | ECerror(EC_R_I2D_ECPKPARAMETERS_FAILURE); |
1047 | ECPKPARAMETERS_free(tmp); | 1048 | goto err; |
1048 | return 0; | ||
1049 | } | 1049 | } |
1050 | ECPKPARAMETERS_free(tmp); | 1050 | |
1051 | return (ret); | 1051 | err: |
1052 | ECPKPARAMETERS_free(parameters); | ||
1053 | |||
1054 | return ret; | ||
1052 | } | 1055 | } |
1053 | LCRYPTO_ALIAS(i2d_ECPKParameters); | 1056 | LCRYPTO_ALIAS(i2d_ECPKParameters); |
1054 | 1057 | ||