Put the \001 prefix back on scp error messages when they're sent to
[u/mdw/putty] / sshaes.c
index 0e7ddc1..361cc64 100644 (file)
--- a/sshaes.c
+++ b/sshaes.c
@@ -32,8 +32,6 @@
 
 #include "ssh.h"
 
-typedef unsigned int word32;
-
 #define MAX_NR 14                     /* max no of rounds */
 #define MAX_NK 8                      /* max no of words in input key */
 #define MAX_NB 8                      /* max no of words in cipher blk */
@@ -1023,7 +1021,21 @@ static void aes_ssh2_decrypt_blk(unsigned char *blk, int len) {
     aes_decrypt_cbc(blk, len, &scctx);
 }
 
-static struct ssh2_cipher ssh_aes128 = {
+void aes256_encrypt_pubkey(unsigned char *key, unsigned char *blk, int len) {
+    AESContext ctx;
+    aes_setup(&ctx, 16, key, 32);
+    memset(ctx.iv, 0, sizeof(ctx.iv));
+    aes_encrypt_cbc(blk, len, &ctx);
+}
+
+void aes256_decrypt_pubkey(unsigned char *key, unsigned char *blk, int len) {
+    AESContext ctx;
+    aes_setup(&ctx, 16, key, 32);
+    memset(ctx.iv, 0, sizeof(ctx.iv));
+    aes_decrypt_cbc(blk, len, &ctx);
+}
+
+static const struct ssh2_cipher ssh_aes128 = {
     aes_csiv, aes128_cskey,
     aes_sciv, aes128_sckey,
     aes_ssh2_encrypt_blk,
@@ -1032,7 +1044,7 @@ static struct ssh2_cipher ssh_aes128 = {
     16, 128
 };
 
-static struct ssh2_cipher ssh_aes192 = {
+static const struct ssh2_cipher ssh_aes192 = {
     aes_csiv, aes192_cskey,
     aes_sciv, aes192_sckey,
     aes_ssh2_encrypt_blk,
@@ -1041,7 +1053,7 @@ static struct ssh2_cipher ssh_aes192 = {
     16, 192
 };
 
-static struct ssh2_cipher ssh_aes256 = {
+static const struct ssh2_cipher ssh_aes256 = {
     aes_csiv, aes256_cskey,
     aes_sciv, aes256_sckey,
     aes_ssh2_encrypt_blk,
@@ -1050,7 +1062,7 @@ static struct ssh2_cipher ssh_aes256 = {
     16, 256
 };
 
-static struct ssh2_cipher ssh_rijndael128 = {
+static const struct ssh2_cipher ssh_rijndael128 = {
     aes_csiv, aes128_cskey,
     aes_sciv, aes128_sckey,
     aes_ssh2_encrypt_blk,
@@ -1059,7 +1071,7 @@ static struct ssh2_cipher ssh_rijndael128 = {
     16, 128
 };
 
-static struct ssh2_cipher ssh_rijndael192 = {
+static const struct ssh2_cipher ssh_rijndael192 = {
     aes_csiv, aes192_cskey,
     aes_sciv, aes192_sckey,
     aes_ssh2_encrypt_blk,
@@ -1068,7 +1080,7 @@ static struct ssh2_cipher ssh_rijndael192 = {
     16, 192
 };
 
-static struct ssh2_cipher ssh_rijndael256 = {
+static const struct ssh2_cipher ssh_rijndael256 = {
     aes_csiv, aes256_cskey,
     aes_sciv, aes256_sckey,
     aes_ssh2_encrypt_blk,
@@ -1077,7 +1089,7 @@ static struct ssh2_cipher ssh_rijndael256 = {
     16, 256
 };
 
-static struct ssh2_cipher ssh_rijndael_lysator = {
+static const struct ssh2_cipher ssh_rijndael_lysator = {
     aes_csiv, aes256_cskey,
     aes_sciv, aes256_sckey,
     aes_ssh2_encrypt_blk,
@@ -1086,7 +1098,7 @@ static struct ssh2_cipher ssh_rijndael_lysator = {
     16, 256
 };
 
-static struct ssh2_cipher *aes_list[] = {
+static const struct ssh2_cipher *const aes_list[] = {
     &ssh_aes256,
     &ssh_rijndael256,
     &ssh_rijndael_lysator,
@@ -1096,7 +1108,7 @@ static struct ssh2_cipher *aes_list[] = {
     &ssh_rijndael128,
 };
 
-struct ssh2_ciphers ssh2_aes = {
+const struct ssh2_ciphers ssh2_aes = {
     sizeof(aes_list) / sizeof(*aes_list),
     aes_list
 };