You are not logged in.
Pages: 1
Hello,
There is a Aes-ECB crypt information with sample input values and result. I want to have same result using mORMot, but I could not achieve that. Code I tried is below:
const
AKey: string = '783490FD6A6C90F07236A8ED402794F8732C96FB711FA0F46C349AC4792493E8';
var
Key: TSHA256Digest;
Aes: TAESECB;
Utf8String: RawByteString;
begin
Key := SHA256Digest(Pointer(@AKey), Length(AKey));
Aes := TAESECB.Create(Key, 256);
try
Utf8String := StringToUTF8('000102030405060708090A0B0C0D0E0F');
try
Utf8String := BinToBase64(Aes.EncryptPKCS7(Utf8String, False));
except
Exit();
end;
ShowMessage(string(Utf8String));
finally
Aes.Free();
end;
end;
Result I get is: 'oZSifB86ZMrA0l5sYpUyCj85t2klIRSDqcwEnyx+wHVugxvzP3U9+BtDD+eqx+pu'
Result I expected is: 'E6861877DB7B021E8B755F927243ED7B'
Online crypt link for same data: http://extranet.cryptomathic.com/aescal … 927243ED7B
I so far only used TAESCFB with mORMot with the help of this forum. I do not have experience about cryptography. I could not fix my code.
I appreciate any help.
Offline
1. EncryptPKCS7() generate random IV (initialization vector), the result will be different each time for the same input data
try this method:
/// perform the AES cypher in the corresponding mode
// - when used in block chaining mode, you should have set the IV property
procedure Encrypt(BufIn, BufOut: pointer; Count: cardinal); virtual; abstract;
but you must known and pass IV
2. You use encoding to Base64, but you expected result in hex?
Offline
Hello,
but you must known and pass IV
I do not know much about encryption. Sample link I provided above says ECB mode does not require any IV. I do not know how to use ECB mode in mORMot.
2. You use encoding to Base64, but you expected result in hex?
You are right. It seems result should be converted to hex from bytes. However, my initial problem above still remains.
Thanks.
Offline
Pages: 1