Using plink with CVS - need to make sure the saved session uses SSH
[u/mdw/putty] / sshsha.c
index 7c10a9a..2a07cc3 100644 (file)
--- a/sshsha.c
+++ b/sshsha.c
@@ -1,7 +1,3 @@
-#include <stdarg.h> /* FIXME */
-#include <windows.h> /* FIXME */
-#include "putty.h" /* FIXME */
-
 /*
  * SHA1 hash algorithm. Used in SSH2 as a MAC, and the transform is
  * also used as a `stirring' function for the PuTTY random number
@@ -11,8 +7,6 @@
 
 #include "ssh.h"
 
-typedef unsigned int uint32;
-
 /* ----------------------------------------------------------------------
  * Core SHA algorithm: processes 16-word blocks into a message digest.
  */
@@ -181,11 +175,6 @@ static void sha1_key(SHA_State *s1, SHA_State *s2,
                      unsigned char *key, int len) {
     unsigned char foo[64];
     int i;
-    {int j;
-        debug(("Key supplied is:\r\n"));
-        for (j=0; j<len; j++) debug(("  %02X", key[j]));
-        debug(("\r\n"));
-    }
 
     memset(foo, 0x36, 64);
     for (i = 0; i < len && i < 64; i++)
@@ -210,6 +199,14 @@ static void sha1_sckey(unsigned char *key) {
     sha1_key(&sha1_sc_mac_s1, &sha1_sc_mac_s2, key, 20);
 }
 
+static void sha1_cskey_buggy(unsigned char *key) {
+    sha1_key(&sha1_cs_mac_s1, &sha1_cs_mac_s2, key, 16);
+}
+
+static void sha1_sckey_buggy(unsigned char *key) {
+    sha1_key(&sha1_sc_mac_s1, &sha1_sc_mac_s2, key, 16);
+}
+
 static void sha1_do_hmac(SHA_State *s1, SHA_State *s2,
                          unsigned char *blk, int len, unsigned long seq,
                          unsigned char *hmac) {
@@ -231,39 +228,27 @@ static void sha1_do_hmac(SHA_State *s1, SHA_State *s2,
 }
 
 static void sha1_generate(unsigned char *blk, int len, unsigned long seq) {
-    {int i;
-        debug(("Gen HMAC on block len=%d seq=%d:\r\n", len, seq));
-        for (i=0; i<len; i++) debug(("  %02X", blk[i]));
-        debug(("\r\n"));
-    }
     sha1_do_hmac(&sha1_cs_mac_s1, &sha1_cs_mac_s2, blk, len, seq, blk+len);
-    {int i;
-        debug(("We compute HMAC as:\r\n"));
-        for (i=0; i<20; i++) debug(("  %02X", blk[len+i]));
-        debug(("\r\n"));
-    }
 }
 
 static int sha1_verify(unsigned char *blk, int len, unsigned long seq) {
     unsigned char correct[20];
-    {int i;
-        debug(("HMAC on block len=%d seq=%d:\r\n", len, seq));
-        for (i=0; i<len; i++) debug(("  %02X", blk[i]));
-        debug(("\r\n"));
-    }
     sha1_do_hmac(&sha1_sc_mac_s1, &sha1_sc_mac_s2, blk, len, seq, correct);
-    {int i;
-        debug(("We compute HMAC as:\r\n"));
-        for (i=0; i<20; i++) debug(("  %02X", correct[i]));
-        debug(("\r\n"));
-    }
     return !memcmp(correct, blk+len, 20);
 }
 
-struct ssh_mac ssh_sha1 = {
+const struct ssh_mac ssh_sha1 = {
     sha1_cskey, sha1_sckey,
     sha1_generate,
     sha1_verify,
     "hmac-sha1",
     20
 };
+
+const struct ssh_mac ssh_sha1_buggy = {
+    sha1_cskey_buggy, sha1_sckey_buggy,
+    sha1_generate,
+    sha1_verify,
+    "hmac-sha1",
+    20
+};