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

Unicode C++ 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
Cloud Signature CSC
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
Secrets
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

 

 

 

(Unicode C++) ScMinidriver - Get Smartcard Properties

See more ScMinidriver Examples

Gets information about the smart card currently inserted in the reader (or USB token).

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <CkScMinidriverW.h>
#include <CkJsonObjectW.h>

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

    CkScMinidriverW scmd;

    // Reader names (smart card readers or USB tokens) can be discovered
    // via PCSC List Readers or PCSC Find Smart Cards
    const wchar_t *readerName = L"Alcor Micro USB Smart Card Reader 0";
    bool success = scmd.AcquireContext(readerName);
    if (success == false) {
        wprintf(L"%s\n",scmd.lastErrorText());
        return;
    }

    CkJsonObjectW json;
    json.put_EmitCompact(false);

    success = scmd.GetCardProperties(json);
    if (success == false) {
        wprintf(L"%s\n",scmd.lastErrorText());
        return;
    }

    wprintf(L"%s\n",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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    const wchar_t *strVal = 0;

    int bytesAvailable = json.IntOf(L"bytesAvailable");
    int containersAvailable = json.IntOf(L"containersAvailable");
    int maxKeyContainers = json.IntOf(L"maxKeyContainers");
    bool capabilitiesFCertificateCompression = json.BoolOf(L"capabilities.fCertificateCompression");
    bool capabilitiesFKeyGen = json.BoolOf(L"capabilities.fKeyGen");
    int keySizesMinimumBitlen = json.IntOf(L"keySizes.minimumBitlen");
    int keySizesDefaultBitlen = json.IntOf(L"keySizes.defaultBitlen");
    int keySizesMaximumBitlen = json.IntOf(L"keySizes.maximumBitlen");
    int keySizesIncrementalBitlen = json.IntOf(L"keySizes.incrementalBitlen");
    bool readOnly = json.BoolOf(L"readOnly");
    const wchar_t *cacheMode = json.stringOf(L"cacheMode");
    bool supportsWinX509Enrollment = json.BoolOf(L"supportsWinX509Enrollment");
    const wchar_t *guid = json.stringOf(L"guid");
    const wchar_t *serial = json.stringOf(L"serial");
    const wchar_t *pinUserType = json.stringOf(L"pin.user.type");
    const wchar_t *pinUserPurpose = json.stringOf(L"pin.user.purpose");
    const wchar_t *pinUserCachePolicy = json.stringOf(L"pin.user.cachePolicy");
    const wchar_t *pinUserPolicyInfo = json.stringOf(L"pin.user.policyInfo");
    const wchar_t *pinUserFlags = json.stringOf(L"pin.user.flags");
    bool pinUserAcceptPlainTextPin = json.BoolOf(L"pin.user.acceptPlainTextPin");
    bool pinUserGenerateSessionPin = json.BoolOf(L"pin.user.generateSessionPin");
    const wchar_t *pinAdminType = json.stringOf(L"pin.admin.type");
    const wchar_t *pinAdminPurpose = json.stringOf(L"pin.admin.purpose");
    const wchar_t *pinAdminCachePolicy = json.stringOf(L"pin.admin.cachePolicy");
    const wchar_t *pinAdminPolicyInfo = json.stringOf(L"pin.admin.policyInfo");
    const wchar_t *pinAdminFlags = json.stringOf(L"pin.admin.flags");
    const wchar_t *pinRole3Type = json.stringOf(L"pin.role3.type");
    const wchar_t *pinRole3Purpose = json.stringOf(L"pin.role3.purpose");
    const wchar_t *pinRole3CachePolicy = json.stringOf(L"pin.role3.cachePolicy");
    const wchar_t *pinRole3PolicyInfo = json.stringOf(L"pin.role3.policyInfo");
    const wchar_t *pinRole3Flags = json.stringOf(L"pin.role3.flags");
    bool pinRole3AcceptPlainTextPin = json.BoolOf(L"pin.role3.acceptPlainTextPin");
    bool pinRole3GenerateSessionPin = json.BoolOf(L"pin.role3.generateSessionPin");
    const wchar_t *pinRole4Type = json.stringOf(L"pin.role4.type");
    const wchar_t *pinRole4Purpose = json.stringOf(L"pin.role4.purpose");
    const wchar_t *pinRole4CachePolicy = json.stringOf(L"pin.role4.cachePolicy");
    const wchar_t *pinRole4PolicyInfo = json.stringOf(L"pin.role4.policyInfo");
    const wchar_t *pinRole4Flags = json.stringOf(L"pin.role4.flags");
    bool pinRole4AcceptPlainTextPin = json.BoolOf(L"pin.role4.acceptPlainTextPin");
    bool pinRole4GenerateSessionPin = json.BoolOf(L"pin.role4.generateSessionPin");
    int i = 0;
    int count_i = json.SizeOfArray(L"pins");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pins[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"pin.user.changePermission");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pin.user.changePermission[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"pin.user.unblockPermission");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pin.user.unblockPermission[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"pin.admin.changePermission");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pin.admin.changePermission[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"pin.role3.changePermission");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pin.role3.changePermission[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"pin.role3.unblockPermission");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pin.role3.unblockPermission[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"pin.role4.changePermission");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"pin.role4.changePermission[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"importSupport");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"importSupport[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"algorithms");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"algorithms[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"paddingSchemes");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"paddingSchemes[i]");
        i = i + 1;
    }

    i = 0;
    count_i = json.SizeOfArray(L"chainingModes");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"chainingModes[i]");
        i = i + 1;
    }

    // Delete the context when finished with the card.
    success = scmd.DeleteContext();
    if (success == false) {
        wprintf(L"%s\n",scmd.lastErrorText());
    }
    }

 

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