Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <67c1ed33a9b15cec63dc669116d06a46@smtp.hushmail.com>
Date: Sun, 17 Jun 2012 10:50:52 +0200
From: magnum <john.magnum@...hmail.com>
To: john-dev@...ts.openwall.com
Subject: Re: Re: [patch] optional new raw sha1 implemetation

On 2012-06-17 10:43, magnum wrote:
> No, that was what I did first but memrchr is not portable. Not everyone
> runs GNU or Linux. I think allocating a 17 byte key and ensure the last
> is null is the simplest fix. In fact we only need to to this once as we
> never overwrite it:
>
> static uint32_t *result;
> if (!result)
> result = mem_calloc_tiny(SHA1_DIGEST_SIZE + 1, MEM_ALIGN_WORD);
>
> I'll commit the above for now but you are obviously free to change it to
> something else.

I confused the above with binary() but here's what I'll use for now:

@@ -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.