|
|
Message-ID: <018b01cd4c99$f8fd75c0$eaf86140$@net>
Date: Sun, 17 Jun 2012 10:00:44 -0500
From: "jfoug" <jfoug@....net>
To: <john-dev@...ts.openwall.com>
Subject: RE: Re: [patch] optional new raw sha1 implemetation
Why are we doing a memset here? A simply *ptr=0 is all that is needed. We
simply need to return a ASCIIZ string, changing the 0x80 to 0x00.
+ strrchr((char*)key, 0x80) = 0;
We are assured that there will be a 0x80 within first 16 bytes, and we have
an array that now is 20 bytes long.
I also think the key[4] = 0 could be eliminated by doing: static uint32_t
key[5] = {0}; or by using a pointer and calloc(17).
Jim.
>@@ -270,7 +270,7 @@ static void sha1_fmt_set_key(char *key, int index)
>
> static char * sha1_fmt_get_key(int index)
> {
>- static uint32_t key[4];
>+ static uint32_t key[5];
>
> // This function is not hot, we can do this slowly. First, restore
> // endianness.
>@@ -279,6 +279,9 @@ static char * sha1_fmt_get_key(int index)
> key[2] = __builtin_bswap32(M[index][2]);
> key[3] = __builtin_bswap32(M[index][3]);
>
>+ // We need a null byte for the strrchr
>+ key[4] = 0;
>+
> // Skip backwards until we hit the trailing bit, then remove it.
> memset(strrchr((char*)key, 0x80), 0x00, 1);
>
>
>magnum
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.