#1 2025-01-18 09:43:08

anouri
Member
Registered: 2024-02-11
Posts: 74

Issue with encrypt functions without adding mormot.crypt.rsa to uses!

I found a problem and it took me a whole day. When using the encryption functions. The mormot.crypt.rsa unit must be used.
Otherwise, the output of some functions is nil and causes problems. For example:
CryptCipher := Decrypt('aes-256-gcm', Pointer(Lkey));

Seems, in the intialziation section of the mormot.crypt.rsa unit, some classes are created and initialized.

Last edited by anouri (2025-01-18 09:44:09)

Offline

#2 2025-01-18 17:47:26

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,838
Website

Re: Issue with encrypt functions without adding mormot.crypt.rsa to uses!

I can not reproduce it here with the 'aes-256-gcm' algorithm.

Please try to debug a little bit more and report here the exact problem.

Offline

#3 2025-01-19 08:52:49

anouri
Member
Registered: 2024-02-11
Posts: 74

Re: Issue with encrypt functions without adding mormot.crypt.rsa to uses!

I have identified the location of the error in the source below.

https://gist.github.com/a-nouri/cb11785 … c11425d05c

And I call it :

procedure TForm1.Button1Click(Sender: TObject);
var
  MyCryptAndHash: TMyCryptAndHash;
  Enc: string;
begin
  MyCryptAndHash := TMyCryptAndHash.Create;
  Enc := MyCryptAndHash.AESEncrypt('111', '01234567890123456789012345678912');
  MyCryptAndHash.Free;
end;

After adding mormot.crypt.rsa to the uses section, the problem is solved.

In mormot.crypt.secure function Cipher return nil. Function can't resolve algoname because it is not initilized

Last edited by anouri (2025-01-19 08:58:07)

Offline

#4 2025-01-23 09:09:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,838
Website

Re: Issue with encrypt functions without adding mormot.crypt.rsa to uses!

You are right: the initialization was sometimes missed.

Please try with
https://github.com/synopse/mORMot2/commit/f47a902e3

Offline

#5 2025-01-24 19:11:57

anouri
Member
Registered: 2024-02-11
Posts: 74

Re: Issue with encrypt functions without adding mormot.crypt.rsa to uses!

Solved. Thank you.

Offline

Board footer

Powered by FluxBB