Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #18003

Re: SHA-512

Newsgroups comp.lang.forth
Date 2012-12-13 19:38 -0800
References <a934a7e2-07db-4e93-8b5e-3627c48e547e@googlegroups.com> <07701490918435@frunobulax.edu>
Message-ID <0bea10e6-ccf1-4ec0-ba3a-fe0183afd4ad@googlegroups.com> (permalink)
Subject Re: SHA-512
From jzakiya@gmail.com

Show all headers | View raw


On Thursday, December 13, 2012 2:33:28 PM UTC-5, Marcel Hendrix wrote:
> jzakiya@gmail.com writes Re: SHA-512
> 
> 
> 
> >On Monday, December 10, 2012 4:17:24 PM UTC-5, Marcel Hendrix wrote:
> 
> >> jzakiya@gmail.com writes Re: SHA-512
> 
> > [..]
> 
> > Marcel, could you run  EX2  by itself, and see what the output is.
> 
> 
> 
> > I think it may have to do with my making the count from the string word EX2a return a double number count 
> 
> > instead of a single, so I changed it as below to make it consistent with 'abc'
> 
> 
> 
> No, it is less subtle -- bytes>< is wrong! This works:
> 
> 
> 
> : bytes>< ( m -- w )  \ Reverse cell bytes: 1234567890abcdef <-> efcdab9078563412
> 
>   [ HEX ]  DUP >R  38 LSHIFT  R@ FF00 AND  28 LSHIFT OR
> 
>   R@ FF0000 AND 18 LSHIFT OR  R@ FF000000 AND 8 LSHIFT OR
> 
> \ R@ 20 RSHIFT FF AND OR   R@ 18 RSHIFT FF00 AND OR   R@  10 RSHIFT FF0000 AND OR
> 
> \ R>  8 RSHIFT FF000000 AND OR [ DECIMAL ]
> 
>   R@ 38 RSHIFT FF AND OR   R@ 28 RSHIFT FF00 AND OR   R@  18 RSHIFT FF0000 AND OR
> 
>   R>  8 RSHIFT FF000000 AND OR [ DECIMAL ]
> 
> ;
> 
> 
> 
> \ In iForth: BSWAP ( u1 -- u2 ) 
> 
> 
> 
> After which the examples both pass:
> 
> 
> 
> FORTH> SHAtest
> 
> SHA-512 test suite:
> 
> cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e ""
> 
> ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f "abc"
> 
> 8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
> 
> 9bc68759247e3332bec1c79d128d28a8931d0c9f96c8aa975731b563475fdddddf7f873c25086908effe270e23c5a01e5dfb3289bf5d091d8fb454b1bcf98dda 2 million copies of ASCII 'a' (61h)
> 
> 19ef4876e03c93476e00b486c62108d4d7136f6d4782817b449bacf44d0963e03f5ab474cb6822c2963a979e8e15298cd60f22841c51f6161620c0e031c65f4a 400,000 copies of ASCII BL (20h)
> 
> 
> 
> > Also, do you know the words the current SwiftForth uses for timing.
> 
> > I'm running SwiftForth i386-Win32 3.4.5 03-Oct-2012 under WINE on Linux and 
> 
> > the old code that uses  ucounter and utimer bombs on this version.
> 
> 
> 
> It works here (under Win7), so I guess it's a [newly introduced?] bug in the Linux version:
> 
> 
> 
> SwiftForth i386-Win32 3.4.2 11-Feb-2012
> 
> ucounter 100 ms utimer 110305  ok
> 
> 
> 
> -marcel

I thought the problem was bytes>< because 'abc' was too small to show the bytes being reversed incorrectly.

So now use shafile and take the sha512 hash of a really big file (like a linux distro or video file) and see that it works correctly. I haven't found sha512 signatures of distros yet, but FREEBSD has sha256 hashes of their iso which I've checked them against with shafile.

Oh, the reason why the timing test suite was messing up with SwiftForth was because I need to correctly use convert the string count to a double number in those examples. Once I did all the tests ran correctly using: ucount ..... utimer.

In fact on Windows 7, SwiftForth ran test3 in 15+ seconds for sha256, which VFX took 17+ seconds (haven't done Win32Forth).
Will try on Gforth when I get a chance.

Since the SHAxxx class hashes all use a similar architecture I plan to do all 7 of them, since it they just use different constants and truncate the outputs for the smaller hash sizes.

Howard,

I can get rid of those bad PICKs :-) if I restructure the implementation to hold the extended message in memory, instead of on the stack. I'll do it if I get the itch  (probably). But I'm not a fundamentalist about them, since they make it so much easier to use the stack. Hey, PICK was created for something, right.  :-)

Once I get th SHAxxx cleaned up, finished, on to Keccak (SHA-3)!

Jabari

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-02 23:48 +0200
  Re: SHA-512 jzakiya@gmail.com - 2012-12-07 14:47 -0800
    Re: SHA-512 Coos Haak <chforth@hccnet.nl> - 2012-12-08 00:49 +0100
      Re: SHA-512 jzakiya@gmail.com - 2012-12-07 16:54 -0800
        Re: SHA-512 Coos Haak <chforth@hccnet.nl> - 2012-12-08 18:21 +0100
      Re: SHA-512 jzakiya@gmail.com - 2012-12-08 18:36 -0800
        Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-09 09:14 +0200
          Re: SHA-512 jzakiya@gmail.com - 2012-12-09 17:23 -0800
            Re: SHA-512 jzakiya@gmail.com - 2012-12-09 17:29 -0800
              Re: SHA-512 jzakiya@gmail.com - 2012-12-09 20:46 -0800
              Re: SHA-512 m.a.m.hendrix@tue.nl - 2012-12-10 03:53 -0800
                Re: SHA-512 jzakiya@gmail.com - 2012-12-10 13:05 -0800
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-10 23:17 +0200
                Re: SHA-512 jzakiya@gmail.com - 2012-12-13 06:30 -0800
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-13 21:33 +0200
                Re: SHA-512 jzakiya@gmail.com - 2012-12-13 19:38 -0800
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-14 22:52 +0200
                Re: SHA-512 jzakiya@gmail.com - 2012-12-14 16:39 -0800
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-15 19:11 +0200
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-16 16:00 +0200
                Re: SHA-512 jzakiya@gmail.com - 2012-12-16 17:33 -0800
                Re: SHA-512 jzakiya@gmail.com - 2012-12-16 22:35 -0800
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-17 10:14 +0200
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-17 10:51 +0200
                Re: SHA-512 jzakiya@gmail.com - 2012-12-17 09:13 -0800
                Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-17 22:24 +0200
                Re: SHA-512 Howerd <howerdo@yahoo.co.uk> - 2012-12-13 13:06 -0800
                Re: SHA-512 Howerd <howerdo@yahoo.co.uk> - 2012-12-13 13:03 -0800
    Re: SHA-512 mhx@iae.nl (Marcel Hendrix) - 2012-12-08 22:08 +0200

csiph-web