% GPSHELL3(1) 3.0.0 | GPShell3 Documentation
gpshell3 - simplified command line tool for managing GlobalPlatform compliant smart cards
| gpshell3 [global-options] [command-args]
gpshell3 is a modern, simplified CLI for GlobalPlatform card management. It provides a concise set of commands for listing, installing and deleting applications, managing keys, opening secure channels, sending raw APDUs, and performing personalization steps, while following the GlobalPlatform Card specification.
Unlike the legacy gpshell (script-driven), gpshell3 is argument-driven and aims to be easy to use interactively, in shell scripts, or on CI systems. All commands work against PC/SC readers and use the in-tree GlobalPlatform library.
Unless otherwise specified, gpshell3 will:
- connect to the first available PC/SC reader;
- select a suitable Issuer Security Domain (ISD) AID automatically (
A000000151000000,A0000001510000, orA000000003000000); - open a Secure Channel using defaults listed below when a command requires security (e.g., install, delete, key management).
See also the example scripts in gpshell/examples/ in the repository.
-r, --reader <name|num> : PC/SC reader name or 1-based number. Default: first present reader.
--protocol <auto|t0|t1>
: Transport protocol. Default: auto.
--sd
: ISD AID to select explicitly (hex). By default gpshell3 will try, in order:
A000000151000000(GP 2.3.1 ISD)A0000001510000(GP 2.1.1 CM)A000000003000000(OP 2.0.1 CM)
--sec <mac|mac+enc|mac+enc+rmac>
: Secure Channel security level. Default: mac+enc.
--scp
: Secure Channel Protocol number, e.g. 1, 2, 3. Normally auto-detected.
--scp-impl
: SCP implementation as a hex value (e.g., 15, 55). Normally auto-detected.
--kv
: Key set version to use for mutual authentication. Default: 0.
--idx
: Key index within the key set for mutual authentication. Default: 0.
--derive <none|visa2|emv> : Key derivation method when authenticating with a single base key.
none(default): use keys as provided.visa2: VISA2 derivation (a.k.a. VISA key derivation).emv: EMV CPS 1.1 derivation.
--key
: Base key (hex) used to derive ENC/MAC/DEK when --derive is not none. If --enc/--mac/--dek are not provided and no derivation is provided, this base key is also used directly for SCP02. Default: bytes 40..4F (16 bytes).
--enc , --mac , --dek
: Explicit S-ENC, S-MAC and DEK keys (hex) for mutual authentication. If provided together, --key is ignored.
-v, --verbose : Verbose output.
-t, --trace : Print APDU trace (hex APDUs and status words).
-h, --help : Show usage.
List Issuer Security Domains, Security Domains, Applications, Load Files and Executable Modules. Output includes:
- AIDs and life cycle states;
- associated Security Domain AIDs;
- privileges in short-name form like
priv=[sd,cm-lock,...].
Example:
gpshell3 list-appsList key information grouped by key set version (kv), including key types and size.
Example:
gpshell3 list-keysList available PC/SC readers.
Load a CAP file and install/make selectable applet instances.
Synopsis:
gpshell3 install [--load-only|--install-only]
[--dap <hex>|@<file>] [--load-token <hex>] [--install-token <hex>]
[--hash <hex>] [--load-file <AIDhex>] [--applet <AIDhex>] [--module <AIDhex>]
[--params <hex>] [--v-data-limit <size>] [--nv-data-limit <size>]
[--priv <p1,p2,...>] <cap-file>Options:
--applet <AIDhex>: Applet AID to install (optional). If omitted together with--module, installs all applets from the CAP.--module <AIDhex>: Module AID (often same as applet) to install (optional).--params <hex>: Installation parameters (hex) passed to the appletinstall()method (optional).--priv <list>: Comma-separated privileges by short names. See “Privileges” below (optional).--v-data-limit <size>: Volatile data storage limit in bytes (optional).--nv-data-limit <size>: Non-volatile data storage limit in bytes (optional).--load-only: Perform INSTALL [for load] + LOAD only, skip installation/make-selectable.--install-only: Perform only INSTALL [for install] and make-selectable. Requires--load-file,--module, and--applet.--load-file <AID>: AID of the load file (required for--install-only).--dap <hex>|@file: DAP signature as hex or binary file (security domain AID is taken from--sd). If used,--hashmust provide the precomputed load-file data block hash.--hash <hex>: Precomputed load-file data block hash (hex) required when--dapis supplied.--load-token <hex>/--install-token <hex>: Tokens for delegated management (optional).
Examples:
# Load and install with default security settings
gpshell3 install ./helloworld.cap
# Load only (stage package without creating instances)
gpshell3 install --load-only ./helloworld.cap
# Install only from an already loaded package
gpshell3 install --install-only \
--load-file A00000000101 \
--module A00000000101 \
--applet A0000000010101 \
--params 80Delete an application instance or load file by AID.
Example:
gpshell3 delete A0000000010101Set the lifecycle state of a card element.
Synopsis:
gpshell3 status <isd|sd|app|sd-app> --lc <state> <AIDhex>Element types and allowed states:
isd:locked,terminated(WARNING:terminatedis permanent.)sd:personalized,lockedapp:locked,selectablesd-app:locked
Set secure channel keys (S-ENC, S-MAC, DEK) for a key set.
Synopsis:
gpshell3 put-auth [--type <aes|3des>] [--derive <none|emv|visa2>] --kv <ver> [--new-kv <ver>] [--key <hex> | --enc <hex> --mac <hex> --dek <hex>]Options:
- Use either a single
--key(with optional--derive) OR all of--enc/--mac/--dek. --kv <ver>: Key set version, defaults to 1, 0 means that a new key set is created (optional).--new-kv <ver>: New key set version when replacing keys, defaults to 1 (optional).--typedefaults toaes.
Put (add or replace) a key in a key set.
Synopsis:
gpshell3 put-key [--type <3des|aes|rsa>] --kv <ver> --idx <idx> --new-kv <ver> (--key <hex>|--pem <file>[:pass])Options:
--kv <ver>: Key set version (mandatory).--idx <idx>: Key index within the set (mandatory).--new-kv <ver>: New key set version when replacing keys (mandatory).- For
--type aes|3des: provide the key via--key <hex>. - For
--type rsa: provide an RSA public key in PEM via--pem <file>[:pass].
Put delegated management keys.
Synopsis:
gpshell3 put-dm --kv <ver> [--new-kv <ver>] [--token-type <rsa>] [--receipt-type <aes|des>] <pem-file>[:pass] <receipt-key-hex>Options:
--kv <ver>: Key set version, defaults to 0, 0 means that a new key set is created (optional).--new-kv <ver>: New key set version when replacing or creating a new key set (mandatory).<pem-file>[:pass]: Token signing key in PEM, optional passphrase after colon.<receipt-key-hex>: Receipt key material (last positional parameter).--token-type: Token key type, defaultrsa.--receipt-type: Receipt key type,aesordes(defaultaes).
Delete a key or an entire key set.
Synopsis:
gpshell3 del-key --kv <ver> [--idx <idx>]Options:
--kv <ver>: Key set version (mandatory).--idx <idx>: Key index within the set If--idxis omitted, the entire key setkvis deleted.
Send raw APDUs. Multiple APDUs can be supplied as separate arguments or separated by ; or , in a single argument. APDUs can be continuous hex (00A40400) or space-separated (00 A4 04 00).
Synopsis:
gpshell3 apdu [--auth] [--nostop|--ignore-errors] <APDU> [<APDU> ...]Options:
--auth: Perform default ISD selection and mutual authentication before sending APDUs.--nostop/--ignore-errors: Continue even if an APDU returns an error status (non-9000).
Compute the load-file data block hash of a CAP file.
Synopsis:
gpshell3 hash <cap-file> [--sha1|--sha256|--sha384|--sha512|--sm3]Default hash algorithm: sha256.
Generate a DAP signature from a precomputed hash.
Synopsis:
gpshell3 sign-dap aes [--output <file>] <hash-hex> <sd-aidhex> <hexkey>
gpshell3 sign-dap rsa [--output <file>] <hash-hex> <sd-aidhex> <pem>[:pass]Writes the signature bytes to stdout unless --output is provided.
Personalize an application by combining INSTALL [for personalization] and STORE DATA.
Synopsis:
gpshell3 store [--encryption <noinfo|app|enc>] [--format <noinfo|dgi|ber>] [--response <true|false>] <AIDhex> <datahex>Options:
--encryption(defaultnoinfo):noinfo: no encryption information;app: application-dependent encryption;enc: encrypted with data encryption key.
--format(defaultnoinfo):noinfo: raw data, no structural information;dgi: DGI structures;ber: BER-TLV structures.
--response <true|false>: expect response data (defaultfalse).
Read a bundle of card data objects, in this order:
- iin (Issuer Identification Number / SD Provider Identification Number, tag
0x42) - cin (Card Image Number / SD Image Number, tag
0x45) - CPLC
- card-info (Card Recognition Data, tag
0x66) - card-cap (Card Capability Information, tag
0x67) - confirm-counter (tag
0xC2) - seq-counter (tag
0xC1) - div-data (Diversification Data, tag
0xCF)
This command does not require authentication.
Example:
gpshell3 card-dataRead and decode the Card Production Life Cycle (CPLC) data. This command does not require authentication.
Example:
gpshell3 cplcRead Issuer Identification Number / SD Provider Identification Number (tag 0x42). This command does not require authentication.
Example:
gpshell3 iinRead Card Image Number / SD Image Number (tag 0x45). This command does not require authentication.
Example:
gpshell3 cinRead and decode GlobalPlatform Card Recognition Data (Card Data tag 0x66). This command does not require authentication.
Example:
gpshell3 card-infoRead and decode GlobalPlatform Card Capability Information (Card Capability Information tag 0x67). This command does not require authentication.
Example:
gpshell3 card-capRead extended card resource information (number of installed applications and free memory). This command does not require authentication.
Example:
gpshell3 card-resourcesRead diversification data (tag 0xCF). This command does not require authentication.
Example:
gpshell3 div-dataRead the Sequence Counter of the default Secure Channel key set (tag 0xC1). This command does not require authentication.
Example:
gpshell3 seq-counterRead the Confirmation Counter (tag 0xC2). This command does not require authentication.
Example:
gpshell3 confirm-counterPrivileges are reported by list-apps as priv=[...]. A subset can be supplied to install --priv as a comma-separated list of short names.
Accepted by install --priv:
sd— Security Domaindap-verif— DAP Verificationdelegated-mgmt— Delegated Managementcm-lock— Card Manager Lock privilegecm-terminate— Card Manager Terminate privilegedefault-selected— Default Selected (does not imply on-reset default)pin-change— PIN Changemandated-dap— Mandated DAP Verification
Additional privilege names that may appear in list-apps output:
authorized-mgmt— Authorized Managementtoken-mgmt— Token Verificationglobal-delete— Global Deleteglobal-lock— Global Lockglobal-registry— Global Registryfinal-application— Final Applicationglobal-service— Global Servicereceipt-generation— Receipt Generationciphered-load-file-data-block— Ciphered Load File Data Blockcontactless-activation— Contactless Activationcontactless-self-activation— Contactless Self Activation
Note: Not all privileges are applicable to all element types. Refer to the GlobalPlatform Card Specification for details.
Install an applet with parameters and explicit privileges:
gpshell3 install --priv default-selected --params 80 ./helloworld.capList applets and related:
gpshell3 list-appsOpen APDU session with mutual auth and send GET DATA:
gpshell3 apdu --auth "80CA006600"Put authentication keys:
put-auth --enc 404142434445464748494a4b4c4d4e4f --mac 404142434445464748494a4b4c4d4e4f --dek 404142434445464748494a4b4c4d4e4fCompute CAP hash and sign DAP (AES):
HASH=$(gpshell3 hash ./helloworld.cap | tr -d '\n')
gpshell3 sign-dap aes --output dap.sig "$HASH" A000000151000000 00112233445566778899AABBCCDDEEFF0on success- non-zero on error (APDU errors produce non-zero unless
apdu --nostopis used)
- PC/SC stack and a compatible card reader
- GlobalPlatform-compliant card
gpshell(1), GlobalPlatform Card Specification