diff options
author | Damien Miller <djm@mindrot.org> | 2013-01-09 16:42:47 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-01-09 16:42:47 +1100 |
commit | d522c68872689e2e80d9667da1c9a18d04b001cd (patch) | |
tree | 418d206dc74252baf58aa08b6ce27d789f476378 | |
parent | 1d75abfe23cadf8cdba0bd2cfd54f3bc1ca80dc5 (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
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | cipher.c | 21 | ||||
-rw-r--r-- | configure.ac | 24 | ||||
-rw-r--r-- | openbsd-compat/openssl-compat.h | 26 |
4 files changed, 54 insertions, 20 deletions
@@ -37,6 +37,9 @@ | |||
37 | [myproposal.h packet.c ssh_config.5 sshd_config.5] | 37 | [myproposal.h packet.c ssh_config.5 sshd_config.5] |
38 | support AES-GCM as defined in RFC 5647 (but with simpler KEX handling) | 38 | support AES-GCM as defined in RFC 5647 (but with simpler KEX handling) |
39 | ok and feedback djm@ | 39 | ok and feedback djm@ |
40 | - (djm) [cipher.c configure.ac openbsd-compat/openssl-compat.h] | ||
41 | Fix merge botch, automatically detect AES-GCM in OpenSSL, move a little | ||
42 | cipher compat code to openssl-compat.h | ||
40 | 43 | ||
41 | 20121217 | 44 | 20121217 |
42 | - (dtucker) [Makefile.in] Add some scaffolding so that the new regress | 45 | - (dtucker) [Makefile.in] Add some scaffolding so that the new regress |
@@ -54,25 +54,18 @@ | |||
54 | extern const EVP_CIPHER *evp_ssh1_bf(void); | 54 | extern const EVP_CIPHER *evp_ssh1_bf(void); |
55 | extern const EVP_CIPHER *evp_ssh1_3des(void); | 55 | extern const EVP_CIPHER *evp_ssh1_3des(void); |
56 | extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int); | 56 | extern 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 | ||
61 | extern const EVP_CIPHER *evp_aes_128_ctr(void); | ||
62 | extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); | ||
63 | #endif | ||
64 | 57 | ||
65 | struct Cipher { | 58 | struct 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 | |||
484 | int | 471 | int |
485 | cipher_get_keycontext(const CipherContext *cc, u_char *dat) | 472 | cipher_get_keycontext(const CipherContext *cc, u_char *dat) |
486 | { | 473 | { |
diff --git a/configure.ac b/configure.ac index 64c231b7e..36761233c 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,4 +1,4 @@ | |||
1 | # $Id: configure.ac,v 1.499 2012/12/12 21:18:56 djm Exp $ | 1 | # $Id: configure.ac,v 1.500 2013/01/09 05:42:47 djm Exp $ |
2 | # | 2 | # |
3 | # Copyright (c) 1999-2004 Damien Miller | 3 | # Copyright (c) 1999-2004 Damien Miller |
4 | # | 4 | # |
@@ -15,7 +15,7 @@ | |||
15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | ||
17 | AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) | 17 | AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) |
18 | AC_REVISION($Revision: 1.499 $) | 18 | AC_REVISION($Revision: 1.500 $) |
19 | AC_CONFIG_SRCDIR([ssh.c]) | 19 | AC_CONFIG_SRCDIR([ssh.c]) |
20 | AC_LANG([C]) | 20 | AC_LANG([C]) |
21 | 21 | ||
@@ -2320,6 +2320,26 @@ AC_LINK_IFELSE( | |||
2320 | ] | 2320 | ] |
2321 | ) | 2321 | ) |
2322 | 2322 | ||
2323 | # Check for OpenSSL with EVP_aes_*gcm | ||
2324 | AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP]) | ||
2325 | AC_LINK_IFELSE( | ||
2326 | [AC_LANG_PROGRAM([[ | ||
2327 | #include <string.h> | ||
2328 | #include <openssl/evp.h> | ||
2329 | ]], [[ | ||
2330 | exit(EVP_aes_128_gcm() == NULL || | ||
2331 | EVP_aes_256_gcm() == NULL); | ||
2332 | ]])], | ||
2333 | [ | ||
2334 | AC_MSG_RESULT([yes]) | ||
2335 | AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1], | ||
2336 | [libcrypto has EVP AES GCM]) | ||
2337 | ], | ||
2338 | [ | ||
2339 | AC_MSG_RESULT([no]) | ||
2340 | ] | ||
2341 | ) | ||
2342 | |||
2323 | AC_MSG_CHECKING([if EVP_DigestUpdate returns an int]) | 2343 | AC_MSG_CHECKING([if EVP_DigestUpdate returns an int]) |
2324 | AC_LINK_IFELSE( | 2344 | AC_LINK_IFELSE( |
2325 | [AC_LANG_PROGRAM([[ | 2345 | [AC_LANG_PROGRAM([[ |
diff --git a/openbsd-compat/openssl-compat.h b/openbsd-compat/openssl-compat.h index a151eff38..28da3be2d 100644 --- a/openbsd-compat/openssl-compat.h +++ b/openbsd-compat/openssl-compat.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $Id: openssl-compat.h,v 1.20 2012/01/17 03:03:39 dtucker Exp $ */ | 1 | /* $Id: openssl-compat.h,v 1.21 2013/01/09 05:42:49 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> | 4 | * Copyright (c) 2005 Darren Tucker <dtucker@zip.com.au> |
@@ -63,6 +63,30 @@ extern const EVP_CIPHER *evp_rijndael(void); | |||
63 | extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); | 63 | extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #ifndef OPENSSL_HAVE_EVPCTR | ||
67 | #define EVP_aes_128_ctr evp_aes_128_ctr | ||
68 | #define EVP_aes_192_ctr evp_aes_128_ctr | ||
69 | #define EVP_aes_256_ctr evp_aes_128_ctr | ||
70 | extern const EVP_CIPHER *evp_aes_128_ctr(void); | ||
71 | extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); | ||
72 | #endif | ||
73 | |||
74 | /* Avoid some #ifdef. Code that uses these is unreachable without GCM */ | ||
75 | #if !defined(OPENSSL_HAVE_EVPGCM) && !defined(EVP_CTRL_GCM_SET_IV_FIXED) | ||
76 | # define EVP_CTRL_GCM_SET_IV_FIXED -1 | ||
77 | # define EVP_CTRL_GCM_IV_GEN -1 | ||
78 | # define EVP_CTRL_GCM_SET_TAG -1 | ||
79 | # define EVP_CTRL_GCM_GET_TAG -1 | ||
80 | #endif | ||
81 | |||
82 | #if OPENSSL_VERSION_NUMBER < 0x00907000L | ||
83 | #define EVP_X_STATE(evp) &(evp).c | ||
84 | #define EVP_X_STATE_LEN(evp) sizeof((evp).c) | ||
85 | #else | ||
86 | #define EVP_X_STATE(evp) (evp).cipher_data | ||
87 | #define EVP_X_STATE_LEN(evp) (evp).cipher->ctx_size | ||
88 | #endif | ||
89 | |||
66 | #if !defined(EVP_CTRL_SET_ACSS_MODE) | 90 | #if !defined(EVP_CTRL_SET_ACSS_MODE) |
67 | # if (OPENSSL_VERSION_NUMBER >= 0x00907000L) | 91 | # if (OPENSSL_VERSION_NUMBER >= 0x00907000L) |
68 | # define USE_CIPHER_ACSS 1 | 92 | # define USE_CIPHER_ACSS 1 |