From: miod Date: Sun, 27 Apr 2014 20:26:46 +0000 (+0000) Subject: Use C99 initializers for the various FOO_METHOD structs. More readable, and X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e402ce74af92e11cf51406acbd53f28852df7c32;p=openbsd 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@ --- diff --git a/lib/libcrypto/asn1/bio_asn1.c b/lib/libcrypto/asn1/bio_asn1.c index 36b82758ed3..327355eeda5 100644 --- a/lib/libcrypto/asn1/bio_asn1.c +++ b/lib/libcrypto/asn1/bio_asn1.c @@ -124,16 +124,16 @@ static int asn1_bio_setup_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_bio_state_t other_state); static BIO_METHOD methods_asn1 = { - BIO_TYPE_ASN1, - "asn1", - asn1_bio_write, - asn1_bio_read, - asn1_bio_puts, - asn1_bio_gets, - asn1_bio_ctrl, - asn1_bio_new, - asn1_bio_free, - asn1_bio_callback_ctrl, + .type = BIO_TYPE_ASN1, + .name = "asn1", + .bwrite = asn1_bio_write, + .bread = asn1_bio_read, + .bputs = asn1_bio_puts, + .bgets = asn1_bio_gets, + .ctrl = asn1_bio_ctrl, + .create = asn1_bio_new, + .destroy = asn1_bio_free, + .callback_ctrl = asn1_bio_callback_ctrl }; BIO_METHOD * diff --git a/lib/libcrypto/asn1/x_crl.c b/lib/libcrypto/asn1/x_crl.c index 674cca4a1c9..097a39c4d16 100644 --- a/lib/libcrypto/asn1/x_crl.c +++ b/lib/libcrypto/asn1/x_crl.c @@ -78,11 +78,8 @@ static int def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer); static X509_CRL_METHOD int_crl_meth = { - 0, - 0, - 0, - def_crl_lookup, - def_crl_verify + .crl_lookup = def_crl_lookup, + .crl_verify = def_crl_verify }; static const X509_CRL_METHOD *default_crl_method = &int_crl_meth; diff --git a/lib/libcrypto/bio/bf_buff.c b/lib/libcrypto/bio/bf_buff.c index 99be1a629e5..e96da40a58a 100644 --- a/lib/libcrypto/bio/bf_buff.c +++ b/lib/libcrypto/bio/bf_buff.c @@ -72,16 +72,16 @@ static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define DEFAULT_BUFFER_SIZE 4096 static BIO_METHOD methods_buffer = { - BIO_TYPE_BUFFER, - "buffer", - buffer_write, - buffer_read, - buffer_puts, - buffer_gets, - buffer_ctrl, - buffer_new, - buffer_free, - buffer_callback_ctrl, + .type = BIO_TYPE_BUFFER, + .name = "buffer", + .bwrite = buffer_write, + .bread = buffer_read, + .bputs = buffer_puts, + .bgets = buffer_gets, + .ctrl = buffer_ctrl, + .create = buffer_new, + .destroy = buffer_free, + .callback_ctrl = buffer_callback_ctrl }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bf_lbuf.c b/lib/libcrypto/bio/bf_lbuf.c index f0bd0d709ea..54c370d0380 100644 --- a/lib/libcrypto/bio/bf_lbuf.c +++ b/lib/libcrypto/bio/bf_lbuf.c @@ -77,16 +77,16 @@ static long linebuffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); /* #define DEBUG */ static BIO_METHOD methods_linebuffer = { - BIO_TYPE_LINEBUFFER, - "linebuffer", - linebuffer_write, - linebuffer_read, - linebuffer_puts, - linebuffer_gets, - linebuffer_ctrl, - linebuffer_new, - linebuffer_free, - linebuffer_callback_ctrl, + .type = BIO_TYPE_LINEBUFFER, + .name = "linebuffer", + .bwrite = linebuffer_write, + .bread = linebuffer_read, + .bputs = linebuffer_puts, + .bgets = linebuffer_gets, + .ctrl = linebuffer_ctrl, + .create = linebuffer_new, + .destroy = linebuffer_free, + .callback_ctrl = linebuffer_callback_ctrl }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bf_nbio.c b/lib/libcrypto/bio/bf_nbio.c index 048e6892ccc..5a0f6b276a5 100644 --- a/lib/libcrypto/bio/bf_nbio.c +++ b/lib/libcrypto/bio/bf_nbio.c @@ -81,16 +81,16 @@ typedef struct nbio_test_st { } NBIO_TEST; static BIO_METHOD methods_nbiof = { - BIO_TYPE_NBIO_TEST, - "non-blocking IO test filter", - nbiof_write, - nbiof_read, - nbiof_puts, - nbiof_gets, - nbiof_ctrl, - nbiof_new, - nbiof_free, - nbiof_callback_ctrl, + .type = BIO_TYPE_NBIO_TEST, + .name = "non-blocking IO test filter", + .bwrite = nbiof_write, + .bread = nbiof_read, + .bputs = nbiof_puts, + .bgets = nbiof_gets, + .ctrl = nbiof_ctrl, + .create = nbiof_new, + .destroy = nbiof_free, + .callback_ctrl = nbiof_callback_ctrl }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bf_null.c b/lib/libcrypto/bio/bf_null.c index 3bba2afe982..7554ed9cf5a 100644 --- a/lib/libcrypto/bio/bf_null.c +++ b/lib/libcrypto/bio/bf_null.c @@ -74,16 +74,16 @@ static int nullf_free(BIO *data); static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); static BIO_METHOD methods_nullf = { - BIO_TYPE_NULL_FILTER, - "NULL filter", - nullf_write, - nullf_read, - nullf_puts, - nullf_gets, - nullf_ctrl, - nullf_new, - nullf_free, - nullf_callback_ctrl, + .type = BIO_TYPE_NULL_FILTER, + .name = "NULL filter", + .bwrite = nullf_write, + .bread = nullf_read, + .bputs = nullf_puts, + .bgets = nullf_gets, + .ctrl = nullf_ctrl, + .create = nullf_new, + .destroy = nullf_free, + .callback_ctrl = nullf_callback_ctrl }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bss_acpt.c b/lib/libcrypto/bio/bss_acpt.c index 916af3cb20e..943d3d9d961 100644 --- a/lib/libcrypto/bio/bss_acpt.c +++ b/lib/libcrypto/bio/bss_acpt.c @@ -98,16 +98,14 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a); #define ACPT_S_OK 3 static BIO_METHOD methods_acceptp = { - BIO_TYPE_ACCEPT, - "socket accept", - acpt_write, - acpt_read, - acpt_puts, - NULL, /* connect_gets, */ - acpt_ctrl, - acpt_new, - acpt_free, - NULL, + .type = BIO_TYPE_ACCEPT, + .name = "socket accept", + .bwrite = acpt_write, + .bread = acpt_read, + .bputs = acpt_puts, + .ctrl = acpt_ctrl, + .create = acpt_new, + .destroy = acpt_free }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bss_bio.c b/lib/libcrypto/bio/bss_bio.c index d31e59872ee..1a17cdf2755 100644 --- a/lib/libcrypto/bio/bss_bio.c +++ b/lib/libcrypto/bio/bss_bio.c @@ -94,16 +94,14 @@ static int bio_make_pair(BIO *bio1, BIO *bio2); static void bio_destroy_pair(BIO *bio); static BIO_METHOD methods_biop = { - BIO_TYPE_BIO, - "BIO pair", - bio_write, - bio_read, - bio_puts, - NULL /* no bio_gets */, - bio_ctrl, - bio_new, - bio_free, - NULL /* no bio_callback_ctrl */ + .type = BIO_TYPE_BIO, + .name = "BIO pair", + .bwrite = bio_write, + .bread = bio_read, + .bputs = bio_puts, + .ctrl = bio_ctrl, + .create = bio_new, + .destroy = bio_free }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bss_conn.c b/lib/libcrypto/bio/bss_conn.c index d7a8619b38e..7ed8f1fe31e 100644 --- a/lib/libcrypto/bio/bss_conn.c +++ b/lib/libcrypto/bio/bss_conn.c @@ -103,16 +103,15 @@ BIO_CONNECT *BIO_CONNECT_new(void); void BIO_CONNECT_free(BIO_CONNECT *a); static BIO_METHOD methods_connectp = { - BIO_TYPE_CONNECT, - "socket connect", - conn_write, - conn_read, - conn_puts, - NULL, /* connect_gets, */ - conn_ctrl, - conn_new, - conn_free, - conn_callback_ctrl, + .type = BIO_TYPE_CONNECT, + .name = "socket connect", + .bwrite = conn_write, + .bread = conn_read, + .bputs = conn_puts, + .ctrl = conn_ctrl, + .create = conn_new, + .destroy = conn_free, + .callback_ctrl = conn_callback_ctrl }; static int diff --git a/lib/libcrypto/bio/bss_dgram.c b/lib/libcrypto/bio/bss_dgram.c index 8c08eff3520..8f7439c51e6 100644 --- a/lib/libcrypto/bio/bss_dgram.c +++ b/lib/libcrypto/bio/bss_dgram.c @@ -106,30 +106,26 @@ static int BIO_dgram_should_retry(int s); static void get_current_time(struct timeval *t); static BIO_METHOD methods_dgramp = { - BIO_TYPE_DGRAM, - "datagram socket", - dgram_write, - dgram_read, - dgram_puts, - NULL, /* dgram_gets, */ - dgram_ctrl, - dgram_new, - dgram_free, - NULL, + .type = BIO_TYPE_DGRAM, + .name = "datagram socket", + .bwrite = dgram_write, + .bread = dgram_read, + .bputs = dgram_puts, + .ctrl = dgram_ctrl, + .create = dgram_new, + .destroy = dgram_free }; #ifndef OPENSSL_NO_SCTP static BIO_METHOD methods_dgramp_sctp = { - BIO_TYPE_DGRAM_SCTP, - "datagram sctp socket", - dgram_sctp_write, - dgram_sctp_read, - dgram_sctp_puts, - NULL, /* dgram_gets, */ - dgram_sctp_ctrl, - dgram_sctp_new, - dgram_sctp_free, - NULL, + .type = BIO_TYPE_DGRAM_SCTP, + .name = "datagram sctp socket", + .bwrite = dgram_sctp_write, + .bread = dgram_sctp_read, + .bputs = dgram_sctp_puts, + .ctrl = dgram_sctp_ctrl, + .create = dgram_sctp_new, + .destroy = dgram_sctp_free }; #endif diff --git a/lib/libcrypto/bio/bss_fd.c b/lib/libcrypto/bio/bss_fd.c index 8ea80f1f65c..04a88a155b7 100644 --- a/lib/libcrypto/bio/bss_fd.c +++ b/lib/libcrypto/bio/bss_fd.c @@ -79,15 +79,15 @@ static int fd_free(BIO *data); int BIO_fd_should_retry(int s); static BIO_METHOD methods_fdp = { - BIO_TYPE_FD, "file descriptor", - fd_write, - fd_read, - fd_puts, - fd_gets, - fd_ctrl, - fd_new, - fd_free, - NULL, + .type = BIO_TYPE_FD, + .name = "file descriptor", + .bwrite = fd_write, + .bread = fd_read, + .bputs = fd_puts, + .bgets = fd_gets, + .ctrl = fd_ctrl, + .create = fd_new, + .destroy = fd_free }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bss_file.c b/lib/libcrypto/bio/bss_file.c index 6d5444f666a..6f81a45a475 100644 --- a/lib/libcrypto/bio/bss_file.c +++ b/lib/libcrypto/bio/bss_file.c @@ -100,16 +100,15 @@ static int file_new(BIO *h); static int file_free(BIO *data); static BIO_METHOD methods_filep = { - BIO_TYPE_FILE, - "FILE pointer", - file_write, - file_read, - file_puts, - file_gets, - file_ctrl, - file_new, - file_free, - NULL, + .type = BIO_TYPE_FILE, + .name = "FILE pointer", + .bwrite = file_write, + .bread = file_read, + .bputs = file_puts, + .bgets = file_gets, + .ctrl = file_ctrl, + .create = file_new, + .destroy = file_free }; BIO * diff --git a/lib/libcrypto/bio/bss_log.c b/lib/libcrypto/bio/bss_log.c index 6aa2d8b0a49..ac1cbc5087b 100644 --- a/lib/libcrypto/bio/bss_log.c +++ b/lib/libcrypto/bio/bss_log.c @@ -86,15 +86,13 @@ static void xsyslog(BIO* bp, int priority, const char* string); static void xcloselog(BIO* bp); static BIO_METHOD methods_slg = { - BIO_TYPE_MEM, "syslog", - slg_write, - NULL, - slg_puts, - NULL, - slg_ctrl, - slg_new, - slg_free, - NULL, + .type = BIO_TYPE_MEM, + .name = "syslog", + .bwrite = slg_write, + .bputs = slg_puts, + .ctrl = slg_ctrl, + .create = slg_new, + .destroy = slg_free }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bss_mem.c b/lib/libcrypto/bio/bss_mem.c index 1a477c12be3..b147a8eccb7 100644 --- a/lib/libcrypto/bio/bss_mem.c +++ b/lib/libcrypto/bio/bss_mem.c @@ -70,16 +70,15 @@ static int mem_new(BIO *h); static int mem_free(BIO *data); static BIO_METHOD mem_method = { - BIO_TYPE_MEM, - "memory buffer", - mem_write, - mem_read, - mem_puts, - mem_gets, - mem_ctrl, - mem_new, - mem_free, - NULL, + .type = BIO_TYPE_MEM, + .name = "memory buffer", + .bwrite = mem_write, + .bread = mem_read, + .bputs = mem_puts, + .bgets = mem_gets, + .ctrl = mem_ctrl, + .create = mem_new, + .destroy = mem_free }; /* bio->num is used to hold the value to return on 'empty', if it is diff --git a/lib/libcrypto/bio/bss_null.c b/lib/libcrypto/bio/bss_null.c index c7289725d98..a5796ea87a0 100644 --- a/lib/libcrypto/bio/bss_null.c +++ b/lib/libcrypto/bio/bss_null.c @@ -70,16 +70,15 @@ static int null_new(BIO *h); static int null_free(BIO *data); static BIO_METHOD null_method = { - BIO_TYPE_NULL, - "NULL", - null_write, - null_read, - null_puts, - null_gets, - null_ctrl, - null_new, - null_free, - NULL, + .type = BIO_TYPE_NULL, + .name = "NULL", + .bwrite = null_write, + .bread = null_read, + .bputs = null_puts, + .bgets = null_gets, + .ctrl = null_ctrl, + .create = null_new, + .destroy = null_free }; BIO_METHOD * diff --git a/lib/libcrypto/bio/bss_sock.c b/lib/libcrypto/bio/bss_sock.c index 3dae2562bf5..757e1dbb8f0 100644 --- a/lib/libcrypto/bio/bss_sock.c +++ b/lib/libcrypto/bio/bss_sock.c @@ -74,16 +74,14 @@ static int sock_free(BIO *data); int BIO_sock_should_retry(int s); static BIO_METHOD methods_sockp = { - BIO_TYPE_SOCKET, - "socket", - sock_write, - sock_read, - sock_puts, - NULL, /* sock_gets, */ - sock_ctrl, - sock_new, - sock_free, - NULL, + .type = BIO_TYPE_SOCKET, + .name = "socket", + .bwrite = sock_write, + .bread = sock_read, + .bputs = sock_puts, + .ctrl = sock_ctrl, + .create = sock_new, + .destroy = sock_free }; BIO_METHOD * diff --git a/lib/libcrypto/cmac/cm_ameth.c b/lib/libcrypto/cmac/cm_ameth.c index 0b8e5670b0e..c960e1cf43b 100644 --- a/lib/libcrypto/cmac/cm_ameth.c +++ b/lib/libcrypto/cmac/cm_ameth.c @@ -73,25 +73,14 @@ static void cmac_key_free(EVP_PKEY *pkey) CMAC_CTX_free(cmctx); } -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, +const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { + .pkey_id = EVP_PKEY_CMAC, + .pkey_base_id = EVP_PKEY_CMAC, - cmac_size, - 0, - 0,0,0,0,0,0,0, + .pem_str = "CMAC", + .info = "OpenSSL CMAC method", - cmac_key_free, - 0, - 0,0 - }; + .pkey_size = cmac_size, + .pkey_free = cmac_key_free +}; diff --git a/lib/libcrypto/cmac/cm_pmeth.c b/lib/libcrypto/cmac/cm_pmeth.c index 00aa4d64d2b..e1a00e90bb9 100644 --- a/lib/libcrypto/cmac/cm_pmeth.c +++ b/lib/libcrypto/cmac/cm_pmeth.c @@ -188,37 +188,19 @@ static int pkey_cmac_ctrl_str(EVP_PKEY_CTX *ctx, return -2; } -const EVP_PKEY_METHOD cmac_pkey_meth = - { - EVP_PKEY_CMAC, - EVP_PKEY_FLAG_SIGCTX_CUSTOM, - pkey_cmac_init, - pkey_cmac_copy, - pkey_cmac_cleanup, - - 0, 0, - - 0, - pkey_cmac_keygen, - - 0, 0, - - 0, 0, - - 0,0, - - cmac_signctx_init, - cmac_signctx, - - 0,0, - - 0,0, +const EVP_PKEY_METHOD cmac_pkey_meth = { + .pkey_id = EVP_PKEY_CMAC, + .flags = EVP_PKEY_FLAG_SIGCTX_CUSTOM, - 0,0, + .init = pkey_cmac_init, + .copy = pkey_cmac_copy, + .cleanup = pkey_cmac_cleanup, - 0,0, + .keygen = pkey_cmac_keygen, - pkey_cmac_ctrl, - pkey_cmac_ctrl_str + .signctx_init = cmac_signctx_init, + .signctx = cmac_signctx, - }; + .ctrl = pkey_cmac_ctrl, + .ctrl_str = pkey_cmac_ctrl_str +}; diff --git a/lib/libcrypto/comp/c_rle.c b/lib/libcrypto/comp/c_rle.c index 7a5db298c5e..48e48cbb7aa 100644 --- a/lib/libcrypto/comp/c_rle.c +++ b/lib/libcrypto/comp/c_rle.c @@ -10,14 +10,10 @@ static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static COMP_METHOD rle_method = { - NID_rle_compression, - LN_rle_compression, - NULL, - NULL, - rle_compress_block, - rle_expand_block, - NULL, - NULL, + .type = NID_rle_compression, + .name = LN_rle_compression, + .compress = rle_compress_block, + .expand = rle_expand_block }; COMP_METHOD * diff --git a/lib/libcrypto/comp/c_zlib.c b/lib/libcrypto/comp/c_zlib.c index 3a73b3df0bd..26c6507cd5d 100644 --- a/lib/libcrypto/comp/c_zlib.c +++ b/lib/libcrypto/comp/c_zlib.c @@ -8,14 +8,8 @@ COMP_METHOD *COMP_zlib(void ); static COMP_METHOD zlib_method_nozlib = { - NID_undef, - "(undef)", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + .type = NID_undef, + .name = "(undef)" }; #ifndef ZLIB @@ -55,26 +49,20 @@ static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); static COMP_METHOD zlib_stateless_method = { - NID_zlib_compression, - LN_zlib_compression, - NULL, - NULL, - zlib_compress_block, - zlib_expand_block, - NULL, - NULL, + .type = NID_zlib_compression, + .name = LN_zlib_compression, + .compress = zlib_compress_block, + .expand = zlib_expand_block }; #endif static COMP_METHOD zlib_stateful_method = { - NID_zlib_compression, - LN_zlib_compression, - zlib_stateful_init, - zlib_stateful_finish, - zlib_stateful_compress_block, - zlib_stateful_expand_block, - NULL, - NULL, + .type = NID_zlib_compression, + .name = LN_zlib_compression, + .init = zlib_stateful_init, + .finish = zlib_stateful_finish, + .compress = zlib_stateful_compress_block, + .expand = zlib_stateful_expand_block }; #ifdef ZLIB_SHARED @@ -433,16 +421,14 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr); static long bio_zlib_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp); static BIO_METHOD bio_meth_zlib = { - BIO_TYPE_COMP, - "zlib", - bio_zlib_write, - bio_zlib_read, - NULL, - NULL, - bio_zlib_ctrl, - bio_zlib_new, - bio_zlib_free, - bio_zlib_callback_ctrl + .type = BIO_TYPE_COMP, + .name = "zlib", + .bwrite = bio_zlib_write, + .bread = bio_zlib_read, + .ctrl = bio_zlib_ctrl, + .create = bio_zlib_new, + .destroy = bio_zlib_free, + .callback_ctrl = bio_zlib_callback_ctrl }; BIO_METHOD * diff --git a/lib/libcrypto/conf/conf_def.c b/lib/libcrypto/conf/conf_def.c index d85773df0e8..b3c75e1a9e5 100644 --- a/lib/libcrypto/conf/conf_def.c +++ b/lib/libcrypto/conf/conf_def.c @@ -91,16 +91,16 @@ static int def_to_int(const CONF *conf, char c); const char CONF_def_version[]="CONF_def" OPENSSL_VERSION_PTEXT; static CONF_METHOD default_method = { - "OpenSSL default", - def_create, - def_init_default, - def_destroy, - def_destroy_data, - def_load_bio, - def_dump, - def_is_number, - def_to_int, - def_load + .name = "OpenSSL default", + .create = def_create, + .init = def_init_default, + .destroy = def_destroy, + .destroy_data = def_destroy_data, + .load_bio = def_load_bio, + .dump = def_dump, + .is_number = def_is_number, + .to_int = def_to_int, + .load = def_load }; static CONF_METHOD WIN32_method = { diff --git a/lib/libcrypto/dh/dh_ameth.c b/lib/libcrypto/dh/dh_ameth.c index d39f4b373d3..a22614ae0a0 100644 --- a/lib/libcrypto/dh/dh_ameth.c +++ b/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/lib/libcrypto/dh/dh_key.c b/lib/libcrypto/dh/dh_key.c index 9596270f7d4..91352a9fbf5 100644 --- a/lib/libcrypto/dh/dh_key.c +++ b/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/lib/libcrypto/dh/dh_pmeth.c b/lib/libcrypto/dh/dh_pmeth.c index ec4553c0a89..c359bb4d2ba 100644 --- a/lib/libcrypto/dh/dh_pmeth.c +++ b/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 +}; diff --git a/lib/libcrypto/dsa/dsa_ameth.c b/lib/libcrypto/dsa/dsa_ameth.c index e9c549802d6..ebca5ec5c51 100644 --- a/lib/libcrypto/dsa/dsa_ameth.c +++ b/lib/libcrypto/dsa/dsa_ameth.c @@ -640,65 +640,61 @@ static int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) /* NB these are sorted in pkey_id order, lowest first */ -const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = +const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = { { + .pkey_id = EVP_PKEY_DSA2, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, - { - EVP_PKEY_DSA2, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, - - { - EVP_PKEY_DSA1, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, - - { - EVP_PKEY_DSA4, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, + { + .pkey_id = EVP_PKEY_DSA1, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, - { - EVP_PKEY_DSA3, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, + { + .pkey_id = EVP_PKEY_DSA4, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, - { - EVP_PKEY_DSA, - EVP_PKEY_DSA, - 0, - - "DSA", - "OpenSSL DSA method", - - dsa_pub_decode, - dsa_pub_encode, - dsa_pub_cmp, - dsa_pub_print, - - dsa_priv_decode, - dsa_priv_encode, - dsa_priv_print, - - int_dsa_size, - dsa_bits, - - dsa_param_decode, - dsa_param_encode, - dsa_missing_parameters, - dsa_copy_parameters, - dsa_cmp_parameters, - dsa_param_print, - dsa_sig_print, - - int_dsa_free, - dsa_pkey_ctrl, - old_dsa_priv_decode, - old_dsa_priv_encode - } - }; + { + .pkey_id = EVP_PKEY_DSA3, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, + { + .pkey_id = EVP_PKEY_DSA, + .pkey_base_id = EVP_PKEY_DSA, + + .pem_str = "DSA", + .info = "OpenSSL DSA method", + + .pub_decode = dsa_pub_decode, + .pub_encode = dsa_pub_encode, + .pub_cmp = dsa_pub_cmp, + .pub_print = dsa_pub_print, + + .priv_decode = dsa_priv_decode, + .priv_encode = dsa_priv_encode, + .priv_print = dsa_priv_print, + + .pkey_size = int_dsa_size, + .pkey_bits = dsa_bits, + + .param_decode = dsa_param_decode, + .param_encode = dsa_param_encode, + .param_missing = dsa_missing_parameters, + .param_copy = dsa_copy_parameters, + .param_cmp = dsa_cmp_parameters, + .param_print = dsa_param_print, + .sig_print = dsa_sig_print, + + .pkey_free = int_dsa_free, + .pkey_ctrl = dsa_pkey_ctrl, + .old_priv_decode = old_dsa_priv_decode, + .old_priv_encode = old_dsa_priv_encode + } +}; diff --git a/lib/libcrypto/dsa/dsa_ossl.c b/lib/libcrypto/dsa/dsa_ossl.c index b3d78e524cf..7e0e3b006ef 100644 --- a/lib/libcrypto/dsa/dsa_ossl.c +++ b/lib/libcrypto/dsa/dsa_ossl.c @@ -74,18 +74,12 @@ static int dsa_init(DSA *dsa); static int dsa_finish(DSA *dsa); static DSA_METHOD openssl_dsa_meth = { -"OpenSSL DSA method", -dsa_do_sign, -dsa_sign_setup, -dsa_do_verify, -NULL, /* dsa_mod_exp, */ -NULL, /* dsa_bn_mod_exp, */ -dsa_init, -dsa_finish, -0, -NULL, -NULL, -NULL + .name = "OpenSSL DSA method", + .dsa_do_sign = dsa_do_sign, + .dsa_sign_setup = dsa_sign_setup, + .dsa_do_verify = dsa_do_verify, + .init = dsa_init, + .finish = dsa_finish }; /* These macro wrappers replace attempts to use the dsa_mod_exp() and diff --git a/lib/libcrypto/dsa/dsa_pmeth.c b/lib/libcrypto/dsa/dsa_pmeth.c index 7076bf7b676..4e77c6f64bb 100644 --- a/lib/libcrypto/dsa/dsa_pmeth.c +++ b/lib/libcrypto/dsa/dsa_pmeth.c @@ -281,38 +281,22 @@ static int pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) return DSA_generate_key(pkey->pkey.dsa); } -const EVP_PKEY_METHOD dsa_pkey_meth = - { - EVP_PKEY_DSA, - EVP_PKEY_FLAG_AUTOARGLEN, - pkey_dsa_init, - pkey_dsa_copy, - pkey_dsa_cleanup, - - 0, - pkey_dsa_paramgen, - - 0, - pkey_dsa_keygen, - - 0, - pkey_dsa_sign, - - 0, - pkey_dsa_verify, - - 0,0, - - 0,0,0,0, +const EVP_PKEY_METHOD dsa_pkey_meth = { + .pkey_id = EVP_PKEY_DSA, + .flags = EVP_PKEY_FLAG_AUTOARGLEN, - 0,0, + .init = pkey_dsa_init, + .copy = pkey_dsa_copy, + .cleanup = pkey_dsa_cleanup, - 0,0, + .paramgen = pkey_dsa_paramgen, - 0,0, + .keygen = pkey_dsa_keygen, - pkey_dsa_ctrl, - pkey_dsa_ctrl_str + .sign = pkey_dsa_sign, + .verify = pkey_dsa_verify, - }; + .ctrl = pkey_dsa_ctrl, + .ctrl_str = pkey_dsa_ctrl_str +}; diff --git a/lib/libcrypto/dso/dso_dlfcn.c b/lib/libcrypto/dso/dso_dlfcn.c index 6cf9ab2667d..bebfdcdbc41 100644 --- a/lib/libcrypto/dso/dso_dlfcn.c +++ b/lib/libcrypto/dso/dso_dlfcn.c @@ -93,23 +93,15 @@ static int dlfcn_pathbyaddr(void *addr, char *path, int sz); static void *dlfcn_globallookup(const char *name); static DSO_METHOD dso_meth_dlfcn = { - "OpenSSL 'dlfcn' shared library method", - dlfcn_load, - dlfcn_unload, - dlfcn_bind_var, - dlfcn_bind_func, -/* For now, "unbind" doesn't exist */ -#if 0 - NULL, /* unbind_var */ - NULL, /* unbind_func */ -#endif - NULL, /* ctrl */ - dlfcn_name_converter, - dlfcn_merger, - NULL, /* init */ - NULL, /* finish */ - dlfcn_pathbyaddr, - dlfcn_globallookup + .name = "OpenSSL 'dlfcn' shared library method", + .dso_load = dlfcn_load, + .dso_unload = dlfcn_unload, + .dso_bind_var = dlfcn_bind_var, + .dso_bind_func = dlfcn_bind_func, + .dso_name_converter = dlfcn_name_converter, + .dso_merger = dlfcn_merger, + .pathbyaddr = dlfcn_pathbyaddr, + .globallookup = dlfcn_globallookup }; DSO_METHOD * diff --git a/lib/libcrypto/dso/dso_null.c b/lib/libcrypto/dso/dso_null.c index 0c877ab2f26..c9f4226cb5f 100644 --- a/lib/libcrypto/dso/dso_null.c +++ b/lib/libcrypto/dso/dso_null.c @@ -64,23 +64,7 @@ #include static DSO_METHOD dso_meth_null = { - "NULL shared library method", - NULL, /* load */ - NULL, /* unload */ - NULL, /* bind_var */ - NULL, /* bind_func */ -/* For now, "unbind" doesn't exist */ -#if 0 - NULL, /* unbind_var */ - NULL, /* unbind_func */ -#endif - NULL, /* ctrl */ - NULL, /* dso_name_converter */ - NULL, /* dso_merger */ - NULL, /* init */ - NULL, /* finish */ - NULL, /* pathbyaddr */ - NULL /* globallookup */ + .name = "NULL shared library method" }; DSO_METHOD * 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 #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 diff --git a/lib/libcrypto/ecdh/ech_ossl.c b/lib/libcrypto/ecdh/ech_ossl.c index a63eb4922db..129475f7bb4 100644 --- a/lib/libcrypto/ecdh/ech_ossl.c +++ b/lib/libcrypto/ecdh/ech_ossl.c @@ -84,14 +84,8 @@ static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); static ECDH_METHOD openssl_ecdh_meth = { - "OpenSSL ECDH method", - ecdh_compute_key, -#if 0 - NULL, /* init */ - NULL, /* finish */ -#endif - 0, /* flags */ - NULL /* app_data */ + .name = "OpenSSL ECDH method", + .compute_key = ecdh_compute_key }; const ECDH_METHOD *ECDH_OpenSSL(void) diff --git a/lib/libcrypto/ecdsa/ecs_ossl.c b/lib/libcrypto/ecdsa/ecs_ossl.c index 7725935610e..4a6e04e9460 100644 --- a/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/lib/libcrypto/ecdsa/ecs_ossl.c @@ -69,16 +69,10 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey); static ECDSA_METHOD openssl_ecdsa_meth = { - "OpenSSL ECDSA method", - ecdsa_do_sign, - ecdsa_sign_setup, - ecdsa_do_verify, -#if 0 - NULL, /* init */ - NULL, /* finish */ -#endif - 0, /* flags */ - NULL /* app_data */ + .name = "OpenSSL ECDSA method", + .ecdsa_do_sign = ecdsa_do_sign, + .ecdsa_sign_setup = ecdsa_sign_setup, + .ecdsa_do_verify = ecdsa_do_verify }; const ECDSA_METHOD *ECDSA_OpenSSL(void) diff --git a/lib/libcrypto/engine/eng_padlock.c b/lib/libcrypto/engine/eng_padlock.c index d5d9a16bf24..c27181ba758 100644 --- a/lib/libcrypto/engine/eng_padlock.c +++ b/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/lib/libcrypto/engine/eng_rdrand.c b/lib/libcrypto/engine/eng_rdrand.c index 4e9e91d54b1..ba1b5bfbffd 100644 --- a/lib/libcrypto/engine/eng_rdrand.c +++ b/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/lib/libcrypto/engine/eng_rsax.c b/lib/libcrypto/engine/eng_rsax.c index fa9159499db..c0f6851601c 100644 --- a/lib/libcrypto/engine/eng_rsax.c +++ b/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/lib/libcrypto/engine/hw_cryptodev.c b/lib/libcrypto/engine/hw_cryptodev.c index 190dcc4f753..9b24511b693 100644 --- a/lib/libcrypto/engine/hw_cryptodev.c +++ b/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" }; /* diff --git a/lib/libcrypto/evp/bio_b64.c b/lib/libcrypto/evp/bio_b64.c index 27fc587ca80..02631ec05a0 100644 --- a/lib/libcrypto/evp/bio_b64.c +++ b/lib/libcrypto/evp/bio_b64.c @@ -91,18 +91,17 @@ typedef struct b64_struct char tmp[B64_BLOCK_SIZE]; } BIO_B64_CTX; -static BIO_METHOD methods_b64= - { - BIO_TYPE_BASE64,"base64 encoding", - b64_write, - b64_read, - b64_puts, - NULL, /* b64_gets, */ - b64_ctrl, - b64_new, - b64_free, - b64_callback_ctrl, - }; +static BIO_METHOD methods_b64= { + .type = BIO_TYPE_BASE64, + .name = "base64 encoding", + .bwrite = b64_write, + .bread = b64_read, + .bputs = b64_puts, + .ctrl = b64_ctrl, + .create = b64_new, + .destroy = b64_free, + .callback_ctrl = b64_callback_ctrl +}; BIO_METHOD *BIO_f_base64(void) { diff --git a/lib/libcrypto/evp/bio_enc.c b/lib/libcrypto/evp/bio_enc.c index 8fe9a45e481..3362c257681 100644 --- a/lib/libcrypto/evp/bio_enc.c +++ b/lib/libcrypto/evp/bio_enc.c @@ -87,18 +87,16 @@ typedef struct enc_struct char buf[ENC_BLOCK_SIZE+BUF_OFFSET+2]; } BIO_ENC_CTX; -static BIO_METHOD methods_enc= - { - BIO_TYPE_CIPHER,"cipher", - enc_write, - enc_read, - NULL, /* enc_puts, */ - NULL, /* enc_gets, */ - enc_ctrl, - enc_new, - enc_free, - enc_callback_ctrl, - }; +static BIO_METHOD methods_enc= { + .type = BIO_TYPE_CIPHER, + .name = "cipher", + .bwrite = enc_write, + .bread = enc_read, + .ctrl = enc_ctrl, + .create = enc_new, + .destroy = enc_free, + .callback_ctrl = enc_callback_ctrl +}; BIO_METHOD *BIO_f_cipher(void) { diff --git a/lib/libcrypto/evp/bio_md.c b/lib/libcrypto/evp/bio_md.c index 144fdfd56a0..85eead6c952 100644 --- a/lib/libcrypto/evp/bio_md.c +++ b/lib/libcrypto/evp/bio_md.c @@ -74,18 +74,17 @@ static int md_new(BIO *h); static int md_free(BIO *data); static long md_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp); -static BIO_METHOD methods_md= - { - BIO_TYPE_MD,"message digest", - md_write, - md_read, - NULL, /* md_puts, */ - md_gets, - md_ctrl, - md_new, - md_free, - md_callback_ctrl, - }; +static BIO_METHOD methods_md = { + .type = BIO_TYPE_MD, + .name = "message digest", + .bwrite = md_write, + .bread = md_read, + .bgets = md_gets, + .ctrl = md_ctrl, + .create = md_new, + .destroy = md_free, + .callback_ctrl = md_callback_ctrl +}; BIO_METHOD *BIO_f_md(void) { diff --git a/lib/libcrypto/evp/bio_ok.c b/lib/libcrypto/evp/bio_ok.c index 09a762ffacd..d0bcbc2bef9 100644 --- a/lib/libcrypto/evp/bio_ok.c +++ b/lib/libcrypto/evp/bio_ok.c @@ -157,18 +157,16 @@ typedef struct ok_struct unsigned char buf[IOBS]; } BIO_OK_CTX; -static BIO_METHOD methods_ok= - { - BIO_TYPE_CIPHER,"reliable", - ok_write, - ok_read, - NULL, /* ok_puts, */ - NULL, /* ok_gets, */ - ok_ctrl, - ok_new, - ok_free, - ok_callback_ctrl, - }; +static BIO_METHOD methods_ok = { + .type = BIO_TYPE_CIPHER, + .name = "reliable", + .bwrite = ok_write, + .bread = ok_read, + .ctrl = ok_ctrl, + .create = ok_new, + .destroy = ok_free, + .callback_ctrl = ok_callback_ctrl +}; BIO_METHOD *BIO_f_reliable(void) { diff --git a/lib/libcrypto/hmac/hm_ameth.c b/lib/libcrypto/hmac/hm_ameth.c index fbada40d9cc..0625b066511 100644 --- a/lib/libcrypto/hmac/hm_ameth.c +++ b/lib/libcrypto/hmac/hm_ameth.c @@ -138,30 +138,20 @@ static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) #endif -const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = - { - EVP_PKEY_HMAC, - EVP_PKEY_HMAC, - 0, - - "HMAC", - "OpenSSL HMAC method", - - 0,0,0,0, +const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = { + .pkey_id = EVP_PKEY_HMAC, + .pkey_base_id = EVP_PKEY_HMAC, - 0,0,0, + .pem_str = "HMAC", + .info = "OpenSSL HMAC method", - hmac_size, - 0, - 0,0,0,0,0,0,0, + .pkey_size = hmac_size, - hmac_key_free, - hmac_pkey_ctrl, + .pkey_free = hmac_key_free, + .pkey_ctrl = hmac_pkey_ctrl, #ifdef HMAC_TEST_PRIVATE_KEY_FORMAT - old_hmac_decode, - old_hmac_encode -#else - 0,0 + .old_priv_decode = old_hmac_decode, + .old_priv_encode = old_hmac_encode #endif }; diff --git a/lib/libcrypto/hmac/hm_pmeth.c b/lib/libcrypto/hmac/hm_pmeth.c index f1c67329d03..4d287724c30 100644 --- a/lib/libcrypto/hmac/hm_pmeth.c +++ b/lib/libcrypto/hmac/hm_pmeth.c @@ -235,37 +235,18 @@ static int pkey_hmac_ctrl_str(EVP_PKEY_CTX *ctx, return -2; } -const EVP_PKEY_METHOD hmac_pkey_meth = - { - EVP_PKEY_HMAC, - 0, - pkey_hmac_init, - pkey_hmac_copy, - pkey_hmac_cleanup, - - 0, 0, - - 0, - pkey_hmac_keygen, - - 0, 0, - - 0, 0, - - 0,0, - - hmac_signctx_init, - hmac_signctx, - - 0,0, - - 0,0, +const EVP_PKEY_METHOD hmac_pkey_meth = { + .pkey_id = EVP_PKEY_HMAC, - 0,0, + .init = pkey_hmac_init, + .copy = pkey_hmac_copy, + .cleanup = pkey_hmac_cleanup, - 0,0, + .keygen = pkey_hmac_keygen, - pkey_hmac_ctrl, - pkey_hmac_ctrl_str + .signctx_init = hmac_signctx_init, + .signctx = hmac_signctx, - }; + .ctrl = pkey_hmac_ctrl, + .ctrl_str = pkey_hmac_ctrl_str +}; diff --git a/lib/libcrypto/pkcs7/bio_ber.c b/lib/libcrypto/pkcs7/bio_ber.c index d787495a218..216d237b4d8 100644 --- a/lib/libcrypto/pkcs7/bio_ber.c +++ b/lib/libcrypto/pkcs7/bio_ber.c @@ -106,18 +106,16 @@ typedef struct bio_ber_struct unsigned char buf[BER_BUF_SIZE]; } BIO_BER_CTX; -static BIO_METHOD methods_ber= - { - BIO_TYPE_CIPHER,"cipher", - ber_write, - ber_read, - NULL, /* ber_puts, */ - NULL, /* ber_gets, */ - ber_ctrl, - ber_new, - ber_free, - ber_callback_ctrl, - }; +static BIO_METHOD methods_ber = { + .type = BIO_TYPE_CIPHER, + .name = "cipher", + .bwrite = ber_write, + .bread = ber_read, + .ctrl = ber_ctrl, + .create = ber_new, + .destroy = ber_free, + .callback_ctrl = ber_callback_ctrl +}; BIO_METHOD *BIO_f_ber(void) { diff --git a/lib/libcrypto/rsa/rsa_ameth.c b/lib/libcrypto/rsa/rsa_ameth.c index fdd11835ad9..f0a346a70ec 100644 --- a/lib/libcrypto/rsa/rsa_ameth.c +++ b/lib/libcrypto/rsa/rsa_ameth.c @@ -657,42 +657,40 @@ static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, return 2; } -const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = +const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = { { - { - EVP_PKEY_RSA, - EVP_PKEY_RSA, - ASN1_PKEY_SIGPARAM_NULL, + .pkey_id = EVP_PKEY_RSA, + .pkey_base_id = EVP_PKEY_RSA, + .pkey_flags = ASN1_PKEY_SIGPARAM_NULL, - "RSA", - "OpenSSL RSA method", + .pem_str = "RSA", + .info = "OpenSSL RSA method", - rsa_pub_decode, - rsa_pub_encode, - rsa_pub_cmp, - rsa_pub_print, + .pub_decode = rsa_pub_decode, + .pub_encode = rsa_pub_encode, + .pub_cmp = rsa_pub_cmp, + .pub_print = rsa_pub_print, - rsa_priv_decode, - rsa_priv_encode, - rsa_priv_print, + .priv_decode = rsa_priv_decode, + .priv_encode = rsa_priv_encode, + .priv_print = rsa_priv_print, - int_rsa_size, - rsa_bits, + .pkey_size = int_rsa_size, + .pkey_bits = rsa_bits, - 0,0,0,0,0,0, + .sig_print = rsa_sig_print, - rsa_sig_print, - int_rsa_free, - rsa_pkey_ctrl, - old_rsa_priv_decode, - old_rsa_priv_encode, - rsa_item_verify, - rsa_item_sign - }, + .pkey_free = int_rsa_free, + .pkey_ctrl = rsa_pkey_ctrl, + .old_priv_decode = old_rsa_priv_decode, + .old_priv_encode = old_rsa_priv_encode, + .item_verify = rsa_item_verify, + .item_sign = rsa_item_sign + }, - { - EVP_PKEY_RSA2, - EVP_PKEY_RSA, - ASN1_PKEY_ALIAS - } - }; + { + .pkey_id = EVP_PKEY_RSA2, + .pkey_base_id = EVP_PKEY_RSA, + .pkey_flags = ASN1_PKEY_ALIAS + } +}; diff --git a/lib/libcrypto/rsa/rsa_eay.c b/lib/libcrypto/rsa/rsa_eay.c index dcf0c16a8f6..845e28877e5 100644 --- a/lib/libcrypto/rsa/rsa_eay.c +++ b/lib/libcrypto/rsa/rsa_eay.c @@ -128,22 +128,17 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx); static int RSA_eay_init(RSA *rsa); static int RSA_eay_finish(RSA *rsa); -static RSA_METHOD rsa_pkcs1_eay_meth={ - "Eric Young's PKCS#1 RSA", - RSA_eay_public_encrypt, - RSA_eay_public_decrypt, /* signature verification */ - RSA_eay_private_encrypt, /* signing */ - RSA_eay_private_decrypt, - RSA_eay_mod_exp, - BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */ - RSA_eay_init, - RSA_eay_finish, - 0, /* flags */ - NULL, - 0, /* rsa_sign */ - 0, /* rsa_verify */ - NULL /* rsa_keygen */ - }; +static RSA_METHOD rsa_pkcs1_eay_meth = { + .name = "Eric Young's PKCS#1 RSA", + .rsa_pub_enc = RSA_eay_public_encrypt, + .rsa_pub_dec = RSA_eay_public_decrypt, /* signature verification */ + .rsa_priv_enc = RSA_eay_private_encrypt, /* signing */ + .rsa_priv_dec = RSA_eay_private_decrypt, + .rsa_mod_exp = RSA_eay_mod_exp, + .bn_mod_exp = BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */ + .init = RSA_eay_init, + .finish = RSA_eay_finish, +}; const RSA_METHOD *RSA_PKCS1_SSLeay(void) { diff --git a/lib/libcrypto/rsa/rsa_null.c b/lib/libcrypto/rsa/rsa_null.c index 2f2202f142f..5b9317cb6cc 100644 --- a/lib/libcrypto/rsa/rsa_null.c +++ b/lib/libcrypto/rsa/rsa_null.c @@ -82,22 +82,15 @@ static int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa); #endif static int RSA_null_init(RSA *rsa); static int RSA_null_finish(RSA *rsa); -static RSA_METHOD rsa_null_meth={ - "Null RSA", - RSA_null_public_encrypt, - RSA_null_public_decrypt, - RSA_null_private_encrypt, - RSA_null_private_decrypt, - NULL, - NULL, - RSA_null_init, - RSA_null_finish, - 0, - NULL, - NULL, - NULL, - NULL - }; +static RSA_METHOD rsa_null_meth = { + .name = "Null RSA", + .rsa_pub_enc = RSA_null_public_encrypt, + .rsa_pub_dec = RSA_null_public_decrypt, + .rsa_priv_enc = RSA_null_private_encrypt, + .rsa_priv_dec = RSA_null_private_decrypt, + .init = RSA_null_init, + .finish = RSA_null_finish, +}; const RSA_METHOD *RSA_null_method(void) { diff --git a/lib/libcrypto/rsa/rsa_pmeth.c b/lib/libcrypto/rsa/rsa_pmeth.c index adec632b3bf..09ef090172b 100644 --- a/lib/libcrypto/rsa/rsa_pmeth.c +++ b/lib/libcrypto/rsa/rsa_pmeth.c @@ -609,41 +609,26 @@ static int pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) return ret; } -const EVP_PKEY_METHOD rsa_pkey_meth = - { - EVP_PKEY_RSA, - EVP_PKEY_FLAG_AUTOARGLEN, - pkey_rsa_init, - pkey_rsa_copy, - pkey_rsa_cleanup, - - 0,0, - - 0, - pkey_rsa_keygen, - - 0, - pkey_rsa_sign, - - 0, - pkey_rsa_verify, - - 0, - pkey_rsa_verifyrecover, +const EVP_PKEY_METHOD rsa_pkey_meth = { + .pkey_id = EVP_PKEY_RSA, + .flags = EVP_PKEY_FLAG_AUTOARGLEN, + .init = pkey_rsa_init, + .copy = pkey_rsa_copy, + .cleanup = pkey_rsa_cleanup, - 0,0,0,0, + .keygen = pkey_rsa_keygen, - 0, - pkey_rsa_encrypt, + .sign = pkey_rsa_sign, - 0, - pkey_rsa_decrypt, + .verify = pkey_rsa_verify, - 0,0, + .verify_recover = pkey_rsa_verifyrecover, - pkey_rsa_ctrl, - pkey_rsa_ctrl_str + .encrypt = pkey_rsa_encrypt, + .decrypt = pkey_rsa_decrypt, - }; + .ctrl = pkey_rsa_ctrl, + .ctrl_str = pkey_rsa_ctrl_str +}; diff --git a/lib/libcrypto/store/str_mem.c b/lib/libcrypto/store/str_mem.c index 997e60fe930..a73279c86b5 100644 --- a/lib/libcrypto/store/str_mem.c +++ b/lib/libcrypto/store/str_mem.c @@ -133,25 +133,22 @@ static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); -static STORE_METHOD store_memory = - { - "OpenSSL memory store interface", - mem_init, - mem_clean, - mem_generate, - mem_get, - mem_store, - mem_modify, - NULL, /* revoke */ - mem_delete, - mem_list_start, - mem_list_next, - mem_list_end, - mem_list_endp, - NULL, /* update */ - mem_lock, - mem_unlock, - mem_ctrl +static STORE_METHOD store_memory = { + .name = "OpenSSL memory store interface", + .init = mem_init, + .clean = mem_clean, + .generate_object = mem_generate, + .get_object = mem_get, + .store_object = mem_store, + .modify_object = mem_modify, + .delete_object = mem_delete, + .list_object_start = mem_list_start, + .list_object_next = mem_list_next, + .list_object_end = mem_list_end, + .list_object_endp = mem_list_endp, + .lock_store = mem_lock, + .unlock_store = mem_unlock, + .ctrl = mem_ctrl }; const STORE_METHOD *STORE_Memory(void) diff --git a/lib/libcrypto/ui/ui_openssl.c b/lib/libcrypto/ui/ui_openssl.c index d3be332f19e..3b79ecaf029 100644 --- a/lib/libcrypto/ui/ui_openssl.c +++ b/lib/libcrypto/ui/ui_openssl.c @@ -157,13 +157,11 @@ static int noecho_console(UI *ui); static int close_console(UI *ui); static UI_METHOD ui_openssl = { - "OpenSSL default user interface", - open_console, - write_string, - NULL, /* No flusher is needed for command lines */ - read_string, - close_console, - NULL + .name = "OpenSSL default user interface", + .ui_open_session = open_console, + .ui_write_string = write_string, + .ui_read_string = read_string, + .ui_close_session = close_console, }; /* The method with all the built-in thingies */ diff --git a/lib/libssl/src/crypto/asn1/bio_asn1.c b/lib/libssl/src/crypto/asn1/bio_asn1.c index 36b82758ed3..327355eeda5 100644 --- a/lib/libssl/src/crypto/asn1/bio_asn1.c +++ b/lib/libssl/src/crypto/asn1/bio_asn1.c @@ -124,16 +124,16 @@ static int asn1_bio_setup_ex(BIO *b, BIO_ASN1_BUF_CTX *ctx, asn1_bio_state_t other_state); static BIO_METHOD methods_asn1 = { - BIO_TYPE_ASN1, - "asn1", - asn1_bio_write, - asn1_bio_read, - asn1_bio_puts, - asn1_bio_gets, - asn1_bio_ctrl, - asn1_bio_new, - asn1_bio_free, - asn1_bio_callback_ctrl, + .type = BIO_TYPE_ASN1, + .name = "asn1", + .bwrite = asn1_bio_write, + .bread = asn1_bio_read, + .bputs = asn1_bio_puts, + .bgets = asn1_bio_gets, + .ctrl = asn1_bio_ctrl, + .create = asn1_bio_new, + .destroy = asn1_bio_free, + .callback_ctrl = asn1_bio_callback_ctrl }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/asn1/x_crl.c b/lib/libssl/src/crypto/asn1/x_crl.c index 674cca4a1c9..097a39c4d16 100644 --- a/lib/libssl/src/crypto/asn1/x_crl.c +++ b/lib/libssl/src/crypto/asn1/x_crl.c @@ -78,11 +78,8 @@ static int def_crl_lookup(X509_CRL *crl, X509_REVOKED **ret, ASN1_INTEGER *serial, X509_NAME *issuer); static X509_CRL_METHOD int_crl_meth = { - 0, - 0, - 0, - def_crl_lookup, - def_crl_verify + .crl_lookup = def_crl_lookup, + .crl_verify = def_crl_verify }; static const X509_CRL_METHOD *default_crl_method = &int_crl_meth; diff --git a/lib/libssl/src/crypto/bio/bf_buff.c b/lib/libssl/src/crypto/bio/bf_buff.c index 99be1a629e5..e96da40a58a 100644 --- a/lib/libssl/src/crypto/bio/bf_buff.c +++ b/lib/libssl/src/crypto/bio/bf_buff.c @@ -72,16 +72,16 @@ static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define DEFAULT_BUFFER_SIZE 4096 static BIO_METHOD methods_buffer = { - BIO_TYPE_BUFFER, - "buffer", - buffer_write, - buffer_read, - buffer_puts, - buffer_gets, - buffer_ctrl, - buffer_new, - buffer_free, - buffer_callback_ctrl, + .type = BIO_TYPE_BUFFER, + .name = "buffer", + .bwrite = buffer_write, + .bread = buffer_read, + .bputs = buffer_puts, + .bgets = buffer_gets, + .ctrl = buffer_ctrl, + .create = buffer_new, + .destroy = buffer_free, + .callback_ctrl = buffer_callback_ctrl }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bf_lbuf.c b/lib/libssl/src/crypto/bio/bf_lbuf.c index f0bd0d709ea..54c370d0380 100644 --- a/lib/libssl/src/crypto/bio/bf_lbuf.c +++ b/lib/libssl/src/crypto/bio/bf_lbuf.c @@ -77,16 +77,16 @@ static long linebuffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); /* #define DEBUG */ static BIO_METHOD methods_linebuffer = { - BIO_TYPE_LINEBUFFER, - "linebuffer", - linebuffer_write, - linebuffer_read, - linebuffer_puts, - linebuffer_gets, - linebuffer_ctrl, - linebuffer_new, - linebuffer_free, - linebuffer_callback_ctrl, + .type = BIO_TYPE_LINEBUFFER, + .name = "linebuffer", + .bwrite = linebuffer_write, + .bread = linebuffer_read, + .bputs = linebuffer_puts, + .bgets = linebuffer_gets, + .ctrl = linebuffer_ctrl, + .create = linebuffer_new, + .destroy = linebuffer_free, + .callback_ctrl = linebuffer_callback_ctrl }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bf_nbio.c b/lib/libssl/src/crypto/bio/bf_nbio.c index 048e6892ccc..5a0f6b276a5 100644 --- a/lib/libssl/src/crypto/bio/bf_nbio.c +++ b/lib/libssl/src/crypto/bio/bf_nbio.c @@ -81,16 +81,16 @@ typedef struct nbio_test_st { } NBIO_TEST; static BIO_METHOD methods_nbiof = { - BIO_TYPE_NBIO_TEST, - "non-blocking IO test filter", - nbiof_write, - nbiof_read, - nbiof_puts, - nbiof_gets, - nbiof_ctrl, - nbiof_new, - nbiof_free, - nbiof_callback_ctrl, + .type = BIO_TYPE_NBIO_TEST, + .name = "non-blocking IO test filter", + .bwrite = nbiof_write, + .bread = nbiof_read, + .bputs = nbiof_puts, + .bgets = nbiof_gets, + .ctrl = nbiof_ctrl, + .create = nbiof_new, + .destroy = nbiof_free, + .callback_ctrl = nbiof_callback_ctrl }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bf_null.c b/lib/libssl/src/crypto/bio/bf_null.c index 3bba2afe982..7554ed9cf5a 100644 --- a/lib/libssl/src/crypto/bio/bf_null.c +++ b/lib/libssl/src/crypto/bio/bf_null.c @@ -74,16 +74,16 @@ static int nullf_free(BIO *data); static long nullf_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); static BIO_METHOD methods_nullf = { - BIO_TYPE_NULL_FILTER, - "NULL filter", - nullf_write, - nullf_read, - nullf_puts, - nullf_gets, - nullf_ctrl, - nullf_new, - nullf_free, - nullf_callback_ctrl, + .type = BIO_TYPE_NULL_FILTER, + .name = "NULL filter", + .bwrite = nullf_write, + .bread = nullf_read, + .bputs = nullf_puts, + .bgets = nullf_gets, + .ctrl = nullf_ctrl, + .create = nullf_new, + .destroy = nullf_free, + .callback_ctrl = nullf_callback_ctrl }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bss_acpt.c b/lib/libssl/src/crypto/bio/bss_acpt.c index 916af3cb20e..943d3d9d961 100644 --- a/lib/libssl/src/crypto/bio/bss_acpt.c +++ b/lib/libssl/src/crypto/bio/bss_acpt.c @@ -98,16 +98,14 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a); #define ACPT_S_OK 3 static BIO_METHOD methods_acceptp = { - BIO_TYPE_ACCEPT, - "socket accept", - acpt_write, - acpt_read, - acpt_puts, - NULL, /* connect_gets, */ - acpt_ctrl, - acpt_new, - acpt_free, - NULL, + .type = BIO_TYPE_ACCEPT, + .name = "socket accept", + .bwrite = acpt_write, + .bread = acpt_read, + .bputs = acpt_puts, + .ctrl = acpt_ctrl, + .create = acpt_new, + .destroy = acpt_free }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bss_bio.c b/lib/libssl/src/crypto/bio/bss_bio.c index d31e59872ee..1a17cdf2755 100644 --- a/lib/libssl/src/crypto/bio/bss_bio.c +++ b/lib/libssl/src/crypto/bio/bss_bio.c @@ -94,16 +94,14 @@ static int bio_make_pair(BIO *bio1, BIO *bio2); static void bio_destroy_pair(BIO *bio); static BIO_METHOD methods_biop = { - BIO_TYPE_BIO, - "BIO pair", - bio_write, - bio_read, - bio_puts, - NULL /* no bio_gets */, - bio_ctrl, - bio_new, - bio_free, - NULL /* no bio_callback_ctrl */ + .type = BIO_TYPE_BIO, + .name = "BIO pair", + .bwrite = bio_write, + .bread = bio_read, + .bputs = bio_puts, + .ctrl = bio_ctrl, + .create = bio_new, + .destroy = bio_free }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bss_conn.c b/lib/libssl/src/crypto/bio/bss_conn.c index d7a8619b38e..7ed8f1fe31e 100644 --- a/lib/libssl/src/crypto/bio/bss_conn.c +++ b/lib/libssl/src/crypto/bio/bss_conn.c @@ -103,16 +103,15 @@ BIO_CONNECT *BIO_CONNECT_new(void); void BIO_CONNECT_free(BIO_CONNECT *a); static BIO_METHOD methods_connectp = { - BIO_TYPE_CONNECT, - "socket connect", - conn_write, - conn_read, - conn_puts, - NULL, /* connect_gets, */ - conn_ctrl, - conn_new, - conn_free, - conn_callback_ctrl, + .type = BIO_TYPE_CONNECT, + .name = "socket connect", + .bwrite = conn_write, + .bread = conn_read, + .bputs = conn_puts, + .ctrl = conn_ctrl, + .create = conn_new, + .destroy = conn_free, + .callback_ctrl = conn_callback_ctrl }; static int diff --git a/lib/libssl/src/crypto/bio/bss_dgram.c b/lib/libssl/src/crypto/bio/bss_dgram.c index 8c08eff3520..8f7439c51e6 100644 --- a/lib/libssl/src/crypto/bio/bss_dgram.c +++ b/lib/libssl/src/crypto/bio/bss_dgram.c @@ -106,30 +106,26 @@ static int BIO_dgram_should_retry(int s); static void get_current_time(struct timeval *t); static BIO_METHOD methods_dgramp = { - BIO_TYPE_DGRAM, - "datagram socket", - dgram_write, - dgram_read, - dgram_puts, - NULL, /* dgram_gets, */ - dgram_ctrl, - dgram_new, - dgram_free, - NULL, + .type = BIO_TYPE_DGRAM, + .name = "datagram socket", + .bwrite = dgram_write, + .bread = dgram_read, + .bputs = dgram_puts, + .ctrl = dgram_ctrl, + .create = dgram_new, + .destroy = dgram_free }; #ifndef OPENSSL_NO_SCTP static BIO_METHOD methods_dgramp_sctp = { - BIO_TYPE_DGRAM_SCTP, - "datagram sctp socket", - dgram_sctp_write, - dgram_sctp_read, - dgram_sctp_puts, - NULL, /* dgram_gets, */ - dgram_sctp_ctrl, - dgram_sctp_new, - dgram_sctp_free, - NULL, + .type = BIO_TYPE_DGRAM_SCTP, + .name = "datagram sctp socket", + .bwrite = dgram_sctp_write, + .bread = dgram_sctp_read, + .bputs = dgram_sctp_puts, + .ctrl = dgram_sctp_ctrl, + .create = dgram_sctp_new, + .destroy = dgram_sctp_free }; #endif diff --git a/lib/libssl/src/crypto/bio/bss_fd.c b/lib/libssl/src/crypto/bio/bss_fd.c index 8ea80f1f65c..04a88a155b7 100644 --- a/lib/libssl/src/crypto/bio/bss_fd.c +++ b/lib/libssl/src/crypto/bio/bss_fd.c @@ -79,15 +79,15 @@ static int fd_free(BIO *data); int BIO_fd_should_retry(int s); static BIO_METHOD methods_fdp = { - BIO_TYPE_FD, "file descriptor", - fd_write, - fd_read, - fd_puts, - fd_gets, - fd_ctrl, - fd_new, - fd_free, - NULL, + .type = BIO_TYPE_FD, + .name = "file descriptor", + .bwrite = fd_write, + .bread = fd_read, + .bputs = fd_puts, + .bgets = fd_gets, + .ctrl = fd_ctrl, + .create = fd_new, + .destroy = fd_free }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bss_file.c b/lib/libssl/src/crypto/bio/bss_file.c index 6d5444f666a..6f81a45a475 100644 --- a/lib/libssl/src/crypto/bio/bss_file.c +++ b/lib/libssl/src/crypto/bio/bss_file.c @@ -100,16 +100,15 @@ static int file_new(BIO *h); static int file_free(BIO *data); static BIO_METHOD methods_filep = { - BIO_TYPE_FILE, - "FILE pointer", - file_write, - file_read, - file_puts, - file_gets, - file_ctrl, - file_new, - file_free, - NULL, + .type = BIO_TYPE_FILE, + .name = "FILE pointer", + .bwrite = file_write, + .bread = file_read, + .bputs = file_puts, + .bgets = file_gets, + .ctrl = file_ctrl, + .create = file_new, + .destroy = file_free }; BIO * diff --git a/lib/libssl/src/crypto/bio/bss_log.c b/lib/libssl/src/crypto/bio/bss_log.c index 6aa2d8b0a49..ac1cbc5087b 100644 --- a/lib/libssl/src/crypto/bio/bss_log.c +++ b/lib/libssl/src/crypto/bio/bss_log.c @@ -86,15 +86,13 @@ static void xsyslog(BIO* bp, int priority, const char* string); static void xcloselog(BIO* bp); static BIO_METHOD methods_slg = { - BIO_TYPE_MEM, "syslog", - slg_write, - NULL, - slg_puts, - NULL, - slg_ctrl, - slg_new, - slg_free, - NULL, + .type = BIO_TYPE_MEM, + .name = "syslog", + .bwrite = slg_write, + .bputs = slg_puts, + .ctrl = slg_ctrl, + .create = slg_new, + .destroy = slg_free }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bss_mem.c b/lib/libssl/src/crypto/bio/bss_mem.c index 1a477c12be3..b147a8eccb7 100644 --- a/lib/libssl/src/crypto/bio/bss_mem.c +++ b/lib/libssl/src/crypto/bio/bss_mem.c @@ -70,16 +70,15 @@ static int mem_new(BIO *h); static int mem_free(BIO *data); static BIO_METHOD mem_method = { - BIO_TYPE_MEM, - "memory buffer", - mem_write, - mem_read, - mem_puts, - mem_gets, - mem_ctrl, - mem_new, - mem_free, - NULL, + .type = BIO_TYPE_MEM, + .name = "memory buffer", + .bwrite = mem_write, + .bread = mem_read, + .bputs = mem_puts, + .bgets = mem_gets, + .ctrl = mem_ctrl, + .create = mem_new, + .destroy = mem_free }; /* bio->num is used to hold the value to return on 'empty', if it is diff --git a/lib/libssl/src/crypto/bio/bss_null.c b/lib/libssl/src/crypto/bio/bss_null.c index c7289725d98..a5796ea87a0 100644 --- a/lib/libssl/src/crypto/bio/bss_null.c +++ b/lib/libssl/src/crypto/bio/bss_null.c @@ -70,16 +70,15 @@ static int null_new(BIO *h); static int null_free(BIO *data); static BIO_METHOD null_method = { - BIO_TYPE_NULL, - "NULL", - null_write, - null_read, - null_puts, - null_gets, - null_ctrl, - null_new, - null_free, - NULL, + .type = BIO_TYPE_NULL, + .name = "NULL", + .bwrite = null_write, + .bread = null_read, + .bputs = null_puts, + .bgets = null_gets, + .ctrl = null_ctrl, + .create = null_new, + .destroy = null_free }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/bio/bss_sock.c b/lib/libssl/src/crypto/bio/bss_sock.c index 3dae2562bf5..757e1dbb8f0 100644 --- a/lib/libssl/src/crypto/bio/bss_sock.c +++ b/lib/libssl/src/crypto/bio/bss_sock.c @@ -74,16 +74,14 @@ static int sock_free(BIO *data); int BIO_sock_should_retry(int s); static BIO_METHOD methods_sockp = { - BIO_TYPE_SOCKET, - "socket", - sock_write, - sock_read, - sock_puts, - NULL, /* sock_gets, */ - sock_ctrl, - sock_new, - sock_free, - NULL, + .type = BIO_TYPE_SOCKET, + .name = "socket", + .bwrite = sock_write, + .bread = sock_read, + .bputs = sock_puts, + .ctrl = sock_ctrl, + .create = sock_new, + .destroy = sock_free }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/cmac/cm_ameth.c b/lib/libssl/src/crypto/cmac/cm_ameth.c index 0b8e5670b0e..c960e1cf43b 100644 --- a/lib/libssl/src/crypto/cmac/cm_ameth.c +++ b/lib/libssl/src/crypto/cmac/cm_ameth.c @@ -73,25 +73,14 @@ static void cmac_key_free(EVP_PKEY *pkey) CMAC_CTX_free(cmctx); } -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, +const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = { + .pkey_id = EVP_PKEY_CMAC, + .pkey_base_id = EVP_PKEY_CMAC, - cmac_size, - 0, - 0,0,0,0,0,0,0, + .pem_str = "CMAC", + .info = "OpenSSL CMAC method", - cmac_key_free, - 0, - 0,0 - }; + .pkey_size = cmac_size, + .pkey_free = cmac_key_free +}; diff --git a/lib/libssl/src/crypto/cmac/cm_pmeth.c b/lib/libssl/src/crypto/cmac/cm_pmeth.c index 00aa4d64d2b..e1a00e90bb9 100644 --- a/lib/libssl/src/crypto/cmac/cm_pmeth.c +++ b/lib/libssl/src/crypto/cmac/cm_pmeth.c @@ -188,37 +188,19 @@ static int pkey_cmac_ctrl_str(EVP_PKEY_CTX *ctx, return -2; } -const EVP_PKEY_METHOD cmac_pkey_meth = - { - EVP_PKEY_CMAC, - EVP_PKEY_FLAG_SIGCTX_CUSTOM, - pkey_cmac_init, - pkey_cmac_copy, - pkey_cmac_cleanup, - - 0, 0, - - 0, - pkey_cmac_keygen, - - 0, 0, - - 0, 0, - - 0,0, - - cmac_signctx_init, - cmac_signctx, - - 0,0, - - 0,0, +const EVP_PKEY_METHOD cmac_pkey_meth = { + .pkey_id = EVP_PKEY_CMAC, + .flags = EVP_PKEY_FLAG_SIGCTX_CUSTOM, - 0,0, + .init = pkey_cmac_init, + .copy = pkey_cmac_copy, + .cleanup = pkey_cmac_cleanup, - 0,0, + .keygen = pkey_cmac_keygen, - pkey_cmac_ctrl, - pkey_cmac_ctrl_str + .signctx_init = cmac_signctx_init, + .signctx = cmac_signctx, - }; + .ctrl = pkey_cmac_ctrl, + .ctrl_str = pkey_cmac_ctrl_str +}; diff --git a/lib/libssl/src/crypto/comp/c_rle.c b/lib/libssl/src/crypto/comp/c_rle.c index 7a5db298c5e..48e48cbb7aa 100644 --- a/lib/libssl/src/crypto/comp/c_rle.c +++ b/lib/libssl/src/crypto/comp/c_rle.c @@ -10,14 +10,10 @@ static int rle_expand_block(COMP_CTX *ctx, unsigned char *out, unsigned int olen, unsigned char *in, unsigned int ilen); static COMP_METHOD rle_method = { - NID_rle_compression, - LN_rle_compression, - NULL, - NULL, - rle_compress_block, - rle_expand_block, - NULL, - NULL, + .type = NID_rle_compression, + .name = LN_rle_compression, + .compress = rle_compress_block, + .expand = rle_expand_block }; COMP_METHOD * diff --git a/lib/libssl/src/crypto/comp/c_zlib.c b/lib/libssl/src/crypto/comp/c_zlib.c index 3a73b3df0bd..26c6507cd5d 100644 --- a/lib/libssl/src/crypto/comp/c_zlib.c +++ b/lib/libssl/src/crypto/comp/c_zlib.c @@ -8,14 +8,8 @@ COMP_METHOD *COMP_zlib(void ); static COMP_METHOD zlib_method_nozlib = { - NID_undef, - "(undef)", - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + .type = NID_undef, + .name = "(undef)" }; #ifndef ZLIB @@ -55,26 +49,20 @@ static int zz_uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen); static COMP_METHOD zlib_stateless_method = { - NID_zlib_compression, - LN_zlib_compression, - NULL, - NULL, - zlib_compress_block, - zlib_expand_block, - NULL, - NULL, + .type = NID_zlib_compression, + .name = LN_zlib_compression, + .compress = zlib_compress_block, + .expand = zlib_expand_block }; #endif static COMP_METHOD zlib_stateful_method = { - NID_zlib_compression, - LN_zlib_compression, - zlib_stateful_init, - zlib_stateful_finish, - zlib_stateful_compress_block, - zlib_stateful_expand_block, - NULL, - NULL, + .type = NID_zlib_compression, + .name = LN_zlib_compression, + .init = zlib_stateful_init, + .finish = zlib_stateful_finish, + .compress = zlib_stateful_compress_block, + .expand = zlib_stateful_expand_block }; #ifdef ZLIB_SHARED @@ -433,16 +421,14 @@ static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr); static long bio_zlib_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp); static BIO_METHOD bio_meth_zlib = { - BIO_TYPE_COMP, - "zlib", - bio_zlib_write, - bio_zlib_read, - NULL, - NULL, - bio_zlib_ctrl, - bio_zlib_new, - bio_zlib_free, - bio_zlib_callback_ctrl + .type = BIO_TYPE_COMP, + .name = "zlib", + .bwrite = bio_zlib_write, + .bread = bio_zlib_read, + .ctrl = bio_zlib_ctrl, + .create = bio_zlib_new, + .destroy = bio_zlib_free, + .callback_ctrl = bio_zlib_callback_ctrl }; BIO_METHOD * diff --git a/lib/libssl/src/crypto/conf/conf_def.c b/lib/libssl/src/crypto/conf/conf_def.c index d85773df0e8..b3c75e1a9e5 100644 --- a/lib/libssl/src/crypto/conf/conf_def.c +++ b/lib/libssl/src/crypto/conf/conf_def.c @@ -91,16 +91,16 @@ static int def_to_int(const CONF *conf, char c); const char CONF_def_version[]="CONF_def" OPENSSL_VERSION_PTEXT; static CONF_METHOD default_method = { - "OpenSSL default", - def_create, - def_init_default, - def_destroy, - def_destroy_data, - def_load_bio, - def_dump, - def_is_number, - def_to_int, - def_load + .name = "OpenSSL default", + .create = def_create, + .init = def_init_default, + .destroy = def_destroy, + .destroy_data = def_destroy_data, + .load_bio = def_load_bio, + .dump = def_dump, + .is_number = def_is_number, + .to_int = def_to_int, + .load = def_load }; static CONF_METHOD WIN32_method = { diff --git a/lib/libssl/src/crypto/dh/dh_ameth.c b/lib/libssl/src/crypto/dh/dh_ameth.c index d39f4b373d3..a22614ae0a0 100644 --- a/lib/libssl/src/crypto/dh/dh_ameth.c +++ b/lib/libssl/src/crypto/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/lib/libssl/src/crypto/dh/dh_key.c b/lib/libssl/src/crypto/dh/dh_key.c index 9596270f7d4..91352a9fbf5 100644 --- a/lib/libssl/src/crypto/dh/dh_key.c +++ b/lib/libssl/src/crypto/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/lib/libssl/src/crypto/dh/dh_pmeth.c b/lib/libssl/src/crypto/dh/dh_pmeth.c index ec4553c0a89..c359bb4d2ba 100644 --- a/lib/libssl/src/crypto/dh/dh_pmeth.c +++ b/lib/libssl/src/crypto/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 +}; diff --git a/lib/libssl/src/crypto/dsa/dsa_ameth.c b/lib/libssl/src/crypto/dsa/dsa_ameth.c index e9c549802d6..ebca5ec5c51 100644 --- a/lib/libssl/src/crypto/dsa/dsa_ameth.c +++ b/lib/libssl/src/crypto/dsa/dsa_ameth.c @@ -640,65 +640,61 @@ static int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) /* NB these are sorted in pkey_id order, lowest first */ -const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = +const EVP_PKEY_ASN1_METHOD dsa_asn1_meths[] = { { + .pkey_id = EVP_PKEY_DSA2, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, - { - EVP_PKEY_DSA2, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, - - { - EVP_PKEY_DSA1, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, - - { - EVP_PKEY_DSA4, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, + { + .pkey_id = EVP_PKEY_DSA1, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, - { - EVP_PKEY_DSA3, - EVP_PKEY_DSA, - ASN1_PKEY_ALIAS - }, + { + .pkey_id = EVP_PKEY_DSA4, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, - { - EVP_PKEY_DSA, - EVP_PKEY_DSA, - 0, - - "DSA", - "OpenSSL DSA method", - - dsa_pub_decode, - dsa_pub_encode, - dsa_pub_cmp, - dsa_pub_print, - - dsa_priv_decode, - dsa_priv_encode, - dsa_priv_print, - - int_dsa_size, - dsa_bits, - - dsa_param_decode, - dsa_param_encode, - dsa_missing_parameters, - dsa_copy_parameters, - dsa_cmp_parameters, - dsa_param_print, - dsa_sig_print, - - int_dsa_free, - dsa_pkey_ctrl, - old_dsa_priv_decode, - old_dsa_priv_encode - } - }; + { + .pkey_id = EVP_PKEY_DSA3, + .pkey_base_id = EVP_PKEY_DSA, + .pkey_flags = ASN1_PKEY_ALIAS + }, + { + .pkey_id = EVP_PKEY_DSA, + .pkey_base_id = EVP_PKEY_DSA, + + .pem_str = "DSA", + .info = "OpenSSL DSA method", + + .pub_decode = dsa_pub_decode, + .pub_encode = dsa_pub_encode, + .pub_cmp = dsa_pub_cmp, + .pub_print = dsa_pub_print, + + .priv_decode = dsa_priv_decode, + .priv_encode = dsa_priv_encode, + .priv_print = dsa_priv_print, + + .pkey_size = int_dsa_size, + .pkey_bits = dsa_bits, + + .param_decode = dsa_param_decode, + .param_encode = dsa_param_encode, + .param_missing = dsa_missing_parameters, + .param_copy = dsa_copy_parameters, + .param_cmp = dsa_cmp_parameters, + .param_print = dsa_param_print, + .sig_print = dsa_sig_print, + + .pkey_free = int_dsa_free, + .pkey_ctrl = dsa_pkey_ctrl, + .old_priv_decode = old_dsa_priv_decode, + .old_priv_encode = old_dsa_priv_encode + } +}; diff --git a/lib/libssl/src/crypto/dsa/dsa_ossl.c b/lib/libssl/src/crypto/dsa/dsa_ossl.c index b3d78e524cf..7e0e3b006ef 100644 --- a/lib/libssl/src/crypto/dsa/dsa_ossl.c +++ b/lib/libssl/src/crypto/dsa/dsa_ossl.c @@ -74,18 +74,12 @@ static int dsa_init(DSA *dsa); static int dsa_finish(DSA *dsa); static DSA_METHOD openssl_dsa_meth = { -"OpenSSL DSA method", -dsa_do_sign, -dsa_sign_setup, -dsa_do_verify, -NULL, /* dsa_mod_exp, */ -NULL, /* dsa_bn_mod_exp, */ -dsa_init, -dsa_finish, -0, -NULL, -NULL, -NULL + .name = "OpenSSL DSA method", + .dsa_do_sign = dsa_do_sign, + .dsa_sign_setup = dsa_sign_setup, + .dsa_do_verify = dsa_do_verify, + .init = dsa_init, + .finish = dsa_finish }; /* These macro wrappers replace attempts to use the dsa_mod_exp() and diff --git a/lib/libssl/src/crypto/dsa/dsa_pmeth.c b/lib/libssl/src/crypto/dsa/dsa_pmeth.c index 7076bf7b676..4e77c6f64bb 100644 --- a/lib/libssl/src/crypto/dsa/dsa_pmeth.c +++ b/lib/libssl/src/crypto/dsa/dsa_pmeth.c @@ -281,38 +281,22 @@ static int pkey_dsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) return DSA_generate_key(pkey->pkey.dsa); } -const EVP_PKEY_METHOD dsa_pkey_meth = - { - EVP_PKEY_DSA, - EVP_PKEY_FLAG_AUTOARGLEN, - pkey_dsa_init, - pkey_dsa_copy, - pkey_dsa_cleanup, - - 0, - pkey_dsa_paramgen, - - 0, - pkey_dsa_keygen, - - 0, - pkey_dsa_sign, - - 0, - pkey_dsa_verify, - - 0,0, - - 0,0,0,0, +const EVP_PKEY_METHOD dsa_pkey_meth = { + .pkey_id = EVP_PKEY_DSA, + .flags = EVP_PKEY_FLAG_AUTOARGLEN, - 0,0, + .init = pkey_dsa_init, + .copy = pkey_dsa_copy, + .cleanup = pkey_dsa_cleanup, - 0,0, + .paramgen = pkey_dsa_paramgen, - 0,0, + .keygen = pkey_dsa_keygen, - pkey_dsa_ctrl, - pkey_dsa_ctrl_str + .sign = pkey_dsa_sign, + .verify = pkey_dsa_verify, - }; + .ctrl = pkey_dsa_ctrl, + .ctrl_str = pkey_dsa_ctrl_str +}; diff --git a/lib/libssl/src/crypto/dso/dso_dlfcn.c b/lib/libssl/src/crypto/dso/dso_dlfcn.c index 6cf9ab2667d..bebfdcdbc41 100644 --- a/lib/libssl/src/crypto/dso/dso_dlfcn.c +++ b/lib/libssl/src/crypto/dso/dso_dlfcn.c @@ -93,23 +93,15 @@ static int dlfcn_pathbyaddr(void *addr, char *path, int sz); static void *dlfcn_globallookup(const char *name); static DSO_METHOD dso_meth_dlfcn = { - "OpenSSL 'dlfcn' shared library method", - dlfcn_load, - dlfcn_unload, - dlfcn_bind_var, - dlfcn_bind_func, -/* For now, "unbind" doesn't exist */ -#if 0 - NULL, /* unbind_var */ - NULL, /* unbind_func */ -#endif - NULL, /* ctrl */ - dlfcn_name_converter, - dlfcn_merger, - NULL, /* init */ - NULL, /* finish */ - dlfcn_pathbyaddr, - dlfcn_globallookup + .name = "OpenSSL 'dlfcn' shared library method", + .dso_load = dlfcn_load, + .dso_unload = dlfcn_unload, + .dso_bind_var = dlfcn_bind_var, + .dso_bind_func = dlfcn_bind_func, + .dso_name_converter = dlfcn_name_converter, + .dso_merger = dlfcn_merger, + .pathbyaddr = dlfcn_pathbyaddr, + .globallookup = dlfcn_globallookup }; DSO_METHOD * diff --git a/lib/libssl/src/crypto/dso/dso_null.c b/lib/libssl/src/crypto/dso/dso_null.c index 0c877ab2f26..c9f4226cb5f 100644 --- a/lib/libssl/src/crypto/dso/dso_null.c +++ b/lib/libssl/src/crypto/dso/dso_null.c @@ -64,23 +64,7 @@ #include static DSO_METHOD dso_meth_null = { - "NULL shared library method", - NULL, /* load */ - NULL, /* unload */ - NULL, /* bind_var */ - NULL, /* bind_func */ -/* For now, "unbind" doesn't exist */ -#if 0 - NULL, /* unbind_var */ - NULL, /* unbind_func */ -#endif - NULL, /* ctrl */ - NULL, /* dso_name_converter */ - NULL, /* dso_merger */ - NULL, /* init */ - NULL, /* finish */ - NULL, /* pathbyaddr */ - NULL /* globallookup */ + .name = "NULL shared library method" }; DSO_METHOD * diff --git a/lib/libssl/src/crypto/ec/ec2_smpl.c b/lib/libssl/src/crypto/ec/ec2_smpl.c index 0cf681fa9df..5682bfab377 100644 --- a/lib/libssl/src/crypto/ec/ec2_smpl.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_ameth.c b/lib/libssl/src/crypto/ec/ec_ameth.c index 79dd11083ec..0e6381f5439 100644 --- a/lib/libssl/src/crypto/ec/ec_ameth.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ec_pmeth.c b/lib/libssl/src/crypto/ec/ec_pmeth.c index dfc8ace27b2..c970d8c9ca2 100644 --- a/lib/libssl/src/crypto/ec/ec_pmeth.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_mont.c b/lib/libssl/src/crypto/ec/ecp_mont.c index cee0fee12a6..6b5b856344e 100644 --- a/lib/libssl/src/crypto/ec/ecp_mont.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_nist.c b/lib/libssl/src/crypto/ec/ecp_nist.c index ac5b8142388..479cff8fc93 100644 --- a/lib/libssl/src/crypto/ec/ecp_nist.c +++ b/lib/libssl/src/crypto/ec/ecp_nist.c @@ -67,49 +67,48 @@ #include #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/libssl/src/crypto/ec/ecp_nistp224.c b/lib/libssl/src/crypto/ec/ecp_nistp224.c index 03f2d9c1d7b..696024a5495 100644 --- a/lib/libssl/src/crypto/ec/ecp_nistp224.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_nistp256.c b/lib/libssl/src/crypto/ec/ecp_nistp256.c index 947fb7eee00..132ca0d2507 100644 --- a/lib/libssl/src/crypto/ec/ecp_nistp256.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_nistp521.c b/lib/libssl/src/crypto/ec/ecp_nistp521.c index 24eb0329513..c34c38b7e83 100644 --- a/lib/libssl/src/crypto/ec/ecp_nistp521.c +++ b/lib/libssl/src/crypto/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/libssl/src/crypto/ec/ecp_smpl.c b/lib/libssl/src/crypto/ec/ecp_smpl.c index a1467528170..c99348f08f5 100644 --- a/lib/libssl/src/crypto/ec/ecp_smpl.c +++ b/lib/libssl/src/crypto/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 diff --git a/lib/libssl/src/crypto/ecdh/ech_ossl.c b/lib/libssl/src/crypto/ecdh/ech_ossl.c index a63eb4922db..129475f7bb4 100644 --- a/lib/libssl/src/crypto/ecdh/ech_ossl.c +++ b/lib/libssl/src/crypto/ecdh/ech_ossl.c @@ -84,14 +84,8 @@ static int ecdh_compute_key(void *out, size_t len, const EC_POINT *pub_key, void *(*KDF)(const void *in, size_t inlen, void *out, size_t *outlen)); static ECDH_METHOD openssl_ecdh_meth = { - "OpenSSL ECDH method", - ecdh_compute_key, -#if 0 - NULL, /* init */ - NULL, /* finish */ -#endif - 0, /* flags */ - NULL /* app_data */ + .name = "OpenSSL ECDH method", + .compute_key = ecdh_compute_key }; const ECDH_METHOD *ECDH_OpenSSL(void) diff --git a/lib/libssl/src/crypto/ecdsa/ecs_ossl.c b/lib/libssl/src/crypto/ecdsa/ecs_ossl.c index 7725935610e..4a6e04e9460 100644 --- a/lib/libssl/src/crypto/ecdsa/ecs_ossl.c +++ b/lib/libssl/src/crypto/ecdsa/ecs_ossl.c @@ -69,16 +69,10 @@ static int ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, EC_KEY *eckey); static ECDSA_METHOD openssl_ecdsa_meth = { - "OpenSSL ECDSA method", - ecdsa_do_sign, - ecdsa_sign_setup, - ecdsa_do_verify, -#if 0 - NULL, /* init */ - NULL, /* finish */ -#endif - 0, /* flags */ - NULL /* app_data */ + .name = "OpenSSL ECDSA method", + .ecdsa_do_sign = ecdsa_do_sign, + .ecdsa_sign_setup = ecdsa_sign_setup, + .ecdsa_do_verify = ecdsa_do_verify }; const ECDSA_METHOD *ECDSA_OpenSSL(void) diff --git a/lib/libssl/src/crypto/engine/eng_padlock.c b/lib/libssl/src/crypto/engine/eng_padlock.c index d5d9a16bf24..c27181ba758 100644 --- a/lib/libssl/src/crypto/engine/eng_padlock.c +++ b/lib/libssl/src/crypto/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/lib/libssl/src/crypto/engine/eng_rdrand.c b/lib/libssl/src/crypto/engine/eng_rdrand.c index 4e9e91d54b1..ba1b5bfbffd 100644 --- a/lib/libssl/src/crypto/engine/eng_rdrand.c +++ b/lib/libssl/src/crypto/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/lib/libssl/src/crypto/engine/eng_rsax.c b/lib/libssl/src/crypto/engine/eng_rsax.c index fa9159499db..c0f6851601c 100644 --- a/lib/libssl/src/crypto/engine/eng_rsax.c +++ b/lib/libssl/src/crypto/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/lib/libssl/src/crypto/engine/hw_cryptodev.c b/lib/libssl/src/crypto/engine/hw_cryptodev.c index 190dcc4f753..9b24511b693 100644 --- a/lib/libssl/src/crypto/engine/hw_cryptodev.c +++ b/lib/libssl/src/crypto/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" }; /* diff --git a/lib/libssl/src/crypto/evp/bio_b64.c b/lib/libssl/src/crypto/evp/bio_b64.c index 27fc587ca80..02631ec05a0 100644 --- a/lib/libssl/src/crypto/evp/bio_b64.c +++ b/lib/libssl/src/crypto/evp/bio_b64.c @@ -91,18 +91,17 @@ typedef struct b64_struct char tmp[B64_BLOCK_SIZE]; } BIO_B64_CTX; -static BIO_METHOD methods_b64= - { - BIO_TYPE_BASE64,"base64 encoding", - b64_write, - b64_read, - b64_puts, - NULL, /* b64_gets, */ - b64_ctrl, - b64_new, - b64_free, - b64_callback_ctrl, - }; +static BIO_METHOD methods_b64= { + .type = BIO_TYPE_BASE64, + .name = "base64 encoding", + .bwrite = b64_write, + .bread = b64_read, + .bputs = b64_puts, + .ctrl = b64_ctrl, + .create = b64_new, + .destroy = b64_free, + .callback_ctrl = b64_callback_ctrl +}; BIO_METHOD *BIO_f_base64(void) { diff --git a/lib/libssl/src/crypto/evp/bio_enc.c b/lib/libssl/src/crypto/evp/bio_enc.c index 8fe9a45e481..3362c257681 100644 --- a/lib/libssl/src/crypto/evp/bio_enc.c +++ b/lib/libssl/src/crypto/evp/bio_enc.c @@ -87,18 +87,16 @@ typedef struct enc_struct char buf[ENC_BLOCK_SIZE+BUF_OFFSET+2]; } BIO_ENC_CTX; -static BIO_METHOD methods_enc= - { - BIO_TYPE_CIPHER,"cipher", - enc_write, - enc_read, - NULL, /* enc_puts, */ - NULL, /* enc_gets, */ - enc_ctrl, - enc_new, - enc_free, - enc_callback_ctrl, - }; +static BIO_METHOD methods_enc= { + .type = BIO_TYPE_CIPHER, + .name = "cipher", + .bwrite = enc_write, + .bread = enc_read, + .ctrl = enc_ctrl, + .create = enc_new, + .destroy = enc_free, + .callback_ctrl = enc_callback_ctrl +}; BIO_METHOD *BIO_f_cipher(void) { diff --git a/lib/libssl/src/crypto/evp/bio_md.c b/lib/libssl/src/crypto/evp/bio_md.c index 144fdfd56a0..85eead6c952 100644 --- a/lib/libssl/src/crypto/evp/bio_md.c +++ b/lib/libssl/src/crypto/evp/bio_md.c @@ -74,18 +74,17 @@ static int md_new(BIO *h); static int md_free(BIO *data); static long md_callback_ctrl(BIO *h,int cmd,bio_info_cb *fp); -static BIO_METHOD methods_md= - { - BIO_TYPE_MD,"message digest", - md_write, - md_read, - NULL, /* md_puts, */ - md_gets, - md_ctrl, - md_new, - md_free, - md_callback_ctrl, - }; +static BIO_METHOD methods_md = { + .type = BIO_TYPE_MD, + .name = "message digest", + .bwrite = md_write, + .bread = md_read, + .bgets = md_gets, + .ctrl = md_ctrl, + .create = md_new, + .destroy = md_free, + .callback_ctrl = md_callback_ctrl +}; BIO_METHOD *BIO_f_md(void) { diff --git a/lib/libssl/src/crypto/evp/bio_ok.c b/lib/libssl/src/crypto/evp/bio_ok.c index 09a762ffacd..d0bcbc2bef9 100644 --- a/lib/libssl/src/crypto/evp/bio_ok.c +++ b/lib/libssl/src/crypto/evp/bio_ok.c @@ -157,18 +157,16 @@ typedef struct ok_struct unsigned char buf[IOBS]; } BIO_OK_CTX; -static BIO_METHOD methods_ok= - { - BIO_TYPE_CIPHER,"reliable", - ok_write, - ok_read, - NULL, /* ok_puts, */ - NULL, /* ok_gets, */ - ok_ctrl, - ok_new, - ok_free, - ok_callback_ctrl, - }; +static BIO_METHOD methods_ok = { + .type = BIO_TYPE_CIPHER, + .name = "reliable", + .bwrite = ok_write, + .bread = ok_read, + .ctrl = ok_ctrl, + .create = ok_new, + .destroy = ok_free, + .callback_ctrl = ok_callback_ctrl +}; BIO_METHOD *BIO_f_reliable(void) { diff --git a/lib/libssl/src/crypto/hmac/hm_ameth.c b/lib/libssl/src/crypto/hmac/hm_ameth.c index fbada40d9cc..0625b066511 100644 --- a/lib/libssl/src/crypto/hmac/hm_ameth.c +++ b/lib/libssl/src/crypto/hmac/hm_ameth.c @@ -138,30 +138,20 @@ static int old_hmac_encode(const EVP_PKEY *pkey, unsigned char **pder) #endif -const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = - { - EVP_PKEY_HMAC, - EVP_PKEY_HMAC, - 0, - - "HMAC", - "OpenSSL HMAC method", - - 0,0,0,0, +const EVP_PKEY_ASN1_METHOD hmac_asn1_meth = { + .pkey_id = EVP_PKEY_HMAC, + .pkey_base_id = EVP_PKEY_HMAC, - 0,0,0, + .pem_str = "HMAC", + .info = "OpenSSL HMAC method", - hmac_size, - 0, - 0,0,0,0,0,0,0, + .pkey_size = hmac_size, - hmac_key_free, - hmac_pkey_ctrl, + .pkey_free = hmac_key_free, + .pkey_ctrl = hmac_pkey_ctrl, #ifdef HMAC_TEST_PRIVATE_KEY_FORMAT - old_hmac_decode, - old_hmac_encode -#else - 0,0 + .old_priv_decode = old_hmac_decode, + .old_priv_encode = old_hmac_encode #endif }; diff --git a/lib/libssl/src/crypto/hmac/hm_pmeth.c b/lib/libssl/src/crypto/hmac/hm_pmeth.c index f1c67329d03..4d287724c30 100644 --- a/lib/libssl/src/crypto/hmac/hm_pmeth.c +++ b/lib/libssl/src/crypto/hmac/hm_pmeth.c @@ -235,37 +235,18 @@ static int pkey_hmac_ctrl_str(EVP_PKEY_CTX *ctx, return -2; } -const EVP_PKEY_METHOD hmac_pkey_meth = - { - EVP_PKEY_HMAC, - 0, - pkey_hmac_init, - pkey_hmac_copy, - pkey_hmac_cleanup, - - 0, 0, - - 0, - pkey_hmac_keygen, - - 0, 0, - - 0, 0, - - 0,0, - - hmac_signctx_init, - hmac_signctx, - - 0,0, - - 0,0, +const EVP_PKEY_METHOD hmac_pkey_meth = { + .pkey_id = EVP_PKEY_HMAC, - 0,0, + .init = pkey_hmac_init, + .copy = pkey_hmac_copy, + .cleanup = pkey_hmac_cleanup, - 0,0, + .keygen = pkey_hmac_keygen, - pkey_hmac_ctrl, - pkey_hmac_ctrl_str + .signctx_init = hmac_signctx_init, + .signctx = hmac_signctx, - }; + .ctrl = pkey_hmac_ctrl, + .ctrl_str = pkey_hmac_ctrl_str +}; diff --git a/lib/libssl/src/crypto/pkcs7/bio_ber.c b/lib/libssl/src/crypto/pkcs7/bio_ber.c index d787495a218..216d237b4d8 100644 --- a/lib/libssl/src/crypto/pkcs7/bio_ber.c +++ b/lib/libssl/src/crypto/pkcs7/bio_ber.c @@ -106,18 +106,16 @@ typedef struct bio_ber_struct unsigned char buf[BER_BUF_SIZE]; } BIO_BER_CTX; -static BIO_METHOD methods_ber= - { - BIO_TYPE_CIPHER,"cipher", - ber_write, - ber_read, - NULL, /* ber_puts, */ - NULL, /* ber_gets, */ - ber_ctrl, - ber_new, - ber_free, - ber_callback_ctrl, - }; +static BIO_METHOD methods_ber = { + .type = BIO_TYPE_CIPHER, + .name = "cipher", + .bwrite = ber_write, + .bread = ber_read, + .ctrl = ber_ctrl, + .create = ber_new, + .destroy = ber_free, + .callback_ctrl = ber_callback_ctrl +}; BIO_METHOD *BIO_f_ber(void) { diff --git a/lib/libssl/src/crypto/rsa/rsa_ameth.c b/lib/libssl/src/crypto/rsa/rsa_ameth.c index fdd11835ad9..f0a346a70ec 100644 --- a/lib/libssl/src/crypto/rsa/rsa_ameth.c +++ b/lib/libssl/src/crypto/rsa/rsa_ameth.c @@ -657,42 +657,40 @@ static int rsa_item_sign(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn, return 2; } -const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = +const EVP_PKEY_ASN1_METHOD rsa_asn1_meths[] = { { - { - EVP_PKEY_RSA, - EVP_PKEY_RSA, - ASN1_PKEY_SIGPARAM_NULL, + .pkey_id = EVP_PKEY_RSA, + .pkey_base_id = EVP_PKEY_RSA, + .pkey_flags = ASN1_PKEY_SIGPARAM_NULL, - "RSA", - "OpenSSL RSA method", + .pem_str = "RSA", + .info = "OpenSSL RSA method", - rsa_pub_decode, - rsa_pub_encode, - rsa_pub_cmp, - rsa_pub_print, + .pub_decode = rsa_pub_decode, + .pub_encode = rsa_pub_encode, + .pub_cmp = rsa_pub_cmp, + .pub_print = rsa_pub_print, - rsa_priv_decode, - rsa_priv_encode, - rsa_priv_print, + .priv_decode = rsa_priv_decode, + .priv_encode = rsa_priv_encode, + .priv_print = rsa_priv_print, - int_rsa_size, - rsa_bits, + .pkey_size = int_rsa_size, + .pkey_bits = rsa_bits, - 0,0,0,0,0,0, + .sig_print = rsa_sig_print, - rsa_sig_print, - int_rsa_free, - rsa_pkey_ctrl, - old_rsa_priv_decode, - old_rsa_priv_encode, - rsa_item_verify, - rsa_item_sign - }, + .pkey_free = int_rsa_free, + .pkey_ctrl = rsa_pkey_ctrl, + .old_priv_decode = old_rsa_priv_decode, + .old_priv_encode = old_rsa_priv_encode, + .item_verify = rsa_item_verify, + .item_sign = rsa_item_sign + }, - { - EVP_PKEY_RSA2, - EVP_PKEY_RSA, - ASN1_PKEY_ALIAS - } - }; + { + .pkey_id = EVP_PKEY_RSA2, + .pkey_base_id = EVP_PKEY_RSA, + .pkey_flags = ASN1_PKEY_ALIAS + } +}; diff --git a/lib/libssl/src/crypto/rsa/rsa_eay.c b/lib/libssl/src/crypto/rsa/rsa_eay.c index dcf0c16a8f6..845e28877e5 100644 --- a/lib/libssl/src/crypto/rsa/rsa_eay.c +++ b/lib/libssl/src/crypto/rsa/rsa_eay.c @@ -128,22 +128,17 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx); static int RSA_eay_init(RSA *rsa); static int RSA_eay_finish(RSA *rsa); -static RSA_METHOD rsa_pkcs1_eay_meth={ - "Eric Young's PKCS#1 RSA", - RSA_eay_public_encrypt, - RSA_eay_public_decrypt, /* signature verification */ - RSA_eay_private_encrypt, /* signing */ - RSA_eay_private_decrypt, - RSA_eay_mod_exp, - BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */ - RSA_eay_init, - RSA_eay_finish, - 0, /* flags */ - NULL, - 0, /* rsa_sign */ - 0, /* rsa_verify */ - NULL /* rsa_keygen */ - }; +static RSA_METHOD rsa_pkcs1_eay_meth = { + .name = "Eric Young's PKCS#1 RSA", + .rsa_pub_enc = RSA_eay_public_encrypt, + .rsa_pub_dec = RSA_eay_public_decrypt, /* signature verification */ + .rsa_priv_enc = RSA_eay_private_encrypt, /* signing */ + .rsa_priv_dec = RSA_eay_private_decrypt, + .rsa_mod_exp = RSA_eay_mod_exp, + .bn_mod_exp = BN_mod_exp_mont, /* XXX probably we should not use Montgomery if e == 3 */ + .init = RSA_eay_init, + .finish = RSA_eay_finish, +}; const RSA_METHOD *RSA_PKCS1_SSLeay(void) { diff --git a/lib/libssl/src/crypto/rsa/rsa_null.c b/lib/libssl/src/crypto/rsa/rsa_null.c index 2f2202f142f..5b9317cb6cc 100644 --- a/lib/libssl/src/crypto/rsa/rsa_null.c +++ b/lib/libssl/src/crypto/rsa/rsa_null.c @@ -82,22 +82,15 @@ static int RSA_null_mod_exp(const BIGNUM *r0, const BIGNUM *i, RSA *rsa); #endif static int RSA_null_init(RSA *rsa); static int RSA_null_finish(RSA *rsa); -static RSA_METHOD rsa_null_meth={ - "Null RSA", - RSA_null_public_encrypt, - RSA_null_public_decrypt, - RSA_null_private_encrypt, - RSA_null_private_decrypt, - NULL, - NULL, - RSA_null_init, - RSA_null_finish, - 0, - NULL, - NULL, - NULL, - NULL - }; +static RSA_METHOD rsa_null_meth = { + .name = "Null RSA", + .rsa_pub_enc = RSA_null_public_encrypt, + .rsa_pub_dec = RSA_null_public_decrypt, + .rsa_priv_enc = RSA_null_private_encrypt, + .rsa_priv_dec = RSA_null_private_decrypt, + .init = RSA_null_init, + .finish = RSA_null_finish, +}; const RSA_METHOD *RSA_null_method(void) { diff --git a/lib/libssl/src/crypto/rsa/rsa_pmeth.c b/lib/libssl/src/crypto/rsa/rsa_pmeth.c index adec632b3bf..09ef090172b 100644 --- a/lib/libssl/src/crypto/rsa/rsa_pmeth.c +++ b/lib/libssl/src/crypto/rsa/rsa_pmeth.c @@ -609,41 +609,26 @@ static int pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) return ret; } -const EVP_PKEY_METHOD rsa_pkey_meth = - { - EVP_PKEY_RSA, - EVP_PKEY_FLAG_AUTOARGLEN, - pkey_rsa_init, - pkey_rsa_copy, - pkey_rsa_cleanup, - - 0,0, - - 0, - pkey_rsa_keygen, - - 0, - pkey_rsa_sign, - - 0, - pkey_rsa_verify, - - 0, - pkey_rsa_verifyrecover, +const EVP_PKEY_METHOD rsa_pkey_meth = { + .pkey_id = EVP_PKEY_RSA, + .flags = EVP_PKEY_FLAG_AUTOARGLEN, + .init = pkey_rsa_init, + .copy = pkey_rsa_copy, + .cleanup = pkey_rsa_cleanup, - 0,0,0,0, + .keygen = pkey_rsa_keygen, - 0, - pkey_rsa_encrypt, + .sign = pkey_rsa_sign, - 0, - pkey_rsa_decrypt, + .verify = pkey_rsa_verify, - 0,0, + .verify_recover = pkey_rsa_verifyrecover, - pkey_rsa_ctrl, - pkey_rsa_ctrl_str + .encrypt = pkey_rsa_encrypt, + .decrypt = pkey_rsa_decrypt, - }; + .ctrl = pkey_rsa_ctrl, + .ctrl_str = pkey_rsa_ctrl_str +}; diff --git a/lib/libssl/src/crypto/store/str_mem.c b/lib/libssl/src/crypto/store/str_mem.c index 997e60fe930..a73279c86b5 100644 --- a/lib/libssl/src/crypto/store/str_mem.c +++ b/lib/libssl/src/crypto/store/str_mem.c @@ -133,25 +133,22 @@ static int mem_unlock(STORE *s, OPENSSL_ITEM attributes[], OPENSSL_ITEM parameters[]); static int mem_ctrl(STORE *s, int cmd, long l, void *p, void (*f)(void)); -static STORE_METHOD store_memory = - { - "OpenSSL memory store interface", - mem_init, - mem_clean, - mem_generate, - mem_get, - mem_store, - mem_modify, - NULL, /* revoke */ - mem_delete, - mem_list_start, - mem_list_next, - mem_list_end, - mem_list_endp, - NULL, /* update */ - mem_lock, - mem_unlock, - mem_ctrl +static STORE_METHOD store_memory = { + .name = "OpenSSL memory store interface", + .init = mem_init, + .clean = mem_clean, + .generate_object = mem_generate, + .get_object = mem_get, + .store_object = mem_store, + .modify_object = mem_modify, + .delete_object = mem_delete, + .list_object_start = mem_list_start, + .list_object_next = mem_list_next, + .list_object_end = mem_list_end, + .list_object_endp = mem_list_endp, + .lock_store = mem_lock, + .unlock_store = mem_unlock, + .ctrl = mem_ctrl }; const STORE_METHOD *STORE_Memory(void) diff --git a/lib/libssl/src/crypto/ui/ui_openssl.c b/lib/libssl/src/crypto/ui/ui_openssl.c index d3be332f19e..3b79ecaf029 100644 --- a/lib/libssl/src/crypto/ui/ui_openssl.c +++ b/lib/libssl/src/crypto/ui/ui_openssl.c @@ -157,13 +157,11 @@ static int noecho_console(UI *ui); static int close_console(UI *ui); static UI_METHOD ui_openssl = { - "OpenSSL default user interface", - open_console, - write_string, - NULL, /* No flusher is needed for command lines */ - read_string, - close_console, - NULL + .name = "OpenSSL default user interface", + .ui_open_session = open_console, + .ui_write_string = write_string, + .ui_read_string = read_string, + .ui_close_session = close_console, }; /* The method with all the built-in thingies */