summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2013-01-09 16:42:47 +1100
committerDamien Miller <djm@mindrot.org>2013-01-09 16:42:47 +1100
commitd522c68872689e2e80d9667da1c9a18d04b001cd (patch)
tree418d206dc74252baf58aa08b6ce27d789f476378 /cipher.c
parent1d75abfe23cadf8cdba0bd2cfd54f3bc1ca80dc5 (diff)
- (djm) [cipher.c configure.ac openbsd-compat/openssl-compat.h]
Fix merge botch, automatically detect AES-GCM in OpenSSL, move a little cipher compat code to openssl-compat.h
Diffstat (limited to 'cipher.c')
-rw-r--r--cipher.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/cipher.c b/cipher.c
index cad8a2f36..e137f359b 100644
--- a/cipher.c
+++ b/cipher.c
@@ -54,25 +54,18 @@
54extern const EVP_CIPHER *evp_ssh1_bf(void); 54extern const EVP_CIPHER *evp_ssh1_bf(void);
55extern const EVP_CIPHER *evp_ssh1_3des(void); 55extern const EVP_CIPHER *evp_ssh1_3des(void);
56extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int); 56extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int);
57#ifndef OPENSSL_HAVE_EVPCTR
58#define EVP_aes_128_ctr evp_aes_128_ctr
59#define EVP_aes_192_ctr evp_aes_128_ctr
60#define EVP_aes_256_ctr evp_aes_128_ctr
61extern const EVP_CIPHER *evp_aes_128_ctr(void);
62extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
63#endif
64 57
65struct Cipher { 58struct Cipher {
66 char *name; 59 char *name;
67 int number; /* for ssh1 only */ 60 int number; /* for ssh1 only */
68 u_int block_size; 61 u_int block_size;
69 u_int key_len; 62 u_int key_len;
63 u_int iv_len; /* defaults to block_size */
64 u_int auth_len;
70 u_int discard_len; 65 u_int discard_len;
71 u_int cbc_mode; 66 u_int cbc_mode;
72 const EVP_CIPHER *(*evptype)(void); 67 const EVP_CIPHER *(*evptype)(void);
73} ciphers[] = { 68} ciphers[] = {
74 { NULL, SSH_CIPHER_INVALID, 0, 0, 0, 0, NULL }
75
76 { "none", SSH_CIPHER_NONE, 8, 0, 0, 0, 0, 0, EVP_enc_null }, 69 { "none", SSH_CIPHER_NONE, 8, 0, 0, 0, 0, 0, EVP_enc_null },
77 { "des", SSH_CIPHER_DES, 8, 8, 0, 0, 0, 1, EVP_des_cbc }, 70 { "des", SSH_CIPHER_DES, 8, 8, 0, 0, 0, 1, EVP_des_cbc },
78 { "3des", SSH_CIPHER_3DES, 8, 16, 0, 0, 0, 1, evp_ssh1_3des }, 71 { "3des", SSH_CIPHER_3DES, 8, 16, 0, 0, 0, 1, evp_ssh1_3des },
@@ -94,10 +87,12 @@ struct Cipher {
94 { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 0, EVP_aes_128_ctr }, 87 { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, 0, 0, EVP_aes_128_ctr },
95 { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 0, EVP_aes_192_ctr }, 88 { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, 0, 0, EVP_aes_192_ctr },
96 { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 0, EVP_aes_256_ctr }, 89 { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, 0, 0, EVP_aes_256_ctr },
90#ifdef OPENSSL_HAVE_EVPGCM
97 { "aes128-gcm@openssh.com", 91 { "aes128-gcm@openssh.com",
98 SSH_CIPHER_SSH2, 16, 16, 12, 16, 0, 0, EVP_aes_128_gcm }, 92 SSH_CIPHER_SSH2, 16, 16, 12, 16, 0, 0, EVP_aes_128_gcm },
99 { "aes256-gcm@openssh.com", 93 { "aes256-gcm@openssh.com",
100 SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm }, 94 SSH_CIPHER_SSH2, 16, 32, 12, 16, 0, 0, EVP_aes_256_gcm },
95#endif
101#ifdef USE_CIPHER_ACSS 96#ifdef USE_CIPHER_ACSS
102 { "acss@openssh.org", 97 { "acss@openssh.org",
103 SSH_CIPHER_SSH2, 16, 5, 0, 0, 0, 0, EVP_acss }, 98 SSH_CIPHER_SSH2, 16, 5, 0, 0, 0, 0, EVP_acss },
@@ -473,14 +468,6 @@ cipher_set_keyiv(CipherContext *cc, u_char *iv)
473 } 468 }
474} 469}
475 470
476#if OPENSSL_VERSION_NUMBER < 0x00907000L
477#define EVP_X_STATE(evp) &(evp).c
478#define EVP_X_STATE_LEN(evp) sizeof((evp).c)
479#else
480#define EVP_X_STATE(evp) (evp).cipher_data
481#define EVP_X_STATE_LEN(evp) (evp).cipher->ctx_size
482#endif
483
484int 471int
485cipher_get_keycontext(const CipherContext *cc, u_char *dat) 472cipher_get_keycontext(const CipherContext *cc, u_char *dat)
486{ 473{