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
(Excel) ScMinidriver - Get Smartcard PropertiesSee more ScMinidriver ExamplesGets information about the smart card currently inserted in the reader (or USB token). Note: This functionality was introduced in Chilkat v9.5.0.87. Note: The ScMinidriver functionality is for Windows-only because ScMinidriver DLLs only exist on Windows. In the next version, Chilkat will be releasing a Pkcs11 class to support Linux, MacOSX, and possibly other operating systems.
' This example requires the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. Dim scmd As Chilkat.ScMinidriver Set scmd = Chilkat.NewScMinidriver ' Reader names (smart card readers or USB tokens) can be discovered ' via PCSC List Readers or PCSC Find Smart Cards readerName = "Alcor Micro USB Smart Card Reader 0" success = scmd.AcquireContext(readerName) If (success = False) Then Debug.Print scmd.LastErrorText Exit Sub End If Dim json As Chilkat.JsonObject Set json = Chilkat.NewJsonObject json.EmitCompact = False success = scmd.GetCardProperties(json) If (success = False) Then Debug.Print scmd.LastErrorText Exit Sub End If Debug.Print json.Emit() ' Here is sample output: ' See below for sample code to parse the JSON. ' ' NOTE: Not all smart cards support all properties. ' The GetCardProperties method will return information for all properties supported by the card. ' { ' "bytesAvailable": 74752, ' "containersAvailable": 18, ' "maxKeyContainers": 20, ' "capabilities": { ' "fCertificateCompression": false, ' "fKeyGen": true ' }, ' "keySizes": { ' "minimumBitlen": 2048, ' "defaultBitlen": 2048, ' "maximumBitlen": 4096, ' "incrementalBitlen": 1024 ' }, ' "readOnly": false, ' "cacheMode": "global", ' "supportsWinX509Enrollment": true, ' "guid": "1201803d-03e6-772a-3d80-0112e6032a77", ' "serial": "e6032a773d800112e6032a77", ' "pins": [ ' "user", ' "admin", ' "role3", ' "role4" ' ], ' "pin": { ' "user": { ' "type": "regular", ' "purpose": "primaryCard", ' "changePermission": [ ' "user" ' ], ' "unblockPermission": [ ' "admin" ' ], ' "cachePolicy": "normal", ' "policyInfo": "00000000", ' "flags": "00000000", ' "acceptPlainTextPin": true, ' "generateSessionPin": false ' }, ' "admin": { ' "type": "challenge/response", ' "purpose": "administrator", ' "changePermission": [ ' "admin" ' ], ' "cachePolicy": "normal", ' "policyInfo": "00000000", ' "flags": "00000000" ' }, ' "role3": { ' "type": "regular", ' "purpose": "digitalSignature", ' "changePermission": [ ' "role3" ' ], ' "unblockPermission": [ ' "role4" ' ], ' "cachePolicy": "alwaysPrompt", ' "policyInfo": "00000000", ' "flags": "00000000", ' "acceptPlainTextPin": true, ' "generateSessionPin": false ' }, ' "role4": { ' "type": "regular", ' "purpose": "unblockOnly", ' "changePermission": [ ' "role4" ' ], ' "cachePolicy": "normal", ' "policyInfo": "00000000", ' "flags": "00000000", ' "acceptPlainTextPin": true, ' "generateSessionPin": false ' } ' }, ' "importSupport": [ ' "plainText", ' "rsaKeyest", ' "eccKeyest", ' "symmetric" ' ], ' "algorithms": [ ' "AES" ' ], ' "paddingSchemes": [ ' "block", ' "pkcs1", ' "pss", ' "oaep" ' ], ' "chainingModes": [ ' "ChainingModeCBC" ' ] ' } ' Use this online tool to generate parsing code from sample JSON: ' Generate Parsing Code from JSON bytesAvailable = json.IntOf("bytesAvailable") containersAvailable = json.IntOf("containersAvailable") maxKeyContainers = json.IntOf("maxKeyContainers") capabilitiesFCertificateCompression = json.BoolOf("capabilities.fCertificateCompression") capabilitiesFKeyGen = json.BoolOf("capabilities.fKeyGen") keySizesMinimumBitlen = json.IntOf("keySizes.minimumBitlen") keySizesDefaultBitlen = json.IntOf("keySizes.defaultBitlen") keySizesMaximumBitlen = json.IntOf("keySizes.maximumBitlen") keySizesIncrementalBitlen = json.IntOf("keySizes.incrementalBitlen") readOnly = json.BoolOf("readOnly") cacheMode = json.StringOf("cacheMode") supportsWinX509Enrollment = json.BoolOf("supportsWinX509Enrollment") guid = json.StringOf("guid") serial = json.StringOf("serial") pinUserType = json.StringOf("pin.user.type") pinUserPurpose = json.StringOf("pin.user.purpose") pinUserCachePolicy = json.StringOf("pin.user.cachePolicy") pinUserPolicyInfo = json.StringOf("pin.user.policyInfo") pinUserFlags = json.StringOf("pin.user.flags") pinUserAcceptPlainTextPin = json.BoolOf("pin.user.acceptPlainTextPin") pinUserGenerateSessionPin = json.BoolOf("pin.user.generateSessionPin") pinAdminType = json.StringOf("pin.admin.type") pinAdminPurpose = json.StringOf("pin.admin.purpose") pinAdminCachePolicy = json.StringOf("pin.admin.cachePolicy") pinAdminPolicyInfo = json.StringOf("pin.admin.policyInfo") pinAdminFlags = json.StringOf("pin.admin.flags") pinRole3Type = json.StringOf("pin.role3.type") pinRole3Purpose = json.StringOf("pin.role3.purpose") pinRole3CachePolicy = json.StringOf("pin.role3.cachePolicy") pinRole3PolicyInfo = json.StringOf("pin.role3.policyInfo") pinRole3Flags = json.StringOf("pin.role3.flags") pinRole3AcceptPlainTextPin = json.BoolOf("pin.role3.acceptPlainTextPin") pinRole3GenerateSessionPin = json.BoolOf("pin.role3.generateSessionPin") pinRole4Type = json.StringOf("pin.role4.type") pinRole4Purpose = json.StringOf("pin.role4.purpose") pinRole4CachePolicy = json.StringOf("pin.role4.cachePolicy") pinRole4PolicyInfo = json.StringOf("pin.role4.policyInfo") pinRole4Flags = json.StringOf("pin.role4.flags") pinRole4AcceptPlainTextPin = json.BoolOf("pin.role4.acceptPlainTextPin") pinRole4GenerateSessionPin = json.BoolOf("pin.role4.generateSessionPin") i = 0 count_i = json.SizeOfArray("pins") Do While i < count_i json.I = i strVal = json.StringOf("pins[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.user.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.user.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.user.unblockPermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.user.unblockPermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.admin.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.admin.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.role3.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.role3.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.role3.unblockPermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.role3.unblockPermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("pin.role4.changePermission") Do While i < count_i json.I = i strVal = json.StringOf("pin.role4.changePermission[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("importSupport") Do While i < count_i json.I = i strVal = json.StringOf("importSupport[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("algorithms") Do While i < count_i json.I = i strVal = json.StringOf("algorithms[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("paddingSchemes") Do While i < count_i json.I = i strVal = json.StringOf("paddingSchemes[i]") i = i + 1 Loop i = 0 count_i = json.SizeOfArray("chainingModes") Do While i < count_i json.I = i strVal = json.StringOf("chainingModes[i]") i = i + 1 Loop ' Delete the context when finished with the card. success = scmd.DeleteContext() If (success = False) Then Debug.Print scmd.LastErrorText End If |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.