Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Studio Installation and Setup.
  • Page:
  • 1

TOPIC:

dcpcrypt problem 11 years 7 months ago #2489

  • Pierre Joubert
  • Pierre Joubert's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
Thank you for CodeTyphon!

I have code that works in Lazarus for Windows. In 64bit Lazarus for Linux, I have a problem, please help.

Here is the error message:
Project raised exception class 'External: SIGSEGV'.
In file 'source/Ciphers/dcprijndael.pas' at line 239:
PDword(@a[1,0])^:= PDword(dword(@InData)+4)^;

Here is the source code (dcp: TDCP_rijndael):
function Encrypt(str: string): string;
begin
dcp.InitStr(String of 130 Characters, TDCP_sha256);
result := dcp.EncryptString(str);
end;

Thanks

Please Log in or Create an account to join the conversation.

dcpcrypt problem 11 years 7 months ago #2490

  • Rain
  • Rain's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 69
  • Thank you received: 8
I assume your Windows test was in Win32, not Win64 ?
Probably this code works in 64bit environments better:
(just forcing qword instead of dword, because in 64bit-OS a pointer (e.g. to InData) is a qword, so the pointer should not be truncated to 32bit (dword), which will definetly crash):

PDword(@a[0,0])^:= PDword(@InData)^;
PDword(@a[1,0])^:= PDword(qword(@InData)+4)^;
PDword(@a[2,0])^:= PDword(qword(@InData)+8)^;
PDword(@a[3,0])^:= PDword(qword(@InData)+12)^;

Please Log in or Create an account to join the conversation.

dcpcrypt problem 11 years 7 months ago #2492

  • Rain
  • Rain's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 69
  • Thank you received: 8
Those files contain either / or

... dword(@ ...
... longword(@ ...

and will therefore crash on 64bit compiled executables:

fpcsrc\rtl\go32v2\sysutils.pp
fpcsrc\rtl\morphos\muihelper.pas
fpcsrc\tests\test\tcmp.pp
fpcsrc\tests\test\tindex.pp
fpcsrc\tests\webtbs\tw2676.pp
lazarus\components\pl_ACS\source\win\win_acs_audio.inc
lazarus\components\pl_DCP\source\dcpcrypt2.pas
lazarus\components\pl_DCP\source\Ciphers\dcpblowfish.pas
lazarus\components\pl_DCP\source\Ciphers\dcpcast128.pas
lazarus\components\pl_DCP\source\Ciphers\dcpcast256.pas
lazarus\components\pl_DCP\source\Ciphers\dcpdes.pas
lazarus\components\pl_DCP\source\Ciphers\dcpgost.pas
lazarus\components\pl_DCP\source\Ciphers\dcpice.pas
lazarus\components\pl_DCP\source\Ciphers\dcpidea.pas
lazarus\components\pl_DCP\source\Ciphers\dcpmars.pas
lazarus\components\pl_DCP\source\Ciphers\dcpmisty1.pas
lazarus\components\pl_DCP\source\Ciphers\dcprc2.pas
lazarus\components\pl_DCP\source\Ciphers\dcprc4.pas
lazarus\components\pl_DCP\source\Ciphers\dcprc5.pas
lazarus\components\pl_DCP\source\Ciphers\dcprc6.pas
lazarus\components\pl_DCP\source\Ciphers\dcprijndael.pas
lazarus\components\pl_DCP\source\Ciphers\dcpserpent.pas
lazarus\components\pl_DCP\source\Ciphers\dcptea.pas
lazarus\components\pl_DCP\source\Ciphers\dcptwofish.pas
lazarus\components\pl_GLScene\source\VideoAPIs\GLSVfw.pas
lazarus\components\pl_KControls\source\kicon.pas


The solution is already in
c:\codetyphon\lazarus\components\pl_DCP\source\dcpcrypt2.pas :

//
For 64bit CodeTyphon Project
{$ifdef CPU32}
xlongword=longword;
{$endif}
{$ifdef CPU64}
xlongword=QWord;
{$endif}

But this defined xlongword is not consequently used afterwards everywhere where is would be indicated to be used.
;)

Please Log in or Create an account to join the conversation.

dcpcrypt problem 11 years 7 months ago #2493

  • Pierre Joubert
  • Pierre Joubert's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 13
  • Thank you received: 0
Thank you.

Yes, I am using 32bit windows (Windows XP).

I changed /usr/lib/codetyphon/lazarus/components/pl_DCP/source/dcpcrypt2.pas to:
// dword= longword;

Pwordarray= ^Twordarray;
Twordarray= array[0..19383] of word;
Pdwordarray= ^Tdwordarray;
Tdwordarray= array[0..8191] of dword;

//
For 64bit CodeTyphon Project
{$ifdef CPU32}
xlongword=longword;
{$endif}
{$ifdef CPU64}
xlongword=QWord;
{$endif}
//


//Pierre
dword= xlongword;

After rebuilding Lazarus I got the following error:
Project raised exception class 'External: SIGSEGV'.
In file 'source/Ciphers/dcprijndael.pas' at line 183:
tk[0,0]:= tk[0,0] xor rcon[rconpointer];

Replacing all occurences of longword in dcprijndael.pas with QWord did not work.

Please Log in or Create an account to join the conversation.

dcpcrypt problem 11 years 7 months ago #2494

  • Rain
  • Rain's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 69
  • Thank you received: 8
Please restore all files (including dcpcrypt2.pas) to the original CT version.
Only replace the existing
c:\codetyphon\lazarus\components\pl_DCP\source\Ciphers\dcprijndael.pas
with the attached one.

File Attachment:

File Name: dcprijndael.zip
File Size:3 KB


Do nothing else. ;)
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by Rain.

dcpcrypt problem 11 years 7 months ago #2495

  • Graeme Geldenhuys
  • Graeme Geldenhuys's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 1
No, no no....

DCPCrypt has already been fixed for 64-bit systems. You guys (and it seems CodeTyphon) are all using an outdated version of DCPCrypt. The latest version is v2.0.4.1 released back in 2010-03. This release added some vital 64-bit fixes that was overlooked in the v2.0.4 release.

Get the latest DCPCrypt code from...

git clone git://lazarus-ccr.git.sourceforge.net/gitroot/lazarus-ccr/dcpcrypt

The sample code posted in the beginning of this thread works 100% here on my 64-bit Linux system (and on 32-bit Linux/Windows systems).

Please Log in or Create an account to join the conversation.

Last edit: by Graeme Geldenhuys.

dcpcrypt problem 11 years 7 months ago #2496

  • Graeme Geldenhuys
  • Graeme Geldenhuys's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 16
  • Thank you received: 1
You are not using the latest DCPCrypt code! The latest is v2.0.4.1 and you can get it from...

git clone git://lazarus-ccr.git.sourceforge.net/gitroot/lazarus-ccr/dcpcrypt

That will fix your problem. You code runs fine here on my 64-bit system.
The following user(s) said Thank You: Konstantinos Papadoulas

Please Log in or Create an account to join the conversation.

dcpcrypt problem 11 years 7 months ago #2497

  • Rain
  • Rain's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 69
  • Thank you received: 8
Oh well, in this case, :) here is a http link I found, if git access is not possible for everyone:

sourceforge.net/projects/lazarus-ccr/fil...2.0.4.1.zip/download
The following user(s) said Thank You: Konstantinos Papadoulas

Please Log in or Create an account to join the conversation.

dcpcrypt problem 11 years 7 months ago #2498

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
Thanks Sir
We will update this package
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Page:
  • 1