DES-MAC
The original block-cipher MAC: secure only for fixed-length messages
Practical attacks exist. Present for compatibility and research only. Reach it with NextSSL(root=True) in Python or the nextssl_root_* functions in C.
About DES-MAC
DES-MAC is one of 2 CBC-MAC and DES-MAC variants in the NextSSL registry, a message authentication code. It uses an 8-byte (64-bit) key, an 8-byte (64-bit) authentication tag and an 8-byte (64-bit) block. Its registry entry cites FIPS 113 (withdrawn) and ANSI X9.9. NextSSL lists it in the broken tier and exposes it through the root API only (NextSSL(root=True) in Python, nextssl_root_* in C).
Overview
CBC-MAC computes a tag by encrypting a message in CBC mode with a zero IV and keeping the last ciphertext block. It is one of the oldest MAC constructions, standardised for DES as DES-MAC in ANSI X9.9 and FIPS 113.
CBC-MAC XORs each message block into the previous cipher output and encrypts the result. When all messages have the same fixed length, this is a secure pseudo-random function. When lengths vary, an attacker who knows the tags of two messages can construct a third valid message-tag pair by splicing, because the tag of one message is the chaining value for the next. This led to the development of CMAC, which fixes the problem with subkey masking.
NextSSL includes generic CBC-MAC as described in ISO/IEC 9797-1 algorithm 1 and DES-MAC from the withdrawn FIPS 113, both for legacy interoperability. Some protocols prepend the length or use a separately derived final key, as EMAC and ISO/IEC 9797-1 algorithm 2 do, to make CBC-MAC safe for variable lengths. CCM mode uses CBC-MAC internally, with the length encoded in the first block.
History
1985–2001Specified in FIPS 113
Specified in NIST SP 800-38A
Security notes
Plain CBC-MAC is forgeable for variable-length messages and must not be used unless the length is fixed and authenticated. DES-MAC additionally relies on 56-bit DES and is broken by exhaustive key search. Use CMAC or HMAC instead.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| key | 8 | Secret key |
| tag | 8 | Authentication tag |
| block | 8 | Block |
Use it
from nextssl_demo import NextSSL
root = NextSSL(root=True) # tier 'broken' is reachable from the root API only
key = root.random(8)
tag = root.call("mac", "des-mac", None, key, b"message", 0)[0]
ok = root.check("mac_verify", "des-mac", None, key, b"message", tag)
nextssl_root_mac("des-mac", NULL, key, data, 0, tag);
nextssl_root_mac_verify("des-mac", NULL, key, data, tag);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_mac_in(reg::all(), Policy::Any, "des-mac", &Params::new())?;
let tag = alg.tag(&key, b"message")?;
let ok = alg.verify(&key, b"message", &tag)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other CBC-MAC and DES-MAC variants
1Similar names
Looking for something else?More message authentication codes
All 30Frequently asked questions
What is DES-MAC?
DES-MAC is a MAC in the CBC-MAC and DES-MAC family. CBC-MAC computes a tag by encrypting a message in CBC mode with a zero IV and keeping the last ciphertext block.
What are the DES-MAC sizes?
In NextSSL, DES-MAC uses: key 8 bytes, tag 8 bytes, block 8 bytes.
Who designed DES-MAC and when?
DES-MAC belongs to the CBC-MAC and DES-MAC family, first published in 1985. Its origin: ANSI X9.9; FIPS 113 (withdrawn); ISO/IEC 9797-1.
Which standards define DES-MAC?
DES-MAC is referenced by FIPS 113 (withdrawn), ANSI X9.9.
Is DES-MAC safe to use?
DES-MAC is in the broken tier. Practical attacks exist. Present for compatibility and research only. It is only reachable through the root API (NextSSL(root=True) in Python, nextssl_root_* in C).
What other CBC-MAC and DES-MAC variants are there?
NextSSL also registers cbc-mac in the CBC-MAC and DES-MAC family.