瀏覽代碼

Updating code to PuTTY c6a8731b

Source commit: ca8dce2e11950f5aea07d6594acb26852c30e8eb
Martin Prikryl 6 年之前
父節點
當前提交
8d01b42a6c

+ 3 - 0
source/Putty.cbproj

@@ -217,6 +217,9 @@
 			<BuildOrder>29</BuildOrder>
 			<BuildOrder>21</BuildOrder>
 		</CppCompile>
+		<CppCompile Include="putty\sshauxcrypt.c">
+			<BuildOrder>78</BuildOrder>
+		</CppCompile>
 		<CppCompile Include="putty\sshbcrypt.c">
 			<BuildOrder>50</BuildOrder>
 		</CppCompile>

+ 2 - 7
source/core/PuttyIntf.cpp

@@ -916,7 +916,7 @@ TStrings * SshCipherList()
   {
     for (int Index2 = 0; Index2 < Ciphers[Index]->nciphers; Index2++)
     {
-      UnicodeString Name = UnicodeString(Ciphers[Index]->list[Index2]->name);
+      UnicodeString Name = UnicodeString(Ciphers[Index]->list[Index2]->ssh2_id);
       Result->Add(Name);
     }
   }
@@ -971,12 +971,7 @@ TStrings * SshMacList()
   return Result.release();
 }
 //---------------------------------------------------------------------------
-UnicodeString GetCipher1Name(const ssh1_cipher * Cipher)
-{
-  return UnicodeString(UTF8String(Cipher->vt->text_name));
-}
-//---------------------------------------------------------------------------
-UnicodeString GetCipher2Name(const ssh2_cipher * Cipher)
+UnicodeString GetCipherName(const ssh_cipher * Cipher)
 {
   return UnicodeString(UTF8String(Cipher->vt->text_name));
 }

+ 1 - 2
source/core/PuttyIntf.h

@@ -27,8 +27,7 @@ extern "C"
 #undef get_data
 }
 //---------------------------------------------------------------------------
-UnicodeString GetCipher1Name(const ssh1_cipher * Cipher);
-UnicodeString GetCipher2Name(const ssh2_cipher * Cipher);
+UnicodeString GetCipherName(const ssh_cipher * Cipher);
 UnicodeString GetCompressorName(const ssh_compressor * Compressor);
 UnicodeString GetDecompressorName(const ssh_decompressor * Decompressor);
 //---------------------------------------------------------------------------

+ 3 - 3
source/core/SecureShell.cpp

@@ -133,7 +133,7 @@ inline void __fastcall TSecureShell::UpdateSessionInfo()
 
     if (FSshVersion == 1)
     {
-      FSessionInfo.CSCipher = GetCipher1Name(get_cipher(FBackendHandle));
+      FSessionInfo.CSCipher = GetCipherName(get_cipher(FBackendHandle));
       FSessionInfo.SCCipher = FSessionInfo.CSCipher;
       // Retrieval of compression is not implemented for SSH-1
       FSessionInfo.CSCompression = UnicodeString();
@@ -141,8 +141,8 @@ inline void __fastcall TSecureShell::UpdateSessionInfo()
     }
     else
     {
-      FSessionInfo.CSCipher = GetCipher2Name(get_cscipher(FBackendHandle));
-      FSessionInfo.SCCipher = GetCipher2Name(get_sccipher(FBackendHandle));
+      FSessionInfo.CSCipher = GetCipherName(get_cscipher(FBackendHandle));
+      FSessionInfo.SCCipher = GetCipherName(get_sccipher(FBackendHandle));
       FSessionInfo.CSCompression = GetCompressorName(get_cscomp(FBackendHandle));
       FSessionInfo.SCCompression = GetDecompressorName(get_sccomp(FBackendHandle));
     }

+ 3 - 3
source/putty/puttyexp.h

@@ -9,9 +9,9 @@ int is_ssh(Plug * plug);
 int get_ssh_version(Backend * be);
 Seat * get_ssh_seat(Plug * plug);
 #ifdef WINSCP_SSH
-const ssh1_cipher * get_cipher(Backend * be);
-const ssh2_cipher * get_cscipher(Backend * be);
-const ssh2_cipher * get_sccipher(Backend * be);
+const ssh_cipher * get_cipher(Backend * be);
+const ssh_cipher * get_cscipher(Backend * be);
+const ssh_cipher * get_sccipher(Backend * be);
 #endif
 const struct ssh_compressor * get_cscomp(Backend * be);
 const struct ssh_decompressor * get_sccomp(Backend * be);

+ 3 - 3
source/putty/ssh.c

@@ -1144,19 +1144,19 @@ Seat * get_ssh_seat(Plug * plug)
   return container_of(plug, Ssh, plug)->seat;
 }
 
-const ssh1_cipher * get_cipher(Backend * be)
+const ssh_cipher * get_cipher(Backend * be)
 {
   Ssh * ssh = container_of(be, Ssh, backend);
   return ssh1_bpp_get_cipher(ssh->bpp);
 }
 
-const ssh2_cipher * get_cscipher(Backend * be)
+const ssh_cipher * get_cscipher(Backend * be)
 {
   Ssh * ssh = container_of(be, Ssh, backend);
   return ssh2_bpp_get_cscipher(ssh->bpp);
 }
 
-const ssh2_cipher * get_sccipher(Backend * be)
+const ssh_cipher * get_sccipher(Backend * be)
 {
   Ssh * ssh = container_of(be, Ssh, backend);
   return ssh2_bpp_get_sccipher(ssh->bpp);

+ 2 - 2
source/putty/ssh1bpp.c

@@ -385,8 +385,8 @@ static void ssh1_bpp_queue_disconnect(BinaryPacketProtocol *bpp,
 }
 
 #ifdef MPEXT
-const ssh1_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp)
+const ssh_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp)
 {
-    return container_of(bpp, struct ssh1_bpp_state, bpp)->cipher;
+    return container_of(bpp, struct ssh1_bpp_state, bpp)->cipher_in; // cipher_out should be the same
 }
 #endif

+ 2 - 2
source/putty/ssh2bpp.c

@@ -913,12 +913,12 @@ static void ssh2_bpp_handle_output(BinaryPacketProtocol *bpp)
 }
 
 #ifdef MPEXT
-const ssh2_cipher * ssh2_bpp_get_cscipher(BinaryPacketProtocol *bpp)
+const ssh_cipher * ssh2_bpp_get_cscipher(BinaryPacketProtocol *bpp)
 {
     return container_of(bpp, struct ssh2_bpp_state, bpp)->out.cipher;
 }
 
-const ssh2_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp)
+const ssh_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp)
 {
     return container_of(bpp, struct ssh2_bpp_state, bpp)->in.cipher;
 }

+ 9 - 9
source/putty/sshaes.c

@@ -1888,33 +1888,33 @@ STUB_ENC_DEC(256)
 
 AESContext * aes_make_context()
 {
-  ssh2_cipher * cipher = ssh2_cipher_new(&ssh_aes256_sdctr);
+  ssh_cipher * cipher = ssh_cipher_new(&ssh_aes256_sdctr);
   return cipher;
 }
 
 void aes_free_context(AESContext * ctx)
 {
-  ssh2_cipher * cipher = (ssh2_cipher *)ctx;
-  ssh2_cipher_free(cipher);
+  ssh_cipher * cipher = (ssh_cipher *)ctx;
+  ssh_cipher_free(cipher);
 }
 
 void aes_iv(AESContext * ctx, const void * iv)
 {
-  ssh2_cipher * cipher = (ssh2_cipher *)ctx;
-  ssh2_cipher_setiv(cipher, iv);
+  ssh_cipher * cipher = (ssh_cipher *)ctx;
+  ssh_cipher_setiv(cipher, iv);
 }
 
 void call_aes_setup(AESContext * ctx, unsigned char * key, int keylen)
 {
-  ssh2_cipher * cipher = (ssh2_cipher *)ctx;
+  ssh_cipher * cipher = (ssh_cipher *)ctx;
   assert(keylen == 32);
-  ssh2_cipher_setkey(cipher, key);
+  ssh_cipher_setkey(cipher, key);
 }
 
 void call_aes_sdctr(unsigned char *blk, int len, void *ctx)
 {
-  ssh2_cipher * cipher = (ssh2_cipher *)ctx;
-  ssh2_cipher_encrypt(cipher, blk, len);
+  ssh_cipher * cipher = (ssh_cipher *)ctx;
+  ssh_cipher_encrypt(cipher, blk, len);
 }
 
 #endif

+ 4 - 0
source/putty/sshauxcrypt.c

@@ -19,10 +19,12 @@ static ssh_cipher *aes256_pubkey_cipher(const void *key)
      */
     char iv[16];
     memset(iv, 0, 16);
+    { // WINSCP
     ssh_cipher *cipher = ssh_cipher_new(&ssh_aes256_cbc);
     ssh_cipher_setkey(cipher, key);
     ssh_cipher_setiv(cipher, iv);
     return cipher;
+    } // WINSCP
 }
 
 void aes256_encrypt_pubkey(const void *key, void *blk, int len)
@@ -129,11 +131,13 @@ static ssh_cipher *des_xdmauth_cipher(const void *vkeydata)
 	nbits -= 7;
     }
 
+    { // WINSCP
     ssh_cipher *c = ssh_cipher_new(&ssh_des);
     ssh_cipher_setkey(c, key);
     smemclr(key, sizeof(key));
     ssh_cipher_setiv(c, key);
     return c;
+    } // WINSCP
 }
 
 void des_encrypt_xdmauth(const void *keydata, void *blk, int len)

+ 3 - 3
source/putty/sshbpp.h

@@ -145,9 +145,9 @@ const char *ssh_verstring_get_local(BinaryPacketProtocol *);
 int ssh_verstring_get_bugs(BinaryPacketProtocol *);
 
 #ifdef MPEXT
-const ssh1_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp);
-const ssh2_cipher * ssh2_bpp_get_cscipher(BinaryPacketProtocol *bpp);
-const ssh2_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp);
+const ssh_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp);
+const ssh_cipher * ssh2_bpp_get_cscipher(BinaryPacketProtocol *bpp);
+const ssh_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp);
 const struct ssh_compressor * ssh2_bpp_get_cscomp(BinaryPacketProtocol *bpp);
 const struct ssh_decompressor * ssh2_bpp_get_sccomp(BinaryPacketProtocol *bpp);
 #endif

+ 2 - 1
source/putty/sshcrc.c

@@ -84,7 +84,8 @@ static inline uint32_t crc32_shift_8(uint32_t v)
 uint32_t crc32_update(uint32_t crc, ptrlen data)
 {
     const uint8_t *p = (const uint8_t *)data.ptr;
-    for (size_t len = data.len; len-- > 0 ;)
+    size_t len; // WINSCP
+    for (len = data.len; len-- > 0 ;)
         crc = crc32_shift_8(crc ^ *p++);
     return crc;
 }

+ 2 - 1
source/putty/sshdes.c

@@ -809,7 +809,8 @@ static void des3_ssh1_setiv(ssh_cipher *cipher, const void *iv)
      * their own IV. So in principle we ought to be able to accept 24
      * bytes of IV here. However, SSH-1 initialises all IVs to zero
      * anyway, so we fudge it by just setting them all the same. */
-    for (int i = 0; i < 3; i++)
+    int i; // WINSCP
+    for (i = 0; i < 3; i++)
         des_iv(&ctx->contexts[i], iv);
 }