Extracts a base64-encoded RSA key value from internal key string.
Public Declare Function RSA_KeyValue Lib "diCrPKI.dll" (ByVal strOutput As String, ByVal nOutChars As Long, ByVal strKeyString As String, ByVal strFieldName As String, ByVal nOptions As Long) As Long
nRet = RSA_KeyValue(strOutput, nOutChars, strKeyString, strFieldName, nOptions)
long __stdcall RSA_KeyValue(char *szOutput, long nOutChars, const char *szKeyString, const char *szFieldName, long nOptions);
If successful, the return value is the number of characters in or required for the output string; otherwise it returns a negative error code.
Public Function rsaKeyValue
(szKeyString As String, szFieldName As String, Optional nOptions As Long = 0) As String
static std::string dipki::Rsa::KeyValue (const std::string &keyStr, const std::string &fieldName)
static Rsa.key_value(keystr, fieldname)
For the "raw" VBA/C function, the user must allocate an output string buffer szOutput of the required length. Specify a zero nOutChars or an empty string for szOutput to find the required length. ANSI C users must add one to this value when allocating memory.
The output is a continuous string of base64 characters
suitable for a <RSAKeyValue>
node in an XML-DSIG document.
A typical <RSAKeyValue>
node looks like this:
<RSAKeyValue> <Modulus> 4IlzOY3Y9fXoh3Y5f06wBbtTg94Pt6vcfcd1KQ0FLm0S36aGJtTSb6pYKfyX7PqCUQ8wgL6xUJ5GRPEsu9gyz8 ZobwfZsGCsvu40CWoT9fcFBZPfXro1Vtlh/xl/yYHm+Gzqh0Bw76xtLHSfLfpVOrmZdwKmSFKMTvNXOFd0V18= </Modulus> <Exponent>AQAB</Exponent> </RSAKeyValue>
Use this function to populate the fields <Modulus>
and <Exponent>
for a given RSA key,
or to use the values in other computations.
Dim nChars As Long Dim strKeyString As String Dim strFieldName As String Dim strValue As String ' Read in key to internal string strKeyString = rsaReadPublicKey("AliceRSASignByCarl.cer") strFieldName = "Modulus" nChars = RSA_KeyValue("", 0, strKeyString, strFieldName, 0) If (nChars < 0) Then Debug.Print "ERROR: " & pkiErrorLookup(nChars) Exit Sub End If ' Dimension output strValue = String(nChars, " ") nChars = RSA_KeyValue(strValue, nChars, strKeyString, strFieldName, 0) Debug.Print strFieldName & "=" & strValue strFieldName = "Exponent" nChars = RSA_KeyValue("", 0, strKeyString, strFieldName, 0) If (nChars < 0) Then Debug.Print "ERROR: " & pkiErrorLookup(nChars) Exit Sub End If ' Dimension output strValue = String(nChars, " ") nChars = RSA_KeyValue(strValue, nChars, strKeyString, strFieldName, 0) Debug.Print strFieldName & "=" & strValue
Modulus=4IlzOY3Y9fXoh3Y5f06wBbt ... +Gzqh0Bw76xtLHSfLfpVOrmZdwKmSFKMTvNXOFd0V18= Exponent=AQAB
Dim strKeyString As String Dim strFieldName As String Dim strValue As String strKeyString = rsaReadPublicKey("AliceRSASignByCarl.cer") strFieldName = "Modulus" strValue = rsaKeyValue(strKeyString, strFieldName) Debug.Print strFieldName & "=" & strValue strFieldName = "Exponent" strValue = rsaKeyValue(strKeyString, strFieldName) Debug.Print strFieldName & "=" & strValue