summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2012-12-13 08:18:56 +1100
committerDamien Miller <djm@mindrot.org>2012-12-13 08:18:56 +1100
commit25a02b0c95e01bc331267a1db0f62d3cbd7a0897 (patch)
treee968ae08dad316203054e909841d3b8367cc3b79 /cipher.c
parent8c05da3326fef892d993f0cd91808f2daf4d6a5f (diff)
- (djm) [configure.ac cipher-ctr.c] Adapt EVP AES CTR change to retain our
compat code for older OpenSSL
Diffstat (limited to 'cipher.c')
-rw-r--r--cipher.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/cipher.c b/cipher.c
index 2116b55b1..d15c226ae 100644
--- a/cipher.c
+++ b/cipher.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cipher.c,v 1.83 2012/12/11 22:31:18 markus Exp $ */ 1/* $OpenBSD: cipher.c,v 1.84 2012/12/12 16:46:10 naddy Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -54,8 +54,12 @@
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);
57extern const EVP_CIPHER *evp_aes_128_ctr(void); 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
58extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int); 61extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
62#endif
59 63
60struct Cipher { 64struct Cipher {
61 char *name; 65 char *name;
@@ -82,9 +86,9 @@ struct Cipher {
82 { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc }, 86 { "aes256-cbc", SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc },
83 { "rijndael-cbc@lysator.liu.se", 87 { "rijndael-cbc@lysator.liu.se",
84 SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc }, 88 SSH_CIPHER_SSH2, 16, 32, 0, 1, EVP_aes_256_cbc },
85 { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, evp_aes_128_ctr }, 89 { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, 0, 0, EVP_aes_128_ctr },
86 { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, evp_aes_128_ctr }, 90 { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, 0, 0, EVP_aes_192_ctr },
87 { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, evp_aes_128_ctr }, 91 { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, 0, 0, EVP_aes_256_ctr },
88#ifdef USE_CIPHER_ACSS 92#ifdef USE_CIPHER_ACSS
89 { "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss }, 93 { "acss@openssh.org", SSH_CIPHER_SSH2, 16, 5, 0, 0, EVP_acss },
90#endif 94#endif
@@ -363,10 +367,12 @@ cipher_get_keyiv(CipherContext *cc, u_char *iv, u_int len)
363 ssh_rijndael_iv(&cc->evp, 0, iv, len); 367 ssh_rijndael_iv(&cc->evp, 0, iv, len);
364 else 368 else
365#endif 369#endif
370#ifndef OPENSSL_HAVE_EVPCTR
366 if (c->evptype == evp_aes_128_ctr) 371 if (c->evptype == evp_aes_128_ctr)
367 ssh_aes_ctr_iv(&cc->evp, 0, iv, len); 372 ssh_aes_ctr_iv(&cc->evp, 0, iv, len);
368 else 373 else
369 memcpy(iv, cc->evp.iv, len); 374#endif
375 memcpy(iv, cc->evp.iv, len);
370 break; 376 break;
371 case SSH_CIPHER_3DES: 377 case SSH_CIPHER_3DES:
372 ssh1_3des_iv(&cc->evp, 0, iv, 24); 378 ssh1_3des_iv(&cc->evp, 0, iv, 24);
@@ -394,10 +400,12 @@ cipher_set_keyiv(CipherContext *cc, u_char *iv)
394 ssh_rijndael_iv(&cc->evp, 1, iv, evplen); 400 ssh_rijndael_iv(&cc->evp, 1, iv, evplen);
395 else 401 else
396#endif 402#endif
403#ifndef OPENSSL_HAVE_EVPCTR
397 if (c->evptype == evp_aes_128_ctr) 404 if (c->evptype == evp_aes_128_ctr)
398 ssh_aes_ctr_iv(&cc->evp, 1, iv, evplen); 405 ssh_aes_ctr_iv(&cc->evp, 1, iv, evplen);
399 else 406 else
400 memcpy(cc->evp.iv, iv, evplen); 407#endif
408 memcpy(cc->evp.iv, iv, evplen);
401 break; 409 break;
402 case SSH_CIPHER_3DES: 410 case SSH_CIPHER_3DES:
403 ssh1_3des_iv(&cc->evp, 1, iv, 24); 411 ssh1_3des_iv(&cc->evp, 1, iv, 24);