Sign string with certificate

Hello, 

in examples you have how to sign files with certificates, but is there possibility to sign string?

For example: we have string "Hello world" 
from this text we will need to make hash SHA256 and sign with  RSASSA-PKCS1 and make output in base64

i try something like this 

 rsa:= TRSAEncSign.Create;
 rsa.KeyLength:= kl2048;
 // to make output in base64
 rsa.OutputFormat:= base64;
 rsa.Unicode := yesUni;
 to make hash SHA256 before sign
 rsa.hashFunction := TRSAhashfunction.sha256;
 // to sign with RSASSA-PKCS1
 rsa.signType:=TRSASignType.spkcs1_5;

// but not know how to load certificates 
// i need to use it on ios i have them in PEM format
 rsa.FromOpenSSLCert(EditCrt.Text);
 rsa.FromOpenSSLPrivateKey(EditKey.Text);
MemoRes.Text:= rsa.Sign('HelloWorld');

is possible to do it? if yes how?

Hi,
The functionnality to sign string with certificate is not yet implemented. You need to extract the key from your private key file to use TRSAEncSign.
Moreover, the openssl functions are only available on Windows for the time being. I will take a look to extend them to other platforms.
Best regards,
Marion

With v5.x, you can load private keys (RSA and EC) from a PKCS#8 file and sign either a string or a file (a digest will be computed and signed in both cases).

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.