I am using Delphi 10.2 and Cryptography Pack 4.3.2.1
I am using RSAEncSign and having trouble with the difference between loading the keys from a file and having the same keys included in the project as a const.
When I use FromOpenSSLPublicKey or FromOpenSSLPrivateKey the encode and decode work as expected.
When I copy the contents of the file to a const variable, I get error "RSA Key Length not supported", using FromPublicKey or FromPrivateKey.
I have tried with and without the "-----BEGIN PUBLIC KEY-----" and tags.
I am not sure how to use the converter class to convert the file contents to a usable format.
working code:
RSA := TRSAEncSign.Create(nil);
RSA.keyLength := kl2048;
RSA.outputFormat := base64;
RSA.Unicode := yesUni;
RSA.encType := epkcs1_5;
sFileName := ExtractFilePath(Application.ExeName)+'\public-key.pem';
RSA.withOpenSSL := true;
RSA.FromOpenSSLPublicKey(sFileName);
memoOut.Text := RSA.Encrypt(memoIn.Text);
code that errors:
RSA := TRSAEncSign.Create(nil);
RSA.keyLength := kl2048;
RSA.outputFormat := base64;
RSA.Unicode := yesUni;
RSA.encType := epkcs1_5;
RSA.withOpenSSL := true;
RSA.FromPrivateKey(PrivateKey);
memoOut.Text := RSA.Encrypt(memoIn.Text);
Thanks.