Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(VB.NET UWP/WinRT) Verify a .p7m and get Algorithm InformationDemonstrates how to verify a .p7m and then examine the algorithms used by the signature.
' This example requires the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim crypt As New Chilkat.Crypt2 Dim inFile As String = "qa_data/p7m/brainpoolP256r1.p7m" Dim outFile As String = "qa_output/something.dat" ' Verify and extract the signed data. Dim success As Boolean = crypt.VerifyP7M(inFile,outFile) If (success = False) Then Debug.WriteLine(crypt.LastErrorText) Exit Sub End If ' Examine details about the signature(s) Dim json As Chilkat.JsonObject = crypt.LastJsonData() json.EmitCompact = False Debug.WriteLine(json.Emit()) ' Sample output ' { ' "pkcs7": { ' "verify": { ' "digestAlgorithms": [ ' "sha256" ' ], ' "signerInfo": [ ' { ' "cert": { ' "serialNumber": "FFFFE552B302FFFFFF1E34C3ACEB2FFFF", ' "issuerCN": "The common name of the cert...", ' "issuerDN": "", ' "digestAlgOid": "2.16.840.1.101.3.4.2.1", ' "digestAlgName": "SHA256" ' }, ' "contentType": "1.2.840.113549.1.7.1", ' "signingTime": "190409140500Z", ' "messageDigest": "lQe9If7vZKFf/NlSYu5Esmlw3phVK/RFsbbb1uH73t8=", ' "signingAlgOid": "1.2.840.10045.4.3.2", ' "signerDigest": "lQe9If7vZKFf/NlSYu5Esmlw3phVK/RFsbbb1uH73t8=", ' "authAttr": [ ' { ' "oid": "1.2.840.113549.1.9.3", ' "oidName": "contentType" ' }, ' { ' "oid": "1.2.840.113549.1.9.5", ' "oidName": "signingTime" ' }, ' { ' "oid": "1.2.840.113549.1.9.52", ' "oidName": "1.2.840.113549.1.9.52", ' "der": "MBs ... AwI=" ' }, ' { ' "oid": "1.2.840.113549.1.9.4", ' "oidName": "messageDigest" ' }, ' { ' "oid": "1.2.840.113549.1.9.16.2.47", ' "oidName": "signingCertificateV2", ' "der": "MCYw .. 7PlQ==" ' }, ' { ' "oid": "1.2.840.113549.1.9.20", ' "oidName": "1.2.840.113549.1.9.20" ' } ' ] ' } ' ] ' } ' } ' } ' Code for parsing the above JSON... Dim i As Integer Dim count_i As Integer Dim strVal As String Dim certSerialNumber As String Dim certIssuerCN As String Dim certIssuerDN As String Dim certDigestAlgOid As String Dim certDigestAlgName As String Dim contentType As String Dim signingTime As String Dim messageDigest As String Dim signingAlgOid As String Dim signerDigest As String Dim j As Integer Dim count_j As Integer Dim oid As String Dim oidName As String Dim der As String i = 0 count_i = json.SizeOfArray("pkcs7.verify.digestAlgorithms") While i < count_i json.I = i strVal = json.StringOf("pkcs7.verify.digestAlgorithms[i]") i = i + 1 End While i = 0 count_i = json.SizeOfArray("pkcs7.verify.signerInfo") While i < count_i json.I = i certSerialNumber = json.StringOf("pkcs7.verify.signerInfo[i].cert.serialNumber") certIssuerCN = json.StringOf("pkcs7.verify.signerInfo[i].cert.issuerCN") certIssuerDN = json.StringOf("pkcs7.verify.signerInfo[i].cert.issuerDN") certDigestAlgOid = json.StringOf("pkcs7.verify.signerInfo[i].cert.digestAlgOid") certDigestAlgName = json.StringOf("pkcs7.verify.signerInfo[i].cert.digestAlgName") contentType = json.StringOf("pkcs7.verify.signerInfo[i].contentType") signingTime = json.StringOf("pkcs7.verify.signerInfo[i].signingTime") messageDigest = json.StringOf("pkcs7.verify.signerInfo[i].messageDigest") signingAlgOid = json.StringOf("pkcs7.verify.signerInfo[i].signingAlgOid") signerDigest = json.StringOf("pkcs7.verify.signerInfo[i].signerDigest") j = 0 count_j = json.SizeOfArray("pkcs7.verify.signerInfo[i].authAttr") While j < count_j json.J = j oid = json.StringOf("pkcs7.verify.signerInfo[i].authAttr[j].oid") oidName = json.StringOf("pkcs7.verify.signerInfo[i].authAttr[j].oidName") der = json.StringOf("pkcs7.verify.signerInfo[i].authAttr[j].der") j = j + 1 End While i = i + 1 End While Debug.WriteLine("Success!") |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.