Hardware sha1 working intermitently.

This commit is contained in:
Brad Nelson
2022-06-11 09:44:45 -07:00
parent 33f5db3209
commit 28c17e7714

View File

@ -24,9 +24,19 @@ $3ff03084 constant sha1_continue
$3ff03088 constant sha1_load $3ff03088 constant sha1_load
$3ff0308c constant sha1_busy $3ff0308c constant sha1_busy
$f peri_clk_en !
$0 peri_rst_en !
: WMOVE ( a a n -- )
0 ?DO
2DUP SWAP UL@ SWAP L!
4 + SWAP 4 + SWAP
LOOP 2DROP ;
: wait begin sha1_busy @ 0= until ; : wait begin sha1_busy @ 0= until ;
variable started variable started
: chunk : chunk
w sha_text 16 WMOVE
started @ if started @ if
1 sha1_continue ! 1 sha1_continue !
else else
@ -36,10 +46,7 @@ variable started
; ;
: >w { msg n } : >w { msg n }
sha_text 64 ERASE w 64 ERASE msg w n CMOVE $80 w n + c! w 64 <->* ;
msg sha_text n CMOVE
$80 sha_text n + c!
sha_text 64 <->* ;
40 constant sha1-size 40 constant sha1-size
create sha1-hash sha1-size allot create sha1-hash sha1-size allot
@ -48,23 +55,21 @@ create sha1-hash sha1-size allot
BASE @ >R HEX <# # # # # # # # # #> R> BASE ! BASE @ >R HEX <# # # # # # # # # #> R> BASE !
ROT 2DUP + >R SWAP CMOVE R> ; ROT 2DUP + >R SWAP CMOVE R> ;
: format : format
sha1-hash sha_text w 20 CMOVE
5 0 DO i cells sha_text + @ >dig LOOP sha1-hash 5 0 DO I @w >dig LOOP DROP ;
DROP ;
: sha1 { msg n -- hash n } n 64 /mod { edge wholes } : sha1 { msg n -- hash n } n 64 /mod { edge wholes }
0 started !
wholes 0 ?DO msg 64 >w chunk 64 +TO msg LOOP wholes 0 ?DO msg 64 >w chunk 64 +TO msg LOOP
edge 0= IF edge 0= IF
0 0 >w 0 0 >w
ELSE ELSE
msg edge >w msg edge >w
edge 56 >= IF chunk sha_text 64 ERASE THEN edge 56 >= IF chunk w 64 ERASE THEN
THEN THEN
n 8 * 16 RSHIFT 16 RSHIFT 14 4* sha_text + L! n 8 * 16 RSHIFT 16 RSHIFT 14 !w
n 8 * 15 4* sha_text + L! n 8 * 15 !w chunk
chunk
1 sha1_load ! wait 1 sha1_load ! wait
sha_text w 5 WMOVE
format sha1-hash sha1-size format sha1-hash sha1-size
; ;