- switch (cfg.cipher) {
- case CIPHER_BLOWFISH:
- cipher_type = SSH_CIPHER_BLOWFISH;
- break;
- case CIPHER_DES:
- cipher_type = SSH_CIPHER_DES;
- break;
- case CIPHER_3DES:
- cipher_type = SSH_CIPHER_3DES;
- break;
- case CIPHER_AES:
- c_write_str("AES not supported in SSH1, falling back to 3DES\r\n");
- cipher_type = SSH_CIPHER_3DES;
- break;
- }
- if ((supported_ciphers_mask & (1 << cipher_type)) == 0) {
- c_write_str
- ("Selected cipher not supported, falling back to 3DES\r\n");
- cipher_type = SSH_CIPHER_3DES;
- if ((supported_ciphers_mask & (1 << cipher_type)) == 0) {
- bombout(("Server violates SSH 1 protocol by "
- "not supporting 3DES encryption"));
+ {
+ int cipher_chosen = 0, warn = 0;
+ char *cipher_string = NULL;
+ for (i = 0; !cipher_chosen && i < CIPHER_MAX; i++) {
+ int next_cipher = cfg.ssh_cipherlist[i];
+ if (next_cipher == CIPHER_WARN) {
+ /* If/when we choose a cipher, warn about it */
+ warn = 1;
+ } else if (next_cipher == CIPHER_AES) {
+ /* XXX Probably don't need to mention this. */
+ logevent("AES not supported in SSH1, skipping");
+ } else {
+ switch (next_cipher) {
+ case CIPHER_3DES: cipher_type = SSH_CIPHER_3DES;
+ cipher_string = "3DES"; break;
+ case CIPHER_BLOWFISH: cipher_type = SSH_CIPHER_BLOWFISH;
+ cipher_string = "Blowfish"; break;
+ case CIPHER_DES: cipher_type = SSH_CIPHER_DES;
+ cipher_string = "single-DES"; break;
+ }
+ if (supported_ciphers_mask & (1 << cipher_type))
+ cipher_chosen = 1;
+ }
+ }
+ if (!cipher_chosen) {
+ if ((supported_ciphers_mask & (1 << SSH_CIPHER_3DES)) == 0)
+ bombout(("Server violates SSH 1 protocol by not "
+ "supporting 3DES encryption"));
+ else
+ /* shouldn't happen */
+ bombout(("No supported ciphers found"));