MHumm/DelphiEncryptionCompendium

no compile on Linux

Morrismx opened this issue · 18 comments

I tried to compile 3de on linux, and got

C:\.....\DelphiEncryptionCompendium\DECUtil.pas(627,24): error E2003: E2003 Undeclared identifier: 'GetTickCount64'
Captura de Pantalla 2022-11-22 a la(s) 12 29 23

FMX on windows works fine
with TCipher_3DES.Create do
try
Mode:=cmCBCx;
Init('5oquil2oo2vb63e8ionujny6','12345678');
Decoded := DecodeBinary ('y/3R651R/AnKxkdtFkUZpihKnpKe9Orx',TFormat_MIME64 );
Free;
end;

MHumm commented

I cannot find the code you are showing with the screenshot. My DECUtil only has 633 lines of code and I cannot find GetTickCount64 at all in the whole project group either (search via Strg-Shift-F). Are you sure you are on a current version? Can you tell me on which version you are?
Notice.txt and readme.md in the root directory should name the version as well as the documentation in the docs subfolder.

open DECUtil.pas an search for GetTickCount64

MHumm commented

Why do you use V5.3? The last official release is 6.4.1 and there changed quite a lot. 5.3 is no longer maintained, while 6.4.1 should be cross platform compatible! I used it in an Android app once and there are two of the FMX based demos available in Google Play: "DEC CIpher Demo" and "DEC Hash Demo". I would like to close this because it should work in 6.4.1.

MHumm commented

Yes. The releases are in the right hand side panel. Or the direct link to them is here:
https://github.com/MHumm/DelphiEncryptionCompendium/releases

In contrast to DEC 5.3 the 6.4.1 release does contain quite a bit of documentation found in the docs subfolder. Please read it, as it will describe the changes made between the releases as well. I tried to keep the interface as close to the old one as possible.

MHumm commented

If you don't mind I'll close this issue now.

MHumm commented

You have not yet specified the expected result. How shall anybody trying to help you know, whether his code is correct?

MHumm commented

Please specify clearly the following things:

  1. The code you show above, is this developed with DEC 5.3 or 6.4.1?
  2. Which text is your encrypted text? 'XDhuT8YknqI=' And this is Mime64 or Base64?
  3. When was the mime applied? Before calling the encryption method or after encryption?
  4. What exactly is the correct result? As string? Or as Hex?
MHumm commented

The key you specify has 24 chars/bytes. But DES is only a 56/64 bit encryption algorithm so the init method complains about the key being too long. The code which created the encrypted data, was this done with DEC as well?

MHumm commented

Try this one, it has only one flaw left: the output string is too long, but it starts with your expected data.
I won't do more on this tonight.

program DESTest;

{$APPTYPE CONSOLE}

{$R *.res}

uses
System.SysUtils,
DECCipherBase in '..\Source\DECCipherBase.pas',
DECCipherModes in '..\Source\DECCipherModes.pas',
DECCiphers in '..\Source\DECCiphers.pas',
DECFormat in '..\Source\DECFormat.pas';

var
DES: TCipher_3DES;
DecodeStr : RawByteString;
ByteArr : TBytes;
begin
DES := TCipher_3DES.Create;

try
try
DES.Mode := TCipherMode.cmCBCx;
DES.Init(RawByteString('5oquil2oo2vb63e8ionujny6'), RawByteString('12345678'));

  DecodeStr := TFormat_Base64.Decode(RawByteString('XDhuT8YknqI='));
  SetLength(ByteArr, length(DecodeStr));
  Move(DecodeStr[low(DecodeStr)], ByteArr[0], length(DecodeStr));

  ByteArr := DES.DecodeBytes(ByteArr);

  SetLength(DecodeStr, length(ByteArr));
  Move(ByteArr[0], DecodeStr[low(DecodeStr)], length(DecodeStr));

  WriteLn(DecodeStr);
except
  on E: Exception do
    Writeln(E.ClassName, ': ', E.Message);
end;

finally
DES.Free;
end;

ReadLn;
end.

MHumm commented

Closed as a working solution was provided to the user.

MHumm commented

Hello,

  1. Can you please create a new issue for this instead of "reviving" a closed one but for a different case?
  2. I'll try to find the time to look into this over the next few days, but I'm quite busy right now.
  3. I'm not sure 3DES is always 100% like that website describes, but it mostly should be.
  4. Can you cross check with some string shorter than DES block size (which is 8 byte) using ECB mode?
    So we can be sure that the implementation of DEC and the website basically do the same thing.
    Because if that works we'd need to look at CBC handling.