Add the CRC32 compensation attack detector that all other SSH
[u/mdw/putty] / sshcrc.c
index fb0db0c..691f7b4 100644 (file)
--- a/sshcrc.c
+++ b/sshcrc.c
@@ -211,9 +211,8 @@ int main(void)
 }
 #endif
 
-unsigned long crc32(const void *buf, size_t len)
+unsigned long crc32_update(unsigned long crcword, const void *buf, size_t len)
 {
-    unsigned long crcword = 0L;
     const unsigned char *p = (const unsigned char *) buf;
     while (len--) {
        unsigned long newbyte = *p++;
@@ -222,3 +221,8 @@ unsigned long crc32(const void *buf, size_t len)
     }
     return crcword;
 }
+
+unsigned long crc32(const void *buf, size_t len)
+{
+    return crc32_update(0L, buf, len);
+}