summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ec_curve.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ec/ec_curve.c')
-rw-r--r--src/lib/libcrypto/ec/ec_curve.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/libcrypto/ec/ec_curve.c b/src/lib/libcrypto/ec/ec_curve.c
index c8eee285b6..1ee2a7c8e8 100644
--- a/src/lib/libcrypto/ec/ec_curve.c
+++ b/src/lib/libcrypto/ec/ec_curve.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_curve.c,v 1.14 2016/11/04 17:33:19 miod Exp $ */ 1/* $OpenBSD: ec_curve.c,v 1.15 2017/01/29 17:49:23 beck Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -3168,7 +3168,7 @@ ec_group_new_from_data(const ec_list_element curve)
3168 const unsigned char *params; 3168 const unsigned char *params;
3169 3169
3170 if ((ctx = BN_CTX_new()) == NULL) { 3170 if ((ctx = BN_CTX_new()) == NULL) {
3171 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_MALLOC_FAILURE); 3171 ECerror(ERR_R_MALLOC_FAILURE);
3172 goto err; 3172 goto err;
3173 } 3173 }
3174 data = curve.data; 3174 data = curve.data;
@@ -3180,19 +3180,19 @@ ec_group_new_from_data(const ec_list_element curve)
3180 if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) || 3180 if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) ||
3181 !(a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) || 3181 !(a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) ||
3182 !(b = BN_bin2bn(params + 2 * param_len, param_len, NULL))) { 3182 !(b = BN_bin2bn(params + 2 * param_len, param_len, NULL))) {
3183 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); 3183 ECerror(ERR_R_BN_LIB);
3184 goto err; 3184 goto err;
3185 } 3185 }
3186 if (curve.meth != 0) { 3186 if (curve.meth != 0) {
3187 meth = curve.meth(); 3187 meth = curve.meth();
3188 if (((group = EC_GROUP_new(meth)) == NULL) || 3188 if (((group = EC_GROUP_new(meth)) == NULL) ||
3189 (!(group->meth->group_set_curve(group, p, a, b, ctx)))) { 3189 (!(group->meth->group_set_curve(group, p, a, b, ctx)))) {
3190 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3190 ECerror(ERR_R_EC_LIB);
3191 goto err; 3191 goto err;
3192 } 3192 }
3193 } else if (data->field_type == NID_X9_62_prime_field) { 3193 } else if (data->field_type == NID_X9_62_prime_field) {
3194 if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) { 3194 if ((group = EC_GROUP_new_curve_GFp(p, a, b, ctx)) == NULL) {
3195 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3195 ECerror(ERR_R_EC_LIB);
3196 goto err; 3196 goto err;
3197 } 3197 }
3198 } 3198 }
@@ -3200,37 +3200,37 @@ ec_group_new_from_data(const ec_list_element curve)
3200 else { /* field_type == 3200 else { /* field_type ==
3201 * NID_X9_62_characteristic_two_field */ 3201 * NID_X9_62_characteristic_two_field */
3202 if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL) { 3202 if ((group = EC_GROUP_new_curve_GF2m(p, a, b, ctx)) == NULL) {
3203 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3203 ECerror(ERR_R_EC_LIB);
3204 goto err; 3204 goto err;
3205 } 3205 }
3206 } 3206 }
3207#endif 3207#endif
3208 3208
3209 if ((P = EC_POINT_new(group)) == NULL) { 3209 if ((P = EC_POINT_new(group)) == NULL) {
3210 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3210 ECerror(ERR_R_EC_LIB);
3211 goto err; 3211 goto err;
3212 } 3212 }
3213 if (!(x = BN_bin2bn(params + 3 * param_len, param_len, NULL)) 3213 if (!(x = BN_bin2bn(params + 3 * param_len, param_len, NULL))
3214 || !(y = BN_bin2bn(params + 4 * param_len, param_len, NULL))) { 3214 || !(y = BN_bin2bn(params + 4 * param_len, param_len, NULL))) {
3215 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); 3215 ECerror(ERR_R_BN_LIB);
3216 goto err; 3216 goto err;
3217 } 3217 }
3218 if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) { 3218 if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) {
3219 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3219 ECerror(ERR_R_EC_LIB);
3220 goto err; 3220 goto err;
3221 } 3221 }
3222 if (!(order = BN_bin2bn(params + 5 * param_len, param_len, NULL)) 3222 if (!(order = BN_bin2bn(params + 5 * param_len, param_len, NULL))
3223 || !BN_set_word(x, (BN_ULONG) data->cofactor)) { 3223 || !BN_set_word(x, (BN_ULONG) data->cofactor)) {
3224 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); 3224 ECerror(ERR_R_BN_LIB);
3225 goto err; 3225 goto err;
3226 } 3226 }
3227 if (!EC_GROUP_set_generator(group, P, order, x)) { 3227 if (!EC_GROUP_set_generator(group, P, order, x)) {
3228 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3228 ECerror(ERR_R_EC_LIB);
3229 goto err; 3229 goto err;
3230 } 3230 }
3231 if (seed_len) { 3231 if (seed_len) {
3232 if (!EC_GROUP_set_seed(group, params - seed_len, seed_len)) { 3232 if (!EC_GROUP_set_seed(group, params - seed_len, seed_len)) {
3233 ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); 3233 ECerror(ERR_R_EC_LIB);
3234 goto err; 3234 goto err;
3235 } 3235 }
3236 } 3236 }
@@ -3266,7 +3266,7 @@ EC_GROUP_new_by_curve_name(int nid)
3266 break; 3266 break;
3267 } 3267 }
3268 if (ret == NULL) { 3268 if (ret == NULL) {
3269 ECerr(EC_F_EC_GROUP_NEW_BY_CURVE_NAME, EC_R_UNKNOWN_GROUP); 3269 ECerror(EC_R_UNKNOWN_GROUP);
3270 return NULL; 3270 return NULL;
3271 } 3271 }
3272 EC_GROUP_set_curve_name(ret, nid); 3272 EC_GROUP_set_curve_name(ret, nid);