Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) ScMinidriver - Get Smartcard PropertiesSee more ScMinidriver ExamplesGets information about the smart card currently inserted in the reader (or USB token).
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set scmd [new_CkScMinidriver] # Reader names (smart card readers or USB tokens) can be discovered # via PCSC List Readers or PCSC Find Smart Cards set readerName "Alcor Micro USB Smart Card Reader 0" set success [CkScMinidriver_AcquireContext $scmd $readerName] if {$success == 0} then { puts [CkScMinidriver_lastErrorText $scmd] delete_CkScMinidriver $scmd exit } set json [new_CkJsonObject] CkJsonObject_put_EmitCompact $json 0 set success [CkScMinidriver_GetCardProperties $scmd $json] if {$success == 0} then { puts [CkScMinidriver_lastErrorText $scmd] delete_CkScMinidriver $scmd delete_CkJsonObject $json exit } puts [CkJsonObject_emit $json] # 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 set bytesAvailable [CkJsonObject_IntOf $json "bytesAvailable"] set containersAvailable [CkJsonObject_IntOf $json "containersAvailable"] set maxKeyContainers [CkJsonObject_IntOf $json "maxKeyContainers"] set capabilitiesFCertificateCompression [CkJsonObject_BoolOf $json "capabilities.fCertificateCompression"] set capabilitiesFKeyGen [CkJsonObject_BoolOf $json "capabilities.fKeyGen"] set keySizesMinimumBitlen [CkJsonObject_IntOf $json "keySizes.minimumBitlen"] set keySizesDefaultBitlen [CkJsonObject_IntOf $json "keySizes.defaultBitlen"] set keySizesMaximumBitlen [CkJsonObject_IntOf $json "keySizes.maximumBitlen"] set keySizesIncrementalBitlen [CkJsonObject_IntOf $json "keySizes.incrementalBitlen"] set readOnly [CkJsonObject_BoolOf $json "readOnly"] set cacheMode [CkJsonObject_stringOf $json "cacheMode"] set supportsWinX509Enrollment [CkJsonObject_BoolOf $json "supportsWinX509Enrollment"] set guid [CkJsonObject_stringOf $json "guid"] set serial [CkJsonObject_stringOf $json "serial"] set pinUserType [CkJsonObject_stringOf $json "pin.user.type"] set pinUserPurpose [CkJsonObject_stringOf $json "pin.user.purpose"] set pinUserCachePolicy [CkJsonObject_stringOf $json "pin.user.cachePolicy"] set pinUserPolicyInfo [CkJsonObject_stringOf $json "pin.user.policyInfo"] set pinUserFlags [CkJsonObject_stringOf $json "pin.user.flags"] set pinUserAcceptPlainTextPin [CkJsonObject_BoolOf $json "pin.user.acceptPlainTextPin"] set pinUserGenerateSessionPin [CkJsonObject_BoolOf $json "pin.user.generateSessionPin"] set pinAdminType [CkJsonObject_stringOf $json "pin.admin.type"] set pinAdminPurpose [CkJsonObject_stringOf $json "pin.admin.purpose"] set pinAdminCachePolicy [CkJsonObject_stringOf $json "pin.admin.cachePolicy"] set pinAdminPolicyInfo [CkJsonObject_stringOf $json "pin.admin.policyInfo"] set pinAdminFlags [CkJsonObject_stringOf $json "pin.admin.flags"] set pinRole3Type [CkJsonObject_stringOf $json "pin.role3.type"] set pinRole3Purpose [CkJsonObject_stringOf $json "pin.role3.purpose"] set pinRole3CachePolicy [CkJsonObject_stringOf $json "pin.role3.cachePolicy"] set pinRole3PolicyInfo [CkJsonObject_stringOf $json "pin.role3.policyInfo"] set pinRole3Flags [CkJsonObject_stringOf $json "pin.role3.flags"] set pinRole3AcceptPlainTextPin [CkJsonObject_BoolOf $json "pin.role3.acceptPlainTextPin"] set pinRole3GenerateSessionPin [CkJsonObject_BoolOf $json "pin.role3.generateSessionPin"] set pinRole4Type [CkJsonObject_stringOf $json "pin.role4.type"] set pinRole4Purpose [CkJsonObject_stringOf $json "pin.role4.purpose"] set pinRole4CachePolicy [CkJsonObject_stringOf $json "pin.role4.cachePolicy"] set pinRole4PolicyInfo [CkJsonObject_stringOf $json "pin.role4.policyInfo"] set pinRole4Flags [CkJsonObject_stringOf $json "pin.role4.flags"] set pinRole4AcceptPlainTextPin [CkJsonObject_BoolOf $json "pin.role4.acceptPlainTextPin"] set pinRole4GenerateSessionPin [CkJsonObject_BoolOf $json "pin.role4.generateSessionPin"] set i 0 set count_i [CkJsonObject_SizeOfArray $json "pins"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pins[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "pin.user.changePermission"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pin.user.changePermission[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "pin.user.unblockPermission"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pin.user.unblockPermission[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "pin.admin.changePermission"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pin.admin.changePermission[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "pin.role3.changePermission"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pin.role3.changePermission[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "pin.role3.unblockPermission"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pin.role3.unblockPermission[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "pin.role4.changePermission"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "pin.role4.changePermission[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "importSupport"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "importSupport[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "algorithms"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "algorithms[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "paddingSchemes"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "paddingSchemes[i]"] set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $json "chainingModes"] while {$i < $count_i} { CkJsonObject_put_I $json $i set strVal [CkJsonObject_stringOf $json "chainingModes[i]"] set i [expr $i + 1] } # Delete the context when finished with the card. set success [CkScMinidriver_DeleteContext $scmd] if {$success == 0} then { puts [CkScMinidriver_lastErrorText $scmd] } delete_CkScMinidriver $scmd delete_CkJsonObject $json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.