Hi,
I need to use a 2048 RSA private key generated in C# for signing. What must the key meet if it is generated in C#, what parameters must it have?
Hi, just export the key in PKCS#1 format in C#
It looks like this, but in ASN.1, then base64 encoded:
// PKCS#1
//    RSAPrivateKey ::= SEQUENCE {
//      version   Version,
//      modulus   INTEGER,  -- n
//      publicExponentINTEGER,  -- e
//      privateExponent   INTEGER,  -- d
//      prime1INTEGER,  -- p
//      prime2INTEGER,  -- q
//      exponent1 INTEGER,  -- d mod (p-1)
//      exponent2 INTEGER,  -- d mod (q-1)
//      coefficient   INTEGER,  -- (inverse of q) mod p
//      otherPrimeInfos   OtherPrimeInfos OPTIONAL
//    }
//
The generated file will start with -----BEGIN PRIVATE KEY----- and will be in base 64.
Then, import this in TMSCP using the TRSAEncryptSign class and procedure TRSAEncSign.FromPrivateKeyFile(KeyFile: string); // KeyFile is the full path of the PKCS#1 file created in C#
If the private key is password protected, don't forget to pass the password to the RSA object:
RSA := TRSAEncryptSign.Create;
RSA.passwd := 'your password';
RSA.FromPrivateKeyFile('YourFullKeyFilePath');
Regards,
bernard