]> andersk Git - openssh.git/blobdiff - deattack.c
- jakob@cvs.openbsd.org 2001/08/02 16:14:05
[openssh.git] / deattack.c
index 27b80f3a253a80e4440f5ad7b246d7c10cb1fca8..1a89be4b803887d318f5146926bad92ef7c65ce3 100644 (file)
@@ -1,5 +1,6 @@
+/*     $OpenBSD: deattack.c,v 1.14 2001/06/23 15:12:18 itojun Exp $    */
+
 /*
- * $Id$
  * Cryptographic attack detector for ssh - source code
  *
  * Copyright (c) 1998 CORE SDI S.A., Buenos Aires, Argentina.
@@ -20,7 +21,7 @@
 
 #include "includes.h"
 #include "deattack.h"
-#include "ssh.h"
+#include "log.h"
 #include "crc32.h"
 #include "getput.h"
 #include "xmalloc.h"
 /* Hash function (Input keys are cipher results) */
 #define HASH(x)                GET_32BIT(x)
 
-#define CMP(a,b)       (memcmp(a, b, SSH_BLOCKSIZE))
-
+#define CMP(a, b)      (memcmp(a, b, SSH_BLOCKSIZE))
 
-void
+static void
 crc_update(u_int32_t *a, u_int32_t b)
 {
        b ^= *a;
-       *a = crc32((unsigned char *) &b, sizeof(b));
+       *a = ssh_crc32((u_char *) &b, sizeof(b));
 }
 
 /* detect if a block is used in a particular pattern */
-int
-check_crc(unsigned char *S, unsigned char *buf, u_int32_t len,
-         unsigned char *IV)
+static int
+check_crc(u_char *S, u_char *buf, u_int32_t len,
+         u_char *IV)
 {
        u_int32_t crc;
-       unsigned char *c;
+       u_char *c;
 
        crc = 0;
        if (IV && !CMP(S, IV)) {
@@ -81,14 +81,14 @@ check_crc(unsigned char *S, unsigned char *buf, u_int32_t len,
 
 /* Detect a crc32 compensation attack on a packet */
 int
-detect_attack(unsigned char *buf, u_int32_t len, unsigned char *IV)
+detect_attack(u_char *buf, u_int32_t len, u_char *IV)
 {
        static u_int16_t *h = (u_int16_t *) NULL;
-       static u_int16_t n = HASH_MINSIZE / HASH_ENTRYSIZE;
+       static u_int32_t n = HASH_MINSIZE / HASH_ENTRYSIZE;
        register u_int32_t i, j;
        u_int32_t l;
-       register unsigned char *c;
-       unsigned char *d;
+       register u_char *c;
+       u_char *d;
 
        if (len > (SSH_MAXBLOCKS * SSH_BLOCKSIZE) ||
            len % SSH_BLOCKSIZE != 0) {
This page took 0.161291 seconds and 4 git commands to generate.