|
Lines 47-52
Link Here
|
| 47 |
#include "xmalloc.h" |
47 |
#include "xmalloc.h" |
| 48 |
#include "log.h" |
48 |
#include "log.h" |
| 49 |
#include "cipher.h" |
49 |
#include "cipher.h" |
|
|
50 |
#include "fips.h" |
| 51 |
#include <openssl/sha.h> |
| 50 |
|
52 |
|
| 51 |
/* compatibility with old or broken OpenSSL versions */ |
53 |
/* compatibility with old or broken OpenSSL versions */ |
| 52 |
#include "openbsd-compat/openssl-compat.h" |
54 |
#include "openbsd-compat/openssl-compat.h" |
|
Lines 65-94
Link Here
|
| 65 |
u_int discard_len; |
67 |
u_int discard_len; |
| 66 |
u_int cbc_mode; |
68 |
u_int cbc_mode; |
| 67 |
const EVP_CIPHER *(*evptype)(void); |
69 |
const EVP_CIPHER *(*evptype)(void); |
|
|
70 |
u_int fips_allowed; |
| 68 |
} ciphers[] = { |
71 |
} ciphers[] = { |
| 69 |
{ "none", SSH_CIPHER_NONE, 8, 0, 0, 0, EVP_enc_null }, |
72 |
{ "none", SSH_CIPHER_NONE, 8, 0, 0, 0, EVP_enc_null, 0 }, |
| 70 |
{ "des", SSH_CIPHER_DES, 8, 8, 0, 1, EVP_des_cbc }, |
73 |
{ "des", SSH_CIPHER_DES, 8, 8, 0, 1, EVP_des_cbc, 0 }, |
| 71 |
{ "3des", SSH_CIPHER_3DES, 8, 16, 0, 1, evp_ssh1_3des }, |
74 |
{ "3des", SSH_CIPHER_3DES, 8, 16, 0, 1, evp_ssh1_3des, 0 }, |
| 72 |
{ "blowfish", SSH_CIPHER_BLOWFISH, 8, 32, 0, 1, evp_ssh1_bf }, |
75 |
{ "blowfish", SSH_CIPHER_BLOWFISH, 8, 32, 0, 1, evp_ssh1_bf, 0 }, |
| 73 |
|
76 |
|
| 74 |
{ "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 1, EVP_des_ede3_cbc }, |
77 |
{ "3des-cbc", SSH_CIPHER_SSH2, 8, 24, 0, 1, EVP_des_ede3_cbc, 1 }, |
| 75 |
{ "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_bf_cbc }, |
78 |
{ "blowfish-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_bf_cbc, 0 }, |
| 76 |
{ "cast128-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_cast5_cbc }, |
79 |
{ "cast128-cbc", SSH_CIPHER_SSH2, 8, 16, 0, 1, EVP_cast5_cbc, 0 }, |
| 77 |
{ "arcfour", SSH_CIPHER_SSH2, 8, 16, 0, 0, EVP_rc4 }, |
80 |
{ "arcfour", SSH_CIPHER_SSH2, 8, 16, 0, 0, EVP_rc4, 0 }, |
| 78 |
{ "arcfour128", SSH_CIPHER_SSH2, 8, 16, 1536, 0, EVP_rc4 }, |
81 |
{ "arcfour128", SSH_CIPHER_SSH2, 8, 16, 1536, 0, EVP_rc4, 0 }, |
| 79 |
{ "arcfour256", SSH_CIPHER_SSH2, 8, 32, 1536, 0, EVP_rc4 }, |
82 |
{ "arcfour256", SSH_CIPHER_SSH2, 8, 32, 1536, 0, EVP_rc4, 0 }, |
| 80 |
{ "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, 1, EVP_aes_128_cbc }, |
83 |
{ "aes128-cbc", SSH_CIPHER_SSH2, 16, 16, 0, 1, EVP_aes_128_cbc, 1 }, |
| 81 |
{ "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, 1, EVP_aes_192_cbc }, |
84 |
{ "aes192-cbc", SSH_CIPHER_SSH2, 16, 24, 0, 1, EVP_aes_192_cbc, 1 }, |
| 82 |
{ "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc }, |
85 |
{ "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc, 1 }, |
| 83 |
{ "rijndael-cbc@lysator.liu.se", |
86 |
{ "rijndael-cbc@lysator.liu.se", |
| 84 |
SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc }, |
87 |
SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc, 0 }, |
| 85 |
{ "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_128_ctr }, |
88 |
{ "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_128_ctr, 1 }, |
| 86 |
{ "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_128_ctr }, |
89 |
{ "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_128_ctr, 1 }, |
| 87 |
{ "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_128_ctr }, |
90 |
{ "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_128_ctr, 1 }, |
| 88 |
#ifdef USE_CIPHER_ACSS |
91 |
#ifdef USE_CIPHER_ACSS |
| 89 |
{ "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss }, |
92 |
{ "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss, 0 }, |
| 90 |
#endif |
93 |
#endif |
| 91 |
{ NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, NULL } |
94 |
{ NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, NULL, 0 } |
| 92 |
}; |
95 |
}; |
| 93 |
|
96 |
|
| 94 |
/*--*/ |
97 |
/*--*/ |
|
Lines 163-168
Link Here
|
| 163 |
for ((p = strsep(&cp, CIPHER_SEP)); p && *p != '\0'; |
166 |
for ((p = strsep(&cp, CIPHER_SEP)); p && *p != '\0'; |
| 164 |
(p = strsep(&cp, CIPHER_SEP))) { |
167 |
(p = strsep(&cp, CIPHER_SEP))) { |
| 165 |
c = cipher_by_name(p); |
168 |
c = cipher_by_name(p); |
|
|
169 |
#ifdef OPENSSL_FIPS |
| 170 |
if (fips_mode && !(c->fips_allowed)) { |
| 171 |
debug("cipher %s disallowed in FIPS mode [%s]", p, names); |
| 172 |
xfree(cipher_list); |
| 173 |
return 0; |
| 174 |
} |
| 175 |
#endif |
| 166 |
if (c == NULL || c->number != SSH_CIPHER_SSH2) { |
176 |
if (c == NULL || c->number != SSH_CIPHER_SSH2) { |
| 167 |
debug("bad cipher %s [%s]", p, names); |
177 |
debug("bad cipher %s [%s]", p, names); |
| 168 |
xfree(cipher_list); |
178 |
xfree(cipher_list); |
|
Lines 298-306
Link Here
|
| 298 |
cipher_set_key_string(CipherContext *cc, Cipher *cipher, |
308 |
cipher_set_key_string(CipherContext *cc, Cipher *cipher, |
| 299 |
const char *passphrase, int do_encrypt) |
309 |
const char *passphrase, int do_encrypt) |
| 300 |
{ |
310 |
{ |
|
|
311 |
#ifdef OPENSSL_FIPS |
| 312 |
SHA_CTX sha; |
| 313 |
#endif |
| 301 |
MD5_CTX md; |
314 |
MD5_CTX md; |
| 302 |
u_char digest[16]; |
315 |
u_char digest[20]; |
| 303 |
|
316 |
|
|
|
317 |
#ifdef OPENSSL_FIPS |
| 318 |
if (fips_mode) { |
| 319 |
SHA1_Init(&sha); |
| 320 |
SHA1_Update(&sha, (const u_char *)passphrase, strlen(passphrase)); |
| 321 |
SHA1_Final(digest, &sha); |
| 322 |
|
| 323 |
cipher_init(cc, cipher, digest, 20, NULL, 0, do_encrypt); |
| 324 |
|
| 325 |
memset(digest, 0, sizeof(digest)); |
| 326 |
memset(&sha, 0, sizeof(sha)); |
| 327 |
return; |
| 328 |
} |
| 329 |
#endif |
| 304 |
MD5_Init(&md); |
330 |
MD5_Init(&md); |
| 305 |
MD5_Update(&md, (const u_char *)passphrase, strlen(passphrase)); |
331 |
MD5_Update(&md, (const u_char *)passphrase, strlen(passphrase)); |
| 306 |
MD5_Final(digest, &md); |
332 |
MD5_Final(digest, &md); |