[fpc-pascal] How to solve "Conversion between ordinals and pointers is not portable"

Graeme Geldenhuys graeme at mastermaths.co.za
Tue Nov 17 11:15:09 CET 2009


dmitry boyarintsev wrote:
> Seems like {$mode delphi} is used.

Indeed it is. :)



> here's faster version of xorblock

[...not that I fully understand the DCPCrypt code...]

Looking at your code and the rest of DCPCrypt code, it seems it already
optimized the calls to xorblock(), instead of inside xorblock()....

Here is an example of a method using xorblock().

--------------------------------
procedure TDCP_blockcipher64.EncryptCBC(const Indata; var Outdata;
    Size: longword);
var
  i: longword;
  p1, p2: pointer;
begin
  if not fInitialized then
    raise EDCP_blockcipher.Create('Cipher not initialized');
  p1:= @Indata;
  p2:= @Outdata;
  for i:= 1 to (Size div 8) do
  begin
    Move(p1^,p2^,8);
    XorBlock(p2^,CV,8);
    EncryptECB(p2^,p2^);
    Move(p2^,CV,8);
    p1:= pointer(p1 + 8);
    p2:= pointer(p2 + 8);
  end;
  if (Size mod 8)<> 0 then
  begin
    EncryptECB(CV,CV);
    Move(p1^,p2^,Size mod 8);
    XorBlock(p2^,CV,Size mod 8);
  end;
end;
--------------------------------

Either way, to scratch my own itch, I am going to put together a small
example app calling the original xorblock() and your xorblockex()
recursively and do some timing around them to see the speed difference.


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/




More information about the fpc-pascal mailing list