]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/checksums/hmac/hmac.factor
Resolved merge.
[factor.git] / basis / checksums / hmac / hmac.factor
index b163766016a33be55a0be16b0f0ee1253d9ef4e1..9ec78248a1c5f2064eab91413a91ca36b924c73f 100755 (executable)
@@ -13,27 +13,26 @@ IN: checksums.hmac
 
 : ipad ( checksum-state -- seq ) block-size>> HEX: 36 <array> ;
 
-:: init-K ( K checksum checksum-state -- o i )
-    checksum-state block-size>> K length <
-    [ K checksum checksum-bytes ] [ K ] if
+:: init-key ( checksum key checksum-state -- o i )
+    checksum-state block-size>> key length <
+    [ key checksum checksum-bytes ] [ key ] if
     checksum-state block-size>> 0 pad-tail 
     [ checksum-state opad seq-bitxor ]
     [ checksum-state ipad seq-bitxor ] bi ;
 
 PRIVATE>
 
-:: hmac-stream ( K stream checksum -- value )
-    K checksum dup initialize-checksum-state
-        dup :> checksum-state
-        init-K :> Ki :> Ko
+:: hmac-stream ( stream key checksum -- value )
+    checksum initialize-checksum-state :> checksum-state
+    checksum key checksum-state init-key :> Ki :> Ko
     checksum-state Ki add-checksum-bytes
     stream add-checksum-stream get-checksum
     checksum initialize-checksum-state
     Ko add-checksum-bytes swap add-checksum-bytes
     get-checksum ;
 
-: hmac-file ( K path checksum -- value )
-    [ binary <file-reader> ] dip hmac-stream ;
+: hmac-file ( path key checksum -- value )
+    [ binary <file-reader> ] 2dip hmac-stream ;
 
-: hmac-bytes ( K seq checksum -- value )
-    [ binary <byte-reader> ] dip hmac-stream ;
+: hmac-bytes ( seq key checksum -- value )
+    [ binary <byte-reader> ] 2dip hmac-stream ;