Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 14 Apr 2013 06:58:30 -0700
From: Jeremi Gosney <epixoip@...dshell.nl>
To: john-dev@...ts.openwall.com
Subject: Re: [patch] sse/xop implementation of raw-sha512

On 4/14/2013 5:39 AM, Solar Designer wrote:
> Since you're working on uint64_t here, "size >> 2" should probably be
> "size >> 3" (or just "size / sizeof(*x)" to keep this line generic).
> Your use of uint64_t here requires that binary be 8-byte aligned, but
> I think you're only ensuring it is 4-byte aligned. I suggest that you
> use uint32_t here.

Good catch, that was the problem. I also caught another issue that
wasn't caught by the self-test and have corrected it as well. New patch
attached.



--- a/src/rawSHA512_ng_fmt.c	2013-04-14 04:55:29.358863519 -0700
+++ b/src/rawSHA512_ng_fmt.c	2013-04-14 06:46:17.294578261 -0700
@@ -50,7 +50,7 @@
 #define CIPHERTEXT_LENGTH         128
 #define DIGEST_SIZE               64
 #define BINARY_SIZE               64
-#define BINARY_ALIGN              MEM_ALIGN_WORD
+#define BINARY_ALIGN              8
 #define SALT_SIZE                 0
 #define SALT_ALIGN                1
 #define MIN_KEYS_PER_CRYPT        1
@@ -93,7 +93,10 @@
 #endif
 
 #define GATHER(x,y,z)                                                     \
-    x = _mm_set_epi64x (y[1][z], y[0][z]);
+{                                                                         \
+    x = _mm_setzero_si128 ();                                             \
+    x = _mm_set_epi64x (y[1][z], y[0][z]);                                \
+}
 
 #define S0(x)                                                             \
 (                                                                         \
@@ -187,7 +190,7 @@
     uint64_t *x = (uint64_t *) _x;
     int i;
 
-    for (i=0; i < (size >> 2); i++)
+    for (i=0; i < (size / sizeof(*x)); i++)
         x[i] = __builtin_bswap64 (x[i]);
 }
 
@@ -247,13 +250,13 @@
 }
 
 
-static int binary_hash_0 (void *binary) { return *(uint64_t *) binary & 0xf; }
-static int binary_hash_1 (void *binary) { return *(uint64_t *) binary & 0xff; }
-static int binary_hash_2 (void *binary) { return *(uint64_t *) binary & 0xfff; }
-static int binary_hash_3 (void *binary) { return *(uint64_t *) binary & 0xffff; }
-static int binary_hash_4 (void *binary) { return *(uint64_t *) binary & 0xfffff; }
-static int binary_hash_5 (void *binary) { return *(uint64_t *) binary & 0xffffff; }
-static int binary_hash_6 (void *binary) { return *(uint64_t *) binary & 0x7ffffff; }
+static int binary_hash_0 (void *binary) { return *(uint32_t *) binary & 0xf; }
+static int binary_hash_1 (void *binary) { return *(uint32_t *) binary & 0xff; }
+static int binary_hash_2 (void *binary) { return *(uint32_t *) binary & 0xfff; }
+static int binary_hash_3 (void *binary) { return *(uint32_t *) binary & 0xffff; }
+static int binary_hash_4 (void *binary) { return *(uint32_t *) binary & 0xfffff; }
+static int binary_hash_5 (void *binary) { return *(uint32_t *) binary & 0xffffff; }
+static int binary_hash_6 (void *binary) { return *(uint32_t *) binary & 0x7ffffff; }
 
 static int get_hash_0 (int index) { return crypt_key[0][index] & 0xf; }
 static int get_hash_1 (int index) { return crypt_key[0][index] & 0xff; }
@@ -270,7 +273,7 @@
     uint8_t  *buf8  = (uint8_t * ) buf64;
     int len = 0;
 
-    memset(buf64, 0, 16);
+    memset(buf8, 0, 64);
 
     while (*key)
         buf8[len++] = *key++;

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ