Expand description
BEGIN / END R-MAC SESSION (CLA 80, INS 7A / 78) — SCP02 response integrity.
These frame an SCP02 R-MAC session: BEGIN R-MAC SESSION tells the card to
start appending an R-MAC to each response, and END R-MAC SESSION retrieves
(and optionally ends) the accumulated R-MAC. They build the plaintext
C-APDU only; the session/backend applies CLA | 0x04 + C-MAC afterwards (the
commands must themselves be sent inside the secure channel).
Coding (GPCS v2.3.1 Appendix E; the parameter tables mirror Amendment D
§7.x for SCP03, and are cross-checked byte-for-byte against the skythen/scp02
Go reference, beginRMACSession/EndRMACSession):
- BEGIN: INS
0x7A, P10x10(each response carries an R-MAC — for SCP02 which has no response encryption,0x30/R-ENC does not apply), P20x00. The data field is an LV-coded ‘data’ element (len ‖ data). The card does not interpret ‘data’ but folds it into the R-MAC, letting the host inject a challenge; the LV total is ≤ 25 bytes, sodatais1..=24bytes. - END: INS
0x78, P10x00, P20x03(end the session and return the R-MAC) or0x01(return the current R-MAC without ending). No data field;Le = 00requests the 8-byte R-MAC in the response.
Functions§
- begin_
rmac_ session - Build a
BEGIN R-MAC SESSION(CLA 80, INS 7A) plaintext C-APDU. - end_
rmac_ session - Build an
END R-MAC SESSION(CLA 80, INS 78) plaintext C-APDU.end_sessionselects P20x03(end and return the R-MAC) vs0x01(return only). The response returns the 8-byte R-MAC, soLe = 00is present.