Reads the content from a CMS signed-data object file directly into a string.
Public Declare Function CMS_ReadSigDataToString Lib "diCrPKI.dll"
(ByVal strDataOut As String, ByVal nDataLen As Long,
ByVal strFileIn As String, ByVal nOptions As Long) As Long
nRet = CMS_ReadSigDataToString(strDataOut, nDataLen, strFileIn,
nOptions) As Long
String to receive the output.Long specifying the length of the output string.String with name of signed-data CMS object file
or the data as a base64 or PEM string.Long option flags: PKI_CMS_FORMAT_BASE64 to read input formatted with base64 encoding (default expected BER-encoded binary)
[not necessary for v3.5 and above].
long _stdcall CMS_ReadSigDataToString(char *szDataOut, long nDataOutLen, const char *szFileIn,
long nOptions);
Long: If successful, the return value is a positive number indicating the number of bytes in the content;
otherwise it returns a negative error code.
Cms.ReadSigDataToString Method
This function extracts the signed data from the signed-data CMS object without making any attempt to verify it.
Call the function with an empty or NULL strDataOut and zero nDataLen parameters to find out the required length of output string.
C/C++ users should add one to this before allocating memory.
The buffer must be large enough to receive the entire output or a SHORT_BUF_ERROR error will result.
This example reads the content from the signed CMS object from example 4.2 in [SMIME-EX].
Dim nRet As Long
Dim strFileIn As String
Dim strData As String
Dim nDataLen As Long
strFileIn = "C:\Test\4.2.bin"
' How long is the content to be read?
nDataLen = CMS_ReadSigDataToString("", 0, strFileIn, 0)
If nDataLen <= 0 Then
Exit Function
End If
' Pre-dimension string to receive data
strData = String(nDataLen, " ")
nRet = CMS_ReadSigDataToString(strData, nDataLen, strFileIn, 0)
Debug.Print "CMS_ReadSigDataToString returns " & nRet
Debug.Print "Data is [" & strData & "]"
This should result in the output:
CMS_ReadSigDataToString returns 28 Data is [This is some sample content.]
CMS_ReadSigData CMS_GetSigDataDigest