Im migrating my 10.4.2 app to D11, so i downloaded current v4.3.2.1 TMS crypto version.
The problem is that the encrypted data made with v4.3.0.4 is not compatible with v4.3.2.1. Im getting this error:
Project app.apk raised exception class ECryptoPack with message 'error : in AES, the cipher text cannot be decrypted because the padding is not correct!
Would like support with this case, because now i have an encrypted database that my app cant read.
Hi Aldo,
Your IV only has 15 characters:
aesencriptar.IV := '2jsf fm39 4SFF msa'; <= the last group has 3 letters only (or you need a conversion)
And the key only has 31 characters:
aesencriptar.key := 'n@#m sd9f kfsa kfas 1SAc m39n FA03 2ds' ;
test := aesencriptar.decrypt('5A7579B3ABA3D60BED7EC626FA8ED7E0013DB4EC6FD0D126B2684231AC89502E4D65A5CF45E3BFFF54EE18A62F1A3AFE');
Any more info, just please let me know.
You can do a test encrypting with v4.3.0.4 using this key/IV
IV := 'DGUpltToscainLee';
key := 'DGursoSTClnPyAleQryAlertasSinLee' or any another key/IV and it wont decrypt with v4.3.2.1 using the same Key/IV
If somehow it can help. I have tested on Delphi 10.4.2 and is working the encryption / decryption with AES and is compatible with TMS Crypto v4.3.0.4 and v4.3.2.1.
To be on the safe side I rerun the tests from NIST Special Publication 800-38A (Recommendation for Block Cipher Modes of Operation) and all of them passed for the ECB 256 and CBC 256 modes and key size in RAD Studio 11. Which brings even more confusion and most likely locates the problem in a conversion operation or similar.
Does the original code convert anything? Yes. Is working fine on Delphi 10.4.2 the AES256 encrypt/decrypt of the database but when i compile on D11 it gives the error Project app.apk raised exception class ECryptoPack with message 'error : in AES, the cipher text cannot be decrypted because the padding is not correct!
Hi Aldo,
Could you you send me the v4.3.0.4 AESObj.pas, MiscObj.pas (in the main TMS CP directory) and aes.obj and aes_mode.obj (in the libWin32 folder), together with a cleartext/cryptogram pair and the IV and key for this pair?
There is no bug in the AES library, the issue was with Delphi 11 (and I could not reproduce it with my version) and was fixed with the release of patch #1.