CryptoSys PKI Toolkit Manual

CMS_ReadSigDataToString

Reads the content from a CMS signed-data object file directly into a string.

VB6/VBA Syntax

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

Parameters

strDataOut
[out] String to receive the output.
nDataLen
[in] Long specifying the length of the output string.
strFileIn
[in] String with name of signed-data CMS object file or the data as a base64 or PEM string.
nOptions
[in] Long option flags:
PKI_DEFAULT (0) for default options
PKI_CMS_FORMAT_BASE64 to read input formatted with base64 encoding (default expected BER-encoded binary) [not necessary for v3.5 and above].

C/C++ Syntax

long _stdcall CMS_ReadSigDataToString(char *szDataOut, long nDataOutLen, const char *szFileIn, long nOptions);

Returns (VB6/C)

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.

.NET Equivalent

Cms.ReadSigDataToString Method

Remarks

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.

Example

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.]

See Also

CMS_ReadSigData CMS_GetSigDataDigest

[Contents] [Index]

[HOME]   [NEXT: CMS_VerifySigData...]

Copyright © 2004-10 D.I. Management Services Pty Ltd. All rights reserved.