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/engine/eng_padlock.c | 9 +++------ src/lib/libcrypto/engine/eng_rdrand.c | 14 +++++--------- src/lib/libcrypto/engine/eng_rsax.c | 22 ++++++--------------- src/lib/libcrypto/engine/hw_cryptodev.c | 34 +++------------------------------ 4 files changed, 17 insertions(+), 62 deletions(-) (limited to 'src/lib/libcrypto/engine') diff --git a/src/lib/libcrypto/engine/eng_padlock.c b/src/lib/libcrypto/engine/eng_padlock.c index d5d9a16bf2..c27181ba75 100644 --- a/src/lib/libcrypto/engine/eng_padlock.c +++ b/src/lib/libcrypto/engine/eng_padlock.c @@ -1086,12 +1086,9 @@ padlock_rand_status(void) /* Prepare structure for registration */ static RAND_METHOD padlock_rand = { - NULL, /* seed */ - padlock_rand_bytes, /* bytes */ - NULL, /* cleanup */ - NULL, /* add */ - padlock_rand_bytes, /* pseudorand */ - padlock_rand_status, /* rand status */ + .bytes = padlock_rand_bytes, + .pseudorand = padlock_rand_bytes, + .status = padlock_rand_status }; #else /* !COMPILE_HW_PADLOCK */ diff --git a/src/lib/libcrypto/engine/eng_rdrand.c b/src/lib/libcrypto/engine/eng_rdrand.c index 4e9e91d54b..ba1b5bfbff 100644 --- a/src/lib/libcrypto/engine/eng_rdrand.c +++ b/src/lib/libcrypto/engine/eng_rdrand.c @@ -84,15 +84,11 @@ static int get_random_bytes (unsigned char *buf, int num) static int random_status (void) { return 1; } -static RAND_METHOD rdrand_meth = - { - NULL, /* seed */ - get_random_bytes, - NULL, /* cleanup */ - NULL, /* add */ - get_random_bytes, - random_status, - }; +static RAND_METHOD rdrand_meth = { + .bytes = get_random_bytes, + .pseudorand = get_random_bytes, + .status = random_status +}; static int rdrand_init(ENGINE *e) { return 1; } diff --git a/src/lib/libcrypto/engine/eng_rsax.c b/src/lib/libcrypto/engine/eng_rsax.c index fa9159499d..c0f6851601 100644 --- a/src/lib/libcrypto/engine/eng_rsax.c +++ b/src/lib/libcrypto/engine/eng_rsax.c @@ -116,22 +116,12 @@ static const ENGINE_CMD_DEFN e_rsax_cmd_defns[] = { #ifndef OPENSSL_NO_RSA /* Our internal RSA_METHOD that we provide pointers to */ -static RSA_METHOD e_rsax_rsa = - { - "Intel RSA-X method", - NULL, - NULL, - NULL, - NULL, - e_rsax_rsa_mod_exp, - NULL, - NULL, - e_rsax_rsa_finish, - RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE, - NULL, - NULL, - NULL - }; +static RSA_METHOD e_rsax_rsa = { + .name = "Intel RSA-X method", + .rsa_mod_exp = e_rsax_rsa_mod_exp, + .finish = e_rsax_rsa_finish, + .flags = RSA_FLAG_CACHE_PUBLIC|RSA_FLAG_CACHE_PRIVATE, +}; #endif /* Constants used when creating the ENGINE */ diff --git a/src/lib/libcrypto/engine/hw_cryptodev.c b/src/lib/libcrypto/engine/hw_cryptodev.c index 190dcc4f75..9b24511b69 100644 --- a/src/lib/libcrypto/engine/hw_cryptodev.c +++ b/src/lib/libcrypto/engine/hw_cryptodev.c @@ -1039,19 +1039,7 @@ err: } static RSA_METHOD cryptodev_rsa = { - "cryptodev RSA method", - NULL, /* rsa_pub_enc */ - NULL, /* rsa_pub_dec */ - NULL, /* rsa_priv_enc */ - NULL, /* rsa_priv_dec */ - NULL, - NULL, - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - NULL, /* rsa_sign */ - NULL /* rsa_verify */ + .name = "cryptodev RSA method" }; static int @@ -1181,16 +1169,7 @@ err: } static DSA_METHOD cryptodev_dsa = { - "cryptodev DSA method", - NULL, - NULL, /* dsa_sign_setup */ - NULL, - NULL, /* dsa_mod_exp */ - NULL, - NULL, /* init */ - NULL, /* finish */ - 0, /* flags */ - NULL /* app_data */ + .name = "cryptodev DSA method" }; static int @@ -1244,14 +1223,7 @@ err: } static DH_METHOD cryptodev_dh = { - "cryptodev DH method", - NULL, /* cryptodev_dh_generate_key */ - NULL, - NULL, - NULL, - NULL, - 0, /* flags */ - NULL /* app_data */ + .name = "cryptodev DH method" }; /* -- cgit v1.2.3-55-g6feb