1
0
mirror of https://git.code.sf.net/p/lazarus-ccr/dcpcrypt synced 2025-07-02 22:56:50 +02:00

Fixes a hell of a lot of compiler warnings.

* Also implemented a local dcpFillChar() method which uses a 'out'
  parameter causing less compiler hints.
This commit is contained in:
Graeme Geldenhuys
2009-11-17 17:11:47 +02:00
parent a6a0258b48
commit 9d151d353a
28 changed files with 144 additions and 63 deletions

View File

@ -79,6 +79,7 @@ var
Cipher: TDCP_blowfish; Cipher: TDCP_blowfish;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_blowfish.Create(nil); Cipher:= TDCP_blowfish.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);
@ -104,6 +105,7 @@ var
KeyB: PByteArray; KeyB: PByteArray;
Block: array[0..7] of byte; Block: array[0..7] of byte;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Size:= Size div 8; Size:= Size div 8;
KeyB:= @Key; KeyB:= @Key;
Move(SBoxOrg,SBox,Sizeof(SBox)); Move(SBoxOrg,SBox,Sizeof(SBox));

View File

@ -90,6 +90,7 @@ var
Block: array[0..7] of byte; Block: array[0..7] of byte;
Cipher: TDCP_cast128; Cipher: TDCP_cast128;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_cast128.Create(nil); Cipher:= TDCP_cast128.Create(nil);
Cipher.Init(Key,128,nil); Cipher.Init(Key,128,nil);
Cipher.EncryptECB(InBlock,Block); Cipher.EncryptECB(InBlock,Block);
@ -122,7 +123,7 @@ begin
Rounds:= 12 Rounds:= 12
else else
Rounds:= 16; Rounds:= 16;
FillChar(x,Sizeof(x),0); dcpFillChar(x, Sizeof(x), 0);
Move(Key,x,Size); Move(Key,x,Size);
x[0]:= (x[0] shr 24) or ((x[0] shr 8) and $FF00) or ((x[0] shl 8) and $FF0000) or (x[0] shl 24); x[0]:= (x[0] shr 24) or ((x[0] shr 8) and $FF00) or ((x[0] shl 8) and $FF0000) or (x[0] shl 24);
x[1]:= (x[1] shr 24) or ((x[1] shr 8) and $FF00) or ((x[1] shl 8) and $FF0000) or (x[1] shl 24); x[1]:= (x[1] shr 24) or ((x[1] shr 8) and $FF00) or ((x[1] shl 8) and $FF0000) or (x[1] shl 24);

View File

@ -123,6 +123,7 @@ var
Block: array[0..15] of byte; Block: array[0..15] of byte;
Cipher: TDCP_cast256; Cipher: TDCP_cast256;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_cast256.Create(nil); Cipher:= TDCP_cast256.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InBlock1,Block); Cipher.EncryptECB(InBlock1,Block);
@ -154,7 +155,7 @@ var
begin begin
Size:= Size div 8; Size:= Size div 8;
FillChar(x,Sizeof(x),0); dcpFillChar(x,Sizeof(x),0);
Move(Key,x,Size); Move(Key,x,Size);
cm:= $5a827999; cm:= $5a827999;

View File

@ -100,6 +100,7 @@ procedure TDCP_customdes.DoInit(KeyB: PByteArray; KeyData: PDwordArray);
var var
c, d, t, s, t2, i: dword; c, d, t, s, t2, i: dword;
begin begin
t := 0;
c:= KeyB^[0] or (KeyB^[1] shl 8) or (KeyB^[2] shl 16) or (KeyB^[3] shl 24); c:= KeyB^[0] or (KeyB^[1] shl 8) or (KeyB^[2] shl 16) or (KeyB^[3] shl 24);
d:= KeyB^[4] or (KeyB^[5] shl 8) or (KeyB^[6] shl 16) or (KeyB^[7] shl 24); d:= KeyB^[4] or (KeyB^[5] shl 8) or (KeyB^[6] shl 16) or (KeyB^[7] shl 24);
perm_op(d,c,t,4,$0f0f0f0f); perm_op(d,c,t,4,$0f0f0f0f);
@ -361,6 +362,7 @@ var
Cipher: TDCP_des; Cipher: TDCP_des;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_des.Create(nil); Cipher:= TDCP_des.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);
@ -381,7 +383,7 @@ procedure TDCP_des.InitKey(const Key; Size: longword);
var var
KeyB: array[0..7] of byte; KeyB: array[0..7] of byte;
begin begin
FillChar(KeyB,Sizeof(KeyB),0); dcpFillChar(KeyB,Sizeof(KeyB),0);
Move(Key,KeyB,Size div 8); Move(Key,KeyB,Size div 8);
DoInit(@KeyB,@KeyData); DoInit(@KeyB,@KeyData);
end; end;
@ -435,6 +437,7 @@ var
Cipher: TDCP_3des; Cipher: TDCP_3des;
Block: array[0..7] of byte; Block: array[0..7] of byte;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_3des.Create(nil); Cipher:= TDCP_3des.Create(nil);
Cipher.Init(Key,Sizeof(Key)*8,nil); Cipher.Init(Key,Sizeof(Key)*8,nil);
Cipher.EncryptECB(PlainText,Block); Cipher.EncryptECB(PlainText,Block);
@ -448,7 +451,7 @@ procedure TDCP_3des.InitKey(const Key; Size: longword);
var var
KeyB: array[0..2,0..7] of byte; KeyB: array[0..2,0..7] of byte;
begin begin
FillChar(KeyB,Sizeof(KeyB),0); dcpFillChar(KeyB,Sizeof(KeyB),0);
Move(Key,KeyB,Size div 8); Move(Key,KeyB,Size div 8);
DoInit(@KeyB[0],@KeyData[0]); DoInit(@KeyB[0],@KeyData[0]);
DoInit(@KeyB[1],@KeyData[1]); DoInit(@KeyB[1],@KeyData[1]);

View File

@ -96,6 +96,7 @@ var
Block: array[0..7] of byte; Block: array[0..7] of byte;
Cipher: TDCP_gost; Cipher: TDCP_gost;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_gost.Create(nil); Cipher:= TDCP_gost.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Block); Cipher.EncryptECB(InData1,Block);
@ -118,8 +119,7 @@ var
userkey: array[0..31] of byte; userkey: array[0..31] of byte;
begin begin
Size:= Size div 8; Size:= Size div 8;
dcpFillChar(userkey,Sizeof(userkey),0);
FillChar(userkey,Sizeof(userkey),0);
Move(Key,userkey,Size); Move(Key,userkey,Size);
for i:= 0 to 7 do for i:= 0 to 7 do
KeyData[i]:= (dword(UserKey[4*i+3]) shl 24) or (dword(UserKey[4*i+2]) shl 16) or KeyData[i]:= (dword(UserKey[4*i+3]) shl 24) or (dword(UserKey[4*i+2]) shl 16) or

View File

@ -233,7 +233,7 @@ var
kb: array[0..3] of word; kb: array[0..3] of word;
keyb: array[0..15] of byte; keyb: array[0..15] of byte;
begin begin
FillChar(keyb,Sizeof(keyb),0); dcpFillChar(keyb,Sizeof(keyb),0);
Move(key,keyb,Size div 8); Move(key,keyb,Size div 8);
if n> 0 then if n> 0 then
rounds:= 16 * n rounds:= 16 * n
@ -339,6 +339,7 @@ var
Cipher: TDCP_ice; Cipher: TDCP_ice;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_ice.Create(nil); Cipher:= TDCP_ice.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);
@ -380,6 +381,7 @@ var
Cipher: TDCP_thinice; Cipher: TDCP_thinice;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_thinice.Create(nil); Cipher:= TDCP_thinice.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);
@ -422,6 +424,7 @@ var
Cipher: TDCP_ice2; Cipher: TDCP_ice2;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_ice2.Create(nil); Cipher:= TDCP_ice2.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);

View File

@ -84,6 +84,7 @@ var
Cipher: TDCP_idea; Cipher: TDCP_idea;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_idea.Create(nil); Cipher:= TDCP_idea.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);

View File

@ -95,6 +95,7 @@ var
Cipher: TDCP_mars; Cipher: TDCP_mars;
Block: array[0..3] of dword; Block: array[0..3] of dword;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_mars.Create(nil); Cipher:= TDCP_mars.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(Plain1,Block); Cipher.EncryptECB(Plain1,Block);
@ -140,8 +141,11 @@ var
t: array[-7..39] of DWord; t: array[-7..39] of DWord;
KeyB: array[0..39] of DWord; KeyB: array[0..39] of DWord;
begin begin
m := 0;
Size:= Size div 8; Size:= Size div 8;
FillChar(KeyB,Sizeof(KeyB),0); dcpFillChar(KeyB,Sizeof(KeyB),0);
dcpFillChar(t, SizeOf(t), 0);
Move(Key,KeyB,Size); Move(Key,KeyB,Size);
Size:= Size div 4; Size:= Size div 4;
Move(vk,t,Sizeof(vk)); Move(vk,t,Sizeof(vk));

View File

@ -92,6 +92,7 @@ var
Cipher: TDCP_misty1; Cipher: TDCP_misty1;
Block: array[0..7] of byte; Block: array[0..7] of byte;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_misty1.Create(nil); Cipher:= TDCP_misty1.Create(nil);
Cipher.Init(Key,Sizeof(Key)*8,nil); Cipher.Init(Key,Sizeof(Key)*8,nil);
Cipher.EncryptECB(Plain1,Block); Cipher.EncryptECB(Plain1,Block);
@ -188,7 +189,7 @@ var
KeyB: array[0..15] of byte; KeyB: array[0..15] of byte;
i: longword; i: longword;
begin begin
FillChar(KeyB,Sizeof(KeyB),0); dcpFillChar(KeyB,Sizeof(KeyB),0);
Move(Key,KeyB,Size div 8); Move(Key,KeyB,Size div 8);
for i:= 0 to 7 do for i:= 0 to 7 do
KeyData[i]:= (KeyB[i*2] * 256) + KeyB[i*2+1]; KeyData[i]:= (KeyB[i*2] * 256) + KeyB[i*2+1];

View File

@ -96,6 +96,7 @@ var
Cipher: TDCP_rc2; Cipher: TDCP_rc2;
Data: array[0..7] of byte; Data: array[0..7] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_rc2.Create(nil); Cipher:= TDCP_rc2.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Data); Cipher.EncryptECB(InData1,Data);
@ -117,6 +118,7 @@ var
i: longword; i: longword;
KeyB: array[0..127] of byte; KeyB: array[0..127] of byte;
begin begin
dcpFillChar(KeyB, SizeOf(KeyB), 0);
Move(Key,KeyB,Size div 8); Move(Key,KeyB,Size div 8);
for i:= (Size div 8) to 127 do for i:= (Size div 8) to 127 do
KeyB[i]:= sBox[(KeyB[i-(Size div 8)]+KeyB[i-1]) and $FF]; KeyB[i]:= sBox[(KeyB[i-(Size div 8)]+KeyB[i-1]) and $FF];

View File

@ -75,6 +75,7 @@ var
Cipher: TDCP_rc4; Cipher: TDCP_rc4;
Data: array[0..4] of byte; Data: array[0..4] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_rc4.Create(nil); Cipher:= TDCP_rc4.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.Encrypt(InData1,Data,Sizeof(Data)); Cipher.Encrypt(InData1,Data,Sizeof(Data));

View File

@ -106,6 +106,7 @@ var
Cipher: TDCP_rc5; Cipher: TDCP_rc5;
Data: array[0..1] of dword; Data: array[0..1] of dword;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_rc5.Create(nil); Cipher:= TDCP_rc5.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(Plain1,Data); Cipher.EncryptECB(Plain1,Data);
@ -128,7 +129,7 @@ var
i, j, k, xKeyLen: longword; i, j, k, xKeyLen: longword;
A, B: DWord; A, B: DWord;
begin begin
FillChar(xKeyD,Sizeof(xKeyD),0); dcpFillChar(xKeyD,Sizeof(xKeyD),0);
Size:= Size div 8; Size:= Size div 8;
Move(Key,xKeyD,Size); Move(Key,xKeyD,Size);
xKeyLen:= Size div 4; xKeyLen:= Size div 4;

View File

@ -111,6 +111,7 @@ var
Cipher: TDCP_rc6; Cipher: TDCP_rc6;
Data: array[0..15] of byte; Data: array[0..15] of byte;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_rc6.Create(nil); Cipher:= TDCP_rc6.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(Plain1,Data); Cipher.EncryptECB(Plain1,Data);
@ -134,7 +135,7 @@ var
A, B: DWord; A, B: DWord;
begin begin
Size:= Size div 8; Size:= Size div 8;
FillChar(xKeyD,Sizeof(xKeyD),0); dcpFillChar(xKeyD,Sizeof(xKeyD),0);
Move(Key,xKeyD,Size); Move(Key,xKeyD,Size);
xKeyLen:= Size div 4; xKeyLen:= Size div 4;
if (Size mod 4)<> 0 then if (Size mod 4)<> 0 then

View File

@ -98,6 +98,7 @@ var
Block: array[0..15] of byte; Block: array[0..15] of byte;
Cipher: TDCP_rijndael; Cipher: TDCP_rijndael;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_rijndael.Create(nil); Cipher:= TDCP_rijndael.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Block); Cipher.EncryptECB(InData1,Block);
@ -138,7 +139,7 @@ var
begin begin
Size:= Size div 8; Size:= Size div 8;
FillChar(tk,Sizeof(tk),0); dcpFillChar(tk,Sizeof(tk),0);
Move(Key,tk,Size); Move(Key,tk,Size);
if Size<= 16 then if Size<= 16 then
begin begin

View File

@ -94,6 +94,7 @@ var
Block: array[0..15] of byte; Block: array[0..15] of byte;
Cipher: TDCP_serpent; Cipher: TDCP_serpent;
begin begin
dcpFillChar(Block, SizeOf(Block), 0);
Cipher:= TDCP_serpent.Create(nil); Cipher:= TDCP_serpent.Create(nil);
Cipher.Init(Key1,Sizeof(Key1)*8,nil); Cipher.Init(Key1,Sizeof(Key1)*8,nil);
Cipher.EncryptECB(InData1,Block); Cipher.EncryptECB(InData1,Block);
@ -123,7 +124,7 @@ var
t, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17: dword; t, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17: dword;
a, b, c, d: dword; a, b, c, d: dword;
begin begin
FillChar(kp,256 div 8,0); dcpFillChar(kp, SizeOf(kp), 0);
Move(Key,kp,Size div 8); Move(Key,kp,Size div 8);
if Size < 256 then if Size < 256 then
begin begin

View File

@ -83,6 +83,7 @@ var
Data: array[0..1] of dword; Data: array[0..1] of dword;
Cipher: TDCP_tea; Cipher: TDCP_tea;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Cipher:= TDCP_tea.Create(nil); Cipher:= TDCP_tea.Create(nil);
Cipher.Init(Key,Sizeof(Key)*8,nil); Cipher.Init(Key,Sizeof(Key)*8,nil);
Cipher.EncryptECB(PT,Data); Cipher.EncryptECB(PT,Data);

View File

@ -100,8 +100,8 @@ var
Cipher: TDCP_twofish; Cipher: TDCP_twofish;
begin begin
Cipher:= TDCP_twofish.Create(nil); Cipher:= TDCP_twofish.Create(nil);
FillChar(Key,Sizeof(Key),0); dcpFillChar(Key,Sizeof(Key),0);
FillChar(Block,Sizeof(Block),0); dcpFillChar(Block,Sizeof(Block),0);
for i:= 1 to 49 do for i:= 1 to 49 do
begin begin
Cipher.Init(Key,128,nil); Cipher.Init(Key,128,nil);
@ -110,8 +110,8 @@ begin
Cipher.Burn; Cipher.Burn;
end; end;
Result:= boolean(CompareMem(@Block,@Out128,16)); Result:= boolean(CompareMem(@Block,@Out128,16));
FillChar(Key,Sizeof(Key),0); dcpFillChar(Key,Sizeof(Key),0);
FillChar(Block,Sizeof(Block),0); dcpFillChar(Block,Sizeof(Block),0);
for i:= 1 to 49 do for i:= 1 to 49 do
begin begin
Cipher.Init(Key,192,nil); Cipher.Init(Key,192,nil);
@ -254,7 +254,7 @@ var
k64Cnt, i, j, A, B, q: DWord; k64Cnt, i, j, A, B, q: DWord;
L0, L1: array[0..255] of byte; L0, L1: array[0..255] of byte;
begin begin
FillChar(Key32,Sizeof(Key32),0); dcpFillChar(Key32,Sizeof(Key32),0);
Move(Key,Key32,Size div 8); Move(Key,Key32,Size div 8);
if Size<= 128 then { pad the key to either 128bit, 192bit or 256bit} if Size<= 128 then { pad the key to either 128bit, 192bit or 256bit}
Size:= 128 Size:= 128

View File

@ -75,6 +75,7 @@ var
W: array[0..31] of DWord; W: array[0..31] of DWord;
Temp: dword; Temp: dword;
begin begin
dcpFillChar(W, SizeOf(W), 0);
t0:= CurrentHash[0]; t0:= CurrentHash[0];
t1:= CurrentHash[1]; t1:= CurrentHash[1];
t2:= CurrentHash[2]; t2:= CurrentHash[2];
@ -253,6 +254,7 @@ class function TDCP_haval.SelfTest: boolean;
TestHash: TDCP_haval; TestHash: TDCP_haval;
TestOut: array[0..31] of byte; TestOut: array[0..31] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_haval.Create(nil); TestHash:= TDCP_haval.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz'); TestHash.UpdateStr('abcdefghijklmnopqrstuvwxyz');

View File

@ -66,6 +66,7 @@ var
Data: array[0..15] of dword; Data: array[0..15] of dword;
A, B, C, D: dword; A, B, C, D: dword;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Move(HashBuffer,Data,Sizeof(Data)); Move(HashBuffer,Data,Sizeof(Data));
A:= CurrentHash[0]; A:= CurrentHash[0];
B:= CurrentHash[1]; B:= CurrentHash[1];
@ -156,6 +157,7 @@ var
TestHash: TDCP_md4; TestHash: TDCP_md4;
TestOut: array[0..19] of byte; TestOut: array[0..19] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_md4.Create(nil); TestHash:= TDCP_md4.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abc'); TestHash.UpdateStr('abc');

View File

@ -66,6 +66,7 @@ var
Data: array[0..15] of dword; Data: array[0..15] of dword;
A, B, C, D: dword; A, B, C, D: dword;
begin begin
dcpFillChar(Data, SizeOf(Data), 0);
Move(HashBuffer,Data,Sizeof(Data)); Move(HashBuffer,Data,Sizeof(Data));
A:= CurrentHash[0]; A:= CurrentHash[0];
B:= CurrentHash[1]; B:= CurrentHash[1];
@ -173,6 +174,7 @@ var
TestHash: TDCP_md5; TestHash: TDCP_md5;
TestOut: array[0..19] of byte; TestOut: array[0..19] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_md5.Create(nil); TestHash:= TDCP_md5.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abc'); TestHash.UpdateStr('abc');

View File

@ -61,6 +61,7 @@ var
X: array[0..15] of DWord; X: array[0..15] of DWord;
a, aa, b, bb, c, cc, d, dd, t: dword; a, aa, b, bb, c, cc, d, dd, t: dword;
begin begin
dcpFillChar(X, SizeOf(X), 0);
Move(HashBuffer,X,Sizeof(X)); Move(HashBuffer,X,Sizeof(X));
a:= CurrentHash[0]; aa:= a; a:= CurrentHash[0]; aa:= a;
b:= CurrentHash[1]; bb:= b; b:= CurrentHash[1]; bb:= b;
@ -239,6 +240,7 @@ var
TestHash: TDCP_ripemd128; TestHash: TDCP_ripemd128;
TestOut: array[0..15] of byte; TestOut: array[0..15] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_ripemd128.Create(nil); TestHash:= TDCP_ripemd128.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('a'); TestHash.UpdateStr('a');

View File

@ -61,6 +61,7 @@ var
aa, bb, cc, dd, ee, aaa, bbb, ccc, ddd, eee: DWord; aa, bb, cc, dd, ee, aaa, bbb, ccc, ddd, eee: DWord;
X: array[0..15] of DWord; X: array[0..15] of DWord;
begin begin
dcpFillChar(X, SizeOf(X), 0);
Move(HashBuffer,X,Sizeof(X)); Move(HashBuffer,X,Sizeof(X));
aa:= CurrentHash[0]; aa:= CurrentHash[0];
aaa:= CurrentHash[0]; aaa:= CurrentHash[0];
@ -599,6 +600,7 @@ var
TestHash: TDCP_ripemd160; TestHash: TDCP_ripemd160;
TestOut: array[0..19] of byte; TestOut: array[0..19] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_ripemd160.Create(nil); TestHash:= TDCP_ripemd160.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('a'); TestHash.UpdateStr('a');

View File

@ -66,6 +66,7 @@ var
i: longword; i: longword;
begin begin
Index:= 0; Index:= 0;
dcpFillChar(W, SizeOf(W), 0);
Move(HashBuffer,W,Sizeof(HashBuffer)); Move(HashBuffer,W,Sizeof(HashBuffer));
for i:= 0 to 15 do for i:= 0 to 15 do
W[i]:= SwapDWord(W[i]); W[i]:= SwapDWord(W[i]);
@ -191,6 +192,7 @@ var
TestHash: TDCP_sha1; TestHash: TDCP_sha1;
TestOut: array[0..19] of byte; TestOut: array[0..19] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_sha1.Create(nil); TestHash:= TDCP_sha1.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abc'); TestHash.UpdateStr('abc');

View File

@ -66,6 +66,7 @@ var
i: longword; i: longword;
begin begin
Index:= 0; Index:= 0;
dcpFillChar(W, SizeOf(W), 0);
a:= CurrentHash[0]; b:= CurrentHash[1]; c:= CurrentHash[2]; d:= CurrentHash[3]; a:= CurrentHash[0]; b:= CurrentHash[1]; c:= CurrentHash[2]; d:= CurrentHash[3];
e:= CurrentHash[4]; f:= CurrentHash[5]; g:= CurrentHash[6]; h:= CurrentHash[7]; e:= CurrentHash[4]; f:= CurrentHash[5]; g:= CurrentHash[6]; h:= CurrentHash[7];
Move(HashBuffer,W,Sizeof(HashBuffer)); Move(HashBuffer,W,Sizeof(HashBuffer));
@ -191,6 +192,7 @@ var
TestHash: TDCP_sha256; TestHash: TDCP_sha256;
TestOut: array[0..31] of byte; TestOut: array[0..31] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_sha256.Create(nil); TestHash:= TDCP_sha256.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abc'); TestHash.UpdateStr('abc');

View File

@ -81,6 +81,7 @@ var
i: longword; i: longword;
begin begin
Index:= 0; Index:= 0;
dcpFillChar(W, SizeOf(W), 0);
a:= CurrentHash[0]; b:= CurrentHash[1]; c:= CurrentHash[2]; d:= CurrentHash[3]; a:= CurrentHash[0]; b:= CurrentHash[1]; c:= CurrentHash[2]; d:= CurrentHash[3];
e:= CurrentHash[4]; f:= CurrentHash[5]; g:= CurrentHash[6]; h:= CurrentHash[7]; e:= CurrentHash[4]; f:= CurrentHash[5]; g:= CurrentHash[6]; h:= CurrentHash[7];
Move(HashBuffer,W,Sizeof(HashBuffer)); Move(HashBuffer,W,Sizeof(HashBuffer));
@ -265,6 +266,7 @@ var
TestHash: TDCP_sha384; TestHash: TDCP_sha384;
TestOut: array[0..47] of byte; TestOut: array[0..47] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_sha384.Create(nil); TestHash:= TDCP_sha384.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abc'); TestHash.UpdateStr('abc');
@ -343,6 +345,7 @@ var
TestHash: TDCP_sha512; TestHash: TDCP_sha512;
TestOut: array[0..63] of byte; TestOut: array[0..63] of byte;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_sha512.Create(nil); TestHash:= TDCP_sha512.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('abc'); TestHash.UpdateStr('abc');

View File

@ -61,6 +61,7 @@ var
a, b, c, aa, bb, cc: int64; a, b, c, aa, bb, cc: int64;
x: array[0..7] of int64; x: array[0..7] of int64;
begin begin
dcpFillChar(x, SizeOf(x), 0);
a:= CurrentHash[0]; aa:= a; a:= CurrentHash[0]; aa:= a;
b:= CurrentHash[1]; bb:= b; b:= CurrentHash[1]; bb:= b;
c:= CurrentHash[2]; cc:= c; c:= CurrentHash[2]; cc:= c;
@ -228,6 +229,7 @@ var
TestHash: TDCP_tiger; TestHash: TDCP_tiger;
TestOut: array[0..2] of int64; TestOut: array[0..2] of int64;
begin begin
dcpFillChar(TestOut, SizeOf(TestOut), 0);
TestHash:= TDCP_tiger.Create(nil); TestHash:= TDCP_tiger.Create(nil);
TestHash.Init; TestHash.Init;
TestHash.UpdateStr('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-'); TestHash.UpdateStr('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-');

View File

@ -224,6 +224,7 @@ var
begin begin
if not fInitialized then if not fInitialized then
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
dcpFillChar(Temp, SizeOf(Temp), 0);
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
for i:= 1 to (Size div 8) do for i:= 1 to (Size div 8) do
@ -254,6 +255,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to Size do for i:= 1 to Size do
begin begin
EncryptECB(CV,Temp); EncryptECB(CV,Temp);
@ -276,6 +278,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to Size do for i:= 1 to Size do
begin begin
TempByte:= p1^; TempByte:= p1^;
@ -324,6 +327,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 8) do for i:= 1 to (Size div 8) do
begin begin
Move(p1^,Temp,8); Move(p1^,Temp,8);
@ -402,6 +406,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 8) do for i:= 1 to (Size div 8) do
begin begin
EncryptECB(CV,temp); EncryptECB(CV,temp);
@ -430,6 +435,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 8) do for i:= 1 to (Size div 8) do
begin begin
EncryptECB(CV,temp); EncryptECB(CV,temp);
@ -551,6 +557,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 16) do for i:= 1 to (Size div 16) do
begin begin
Move(p1^,p2^,16); Move(p1^,p2^,16);
@ -579,6 +586,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to Size do for i:= 1 to Size do
begin begin
EncryptECB(CV,Temp); EncryptECB(CV,Temp);
@ -601,6 +609,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to Size do for i:= 1 to Size do
begin begin
TempByte:= p1^; TempByte:= p1^;
@ -649,6 +658,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 16) do for i:= 1 to (Size div 16) do
begin begin
Move(p1^,Temp,16); Move(p1^,Temp,16);
@ -727,6 +737,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 16) do for i:= 1 to (Size div 16) do
begin begin
EncryptECB(CV,temp); EncryptECB(CV,temp);
@ -755,6 +766,7 @@ begin
raise EDCP_blockcipher.Create('Cipher not initialized'); raise EDCP_blockcipher.Create('Cipher not initialized');
p1:= @Indata; p1:= @Indata;
p2:= @Outdata; p2:= @Outdata;
dcpFillChar(Temp, SizeOf(Temp), 0);
for i:= 1 to (Size div 16) do for i:= 1 to (Size div 16) do
begin begin
EncryptECB(CV,temp); EncryptECB(CV,temp);

View File

@ -247,9 +247,14 @@ type
{ Helper functions } { Helper functions }
procedure XorBlock(var InData1, InData2; Size: longword); procedure XorBlock(var InData1, InData2; Size: longword);
// removes the compiler hint due to first param being 'var' instead of 'out'
procedure dcpFillChar(out x; count: SizeInt; Value: Byte); overload;
procedure dcpFillChar(out x; count: SizeInt; Value: Char); overload;
implementation implementation
{$Q-}{$R-} {$Q-}{$R-}
@ -319,6 +324,7 @@ var
Buffer: array[0..8191] of byte; Buffer: array[0..8191] of byte;
i, read: integer; i, read: integer;
begin begin
dcpFillChar(Buffer, SizeOf(Buffer), 0);
for i:= 1 to (Size div Sizeof(Buffer)) do for i:= 1 to (Size div Sizeof(Buffer)) do
begin begin
read:= Stream.Read(Buffer,Sizeof(Buffer)); read:= Stream.Read(Buffer,Sizeof(Buffer));
@ -414,9 +420,13 @@ begin
Hash.Final(Digest^); Hash.Final(Digest^);
Hash.Free; Hash.Free;
if MaxKeySize< HashType.GetHashSize then if MaxKeySize< HashType.GetHashSize then
Init(Digest^,MaxKeySize,nil) begin
Init(Digest^,MaxKeySize,nil);
end
else else
begin
Init(Digest^,HashType.GetHashSize,nil); Init(Digest^,HashType.GetHashSize,nil);
end;
FillChar(Digest^,HashType.GetHashSize div 8,$FF); FillChar(Digest^,HashType.GetHashSize div 8,$FF);
FreeMem(Digest); FreeMem(Digest);
except except
@ -446,6 +456,7 @@ var
Buffer: array[0..8191] of byte; Buffer: array[0..8191] of byte;
i, Read: longword; i, Read: longword;
begin begin
dcpFillChar(Buffer, SizeOf(Buffer), 0);
Result:= 0; Result:= 0;
for i:= 1 to (Size div Sizeof(Buffer)) do for i:= 1 to (Size div Sizeof(Buffer)) do
begin begin
@ -468,6 +479,7 @@ var
Buffer: array[0..8191] of byte; Buffer: array[0..8191] of byte;
i, Read: longword; i, Read: longword;
begin begin
dcpFillChar(Buffer, SizeOf(Buffer), 0);
Result:= 0; Result:= 0;
for i:= 1 to (Size div Sizeof(Buffer)) do for i:= 1 to (Size div Sizeof(Buffer)) do
begin begin
@ -639,5 +651,19 @@ begin
b1[i] := b1[i] xor b2[i]; b1[i] := b1[i] xor b2[i];
end; end;
procedure dcpFillChar(out x; count: SizeInt; Value: Byte);
begin
{$HINTS OFF}
FillChar(x, count, value);
{$HINTS ON}
end;
procedure dcpFillChar(out x; count: SizeInt; Value: Char);
begin
{$HINTS OFF}
FillChar(x, count, Value);
{$HINTS ON}
end;
end. end.