Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) ScMinidriver - Get CSP Container Map for Smart Card or USB Token

See more ScMinidriver Examples

Returns the contents of the CSP container map file (cmapfile). This gives an overview of what key containers and certificates exist in the smart card from a CSP's point of view.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoScmd
    String sReaderName
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Integer iIndex
    String sGuid
    Boolean iDefault
    Integer iSigKeySizeBits
    Integer iKexKeySizeBits
    String sKexCertSerialNum
    String sKexCertIssuerCN
    String sKexCertSubjectCN
    String sSigCertSerialNum
    String sSigCertIssuerCN
    String sSigCertSubjectCN
    Integer i
    Integer iCount_i
    String sTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatScMinidriver)) To hoScmd
    If (Not(IsComObjectCreated(hoScmd))) Begin
        Send CreateComObject of hoScmd
    End

    // Reader names (smart card readers or USB tokens) can be discovered
    // via PCSC List Readers or PCSC Find Smart Cards
    Move "SCM Microsystems Inc. SCR33x USB Smart Card Reader 0" To sReaderName
    Get ComAcquireContext Of hoScmd sReaderName To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoScmd To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Set ComEmitCompact Of hoJson To False

    Get pvComObject of hoJson to vJson
    Get ComGetCspContainerMap Of hoScmd vJson To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoScmd To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // Here is sample output:
    // See below for sample code to parse the JSON.

    // --------------------------------------------------------------
    // Some notes:
    // 
    // 1) Empty containers are not listed.
    // 2) The "index" is the index of the key container on the card.
    //    Note that in the example output below, the card has 4 occupied containers
    //    at indexes 0, 1, 2, and 5.
    // 3) If you see a key size (in bits) equal to 0, it means that key does not exist.
    // 4) A container can potentially contain 2 keys + certificates -- a key for signing (also known as 
    //    the "signature" key), and a key for authentication/authorization (also known as the 
    //    "key exchange" key).
    // 5) It is possible for a key to exist without the certificate.  For example, in the results
    //    below there is a 2048-bit key-exchange key at index 1, but no certificate.
    // 6) A certificate belonging to the key-exchange key is contained in the "kexCert" JSON member,
    //    a certificate belonging to the signature key is contained in the "sigCert" JSON member (not shown below).
    // --------------------------------------------------------------

    // {
    //   "containers": [
    //     {
    //       "index": 0,
    //       "guid": "CertReq-PIVKeyC910-205fc3c2-19fe--42448",
    //       "default": true,
    //       "sigKeySizeBits": 0,
    //       "kexKeySizeBits": 2048,
    //       "kexCert": {
    //         "serialNum": "15FBFBCF00010000313D",
    //         "issuerCN": "PIVKey Device Certificate Authority",
    //         "subjectCN": "PIVKey Device Certificate Authority"
    //       }
    //     },
    //     {
    //       "index": 1,
    //       "guid": "{7b3c32dd-e992-c58f-0822-67d72fd52d43}",
    //       "default": false,
    //       "sigKeySizeBits": 0,
    //       "kexKeySizeBits": 2048
    //     },
    //     {
    //       "index": 2,
    //       "guid": "{57547a77-18e7-7516-f5da-6aee13b46bbc}",
    //       "default": false,
    //       "sigKeySizeBits": 0,
    //       "kexKeySizeBits": 2048
    //     },
    //     {
    //       "index": 5,
    //       "guid": "{306fd6da-9954-4f75-95c0-178f607a41fb}",
    //       "default": false,
    //       "sigKeySizeBits": 0,
    //       "kexKeySizeBits": 2048,
    //       "kexCert": {
    //         "serialNum": "17C1B793A24D1A81490F5F768E6D23A5",
    //         "issuerCN": "Matt",
    //         "subjectCN": "Matt"
    //       }
    //     }
    //   ]
    // }

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    Move 0 To i
    Get ComSizeOfArray Of hoJson "containers" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComIntOf Of hoJson "containers[i].index" To iIndex
        Get ComStringOf Of hoJson "containers[i].guid" To sGuid
        Get ComBoolOf Of hoJson "containers[i].default" To iDefault
        Get ComIntOf Of hoJson "containers[i].sigKeySizeBits" To iSigKeySizeBits
        Get ComIntOf Of hoJson "containers[i].kexKeySizeBits" To iKexKeySizeBits
        Get ComStringOf Of hoJson "containers[i].kexCert.serialNum" To sKexCertSerialNum
        Get ComStringOf Of hoJson "containers[i].kexCert.issuerCN" To sKexCertIssuerCN
        Get ComStringOf Of hoJson "containers[i].kexCert.subjectCN" To sKexCertSubjectCN
        Get ComStringOf Of hoJson "containers[i].sigCert.serialNum" To sSigCertSerialNum
        Get ComStringOf Of hoJson "containers[i].sigCert.issuerCN" To sSigCertIssuerCN
        Get ComStringOf Of hoJson "containers[i].sigCert.subjectCN" To sSigCertSubjectCN
        Move (i + 1) To i
    Loop

    // Delete the context when finished with the card.
    Get ComDeleteContext Of hoScmd To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoScmd To sTemp1
        Showln sTemp1
    End



End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.