summaryrefslogtreecommitdiffstats
path: root/src/crypto/ec/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/ec/ec.c')
-rw-r--r--src/crypto/ec/ec.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/src/crypto/ec/ec.c b/src/crypto/ec/ec.c
index 6e676c9..5426b8f 100644
--- a/src/crypto/ec/ec.c
+++ b/src/crypto/ec/ec.c
@@ -219,11 +219,18 @@ static const struct curve_data P521 = {
0xB7, 0x1E, 0x91, 0x38, 0x64, 0x09}};
const struct built_in_curve OPENSSL_built_in_curves[] = {
- {NID_secp224r1, &P224, 0},
- {NID_X9_62_prime256v1, &P256, 0},
- {NID_secp384r1, &P384, 0},
- {NID_secp521r1, &P521, 0},
- {NID_undef, 0, 0},
+ {NID_secp224r1, &P224, 0},
+ {
+ NID_X9_62_prime256v1, &P256,
+#if defined(OPENSSL_64_BIT) && !defined(OPENSSL_WINDOWS)
+ EC_GFp_nistp256_method,
+#else
+ 0,
+#endif
+ },
+ {NID_secp384r1, &P384, 0},
+ {NID_secp521r1, &P521, 0},
+ {NID_undef, 0, 0},
};
EC_GROUP *ec_group_new(const EC_METHOD *meth) {
@@ -357,22 +364,14 @@ err:
EC_GROUP_free(group);
group = NULL;
}
- if (P)
- EC_POINT_free(P);
- if (ctx)
- BN_CTX_free(ctx);
- if (p)
- BN_free(p);
- if (a)
- BN_free(a);
- if (b)
- BN_free(b);
- if (order)
- BN_free(order);
- if (x)
- BN_free(x);
- if (y)
- BN_free(y);
+ EC_POINT_free(P);
+ BN_CTX_free(ctx);
+ BN_free(p);
+ BN_free(a);
+ BN_free(b);
+ BN_free(order);
+ BN_free(x);
+ BN_free(y);
return group;
}
@@ -409,16 +408,14 @@ void EC_GROUP_free(EC_GROUP *group) {
ec_pre_comp_free(group->pre_comp);
- if (group->generator != NULL) {
- EC_POINT_free(group->generator);
- }
+ EC_POINT_free(group->generator);
BN_free(&group->order);
BN_free(&group->cofactor);
OPENSSL_free(group);
}
-int EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) {
+int ec_group_copy(EC_GROUP *dest, const EC_GROUP *src) {
if (dest->meth->group_copy == 0) {
OPENSSL_PUT_ERROR(EC, EC_GROUP_copy, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
@@ -474,7 +471,7 @@ EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) {
if (t == NULL) {
return NULL;
}
- if (!EC_GROUP_copy(t, a)) {
+ if (!ec_group_copy(t, a)) {
goto err;
}
@@ -482,9 +479,7 @@ EC_GROUP *EC_GROUP_dup(const EC_GROUP *a) {
err:
if (!ok) {
- if (t) {
- EC_GROUP_free(t);
- }
+ EC_GROUP_free(t);
return NULL;
} else {
return t;