verify_mac
Verify a Message Authentication Code (MAC) on received payment messages or issuer scripts, using the same key and algorithm parameters as generation to confirm data integrity and authenticity.
Instructions
Call this to verify a MAC on a received payment message or issuer script. Mirrors generate_mac — use the same algorithm and key.
CMAC truncation warning: verify_mac with CMAC requires the FULL MAC value (16 bytes / 32H for AES-128). Passing a truncated CMAC — e.g. 4 bytes / 8H produced by payShield M6 with mac_size=0 — returns ValidationException with no descriptive error message. ISO 9797-1 Alg 1/3 produce 4-byte MACs natively and are not affected.
Workaround for truncated CMAC verify (e.g. bridging a payShield M8 flow):
Call generate_mac with the same key and message.
Compare the leading mac_length bytes of the returned 32H MAC against the received value. This costs one extra APC call per verify.
Args: key_identifier: ARN or alias of MAC key message_data: Hex-encoded message that was authenticated mac: Hex-encoded MAC value to verify (CMAC: must be full 32H, not truncated) verification_attributes: MAC algorithm parameters (mirrors generate_mac) mac_length: MAC length in nibbles/hex-digits (NOT bytes): 8=4-byte MAC, 16=8-byte MAC; must match the value used during generation
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mac | Yes | ||
| mac_length | No | ||
| message_data | Yes | ||
| key_identifier | Yes | ||
| verification_attributes | Yes |