CryptoSys PKI Pro Manual

Example: Cms.GetSigDataDigest  Cms.QuerySigData  Cms.ReadSigDataToString  Hash.HexFromString 

[VB6 equivalent: CMS_GetSigDataDigest]

Dim strCmsFile As String
Dim strHexDigest As String
Dim strData As String
Dim strContentDigest As String
Dim strDigestAlg As String

strCmsFile = "4.2.bin"

' 1. Get the digest value
strHexDigest = Cms.GetSigDataDigest(strCmsFile, "")
If strHexDigest.Length = 0 Then
    Exit Sub
End If
Console.WriteLine("Extracted digest is")
Console.WriteLine("[" & strHexDigest & "]")

' 2. Go get the content - in this case it's in the signed-data object
strData = Cms.ReadSigDataToString(strCmsFile)
If strData.Length = 0 Then
    Exit Sub
End If
Console.WriteLine("Data is [" & strData & "]")

' 3. Compute independently the hash of what we found
' [.NET] We have to query the signed data to find the hash algorithm
strDigestAlg = Cms.QuerySigData(strCmsFile, "digestAlgorithm")
Console.WriteLine("digestAlgorithm=" & strDigestAlg)
strContentDigest = Hash.HexFromString(strData, HashAlgorithm.Sha1)
Console.WriteLine("Computed hash of content is")
Console.WriteLine("[" & strContentDigest & "]")

' 4. Can we match this hash digest with
'    what we extracted from the signed-data?
If strContentDigest = strHexDigest Then
    Console.WriteLine("SUCCESS - digests match!")
Else
    Console.WriteLine("FAILS! - no match")
End If

See Also:
Cms.GetSigDataDigest Method

[Contents] [Index]

[PREV: Example: Cms.GetSigDataDigest ...]   [Contents]   [Index]   
   [NEXT: Example: Cms.MakeDetachedSig ...]

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