Add AES support in SSH2. Not yet complete: there's no way to select
[u/mdw/putty] / sshdes.c
index bc1fe59..0b47aab 100644 (file)
--- a/sshdes.c
+++ b/sshdes.c
@@ -1,8 +1,4 @@
 #include <assert.h>
-#include <stdio.h> /* FIXME */
-#include <stdarg.h> /* FIXME */
-#include <windows.h> /* FIXME */
-#include "putty.h" /* FIXME */
 #include "ssh.h"
 
 
@@ -782,6 +778,18 @@ void des3_decrypt_pubkey(unsigned char *key,
     des_3cbc_decrypt(blk, blk, len, ourkeys);
 }
 
+void des3_encrypt_pubkey(unsigned char *key,
+                         unsigned char *blk, int len) {
+    DESContext ourkeys[3];
+    des_key_setup(GET_32BIT_MSB_FIRST(key),
+                  GET_32BIT_MSB_FIRST(key+4), &ourkeys[0]);
+    des_key_setup(GET_32BIT_MSB_FIRST(key+8),
+                  GET_32BIT_MSB_FIRST(key+12), &ourkeys[1]);
+    des_key_setup(GET_32BIT_MSB_FIRST(key),
+                  GET_32BIT_MSB_FIRST(key+4), &ourkeys[2]);
+    des_3cbc_encrypt(blk, blk, len, ourkeys);
+}
+
 struct ssh_cipher ssh_3des_ssh2 = {
     NULL,
     des3_csiv, des3_cskey,
@@ -789,7 +797,7 @@ struct ssh_cipher ssh_3des_ssh2 = {
     des3_ssh2_encrypt_blk,
     des3_ssh2_decrypt_blk,
     "3des-cbc",
-    8
+    8, 168
 };
 
 struct ssh_cipher ssh_3des = {
@@ -798,7 +806,7 @@ struct ssh_cipher ssh_3des = {
     des3_encrypt_blk,
     des3_decrypt_blk,
     "3des-cbc",
-    8
+    8, 168
 };
 
 static void des_sesskey(unsigned char *key) {
@@ -821,5 +829,5 @@ struct ssh_cipher ssh_des = {
     des_encrypt_blk,
     des_decrypt_blk,
     "des-cbc", /* should never be used - not a valid cipher in ssh2 */
-    8
+    8, 56
 };