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
long __stdcall RSA_SavePublicKey(const char *szFileOut, const char *szKeyString, long nOptions);
"RSA PUBLIC KEY"
file"PUBLIC KEY"
PEM fileIf successful, the return value is zero; otherwise it returns a nonzero error code.
Public Function rsaSaveKey
(szOutputFile As String, szKeyStr As String, Optional nOptions As Long = 0) As Long
static int dipki::Rsa::SaveKey (const std::string &outputFile, const std::string &keyStr, Format fileFormat=Format::Binary)
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-----
The OpenSSL format key is saved with "Unix" line endings and a line length of strictly 64 characters.
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