Re: SHA-512 and 128-bit integers

From: Ken Very Big Liar (kellydeanbeard_at_hotmail.com)
Date: 04/29/03


Date: Tue, 29 Apr 2003 12:11:14 -0500

On 29 Apr 2003 09:08:44 -0700, tomstdenis@yahoo.com (Tom St Denis) wrote:

>Ken Very Big Liar <kellydeanbeard@hotmail.com> wrote in message news:<3a0tavkqthnt51j2kniv2a5u8gok5cq7p1@4ax.com>...
>> Ok, does anyone have a good solution to using 128-bit integers on 32 bit
>> machines? The Linux Pent III that I'm using to develop the different SHAs
>> supports the C type "long long", which is a 64-bit type, but there is no support
>> for 128-bit integers. Probably because there is no machine code for this, I'm
>> not sure.
>
>SHA doesn't require 128-bit data types.
>

from FIPS 180-2:
If Z is an integer, 0 <= Z < 2^128, then Z = 2^64X + Y, where 0 <= X < 2^64 and
0 <= Y < 2^64. Since X and Y can be represented as 64-bit words x and y,
respectively, the integer Z can be represented as the pair of words (x, y). This
property is used for SHA-384 and SHA-512.

That doesn't explicitly say a '128-bit' data type, but it does specify being
able to store the length of the message (<= 2^128 - 1) in bits.

>> I noticed that the even Tom's crypt library sidesteps this issue by hoping that
>> you won't be using huge data sets.
>
>That could be one explanation. Another could be you're completely
>wrong and falsely defaming others?
>

Could be something more innocent than that. You tell me. You supposedly wrote
this stuff, I'm just writing my own implementation for fun and learning and when
I want to, look at your code or others for a different perspective. I'm just
trying to write my stuff to spec. That's all.

from sha512.c:

00189 /* pad upto 120 bytes of zeroes
00190 * note: that from 112 to 120 is the 64 MSB of the length. We assume
that you won't hash
00191 * > 2^64 bits of data... :-)
00192 */
00193 while (md->sha512.curlen < 120) {
00194 md->sha512.buf[md->sha512.curlen++] = (unsigned char)0;
00195 }
00196
00197 /* store length */
00198 STORE64H(md->sha512.length, md->sha512.buf+120);
00199 sha512_compress(md);
00200

'.length' is a 64-bit number (ulong64). If you're magically storing 128 bits
worth of data in a 64 bit space, then do share.

>As for the general question to bignums why not use a bignum library,
>such as oh, um, I dunno, LibTomMath!!!
>
>Tom

I'll check it out. Thank you.

---
Kelly Beard, a.k.a. Mr. K.V.B. Liar


Relevant Pages

  • Re: SHA-512 and 128-bit integers
    ... The Linux Pent III that I'm using to develop the different SHAs ... Probably because there is no machine code for this, ... SHA doesn't require 128-bit data types. ...
    (sci.crypt)
  • Re: SHA-512 and 128-bit integers
    ... The Linux Pent III that I'm using to develop the different SHAs ... > SHA doesn't require 128-bit data types. ... is not LibTomMath just this-- ...
    (sci.crypt)