diff options
author | tb <> | 2024-10-26 14:33:59 +0000 |
---|---|---|
committer | tb <> | 2024-10-26 14:33:59 +0000 |
commit | b70bdeed51794636632e093b9c645f44b6938f66 (patch) | |
tree | be9e4f1112aac3c58d27cf655de72202cb66737a /src | |
parent | f39ebbbad9ab0d5e2ba7dd51a5bc98b6d4833786 (diff) | |
download | openbsd-b70bdeed51794636632e093b9c645f44b6938f66.tar.gz openbsd-b70bdeed51794636632e093b9c645f44b6938f66.tar.bz2 openbsd-b70bdeed51794636632e093b9c645f44b6938f66.zip |
a and ret aren't great names for EC_KEYs
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ec_asn1.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c index 3bb175873c..5c2e19a35a 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.80 2024/10/26 14:32:56 tb Exp $ */ | 1 | /* $OpenBSD: ec_asn1.c,v 1.81 2024/10/26 14:33:59 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -1090,39 +1090,39 @@ i2d_ECPKParameters(const EC_GROUP *group, unsigned char **out_der) | |||
1090 | LCRYPTO_ALIAS(i2d_ECPKParameters); | 1090 | LCRYPTO_ALIAS(i2d_ECPKParameters); |
1091 | 1091 | ||
1092 | EC_KEY * | 1092 | EC_KEY * |
1093 | d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) | 1093 | d2i_ECPrivateKey(EC_KEY **out_ec_key, const unsigned char **in, long len) |
1094 | { | 1094 | { |
1095 | EC_KEY *ret = NULL; | 1095 | EC_KEY *ec_key = NULL; |
1096 | EC_PRIVATEKEY *ec_privatekey = NULL; | 1096 | EC_PRIVATEKEY *ec_privatekey = NULL; |
1097 | 1097 | ||
1098 | if ((ec_privatekey = d2i_EC_PRIVATEKEY(NULL, in, len)) == NULL) { | 1098 | if ((ec_privatekey = d2i_EC_PRIVATEKEY(NULL, in, len)) == NULL) { |
1099 | ECerror(ERR_R_EC_LIB); | 1099 | ECerror(ERR_R_EC_LIB); |
1100 | return NULL; | 1100 | return NULL; |
1101 | } | 1101 | } |
1102 | if (a == NULL || *a == NULL) { | 1102 | if (out_ec_key == NULL || *out_ec_key == NULL) { |
1103 | if ((ret = EC_KEY_new()) == NULL) { | 1103 | if ((ec_key = EC_KEY_new()) == NULL) { |
1104 | ECerror(ERR_R_MALLOC_FAILURE); | 1104 | ECerror(ERR_R_MALLOC_FAILURE); |
1105 | goto err; | 1105 | goto err; |
1106 | } | 1106 | } |
1107 | } else | 1107 | } else |
1108 | ret = *a; | 1108 | ec_key = *out_ec_key; |
1109 | 1109 | ||
1110 | if (ec_privatekey->parameters) { | 1110 | if (ec_privatekey->parameters) { |
1111 | EC_GROUP_free(ret->group); | 1111 | EC_GROUP_free(ec_key->group); |
1112 | ret->group = ec_asn1_pkparameters2group(ec_privatekey->parameters); | 1112 | ec_key->group = ec_asn1_pkparameters2group(ec_privatekey->parameters); |
1113 | } | 1113 | } |
1114 | if (ret->group == NULL) { | 1114 | if (ec_key->group == NULL) { |
1115 | ECerror(ERR_R_EC_LIB); | 1115 | ECerror(ERR_R_EC_LIB); |
1116 | goto err; | 1116 | goto err; |
1117 | } | 1117 | } |
1118 | ret->version = ec_privatekey->version; | 1118 | ec_key->version = ec_privatekey->version; |
1119 | 1119 | ||
1120 | if (ec_privatekey->privateKey) { | 1120 | if (ec_privatekey->privateKey) { |
1121 | ret->priv_key = BN_bin2bn( | 1121 | ec_key->priv_key = BN_bin2bn( |
1122 | ASN1_STRING_data(ec_privatekey->privateKey), | 1122 | ASN1_STRING_data(ec_privatekey->privateKey), |
1123 | ASN1_STRING_length(ec_privatekey->privateKey), | 1123 | ASN1_STRING_length(ec_privatekey->privateKey), |
1124 | ret->priv_key); | 1124 | ec_key->priv_key); |
1125 | if (ret->priv_key == NULL) { | 1125 | if (ec_key->priv_key == NULL) { |
1126 | ECerror(ERR_R_BN_LIB); | 1126 | ECerror(ERR_R_BN_LIB); |
1127 | goto err; | 1127 | goto err; |
1128 | } | 1128 | } |
@@ -1131,10 +1131,10 @@ d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) | |||
1131 | goto err; | 1131 | goto err; |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | if (ret->pub_key) | 1134 | if (ec_key->pub_key) |
1135 | EC_POINT_free(ret->pub_key); | 1135 | EC_POINT_free(ec_key->pub_key); |
1136 | ret->pub_key = EC_POINT_new(ret->group); | 1136 | ec_key->pub_key = EC_POINT_new(ec_key->group); |
1137 | if (ret->pub_key == NULL) { | 1137 | if (ec_key->pub_key == NULL) { |
1138 | ECerror(ERR_R_EC_LIB); | 1138 | ECerror(ERR_R_EC_LIB); |
1139 | goto err; | 1139 | goto err; |
1140 | } | 1140 | } |
@@ -1151,30 +1151,30 @@ d2i_ECPrivateKey(EC_KEY **a, const unsigned char **in, long len) | |||
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | /* save the point conversion form */ | 1153 | /* save the point conversion form */ |
1154 | ret->conv_form = (point_conversion_form_t) (pub_oct[0] & ~0x01); | 1154 | ec_key->conv_form = (point_conversion_form_t) (pub_oct[0] & ~0x01); |
1155 | if (!EC_POINT_oct2point(ret->group, ret->pub_key, | 1155 | if (!EC_POINT_oct2point(ec_key->group, ec_key->pub_key, |
1156 | pub_oct, pub_oct_len, NULL)) { | 1156 | pub_oct, pub_oct_len, NULL)) { |
1157 | ECerror(ERR_R_EC_LIB); | 1157 | ECerror(ERR_R_EC_LIB); |
1158 | goto err; | 1158 | goto err; |
1159 | } | 1159 | } |
1160 | } else { | 1160 | } else { |
1161 | if (!EC_POINT_mul(ret->group, ret->pub_key, ret->priv_key, | 1161 | if (!EC_POINT_mul(ec_key->group, ec_key->pub_key, ec_key->priv_key, |
1162 | NULL, NULL, NULL)) { | 1162 | NULL, NULL, NULL)) { |
1163 | ECerror(ERR_R_EC_LIB); | 1163 | ECerror(ERR_R_EC_LIB); |
1164 | goto err; | 1164 | goto err; |
1165 | } | 1165 | } |
1166 | /* Remember the original private-key-only encoding. */ | 1166 | /* Remember the original private-key-only encoding. */ |
1167 | ret->enc_flag |= EC_PKEY_NO_PUBKEY; | 1167 | ec_key->enc_flag |= EC_PKEY_NO_PUBKEY; |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | EC_PRIVATEKEY_free(ec_privatekey); | 1170 | EC_PRIVATEKEY_free(ec_privatekey); |
1171 | if (a != NULL) | 1171 | if (out_ec_key != NULL) |
1172 | *a = ret; | 1172 | *out_ec_key = ec_key; |
1173 | return (ret); | 1173 | return (ec_key); |
1174 | 1174 | ||
1175 | err: | 1175 | err: |
1176 | if (a == NULL || *a != ret) | 1176 | if (out_ec_key == NULL || *out_ec_key != ec_key) |
1177 | EC_KEY_free(ret); | 1177 | EC_KEY_free(ec_key); |
1178 | if (ec_privatekey) | 1178 | if (ec_privatekey) |
1179 | EC_PRIVATEKEY_free(ec_privatekey); | 1179 | EC_PRIVATEKEY_free(ec_privatekey); |
1180 | 1180 | ||