From 422a89e208910523d654db5e670433c89730c8bb Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 14 Apr 2022 06:38:30 +0100 Subject: [PATCH] Use C99 named initialisers in all ssh_kex instances. No functional change, but this will allow me to add more fields to that structure without breaking the existing initialisers. --- crypto/diffie-hellman.c | 56 +++++++++++++++++++++++++++++------------ crypto/ecc-ssh.c | 36 +++++++++++++++++--------- crypto/rsa.c | 12 ++++++--- 3 files changed, 72 insertions(+), 32 deletions(-) diff --git a/crypto/diffie-hellman.c b/crypto/diffie-hellman.c index 914167bb..78e6fab2 100644 --- a/crypto/diffie-hellman.c +++ b/crypto/diffie-hellman.c @@ -40,8 +40,11 @@ static const struct dh_extra extra_group1 = { }; const ssh_kex ssh_diffiehellman_group1_sha1 = { - "diffie-hellman-group1-sha1", "group1", - KEXTYPE_DH, &ssh_sha1, &extra_group1, + .name = "diffie-hellman-group1-sha1", + .groupname = "group1", + .main_type = KEXTYPE_DH, + .hash = &ssh_sha1, + .extra = &extra_group1, }; static const ssh_kex *const group1_list[] = { @@ -55,13 +58,19 @@ static const struct dh_extra extra_group14 = { }; const ssh_kex ssh_diffiehellman_group14_sha256 = { - "diffie-hellman-group14-sha256", "group14", - KEXTYPE_DH, &ssh_sha256, &extra_group14, + .name = "diffie-hellman-group14-sha256", + .groupname = "group14", + .main_type = KEXTYPE_DH, + .hash = &ssh_sha256, + .extra = &extra_group14, }; const ssh_kex ssh_diffiehellman_group14_sha1 = { - "diffie-hellman-group14-sha1", "group14", - KEXTYPE_DH, &ssh_sha1, &extra_group14, + .name = "diffie-hellman-group14-sha1", + .groupname = "group14", + .main_type = KEXTYPE_DH, + .hash = &ssh_sha1, + .extra = &extra_group14, }; static const ssh_kex *const group14_list[] = { @@ -76,13 +85,19 @@ const ssh_kexes ssh_diffiehellman_group14 = { static const struct dh_extra extra_gex = { true }; static const ssh_kex ssh_diffiehellman_gex_sha256 = { - "diffie-hellman-group-exchange-sha256", NULL, - KEXTYPE_DH, &ssh_sha256, &extra_gex, + .name = "diffie-hellman-group-exchange-sha256", + .groupname = NULL, + .main_type = KEXTYPE_DH, + .hash = &ssh_sha256, + .extra = &extra_gex, }; static const ssh_kex ssh_diffiehellman_gex_sha1 = { - "diffie-hellman-group-exchange-sha1", NULL, - KEXTYPE_DH, &ssh_sha1, &extra_gex, + .name = "diffie-hellman-group-exchange-sha1", + .groupname = NULL, + .main_type = KEXTYPE_DH, + .hash = &ssh_sha1, + .extra = &extra_gex, }; static const ssh_kex *const gex_list[] = { @@ -107,18 +122,27 @@ const ssh_kexes ssh_diffiehellman_gex = { lenof(gex_list), gex_list }; #define GSS_KRB5_OID_HASH "toWM5Slw5Ew8Mqkay+al2g==" static const ssh_kex ssh_gssk5_diffiehellman_gex_sha1 = { - "gss-gex-sha1-" GSS_KRB5_OID_HASH, NULL, - KEXTYPE_GSS, &ssh_sha1, &extra_gex, + .name = "gss-gex-sha1-" GSS_KRB5_OID_HASH, + .groupname = NULL, + .main_type = KEXTYPE_GSS, + .hash = &ssh_sha1, + .extra = &extra_gex, }; static const ssh_kex ssh_gssk5_diffiehellman_group14_sha1 = { - "gss-group14-sha1-" GSS_KRB5_OID_HASH, "group14", - KEXTYPE_GSS, &ssh_sha1, &extra_group14, + .name = "gss-group14-sha1-" GSS_KRB5_OID_HASH, + .groupname = "group14", + .main_type = KEXTYPE_GSS, + .hash = &ssh_sha1, + .extra = &extra_group14, }; static const ssh_kex ssh_gssk5_diffiehellman_group1_sha1 = { - "gss-group1-sha1-" GSS_KRB5_OID_HASH, "group1", - KEXTYPE_GSS, &ssh_sha1, &extra_group1, + .name = "gss-group1-sha1-" GSS_KRB5_OID_HASH, + .groupname = "group1", + .main_type = KEXTYPE_GSS, + .hash = &ssh_sha1, + .extra = &extra_group1, }; static const ssh_kex *const gssk5_sha1_kex_list[] = { diff --git a/crypto/ecc-ssh.c b/crypto/ecc-ssh.c index d246d2b7..b2eb6e51 100644 --- a/crypto/ecc-ssh.c +++ b/crypto/ecc-ssh.c @@ -1563,13 +1563,17 @@ static const struct eckex_extra kex_extra_curve25519 = { ssh_ecdhkex_m_getkey, }; const ssh_kex ssh_ec_kex_curve25519 = { - "curve25519-sha256", NULL, KEXTYPE_ECDH, - &ssh_sha256, &kex_extra_curve25519, + .name = "curve25519-sha256", + .main_type = KEXTYPE_ECDH, + .hash = &ssh_sha256, + .extra = &kex_extra_curve25519, }; /* Pre-RFC alias */ const ssh_kex ssh_ec_kex_curve25519_libssh = { - "curve25519-sha256@libssh.org", NULL, KEXTYPE_ECDH, - &ssh_sha256, &kex_extra_curve25519, + .name = "curve25519-sha256@libssh.org", + .main_type = KEXTYPE_ECDH, + .hash = &ssh_sha256, + .extra = &kex_extra_curve25519, }; static const struct eckex_extra kex_extra_curve448 = { @@ -1580,8 +1584,10 @@ static const struct eckex_extra kex_extra_curve448 = { ssh_ecdhkex_m_getkey, }; const ssh_kex ssh_ec_kex_curve448 = { - "curve448-sha512", NULL, KEXTYPE_ECDH, - &ssh_sha512, &kex_extra_curve448, + .name = "curve448-sha512", + .main_type = KEXTYPE_ECDH, + .hash = &ssh_sha512, + .extra = &kex_extra_curve448, }; static const struct eckex_extra kex_extra_nistp256 = { @@ -1592,8 +1598,10 @@ static const struct eckex_extra kex_extra_nistp256 = { ssh_ecdhkex_w_getkey, }; const ssh_kex ssh_ec_kex_nistp256 = { - "ecdh-sha2-nistp256", NULL, KEXTYPE_ECDH, - &ssh_sha256, &kex_extra_nistp256, + .name = "ecdh-sha2-nistp256", + .main_type = KEXTYPE_ECDH, + .hash = &ssh_sha256, + .extra = &kex_extra_nistp256, }; static const struct eckex_extra kex_extra_nistp384 = { @@ -1604,8 +1612,10 @@ static const struct eckex_extra kex_extra_nistp384 = { ssh_ecdhkex_w_getkey, }; const ssh_kex ssh_ec_kex_nistp384 = { - "ecdh-sha2-nistp384", NULL, KEXTYPE_ECDH, - &ssh_sha384, &kex_extra_nistp384, + .name = "ecdh-sha2-nistp384", + .main_type = KEXTYPE_ECDH, + .hash = &ssh_sha384, + .extra = &kex_extra_nistp384, }; static const struct eckex_extra kex_extra_nistp521 = { @@ -1616,8 +1626,10 @@ static const struct eckex_extra kex_extra_nistp521 = { ssh_ecdhkex_w_getkey, }; const ssh_kex ssh_ec_kex_nistp521 = { - "ecdh-sha2-nistp521", NULL, KEXTYPE_ECDH, - &ssh_sha512, &kex_extra_nistp521, + .name = "ecdh-sha2-nistp521", + .main_type = KEXTYPE_ECDH, + .hash = &ssh_sha512, + .extra = &kex_extra_nistp521, }; static const ssh_kex *const ec_kex_list[] = { diff --git a/crypto/rsa.c b/crypto/rsa.c index ef832868..1afa766d 100644 --- a/crypto/rsa.c +++ b/crypto/rsa.c @@ -1092,13 +1092,17 @@ static const struct ssh_rsa_kex_extra ssh_rsa_kex_extra_sha1 = { 1024 }; static const struct ssh_rsa_kex_extra ssh_rsa_kex_extra_sha256 = { 2048 }; static const ssh_kex ssh_rsa_kex_sha1 = { - "rsa1024-sha1", NULL, KEXTYPE_RSA, - &ssh_sha1, &ssh_rsa_kex_extra_sha1, + .name = "rsa1024-sha1", + .main_type = KEXTYPE_RSA, + .hash = &ssh_sha1, + .extra = &ssh_rsa_kex_extra_sha1, }; static const ssh_kex ssh_rsa_kex_sha256 = { - "rsa2048-sha256", NULL, KEXTYPE_RSA, - &ssh_sha256, &ssh_rsa_kex_extra_sha256, + .name = "rsa2048-sha256", + .main_type = KEXTYPE_RSA, + .hash = &ssh_sha256, + .extra = &ssh_rsa_kex_extra_sha256, }; static const ssh_kex *const rsa_kex_list[] = {