From 45bb7f0ae87ddf787dd06d515db9afb04a74bf6c Mon Sep 17 00:00:00 2001 From: miod <> Date: Sun, 27 Apr 2014 20:26:49 +0000 Subject: 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@ --- src/lib/libcrypto/dh/dh_ameth.c | 60 +++++++++++++++++++---------------------- src/lib/libcrypto/dh/dh_key.c | 15 +++++------ src/lib/libcrypto/dh/dh_pmeth.c | 42 +++++++++-------------------- 3 files changed, 46 insertions(+), 71 deletions(-) (limited to 'src/lib/libcrypto/dh') diff --git a/src/lib/libcrypto/dh/dh_ameth.c b/src/lib/libcrypto/dh/dh_ameth.c index d39f4b373d..a22614ae0a 100644 --- a/src/lib/libcrypto/dh/dh_ameth.c +++ b/src/lib/libcrypto/dh/dh_ameth.c @@ -466,36 +466,32 @@ int DHparams_print(BIO *bp, const DH *x) return do_dh_print(bp, x, 4, NULL, 0); } -const EVP_PKEY_ASN1_METHOD dh_asn1_meth = - { - EVP_PKEY_DH, - EVP_PKEY_DH, - 0, - - "DH", - "OpenSSL PKCS#3 DH method", - - dh_pub_decode, - dh_pub_encode, - dh_pub_cmp, - dh_public_print, - - dh_priv_decode, - dh_priv_encode, - dh_private_print, - - int_dh_size, - dh_bits, - - dh_param_decode, - dh_param_encode, - dh_missing_parameters, - dh_copy_parameters, - dh_cmp_parameters, - dh_param_print, - 0, - - int_dh_free, - 0 - }; +const EVP_PKEY_ASN1_METHOD dh_asn1_meth = { + .pkey_id = EVP_PKEY_DH, + .pkey_base_id = EVP_PKEY_DH, + + .pem_str = "DH", + .info = "OpenSSL PKCS#3 DH method", + + .pub_decode = dh_pub_decode, + .pub_encode = dh_pub_encode, + .pub_cmp = dh_pub_cmp, + .pub_print = dh_public_print, + + .priv_decode = dh_priv_decode, + .priv_encode = dh_priv_encode, + .priv_print = dh_private_print, + + .pkey_size = int_dh_size, + .pkey_bits = dh_bits, + + .param_decode = dh_param_decode, + .param_encode = dh_param_encode, + .param_missing = dh_missing_parameters, + .param_copy = dh_copy_parameters, + .param_cmp = dh_cmp_parameters, + .param_print = dh_param_print, + + .pkey_free = int_dh_free, +}; diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c index 9596270f7d..91352a9fbf 100644 --- a/src/lib/libcrypto/dh/dh_key.c +++ b/src/lib/libcrypto/dh/dh_key.c @@ -82,15 +82,12 @@ int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) } static DH_METHOD dh_ossl = { -"OpenSSL DH Method", -generate_key, -compute_key, -dh_bn_mod_exp, -dh_init, -dh_finish, -0, -NULL, -NULL + .name = "OpenSSL DH Method", + .generate_key = generate_key, + .compute_key = compute_key, + .bn_mod_exp = dh_bn_mod_exp, + .init = dh_init, + .finish = dh_finish, }; const DH_METHOD *DH_OpenSSL(void) diff --git a/src/lib/libcrypto/dh/dh_pmeth.c b/src/lib/libcrypto/dh/dh_pmeth.c index ec4553c0a8..c359bb4d2b 100644 --- a/src/lib/libcrypto/dh/dh_pmeth.c +++ b/src/lib/libcrypto/dh/dh_pmeth.c @@ -217,38 +217,20 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen) return 1; } -const EVP_PKEY_METHOD dh_pkey_meth = - { - EVP_PKEY_DH, - EVP_PKEY_FLAG_AUTOARGLEN, - pkey_dh_init, - pkey_dh_copy, - pkey_dh_cleanup, - - 0, - pkey_dh_paramgen, - - 0, - pkey_dh_keygen, - - 0, - 0, - - 0, - 0, - - 0,0, - - 0,0,0,0, +const EVP_PKEY_METHOD dh_pkey_meth = { + .pkey_id = EVP_PKEY_DH, + .flags = EVP_PKEY_FLAG_AUTOARGLEN, - 0,0, + .init = pkey_dh_init, + .copy = pkey_dh_copy, + .cleanup = pkey_dh_cleanup, - 0,0, + .paramgen = pkey_dh_paramgen, - 0, - pkey_dh_derive, + .keygen = pkey_dh_keygen, - pkey_dh_ctrl, - pkey_dh_ctrl_str + .derive = pkey_dh_derive, - }; + .ctrl = pkey_dh_ctrl, + .ctrl_str = pkey_dh_ctrl_str +}; -- cgit v1.2.3-55-g6feb