hedgewars/uSHA.pas
changeset 100 f324a18698fe
parent 4 bcbd7adb4e4b
child 101 f568cc72ea8c
equal deleted inserted replaced
99:fd9613278d1b 100:f324a18698fe
    50 procedure SHA1Update(var Context: TSHA1Context; Buf: Pointer; Length: LongWord);
    50 procedure SHA1Update(var Context: TSHA1Context; Buf: Pointer; Length: LongWord);
    51 function  SHA1Final(Context: TSHA1Context): TSHA1Digest;
    51 function  SHA1Final(Context: TSHA1Context): TSHA1Digest;
    52 
    52 
    53 implementation
    53 implementation
    54 
    54 
    55 function _bswap(X: LongWord): LongWord; assembler;
    55 function _bswap(X: LongWord): LongWord;
    56 asm
    56 begin
    57   bswap eax
    57   Result:= (X shr 24) or ((X shr 8) and $FF00) or ((X shl 8) and $FF0000) or (X shl 24)
    58 end;
    58 end;
    59 
    59 
    60 function rol(x: LongWord; y: Byte): LongWord; assembler;
    60 function rol(x: LongWord; y: Byte): LongWord;
    61 asm
    61 begin
    62   mov   cl,dl
    62   Result:= (X shl y) or (X shr (32 - y))
    63   rol   eax,cl
       
    64 end;
    63 end;
    65 
    64 
    66 function Ft(t, b, c, d: LongWord): LongWord;
    65 function Ft(t, b, c, d: LongWord): LongWord;
    67 begin
    66 begin
    68 case t of
    67 case t of