Saves a public key string to PKCS-1 public key file.
Public Declare Function RSA_SavePublicKey Lib "diCrPKI.dll"
(ByVal strOutputFile As String, ByVal strPublicKey As String,
ByVal nOptions As Long) As Long
nRet = RSA_SavePublicKey(strOutputFile, strPublicKey,
nOptions) As Long
String specifying the filename of the output file to be created.String containing the public key string (or a private key string)Long Option flags. Select one of:RSA PUBLIC KEY" filePUBLIC KEY" PEM file
long _stdcall RSA_SavePublicKey(const char *szFileOut, const char *szKeyString, long nOptions);
Long: If successful, the return value is zero;
otherwise it returns a nonzero error code.
Any existing file of the specified name will be overwritten without warning. Saves by default as binary DER/BER-encoded PKCS-1 RSAPublicKey data. The file saved with the PKI_KEY_FORMAT_PEM option is the same data in PEM format with header and footer lines:
-----BEGIN RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
The file saved with the PKI_KEY_FORMAT_SSL option is compatible with the format used by OpenSSL. The data is saved as X.509 SubjectPublicKeyInfo format encoded with header and footer lines:
-----BEGIN PUBLIC KEY----- -----END PUBLIC KEY-----
[New in v3.7:] The OpenSSL format key is now saved with "Unix" line endings and a line length of strictly 64 characters. This is to help users in Portugal, but should not affect others.
You can use this function to extract a public key from a private key. Just pass the internal private key string instead of the public key string.
See the example in RSA_GetPublicKeyFromCert.
RSA_ReadPublicKey RSA_GetPublicKeyFromCert