From a6a0258b48cf5603bc68226d895627b0aa38c944 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 17 Nov 2009 17:07:00 +0200 Subject: [PATCH] Rather large fix to correctly support 64-bit platforms. * My previous attempt was not thorough enough and I missed a lot of details. * More testing was done and now it seems to work correctly on 32-bit and 64-bit Linux. --- Ciphers/dcpblowfish.pas | 11 +++---- Ciphers/dcpcast128.pas | 8 ++--- Ciphers/dcpcast256.pas | 24 +++++++-------- Ciphers/dcpdes.pas | 8 ++--- Ciphers/dcpgost.pas | 8 ++--- Ciphers/dcpice.pas | 8 ++--- Ciphers/dcpidea.pas | 8 ++--- Ciphers/dcpmars.pas | 24 +++++++-------- Ciphers/dcpmisty1.pas | 8 ++--- Ciphers/dcprc2.pas | 8 ++--- Ciphers/dcprc4.pas | 16 +++++----- Ciphers/dcprc5.pas | 8 ++--- Ciphers/dcprc6.pas | 24 +++++++-------- Ciphers/dcprijndael.pas | 24 +++++++-------- Ciphers/dcpserpent.pas | 28 ++++++++--------- Ciphers/dcptea.pas | 20 +++++++----- Ciphers/dcptwofish.pas | 28 ++++++++--------- Hashes/dcptiger.pas | 4 +-- dcpblockciphers.pas | 68 ++++++++++++++++++++--------------------- dcpcrypt2.pas | 14 ++++++--- 20 files changed, 178 insertions(+), 171 deletions(-) diff --git a/Ciphers/dcpblowfish.pas b/Ciphers/dcpblowfish.pas index c123a1c..748a0f0 100644 --- a/Ciphers/dcpblowfish.pas +++ b/Ciphers/dcpblowfish.pas @@ -47,9 +47,8 @@ type end; -{******************************************************************************} -{******************************************************************************} implementation + {$R-}{$Q-} {$I DCPblowfish.inc} @@ -151,7 +150,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); xL:= Pdword(@InData)^; - xR:= Pdword(longword(@InData)+4)^; + xR:= Pdword(pointer(@InData)+4)^; xL:= ((xL and $FF) shl 24) or ((xL and $FF00) shl 8) or ((xL and $FF0000) shr 8) or ((xL and $FF000000) shr 24); xR:= ((xR and $FF) shl 24) or ((xR and $FF00) shl 8) or ((xR and $FF0000) shr 8) or ((xR and $FF000000) shr 24); xL:= xL xor PBox[0]; @@ -191,7 +190,7 @@ begin xL:= ((xL and $FF) shl 24) or ((xL and $FF00) shl 8) or ((xL and $FF0000) shr 8) or ((xL and $FF000000) shr 24); xR:= ((xR and $FF) shl 24) or ((xR and $FF00) shl 8) or ((xR and $FF0000) shr 8) or ((xR and $FF000000) shr 24); Pdword(@OutData)^:= xR; - Pdword(longword(@OutData)+4)^:= xL; + Pdword(pointer(@OutData)+4)^:= xL; end; procedure TDCP_blowfish.DecryptECB(const InData; var OutData); @@ -201,7 +200,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); xL:= Pdword(@InData)^; - xR:= Pdword(longword(@InData)+4)^; + xR:= Pdword(pointer(@InData)+4)^; xL:= (xL shr 24) or ((xL shr 8) and $FF00) or ((xL shl 8) and $FF0000) or (xL shl 24); xR:= (xR shr 24) or ((xR shr 8) and $FF00) or ((xR shl 8) and $FF0000) or (xR shl 24); xL:= xL xor PBox[17]; @@ -241,7 +240,7 @@ begin xL:= (xL shr 24) or ((xL shr 8) and $FF00) or ((xL shl 8) and $FF0000) or (xL shl 24); xR:= (xR shr 24) or ((xR shr 8) and $FF00) or ((xR shl 8) and $FF0000) or (xR shl 24); Pdword(@OutData)^:= xR; - Pdword(longword(@OutData)+4)^:= xL; + Pdword(pointer(@OutData)+4)^:= xL; end; end. diff --git a/Ciphers/dcpcast128.pas b/Ciphers/dcpcast128.pas index ecfd50a..194dcac 100644 --- a/Ciphers/dcpcast128.pas +++ b/Ciphers/dcpcast128.pas @@ -250,7 +250,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); l:= Pdword(@InData)^; - r:= Pdword(longword(@InData)+4)^; + r:= Pdword(Pointer(@InData)+4)^; l:= (l shr 24) or ((l shr 8) and $FF00) or ((l shl 8) and $FF0000) or (l shl 24); r:= (r shr 24) or ((r shr 8) and $FF00) or ((r shl 8) and $FF0000) or (r shl 24); t:= LRot32(KeyData[0]+r, KeyData[0+16]); @@ -307,7 +307,7 @@ begin l:= (l shr 24) or ((l shr 8) and $FF00) or ((l shl 8) and $FF0000) or (l shl 24); r:= (r shr 24) or ((r shr 8) and $FF00) or ((r shl 8) and $FF0000) or (r shl 24); Pdword(@OutData)^:= r; - Pdword(longword(@OutData)+4)^:= l; + Pdword(pointer(@OutData)+4)^:= l; end; procedure TDCP_cast128.DecryptECB(const InData; var OutData); @@ -317,7 +317,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); r:= Pdword(@InData)^; - l:= Pdword(longword(@InData)+4)^; + l:= Pdword(pointer(@InData)+4)^; l:= (l shr 24) or ((l shr 8) and $FF00) or ((l shl 8) and $FF0000) or (l shl 24); r:= (r shr 24) or ((r shr 8) and $FF00) or ((r shl 8) and $FF0000) or (r shl 24); if Rounds> 12 then @@ -374,7 +374,7 @@ begin l:= (l shr 24) or ((l shr 8) and $FF00) or ((l shl 8) and $FF0000) or (l shl 24); r:= (r shr 24) or ((r shr 8) and $FF00) or ((r shl 8) and $FF0000) or (r shl 24); Pdword(@OutData)^:= l; - Pdword(longword(@OutData)+4)^:= r; + Pdword(pointer(@OutData)+4)^:= r; end; diff --git a/Ciphers/dcpcast256.pas b/Ciphers/dcpcast256.pas index 2c5ecb8..7ddbcdf 100644 --- a/Ciphers/dcpcast256.pas +++ b/Ciphers/dcpcast256.pas @@ -221,9 +221,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); A[0]:= PDWord(@InData)^; - A[1]:= PDWord(longword(@InData)+4)^; - A[2]:= PDWord(longword(@InData)+8)^; - A[3]:= PDWord(longword(@InData)+12)^; + A[1]:= PDWord(pointer(@InData)+4)^; + A[2]:= PDWord(pointer(@InData)+8)^; + A[3]:= PDWord(pointer(@InData)+12)^; A[0]:= SwapDWord(A[0]); A[1]:= SwapDWord(A[1]); @@ -284,9 +284,9 @@ begin A[3]:= SwapDWord(A[3]); PDWord(@OutData)^:= A[0]; - PDWord(longword(@OutData)+4)^:= A[1]; - PDWord(longword(@OutData)+8)^:= A[2]; - PDWord(longword(@OutData)+12)^:= A[3]; + PDWord(pointer(@OutData)+4)^:= A[1]; + PDWord(pointer(@OutData)+8)^:= A[2]; + PDWord(pointer(@OutData)+12)^:= A[3]; end; procedure TDCP_cast256.DecryptECB(const InData; var OutData); @@ -296,9 +296,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); A[0]:= PDWord(@InData)^; - A[1]:= PDWord(longword(@InData)+4)^; - A[2]:= PDWord(longword(@InData)+8)^; - A[3]:= PDWord(longword(@InData)+12)^; + A[1]:= PDWord(pointer(@InData)+4)^; + A[2]:= PDWord(pointer(@InData)+8)^; + A[3]:= PDWord(pointer(@InData)+12)^; A[0]:= SwapDWord(A[0]); A[1]:= SwapDWord(A[1]); @@ -359,9 +359,9 @@ begin A[3]:= SwapDWord(A[3]); PDWord(@OutData)^:= A[0]; - PDWord(longword(@OutData)+4)^:= A[1]; - PDWord(longword(@OutData)+8)^:= A[2]; - PDWord(longword(@OutData)+12)^:= A[3]; + PDWord(pointer(@OutData)+4)^:= A[1]; + PDWord(pointer(@OutData)+8)^:= A[2]; + PDWord(pointer(@OutData)+12)^:= A[3]; end; diff --git a/Ciphers/dcpdes.pas b/Ciphers/dcpdes.pas index 9a56f0c..2365bc7 100644 --- a/Ciphers/dcpdes.pas +++ b/Ciphers/dcpdes.pas @@ -146,7 +146,7 @@ var i: longint; begin r:= PDword(@InData)^; - l:= PDword(dword(@InData)+4)^; + l:= PDword(pointer(@InData)+4)^; t:= ((l shr 4) xor r) and $0f0f0f0f; r:= r xor t; l:= l xor (t shl 4); @@ -231,7 +231,7 @@ begin l:= l xor t; r:= r xor (t shl 4); PDword(@OutData)^:= l; - PDword(dword(@OutData)+4)^:= r; + PDword(pointer(@OutData)+4)^:= r; end; procedure TDCP_customdes.DecryptBlock(const InData; var OutData; KeyData: PDWordArray); @@ -240,7 +240,7 @@ var i: longint; begin r:= PDword(@InData)^; - l:= PDword(dword(@InData)+4)^; + l:= PDword(pointer(@InData)+4)^; t:= ((l shr 4) xor r) and $0f0f0f0f; r:= r xor t; l:= l xor (t shl 4); @@ -325,7 +325,7 @@ begin l:= l xor t; r:= r xor (t shl 4); PDword(@OutData)^:= l; - PDword(dword(@OutData)+4)^:= r; + PDword(pointer(@OutData)+4)^:= r; end; class function TDCP_des.GetMaxKeySize: integer; diff --git a/Ciphers/dcpgost.pas b/Ciphers/dcpgost.pas index 0ac969a..7f5f887 100644 --- a/Ciphers/dcpgost.pas +++ b/Ciphers/dcpgost.pas @@ -140,7 +140,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); n1:= PDword(@InData)^; - n2:= PDword(dword(@InData)+4)^; + n2:= PDword(pointer(@InData)+4)^; for i:= 0 to 2 do begin n2:= n2 xor (sTable[3,(n1+KeyData[0]) shr 24] xor sTable[2,((n1+KeyData[0]) shr 16) and $FF] @@ -177,7 +177,7 @@ begin n1:= n1 xor (sTable[3,(n2+KeyData[0]) shr 24] xor sTable[2,((n2+KeyData[0]) shr 16) and $FF] xor sTable[1,((n2+KeyData[0]) shr 8) and $FF] xor sTable[0,(n2+KeyData[0]) and $FF]); PDword(@OutData)^:= n2; - PDword(dword(@OutData)+4)^:= n1; + PDword(pointer(@OutData)+4)^:= n1; end; procedure TDCP_gost.DecryptECB(const InData; var OutData); @@ -188,7 +188,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); n1:= PDword(@InData)^; - n2:= PDword(dword(@InData)+4)^; + n2:= PDword(pointer(@InData)+4)^; n2:= n2 xor (sTable[3,(n1+KeyData[0]) shr 24] xor sTable[2,((n1+KeyData[0]) shr 16) and $FF] xor sTable[1,((n1+KeyData[0]) shr 8) and $FF] xor sTable[0,(n1+KeyData[0]) and $FF]); n1:= n1 xor (sTable[3,(n2+KeyData[1]) shr 24] xor sTable[2,((n2+KeyData[1]) shr 16) and $FF] @@ -225,7 +225,7 @@ begin xor sTable[1,((n2+KeyData[0]) shr 8) and $FF] xor sTable[0,(n2+KeyData[0]) and $FF]); end; PDword(@OutData)^:= n2; - PDword(dword(@OutData)+4)^:= n1; + PDword(pointer(@OutData)+4)^:= n1; end; diff --git a/Ciphers/dcpice.pas b/Ciphers/dcpice.pas index 16ddcca..b8b0798 100644 --- a/Ciphers/dcpice.pas +++ b/Ciphers/dcpice.pas @@ -272,7 +272,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); l:= SwapDWord(Pdword(@InData)^); - r:= SwapDWord(Pdword(longword(@InData)+4)^); + r:= SwapDWord(Pdword(pointer(@InData)+4)^); i:= 0; while i< rounds do begin @@ -281,7 +281,7 @@ begin Inc(i,2); end; Pdword(@OutData)^:= SwapDWord(r); - Pdword(longword(@OutData)+4)^:= SwapDWord(l); + Pdword(pointer(@OutData)+4)^:= SwapDWord(l); end; procedure TDCP_customice.DecryptECB(const InData; var OutData); @@ -292,7 +292,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); l:= SwapDWord(Pdword(@InData)^); - r:= SwapDWord(Pdword(longword(@InData)+4)^); + r:= SwapDWord(Pdword(pointer(@InData)+4)^); i:= rounds-1; while i> 0 do begin @@ -301,7 +301,7 @@ begin Dec(i,2); end; Pdword(@OutData)^:= SwapDWord(r); - Pdword(longword(@OutData)+4)^:= SwapDWord(l); + Pdword(pointer(@OutData)+4)^:= SwapDWord(l); end; constructor TDCP_customice.Create(AOwner: TComponent); diff --git a/Ciphers/dcpidea.pas b/Ciphers/dcpidea.pas index af356e5..f479f37 100644 --- a/Ciphers/dcpidea.pas +++ b/Ciphers/dcpidea.pas @@ -214,7 +214,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); PDword(@X[1])^:= PDword(@InData)^; - PDword(@X[3])^:= PDword(dword(@InData)+4)^; + PDword(@X[3])^:= PDword(pointer(@InData)+4)^; for i:= 1 to 4 do x[i]:= (x[i] shl 8) or (x[i] shr 8); for i:= 0 to 7 do @@ -246,7 +246,7 @@ begin x[4]:= (x[4] shl 8) or (x[4] shr 8); x[2]:= s2; PDword(@OutData)^:= PDword(@x[1])^; - PDword(dword(@OutData)+4)^:= PDword(@x[3])^; + PDword(pointer(@OutData)+4)^:= PDword(@x[3])^; end; procedure TDCP_idea.DecryptECB(const InData; var OutData); @@ -258,7 +258,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); PDword(@X[1])^:= PDword(@InData)^; - PDword(@X[3])^:= PDword(dword(@InData)+4)^; + PDword(@X[3])^:= PDword(pointer(@InData)+4)^; for i:= 1 to 4 do x[i]:= (x[i] shl 8) or (x[i] shr 8); for i:= 0 to 7 do @@ -290,7 +290,7 @@ begin x[4]:= (x[4] shl 8) or (x[4] shr 8); x[2]:= s2; PDword(@OutData)^:= PDword(@x[1])^; - PDword(dword(@OutData)+4)^:= PDword(@x[3])^; + PDword(pointer(@OutData)+4)^:= PDword(@x[3])^; end; diff --git a/Ciphers/dcpmars.pas b/Ciphers/dcpmars.pas index 3af078c..817a2d5 100644 --- a/Ciphers/dcpmars.pas +++ b/Ciphers/dcpmars.pas @@ -188,9 +188,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); Blk[0]:= PDWord(@InData)^; - Blk[1]:= PDWord(longword(@InData)+4)^; - Blk[2]:= PDWord(longword(@InData)+8)^; - Blk[3]:= PDWord(longword(@InData)+12)^; + Blk[1]:= PDWord(pointer(@InData)+4)^; + Blk[2]:= PDWord(pointer(@InData)+8)^; + Blk[3]:= PDWord(pointer(@InData)+12)^; blk[0]:= blk[0] + KeyData[0]; blk[1]:= blk[1] + KeyData[1]; blk[2]:= blk[2] + KeyData[2]; blk[3]:= blk[3] + KeyData[3]; @@ -438,9 +438,9 @@ begin blk[2]:= blk[2] - KeyData[38]; blk[3]:= blk[3] - KeyData[39]; PDWord(@OutData)^:= Blk[0]; - PDWord(longword(@OutData)+4)^:= Blk[1]; - PDWord(longword(@OutData)+8)^:= Blk[2]; - PDWord(longword(@OutData)+12)^:= Blk[3]; + PDWord(pointer(@OutData)+4)^:= Blk[1]; + PDWord(pointer(@OutData)+8)^:= Blk[2]; + PDWord(pointer(@OutData)+12)^:= Blk[3]; end; procedure TDCP_mars.DecryptECB(const InData; var OutData); @@ -451,9 +451,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); Blk[0]:= PDWord(@InData)^; - Blk[1]:= PDWord(longword(@InData)+4)^; - Blk[2]:= PDWord(longword(@InData)+8)^; - Blk[3]:= PDWord(longword(@InData)+12)^; + Blk[1]:= PDWord(pointer(@InData)+4)^; + Blk[2]:= PDWord(pointer(@InData)+8)^; + Blk[3]:= PDWord(pointer(@InData)+12)^; blk[0]:= blk[0] + KeyData[36]; blk[1]:= blk[1] + KeyData[37]; blk[2]:= blk[2] + KeyData[38]; blk[3]:= blk[3] + KeyData[39]; @@ -701,9 +701,9 @@ begin blk[2]:= blk[2] - KeyData[2]; blk[3]:= blk[3] - KeyData[3]; PDWord(@OutData)^:= Blk[0]; - PDWord(longword(@OutData)+4)^:= Blk[1]; - PDWord(longword(@OutData)+8)^:= Blk[2]; - PDWord(longword(@OutData)+12)^:= Blk[3]; + PDWord(pointer(@OutData)+4)^:= Blk[1]; + PDWord(pointer(@OutData)+8)^:= Blk[2]; + PDWord(pointer(@OutData)+12)^:= Blk[3]; end; end. diff --git a/Ciphers/dcpmisty1.pas b/Ciphers/dcpmisty1.pas index 4f18376..427f16e 100644 --- a/Ciphers/dcpmisty1.pas +++ b/Ciphers/dcpmisty1.pas @@ -214,7 +214,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); d0:= SwapDWord(PDWord(@InData)^); - d1:= SwapDWord(PDWord(longword(@InData)+4)^); + d1:= SwapDWord(PDWord(pointer(@InData)+4)^); for i:= 0 to NUMROUNDS-1 do begin if (i mod 2)= 0 then @@ -229,7 +229,7 @@ begin d0:= FL(d0,NUMROUNDS); d1:= FL(d1,NUMROUNDS+1); PDWord(@OutData)^:= SwapDWord(d1); - PDWord(longword(@OutData)+4)^:= SwapDWord(d0); + PDWord(pointer(@OutData)+4)^:= SwapDWord(d0); end; procedure TDCP_misty1.DecryptECB(const InData; var OutData); @@ -240,7 +240,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); d1:= SwapDWord(PDWord(@InData)^); - d0:= SwapDWord(PDWord(longword(@InData)+4)^); + d0:= SwapDWord(PDWord(pointer(@InData)+4)^); d1:= FLINV(d1,NUMROUNDS+1); d0:= FLINV(d0,NUMROUNDS); for i:= NUMROUNDS-1 downto 0 do @@ -255,7 +255,7 @@ begin d0:= d0 xor FO(d1,i); end; PDWord(@OutData)^:= SwapDWord(d0); - PDWord(longword(@OutData)+4)^:= SwapDWord(d1); + PDWord(pointer(@OutData)+4)^:= SwapDWord(d1); end; end. diff --git a/Ciphers/dcprc2.pas b/Ciphers/dcprc2.pas index e7697b1..bfbe49a 100644 --- a/Ciphers/dcprc2.pas +++ b/Ciphers/dcprc2.pas @@ -138,7 +138,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); Pdword(@w[0])^:= Pdword(@InData)^; - Pdword(@w[2])^:= Pdword(longword(@InData)+4)^; + Pdword(@w[2])^:= Pdword(pointer(@InData)+4)^; for i:= 0 to 15 do begin j:= i*4; @@ -155,7 +155,7 @@ begin end; end; Pdword(@OutData)^:= Pdword(@w[0])^; - Pdword(longword(@OutData)+4)^:= Pdword(@w[2])^; + Pdword(pointer(@OutData)+4)^:= Pdword(@w[2])^; end; procedure TDCP_rc2.DecryptECB(const InData; var OutData); @@ -166,7 +166,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); Pdword(@w[0])^:= Pdword(@InData)^; - Pdword(@w[2])^:= Pdword(longword(@InData)+4)^; + Pdword(@w[2])^:= Pdword(pointer(@InData)+4)^; for i:= 15 downto 0 do begin j:= i*4; @@ -183,7 +183,7 @@ begin end; end; Pdword(@OutData)^:= Pdword(@w[0])^; - Pdword(longword(@OutData)+4)^:= Pdword(@w[2])^; + Pdword(pointer(@OutData)+4)^:= Pdword(@w[2])^; end; end. diff --git a/Ciphers/dcprc4.pas b/Ciphers/dcprc4.pas index b7928ce..3594635 100644 --- a/Ciphers/dcprc4.pas +++ b/Ciphers/dcprc4.pas @@ -99,21 +99,21 @@ begin while i< 255 do begin KeyData[i]:= i; - xKey[i]:= PByte(longword(@Key)+(i mod Size))^; + xKey[i]:= PByte(pointer(@Key)+(i mod Size))^; KeyData[i+1]:= i+1; - xKey[i+1]:= PByte(longword(@Key)+((i+1) mod Size))^; + xKey[i+1]:= PByte(pointer(@Key)+((i+1) mod Size))^; KeyData[i+2]:= i+2; - xKey[i+2]:= PByte(longword(@Key)+((i+2) mod Size))^; + xKey[i+2]:= PByte(pointer(@Key)+((i+2) mod Size))^; KeyData[i+3]:= i+3; - xKey[i+3]:= PByte(longword(@Key)+((i+3) mod Size))^; + xKey[i+3]:= PByte(pointer(@Key)+((i+3) mod Size))^; KeyData[i+4]:= i+4; - xKey[i+4]:= PByte(longword(@Key)+((i+4) mod Size))^; + xKey[i+4]:= PByte(pointer(@Key)+((i+4) mod Size))^; KeyData[i+5]:= i+5; - xKey[i+5]:= PByte(longword(@Key)+((i+5) mod Size))^; + xKey[i+5]:= PByte(pointer(@Key)+((i+5) mod Size))^; KeyData[i+6]:= i+6; - xKey[i+6]:= PByte(longword(@Key)+((i+6) mod Size))^; + xKey[i+6]:= PByte(pointer(@Key)+((i+6) mod Size))^; KeyData[i+7]:= i+7; - xKey[i+7]:= PByte(longword(@Key)+((i+7) mod Size))^; + xKey[i+7]:= PByte(pointer(@Key)+((i+7) mod Size))^; Inc(i,8); end; j:= 0; diff --git a/Ciphers/dcprc5.pas b/Ciphers/dcprc5.pas index 2ad83a9..9327d00 100644 --- a/Ciphers/dcprc5.pas +++ b/Ciphers/dcprc5.pas @@ -167,7 +167,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); A:= PDword(@InData)^ + KeyData[0]; - B:= PDword(longword(@InData)+4)^ + KeyData[1]; + B:= PDword(pointer(@InData)+4)^ + KeyData[1]; for i:= 1 to NUMROUNDS do begin A:= A xor B; @@ -176,7 +176,7 @@ begin B:= LRot32(B,A)+KeyData[(2*i)+1]; end; PDword(@OutData)^:= A; - PDword(longword(@OutData)+4)^:= B; + PDword(pointer(@OutData)+4)^:= B; end; procedure TDCP_rc5.DecryptECB(const InData; var OutData); @@ -187,7 +187,7 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); A:= PDword(@InData)^; - B:= PDword(longword(@InData)+4)^; + B:= PDword(pointer(@InData)+4)^; for i:= NUMROUNDS downto 1 do begin B:= RRot32(B-KeyData[(2*i)+1],A); @@ -196,7 +196,7 @@ begin A:= A xor B; end; PDword(@OutData)^:= A - KeyData[0]; - PDword(longword(@OutData)+4)^:= B - KeyData[1]; + PDword(pointer(@OutData)+4)^:= B - KeyData[1]; end; end. diff --git a/Ciphers/dcprc6.pas b/Ciphers/dcprc6.pas index 9c8cef0..7745167 100644 --- a/Ciphers/dcprc6.pas +++ b/Ciphers/dcprc6.pas @@ -173,9 +173,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); x0:= PDword(@InData)^; - x1:= PDword(longword(@InData)+4)^; - x2:= PDword(longword(@InData)+8)^; - x3:= PDword(longword(@InData)+12)^; + x1:= PDword(pointer(@InData)+4)^; + x2:= PDword(pointer(@InData)+8)^; + x3:= PDword(pointer(@InData)+12)^; x1:= x1 + KeyData[0]; x3:= x3 + KeyData[1]; for i:= 1 to NUMROUNDS do @@ -189,9 +189,9 @@ begin x0:= x0 + KeyData[(2*NUMROUNDS)+2]; x2:= x2 + KeyData[(2*NUMROUNDS)+3]; PDword(@OutData)^:= x0; - PDword(longword(@OutData)+4)^:= x1; - PDword(longword(@OutData)+8)^:= x2; - PDword(longword(@OutData)+12)^:= x3; + PDword(pointer(@OutData)+4)^:= x1; + PDword(pointer(@OutData)+8)^:= x2; + PDword(pointer(@OutData)+12)^:= x3; end; procedure TDCP_rc6.DecryptECB(const InData; var OutData); @@ -203,9 +203,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); x0:= PDword(@InData)^; - x1:= PDword(longword(@InData)+4)^; - x2:= PDword(longword(@InData)+8)^; - x3:= PDword(longword(@InData)+12)^; + x1:= PDword(pointer(@InData)+4)^; + x2:= PDword(pointer(@InData)+8)^; + x3:= PDword(pointer(@InData)+12)^; x2:= x2 - KeyData[(2*NUMROUNDS)+3]; x0:= x0 - KeyData[(2*NUMROUNDS)+2]; for i:= NUMROUNDS downto 1 do @@ -219,9 +219,9 @@ begin x3:= x3 - KeyData[1]; x1:= x1 - KeyData[0]; PDword(@OutData)^:= x0; - PDword(longword(@OutData)+4)^:= x1; - PDword(longword(@OutData)+8)^:= x2; - PDword(longword(@OutData)+12)^:= x3; + PDword(pointer(@OutData)+4)^:= x1; + PDword(pointer(@OutData)+8)^:= x2; + PDword(pointer(@OutData)+12)^:= x3; end; end. diff --git a/Ciphers/dcprijndael.pas b/Ciphers/dcprijndael.pas index bbc3e2b..2404457 100644 --- a/Ciphers/dcprijndael.pas +++ b/Ciphers/dcprijndael.pas @@ -236,9 +236,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); PDword(@a[0,0])^:= PDword(@InData)^; - PDword(@a[1,0])^:= PDword(dword(@InData)+4)^; - PDword(@a[2,0])^:= PDword(dword(@InData)+8)^; - PDword(@a[3,0])^:= PDword(dword(@InData)+12)^; + PDword(@a[1,0])^:= PDword(pointer(@InData)+4)^; + PDword(@a[2,0])^:= PDword(pointer(@InData)+8)^; + PDword(@a[3,0])^:= PDword(pointer(@InData)+12)^; for r:= 0 to (numrounds-2) do begin PDWord(@tempb[0])^:= PDWord(@a[0])^ xor rk[r,0]; @@ -288,9 +288,9 @@ begin PDWord(@a[3])^:= PDWord(@a[3])^ xor rk[numrounds,3]; PDword(@OutData)^:= PDword(@a[0,0])^; - PDword(dword(@OutData)+4)^:= PDword(@a[1,0])^; - PDword(dword(@OutData)+8)^:= PDword(@a[2,0])^; - PDword(dword(@OutData)+12)^:= PDword(@a[3,0])^; + PDword(pointer(@OutData)+4)^:= PDword(@a[1,0])^; + PDword(pointer(@OutData)+8)^:= PDword(@a[2,0])^; + PDword(pointer(@OutData)+12)^:= PDword(@a[3,0])^; end; procedure TDCP_rijndael.DecryptECB(const InData; var OutData); @@ -302,9 +302,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); PDword(@a[0,0])^:= PDword(@InData)^; - PDword(@a[1,0])^:= PDword(dword(@InData)+4)^; - PDword(@a[2,0])^:= PDword(dword(@InData)+8)^; - PDword(@a[3,0])^:= PDword(dword(@InData)+12)^; + PDword(@a[1,0])^:= PDword(pointer(@InData)+4)^; + PDword(@a[2,0])^:= PDword(pointer(@InData)+8)^; + PDword(@a[3,0])^:= PDword(pointer(@InData)+12)^; for r:= NumRounds downto 2 do begin PDWord(@tempb[0])^:= PDWord(@a[0])^ xor drk[r,0]; @@ -353,9 +353,9 @@ begin PDWord(@a[2])^:= PDWord(@a[2])^ xor drk[0,2]; PDWord(@a[3])^:= PDWord(@a[3])^ xor drk[0,3]; PDword(@OutData)^:= PDword(@a[0,0])^; - PDword(dword(@OutData)+4)^:= PDword(@a[1,0])^; - PDword(dword(@OutData)+8)^:= PDword(@a[2,0])^; - PDword(dword(@OutData)+12)^:= PDword(@a[3,0])^; + PDword(pointer(@OutData)+4)^:= PDword(@a[1,0])^; + PDword(pointer(@OutData)+8)^:= PDword(@a[2,0])^; + PDword(pointer(@OutData)+12)^:= PDword(@a[3,0])^; end; diff --git a/Ciphers/dcpserpent.pas b/Ciphers/dcpserpent.pas index 27a073f..1987d23 100644 --- a/Ciphers/dcpserpent.pas +++ b/Ciphers/dcpserpent.pas @@ -178,9 +178,9 @@ begin raise EDCP_blockcipher.Create('Cipher not initialized'); a:= PDWord(@InData)^; - b:= PDWord(longword(@InData)+4)^; - c:= PDWord(longword(@InData)+8)^; - d:= PDWord(longword(@InData)+12)^; + b:= PDWord(pointer(@InData)+4)^; + c:= PDWord(pointer(@InData)+8)^; + d:= PDWord(pointer(@InData)+12)^; i:= 0; while i < 32 do @@ -217,10 +217,10 @@ begin end; a:= a xor l_key[128]; b:= b xor l_key[128+1]; c:= c xor l_key[128+2]; d:= d xor l_key[128+3]; - PDWord(PtrUInt(@OutData)+ 0)^:= a; - PDWord(PtrUInt(@OutData)+ 4)^:= b; - PDWord(PtrUInt(@OutData)+ 8)^:= c; - PDWord(PtrUInt(@OutData)+12)^:= d; + PDWord(pointer(@OutData)+ 0)^:= a; + PDWord(pointer(@OutData)+ 4)^:= b; + PDWord(pointer(@OutData)+ 8)^:= c; + PDWord(pointer(@OutData)+12)^:= d; end; procedure TDCP_serpent.DecryptECB(const InData; var OutData); @@ -233,9 +233,9 @@ begin raise EDCP_blockcipher.Create('Cipher not initialized'); a:= PDWord(@InData)^; - b:= PDWord(longword(@InData)+4)^; - c:= PDWord(longword(@InData)+8)^; - d:= PDWord(longword(@InData)+12)^; + b:= PDWord(pointer(@InData)+4)^; + c:= PDWord(pointer(@InData)+8)^; + d:= PDWord(pointer(@InData)+12)^; i:= 32; a:= a xor l_key[4*32]; b:= b xor l_key[4*32+1]; c:= c xor l_key[4*32+2]; d:= d xor l_key[4*32+3]; @@ -272,10 +272,10 @@ begin Dec(i,8); end; - PDWord(PtrUInt(@OutData)+ 0)^:= a; - PDWord(PtrUInt(@OutData)+ 4)^:= b; - PDWord(PtrUInt(@OutData)+ 8)^:= c; - PDWord(PtrUInt(@OutData)+12)^:= d; + PDWord(pointer(@OutData)+ 0)^:= a; + PDWord(pointer(@OutData)+ 4)^:= b; + PDWord(pointer(@OutData)+ 8)^:= c; + PDWord(pointer(@OutData)+12)^:= d; end; end. diff --git a/Ciphers/dcptea.pas b/Ciphers/dcptea.pas index 4726127..4f5214b 100644 --- a/Ciphers/dcptea.pas +++ b/Ciphers/dcptea.pas @@ -22,8 +22,8 @@ {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *} {* DEALINGS IN THE SOFTWARE. *} {******************************************************************************} -unit DCPtea; - +unit DCPtea; + {$MODE Delphi} interface @@ -52,7 +52,7 @@ implementation {$R-}{$Q-} const - Delta= $9e3779b9; + Delta: DWord = $9e3779b9; Rounds= 32; function SwapDword(a: dword): dword; @@ -115,7 +115,7 @@ begin raise EDCP_blockcipher.Create('Cipher not initialized'); x:= SwapDWord(pdword(@InData)^); - y:= SwapDWord(pdword(longword(@InData)+4)^); + y:= SwapDWord(pdword(pointer(@InData)+4)^); sum:= 0; a:= KeyData[0]; b:= KeyData[1]; c:= KeyData[2]; d:= KeyData[3]; for n:= 1 to Rounds do begin @@ -124,7 +124,7 @@ begin Inc(y,(x shl 4) + (c xor x) + (sum xor (x shr 5)) + d); end; pdword(@OutData)^:= SwapDWord(x); - pdword(longword(@OutData)+4)^:= SwapDWord(y); + pdword(pointer(@OutData)+4)^:= SwapDWord(y); end; procedure TDCP_tea.DecryptECB(const InData; var OutData); @@ -135,8 +135,12 @@ begin raise EDCP_blockcipher.Create('Cipher not initialized'); x:= SwapDWord(pdword(@InData)^); - y:= SwapDWord(pdword(longword(@InData)+4)^); - sum:= Delta shl 5; a:= KeyData[0]; b:= KeyData[1]; c:= KeyData[2]; d:= KeyData[3]; + y:= SwapDWord(pdword(pointer(@InData)+4)^); + sum:= Delta shl 5; + a:= KeyData[0]; + b:= KeyData[1]; + c:= KeyData[2]; + d:= KeyData[3]; for n:= 1 to Rounds do begin Dec(y,(x shl 4) + (c xor x) + (sum xor (x shr 5)) + d); @@ -144,7 +148,7 @@ begin Dec(sum,Delta); end; pdword(@OutData)^:= SwapDWord(x); - pdword(longword(@OutData)+4)^:= SwapDWord(y); + pdword(pointer(@OutData)+4)^:= SwapDWord(y); end; end. diff --git a/Ciphers/dcptwofish.pas b/Ciphers/dcptwofish.pas index 9703fcc..702b23a 100644 --- a/Ciphers/dcptwofish.pas +++ b/Ciphers/dcptwofish.pas @@ -457,9 +457,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); x[0]:= PDWord(@InData)^ xor SubKeys[INPUTWHITEN]; - x[1]:= PDWord(longword(@InData)+4)^ xor SubKeys[INPUTWHITEN+1]; - x[2]:= PDWord(longword(@InData)+8)^ xor SubKeys[INPUTWHITEN+2]; - x[3]:= PDWord(longword(@InData)+12)^ xor SubKeys[INPUTWHITEN+3]; + x[1]:= PDWord(pointer(@InData)+4)^ xor SubKeys[INPUTWHITEN+1]; + x[2]:= PDWord(pointer(@InData)+8)^ xor SubKeys[INPUTWHITEN+2]; + x[3]:= PDWord(pointer(@InData)+12)^ xor SubKeys[INPUTWHITEN+3]; i:= 0; while i<= NUMROUNDS-2 do begin @@ -482,10 +482,10 @@ begin x[0]:= (x[0] shr 1) or (x[0] shl 31); Inc(i,2); end; - PDWord(PtrUInt(@OutData)+ 0)^:= x[2] xor SubKeys[OUTPUTWHITEN]; - PDWord(PtrUInt(@OutData)+ 4)^:= x[3] xor SubKeys[OUTPUTWHITEN+1]; - PDWord(PtrUInt(@OutData)+ 8)^:= x[0] xor SubKeys[OUTPUTWHITEN+2]; - PDWord(PtrUInt(@OutData)+12)^:= x[1] xor SubKeys[OUTPUTWHITEN+3]; + PDWord(pointer(@OutData)+ 0)^:= x[2] xor SubKeys[OUTPUTWHITEN]; + PDWord(pointer(@OutData)+ 4)^:= x[3] xor SubKeys[OUTPUTWHITEN+1]; + PDWord(pointer(@OutData)+ 8)^:= x[0] xor SubKeys[OUTPUTWHITEN+2]; + PDWord(pointer(@OutData)+12)^:= x[1] xor SubKeys[OUTPUTWHITEN+3]; end; procedure TDCP_twofish.DecryptECB(const InData; var OutData); @@ -497,9 +497,9 @@ begin if not fInitialized then raise EDCP_blockcipher.Create('Cipher not initialized'); X[2]:= PDWord(@InData)^ xor SubKeys[OUTPUTWHITEN]; - X[3]:= PDWord(longword(@InData)+4)^ xor SubKeys[OUTPUTWHITEN+1]; - X[0]:= PDWord(longword(@InData)+8)^ xor SubKeys[OUTPUTWHITEN+2]; - X[1]:= PDWord(longword(@InData)+12)^ xor SubKeys[OUTPUTWHITEN+3]; + X[3]:= PDWord(pointer(@InData)+4)^ xor SubKeys[OUTPUTWHITEN+1]; + X[0]:= PDWord(pointer(@InData)+8)^ xor SubKeys[OUTPUTWHITEN+2]; + X[1]:= PDWord(pointer(@InData)+12)^ xor SubKeys[OUTPUTWHITEN+3]; i:= NUMROUNDS-2; while i>= 0 do begin @@ -522,10 +522,10 @@ begin x[3]:= (x[3] shr 1) or (x[3] shl 31); Dec(i,2); end; - PDWord(PtrUInt(@OutData)+ 0)^:= X[0] xor SubKeys[INPUTWHITEN]; - PDWord(PtrUInt(@OutData)+ 4)^:= X[1] xor SubKeys[INPUTWHITEN+1]; - PDWord(PtrUInt(@OutData)+ 8)^:= X[2] xor SubKeys[INPUTWHITEN+2]; - PDWord(PtrUInt(@OutData)+12)^:= X[3] xor SubKeys[INPUTWHITEN+3]; + PDWord(pointer(@OutData)+ 0)^:= X[0] xor SubKeys[INPUTWHITEN]; + PDWord(pointer(@OutData)+ 4)^:= X[1] xor SubKeys[INPUTWHITEN+1]; + PDWord(pointer(@OutData)+ 8)^:= X[2] xor SubKeys[INPUTWHITEN+2]; + PDWord(pointer(@OutData)+12)^:= X[3] xor SubKeys[INPUTWHITEN+3]; end; procedure PreCompMDS; diff --git a/Hashes/dcptiger.pas b/Hashes/dcptiger.pas index a7c4989..8690209 100644 --- a/Hashes/dcptiger.pas +++ b/Hashes/dcptiger.pas @@ -22,8 +22,8 @@ {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *} {* DEALINGS IN THE SOFTWARE. *} {******************************************************************************} -unit DCPtiger; - +unit DCPtiger; + {$MODE Delphi} interface diff --git a/dcpblockciphers.pas b/dcpblockciphers.pas index 6872485..7407e68 100644 --- a/dcpblockciphers.pas +++ b/dcpblockciphers.pas @@ -22,8 +22,8 @@ {* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *} {* DEALINGS IN THE SOFTWARE. *} {******************************************************************************} -unit DCPblockciphers; - +unit DCPblockciphers; + {$MODE Delphi} interface @@ -205,8 +205,8 @@ begin XorBlock(p2^,CV,8); EncryptECB(p2^,p2^); Move(p2^,CV,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(p1 + 8); + p2:= pointer(p2 + 8); end; if (Size mod 8)<> 0 then begin @@ -233,8 +233,8 @@ begin DecryptECB(p2^,p2^); XorBlock(p2^,CV,8); Move(Temp,CV,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(p1 + 8); + p2:= pointer(p2 + 8); end; if (Size mod 8)<> 0 then begin @@ -303,8 +303,8 @@ begin Move(p1^,p2^,8); XorBlock(p2^,CV,8); Move(p2^,CV,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(pointer(p1) + 8); + p2:= pointer(pointer(p2) + 8); end; if (Size mod 8)<> 0 then begin @@ -331,8 +331,8 @@ begin Move(p1^,p2^,8); XorBlock(p2^,CV,8); Move(Temp,CV,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(pointer(p1) + 8); + p2:= pointer(pointer(p2) + 8); end; if (Size mod 8)<> 0 then begin @@ -356,8 +356,8 @@ begin EncryptECB(CV,CV); Move(p1^,p2^,8); XorBlock(p2^,CV,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(p1 + 8); + p2:= pointer(p2 + 8); end; if (Size mod 8)<> 0 then begin @@ -381,8 +381,8 @@ begin EncryptECB(CV,CV); Move(p1^,p2^,8); XorBlock(p2^,CV,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(p1 + 8); + p2:= pointer(p2 + 8); end; if (Size mod 8)<> 0 then begin @@ -408,8 +408,8 @@ begin IncCounter; Move(p1^,p2^,8); XorBlock(p2^,temp,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(p1 + 8); + p2:= pointer(p2 + 8); end; if (Size mod 8)<> 0 then begin @@ -436,8 +436,8 @@ begin IncCounter; Move(p1^,p2^,8); XorBlock(p2^,temp,8); - p1:= pointer(longword(p1) + 8); - p2:= pointer(longword(p2) + 8); + p1:= pointer(p1 + 8); + p2:= pointer(p2 + 8); end; if (Size mod 8)<> 0 then begin @@ -530,8 +530,8 @@ begin XorBlock(p2^,CV,16); EncryptECB(p2^,p2^); Move(p2^,CV,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(p1 + 16); + p2:= pointer(p2 + 16); end; if (Size mod 16)<> 0 then begin @@ -558,8 +558,8 @@ begin DecryptECB(p2^,p2^); XorBlock(p2^,CV,16); Move(Temp,CV,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(p1 + 16); + p2:= pointer(p2 + 16); end; if (Size mod 16)<> 0 then begin @@ -628,8 +628,8 @@ begin Move(p1^,p2^,16); XorBlock(p2^,CV,16); Move(p2^,CV,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(pointer(p1) + 16); + p2:= pointer(pointer(p2) + 16); end; if (Size mod 16)<> 0 then begin @@ -656,8 +656,8 @@ begin Move(p1^,p2^,16); XorBlock(p2^,CV,16); Move(Temp,CV,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(pointer(p1) + 16); + p2:= pointer(pointer(p2) + 16); end; if (Size mod 16)<> 0 then begin @@ -681,8 +681,8 @@ begin EncryptECB(CV,CV); Move(p1^,p2^,16); XorBlock(p2^,CV,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(p1 + 16); + p2:= pointer(p2 + 16); end; if (Size mod 16)<> 0 then begin @@ -706,8 +706,8 @@ begin EncryptECB(CV,CV); Move(p1^,p2^,16); XorBlock(p2^,CV,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(p1 + 16); + p2:= pointer(p2 + 16); end; if (Size mod 16)<> 0 then begin @@ -733,8 +733,8 @@ begin IncCounter; Move(p1^,p2^,16); XorBlock(p2^,temp,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(p1 + 16); + p2:= pointer(p2 + 16); end; if (Size mod 16)<> 0 then begin @@ -761,8 +761,8 @@ begin IncCounter; Move(p1^,p2^,16); XorBlock(p2^,temp,16); - p1:= pointer(longword(p1) + 16); - p2:= pointer(longword(p2) + 16); + p1:= pointer(p1 + 16); + p2:= pointer(p2 + 16); end; if (Size mod 16)<> 0 then begin diff --git a/dcpcrypt2.pas b/dcpcrypt2.pas index be465db..40b9066 100644 --- a/dcpcrypt2.pas +++ b/dcpcrypt2.pas @@ -28,7 +28,7 @@ unit DCPcrypt2; interface uses - Classes, Sysutils, DCPconst, DCPbase64; + Classes, Sysutils, DCPbase64; //{$DEFINE DCP1COMPAT} { DCPcrypt v1.31 compatiblity mode - see documentation } @@ -36,15 +36,15 @@ uses { A few predefined types to help out } type + {$IFNDEF FPC} Pbyte= ^byte; Pword= ^word; Pdword= ^dword; Pint64= ^int64; - {$IFNDEF FPC} dword= longword; - {$ENDIF} Pwordarray= ^Twordarray; Twordarray= array[0..19383] of word; + {$ENDIF} Pdwordarray= ^Tdwordarray; Tdwordarray= array[0..8191] of dword; @@ -629,10 +629,14 @@ end; {** Helpher functions *********************************************************} procedure XorBlock(var InData1, InData2; Size: longword); var + b1: PByteArray; + b2: PByteArray; i: longword; begin - for i:= 1 to Size do - Pbyte(longword(@InData1)+i-1)^:= Pbyte(longword(@InData1)+i-1)^ xor Pbyte(longword(@InData2)+i-1)^; + b1 := @InData1; + b2 := @InData2; + for i := 0 to size-1 do + b1[i] := b1[i] xor b2[i]; end; end.