This command allows secure data decryption or symmetric key derivation using an internal EC key from the device’s BIP32 seed tree. Inspired by OpenPGP smartcards, it enables asymmetric encryption and decryption using a fixed derivation path, ensuring that only the private key securely stored on the card can decrypt the content encrypted using the corresponding public key.
This command supports two operational modes:
def decrypt(pub_key: Any, PIN: str):
card.decrypt(pub_key, PIN)
For example, decrypt(pub_key, ”123456”)
📘 Note
Application Protocol Data Unit (APDU) Components
The following table outlines the components of the Application Protocol Data Unit (APDU).
Field | Description | Value |
CLA | This field specifies the class of the instruction. | 0x80 |
INS | This field specifies the particular command or operation that the smart card or secure element should execute. | 0xC4 |
P1 | First parameter of the instruction that specifies the details about the operation being requested. | provide symmetric key OR decrypt in card |
Data | Key data | PIN (in case not user auth) | PubKey | dataEncrypted (when P1=1) |
Decrypt Command Modes
Condition | Data Value |
P1 = 0x00 & Secure Channel Opened & No User Auth (PIN required) & Data Length = 74 bytes |
|
P1 = 0x00 & Secure Channel Opened & User Authenticated via Signature (no PIN) & Data Length = 65 bytes |
|
P1 = 0x01 & Secure Channel Opened & No User Auth (PIN required) & Data Length ≥ 74 bytes & EncData % 16 == 0 |
|
P1 = 0x01 & Secure Channel Opened & User Authenticated via Signature (no PIN) & Data Length ≥ 65 bytes & EncData % 16 == 0 |
|
📘 Note
Response
The following table outlines the possible responses that you will receive
Response Code | Description |
0x9000 | Success |
0x6A80 | The data length is not correct |
0x6985 | No key/seed loaded |
0x63Cx | The PIN is not correct |
0x6982 | (outside secure channel) The data input length is far too long |