TR-31 optional block data
A TR-31 key block can contain standard defined optional blocks and optional blocks with IBM-defined data.
See ANSI X9.143-2022: Retail Financial Services Interoperable Secure Key Block Specification for the definition of a TR-31 key block and for a full list of standard defined optional blocks. A TR-31 key block can contain one or more optional blocks. A TR-31 key block contains at least one optional block when byte numbers 12 - 13 are a value other than ASCII string "00".
DA optional block
The DA optional block is a standard optional block used to define derivations allowed for
derivation keys. That is to say, it allows the user to set which types of keys a derivation key can
create. The DA optional block can only be set in a TR-31 key block with TR-31 key usage
B3, otherwise it is not allowed. This block will contain one or more sets of key
attributes, up to a maximum of 49 sets, contained in 5 byte ASCII strings. Each string will contain
key usage, algorithm, TR-31 mode of key use, and exportability. For example,
imagine you want to limit your B3 TR-31 key token to only generate PIN encryption
keys, that use the TDEA algorithm, and that are only allowed to encrypt, and that are exportable.
For these attributes and purposes, you would place the following string into your DA optional block:
P0TEE
Here are a few other examples and their breakdowns:
P0TDE (P0, T, D, E)
- Only the following derivation is allowed: PIN Encryption key usage P0, TDEA algorithm, Decrypt only TR-31 mode of key use, Exportable
P0TEED0AEN (P0, T, E, E, D0, A, E, N)
- First Derivation allowed: PIN Encryption key usage P0, TDEA algorithm, Encrypt only mode of use, Exportable
- Second Derivation allowed: Symmetric Data Encryption key usage D0, AES algorithm, Encrypt Only mode of use, Not Exportable
IBM-defined optional block
The control vector is only copied from the CCA key-token when the user of the TR31 Translate verb specifies a control vector transport control keyword (INCL-CV or ATTR-CV):
- If the optional block contains a control vector as the result of specifying the INCL-CV keyword during export, the key usage and mode of use fields indicate the key attributes, and these attributes are verified during export to be compatible with the ones in the included control vector.
- If the optional block contains a control vector as the result of specifying the ATTR-CV keyword during export, the key usage field (byte number 5 - 6 of the TR-31 key block) is set to the proprietary value 10 (X'3130'), and the mode of use field (byte number 8) is set to the proprietary value 1 (X'31'). These proprietary values indicate that the key attributes are specified in the included control vector.
| Offset (bytes) | Length (bytes) | Description |
|---|---|---|
| 00 | 02 | Proprietary ID of TR-31 optional block (alphanumeric-ASCII):
|
| 02 | 02 | Length of optional block (hex-ASCII): For TLV valued to 01:
For TLV valued to 02:
|
| 04 | 04 | Magic value (alphanumeric-ASCII):
|
| 08 | 02 | Tag-length-value (TLV) ID (numeric-ASCII):
|
| 10 | 02 | Length of TLV (hex-ASCII) For TLV valued to 01:
For TLV valued to 02:
|
| 12 | 16, 24, or 32 | For TLV ID X’3031’: This should be 16 or 32 bytes long and contain the control vector (hex- ASCII) |
IBM optional block internal controls
The IBM optional block with TLV ID ’02’ (X’3032’) consists of 12 bytes that are represented using 24 hex ASCII bytes. The 12 bytes are built as follows:
- The first four bytes are general bytes applicable to all optional blocks.
- The second four bytes are type specific and only used for certain TR-31 key usages. Currently
only the first byte of this set is used. These bytes will be set to zero if they are
unused.Note: For CCA 8.1, these controls (the controls specified in the second four bytes) are not added, and the first bit of this byte (bit 32) is set to 1 to indicate that there are NO CONTROLS ADDED YET. Anything else that is in the byte is ignored if bit 32 is set to 1. When further controls are added, this should be set to 0 to indicate that this byte information should be used.
- The last four bytes are reserved for future use and should be set to 0.
The first byte (offset 12) with bit fields 0 through 7 set as 00000ceD is a general flag byte applicable for all optional blocks. The flags are as follows:
- Bit 0: reserved, 0
- Bit 1: reserved, 0
- Bit 2: reserved, 0
- Bit 3: reserved, 0
- Bit 4: reserved, 0
- Bit 5: 1 = Compliance Tag (see c in 00000ceD)
- Bit 6: 1 = CPACF export bit control (see e in 00000ceD)
- Bit 7: 1 = Only usable in DK services, DKPINOP/KUF equivalent (see D in 00000ceD)
The following three bytes are used as the KDF indicator and should be set as follows:
- Second byte (offset 13): 0x00
- Third byte (offset 14): 0x00
- Fourth byte (offset 15), KDF indicator:
- 0x00: No KDF / comp-tag indicator
- 0x04: Comp-tag KDF for TR-31
| Key Usage | <00...07> | <08...15> | <16...23> | <24...31> | <32...39> | <40...95> |
| All Types | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000000 | reserved |
| B0 | 00000ceD | 00000000 | 00000000 | 00000K00 | x00000xx | reserved |
| B1 | 00000ceD | 00000000 | 00000000 | 00000K00 | x00000xx | reserved |
| B3 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| C0 | 00000ceD | 00000000 | 00000000 | 00000K00 | x00000xx | reserved |
| E0 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| E1 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| E2 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| E3 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| E4 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| E5 | 00000ceD | 00000000 | 00000000 | 00000K00 | x0000xxx | reserved |
| F1 | 00000ceD | 00000000 | 00000000 | 00000K00 | x00000xx | reserved |
| K0 | 00000ceD | 00000000 | 00000000 | 00000K00 | x000000x | reserved |
| M0 | 00000ceD | 00000000 | 00000000 | 00000K00 | x000000x | reserved |
| V0 | 00000ceD | 00000000 | 00000000 | 00000K00 | x000xxxx | reserved |
| V1 | 00000ceD | 00000000 | 00000000 | 00000K00 | x000000x | reserved |