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


Groups > comp.lang.forth > #17967

Re: SHA-512

From mhx@iae.nl (Marcel Hendrix)
Subject Re: SHA-512
Newsgroups comp.lang.forth
Message-ID <11181293918435@frunobulax.edu> (permalink)
Date 2012-12-10 23:17 +0200
References <2737d607-cb81-41e6-a7fa-f19e8455f6a6@googlegroups.com>
Organization Wanadoo

Show all headers | View raw


jzakiya@gmail.com writes Re: SHA-512

> On Monday, December 10, 2012 6:53:44 AM UTC-5, m.a.m....@tue.nl wrote:
>> On Monday, December 10, 2012 2:29:04 AM UTC+1, jza...@gmail.com wrote:
>>
>> [..]
>>
>> [ Egg on my face, should not have touched the DECIMAL/HEX issues yet. ]
>
>> Yes, the code now runs and gives the correct results for S" abc".
>>
>> This would be the first working SHA-512 in 64-bit Forth!

> Hey GREAT! :-)

> Be sure to do the longer example also to make sure there are no 
> other problems (which I don't forsee).

Unfortunately, the longer string does not hash properly. To avoid 
more egg on my face, I downloaded your latest code from 4share. 
To make it work in iForth64 I needed the patch that I have appended
(Enable PLACE and rewrite timer-start and ms?, typos in SHA256 and 
SHAinit, extra stack item in EX2a dropped.)

[..]

> I ALWAYS start from the algorithm description to do Forth versions, even if
> I look at other existing language implementations, because I think so much
> differently when I create in Forth.

Ok. Please forget about macro's, ]L and EVALUATE for the time being. Also,
the 15 PICKs you may get rid off without any ill effects :-)

Here are the current results with your patched code:

FORTH> in
Redefining split-at-char
Redefining MACRO
Redefining MS?  ok
FORTH> SHAtest
SHA-512 test suite:
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e ""
ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f "abc"
8cc1fec83f21176a675306d9f80b26597469eff277ab9d0f03a725b15d57d33a2e3aadea4727cf632a3e5ec3c744bcc0eb2183c41c717cc4a84fa6dbf8244243 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"
9bc68759247e3332bec1c79d128d28a8931d0c9f96c8aa975731b563475fdddddf7f873c25086908effe270e23c5a01e5dfb3289bf5d091d8fb454b1bcf98dda 2 million copies of ASCII 'a' (61h)
19ef4876e03c93476e00b486c62108d4d7136f6d4782817b449bacf44d0963e03f5ab474cb6822c2963a979e8e15298cd60f22841c51f6161620c0e031c65f4a 400,000 copies of ASCII BL (20h)
 ok

-marcel

-- ----------
Compare: (<)C:\Users\marcel\Desktop\SHA-512.frt
   with: (>)C:\Users\marcel\Desktop\SHA-512VFX.F

1d1
< ANEW -sha-512
19c18,19
< : PLACE  ( caddr n addr -)  2DUP  C!  CHAR+  SWAP  CHARS  MOVE ;
---
> \ Not needed for SwiftForth v 2.00.3, needed for Win32Forth V 4.10
> \ : PLACE  ( caddr n addr -)  2DUP  C!  CHAR+  SWAP  CHARS  MOVE ;
161c161
< : SHA512 ( Wadr - )
---
> : SHA256  ( Wadr - )
233c233
<   SHAinit  2DUP  SHAlen 2!  hashfullblocks  hashfinal
---
>   SHAinit  2DUP  SHAlen 2 !  hashfullblocks  hashfinal
375,376c375,376
<   EX1  S" abc"   QuoteString
<   EX2  EX2a DROP QuoteString
---
>   EX1  S" abc"  QuoteString
>   EX2  EX2a     QuoteString
381,384c381,391
<   VARIABLE  start-ms
< 
< : TIMER-START  ( -- )  ?MS  start-ms  ! ;
< : MS?  ( -- u )  ?MS  start-ms  @  - ( abs ) ;
---
> \ ===========  VFX Forth specific performance test ===========
> 
>   [undefined] GetTickCount
>   [IF] extern: DWORD PASCAL GetTickCount( void ) [THEN]
> 
>   VARIABLE  start-ms
> 
> : TIMER-START  ( -- )  GetTickCount  start-ms  ! ;
> 
> : MS?  ( -- u )  GetTickCount  start-ms  @  - ( abs ) ;
> 

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


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 jzakiya@gmail.com - 2013-01-15 20:38 -0800
                Re: SHA-512 jzakiya@gmail.com - 2013-01-15 20:54 -0800
                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