Creates a "detached signature" CMS signed-data object from a message digest of the content.
Public Declare Function CMS_MakeDetachedSig Lib "diCrPKI.dll"
(ByVal strFileOut As String, ByVal strHexDigest As String,
ByVal strCertList As String, ByVal strPrivateKey As String,
ByVal nOptions As Long) As Long
nRet = CMS_MakeDetachedSig(strFileOut, strHexDigest,
strCertList, strPrivateKey, nOptions) As Long
long __stdcall CMS_MakeDetachedSig(const char *szFileOut, const char *szHexDigest, const char *szCertList, const char *szPrivateKey, long nOptions);
;
)
If successful, the return value is zero;
otherwise it returns a nonzero error code. Further error information may be available by calling
PKI_LastError()
.
static int dipki::Cms::MakeDetachedSig (const std::string &outputFile, const std::string &hexDigest, const std::string &certList, const std::string &privateKey, SigAlg sigAlg=SigAlg::Default, SigDataOptions opts=SigDataOptions::Default_SigDataOpt, Format format=Format::Default)
static Cms.make_detached_sig(outputfile, hexdigest, certlist, prikeystr, sigalg=SigAlg.DEFAULT, opts=SigDataOpts.DEFAULT)
RSASSA-PKCS1V1_5 only.
See CMS_MakeSigData()
for more details.
The PKI_CMS_EXCLUDE_DATA
option is obviously ignored.
This example creates a "detached signature" CMS signed-data object that would duplicate a "detached signature" version of example 4.2 from [SMIME-EX] if they did one. It uses Alice's RSA private key to sign the SHA-1 Message digest of the content "This is some sample content.". The output is a BER-encoded CMS signedData object which includes her certificate but has no signed attributes.
Dim nRet As Long Dim strEPKFile As String Dim strCertFile As String Dim strOutFile As String Dim strHexDigest As String Dim strPrivateKey As String strEPKFile = "AlicePrivRSASign.p8e" strCertFile = "AliceRSASignByCarl.cer" strOutFile = "DetSignByAlice.bin" strHexDigest = "406aec085279ba6e16022d9e0629c0229687dd48" ' First, Alice reads her private key into a string strPrivateKey = rsaReadPrivateKey(strEPKFile, "password") If Len(strPrivateKey) = 0 Then MsgBox "Cannot read private key" Exit Function End If ' Alice makes a detached signature using ' the hash of the content and her private key nRet = CMS_MakeDetachedSig(strOutFile, strHexDigest, _ strCertFile, strPrivateKey, 0) Debug.Print "CMS_MakeDetachedSig returns " & nRet
CMS_MakeSigData CMS_MakeSigDataFromString