#1 2021-04-19 13:51:40

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 416

mormot2: TAescbc gives different decrypted output for the same inputs

Hi,
I am trying to decrypt a rijndael encrypted piece of data that is encrypted with DCPcrypt2's encryptCBC function, using mormot2's TAescbc with the following code:

var dat,test,dIV:array of byte; i:cardinal
begin
e:=TAescbc.Create(mkey,128);
e.IV:=PHash128(@dIV[8])^;
i:=length(dat)
setlength(test,i);
e.Decrypt(dat,test,i);
e.Free;

What I notice is that even if I put the same data in mkey, dIV, dat, I am getting every time it runs different results in "test"
Am I missing something?
Thank you in advance

Last edited by dcoun (2021-04-19 14:12:09)

Offline

#2 2021-04-19 14:57:32

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

Re: mormot2: TAescbc gives different decrypted output for the same inputs

My guess is that you are confusing the mkey "var" parameter.
mkey should be a memory buffer - if you pass a string here you will hash the pointer to the string, not the string itself.
Try to use mkey[1] for a string.

Offline

#3 2021-04-19 15:08:19

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 416

Re: mormot2: TAescbc gives different decrypted output for the same inputs

I  apologize. Mkey is tbytes And it worked as it follows:
e:=TAescbc.Create(mkey[0],128);

Thank you a lot

Last edited by dcoun (2021-04-19 15:29:24)

Offline

Board footer

Powered by FluxBB