         4 { } nappend-as
     ]
 
-TUPLE: sha2-state < checksum-state K H word-size ;
+TUPLE: sha2-state < checksum-state
+{ K array }
+{ H array }
+{ word-size fixnum } ;
 
 TUPLE: sha2-short < sha2-state ;
 

    [ prepare-message-schedule ]
    [ [ block-size>> ] [ H>> clone ] [ ] tri process-chunk ] bi ;

: sequence>byte-array ( seq n -- string )
    '[ _ >be ] map B{ } concat-as ;

: sha1>checksum ( sha2 -- bytes )
    H>> 4 sequence>byte-array ;

: sha-224>checksum ( sha2 -- bytes )
    H>> 7 head 4 sequence>byte-array ;

: sha-256>checksum ( sha2 -- bytes )
    H>> 4 sequence>byte-array ;

: pad-last-short-block ( state -- )
    [ bytes>> t ] [ bytes-read>> pad-last-block ] [ ] tri
    [ checksum-block ] curry each ;

PRIVATE>


! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays checksums checksums.common
checksums.stream combinators combinators.smart fry grouping
io.binary kernel literals locals math math.bitwise math.ranges
sequences sequences.generalizations sequences.private ;
IN: checksums.sha

SINGLETON: sha1
