4.2 Secure Messaging
All changes in this version
Title
Secure Messaging
Control
PIV secure messaging is used to protect the integrity and confidentiality of the PIV data being transmitted between the card and the relying system. PIV secure messaging shall be provided using symmetric session keys derived using the key establishment protocol defined Section 4.1 .
Once session keys are established and the card is authenticated as specified in Section 4.1 , subsequent communication with the card can be performed using secure messaging by setting bits b3 and b4 of the CLA byte of the command APDU to 1, resulting in a '0C' or '1C' CLA byte. If bits b3 and b4 of the CLA byte are set, then both the command and the response shall be encrypted and integrity protected as described in this section. If the PIV Card Application cannot encrypt and integrity protect the response (e.g., because it does not support secure messaging or no session keys have been established), the PIV Card Application shall return an error (see Section 4.2.7 ). In the case of command chaining, if bits b3 and b4 of the CLA are set in any command in the chain, then they shall be set in every command in the chain.
When secure messaging is used, the data field of the card command (or response) is encrypted first and then a message authentication code (MAC) is applied to the entire command (or response). When command (or response) chaining is required, the encryption and MAC are applied to the entire message and the result is then fragmented into separate command (or response) data fields.
In order to ensure that message reordering or replay attacks can be detected, a 16-byte MAC chaining value (MCV) is used. For the first command, and for the first response, sent after successful completion of the key establishment protocol the MCV consists of 16 bytes of '00'. For each subsequent command the MCV is the 16-byte MAC value computed on the previous command, and for each subsequent response the MCV is the 16-byte MAC value computed on the previous response. The MCV is included as part of the message over which the MAC value for each command (or response) is computed.
The SK ENC session key shall be used to encrypt the command data field and response data field as described in Section 4.2.2 . The SK MAC session key shall be used to add integrity to the command as described in Section 4.2.3 . The SK RMAC session key shall be used to add integrity to the response as described in Section 4.2.5 .
Secure messaging specified in this section can be applied to the following commands:
+ GET DATA
+ VERIFY
+ CHANGE REFERENCE DATA
+ GENERAL AUTHENTICATE