summaryrefslogtreecommitdiff
path: root/cipher.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-05-18 20:53:59 +1000
committerDamien Miller <djm@mindrot.org>2003-05-18 20:53:59 +1000
commitf5399c24dc53a9afebf089a013a0359e7c775a90 (patch)
treec9aba4bc854b0fb83abad0ac93d54022d9d194f4 /cipher.c
parenta9825785e864fa795d4b39d99d14bc6f9995a7dc (diff)
- markus@cvs.openbsd.org 2003/05/17 04:27:52
[cipher.c cipher-ctr.c myproposal.h] experimental support for aes-ctr modes from http://www.ietf.org/internet-drafts/draft-ietf-secsh-newmodes-00.txt ok djm@
Diffstat (limited to 'cipher.c')
-rw-r--r--cipher.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/cipher.c b/cipher.c
index acb436c8a..e7c3c5411 100644
--- a/cipher.c
+++ b/cipher.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: cipher.c,v 1.64 2003/05/15 03:08:29 markus Exp $"); 38RCSID("$OpenBSD: cipher.c,v 1.65 2003/05/17 04:27:52 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "log.h" 41#include "log.h"
@@ -55,6 +55,8 @@ extern void ssh_rijndael_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
55extern const EVP_CIPHER *evp_ssh1_bf(void); 55extern const EVP_CIPHER *evp_ssh1_bf(void);
56extern const EVP_CIPHER *evp_ssh1_3des(void); 56extern const EVP_CIPHER *evp_ssh1_3des(void);
57extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int); 57extern void ssh1_3des_iv(EVP_CIPHER_CTX *, int, u_char *, int);
58extern const EVP_CIPHER *evp_aes_128_ctr(void);
59extern void ssh_aes_ctr_iv(EVP_CIPHER_CTX *, int, u_char *, u_int);
58 60
59struct Cipher { 61struct Cipher {
60 char *name; 62 char *name;
@@ -85,6 +87,9 @@ struct Cipher {
85 { "rijndael-cbc@lysator.liu.se", 87 { "rijndael-cbc@lysator.liu.se",
86 SSH_CIPHER_SSH2, 16, 32, EVP_aes_256_cbc }, 88 SSH_CIPHER_SSH2, 16, 32, EVP_aes_256_cbc },
87#endif 89#endif
90 { "aes128-ctr", SSH_CIPHER_SSH2, 16, 16, evp_aes_128_ctr },
91 { "aes192-ctr", SSH_CIPHER_SSH2, 16, 24, evp_aes_128_ctr },
92 { "aes256-ctr", SSH_CIPHER_SSH2, 16, 32, evp_aes_128_ctr },
88 93
89 { NULL, SSH_CIPHER_ILLEGAL, 0, 0, NULL } 94 { NULL, SSH_CIPHER_ILLEGAL, 0, 0, NULL }
90}; 95};
@@ -337,6 +342,9 @@ cipher_get_keyiv(CipherContext *cc, u_char *iv, u_int len)
337 ssh_rijndael_iv(&cc->evp, 0, iv, len); 342 ssh_rijndael_iv(&cc->evp, 0, iv, len);
338 else 343 else
339#endif 344#endif
345 if (c->evptype == evp_aes_128_ctr)
346 ssh_aes_ctr_iv(&cc->evp, 0, iv, len);
347 else
340 memcpy(iv, cc->evp.iv, len); 348 memcpy(iv, cc->evp.iv, len);
341 break; 349 break;
342 case SSH_CIPHER_3DES: 350 case SSH_CIPHER_3DES:
@@ -365,6 +373,9 @@ cipher_set_keyiv(CipherContext *cc, u_char *iv)
365 ssh_rijndael_iv(&cc->evp, 1, iv, evplen); 373 ssh_rijndael_iv(&cc->evp, 1, iv, evplen);
366 else 374 else
367#endif 375#endif
376 if (c->evptype == evp_aes_128_ctr)
377 ssh_aes_ctr_iv(&cc->evp, 1, iv, evplen);
378 else
368 memcpy(cc->evp.iv, iv, evplen); 379 memcpy(cc->evp.iv, iv, evplen);
369 break; 380 break;
370 case SSH_CIPHER_3DES: 381 case SSH_CIPHER_3DES: