Ver Fonte

Updating code to PuTTY 0.81

Source commit: 8e3ec1c8c30e6aaf20df3963df23c773c0e1fb9f
Martin Prikryl há 1 ano atrás
pai
commit
d3b909a833
2 ficheiros alterados com 15 adições e 2 exclusões
  1. 3 0
      source/Putty.cbproj
  2. 12 2
      source/putty/crypto/rfc6979.c

+ 3 - 0
source/Putty.cbproj

@@ -190,6 +190,9 @@
 		<CppCompile Include="putty\crypto\pubkey-ppk.c">
 			<BuildOrder>31</BuildOrder>
 		</CppCompile>
+		<CppCompile Include="putty\crypto\rfc6979.c">
+			<BuildOrder>165</BuildOrder>
+		</CppCompile>
 		<CppCompile Include="putty\crypto\rsa.c">
 			<BuildOrder>32</BuildOrder>
 		</CppCompile>

+ 12 - 2
source/putty/crypto/rfc6979.c

@@ -143,6 +143,7 @@ static mp_int *bits2int(ptrlen b, RFC6979 *s)
 {
     if (b.len > s->qbytes)
         b.len = s->qbytes;
+    { // WINSCP
     mp_int *x = mp_from_bytes_be(b);
 
     /*
@@ -160,12 +161,14 @@ static mp_int *bits2int(ptrlen b, RFC6979 *s)
         mp_rshift_fixed_into(x, x, b.len * 8 - s->qbits);
 
     return x;
+    } // WINSCP
 }
 
 static void BinarySink_put_int2octets(BinarySink *bs, mp_int *x, RFC6979 *s)
 {
     mp_int *x_mod_q = mp_mod(x, s->q);
-    for (size_t i = s->qbytes; i-- > 0 ;)
+    size_t i; // WINSCP
+    for (i = s->qbytes; i-- > 0 ;)
         put_byte(bs, mp_get_byte(x_mod_q, i));
     mp_free(x_mod_q);
 }
@@ -196,11 +199,13 @@ RFC6979 *rfc6979_new(const ssh_hashalg *hashalg, mp_int *q, mp_int *x)
 
     /* In each attempt, we concatenate enough hash blocks to be
      * greater than qbits in size. */
+    { // WINSCP
     size_t hbits = 8 * s->hlen;
     s->T_nblocks = (s->qbits + hbits - 1) / hbits;
     s->T = snewn(s->T_nblocks * s->hlen, unsigned char);
 
     return s;
+    } // WINSCP
 }
 
 void rfc6979_setup(RFC6979 *s, ptrlen message)
@@ -263,7 +268,8 @@ RFC6979Result rfc6979_attempt(RFC6979 *s)
 
     /* 3.2 (h) 1: set T to the empty string */
     /* 3.2 (h) 2: make lots of output by concatenating MACs of V */
-    for (size_t i = 0; i < s->T_nblocks; i++) {
+    size_t i; // WINSCP
+    for (i = 0; i < s->T_nblocks; i++) {
         ssh2_mac_start(s->mac);
         put_data(s->mac, s->V, s->hlen);
         ssh2_mac_genresult(s->mac, s->V);
@@ -311,6 +317,7 @@ RFC6979Result rfc6979_attempt(RFC6979 *s)
     ssh2_mac_start(s->mac);
     put_data(s->mac, s->V, s->hlen);
     put_byte(s->mac, 0);
+    { // WINSCP
     unsigned char K[MAX_HASH_LEN];
     ssh2_mac_genresult(s->mac, K);
     ssh2_mac_setkey(s->mac, make_ptrlen(K, s->hlen));
@@ -321,6 +328,7 @@ RFC6979Result rfc6979_attempt(RFC6979 *s)
     ssh2_mac_genresult(s->mac, s->V);
 
     return result;
+    } // WINSCP
 }
 
 void rfc6979_free(RFC6979 *s)
@@ -346,6 +354,7 @@ mp_int *rfc6979(
 {
     RFC6979 *s = rfc6979_new(hashalg, q, x);
     rfc6979_setup(s, message);
+    { // WINSCP
     RFC6979Result result;
     while (true) {
         result = rfc6979_attempt(s);
@@ -356,4 +365,5 @@ mp_int *rfc6979(
     }
     rfc6979_free(s);
     return result.k;
+    } // WINSCP
 }