ssh command & valid cipher names
Marko Asplund
aspa at kronodoc.fi
Fri Nov 10 18:22:23 EST 2000
hello
i thought that it would be useful to make ssh command to print valid
cipher names in case an unknown cipher has been specified by the user for
example the command 'ssh -c list' would print:
Unknown cipher type 'list'
valid cipher names: none, des, 3des, blowfish, 3des-cbc, blowfish-cbc,
cast128-cbc, arcfour, aes128-cbc, aes192-cbc, aes256-cbc, rijndael128-cbc,
rijndael192-cbc, rijndael256-cbc, rijndael-cbc at lysator.liu.se
i've included a patch in case someone is interested in this small feature.
best regards,
--
aspa
-------------- next part --------------
*** openssh-2.3.0p1/cipher.c.dist Fri Nov 10 07:44:26 2000
--- openssh-2.3.0p1/cipher.c Fri Nov 10 08:39:20 2000
***************
*** 442,447 ****
--- 442,459 ----
return mask;
}
+ char **get_valid_cipher_names() {
+ int max_cipher_cnt = 30;
+ char **cipher_names = (char **) xmalloc(max_cipher_cnt*sizeof(char *));
+ int i;
+ Cipher *c;
+
+ for (c = ciphers, i = 0; (c->name != NULL) && i < max_cipher_cnt-1; c++, i++)
+ cipher_names[i] = c->name;
+ cipher_names[i] = NULL;
+ return cipher_names;
+ }
+
Cipher *
cipher_by_name(const char *name)
{
*** openssh-2.3.0p1/cipher.h.dist Fri Nov 10 07:51:59 2000
--- openssh-2.3.0p1/cipher.h Fri Nov 10 08:32:05 2000
***************
*** 108,113 ****
--- 108,114 ----
Cipher *cipher_by_number(int id);
int cipher_number(const char *name);
char *cipher_name(int id);
+ char **get_valid_cipher_names(void);
int ciphers_valid(const char *names);
void cipher_init(CipherContext *, Cipher *, const u_char *, u_int, const u_char *, u_int);
void cipher_encrypt(CipherContext *context, u_char *dest, const u_char *src, u_int len);
*** openssh-2.3.0p1/ssh.c.dist Fri Nov 10 07:45:47 2000
--- openssh-2.3.0p1/ssh.c Fri Nov 10 08:37:09 2000
***************
*** 58,63 ****
--- 58,64 ----
#include "key.h"
#include "authfd.h"
#include "authfile.h"
+ #include "cipher.h"
#ifdef HAVE___PROGNAME
extern char *__progname;
***************
*** 427,433 ****
--- 428,443 ----
/* SSH1 only */
Cipher *c = cipher_by_name(optarg);
if (c == NULL || c->number < 0) {
+ char **namelist;
+ int i;
fprintf(stderr, "Unknown cipher type '%s'\n", optarg);
+ fprintf(stderr, "valid cipher names: ");
+ namelist = get_valid_cipher_names();
+ for(i=0; namelist[i] != NULL; i++) {
+ if(i) fprintf(stderr, ", ");
+ fprintf(stderr, "%s", namelist[i]);
+ }
+ fprintf(stderr, "\n");
exit(1);
}
options.cipher = c->number;
More information about the openssh-unix-dev
mailing list