Created
October 9, 2016 04:24
-
-
Save daumiller/08e24b6fe47f861aeba0c42055d30173 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[SHA-256 in RepGen :) ] | |
[==================================================================================================================================] | |
Target = Account | |
[==================================================================================================================================] | |
Define | |
SHAInput = character | |
SHAOutput = character(64) | |
SHAw0a=number SHAw0b=number SHAw0c=number SHAw0d=number | |
SHAw1a=number SHAw1b=number SHAw1c=number SHAw1d=number | |
SHAw2a=number SHAw2b=number SHAw2c=number SHAw2d=number | |
SHAw3a=number SHAw3b=number SHAw3c=number SHAw3d=number | |
SHAw4a=number SHAw4b=number SHAw4c=number SHAw4d=number | |
SHAw5a=number SHAw5b=number SHAw5c=number SHAw5d=number | |
SHAw6a=number SHAw6b=number SHAw6c=number SHAw6d=number | |
SHAw7a=number SHAw7b=number SHAw7c=number SHAw7d=number | |
SHAw8a=number SHAw8b=number SHAw8c=number SHAw8d=number | |
SHAw9a=number SHAw9b=number SHAw9c=number SHAw9d=number | |
SHAwAa=number SHAwAb=number SHAwAc=number SHAwAd=number | |
SHAwBa=number SHAwBb=number SHAwBc=number SHAwBd=number | |
SHAwCa=number SHAwCb=number SHAwCc=number SHAwCd=number | |
SHAwDa=number SHAwDb=number SHAwDc=number SHAwDd=number | |
SHAwEa=number SHAwEb=number SHAwEc=number SHAwEd=number | |
SHAwFa=number SHAwFb=number SHAwFc=number SHAwFd=number | |
SHAwGa=number SHAwGb=number SHAwGc=number SHAwGd=number | |
SHAwHa=number SHAwHb=number SHAwHc=number SHAwHd=number | |
SHAw =number SHAx =number SHAy =number SHAz =number | |
SHAop = number | |
SHAop2 = number | |
SHAcarry = number | |
SHAstr = character(12) | |
SHAi = number | |
SHAn = number | |
SHAg = number | |
SHAh = number array( 63) | |
SHAk = number array(255) | |
SHAbuff = number array(191) | |
SHAlen = number | |
SHAcounter = number | |
SHAchunk = number array(255) | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Select | |
None | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Print Title = "Test - " | |
call SHAReset | |
SHAInput = "The quick brown fox jumps over the lazy dog" call SHA256 | |
col=01 CtrlChr(34) + SHAInput + CtrlChr(34) newline | |
col=01 " calculated : " + SHAOutput newline | |
col=01 " should be : " + UpperCase("d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592") newline | |
col=01 "----------------------------------------------------------------------------------------------" newline | |
call SHAReset | |
SHAInput = "The quick brown fox jumps over the lazy dog." call SHA256 | |
col=01 CtrlChr(34) + SHAInput + CtrlChr(34) newline | |
col=01 " calculated : " + SHAOutput newline | |
col=01 " should be : " + UpperCase("ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c") newline | |
col=01 "----------------------------------------------------------------------------------------------" newline | |
call SHAReset | |
SHAInput = "abc" call SHA256 | |
col=01 CtrlChr(34) + SHAInput + CtrlChr(34) newline | |
col=01 " calculated : " + SHAOutput newline | |
col=01 " should be : " + UpperCase("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") newline | |
col=01 "----------------------------------------------------------------------------------------------" newline | |
End | |
[==================================================================================================================================] | |
Procedure SHA256 | |
call SHAConvertInput | |
call SHAProcessChunks | |
call SHAStringOutput | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHAProcessChunks | |
SHAcounter = 0 | |
while(SHAcounter < SHAlen) do | |
call SHALoadChunk | |
call SHAProcessSingleChunk | |
SHAcounter = SHAcounter + 64 | |
end | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHAStringOutput | |
SHAOutput = "" | |
for SHAi=0 to 31 do | |
SHAn = SHAh(SHAi) | |
SHAg = Mod(SHAn,16) | |
SHAn = Number(Float(SHAn - SHAg) / Float(16)) | |
if(SHAn < 10) then SHAOutput=SHAOutput+CtrlChr(ChrValue("0") + SHAn) else SHAOutput=SHAOutput+CtrlChr(ChrValue("A") + (SHAn - 10)) | |
if(SHAg < 10) then SHAOutput=SHAOutput+CtrlChr(ChrValue("0") + SHAg) else SHAOutput=SHAOutput+CtrlChr(ChrValue("A") + (SHAg - 10)) | |
end | |
End | |
[==================================================================================================================================] | |
Procedure SHALoadChunk | |
for SHAi=0 to 63 do | |
SHAchunk(SHAi) = SHAbuff(SHAcounter + SHAi) | |
end | |
for SHAi=16 to 63 do | |
[4 = s0 := (w(i-15) rightrotate 7) xor (w(i-15) rightrotate 18) xor (w(i-15) rightshift 3)] | |
SHAop2=0 SHAop=((SHAi-15)*4) call SHALoadChunkToWord SHAop= 7 call SHARightRotate SHAop=0 SHAop2=1 call SHAMoveWord | |
SHAop2=0 SHAop=((SHAi-15)*4) call SHALoadChunkToWord SHAop=18 call SHARightRotate call SHAXor SHAop=2 SHAop2=1 call SHAMoveWord | |
SHAop2=0 SHAop=((SHAi-15)*4) call SHAloadChunkToWord SHAop= 3 call SHARightShift call SHAXor SHAop=2 SHAop2=4 call SHAMoveWord | |
[3 = s1 := (w(i-2) rightrotate 17) xor (w(i-2) rightrotate 19) xor (w(i-2) rightshift 10)] | |
SHAop2=0 SHAop=((SHAi- 2)*4) call SHALoadChunkToWord SHAop=17 call SHARightRotate SHAop=0 SHAop2=1 call SHAMoveWord | |
SHAop2=0 SHAop=((SHAi- 2)*4) call SHALoadChunkToWord SHAop=19 call SHARightRotate call SHAXor SHAop=2 SHAop2=1 call SHAMoveWord | |
SHAop2=0 SHAop=((SHAi- 2)*4) call SHAloadChunkToWord SHAop=10 call SHARightShift call SHAXor SHAop=2 SHAop2=3 call SHAMoveWord | |
[w(i) := w(i-16) + w(i-7) + s0 + s1] | |
SHAop2=0 SHAop=((SHAi-16)*4) call SHALoadChunkToWord | |
SHAop2=1 SHAop=((SHAi- 7)*4) call SHALoadChunkToWord | |
call SHAAdd | |
SHAop=2 SHAop2=0 call SHAMoveWord | |
SHAop=4 SHAop2=1 call SHAMoveWord | |
call SHAAdd | |
SHAop=2 SHAop2=0 call SHAMoveWord | |
SHAop=3 SHAop2=1 call SHAMoveWord | |
call SHAAdd | |
SHAop=2 SHAop2=(SHAi*4) call SHALoadWordToChunk | |
end | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHALoadChunkToWord | |
if(SHAop2 = 0) then do SHAw0a=SHAchunk(SHAop+0) SHAw0b=SHAchunk(SHAop+1) SHAw0c=SHAchunk(SHAop+2) SHAw0d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 1) then do SHAw1a=SHAchunk(SHAop+0) SHAw1b=SHAchunk(SHAop+1) SHAw1c=SHAchunk(SHAop+2) SHAw1d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 2) then do SHAw2a=SHAchunk(SHAop+0) SHAw2b=SHAchunk(SHAop+1) SHAw2c=SHAchunk(SHAop+2) SHAw2d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 3) then do SHAw3a=SHAchunk(SHAop+0) SHAw3b=SHAchunk(SHAop+1) SHAw3c=SHAchunk(SHAop+2) SHAw3d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 4) then do SHAw4a=SHAchunk(SHAop+0) SHAw4b=SHAchunk(SHAop+1) SHAw4c=SHAchunk(SHAop+2) SHAw4d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 5) then do SHAw5a=SHAchunk(SHAop+0) SHAw5b=SHAchunk(SHAop+1) SHAw5c=SHAchunk(SHAop+2) SHAw5d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 6) then do SHAw6a=SHAchunk(SHAop+0) SHAw6b=SHAchunk(SHAop+1) SHAw6c=SHAchunk(SHAop+2) SHAw6d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 7) then do SHAw7a=SHAchunk(SHAop+0) SHAw7b=SHAchunk(SHAop+1) SHAw7c=SHAchunk(SHAop+2) SHAw7d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 8) then do SHAw8a=SHAchunk(SHAop+0) SHAw8b=SHAchunk(SHAop+1) SHAw8c=SHAchunk(SHAop+2) SHAw8d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 9) then do SHAw9a=SHAchunk(SHAop+0) SHAw9b=SHAchunk(SHAop+1) SHAw9c=SHAchunk(SHAop+2) SHAw9d=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 10) then do SHAwAa=SHAchunk(SHAop+0) SHAwAb=SHAchunk(SHAop+1) SHAwAc=SHAchunk(SHAop+2) SHAwAd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 11) then do SHAwBa=SHAchunk(SHAop+0) SHAwBb=SHAchunk(SHAop+1) SHAwBc=SHAchunk(SHAop+2) SHAwBd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 12) then do SHAwCa=SHAchunk(SHAop+0) SHAwCb=SHAchunk(SHAop+1) SHAwCc=SHAchunk(SHAop+2) SHAwCd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 13) then do SHAwDa=SHAchunk(SHAop+0) SHAwDb=SHAchunk(SHAop+1) SHAwDc=SHAchunk(SHAop+2) SHAwDd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 14) then do SHAwEa=SHAchunk(SHAop+0) SHAwEb=SHAchunk(SHAop+1) SHAwEc=SHAchunk(SHAop+2) SHAwEd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 15) then do SHAwFa=SHAchunk(SHAop+0) SHAwFb=SHAchunk(SHAop+1) SHAwFc=SHAchunk(SHAop+2) SHAwFd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 16) then do SHAwGa=SHAchunk(SHAop+0) SHAwGb=SHAchunk(SHAop+1) SHAwGc=SHAchunk(SHAop+2) SHAwGd=SHAchunk(SHAop+3) end | |
else if(SHAop2 = 17) then do SHAwHa=SHAchunk(SHAop+0) SHAwHb=SHAchunk(SHAop+1) SHAwHc=SHAchunk(SHAop+2) SHAwHd=SHAchunk(SHAop+3) end | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHALoadWordToChunk | |
if(SHAop = 0) then do SHAchunk(SHAop2+0)=SHAw0a SHAchunk(SHAop2+1)=SHAw0b SHAchunk(SHAop2+2)=SHAw0c SHAchunk(SHAop2+3)=SHAw0d end | |
else if(SHAop = 1) then do SHAchunk(SHAop2+0)=SHAw1a SHAchunk(SHAop2+1)=SHAw1b SHAchunk(SHAop2+2)=SHAw1c SHAchunk(SHAop2+3)=SHAw1d end | |
else if(SHAop = 2) then do SHAchunk(SHAop2+0)=SHAw2a SHAchunk(SHAop2+1)=SHAw2b SHAchunk(SHAop2+2)=SHAw2c SHAchunk(SHAop2+3)=SHAw2d end | |
else if(SHAop = 3) then do SHAchunk(SHAop2+0)=SHAw3a SHAchunk(SHAop2+1)=SHAw3b SHAchunk(SHAop2+2)=SHAw3c SHAchunk(SHAop2+3)=SHAw3d end | |
else if(SHAop = 4) then do SHAchunk(SHAop2+0)=SHAw4a SHAchunk(SHAop2+1)=SHAw4b SHAchunk(SHAop2+2)=SHAw4c SHAchunk(SHAop2+3)=SHAw4d end | |
else if(SHAop = 5) then do SHAchunk(SHAop2+0)=SHAw5a SHAchunk(SHAop2+1)=SHAw5b SHAchunk(SHAop2+2)=SHAw5c SHAchunk(SHAop2+3)=SHAw5d end | |
else if(SHAop = 6) then do SHAchunk(SHAop2+0)=SHAw6a SHAchunk(SHAop2+1)=SHAw6b SHAchunk(SHAop2+2)=SHAw6c SHAchunk(SHAop2+3)=SHAw6d end | |
else if(SHAop = 7) then do SHAchunk(SHAop2+0)=SHAw7a SHAchunk(SHAop2+1)=SHAw7b SHAchunk(SHAop2+2)=SHAw7c SHAchunk(SHAop2+3)=SHAw7d end | |
else if(SHAop = 8) then do SHAchunk(SHAop2+0)=SHAw8a SHAchunk(SHAop2+1)=SHAw8b SHAchunk(SHAop2+2)=SHAw8c SHAchunk(SHAop2+3)=SHAw8d end | |
else if(SHAop = 9) then do SHAchunk(SHAop2+0)=SHAw9a SHAchunk(SHAop2+1)=SHAw9b SHAchunk(SHAop2+2)=SHAw9c SHAchunk(SHAop2+3)=SHAw9d end | |
else if(SHAop = 10) then do SHAchunk(SHAop2+0)=SHAwAa SHAchunk(SHAop2+1)=SHAwAb SHAchunk(SHAop2+2)=SHAwAc SHAchunk(SHAop2+3)=SHAwAd end | |
else if(SHAop = 11) then do SHAchunk(SHAop2+0)=SHAwBa SHAchunk(SHAop2+1)=SHAwBb SHAchunk(SHAop2+2)=SHAwBc SHAchunk(SHAop2+3)=SHAwBd end | |
else if(SHAop = 12) then do SHAchunk(SHAop2+0)=SHAwCa SHAchunk(SHAop2+1)=SHAwCb SHAchunk(SHAop2+2)=SHAwCc SHAchunk(SHAop2+3)=SHAwCd end | |
else if(SHAop = 13) then do SHAchunk(SHAop2+0)=SHAwDa SHAchunk(SHAop2+1)=SHAwDb SHAchunk(SHAop2+2)=SHAwDc SHAchunk(SHAop2+3)=SHAwDd end | |
else if(SHAop = 14) then do SHAchunk(SHAop2+0)=SHAwEa SHAchunk(SHAop2+1)=SHAwEb SHAchunk(SHAop2+2)=SHAwEc SHAchunk(SHAop2+3)=SHAwEd end | |
else if(SHAop = 15) then do SHAchunk(SHAop2+0)=SHAwFa SHAchunk(SHAop2+1)=SHAwFb SHAchunk(SHAop2+2)=SHAwFc SHAchunk(SHAop2+3)=SHAwFd end | |
else if(SHAop = 16) then do SHAchunk(SHAop2+0)=SHAwGa SHAchunk(SHAop2+1)=SHAwGb SHAchunk(SHAop2+2)=SHAwGc SHAchunk(SHAop2+3)=SHAwGd end | |
else if(SHAop = 17) then do SHAchunk(SHAop2+0)=SHAwHa SHAchunk(SHAop2+1)=SHAwHb SHAchunk(SHAop2+2)=SHAwHc SHAchunk(SHAop2+3)=SHAwHd end | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHAMoveWord | |
if(SHAop = 0) then do SHAw=SHAw0a SHAx=SHAw0b SHAy=SHAw0c SHAz=SHAw0d end | |
else if(SHAop = 1) then do SHAw=SHAw1a SHAx=SHAw1b SHAy=SHAw1c SHAz=SHAw1d end | |
else if(SHAop = 2) then do SHAw=SHAw2a SHAx=SHAw2b SHAy=SHAw2c SHAz=SHAw2d end | |
else if(SHAop = 3) then do SHAw=SHAw3a SHAx=SHAw3b SHAy=SHAw3c SHAz=SHAw3d end | |
else if(SHAop = 4) then do SHAw=SHAw4a SHAx=SHAw4b SHAy=SHAw4c SHAz=SHAw4d end | |
else if(SHAop = 5) then do SHAw=SHAw5a SHAx=SHAw5b SHAy=SHAw5c SHAz=SHAw5d end | |
else if(SHAop = 6) then do SHAw=SHAw6a SHAx=SHAw6b SHAy=SHAw6c SHAz=SHAw6d end | |
else if(SHAop = 7) then do SHAw=SHAw7a SHAx=SHAw7b SHAy=SHAw7c SHAz=SHAw7d end | |
else if(SHAop = 8) then do SHAw=SHAw8a SHAx=SHAw8b SHAy=SHAw8c SHAz=SHAw8d end | |
else if(SHAop = 9) then do SHAw=SHAw9a SHAx=SHAw9b SHAy=SHAw9c SHAz=SHAw9d end | |
else if(SHAop = 10) then do SHAw=SHAwAa SHAx=SHAwAb SHAy=SHAwAc SHAz=SHAwAd end | |
else if(SHAop = 11) then do SHAw=SHAwBa SHAx=SHAwBb SHAy=SHAwBc SHAz=SHAwBd end | |
else if(SHAop = 12) then do SHAw=SHAwCa SHAx=SHAwCb SHAy=SHAwCc SHAz=SHAwCd end | |
else if(SHAop = 13) then do SHAw=SHAwDa SHAx=SHAwDb SHAy=SHAwDc SHAz=SHAwDd end | |
else if(SHAop = 14) then do SHAw=SHAwEa SHAx=SHAwEb SHAy=SHAwEc SHAz=SHAwEd end | |
else if(SHAop = 15) then do SHAw=SHAwFa SHAx=SHAwFb SHAy=SHAwFc SHAz=SHAwFd end | |
else if(SHAop = 16) then do SHAw=SHAwGa SHAx=SHAwGb SHAy=SHAwGc SHAz=SHAwGd end | |
else if(SHAop = 17) then do SHAw=SHAwHa SHAx=SHAwHb SHAy=SHAwHc SHAz=SHAwHd end | |
if(SHAop2 = 0) then do SHAw0a=SHAw SHAw0b=SHAx SHAw0c=SHAy SHAw0d=SHAz end | |
else if(SHAop2 = 1) then do SHAw1a=SHAw SHAw1b=SHAx SHAw1c=SHAy SHAw1d=SHAz end | |
else if(SHAop2 = 2) then do SHAw2a=SHAw SHAw2b=SHAx SHAw2c=SHAy SHAw2d=SHAz end | |
else if(SHAop2 = 3) then do SHAw3a=SHAw SHAw3b=SHAx SHAw3c=SHAy SHAw3d=SHAz end | |
else if(SHAop2 = 4) then do SHAw4a=SHAw SHAw4b=SHAx SHAw4c=SHAy SHAw4d=SHAz end | |
else if(SHAop2 = 5) then do SHAw5a=SHAw SHAw5b=SHAx SHAw5c=SHAy SHAw5d=SHAz end | |
else if(SHAop2 = 6) then do SHAw6a=SHAw SHAw6b=SHAx SHAw6c=SHAy SHAw6d=SHAz end | |
else if(SHAop2 = 7) then do SHAw7a=SHAw SHAw7b=SHAx SHAw7c=SHAy SHAw7d=SHAz end | |
else if(SHAop2 = 8) then do SHAw8a=SHAw SHAw8b=SHAx SHAw8c=SHAy SHAw8d=SHAz end | |
else if(SHAop2 = 9) then do SHAw9a=SHAw SHAw9b=SHAx SHAw9c=SHAy SHAw9d=SHAz end | |
else if(SHAop2 = 10) then do SHAwAa=SHAw SHAwAb=SHAx SHAwAc=SHAy SHAwAd=SHAz end | |
else if(SHAop2 = 11) then do SHAwBa=SHAw SHAwBb=SHAx SHAwBc=SHAy SHAwBd=SHAz end | |
else if(SHAop2 = 12) then do SHAwCa=SHAw SHAwCb=SHAx SHAwCc=SHAy SHAwCd=SHAz end | |
else if(SHAop2 = 13) then do SHAwDa=SHAw SHAwDb=SHAx SHAwDc=SHAy SHAwDd=SHAz end | |
else if(SHAop2 = 14) then do SHAwEa=SHAw SHAwEb=SHAx SHAwEc=SHAy SHAwEd=SHAz end | |
else if(SHAop2 = 15) then do SHAwFa=SHAw SHAwFb=SHAx SHAwFc=SHAy SHAwFd=SHAz end | |
else if(SHAop2 = 16) then do SHAwGa=SHAw SHAwGb=SHAx SHAwGc=SHAy SHAwGd=SHAz end | |
else if(SHAop2 = 17) then do SHAwHa=SHAw SHAwHb=SHAx SHAwHc=SHAy SHAwHd=SHAz end | |
End | |
[==================================================================================================================================] | |
Procedure SHAProcessSingleChunk | |
SHAwAa=SHAh(00) SHAwAb=SHAh(01) SHAwAc=SHAh(02) SHAwAd=SHAh(03) | |
SHAwBa=SHAh(04) SHAwBb=SHAh(05) SHAwBc=SHAh(06) SHAwBd=SHAh(07) | |
SHAwCa=SHAh(08) SHAwCb=SHAh(09) SHAwCc=SHAh(10) SHAwCd=SHAh(11) | |
SHAwDa=SHAh(12) SHAwDb=SHAh(13) SHAwDc=SHAh(14) SHAwDd=SHAh(15) | |
SHAwEa=SHAh(16) SHAwEb=SHAh(17) SHAwEc=SHAh(18) SHAwEd=SHAh(19) | |
SHAwFa=SHAh(20) SHAwFb=SHAh(21) SHAwFc=SHAh(22) SHAwFd=SHAh(23) | |
SHAwGa=SHAh(24) SHAwGb=SHAh(25) SHAwGc=SHAh(26) SHAwGd=SHAh(27) | |
SHAwHa=SHAh(28) SHAwHb=SHAh(29) SHAwHc=SHAh(30) SHAwHd=SHAh(31) | |
for SHAi=0 to 63 do | |
[9 == temporary storage] | |
[3 = S0 = (a rightrotate 2) xor (a rightrotate 13) xor (a rightrotate 22)] | |
SHAop=10 SHAop2=0 call SHAMoveWord SHAop=02 call SHARightRotate SHAop=0 SHAop2=1 call SHAMoveWord | |
SHAop=10 SHAop2=0 call SHAMoveWord SHAop=13 call SHARightRotate call SHAXor SHAop=2 SHAop2=1 call SHAMoveWord | |
SHAop=10 SHAop2=0 call SHAMoveWord SHAop=22 call SHARightRotate call SHAXor SHAop=2 SHAop2=3 call SHAMoveWord | |
[4 = maj = (a and b) xor (a and c) xor (b and c)] | |
SHAop=10 SHAop2=0 call SHAMoveWord SHAop=11 SHAop2=1 call SHAMoveWord call SHAAnd SHAop=2 SHAop2=9 call SHAMoveWord | |
SHAop=10 SHAop2=0 call SHAMoveWord SHAop=12 SHAop2=1 call SHAMoveWord call SHAAnd SHAop=2 SHAop2=0 call SHAMoveWord SHAop=9 SHAop2=1 call SHAMoveWord call SHAXor SHAop=2 SHAop2=9 call SHAMoveWord | |
SHAop=11 SHAop2=0 call SHAMoveWord SHAop=12 SHAop2=1 call SHAMoveWord call SHAAnd SHAop=2 SHAop2=0 call SHAMoveWord SHAop=9 SHAop2=1 call SHAMoveWord call SHAXor SHAOp=2 SHAop2=4 call SHAMoveWord | |
[5 = t2 = S0 + maj] | |
SHAop=3 SHAop2=0 call SHAMoveWord | |
SHAop=4 SHAop2=1 call SHAMoveWord | |
call SHAAdd SHAop=2 SHAop2=5 call SHAMoveWord | |
[6 = S1 = (e rightrotate 6) xor (e rightrotate 11) xor (e rightrotate 25)] | |
SHAop=14 SHAop2=0 call SHAMoveWord SHAop=06 call SHARightRotate SHAop=0 SHAop2=1 call SHAMoveWord | |
SHAop=14 SHAop2=0 call SHAMoveWord SHAop=11 call SHARightRotate call SHAXor SHAop=2 SHAop2=1 call SHAMoveWord | |
SHAop=14 SHAop2=0 call SHAMoveWord SHAop=25 call SHARightRotate call SHAXor SHAop=2 SHAop2=6 call SHAMoveWord | |
[7 = ch = (e and f) xor ((not e) and g)] | |
SHAop=14 SHAop2=0 call SHAMoveWord SHAop=15 SHAop2=1 call SHAMoveWord call SHAAnd SHAop=2 SHAop2=9 call SHAMoveWord | |
SHAop=14 SHAop2=0 call SHAMoveWord call SHANot SHAop=16 SHAop2=1 call SHAMoveWord call SHAAnd SHAop=2 SHAop2=0 call SHAMoveWord | |
SHAop=09 SHAop2=1 call SHAMoveWord call SHAXor SHAop=02 SHAop2=7 call SHAMoveWord | |
[8 = t1 = h + S1 + ch + k(i) + w(i)] | |
SHAw0a= SHAk((SHAi*4)+0) SHAw0b= SHAk((SHAi*4)+1) SHAw0c=SHAk((SHAi*4)+2) SHAw0d= SHAk((SHAi*4)+3) | |
SHAw1a=SHAchunk((SHAi*4)+0) SHAw1b=SHAchunk((SHAi*4)+1) SHAw1c=SHAchunk((SHAi*4)+2) SHAw1d=SHAchunk((SHAi*4)+3) | |
call SHAAdd | |
SHAop=2 SHAop2=1 call SHAMoveWord SHAop=17 SHAop2=0 call SHAMoveWord call SHAAdd | |
SHAop=2 SHAop2=1 call SHAMoveWord SHAop=06 SHAop2=0 call SHAMoveWord call SHAAdd | |
SHAop=2 SHAop2=1 call SHAMoveWord SHAop=07 SHAop2=0 call SHAMoveWord call SHAAdd | |
SHAop=2 SHAop2=8 call SHAMoveWord | |
SHAop=16 SHAop2=17 call SHAMoveWord [h = g :: g -> h] | |
SHAop=15 SHAop2=16 call SHAMoveWord [g = f :: f -> g] | |
SHAop=14 SHAop2=15 call SHAMoveWord [f = e :: e -> f] | |
SHAop=13 SHAop2=00 call SHAMoveWord SHAop=8 SHAop2=1 call SHAMoveWord call SHAAdd SHAop=2 SHAop2=14 call SHAMoveWord [e = d + t1] | |
SHAop=12 SHAop2=13 call SHAMoveWord [d = c :: c -> d] | |
SHAop=11 SHAop2=12 call SHAMoveWord [c = b :: b -> c] | |
SHAop=10 SHAop2=11 call SHAMoveWord [b = a :: a -> b] | |
SHAop=08 SHAop2=00 call SHAMoveWord SHAop=5 SHAop2=1 call SHAMoveWord call SHAAdd SHAop=2 SHAop2=10 call SHAMoveWord [a = t1 + t2] | |
end | |
SHAw0a=SHAh(00) SHAw0b=SHAh(01) SHAw0c=SHAh(02) SHAw0d=SHAh(03) SHAop=10 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(00)=SHAw2a SHAh(01)=SHAw2b SHAh(02)=SHAw2c SHAh(03)=SHAw2d | |
SHAw0a=SHAh(04) SHAw0b=SHAh(05) SHAw0c=SHAh(06) SHAw0d=SHAh(07) SHAop=11 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(04)=SHAw2a SHAh(05)=SHAw2b SHAh(06)=SHAw2c SHAh(07)=SHAw2d | |
SHAw0a=SHAh(08) SHAw0b=SHAh(09) SHAw0c=SHAh(10) SHAw0d=SHAh(11) SHAop=12 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(08)=SHAw2a SHAh(09)=SHAw2b SHAh(10)=SHAw2c SHAh(11)=SHAw2d | |
SHAw0a=SHAh(12) SHAw0b=SHAh(13) SHAw0c=SHAh(14) SHAw0d=SHAh(15) SHAop=13 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(12)=SHAw2a SHAh(13)=SHAw2b SHAh(14)=SHAw2c SHAh(15)=SHAw2d | |
SHAw0a=SHAh(16) SHAw0b=SHAh(17) SHAw0c=SHAh(18) SHAw0d=SHAh(19) SHAop=14 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(16)=SHAw2a SHAh(17)=SHAw2b SHAh(18)=SHAw2c SHAh(19)=SHAw2d | |
SHAw0a=SHAh(20) SHAw0b=SHAh(21) SHAw0c=SHAh(22) SHAw0d=SHAh(23) SHAop=15 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(20)=SHAw2a SHAh(21)=SHAw2b SHAh(22)=SHAw2c SHAh(23)=SHAw2d | |
SHAw0a=SHAh(24) SHAw0b=SHAh(25) SHAw0c=SHAh(26) SHAw0d=SHAh(27) SHAop=16 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(24)=SHAw2a SHAh(25)=SHAw2b SHAh(26)=SHAw2c SHAh(27)=SHAw2d | |
SHAw0a=SHAh(28) SHAw0b=SHAh(29) SHAw0c=SHAh(30) SHAw0d=SHAh(31) SHAop=17 SHAop2=1 call SHAMoveWord call SHAAdd SHAh(28)=SHAw2a SHAh(29)=SHAw2b SHAh(30)=SHAw2c SHAh(31)=SHAw2d | |
End | |
[==================================================================================================================================] | |
Procedure SHAConvertInput | |
SHAlen = Length(SHAInput) | |
for SHAi=1 to SHAlen do | |
SHAbuff(SHAi-1) = ChrValue(Segment(SHAInput,SHAi,SHAi)) | |
end | |
SHAbuff(SHAlen) = 128 | |
SHAlen = SHAlen + 1 | |
while(Mod(SHAlen,64) <> 56) do | |
SHAbuff(SHAlen) = 0 | |
SHAlen = SHAlen + 1 | |
end | |
SHAi = Length(SHAInput) * 8 | |
SHAn = Mod(SHAi,256) | |
SHAi = Number(Float(SHAi - SHAn) / Float(256)) | |
SHAbuff(SHAlen+0)=0 SHAbuff(SHAlen+1)=0 SHAbuff(SHAlen+2)=0 SHAbuff(SHAlen+3)=0 | |
SHAbuff(SHAlen+4)=0 SHAbuff(SHAlen+5)=0 SHAbuff(SHAlen+6)=SHAi SHAbuff(SHAlen+7)=SHAn | |
SHAlen = SHAlen + 8 | |
End | |
[==================================================================================================================================] | |
Procedure SHAReset | |
SHAstr="0x6A09E667" call SHAHexString SHAh(00)=SHAw0a SHAh(01)=SHAw0b SHAh(02)=SHAw0c SHAh(03)=SHAw0d | |
SHAstr="0xBB67AE85" call SHAHexString SHAh(04)=SHAw0a SHAh(05)=SHAw0b SHAh(06)=SHAw0c SHAh(07)=SHAw0d | |
SHAstr="0x3C6Ef372" call SHAHexString SHAh(08)=SHAw0a SHAh(09)=SHAw0b SHAh(10)=SHAw0c SHAh(11)=SHAw0d | |
SHAstr="0xA54FF53A" call SHAHexString SHAh(12)=SHAw0a SHAh(13)=SHAw0b SHAh(14)=SHAw0c SHAh(15)=SHAw0d | |
SHAstr="0x510E527F" call SHAHexString SHAh(16)=SHAw0a SHAh(17)=SHAw0b SHAh(18)=SHAw0c SHAh(19)=SHAw0d | |
SHAstr="0x9B05688C" call SHAHexString SHAh(20)=SHAw0a SHAh(21)=SHAw0b SHAh(22)=SHAw0c SHAh(23)=SHAw0d | |
SHAstr="0x1F83D9AB" call SHAHexString SHAh(24)=SHAw0a SHAh(25)=SHAw0b SHAh(26)=SHAw0c SHAh(27)=SHAw0d | |
SHAstr="0x5BE0CD19" call SHAHexString SHAh(28)=SHAw0a SHAh(29)=SHAw0b SHAh(30)=SHAw0c SHAh(31)=SHAw0d | |
SHAstr="0x428A2F98" call SHAHexString SHAk(000)=SHAw0a SHAk(001)=SHAw0b SHAk(002)=SHAw0c SHAk(003)=SHAw0d | |
SHAstr="0x71374491" call SHAHexString SHAk(004)=SHAw0a SHAk(005)=SHAw0b SHAk(006)=SHAw0c SHAk(007)=SHAw0d | |
SHAstr="0xB5C0FBCF" call SHAHexString SHAk(008)=SHAw0a SHAk(009)=SHAw0b SHAk(010)=SHAw0c SHAk(011)=SHAw0d | |
SHAstr="0xE9B5DBA5" call SHAHexString SHAk(012)=SHAw0a SHAk(013)=SHAw0b SHAk(014)=SHAw0c SHAk(015)=SHAw0d | |
SHAstr="0x3956C25B" call SHAHexString SHAk(016)=SHAw0a SHAk(017)=SHAw0b SHAk(018)=SHAw0c SHAk(019)=SHAw0d | |
SHAstr="0x59F111F1" call SHAHexString SHAk(020)=SHAw0a SHAk(021)=SHAw0b SHAk(022)=SHAw0c SHAk(023)=SHAw0d | |
SHAstr="0x923F82A4" call SHAHexString SHAk(024)=SHAw0a SHAk(025)=SHAw0b SHAk(026)=SHAw0c SHAk(027)=SHAw0d | |
SHAstr="0xAB1C5ED5" call SHAHexString SHAk(028)=SHAw0a SHAk(029)=SHAw0b SHAk(030)=SHAw0c SHAk(031)=SHAw0d | |
SHAstr="0xD807AA98" call SHAHexString SHAk(032)=SHAw0a SHAk(033)=SHAw0b SHAk(034)=SHAw0c SHAk(035)=SHAw0d | |
SHAstr="0x12835B01" call SHAHexString SHAk(036)=SHAw0a SHAk(037)=SHAw0b SHAk(038)=SHAw0c SHAk(039)=SHAw0d | |
SHAstr="0x243185BE" call SHAHexString SHAk(040)=SHAw0a SHAk(041)=SHAw0b SHAk(042)=SHAw0c SHAk(043)=SHAw0d | |
SHAstr="0x550C7DC3" call SHAHexString SHAk(044)=SHAw0a SHAk(045)=SHAw0b SHAk(046)=SHAw0c SHAk(047)=SHAw0d | |
SHAstr="0x72BE5D74" call SHAHexString SHAk(048)=SHAw0a SHAk(049)=SHAw0b SHAk(050)=SHAw0c SHAk(051)=SHAw0d | |
SHAstr="0x80DEB1FE" call SHAHexString SHAk(052)=SHAw0a SHAk(053)=SHAw0b SHAk(054)=SHAw0c SHAk(055)=SHAw0d | |
SHAstr="0x9BDC06A7" call SHAHexString SHAk(056)=SHAw0a SHAk(057)=SHAw0b SHAk(058)=SHAw0c SHAk(059)=SHAw0d | |
SHAstr="0xC19BF174" call SHAHexString SHAk(060)=SHAw0a SHAk(061)=SHAw0b SHAk(062)=SHAw0c SHAk(063)=SHAw0d | |
SHAstr="0xE49B69C1" call SHAHexString SHAk(064)=SHAw0a SHAk(065)=SHAw0b SHAk(066)=SHAw0c SHAk(067)=SHAw0d | |
SHAstr="0xEFBE4786" call SHAHexString SHAk(068)=SHAw0a SHAk(069)=SHAw0b SHAk(070)=SHAw0c SHAk(071)=SHAw0d | |
SHAstr="0x0FC19DC6" call SHAHexString SHAk(072)=SHAw0a SHAk(073)=SHAw0b SHAk(074)=SHAw0c SHAk(075)=SHAw0d | |
SHAstr="0x240CA1CC" call SHAHexString SHAk(076)=SHAw0a SHAk(077)=SHAw0b SHAk(078)=SHAw0c SHAk(079)=SHAw0d | |
SHAstr="0x2DE92C6F" call SHAHexString SHAk(080)=SHAw0a SHAk(081)=SHAw0b SHAk(082)=SHAw0c SHAk(083)=SHAw0d | |
SHAstr="0x4A7484AA" call SHAHexString SHAk(084)=SHAw0a SHAk(085)=SHAw0b SHAk(086)=SHAw0c SHAk(087)=SHAw0d | |
SHAstr="0x5CB0A9DC" call SHAHexString SHAk(088)=SHAw0a SHAk(089)=SHAw0b SHAk(090)=SHAw0c SHAk(091)=SHAw0d | |
SHAstr="0x76F988DA" call SHAHexString SHAk(092)=SHAw0a SHAk(093)=SHAw0b SHAk(094)=SHAw0c SHAk(095)=SHAw0d | |
SHAstr="0x983E5152" call SHAHexString SHAk(096)=SHAw0a SHAk(097)=SHAw0b SHAk(098)=SHAw0c SHAk(099)=SHAw0d | |
SHAstr="0xA831C66D" call SHAHexString SHAk(100)=SHAw0a SHAk(101)=SHAw0b SHAk(102)=SHAw0c SHAk(103)=SHAw0d | |
SHAstr="0xB00327C8" call SHAHexString SHAk(104)=SHAw0a SHAk(105)=SHAw0b SHAk(106)=SHAw0c SHAk(107)=SHAw0d | |
SHAstr="0xBF597FC7" call SHAHexString SHAk(108)=SHAw0a SHAk(109)=SHAw0b SHAk(110)=SHAw0c SHAk(111)=SHAw0d | |
SHAstr="0xC6E00BF3" call SHAHexString SHAk(112)=SHAw0a SHAk(113)=SHAw0b SHAk(114)=SHAw0c SHAk(115)=SHAw0d | |
SHAstr="0xD5A79147" call SHAHexString SHAk(116)=SHAw0a SHAk(117)=SHAw0b SHAk(118)=SHAw0c SHAk(119)=SHAw0d | |
SHAstr="0x06CA6351" call SHAHexString SHAk(120)=SHAw0a SHAk(121)=SHAw0b SHAk(122)=SHAw0c SHAk(123)=SHAw0d | |
SHAstr="0x14292967" call SHAHexString SHAk(124)=SHAw0a SHAk(125)=SHAw0b SHAk(126)=SHAw0c SHAk(127)=SHAw0d | |
SHAstr="0x27B70A85" call SHAHexString SHAk(128)=SHAw0a SHAk(129)=SHAw0b SHAk(130)=SHAw0c SHAk(131)=SHAw0d | |
SHAstr="0x2E1B2138" call SHAHexString SHAk(132)=SHAw0a SHAk(133)=SHAw0b SHAk(134)=SHAw0c SHAk(135)=SHAw0d | |
SHAstr="0x4D2C6DFC" call SHAHexString SHAk(136)=SHAw0a SHAk(137)=SHAw0b SHAk(138)=SHAw0c SHAk(139)=SHAw0d | |
SHAstr="0x53380D13" call SHAHexString SHAk(140)=SHAw0a SHAk(141)=SHAw0b SHAk(142)=SHAw0c SHAk(143)=SHAw0d | |
SHAstr="0x650A7354" call SHAHexString SHAk(144)=SHAw0a SHAk(145)=SHAw0b SHAk(146)=SHAw0c SHAk(147)=SHAw0d | |
SHAstr="0x766A0ABB" call SHAHexString SHAk(148)=SHAw0a SHAk(149)=SHAw0b SHAk(150)=SHAw0c SHAk(151)=SHAw0d | |
SHAstr="0x81C2C92E" call SHAHexString SHAk(152)=SHAw0a SHAk(153)=SHAw0b SHAk(154)=SHAw0c SHAk(155)=SHAw0d | |
SHAstr="0x92722C85" call SHAHexString SHAk(156)=SHAw0a SHAk(157)=SHAw0b SHAk(158)=SHAw0c SHAk(159)=SHAw0d | |
SHAstr="0xA2BFE8A1" call SHAHexString SHAk(160)=SHAw0a SHAk(161)=SHAw0b SHAk(162)=SHAw0c SHAk(163)=SHAw0d | |
SHAstr="0xA81A664B" call SHAHexString SHAk(164)=SHAw0a SHAk(165)=SHAw0b SHAk(166)=SHAw0c SHAk(167)=SHAw0d | |
SHAstr="0xC24B8B70" call SHAHexString SHAk(168)=SHAw0a SHAk(169)=SHAw0b SHAk(170)=SHAw0c SHAk(171)=SHAw0d | |
SHAstr="0xC76C51A3" call SHAHexString SHAk(172)=SHAw0a SHAk(173)=SHAw0b SHAk(174)=SHAw0c SHAk(175)=SHAw0d | |
SHAstr="0xD192E819" call SHAHexString SHAk(176)=SHAw0a SHAk(177)=SHAw0b SHAk(178)=SHAw0c SHAk(179)=SHAw0d | |
SHAstr="0xD6990624" call SHAHexString SHAk(180)=SHAw0a SHAk(181)=SHAw0b SHAk(182)=SHAw0c SHAk(183)=SHAw0d | |
SHAstr="0xF40E3585" call SHAHexString SHAk(184)=SHAw0a SHAk(185)=SHAw0b SHAk(186)=SHAw0c SHAk(187)=SHAw0d | |
SHAstr="0x106AA070" call SHAHexString SHAk(188)=SHAw0a SHAk(189)=SHAw0b SHAk(190)=SHAw0c SHAk(191)=SHAw0d | |
SHAstr="0x19A4C116" call SHAHexString SHAk(192)=SHAw0a SHAk(193)=SHAw0b SHAk(194)=SHAw0c SHAk(195)=SHAw0d | |
SHAstr="0x1E376C08" call SHAHexString SHAk(196)=SHAw0a SHAk(197)=SHAw0b SHAk(198)=SHAw0c SHAk(199)=SHAw0d | |
SHAstr="0x2748774C" call SHAHexString SHAk(200)=SHAw0a SHAk(201)=SHAw0b SHAk(202)=SHAw0c SHAk(203)=SHAw0d | |
SHAstr="0x34B0BCB5" call SHAHexString SHAk(204)=SHAw0a SHAk(205)=SHAw0b SHAk(206)=SHAw0c SHAk(207)=SHAw0d | |
SHAstr="0x391C0CB3" call SHAHexString SHAk(208)=SHAw0a SHAk(209)=SHAw0b SHAk(210)=SHAw0c SHAk(211)=SHAw0d | |
SHAstr="0x4ED8AA4A" call SHAHexString SHAk(212)=SHAw0a SHAk(213)=SHAw0b SHAk(214)=SHAw0c SHAk(215)=SHAw0d | |
SHAstr="0x5B9CCA4F" call SHAHexString SHAk(216)=SHAw0a SHAk(217)=SHAw0b SHAk(218)=SHAw0c SHAk(219)=SHAw0d | |
SHAstr="0x682E6FF3" call SHAHexString SHAk(220)=SHAw0a SHAk(221)=SHAw0b SHAk(222)=SHAw0c SHAk(223)=SHAw0d | |
SHAstr="0x748F82EE" call SHAHexString SHAk(224)=SHAw0a SHAk(225)=SHAw0b SHAk(226)=SHAw0c SHAk(227)=SHAw0d | |
SHAstr="0x78A5636F" call SHAHexString SHAk(228)=SHAw0a SHAk(229)=SHAw0b SHAk(230)=SHAw0c SHAk(231)=SHAw0d | |
SHAstr="0x84C87814" call SHAHexString SHAk(232)=SHAw0a SHAk(233)=SHAw0b SHAk(234)=SHAw0c SHAk(235)=SHAw0d | |
SHAstr="0x8CC70208" call SHAHexString SHAk(236)=SHAw0a SHAk(237)=SHAw0b SHAk(238)=SHAw0c SHAk(239)=SHAw0d | |
SHAstr="0x90BEFFFA" call SHAHexString SHAk(240)=SHAw0a SHAk(241)=SHAw0b SHAk(242)=SHAw0c SHAk(243)=SHAw0d | |
SHAstr="0xA4506CEB" call SHAHexString SHAk(244)=SHAw0a SHAk(245)=SHAw0b SHAk(246)=SHAw0c SHAk(247)=SHAw0d | |
SHAstr="0xBEF9A3F7" call SHAHexString SHAk(248)=SHAw0a SHAk(249)=SHAw0b SHAk(250)=SHAw0c SHAk(251)=SHAw0d | |
SHAstr="0xC67178F2" call SHAHexString SHAk(252)=SHAw0a SHAk(253)=SHAw0b SHAk(254)=SHAw0c SHAk(255)=SHAw0d | |
End | |
[==================================================================================================================================] | |
Procedure SHAHexByte | |
SHAi = 0 | |
SHAn = ChrValue(Segment(SHAstr,1,1)) | |
if((SHAn >= ChrValue("0")) and (SHAn <= ChrValue("9"))) then | |
SHAi = SHAi + (SHAn - ChrValue("0")) | |
else if((SHAn >= ChrValue("A")) and (SHAn <= ChrValue("F"))) then | |
SHAi = SHAi + 10 + (SHAn - ChrValue("A")) | |
SHAi = SHAi * 16 | |
SHAn = ChrValue(Segment(SHAstr,2,2)) | |
if((SHAn >= ChrValue("0")) and (SHAn <= ChrValue("9"))) then | |
SHAi = SHAi + (SHAn - ChrValue("0")) | |
else if((SHAn >= ChrValue("A")) and (SHAn <= ChrValue("F"))) then | |
SHAi = SHAi + 10 + (SHAn - ChrValue("A")) | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHAHexString | |
SHAstr = UpperCase(SHAstr) | |
SHAw0a=0 SHAw0b=0 SHAw0c=0 SHAw0d=0 | |
if(Segment(SHAstr,1,2) = "0X") then SHAstr = Segment(SHAstr,3,Length(SHAstr)) | |
call SHAHexByte SHAw0a=SHAi SHAstr = Segment(SHAstr,3,Length(SHAstr)) | |
call SHAHexByte SHAw0b=SHAi SHAstr = Segment(SHAstr,3,Length(SHAstr)) | |
call SHAHexByte SHAw0c=SHAi SHAstr = Segment(SHAstr,3,Length(SHAstr)) | |
call SHAHexByte SHAw0d=SHAi SHAstr = Segment(SHAstr,3,Length(SHAstr)) | |
End | |
[==================================================================================================================================] | |
Procedure SHARightShiftBit | |
SHAcarry = Mod(SHAw0a,2) | |
SHAw0a = Number(Float(SHAw0a - SHAcarry) / Float(2)) | |
SHAw0b = SHAw0b + (256 * SHAcarry) | |
SHAcarry = Mod(SHAw0b,2) | |
SHAw0b = Number(Float(SHAw0b - SHAcarry) / Float(2)) | |
SHAw0c = SHAw0c + (256 * SHAcarry) | |
SHACarry = Mod(SHAw0c,2) | |
SHAw0c = Number(Float(SHAw0c - SHAcarry) / Float(2)) | |
SHAw0d = SHAw0d + (256 * SHACarry) | |
SHACarry = Mod(SHAw0d,2) | |
SHAw0d = Number(Float(SHAw0d - SHAcarry) / Float(2)) | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHARightRotateBit | |
call SHARightShiftBit | |
SHAw0a = SHAw0a + (128 * SHAcarry) | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHARightShift | |
while(SHAop > 0) do | |
call SHARightShiftBit | |
SHAop = SHAop - 1 | |
end | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHARightRotate | |
while(SHAop > 0) do | |
call SHARightRotateBit | |
SHAop = SHAop - 1 | |
end | |
End | |
[==================================================================================================================================] | |
Procedure SHAAnd | |
SHAw2a=0 SHAw2b=0 SHAw2c=0 SHAw2d=0 | |
if((Mod(SHAw0a,256)>127) and (Mod(SHAw1a,256)>127)) then SHAw2a=SHAw2a+128 | |
if((Mod(SHAw0a,128)> 63) and (Mod(SHAw1a,128)> 63)) then SHAw2a=SHAw2a+ 64 | |
if((Mod(SHAw0a, 64)> 31) and (Mod(SHAw1a, 64)> 31)) then SHAw2a=SHAw2a+ 32 | |
if((Mod(SHAw0a, 32)> 15) and (Mod(SHAw1a, 32)> 15)) then SHAw2a=SHAw2a+ 16 | |
if((Mod(SHAw0a, 16)> 7) and (Mod(SHAw1a, 16)> 7)) then SHAw2a=SHAw2a+ 8 | |
if((Mod(SHAw0a, 8)> 3) and (Mod(SHAw1a, 8)> 3)) then SHAw2a=SHAw2a+ 4 | |
if((Mod(SHAw0a, 4)> 1) and (Mod(SHAw1a, 4)> 1)) then SHAw2a=SHAw2a+ 2 | |
if((Mod(SHAw0a, 2)> 0) and (Mod(SHAw1a, 2)> 0)) then SHAw2a=SHAw2a+ 1 | |
if((Mod(SHAw0b,256)>127) and (Mod(SHAw1b,256)>127)) then SHAw2b=SHAw2b+128 | |
if((Mod(SHAw0b,128)> 63) and (Mod(SHAw1b,128)> 63)) then SHAw2b=SHAw2b+ 64 | |
if((Mod(SHAw0b, 64)> 31) and (Mod(SHAw1b, 64)> 31)) then SHAw2b=SHAw2b+ 32 | |
if((Mod(SHAw0b, 32)> 15) and (Mod(SHAw1b, 32)> 15)) then SHAw2b=SHAw2b+ 16 | |
if((Mod(SHAw0b, 16)> 7) and (Mod(SHAw1b, 16)> 7)) then SHAw2b=SHAw2b+ 8 | |
if((Mod(SHAw0b, 8)> 3) and (Mod(SHAw1b, 8)> 3)) then SHAw2b=SHAw2b+ 4 | |
if((Mod(SHAw0b, 4)> 1) and (Mod(SHAw1b, 4)> 1)) then SHAw2b=SHAw2b+ 2 | |
if((Mod(SHAw0b, 2)> 0) and (Mod(SHAw1b, 2)> 0)) then SHAw2b=SHAw2b+ 1 | |
if((Mod(SHAw0c,256)>127) and (Mod(SHAw1c,256)>127)) then SHAw2c=SHAw2c+128 | |
if((Mod(SHAw0c,128)> 63) and (Mod(SHAw1c,128)> 63)) then SHAw2c=SHAw2c+ 64 | |
if((Mod(SHAw0c, 64)> 31) and (Mod(SHAw1c, 64)> 31)) then SHAw2c=SHAw2c+ 32 | |
if((Mod(SHAw0c, 32)> 15) and (Mod(SHAw1c, 32)> 15)) then SHAw2c=SHAw2c+ 16 | |
if((Mod(SHAw0c, 16)> 7) and (Mod(SHAw1c, 16)> 7)) then SHAw2c=SHAw2c+ 8 | |
if((Mod(SHAw0c, 8)> 3) and (Mod(SHAw1c, 8)> 3)) then SHAw2c=SHAw2c+ 4 | |
if((Mod(SHAw0c, 4)> 1) and (Mod(SHAw1c, 4)> 1)) then SHAw2c=SHAw2c+ 2 | |
if((Mod(SHAw0c, 2)> 0) and (Mod(SHAw1c, 2)> 0)) then SHAw2c=SHAw2c+ 1 | |
if((Mod(SHAw0d,256)>127) and (Mod(SHAw1d,256)>127)) then SHAw2d=SHAw2d+128 | |
if((Mod(SHAw0d,128)> 63) and (Mod(SHAw1d,128)> 63)) then SHAw2d=SHAw2d+ 64 | |
if((Mod(SHAw0d, 64)> 31) and (Mod(SHAw1d, 64)> 31)) then SHAw2d=SHAw2d+ 32 | |
if((Mod(SHAw0d, 32)> 15) and (Mod(SHAw1d, 32)> 15)) then SHAw2d=SHAw2d+ 16 | |
if((Mod(SHAw0d, 16)> 7) and (Mod(SHAw1d, 16)> 7)) then SHAw2d=SHAw2d+ 8 | |
if((Mod(SHAw0d, 8)> 3) and (Mod(SHAw1d, 8)> 3)) then SHAw2d=SHAw2d+ 4 | |
if((Mod(SHAw0d, 4)> 1) and (Mod(SHAw1d, 4)> 1)) then SHAw2d=SHAw2d+ 2 | |
if((Mod(SHAw0d, 2)> 0) and (Mod(SHAw1d, 2)> 0)) then SHAw2d=SHAw2d+ 1 | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHAXor | |
SHAw2a=0 SHAw2b=0 SHAw2c=0 SHAw2d=0 | |
if((Mod(SHAw0a,256)-Mod(SHAw0a,128)) <> (Mod(SHAw1a,256)-Mod(SHAw1a,128))) then SHAw2a=SHAw2a+128 | |
if((Mod(SHAw0a,128)-Mod(SHAw0a, 64)) <> (Mod(SHAw1a,128)-Mod(SHAw1a, 64))) then SHAw2a=SHAw2a+ 64 | |
if((Mod(SHAw0a, 64)-Mod(SHAw0a, 32)) <> (Mod(SHAw1a, 64)-Mod(SHAw1a, 32))) then SHAw2a=SHAw2a+ 32 | |
if((Mod(SHAw0a, 32)-Mod(SHAw0a, 16)) <> (Mod(SHAw1a, 32)-Mod(SHAw1a, 16))) then SHAw2a=SHAw2a+ 16 | |
if((Mod(SHAw0a, 16)-Mod(SHAw0a, 8)) <> (Mod(SHAw1a, 16)-Mod(SHAw1a, 8))) then SHAw2a=SHAw2a+ 8 | |
if((Mod(SHAw0a, 8)-Mod(SHAw0a, 4)) <> (Mod(SHAw1a, 8)-Mod(SHAw1a, 4))) then SHAw2a=SHAw2a+ 4 | |
if((Mod(SHAw0a, 4)-Mod(SHAw0a, 2)) <> (Mod(SHAw1a, 4)-Mod(SHAw1a, 2))) then SHAw2a=SHAw2a+ 2 | |
if((Mod(SHAw0a, 2) ) <> (Mod(SHAw1a, 2) )) then SHAw2a=SHAw2a+ 1 | |
if((Mod(SHAw0b,256)-Mod(SHAw0b,128)) <> (Mod(SHAw1b,256)-Mod(SHAw1b,128))) then SHAw2b=SHAw2b+128 | |
if((Mod(SHAw0b,128)-Mod(SHAw0b, 64)) <> (Mod(SHAw1b,128)-Mod(SHAw1b, 64))) then SHAw2b=SHAw2b+ 64 | |
if((Mod(SHAw0b, 64)-Mod(SHAw0b, 32)) <> (Mod(SHAw1b, 64)-Mod(SHAw1b, 32))) then SHAw2b=SHAw2b+ 32 | |
if((Mod(SHAw0b, 32)-Mod(SHAw0b, 16)) <> (Mod(SHAw1b, 32)-Mod(SHAw1b, 16))) then SHAw2b=SHAw2b+ 16 | |
if((Mod(SHAw0b, 16)-Mod(SHAw0b, 8)) <> (Mod(SHAw1b, 16)-Mod(SHAw1b, 8))) then SHAw2b=SHAw2b+ 8 | |
if((Mod(SHAw0b, 8)-Mod(SHAw0b, 4)) <> (Mod(SHAw1b, 8)-Mod(SHAw1b, 4))) then SHAw2b=SHAw2b+ 4 | |
if((Mod(SHAw0b, 4)-Mod(SHAw0b, 2)) <> (Mod(SHAw1b, 4)-Mod(SHAw1b, 2))) then SHAw2b=SHAw2b+ 2 | |
if((Mod(SHAw0b, 2) ) <> (Mod(SHAw1b, 2) )) then SHAw2b=SHAw2b+ 1 | |
if((Mod(SHAw0c,256)-Mod(SHAw0c,128)) <> (Mod(SHAw1c,256)-Mod(SHAw1c,128))) then SHAw2c=SHAw2c+128 | |
if((Mod(SHAw0c,128)-Mod(SHAw0c, 64)) <> (Mod(SHAw1c,128)-Mod(SHAw1c, 64))) then SHAw2c=SHAw2c+ 64 | |
if((Mod(SHAw0c, 64)-Mod(SHAw0c, 32)) <> (Mod(SHAw1c, 64)-Mod(SHAw1c, 32))) then SHAw2c=SHAw2c+ 32 | |
if((Mod(SHAw0c, 32)-Mod(SHAw0c, 16)) <> (Mod(SHAw1c, 32)-Mod(SHAw1c, 16))) then SHAw2c=SHAw2c+ 16 | |
if((Mod(SHAw0c, 16)-Mod(SHAw0c, 8)) <> (Mod(SHAw1c, 16)-Mod(SHAw1c, 8))) then SHAw2c=SHAw2c+ 8 | |
if((Mod(SHAw0c, 8)-Mod(SHAw0c, 4)) <> (Mod(SHAw1c, 8)-Mod(SHAw1c, 4))) then SHAw2c=SHAw2c+ 4 | |
if((Mod(SHAw0c, 4)-Mod(SHAw0c, 2)) <> (Mod(SHAw1c, 4)-Mod(SHAw1c, 2))) then SHAw2c=SHAw2c+ 2 | |
if((Mod(SHAw0c, 2) ) <> (Mod(SHAw1c, 2) )) then SHAw2c=SHAw2c+ 1 | |
if((Mod(SHAw0d,256)-Mod(SHAw0d,128)) <> (Mod(SHAw1d,256)-Mod(SHAw1d,128))) then SHAw2d=SHAw2d+128 | |
if((Mod(SHAw0d,128)-Mod(SHAw0d, 64)) <> (Mod(SHAw1d,128)-Mod(SHAw1d, 64))) then SHAw2d=SHAw2d+ 64 | |
if((Mod(SHAw0d, 64)-Mod(SHAw0d, 32)) <> (Mod(SHAw1d, 64)-Mod(SHAw1d, 32))) then SHAw2d=SHAw2d+ 32 | |
if((Mod(SHAw0d, 32)-Mod(SHAw0d, 16)) <> (Mod(SHAw1d, 32)-Mod(SHAw1d, 16))) then SHAw2d=SHAw2d+ 16 | |
if((Mod(SHAw0d, 16)-Mod(SHAw0d, 8)) <> (Mod(SHAw1d, 16)-Mod(SHAw1d, 8))) then SHAw2d=SHAw2d+ 8 | |
if((Mod(SHAw0d, 8)-Mod(SHAw0d, 4)) <> (Mod(SHAw1d, 8)-Mod(SHAw1d, 4))) then SHAw2d=SHAw2d+ 4 | |
if((Mod(SHAw0d, 4)-Mod(SHAw0d, 2)) <> (Mod(SHAw1d, 4)-Mod(SHAw1d, 2))) then SHAw2d=SHAw2d+ 2 | |
if((Mod(SHAw0d, 2) ) <> (Mod(SHAw1d, 2) )) then SHAw2d=SHAw2d+ 1 | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHANot | |
SHAw0a = 255 - SHAw0a | |
SHAw0b = 255 - SHAw0b | |
SHAw0c = 255 - SHAw0c | |
SHAw0d = 255 - SHAw0d | |
End | |
[----------------------------------------------------------------------------------------------------------------------------------] | |
Procedure SHAAdd | |
SHAg=SHAw0d+SHAw1d if(SHAg>255) then SHAcarry=1 else SHAcarry=0 SHAw2d=Mod(SHAg,256) | |
SHAg=SHAw0c+SHAw1c+SHAcarry if(SHAg>255) then SHAcarry=1 else SHAcarry=0 SHAw2c=Mod(SHAg,256) | |
SHAg=SHAw0b+SHAw1b+SHAcarry if(SHAg>255) then SHAcarry=1 else SHAcarry=0 SHAw2b=Mod(SHAg,256) | |
SHAg=SHAw0a+SHAw1a+SHAcarry if(SHAg>255) then SHAcarry=1 else SHAcarry=0 SHAw2a=Mod(SHAg,256) | |
End | |
[==================================================================================================================================] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment