 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays checksums checksums.common combinators
-combinators.smart fry grouping io.binary kernel kernel.private
-literals locals math math.bitwise math.ranges sequences
-sequences.generalizations sequences.private ;
+USING: accessors alien.c-types arrays checksums checksums.common
+combinators combinators.smart fry grouping io.binary kernel
+kernel.private literals locals math math.bitwise math.ranges
+sequences sequences.generalizations sequences.private
+specialized-arrays ;
+SPECIALIZED-ARRAY: uint
+SPECIALIZED-ARRAY: ulong
 IN: checksums.sha
 
 MIXIN: sha

    T1 T2 w+ a H set-nth-unsafe ; inline

: prepare-message-schedule ( seq sha2 -- w-seq )
    [ word-size>> <groups> [ be> ] map ]
    [
        block-size>> [ 0 pad-tail 16 ] keep [a,b) over
        '[ _ prepare-M-256 ] each
    ] bi ; inline

:: process-chunk ( M block-size cloned-H sha2 -- )
    block-size [

    } 2cleave set-nth-unsafe ; inline

: prepare-M-512 ( n seq -- )
    { ulong-array } declare
    {
        [ [ 16 - ] dip nth-unsafe ]
        [ [ 15 - ] dip nth-unsafe s0-512 ]
