mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
kex: Avoid trailing comma in cipher list
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com>
This commit is contained in:
23
src/kex.c
23
src/kex.c
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
#ifdef WITH_BLOWFISH_CIPHER
|
#ifdef WITH_BLOWFISH_CIPHER
|
||||||
# if defined(HAVE_OPENSSL_BLOWFISH_H) || defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBMBEDCRYPTO)
|
# if defined(HAVE_OPENSSL_BLOWFISH_H) || defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBMBEDCRYPTO)
|
||||||
# define BLOWFISH "blowfish-cbc,"
|
# define BLOWFISH ",blowfish-cbc"
|
||||||
# else
|
# else
|
||||||
# define BLOWFISH ""
|
# define BLOWFISH ""
|
||||||
# endif
|
# endif
|
||||||
@ -58,10 +58,9 @@
|
|||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
# define AES "aes256-gcm@openssh.com,aes128-gcm@openssh.com," \
|
# define AES "aes256-gcm@openssh.com,aes128-gcm@openssh.com," \
|
||||||
"aes256-ctr,aes192-ctr,aes128-ctr,"
|
"aes256-ctr,aes192-ctr,aes128-ctr"
|
||||||
# define AES_CBC "aes256-cbc,aes192-cbc,aes128-cbc,"
|
# define AES_CBC ",aes256-cbc,aes192-cbc,aes128-cbc"
|
||||||
# define DES "3des-cbc"
|
# define DES_SUPPORTED ",3des-cbc"
|
||||||
# define DES_SUPPORTED "3des-cbc"
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO)
|
#elif defined(HAVE_LIBMBEDCRYPTO)
|
||||||
# ifdef MBEDTLS_GCM_C
|
# ifdef MBEDTLS_GCM_C
|
||||||
@ -69,23 +68,21 @@
|
|||||||
# else
|
# else
|
||||||
# define GCM ""
|
# define GCM ""
|
||||||
# endif /* MBEDTLS_GCM_C */
|
# endif /* MBEDTLS_GCM_C */
|
||||||
# define AES GCM "aes256-ctr,aes192-ctr,aes128-ctr,"
|
# define AES GCM "aes256-ctr,aes192-ctr,aes128-ctr"
|
||||||
# define AES_CBC "aes256-cbc,aes192-cbc,aes128-cbc,"
|
# define AES_CBC ",aes256-cbc,aes192-cbc,aes128-cbc"
|
||||||
# define DES "3des-cbc"
|
# define DES_SUPPORTED ",3des-cbc"
|
||||||
# define DES_SUPPORTED "3des-cbc"
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBCRYPTO)
|
#elif defined(HAVE_LIBCRYPTO)
|
||||||
# ifdef HAVE_OPENSSL_AES_H
|
# ifdef HAVE_OPENSSL_AES_H
|
||||||
# define GCM "aes256-gcm@openssh.com,aes128-gcm@openssh.com,"
|
# define GCM "aes256-gcm@openssh.com,aes128-gcm@openssh.com,"
|
||||||
# define AES GCM "aes256-ctr,aes192-ctr,aes128-ctr,"
|
# define AES GCM "aes256-ctr,aes192-ctr,aes128-ctr"
|
||||||
# define AES_CBC "aes256-cbc,aes192-cbc,aes128-cbc,"
|
# define AES_CBC ",aes256-cbc,aes192-cbc,aes128-cbc"
|
||||||
# else /* HAVE_OPENSSL_AES_H */
|
# else /* HAVE_OPENSSL_AES_H */
|
||||||
# define AES ""
|
# define AES ""
|
||||||
# define AES_CBC ""
|
# define AES_CBC ""
|
||||||
# endif /* HAVE_OPENSSL_AES_H */
|
# endif /* HAVE_OPENSSL_AES_H */
|
||||||
|
|
||||||
# define DES "3des-cbc"
|
# define DES_SUPPORTED ",3des-cbc"
|
||||||
# define DES_SUPPORTED "3des-cbc"
|
|
||||||
#endif /* HAVE_LIBCRYPTO */
|
#endif /* HAVE_LIBCRYPTO */
|
||||||
|
|
||||||
#ifdef WITH_ZLIB
|
#ifdef WITH_ZLIB
|
||||||
|
@ -1431,7 +1431,7 @@ static void torture_config_plus(void **state,
|
|||||||
const char *def_mac = ssh_kex_get_default_methods(SSH_MAC_C_S);
|
const char *def_mac = ssh_kex_get_default_methods(SSH_MAC_C_S);
|
||||||
const char *fips_mac = ssh_kex_get_fips_methods(SSH_MAC_C_S);
|
const char *fips_mac = ssh_kex_get_fips_methods(SSH_MAC_C_S);
|
||||||
const char *hostkeys_added = ",ssh-rsa";
|
const char *hostkeys_added = ",ssh-rsa";
|
||||||
const char *ciphers_added = "aes128-cbc,aes256-cbc";
|
const char *ciphers_added = ",aes128-cbc,aes256-cbc";
|
||||||
const char *kex_added = ",diffie-hellman-group14-sha1,diffie-hellman-group1-sha1";
|
const char *kex_added = ",diffie-hellman-group14-sha1,diffie-hellman-group1-sha1";
|
||||||
const char *mac_added = ",hmac-sha1,hmac-sha1-etm@openssh.com";
|
const char *mac_added = ",hmac-sha1,hmac-sha1-etm@openssh.com";
|
||||||
char *awaited = NULL;
|
char *awaited = NULL;
|
||||||
@ -1558,8 +1558,6 @@ static void torture_config_minus(void **state,
|
|||||||
awaited = calloc(strlen(def_ciphers) + 1, 1);
|
awaited = calloc(strlen(def_ciphers) + 1, 1);
|
||||||
rc = snprintf(awaited, strlen(def_ciphers) + 1, "%s", def_ciphers);
|
rc = snprintf(awaited, strlen(def_ciphers) + 1, "%s", def_ciphers);
|
||||||
assert_int_equal(rc, strlen(def_ciphers));
|
assert_int_equal(rc, strlen(def_ciphers));
|
||||||
/* remove the comma at the end of the list */
|
|
||||||
awaited[strlen(awaited) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
/* remove the substring from the defaults */
|
/* remove the substring from the defaults */
|
||||||
helper_remove_substring(awaited, ciphers_removed, 0);
|
helper_remove_substring(awaited, ciphers_removed, 0);
|
||||||
@ -1676,8 +1674,6 @@ static void torture_config_caret(void **state,
|
|||||||
rc = snprintf(awaited, strlen(ciphers_prio) + strlen(def_ciphers) + 1,
|
rc = snprintf(awaited, strlen(ciphers_prio) + strlen(def_ciphers) + 1,
|
||||||
"%s%s", ciphers_prio, def_ciphers);
|
"%s%s", ciphers_prio, def_ciphers);
|
||||||
assert_int_equal(rc, strlen(ciphers_prio) + strlen(def_ciphers));
|
assert_int_equal(rc, strlen(ciphers_prio) + strlen(def_ciphers));
|
||||||
/* remove the comma at the end of the list */
|
|
||||||
awaited[strlen(awaited) - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_string_equal(session->opts.wanted_methods[SSH_CRYPT_C_S], awaited);
|
assert_string_equal(session->opts.wanted_methods[SSH_CRYPT_C_S], awaited);
|
||||||
|
Reference in New Issue
Block a user