You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document assumes a familiarity with The Specification and as such uses terms and abbreviations from The Specification without further explanation.
ASN.1
BER-TLV - Tag-Length-Value
Tag
Length
Value
1 or more bytes
1 or more bytes encoded as an integer
0 or more bytes, depending on the length
Length
While ASN.1 has a variety of length encodings, the OpenPGP application uses the following:
Length
Encoding
0-127
1 byte; short form
0-255
2 bytes; 81nn
0-65535
3 bytes; 82nn nn
Compact-TLV
Tag and length share the first byte.
Bits
Description
8-5
Tag
4-1
Length; simple 4-bit integer
Interpreting SW1/SW2
The implementation shall correctly interpret the SW1 and SW2 bytes in order to correctly process responses from the card.
Minimal Use-Cases
Required to achieve minimally functional OpenPGP operations.
Based on the basic flow charts in section 9 of The Functional Specification.
Do not support logical channels.
Uses CLA=X0 for all commands.
Do not support extended length APDUs.
Do not support KDF.
Application Selection
Command
CLA
INS
P1
P2
Lc
Data
Le
SELECT
00
A4
04
00
06
D2 76 00 01 24 01
00
Response Body
Tag
Description
FCI
6F
When P2=00 none returned; SW1/SW2=9000
FCP
62
When P2=04 none returned; SW1/SW2=6D00
FMD
64
When P2=08 none returned; SW1/SW2=6D00
Status
SW1
SW2
Description
90
00
Success - no other information
62
83
Selceted file invalidated
84
FCI not formatted according to ISO 7816-4
6A
81
Function not supported
82
File not found
86
Incorrect parameters P1-P2
87
Lc inconsistent with P1-P2
6D
00
Instruction code not supported or invalid
Reading main DOs
Application Related Data - Tag 6E
Command
CLA
INS
P1
P2
Lc
Data
Le
GET DATA
00
CA
00
6E
-
-
00
Response Body
Tag
Size
Description
Application related data
6E
sz
Followed by any of,
Application identifier (AID)
4F
sz
Full application identifier.
Historical bytes
5F52
See sections below.
Extended length information
7F66
08
General feature management data
7F74
03
Discretionary data objects
73
sz
Followed by any of,
Extended Capabilities
C0
0A
Algorithm attributes signature
C1
sz
Algorithm attributes decryption
C2
sz
Algorithm attributes authentication
C3
sz
PW status bytes
C4
07
Fingerprints
C5
3C
3x20 bytes; signature, decryption, authentication in that order. Zero bytes indicates not present.
CA-Fingerprints
C6
3C
3x20 bytes; signature, decryption, authentication in that order. Zero bytes indicates not present.
Key generation date
CD
0C
3x4 bytes; UNIX epoch time. Zero bytes indicates not specified.
For "query", handles 6A80 as ISO7816_VERIFY_NO_PIN.
For "unverify", doesn't seem to support this at all. I cannot find any APDU for CLA=00,INS=20,P1=FF in the codebase.
Compute Digital Signature
Command
CLA
INS
P1
P2
Lc
Data
Le
PSO:CDS
00
2A
9E
9A
xx
xx xx xx xx xx xx
00
Response
SW1
SW2
Description
90
00
Success - no other information
69
82
Security status not satisified. PW wrong. PW not checked (command not allowed).
Data field
DigestInfo created using a hash algorithm of the supported algorithms specified in the algorithm attributes for the signature key. The digest itself is taken from the contents of the signature packet.
RSA DigestInfo
Using SHA-256
Hash-code length
32 (decimal)
Tag
Length
Value
30
31
30
0D
06
09
608648016503040201
05
00
-
04
20
32-byte hash-code
Using SHA-384
Hash-code length
48 (decimal)
Tag
Length
Value
30
41
30
0D
06
09
608648016503040202
05
00
-
04
30
48-byte hash-code
Using SHA-512
Hash-code length
64 (decimal)
Tag
Length
Value
30
51
30
0D
06
09
608648016503040203
05
00
-
04
40
64-byte hash-code
Decrypt Message
Command
CLA
INS
P1
P2
Lc
Data
Le
PSO:DEC
00
2A
80
86
xx
xx xx xx xx xx xx
00
RSA
Data field is padded with 00 padding indicator byte.
Some questions regarding the section 7.2.11 PSO:DECIPHER statement
In case of the RSA algorithm the command input (except padding indicator byte) shall be formatted according to PCKS#1 before encryption.
Description
Length
Value
Start byte
1
00
Block type
1
02
Padding string (PS)
N -3 - L
Non-zero random bytes
Separator
1
00
Data
L
Message
...The card decrypts all bytes after the padding indicator byte, checks the conformance of correct PKCS#1 padding and returns the plain text (length = message) in the response.
I'm unsure if this means that the above table is how content must be provided to PSO:DECIPHER, or what?