Reads from a BER-encoded public key file into an "internal" public key string.
Public Declare Function RSA_ReadPublicKey Lib "diCrPKI.dll"
(ByVal strPublicKey As String, ByVal nOutChars As Long, ByVal strKeyFileName As String,
ByVal nOptions As Long) As Long
nRet = RSA_ReadPublicKey(strPublicKey, nOutChars,
strKeyFileName, nOptions) As Long
String to receive public key data in encoded "internal" format.Long specifying the maximum number of characters to be received.String specifying the filename of a public key file
(or a string containing the data in PEM format).Long option flags: not used in this release. Specify zero.
long _stdcall RSA_ReadPublicKey(char *szOutput, long nOutChars, const char *szKeyFile, long flags);
Long: If successful, the return value is the number of characters in the output string;
otherwise it returns a negative error code.
Only PKCS-1 RSAPublicKey files are supported.
The file must be either in binary BER-encoded format or PEM format.
Call the function with an empty or NULL strOutput string or zero nOutChars parameter to find out the required length of
the output string. C/C++ users should add one to this value when allocating memory.
This wrapper function returns the public key string given the filename
Public Function rsaReadPublicKey(strKeyFile As String) As String Dim nKeyLen As Long Dim nRet As Long ' How long is key string? nKeyLen = RSA_ReadPublicKey("", 0, strKeyFile, 0) If nKeyLen <= 0 Then Exit Function End If ' Pre-dimension the string to receive data rsaReadPublicKey = String(nKeyLen, " ") ' Read in the Private Key nRet = RSA_ReadPublicKey(rsaReadPublicKey, nKeyLen, strKeyFile, 0) End Function
RSA_SavePublicKey RSA_GetPublicKeyFromCert