Applet Commands
1 Contents
2 Overview
This section describes the OpenFIPS201 interface, including communications, command and data interfaces.
3 Communications (ISO 7816 and ISO 14443)
3.1.1 Application Identifier (AID)
The PIV AID is specified by the standard [SP800-73]:
A0 00 00 03 08 00 00 10 00 01 00
The standard requires that this AID be used as the PIV application, however there may be use cases where you wish to have two or more instances on a card, for instance in multi-domain card configurations. You will need to have multi-instance aware middleware to achieve this.
3.1.2 Communications
OpenFIPS201 is intended to be used on cards that support ISO 7816 Part 4 (T=0 and T=1) and ISO 14443 Part 4 (T=CL) framing.
Only ISO 7816 single-length APDU formatting supported. Any extended-length APDU sent to the card will be rejected with an error.
ISO 7816 command chaining and GET RESPONSE is supported for the following commands:
VERIFY
GENERAL AUTHENTICATE
PUT DATA
GENERATE ASYMMETRIC KEYPAIR
PUT DATA ADMIN
CHANGE REFERENCE DATA ADMIN
3.1.3 Card Selection
For ISO 7816-4 interface, whilst the ATR value is not mandatory, it is recommended that cards predominantly used for PIV include the PIV AID in their Historical Bytes field (tag ‘F9’)
3.1.4 Inter-Industry Commands
To facilitate applet selection and Secure Channel functionality, the following ISO 7816 inter-industry commands are implemented:
INITIALIZE UPDATE (INS = ‘50’)
EXTERNAL AUTHENTICATE (INS = ‘82’)
SELECT (INS = 'A4')
GET RESPONSE (INS = ‘C0’)
More detail on these inter-industry commands can be found in the ISO 7816 standard [ISO-7816-4].
4 Commands - ISO Inter-Industry
4.1 Command - SELECT
Command | |
---|---|
CLA | ‘00’ |
INS | ‘A4’ |
P1 | ‘04’ |
P2 | ‘00’ |
LC | Variable - Length of Application Identifier |
Data | Either full or the right-truncated AID of the PIV Card Application: This value is always |
LE | ‘00’ |
Normal Response | |
DATA | The Application Property Template as described in [SP800-73-4] Part 2, 3.1 - Table 3 |
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Implementation Notes
|
4.2 Command - INITIALIZE UPDATE
Command | |
---|---|
CLA | ‘80’ |
INS | ‘50’ |
P1 | Key Version Number |
P2 | ‘00’ |
LC | Length of host challenge |
Data | Host challenge |
LE | ‘00’ |
Normal Response | |
DATA |
|
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Implementation Notes
|
4.3 Command - EXTERNAL AUTHENTICATE
Command | |
---|---|
CLA | ‘84’ |
INS | ‘82’ |
P1 | Security Level From GlobalPlatform Secure Channel Protocol 03 - Addendum D Specification
|
P2 | ‘00’ |
LC | Length of host cryptogram and MAC |
Data | Host cryptogram and MAC |
LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Implementation Notes
|
4.4 Command - GET RESPONSE
This command is used where a single response APDU frame is not large enough to return all the required data. This is defined as Response Chaining in [ISO 7816-4].
Command | |
---|---|
CLA | ‘00' |
INS | ‘C0’ |
P1 | ‘00’ |
P2 | ‘00’ |
LC | ‘00’ |
Data | Not Present |
LE | Maximum length of data expected in response |
Normal Response | |
DATA | Response Data |
STATUS |
|
Error Responses | |
STATUS |
|
Implementation Notes
|
5 Commands - Operational
5.1 Command - GET DATA
The GET DATA card command retrieves the data content of the single data object whose tag is given in the data field.
Command | |
---|---|
CLA |
|
INS | ‘CB’ |
P1 | ‘3F’ |
P2 | ‘FF’ |
LC | Length of data field |
Data | Tag list ‘5C’ as specified in [SP800-73] Part 2, 3.1.2 |
LE | ‘00’ |
Normal Response | |
DATA | Content of the requested data object, contained within the tag ‘53’ |
STATUS |
|
Error Responses | |
STATUS |
|
Command Pre-Conditions
Implementation Notes
|
5.2 Command - VERIFY
The VERIFY command is the used for a number of purposes, all around verification of the cardholder or reader:
Verify the local or global PIN
Verify the Pairing Code over Secure Messaging
Verify biometric minutiae for on-card biometric comparison (not currently supported)
Clear the verification status of a PIN, Pairing Code or Biometric
Return the number of remaining attempts for a PIN
Command | |
---|---|
CLA |
|
INS | ‘20’ |
P1 | Either:
|
P2 | PIN, Pairing Code or Biometric Reference |
LC | If P1 is ‘00’ (Verify):
If P1 is ‘FF’ (Reset Verification):
|
Data | If P1 is ‘00’ (Verify):
If P1 is ‘FF’ (Reset Verification):
|
LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Command Pre-Conditions
Implementation Notes
|
5.3 Command - CHANGE REFERENCE DATA
Command | |
---|---|
CLA |
|
INS | ‘24’ |
P1 | ‘00’ |
P2 |
|
LC | Variable |
Data | Current value, concatenated immediately with new value. |
LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Command Pre-Conditions
Implementation Notes
|
5.4 Command - RESET RETRY COUNTER
This command changes the value of the PIV Card Application PIN and resets the retry counter of the to its initial value. Its intended use is to allow a PIN reset / unblock by an authorised person (Security Officer role) or management system.
Command | |
---|---|
CLA | ‘00’ |
INS | ‘2C’ |
P1 | ‘00’ |
P2 | ‘80’ - PIV Card Application PIN |
LC | ‘10’ |
Data | Current PUK value, concatenated immediately with new PIN value. |
LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Command Pre-Conditions
Implementation Notes
|
5.5 Command - GENERAL AUTHENTICATE
All operational cryptographic commands are encapsulated under the ‘General Authentication’ command, including:
Authentication
Digital Signatures
Key Establishment
Secure Messaging
There are 6 authentication cases that make up all of the GENERAL AUTHENTICATE functionality.
Case |
| |
---|---|---|
1 | Internal Authenticate | The CLIENT presents a CHALLENGE to the CARD, which then returns the encrypted/signed CHALLENGE RESPONSE. This is handled in 3 different mode variants, depending on the key
|
2 | External Authenticate Request | The client requests a CHALLENGE from the CARD. |
3 | External Authenticate Response | The client presents a CHALLENGE RESPONSE to the CARD, which then verifies it. |
4 | Mutual Authenticate Request | The client requests a WITNESS (a proof of key possession) from the CARD. The card generates the WITNESS, encrypts it and returns it as ciphertext. |
5 | Mutual Authenticate Response | The client decrypts the received WITNESS, generates a CHALLENGE REQUEST and presents both to the CARD. The card verifies the decrypted WITNESS and encrypts the CHALLENGE, which it then returns as the CHALLENGE RESPONSE. |
6 | Key Establishment Scheme | The client requests an Elliptic Curve key agreement operation against the supplied exponentiation parameter. |
Command | |
---|---|
CLA |
|
INS | ‘87’ |
P1 | Requested mechanism (See TBD ref) |
P2 | Requested key reference (See TBD ref) |
LC | Variable |
Data | Dynamic Authentication Template (Tag ‘7C’) |
LE | Not present or ‘00’ |
Normal Response | |
DATA | Cryptographic operation output data |
STATUS |
|
Error Responses | |
STATUS |
|
Command Pre-Conditions
General
Case 1 - Internal Authenticate
Case 2 - External Authenticate Request
Case 3 - External Authenticate Response
Case 4 - Mutual Authenticate Request
Case 5 - Mutual Authenticate Response
Case 6 - Key Establishment Scheme
Implementation Notes
|
5.6 Command - PUT DATA
This command completely replaces the contents of a single data object in the PIV card application with new content.
Command | |
---|---|
CLA |
|
INS | ‘DB’ |
P1 | ‘3F’ |
P2 | ‘FF’ |
LC | Variable |
Data | BER-TLV of data object |
LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ - Success |
Error Responses | |
STATUS |
|
Command Pre-Conditions
Implementation Notes
|
5.7 Command - GENERATE ASYMMETRIC KEYPAIR
Command | |
---|---|
CLA |
|
INS | ‘47’ |
P1 | ‘00’ |
P2 | Key reference |
LC | Variable |
Data | Control reference template (See [SP800-73-4] Part 2, Table 11) |
LE | ‘00’ |
Normal Response | |
DATA | Public key value of generated key pair (See [SP800-73-4] Part 2, Table 12) |
STATUS |
|
Error Responses | |
STATUS |
|
Implementation Notes
|
6 Commands - Extended
The following commands extend the PIV command set, providing additional functionality for card management, status and key injection.
6.1 Command - PUT DATA ADMIN
This command permits management of the dynamic file system and configuration values.
This is an extended version of the PIV 'PUT DATA' command, with the following changes made:
The P1/P2 value must be set to 3F00 instead of 3FFF used by the normal PUT DATA command.
The command will only work under a Secure Channel Protocol session with the CENC and CMAC options set
The data content must conform to the basic ASN.1 structure defined below and encoded using BER-TLV.
Command | |
---|---|
CLA | ‘0C’ - Secure Messaging |
INS | ‘DB’ |
P1 | ‘3F’ |
P2 | ‘00' |
LC | Variable |
Data | One of the following objects encoded using BER-TLV:
(For details and examples of these command objects, see Appendix - ASN.1 Schema) |
LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ |
Error Responses | |
STATUS |
|
Implementation Notes
|
6.2 Command - CHANGE REFERENCE DATA ADMIN
The PIV standard defines commands to write data objects, generate asymmetric keys and change PIN values. It does not however define any administrative mechanism to inject key values.
This is always necessary for symmetric keys (such as 9B and optionally 9E), but only required for asymmetric keys (9A, 9C, 9D, 9E and retired keys) if they have been generated off-card (i.e. inside a HSM).
OpenFIPS201 supports key injection to address this need, as well as securely configuring default PIN/PUK values.
6.2.1 Key Injection Command
This command is the equivalent of the CHANGE REFERENCE DATA command APDU, however it is intended to operate on key references that are NOT listed in SP800-73-4.
The main differences to CHANGE REFERENCE DATA are:
It supports updating any key reference that is not covered by CHANGE REFERENCE DATA already
The command will only work under a Secure Channel Protocol session with the CENC and CMAC options set
It does NOT require the old value to be supplied in order to change a key
It also supports updating the PIN/PUK values without requiring knowledge of the old value (The value of P1 does is ignored for PIN/PUK updates)
The APDU supports command chaining for large key values
The data content for this command depends on whether you are updating a PIN or a KEY reference.
For KEY references, the data contains a BER-TLV formatted ASN.1 object.
Command | |
---|---|
CLA | ‘0C’ - Secure Messaging |
INS | ‘24’ |
P1 | ‘00’ |
P2 | Key Reference |
LC | Variable |
Data | Where
Where the value of
|
_LE | Not present |
Normal Response | |
DATA | Not present |
STATUS | ‘9000’ |
Error Responses | |
STATUS |
|
Implementation Notes
|
6.3 Command - GET STATUS
This command is equivalent to the PIV GET DATA
command, with the following differences:
The value of
P2
is 00 instead of FF to indicate this is an extended GET DATA command.The tag reference is
2F4753h
, which equates to the ASCII value/GS
.
Command | |
---|---|
CLA | ‘00’ |
INS | ‘CB’ |
P1 | ‘3F’ |
P2 | ‘00’ |
LC | ‘05’ |
Data | ‘5C032F4753’ |
LE | ‘00’ |
Normal Response | |
DATA | A GetStatusResponse object encoded in BER-TLV format (See Appendix - ASN.1 Schema) |
)STATUS | ‘9000’ |
Error Responses | |
STATUS |
|
Command Pre-Conditions
Implementation Notes
|
6.4 Command - GET VERSION
This command is equivalent to the PIV GET DATA
command, with the following differences:
The value of
P2
is 00 instead of FF to indicate this is an extended GET DATA command.The tag reference is
2F4756
, which equates to the ASCII value/GV
.
Command | |
---|---|
CLA | ‘00’ |
INS | ‘CB’ |
P1 | ‘3F’ |
P2 | ‘00’ |
LC | ‘05’ |
Data | ‘5C032F4756’ |
LE | ‘00’ |
Normal Response | |
DATA | A GetVersionResponse object encoded in BER-TLV format (See Appendix - ASN.1 Schema) |
STATUS | ‘9000’ |
Error Responses | |
STATUS |
|
Implementation Notes
|