Do not compile aes*-ctr with <=OpenSSL 0.9.7b

This commit is contained in:
Aris Adamantiadis
2010-04-14 20:43:06 +02:00
parent bc15f7b7aa
commit 250273cf1a
3 changed files with 18 additions and 0 deletions

View File

@@ -70,6 +70,11 @@ typedef HMAC_CTX* HMACCTX;
#define MD5_DIGEST_LEN MD5_DIGEST_LENGTH #define MD5_DIGEST_LEN MD5_DIGEST_LENGTH
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/opensslv.h>
#define OPENSSL_0_9_7b 0x0090702fL
#if (OPENSSL_VERSION_NUMBER <= OPENSSL_0_9_7b)
#define BROKEN_AES_CTR
#endif
typedef BIGNUM* bignum; typedef BIGNUM* bignum;
typedef BN_CTX* bignum_CTX; typedef BN_CTX* bignum_CTX;

View File

@@ -53,10 +53,15 @@
#define BLOWFISH "" #define BLOWFISH ""
#endif #endif
#ifdef HAVE_OPENSSL_AES_H #ifdef HAVE_OPENSSL_AES_H
#ifdef BROKEN_AES_CTR
#define AES "aes256-cbc,aes192-cbc,aes128-cbc,"
#else
#define AES "aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc," #define AES "aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc,"
#endif /* BROKEN_AES_CTR */
#else #else
#define AES "" #define AES ""
#endif #endif
#define DES "3des-cbc" #define DES "3des-cbc"
#endif #endif

View File

@@ -614,6 +614,11 @@ static void aes_decrypt(struct crypto_struct *cipher, void *in, void *out,
AES_cbc_encrypt(in, out, len, cipher->key, IV, AES_DECRYPT); AES_cbc_encrypt(in, out, len, cipher->key, IV, AES_DECRYPT);
} }
#ifndef BROKEN_AES_CTR
/* OpenSSL until 0.9.7c has a broken AES_ctr128_encrypt implementation which
* increments the counter from 2^64 instead of 1. It's better not to use it
*/
/** @internal /** @internal
* @brief encrypts/decrypts data with stream cipher AES_ctr128. 128 bits is actually * @brief encrypts/decrypts data with stream cipher AES_ctr128. 128 bits is actually
* the size of the CTR counter and incidentally the blocksize, but not the keysize. * the size of the CTR counter and incidentally the blocksize, but not the keysize.
@@ -631,6 +636,7 @@ static void aes_ctr128_encrypt(struct crypto_struct *cipher, void *in, void *out
*/ */
AES_ctr128_encrypt(in, out, len, cipher->key, IV, tmp_buffer, &num); AES_ctr128_encrypt(in, out, len, cipher->key, IV, tmp_buffer, &num);
} }
#endif /* BROKEN_AES_CTR */
#endif /* HAS_AES */ #endif /* HAS_AES */
#ifdef HAS_DES #ifdef HAS_DES
@@ -722,6 +728,7 @@ static struct crypto_struct ssh_ciphertab[] = {
}, },
#endif /* HAS_BLOWFISH */ #endif /* HAS_BLOWFISH */
#ifdef HAS_AES #ifdef HAS_AES
#ifndef BROKEN_AES_CTR
{ {
"aes128-ctr", "aes128-ctr",
16, 16,
@@ -755,6 +762,7 @@ static struct crypto_struct ssh_ciphertab[] = {
aes_ctr128_encrypt, aes_ctr128_encrypt,
aes_ctr128_encrypt aes_ctr128_encrypt
}, },
#endif /* BROKEN_AES_CTR */
{ {
"aes128-cbc", "aes128-cbc",
16, 16,