summaryrefslogtreecommitdiff
path: root/lib/libcrypto/ec
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2014-04-27 20:26:50 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2014-04-27 20:26:50 +0000
commite5cffcd34247f85edfdeb62a15a64dfbfbd449e0 (patch)
treeda4996e6e0a1e6f377715dfbc7b3352529477cba /lib/libcrypto/ec
parenta87db0183f55bcd74e22af7a30de8ff482d0495b (diff)
Use C99 initializers for the various FOO_METHOD structs. More readable, and
avoid unreadable/unmaintainable constructs like that: const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { EVP_PKEY_CMAC, EVP_PKEY_CMAC, 0, "CMAC", "OpenSSL CMAC method", 0,0,0,0, 0,0,0, cmac_size, 0, 0,0,0,0,0,0,0, cmac_key_free, 0, 0,0 }; ok matthew@ deraadt@
Diffstat (limited to 'lib/libcrypto/ec')
-rw-r--r--lib/libcrypto/ec/ec2_smpl.c79
-rw-r--r--lib/libcrypto/ec/ec_ameth.c64
-rw-r--r--lib/libcrypto/ec/ec_pmeth.c41
-rw-r--r--lib/libcrypto/ec/ecp_mont.c82
-rw-r--r--lib/libcrypto/ec/ecp_nist.c79
-rw-r--r--lib/libcrypto/ec/ecp_nistp224.c84
-rw-r--r--lib/libcrypto/ec/ecp_nistp256.c84
-rw-r--r--lib/libcrypto/ec/ecp_nistp521.c84
-rw-r--r--lib/libcrypto/ec/ecp_smpl.c79
9 files changed, 329 insertions, 347 deletions
diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c
index 0cf681fa9df..5682bfab377 100644
--- a/lib/libcrypto/ec/ec2_smpl.c
+++ b/lib/libcrypto/ec/ec2_smpl.c
@@ -73,52 +73,51 @@
#ifndef OPENSSL_NO_EC2M
-const EC_METHOD *EC_GF2m_simple_method(void)
- {
+const EC_METHOD *
+EC_GF2m_simple_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_characteristic_two_field,
- ec_GF2m_simple_group_init,
- ec_GF2m_simple_group_finish,
- ec_GF2m_simple_group_clear_finish,
- ec_GF2m_simple_group_copy,
- ec_GF2m_simple_group_set_curve,
- ec_GF2m_simple_group_get_curve,
- ec_GF2m_simple_group_get_degree,
- ec_GF2m_simple_group_check_discriminant,
- ec_GF2m_simple_point_init,
- ec_GF2m_simple_point_finish,
- ec_GF2m_simple_point_clear_finish,
- ec_GF2m_simple_point_copy,
- ec_GF2m_simple_point_set_to_infinity,
- 0 /* set_Jprojective_coordinates_GFp */,
- 0 /* get_Jprojective_coordinates_GFp */,
- ec_GF2m_simple_point_set_affine_coordinates,
- ec_GF2m_simple_point_get_affine_coordinates,
- 0,0,0,
- ec_GF2m_simple_add,
- ec_GF2m_simple_dbl,
- ec_GF2m_simple_invert,
- ec_GF2m_simple_is_at_infinity,
- ec_GF2m_simple_is_on_curve,
- ec_GF2m_simple_cmp,
- ec_GF2m_simple_make_affine,
- ec_GF2m_simple_points_make_affine,
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_characteristic_two_field,
+ .group_init = ec_GF2m_simple_group_init,
+ .group_finish = ec_GF2m_simple_group_finish,
+ .group_clear_finish = ec_GF2m_simple_group_clear_finish,
+ .group_copy = ec_GF2m_simple_group_copy,
+ .group_set_curve = ec_GF2m_simple_group_set_curve,
+ .group_get_curve = ec_GF2m_simple_group_get_curve,
+ .group_get_degree = ec_GF2m_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GF2m_simple_group_check_discriminant,
+ .point_init = ec_GF2m_simple_point_init,
+ .point_finish = ec_GF2m_simple_point_finish,
+ .point_clear_finish = ec_GF2m_simple_point_clear_finish,
+ .point_copy = ec_GF2m_simple_point_copy,
+ .point_set_to_infinity = ec_GF2m_simple_point_set_to_infinity,
+ .point_set_affine_coordinates =
+ ec_GF2m_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GF2m_simple_point_get_affine_coordinates,
+ .add = ec_GF2m_simple_add,
+ .dbl = ec_GF2m_simple_dbl,
+ .invert = ec_GF2m_simple_invert,
+ .is_at_infinity = ec_GF2m_simple_is_at_infinity,
+ .is_on_curve = ec_GF2m_simple_is_on_curve,
+ .point_cmp = ec_GF2m_simple_cmp,
+ .make_affine = ec_GF2m_simple_make_affine,
+ .points_make_affine = ec_GF2m_simple_points_make_affine,
/* the following three method functions are defined in ec2_mult.c */
- ec_GF2m_simple_mul,
- ec_GF2m_precompute_mult,
- ec_GF2m_have_precompute_mult,
+ .mul = ec_GF2m_simple_mul,
+ .precompute_mult = ec_GF2m_precompute_mult,
+ .have_precompute_mult = ec_GF2m_have_precompute_mult,
- ec_GF2m_simple_field_mul,
- ec_GF2m_simple_field_sqr,
- ec_GF2m_simple_field_div,
- 0 /* field_encode */,
- 0 /* field_decode */,
- 0 /* field_set_to_one */ };
+ .field_mul = ec_GF2m_simple_field_mul,
+ .field_sqr = ec_GF2m_simple_field_sqr,
+ .field_div = ec_GF2m_simple_field_div,
+ };
return &ret;
- }
+}
/* Initialize a GF(2^m)-based EC_GROUP structure.
diff --git a/lib/libcrypto/ec/ec_ameth.c b/lib/libcrypto/ec/ec_ameth.c
index 79dd11083ec..0e6381f5439 100644
--- a/lib/libcrypto/ec/ec_ameth.c
+++ b/lib/libcrypto/ec/ec_ameth.c
@@ -626,36 +626,34 @@ static int ec_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2)
}
-const EVP_PKEY_ASN1_METHOD eckey_asn1_meth =
- {
- EVP_PKEY_EC,
- EVP_PKEY_EC,
- 0,
- "EC",
- "OpenSSL EC algorithm",
-
- eckey_pub_decode,
- eckey_pub_encode,
- eckey_pub_cmp,
- eckey_pub_print,
-
- eckey_priv_decode,
- eckey_priv_encode,
- eckey_priv_print,
-
- int_ec_size,
- ec_bits,
-
- eckey_param_decode,
- eckey_param_encode,
- ec_missing_parameters,
- ec_copy_parameters,
- ec_cmp_parameters,
- eckey_param_print,
- 0,
-
- int_ec_free,
- ec_pkey_ctrl,
- old_ec_priv_decode,
- old_ec_priv_encode
- };
+const EVP_PKEY_ASN1_METHOD eckey_asn1_meth = {
+ .pkey_id = EVP_PKEY_EC,
+ .pkey_base_id = EVP_PKEY_EC,
+
+ .pem_str = "EC",
+ .info = "OpenSSL EC algorithm",
+
+ .pub_decode = eckey_pub_decode,
+ .pub_encode = eckey_pub_encode,
+ .pub_cmp = eckey_pub_cmp,
+ .pub_print = eckey_pub_print,
+
+ .priv_decode = eckey_priv_decode,
+ .priv_encode = eckey_priv_encode,
+ .priv_print = eckey_priv_print,
+
+ .pkey_size = int_ec_size,
+ .pkey_bits = ec_bits,
+
+ .param_decode = eckey_param_decode,
+ .param_encode = eckey_param_encode,
+ .param_missing = ec_missing_parameters,
+ .param_copy = ec_copy_parameters,
+ .param_cmp = ec_cmp_parameters,
+ .param_print = eckey_param_print,
+
+ .pkey_free = int_ec_free,
+ .pkey_ctrl = ec_pkey_ctrl,
+ .old_priv_decode = old_ec_priv_decode,
+ .old_priv_encode = old_ec_priv_encode
+};
diff --git a/lib/libcrypto/ec/ec_pmeth.c b/lib/libcrypto/ec/ec_pmeth.c
index dfc8ace27b2..c970d8c9ca2 100644
--- a/lib/libcrypto/ec/ec_pmeth.c
+++ b/lib/libcrypto/ec/ec_pmeth.c
@@ -304,38 +304,23 @@ static int pkey_ec_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey)
return EC_KEY_generate_key(pkey->pkey.ec);
}
-const EVP_PKEY_METHOD ec_pkey_meth =
- {
- EVP_PKEY_EC,
- 0,
- pkey_ec_init,
- pkey_ec_copy,
- pkey_ec_cleanup,
-
- 0,
- pkey_ec_paramgen,
-
- 0,
- pkey_ec_keygen,
-
- 0,
- pkey_ec_sign,
-
- 0,
- pkey_ec_verify,
+const EVP_PKEY_METHOD ec_pkey_meth = {
+ .pkey_id = EVP_PKEY_EC,
- 0,0,
+ .init = pkey_ec_init,
+ .copy = pkey_ec_copy,
+ .cleanup = pkey_ec_cleanup,
- 0,0,0,0,
+ .paramgen = pkey_ec_paramgen,
- 0,0,
+ .keygen = pkey_ec_keygen,
- 0,0,
+ .sign = pkey_ec_sign,
- 0,
- pkey_ec_derive,
+ .verify = pkey_ec_verify,
- pkey_ec_ctrl,
- pkey_ec_ctrl_str
+ .derive = pkey_ec_derive,
- };
+ .ctrl = pkey_ec_ctrl,
+ .ctrl_str = pkey_ec_ctrl_str
+};
diff --git a/lib/libcrypto/ec/ecp_mont.c b/lib/libcrypto/ec/ecp_mont.c
index cee0fee12a6..6b5b856344e 100644
--- a/lib/libcrypto/ec/ecp_mont.c
+++ b/lib/libcrypto/ec/ecp_mont.c
@@ -66,49 +66,51 @@
#include "ec_lcl.h"
-const EC_METHOD *EC_GFp_mont_method(void)
- {
+const EC_METHOD *
+EC_GFp_mont_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_prime_field,
- ec_GFp_mont_group_init,
- ec_GFp_mont_group_finish,
- ec_GFp_mont_group_clear_finish,
- ec_GFp_mont_group_copy,
- ec_GFp_mont_group_set_curve,
- ec_GFp_simple_group_get_curve,
- ec_GFp_simple_group_get_degree,
- ec_GFp_simple_group_check_discriminant,
- ec_GFp_simple_point_init,
- ec_GFp_simple_point_finish,
- ec_GFp_simple_point_clear_finish,
- ec_GFp_simple_point_copy,
- ec_GFp_simple_point_set_to_infinity,
- ec_GFp_simple_set_Jprojective_coordinates_GFp,
- ec_GFp_simple_get_Jprojective_coordinates_GFp,
- ec_GFp_simple_point_set_affine_coordinates,
- ec_GFp_simple_point_get_affine_coordinates,
- 0,0,0,
- ec_GFp_simple_add,
- ec_GFp_simple_dbl,
- ec_GFp_simple_invert,
- ec_GFp_simple_is_at_infinity,
- ec_GFp_simple_is_on_curve,
- ec_GFp_simple_cmp,
- ec_GFp_simple_make_affine,
- ec_GFp_simple_points_make_affine,
- 0 /* mul */,
- 0 /* precompute_mult */,
- 0 /* have_precompute_mult */,
- ec_GFp_mont_field_mul,
- ec_GFp_mont_field_sqr,
- 0 /* field_div */,
- ec_GFp_mont_field_encode,
- ec_GFp_mont_field_decode,
- ec_GFp_mont_field_set_to_one };
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_prime_field,
+ .group_init = ec_GFp_mont_group_init,
+ .group_finish = ec_GFp_mont_group_finish,
+ .group_clear_finish = ec_GFp_mont_group_clear_finish,
+ .group_copy = ec_GFp_mont_group_copy,
+ .group_set_curve = ec_GFp_mont_group_set_curve,
+ .group_get_curve = ec_GFp_simple_group_get_curve,
+ .group_get_degree = ec_GFp_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GFp_simple_group_check_discriminant,
+ .point_init = ec_GFp_simple_point_init,
+ .point_finish = ec_GFp_simple_point_finish,
+ .point_clear_finish = ec_GFp_simple_point_clear_finish,
+ .point_copy = ec_GFp_simple_point_copy,
+ .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
+ .point_set_Jprojective_coordinates_GFp =
+ ec_GFp_simple_set_Jprojective_coordinates_GFp,
+ .point_get_Jprojective_coordinates_GFp =
+ ec_GFp_simple_get_Jprojective_coordinates_GFp,
+ .point_set_affine_coordinates =
+ ec_GFp_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GFp_simple_point_get_affine_coordinates,
+ .add = ec_GFp_simple_add,
+ .dbl = ec_GFp_simple_dbl,
+ .invert = ec_GFp_simple_invert,
+ .is_at_infinity = ec_GFp_simple_is_at_infinity,
+ .is_on_curve = ec_GFp_simple_is_on_curve,
+ .point_cmp = ec_GFp_simple_cmp,
+ .make_affine = ec_GFp_simple_make_affine,
+ .points_make_affine = ec_GFp_simple_points_make_affine,
+ .field_mul = ec_GFp_mont_field_mul,
+ .field_sqr = ec_GFp_mont_field_sqr,
+ .field_encode = ec_GFp_mont_field_encode,
+ .field_decode = ec_GFp_mont_field_decode,
+ .field_set_to_one = ec_GFp_mont_field_set_to_one
+ };
return &ret;
- }
+}
int ec_GFp_mont_group_init(EC_GROUP *group)
diff --git a/lib/libcrypto/ec/ecp_nist.c b/lib/libcrypto/ec/ecp_nist.c
index ac5b8142388..479cff8fc93 100644
--- a/lib/libcrypto/ec/ecp_nist.c
+++ b/lib/libcrypto/ec/ecp_nist.c
@@ -67,49 +67,48 @@
#include <openssl/obj_mac.h>
#include "ec_lcl.h"
-const EC_METHOD *EC_GFp_nist_method(void)
- {
+const EC_METHOD *
+EC_GFp_nist_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_prime_field,
- ec_GFp_simple_group_init,
- ec_GFp_simple_group_finish,
- ec_GFp_simple_group_clear_finish,
- ec_GFp_nist_group_copy,
- ec_GFp_nist_group_set_curve,
- ec_GFp_simple_group_get_curve,
- ec_GFp_simple_group_get_degree,
- ec_GFp_simple_group_check_discriminant,
- ec_GFp_simple_point_init,
- ec_GFp_simple_point_finish,
- ec_GFp_simple_point_clear_finish,
- ec_GFp_simple_point_copy,
- ec_GFp_simple_point_set_to_infinity,
- ec_GFp_simple_set_Jprojective_coordinates_GFp,
- ec_GFp_simple_get_Jprojective_coordinates_GFp,
- ec_GFp_simple_point_set_affine_coordinates,
- ec_GFp_simple_point_get_affine_coordinates,
- 0,0,0,
- ec_GFp_simple_add,
- ec_GFp_simple_dbl,
- ec_GFp_simple_invert,
- ec_GFp_simple_is_at_infinity,
- ec_GFp_simple_is_on_curve,
- ec_GFp_simple_cmp,
- ec_GFp_simple_make_affine,
- ec_GFp_simple_points_make_affine,
- 0 /* mul */,
- 0 /* precompute_mult */,
- 0 /* have_precompute_mult */,
- ec_GFp_nist_field_mul,
- ec_GFp_nist_field_sqr,
- 0 /* field_div */,
- 0 /* field_encode */,
- 0 /* field_decode */,
- 0 /* field_set_to_one */ };
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_prime_field,
+ .group_init = ec_GFp_simple_group_init,
+ .group_finish = ec_GFp_simple_group_finish,
+ .group_clear_finish = ec_GFp_simple_group_clear_finish,
+ .group_copy = ec_GFp_nist_group_copy,
+ .group_set_curve = ec_GFp_nist_group_set_curve,
+ .group_get_curve = ec_GFp_simple_group_get_curve,
+ .group_get_degree = ec_GFp_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GFp_simple_group_check_discriminant,
+ .point_init = ec_GFp_simple_point_init,
+ .point_finish = ec_GFp_simple_point_finish,
+ .point_clear_finish = ec_GFp_simple_point_clear_finish,
+ .point_copy = ec_GFp_simple_point_copy,
+ .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
+ .point_set_Jprojective_coordinates_GFp =
+ ec_GFp_simple_set_Jprojective_coordinates_GFp,
+ .point_get_Jprojective_coordinates_GFp =
+ ec_GFp_simple_get_Jprojective_coordinates_GFp,
+ .point_set_affine_coordinates =
+ ec_GFp_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GFp_simple_point_get_affine_coordinates,
+ .add = ec_GFp_simple_add,
+ .dbl = ec_GFp_simple_dbl,
+ .invert = ec_GFp_simple_invert,
+ .is_at_infinity = ec_GFp_simple_is_at_infinity,
+ .is_on_curve = ec_GFp_simple_is_on_curve,
+ .point_cmp = ec_GFp_simple_cmp,
+ .make_affine = ec_GFp_simple_make_affine,
+ .points_make_affine = ec_GFp_simple_points_make_affine,
+ .field_mul = ec_GFp_nist_field_mul,
+ .field_sqr = ec_GFp_nist_field_sqr
+ };
return &ret;
- }
+}
int ec_GFp_nist_group_copy(EC_GROUP *dest, const EC_GROUP *src)
{
diff --git a/lib/libcrypto/ec/ecp_nistp224.c b/lib/libcrypto/ec/ecp_nistp224.c
index 03f2d9c1d7b..696024a5495 100644
--- a/lib/libcrypto/ec/ecp_nistp224.c
+++ b/lib/libcrypto/ec/ecp_nistp224.c
@@ -233,51 +233,51 @@ typedef struct {
int references;
} NISTP224_PRE_COMP;
-const EC_METHOD *EC_GFp_nistp224_method(void)
- {
+const EC_METHOD *
+EC_GFp_nistp224_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_prime_field,
- ec_GFp_nistp224_group_init,
- ec_GFp_simple_group_finish,
- ec_GFp_simple_group_clear_finish,
- ec_GFp_nist_group_copy,
- ec_GFp_nistp224_group_set_curve,
- ec_GFp_simple_group_get_curve,
- ec_GFp_simple_group_get_degree,
- ec_GFp_simple_group_check_discriminant,
- ec_GFp_simple_point_init,
- ec_GFp_simple_point_finish,
- ec_GFp_simple_point_clear_finish,
- ec_GFp_simple_point_copy,
- ec_GFp_simple_point_set_to_infinity,
- ec_GFp_simple_set_Jprojective_coordinates_GFp,
- ec_GFp_simple_get_Jprojective_coordinates_GFp,
- ec_GFp_simple_point_set_affine_coordinates,
- ec_GFp_nistp224_point_get_affine_coordinates,
- 0 /* point_set_compressed_coordinates */,
- 0 /* point2oct */,
- 0 /* oct2point */,
- ec_GFp_simple_add,
- ec_GFp_simple_dbl,
- ec_GFp_simple_invert,
- ec_GFp_simple_is_at_infinity,
- ec_GFp_simple_is_on_curve,
- ec_GFp_simple_cmp,
- ec_GFp_simple_make_affine,
- ec_GFp_simple_points_make_affine,
- ec_GFp_nistp224_points_mul,
- ec_GFp_nistp224_precompute_mult,
- ec_GFp_nistp224_have_precompute_mult,
- ec_GFp_nist_field_mul,
- ec_GFp_nist_field_sqr,
- 0 /* field_div */,
- 0 /* field_encode */,
- 0 /* field_decode */,
- 0 /* field_set_to_one */ };
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_prime_field,
+ .group_init = ec_GFp_nistp224_group_init,
+ .group_finish = ec_GFp_simple_group_finish,
+ .group_clear_finish = ec_GFp_simple_group_clear_finish,
+ .group_copy = ec_GFp_nist_group_copy,
+ .group_set_curve = ec_GFp_nistp224_group_set_curve,
+ .group_get_curve = ec_GFp_simple_group_get_curve,
+ .group_get_degree = ec_GFp_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GFp_simple_group_check_discriminant,
+ .point_init = ec_GFp_simple_point_init,
+ .point_finish = ec_GFp_simple_point_finish,
+ .point_clear_finish = ec_GFp_simple_point_clear_finish,
+ .point_copy = ec_GFp_simple_point_copy,
+ .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
+ .point_set_Jprojective_coordinates_GFp =
+ ec_GFp_simple_set_Jprojective_coordinates_GFp,
+ .point_get_Jprojective_coordinates_GFp =
+ ec_GFp_simple_get_Jprojective_coordinates_GFp,
+ .point_set_affine_coordinates =
+ ec_GFp_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GFp_nistp224_point_get_affine_coordinates,
+ .add = ec_GFp_simple_add,
+ .dbl = ec_GFp_simple_dbl,
+ .invert = ec_GFp_simple_invert,
+ .is_at_infinity = ec_GFp_simple_is_at_infinity,
+ .is_on_curve = ec_GFp_simple_is_on_curve,
+ .point_cmp = ec_GFp_simple_cmp,
+ .make_affine = ec_GFp_simple_make_affine,
+ .points_make_affine = ec_GFp_simple_points_make_affine,
+ .mul = ec_GFp_nistp224_points_mul,
+ .precompute_mult = ec_GFp_nistp224_precompute_mult,
+ .have_precompute_mult = ec_GFp_nistp224_have_precompute_mult,
+ .field_mul = ec_GFp_nist_field_mul,
+ .field_sqr = ec_GFp_nist_field_sqr
+ };
return &ret;
- }
+}
/* Helper functions to convert field elements to/from internal representation */
static void bin28_to_felem(felem out, const u8 in[28])
diff --git a/lib/libcrypto/ec/ecp_nistp256.c b/lib/libcrypto/ec/ecp_nistp256.c
index 947fb7eee00..132ca0d2507 100644
--- a/lib/libcrypto/ec/ecp_nistp256.c
+++ b/lib/libcrypto/ec/ecp_nistp256.c
@@ -1613,51 +1613,51 @@ typedef struct {
int references;
} NISTP256_PRE_COMP;
-const EC_METHOD *EC_GFp_nistp256_method(void)
- {
+const EC_METHOD *
+EC_GFp_nistp256_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_prime_field,
- ec_GFp_nistp256_group_init,
- ec_GFp_simple_group_finish,
- ec_GFp_simple_group_clear_finish,
- ec_GFp_nist_group_copy,
- ec_GFp_nistp256_group_set_curve,
- ec_GFp_simple_group_get_curve,
- ec_GFp_simple_group_get_degree,
- ec_GFp_simple_group_check_discriminant,
- ec_GFp_simple_point_init,
- ec_GFp_simple_point_finish,
- ec_GFp_simple_point_clear_finish,
- ec_GFp_simple_point_copy,
- ec_GFp_simple_point_set_to_infinity,
- ec_GFp_simple_set_Jprojective_coordinates_GFp,
- ec_GFp_simple_get_Jprojective_coordinates_GFp,
- ec_GFp_simple_point_set_affine_coordinates,
- ec_GFp_nistp256_point_get_affine_coordinates,
- 0 /* point_set_compressed_coordinates */,
- 0 /* point2oct */,
- 0 /* oct2point */,
- ec_GFp_simple_add,
- ec_GFp_simple_dbl,
- ec_GFp_simple_invert,
- ec_GFp_simple_is_at_infinity,
- ec_GFp_simple_is_on_curve,
- ec_GFp_simple_cmp,
- ec_GFp_simple_make_affine,
- ec_GFp_simple_points_make_affine,
- ec_GFp_nistp256_points_mul,
- ec_GFp_nistp256_precompute_mult,
- ec_GFp_nistp256_have_precompute_mult,
- ec_GFp_nist_field_mul,
- ec_GFp_nist_field_sqr,
- 0 /* field_div */,
- 0 /* field_encode */,
- 0 /* field_decode */,
- 0 /* field_set_to_one */ };
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_prime_field,
+ .group_init = ec_GFp_nistp256_group_init,
+ .group_finish = ec_GFp_simple_group_finish,
+ .group_clear_finish = ec_GFp_simple_group_clear_finish,
+ .group_copy = ec_GFp_nist_group_copy,
+ .group_set_curve = ec_GFp_nistp256_group_set_curve,
+ .group_get_curve = ec_GFp_simple_group_get_curve,
+ .group_get_degree = ec_GFp_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GFp_simple_group_check_discriminant,
+ .point_init = ec_GFp_simple_point_init,
+ .point_finish = ec_GFp_simple_point_finish,
+ .point_clear_finish = ec_GFp_simple_point_clear_finish,
+ .point_copy = ec_GFp_simple_point_copy,
+ .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
+ .point_set_Jprojective_coordinates_GFp =
+ ec_GFp_simple_set_Jprojective_coordinates_GFp,
+ .point_get_Jprojective_coordinates_GFp =
+ ec_GFp_simple_get_Jprojective_coordinates_GFp,
+ .point_set_affine_coordinates =
+ ec_GFp_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GFp_nistp256_point_get_affine_coordinates,
+ .add = ec_GFp_simple_add,
+ .dbl = ec_GFp_simple_dbl,
+ .invert = ec_GFp_simple_invert,
+ .is_at_infinity = ec_GFp_simple_is_at_infinity,
+ .is_on_curve = ec_GFp_simple_is_on_curve,
+ .point_cmp = ec_GFp_simple_cmp,
+ .make_affine = ec_GFp_simple_make_affine,
+ .points_make_affine = ec_GFp_simple_points_make_affine,
+ .mul = ec_GFp_nistp256_points_mul,
+ .precompute_mult = ec_GFp_nistp256_precompute_mult,
+ .have_precompute_mult = ec_GFp_nistp256_have_precompute_mult,
+ .field_mul = ec_GFp_nist_field_mul,
+ .field_sqr = ec_GFp_nist_field_sqr
+ };
return &ret;
- }
+}
/******************************************************************************/
/* FUNCTIONS TO MANAGE PRECOMPUTATION
diff --git a/lib/libcrypto/ec/ecp_nistp521.c b/lib/libcrypto/ec/ecp_nistp521.c
index 24eb0329513..c34c38b7e83 100644
--- a/lib/libcrypto/ec/ecp_nistp521.c
+++ b/lib/libcrypto/ec/ecp_nistp521.c
@@ -1479,51 +1479,51 @@ typedef struct {
int references;
} NISTP521_PRE_COMP;
-const EC_METHOD *EC_GFp_nistp521_method(void)
- {
+const EC_METHOD *
+EC_GFp_nistp521_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_prime_field,
- ec_GFp_nistp521_group_init,
- ec_GFp_simple_group_finish,
- ec_GFp_simple_group_clear_finish,
- ec_GFp_nist_group_copy,
- ec_GFp_nistp521_group_set_curve,
- ec_GFp_simple_group_get_curve,
- ec_GFp_simple_group_get_degree,
- ec_GFp_simple_group_check_discriminant,
- ec_GFp_simple_point_init,
- ec_GFp_simple_point_finish,
- ec_GFp_simple_point_clear_finish,
- ec_GFp_simple_point_copy,
- ec_GFp_simple_point_set_to_infinity,
- ec_GFp_simple_set_Jprojective_coordinates_GFp,
- ec_GFp_simple_get_Jprojective_coordinates_GFp,
- ec_GFp_simple_point_set_affine_coordinates,
- ec_GFp_nistp521_point_get_affine_coordinates,
- 0 /* point_set_compressed_coordinates */,
- 0 /* point2oct */,
- 0 /* oct2point */,
- ec_GFp_simple_add,
- ec_GFp_simple_dbl,
- ec_GFp_simple_invert,
- ec_GFp_simple_is_at_infinity,
- ec_GFp_simple_is_on_curve,
- ec_GFp_simple_cmp,
- ec_GFp_simple_make_affine,
- ec_GFp_simple_points_make_affine,
- ec_GFp_nistp521_points_mul,
- ec_GFp_nistp521_precompute_mult,
- ec_GFp_nistp521_have_precompute_mult,
- ec_GFp_nist_field_mul,
- ec_GFp_nist_field_sqr,
- 0 /* field_div */,
- 0 /* field_encode */,
- 0 /* field_decode */,
- 0 /* field_set_to_one */ };
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_prime_field,
+ .group_init = ec_GFp_nistp521_group_init,
+ .group_finish = ec_GFp_simple_group_finish,
+ .group_clear_finish = ec_GFp_simple_group_clear_finish,
+ .group_copy = ec_GFp_nist_group_copy,
+ .group_set_curve = ec_GFp_nistp521_group_set_curve,
+ .group_get_curve = ec_GFp_simple_group_get_curve,
+ .group_get_degree = ec_GFp_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GFp_simple_group_check_discriminant,
+ .point_init = ec_GFp_simple_point_init,
+ .point_finish = ec_GFp_simple_point_finish,
+ .point_clear_finish = ec_GFp_simple_point_clear_finish,
+ .point_copy = ec_GFp_simple_point_copy,
+ .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
+ .point_set_Jprojective_coordinates_GFp =
+ ec_GFp_simple_set_Jprojective_coordinates_GFp,
+ .point_get_Jprojective_coordinates_GFp =
+ ec_GFp_simple_get_Jprojective_coordinates_GFp,
+ .point_set_affine_coordinates =
+ ec_GFp_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GFp_nistp521_point_get_affine_coordinates,
+ .add = ec_GFp_simple_add,
+ .dbl = ec_GFp_simple_dbl,
+ .invert = ec_GFp_simple_invert,
+ .is_at_infinity = ec_GFp_simple_is_at_infinity,
+ .is_on_curve = ec_GFp_simple_is_on_curve,
+ .point_cmp = ec_GFp_simple_cmp,
+ .make_affine = ec_GFp_simple_make_affine,
+ .points_make_affine = ec_GFp_simple_points_make_affine,
+ .mul = ec_GFp_nistp521_points_mul,
+ .precompute_mult = ec_GFp_nistp521_precompute_mult,
+ .have_precompulte_mult = ec_GFp_nistp521_have_precompute_mult,
+ .field_mul = ec_GFp_nist_field_mul,
+ .field_sqr = ec_GFp_nist_field_sqr
+ };
return &ret;
- }
+}
/******************************************************************************/
diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c
index a1467528170..c99348f08f5 100644
--- a/lib/libcrypto/ec/ecp_smpl.c
+++ b/lib/libcrypto/ec/ecp_smpl.c
@@ -66,49 +66,48 @@
#include "ec_lcl.h"
-const EC_METHOD *EC_GFp_simple_method(void)
- {
+const EC_METHOD *
+EC_GFp_simple_method(void)
+{
static const EC_METHOD ret = {
- EC_FLAGS_DEFAULT_OCT,
- NID_X9_62_prime_field,
- ec_GFp_simple_group_init,
- ec_GFp_simple_group_finish,
- ec_GFp_simple_group_clear_finish,
- ec_GFp_simple_group_copy,
- ec_GFp_simple_group_set_curve,
- ec_GFp_simple_group_get_curve,
- ec_GFp_simple_group_get_degree,
- ec_GFp_simple_group_check_discriminant,
- ec_GFp_simple_point_init,
- ec_GFp_simple_point_finish,
- ec_GFp_simple_point_clear_finish,
- ec_GFp_simple_point_copy,
- ec_GFp_simple_point_set_to_infinity,
- ec_GFp_simple_set_Jprojective_coordinates_GFp,
- ec_GFp_simple_get_Jprojective_coordinates_GFp,
- ec_GFp_simple_point_set_affine_coordinates,
- ec_GFp_simple_point_get_affine_coordinates,
- 0,0,0,
- ec_GFp_simple_add,
- ec_GFp_simple_dbl,
- ec_GFp_simple_invert,
- ec_GFp_simple_is_at_infinity,
- ec_GFp_simple_is_on_curve,
- ec_GFp_simple_cmp,
- ec_GFp_simple_make_affine,
- ec_GFp_simple_points_make_affine,
- 0 /* mul */,
- 0 /* precompute_mult */,
- 0 /* have_precompute_mult */,
- ec_GFp_simple_field_mul,
- ec_GFp_simple_field_sqr,
- 0 /* field_div */,
- 0 /* field_encode */,
- 0 /* field_decode */,
- 0 /* field_set_to_one */ };
+ .flags = EC_FLAGS_DEFAULT_OCT,
+ .field_type = NID_X9_62_prime_field,
+ .group_init = ec_GFp_simple_group_init,
+ .group_finish = ec_GFp_simple_group_finish,
+ .group_clear_finish = ec_GFp_simple_group_clear_finish,
+ .group_copy = ec_GFp_simple_group_copy,
+ .group_set_curve = ec_GFp_simple_group_set_curve,
+ .group_get_curve = ec_GFp_simple_group_get_curve,
+ .group_get_degree = ec_GFp_simple_group_get_degree,
+ .group_check_discriminant =
+ ec_GFp_simple_group_check_discriminant,
+ .point_init = ec_GFp_simple_point_init,
+ .point_finish = ec_GFp_simple_point_finish,
+ .point_clear_finish = ec_GFp_simple_point_clear_finish,
+ .point_copy = ec_GFp_simple_point_copy,
+ .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
+ .point_set_Jprojective_coordinates_GFp =
+ ec_GFp_simple_set_Jprojective_coordinates_GFp,
+ .point_get_Jprojective_coordinates_GFp =
+ ec_GFp_simple_get_Jprojective_coordinates_GFp,
+ .point_set_affine_coordinates =
+ ec_GFp_simple_point_set_affine_coordinates,
+ .point_get_affine_coordinates =
+ ec_GFp_simple_point_get_affine_coordinates,
+ .add = ec_GFp_simple_add,
+ .dbl = ec_GFp_simple_dbl,
+ .invert = ec_GFp_simple_invert,
+ .is_at_infinity = ec_GFp_simple_is_at_infinity,
+ .is_on_curve = ec_GFp_simple_is_on_curve,
+ .point_cmp = ec_GFp_simple_cmp,
+ .make_affine = ec_GFp_simple_make_affine,
+ .points_make_affine = ec_GFp_simple_points_make_affine,
+ .field_mul = ec_GFp_simple_field_mul,
+ .field_sqr = ec_GFp_simple_field_sqr
+ };
return &ret;
- }
+}
/* Most method functions in this file are designed to work with