version 1.23, 2000/04/12 00:18:20 |
version 1.24, 2000/04/12 07:45:43 |
|
|
|
|
#include "ssh.h" |
#include "ssh.h" |
#include "cipher.h" |
#include "cipher.h" |
|
#include "xmalloc.h" |
|
|
#include <ssl/md5.h> |
#include <ssl/md5.h> |
|
|
/* |
/* |
|
* This is used by SSH1: |
|
* |
* What kind of triple DES are these 2 routines? |
* What kind of triple DES are these 2 routines? |
* |
* |
* Why is there a redundant initialization vector? |
* Why is there a redundant initialization vector? |
|
|
} |
} |
|
|
/* |
/* |
* SSH uses a variation on Blowfish, all bytes must be swapped before |
* SSH1 uses a variation on Blowfish, all bytes must be swapped before |
* and after encryption/decryption. Thus the swap_bytes stuff (yuk). |
* and after encryption/decryption. Thus the swap_bytes stuff (yuk). |
*/ |
*/ |
static void |
static void |
|
|
{ |
{ |
if (cipher < 0 || cipher >= sizeof(cipher_names) / sizeof(cipher_names[0]) || |
if (cipher < 0 || cipher >= sizeof(cipher_names) / sizeof(cipher_names[0]) || |
cipher_names[cipher] == NULL) |
cipher_names[cipher] == NULL) |
fatal("cipher_name: bad cipher number: %d", cipher); |
fatal("cipher_name: bad cipher name: %d", cipher); |
return cipher_names[cipher]; |
return cipher_names[cipher]; |
} |
} |
|
|
|
/* Returns 1 if the name of the ciphers are valid. */ |
|
|
|
#define CIPHER_SEP "," |
|
int |
|
ciphers_valid(const char *names) |
|
{ |
|
char *ciphers; |
|
char *p; |
|
int i; |
|
|
|
if (strcmp(names, "") == 0) |
|
return 0; |
|
ciphers = xstrdup(names); |
|
for ((p = strtok(ciphers, CIPHER_SEP)); p; (p = strtok(NULL, CIPHER_SEP))) { |
|
i = cipher_number(p); |
|
if (i == -1 || !(cipher_mask2() & (1 << i))) { |
|
xfree(ciphers); |
|
return 0; |
|
} |
|
} |
|
xfree(ciphers); |
|
return 1; |
|
} |
|
|
/* |
/* |
* Parses the name of the cipher. Returns the number of the corresponding |
* Parses the name of the cipher. Returns the number of the corresponding |
* cipher, or -1 on error. |
* cipher, or -1 on error. |
|
|
} |
} |
memset(padded, 0, sizeof(padded)); |
memset(padded, 0, sizeof(padded)); |
} |
} |
|
|
|
|
void |
void |
cipher_set_key_iv(CipherContext * context, int cipher, |
cipher_set_key_iv(CipherContext * context, int cipher, |