Tools

    MAC calculator (ISO 9797-1, Retail MAC, AES-CMAC)

    ISO 9797-1 MAC, X9.19 Retail MAC and AES-CMAC.

    • Runs in your browser
    • No sign-up

    Input

    16 bytes · KCV (DES / TDES) 08D7B4

    MAC 15A6C3C6BAAFA0D2

    Result

    MAC (8 bytes)
    15A6C3C6BAAFA0D2
    Leftmost 4 bytes
    15A6C3C6

    Issuer script or host message MAC failing to verify? IDNTEQ can find the cause. EMV transaction troubleshooting

    About this tool

    Runs in your browser. This page loads no analytics or third-party scripts and does not send what you type.

    Compute a MAC over a message with ISO 9797-1 Algorithm 1 (DES CBC-MAC), Algorithm 3 (X9.19 Retail MAC) or AES-CMAC. Method 2 padding is applied by default.

    Algorithms

    The Retail MAC (ISO 9797-1 Algorithm 3) uses a 16-byte K1||K2 key: DES CBC-MAC under K1, then a final decrypt with K2 and encrypt with K1. EMV secure messaging and issuer scripts use this algorithm. AES-CMAC follows NIST SP 800-38B / RFC 4493 and handles its own sub-key padding.

    With ISO 9797-1 padding method 1 an empty message is padded to one block of zeros; method 2 pads it to 80 00 … 00. Without padding, the message must be a non-empty multiple of 8 bytes.

    The key length and KCV are shown under the key, so you can confirm the key before comparing MACs. Many messages carry a truncated MAC, so the leftmost 4 bytes (and, for AES-CMAC, the leftmost 8 bytes) are shown next to the full value. Published examples from RFC 4493 (AES-CMAC) and FIPS 81 (DES CBC-MAC) can be loaded to check the tool against a known value.

    Spec references

    • ISO 9797-1 (Algorithms 1 & 3)
    • ANSI X9.19 (Retail MAC)
    • NIST SP 800-38B / RFC 4493 (CMAC)

    Verified against

    Specifications
    • ISO/IEC 9797-1 MAC algorithms 1 and 3 (X9.19 Retail MAC), padding methods 1 and 2
    • NIST SP 800-38B / RFC 4493 (AES-CMAC)
    Published examples in the tests
    Other checks in the tests
    • Retail MAC against an OpenSSL construction on 40 messages; CBC-MAC as the last OpenSSL CBC block
    Inputs
    Key and message in hex; DES 8 bytes or a 16-byte K1||K2 key for the Retail MAC; AES 16, 24 or 32 bytes for CMAC.
    Not covered
    ISO 9797-1 algorithms 2, 4, 5 and 6, padding method 3 and HMAC are not offered.
    Last reviewed