diff options
Diffstat (limited to 'cipher.c')
-rw-r--r-- | cipher.c | 37 |
1 files changed, 31 insertions, 6 deletions
@@ -12,11 +12,11 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$Id: cipher.c,v 1.16 2000/04/06 02:32:39 damien Exp $"); | 15 | RCSID("$Id: cipher.c,v 1.17 2000/04/12 10:17:39 damien Exp $"); |
16 | 16 | ||
17 | #include "ssh.h" | 17 | #include "ssh.h" |
18 | #include "cipher.h" | 18 | #include "cipher.h" |
19 | #include "config.h" | 19 | #include "xmalloc.h" |
20 | 20 | ||
21 | #ifdef HAVE_OPENSSL | 21 | #ifdef HAVE_OPENSSL |
22 | #include <openssl/md5.h> | 22 | #include <openssl/md5.h> |
@@ -26,7 +26,9 @@ RCSID("$Id: cipher.c,v 1.16 2000/04/06 02:32:39 damien Exp $"); | |||
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * What kind of tripple DES are these 2 routines? | 29 | * This is used by SSH1: |
30 | * | ||
31 | * What kind of triple DES are these 2 routines? | ||
30 | * | 32 | * |
31 | * Why is there a redundant initialization vector? | 33 | * Why is there a redundant initialization vector? |
32 | * | 34 | * |
@@ -81,7 +83,7 @@ SSH_3CBC_DECRYPT(des_key_schedule ks1, | |||
81 | } | 83 | } |
82 | 84 | ||
83 | /* | 85 | /* |
84 | * SSH uses a variation on Blowfish, all bytes must be swapped before | 86 | * SSH1 uses a variation on Blowfish, all bytes must be swapped before |
85 | * and after encryption/decryption. Thus the swap_bytes stuff (yuk). | 87 | * and after encryption/decryption. Thus the swap_bytes stuff (yuk). |
86 | */ | 88 | */ |
87 | static void | 89 | static void |
@@ -167,10 +169,34 @@ cipher_name(int cipher) | |||
167 | { | 169 | { |
168 | if (cipher < 0 || cipher >= sizeof(cipher_names) / sizeof(cipher_names[0]) || | 170 | if (cipher < 0 || cipher >= sizeof(cipher_names) / sizeof(cipher_names[0]) || |
169 | cipher_names[cipher] == NULL) | 171 | cipher_names[cipher] == NULL) |
170 | fatal("cipher_name: bad cipher number: %d", cipher); | 172 | fatal("cipher_name: bad cipher name: %d", cipher); |
171 | return cipher_names[cipher]; | 173 | return cipher_names[cipher]; |
172 | } | 174 | } |
173 | 175 | ||
176 | /* Returns 1 if the name of the ciphers are valid. */ | ||
177 | |||
178 | #define CIPHER_SEP "," | ||
179 | int | ||
180 | ciphers_valid(const char *names) | ||
181 | { | ||
182 | char *ciphers; | ||
183 | char *p; | ||
184 | int i; | ||
185 | |||
186 | if (strcmp(names, "") == 0) | ||
187 | return 0; | ||
188 | ciphers = xstrdup(names); | ||
189 | for ((p = strtok(ciphers, CIPHER_SEP)); p; (p = strtok(NULL, CIPHER_SEP))) { | ||
190 | i = cipher_number(p); | ||
191 | if (i == -1 || !(cipher_mask2() & (1 << i))) { | ||
192 | xfree(ciphers); | ||
193 | return 0; | ||
194 | } | ||
195 | } | ||
196 | xfree(ciphers); | ||
197 | return 1; | ||
198 | } | ||
199 | |||
174 | /* | 200 | /* |
175 | * Parses the name of the cipher. Returns the number of the corresponding | 201 | * Parses the name of the cipher. Returns the number of the corresponding |
176 | * cipher, or -1 on error. | 202 | * cipher, or -1 on error. |
@@ -271,7 +297,6 @@ cipher_set_key(CipherContext *context, int cipher, const unsigned char *key, | |||
271 | memset(padded, 0, sizeof(padded)); | 297 | memset(padded, 0, sizeof(padded)); |
272 | } | 298 | } |
273 | 299 | ||
274 | |||
275 | void | 300 | void |
276 | cipher_set_key_iv(CipherContext * context, int cipher, | 301 | cipher_set_key_iv(CipherContext * context, int cipher, |
277 | const unsigned char *key, int keylen, | 302 | const unsigned char *key, int keylen, |