are able to do it with:
openssl-1.0.2u-x64_86-win64\openssl.exe rsautl -oaep -encrypt -pubin -inkey test.pem -in req.txt -out req.sign
openssl.exe base64 -A -in req.sign -out res.txt
but are getting error: RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error
from supplier, so some thought on this?
I've tried all kind of combination without any luck.
I cant get it to work, but I've tried by creating a sample project:
object rsa: TRSAEncSign
Version = '4.3.3.0'
pssSaltLen = 0
Left = 304
Top = 224
end
procedure test;
var
s,pw:string;
fs:TMemoryStream;
begin
pw := 'my test text';
RSA.withOpenSSL := true;
RSA.FromPublicKeyFile('public-key.pem');
s := rsa.Encrypt(pw);
fs := TMemoryStream.Create;
fs.Size := length(s) div 2;
HexToBin(pansichar(s),fs.Memory,fs.Size);
fs.SaveToFile('C:\openssl\test\encoded.txt');
end;
I couldn't make it work either, so I tried to decrypt with TMS CP and found and issue with the key format in SetPrivateExponent. A key provided in hex shall not be converted to hex again.
Once fixed, I could decrypt.
I'll do more tests to understand what's wrong.
Hi, thank you for new version, but still i cant get this to work, so tried with the demo i made over, outcome of openssl is:
10616:error:04065084:rsa routines:RSA_EAY_PRIVATE_DECRYPT:data too large for modulus:.\crypto\rsa\rsa_eay.c:519:
tried with the demo application to encrypt and decrypt base64 code between openssl and application but failes all the time. Could you verify a working setup for rsa 2048 oaep with a public/private pem certificate?
begin
pw := 'my test text';
RSA.withOpenSSL := true;
RSA.FromPublicKeyFile('public-key.pem');
s := rsa.Encrypt(pw);
fs := TMemoryStream.Create;
fs.Size := length(s) div 2;
HexToBin(pansichar(s),fs.Memory,fs.Size);
fs.SaveToFile('C:\openssl\test\encoded.txt');
end;
The error message looks like the outcome of a conversion (or lack of) issue.
And also, nothing to do with your example, but the RSACore.pas file needs to be edited on line 2912:
writeln(S1, ':', S2, ':', S3); needs to be commented or deleted
This section is used to clock the sequence and is useless for normal use.
After a few conversion corrections, I get (using openSSL):
304C0000:error:02000079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error:crypto\rsa\rsa_oaep.c:308:
This needs to be investigated further as the OAEP padding doesn't seem to be correct.