From dadffdf6e33beac41a10a581e80267e89899d0a4 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 8 Sep 2005 16:05:25 +0000 Subject: [PATCH] Inlined the hashtable in sha1. --- contrib/crypto/sha1.factor | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/contrib/crypto/sha1.factor b/contrib/crypto/sha1.factor index 5de365454a..f04c0ead47 100644 --- a/contrib/crypto/sha1.factor +++ b/contrib/crypto/sha1.factor @@ -16,7 +16,6 @@ SYMBOL: D SYMBOL: E SYMBOL: w SYMBOL: K -SYMBOL: f-table : reset-w ( -- ) 80 w set ; @@ -53,6 +52,7 @@ SYMBOL: f-table ! f(t;B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <= 59) ! f(t;B,C,D) = B XOR C XOR D (60 <= t <= 79) +! use this syntax eventually ! JUMP-TABLE: f 4 ( maximum ) ! {{ ! [[ 0 [ >r over bitnot r> bitand >r bitand r> bitor ] ]] @@ -66,16 +66,14 @@ SYMBOL: f-table ! J: 2 f 2dup bitand >r pick bitand >r bitand r> r> bitor bitor ; ! J: 3 f bitxor bitxor ; -! todo: make inlined -{ - { [ dup 0 = ] [ drop >r over bitnot r> bitand >r bitand r> bitor ] } - { [ dup 1 = ] [ drop bitxor bitxor ] } - { [ dup 2 = ] [ drop 2dup bitand >r pick bitand >r bitand r> r> bitor bitor ] } - { [ dup 3 = ] [ drop bitxor bitxor ] } -} f-table set - : sha1-f ( B C D t -- f_tbcd ) - 20 /i f-table get cond ; + 20 /i + { + { [ dup 0 = ] [ drop >r over bitnot r> bitand >r bitand r> bitor ] } + { [ dup 1 = ] [ drop bitxor bitxor ] } + { [ dup 2 = ] [ drop 2dup bitand >r pick bitand >r bitand r> r> bitor bitor ] } + { [ dup 3 = ] [ drop bitxor bitxor ] } + } cond ; : make-w ( -- ) ! compute w, steps a-b of RFC 3174, section 6.1