summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-04-12 20:17:38 +1000
committerDamien Miller <djm@mindrot.org>2000-04-12 20:17:38 +1000
commit78928793fb23a3a4c80ae62eca6a7826b2987690 (patch)
treeadd8a953ac4cf06877b91624fe7f647b17e6cf6f /cipher.c
parentefb4afe0265333ce554f699c2a19ae249dd8d1b5 (diff)
- OpenBSD CVS updates:
- [channels.c] repair x11-fwd - [sshconnect.c] fix passwd prompt for ssh2, less debugging output. - [clientloop.c compat.c dsa.c kex.c sshd.c] less debugging output - [kex.c kex.h sshconnect.c sshd.c] check for reasonable public DH values - [README.openssh2 cipher.c cipher.h compat.c compat.h readconf.c] [readconf.h servconf.c servconf.h ssh.c ssh.h sshconnect.c sshd.c] add Cipher and Protocol options to ssh/sshd, e.g.: ssh -o 'Protocol 1,2' if you prefer proto 1, ssh -o 'Ciphers arcfour,3des-cbc' - [sshd.c] print 1.99 only if server supports both
Diffstat (limited to 'cipher.c')
-rw-r--r--cipher.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/cipher.c b/cipher.c
index 8911ffef6..27debf90f 100644
--- a/cipher.c
+++ b/cipher.c
@@ -12,11 +12,11 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$Id: cipher.c,v 1.16 2000/04/06 02:32:39 damien Exp $"); 15RCSID("$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 */
87static void 89static 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 ","
179int
180ciphers_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
275void 300void
276cipher_set_key_iv(CipherContext * context, int cipher, 301cipher_set_key_iv(CipherContext * context, int cipher,
277 const unsigned char *key, int keylen, 302 const unsigned char *key, int keylen,