瀏覽代碼

Merge branch 'thirdparty_dev' into dev

Source commit: d184a4d56cb6d7bc20440940e071c5f83c2722c7
Martin Prikryl 7 年之前
父節點
當前提交
02580334be
共有 3 個文件被更改,包括 15 次插入4 次删除
  1. 13 3
      source/putty/import.c
  2. 1 0
      source/putty/ssh.h
  3. 1 1
      source/putty/sshaes.c

+ 13 - 3
source/putty/import.c

@@ -1270,7 +1270,7 @@ int openssh_pem_write(const Filename *filename, struct ssh2_userkey *key,
  */
  */
 
 
 typedef enum {
 typedef enum {
-    ON_E_NONE, ON_E_AES256CBC
+    ON_E_NONE, ON_E_AES256CBC, ON_E_AES256CTR
 } openssh_new_cipher;
 } openssh_new_cipher;
 typedef enum {
 typedef enum {
     ON_K_NONE, ON_K_BCRYPT
     ON_K_NONE, ON_K_BCRYPT
@@ -1409,6 +1409,8 @@ static struct openssh_new_key *load_openssh_new_key(const Filename *filename,
         ret->cipher = ON_E_NONE;
         ret->cipher = ON_E_NONE;
     } else if (match_ssh_id(stringlen, string, "aes256-cbc")) {
     } else if (match_ssh_id(stringlen, string, "aes256-cbc")) {
         ret->cipher = ON_E_AES256CBC;
         ret->cipher = ON_E_AES256CBC;
+    } else if (match_ssh_id(stringlen, string, "aes256-ctr")) {
+        ret->cipher = ON_E_AES256CTR;
     } else {
     } else {
         errmsg = "unrecognised cipher name\n";
         errmsg = "unrecognised cipher name\n";
         goto error;
         goto error;
@@ -1568,6 +1570,7 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename,
             keysize = 0;
             keysize = 0;
             break;
             break;
           case ON_E_AES256CBC:
           case ON_E_AES256CBC:
+          case ON_E_AES256CTR:
             keysize = 48;              /* 32 byte key + 16 byte IV */
             keysize = 48;              /* 32 byte key + 16 byte IV */
             break;
             break;
           default:
           default:
@@ -1592,6 +1595,7 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename,
           case ON_E_NONE:
           case ON_E_NONE:
             break;
             break;
           case ON_E_AES256CBC:
           case ON_E_AES256CBC:
+          case ON_E_AES256CTR:
             if (key->privatelen % 16 != 0) {
             if (key->privatelen % 16 != 0) {
                 errmsg = "private key container length is not a"
                 errmsg = "private key container length is not a"
                     " multiple of AES block size\n";
                     " multiple of AES block size\n";
@@ -1601,8 +1605,14 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename,
                 void *ctx = aes_make_context();
                 void *ctx = aes_make_context();
                 aes256_key(ctx, keybuf);
                 aes256_key(ctx, keybuf);
                 aes_iv(ctx, keybuf + 32);
                 aes_iv(ctx, keybuf + 32);
-                aes_ssh2_decrypt_blk(ctx, key->privatestr,
-                                     key->privatelen);
+                if (key->cipher == ON_E_AES256CBC) {
+                    aes_ssh2_decrypt_blk(ctx, key->privatestr,
+                                         key->privatelen);
+                }
+                else {
+                    aes_ssh2_sdctr(ctx, key->privatestr,
+                                   key->privatelen);
+                }
                 aes_free_context(ctx);
                 aes_free_context(ctx);
             }
             }
             break;
             break;

+ 1 - 0
source/putty/ssh.h

@@ -500,6 +500,7 @@ void aes256_key(void *handle, unsigned char *key);
 void aes_iv(void *handle, unsigned char *iv);
 void aes_iv(void *handle, unsigned char *iv);
 void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len);
 void aes_ssh2_encrypt_blk(void *handle, unsigned char *blk, int len);
 void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len);
 void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len);
+void aes_ssh2_sdctr(void *handle, unsigned char *blk, int len);
 
 
 /*
 /*
  * PuTTY version number formatted as an SSH version string. 
  * PuTTY version number formatted as an SSH version string. 

+ 1 - 1
source/putty/sshaes.c

@@ -1172,7 +1172,7 @@ void aes_ssh2_decrypt_blk(void *handle, unsigned char *blk, int len)
     aes_decrypt_cbc(blk, len, ctx);
     aes_decrypt_cbc(blk, len, ctx);
 }
 }
 
 
-static void aes_ssh2_sdctr(void *handle, unsigned char *blk, int len)
+void aes_ssh2_sdctr(void *handle, unsigned char *blk, int len)
 {
 {
     AESContext *ctx = (AESContext *)handle;
     AESContext *ctx = (AESContext *)handle;
     aes_sdctr(blk, len, ctx);
     aes_sdctr(blk, len, ctx);