Mac
Specification
This operation requests the server to perform a Message Authentication Code (MAC) operation on provided data using a specified MAC key and algorithm. The operation can be performed in a single request or as a series of requests for long data streams or by-parts cryptographic operations.
The response contains the MAC value or correlation value for streamed operations.
When a stream or by-parts operation is requested:
- The server SHALL create a unique identifier, called correlation value if Init Indicator is True.
- The server SHALL expect one or more requests with the same correlation value if Init Indicator is True.
- The server SHALL return the Correlation Value in the response if Init Indicator is True.
- The server SHALL use the Correlation Value for subsequent MAC requests.
- The server SHALL close the stream or by-parts operation when Final Indicator is True.
Implementation
The Eviden KMS server supports the following MAC algorithms:
- HMAC-SHA-1 (NIST SP 800-131A Rev. 2 โ Acceptable)
- HMAC-SHA-224 (NIST SP 800-131A Rev. 2 โ Acceptable)
- HMAC-SHA-256
- HMAC-SHA-384
- HMAC-SHA-512
- HMAC-SHA3-224, HMAC-SHA3-256, HMAC-SHA3-384, HMAC-SHA3-512 (keys of algorithm
HMACSHA3224toHMACSHA3512can be created) - AES-CMAC (NIST SP 800-38B) with AES-128, AES-192 and AES-256 keys
- AES-GMAC (NIST SP 800-38D) with AES-128, AES-192 and AES-256 keys
For the complete list of supported MAC algorithms, please check the algorithms page.
The hash function is taken from the request Hashing Algorithm, else from the request Cryptographic Algorithm
(HMACSHA*; any other value returns Bad_Cryptographic_Parameters), else from the key's algorithm. Unsupported
hash functions return Feature_Not_Supported.
The key's Cryptographic Usage Mask is not enforced, so keys created by earlier versions or by other clients keep
working. HMAC keys created by the server get the MAC Generate and MAC Verify bits. A key in the wrong state returns
Wrong_Key_Lifecycle_State and a usable object of the wrong type Invalid_Object_Type.
A request with both Init Indicator and Final Indicator but no Correlation Value is a single-part request.
A single-part MAC without Data returns Invalid_Field. HSM keys cannot be used for multi-part MAC
(Feature_Not_Supported).
MAC Verify
MAC Verify accepts Active, Deactivated and Compromised keys. It supports multi-part requests: the MACData to check
may be sent on the Init or the Final part, and a missing MACData at the end returns Invalid_Field. The
ValidityIndicator is returned only on single-part or final responses. The comparison runs in constant time.
AES-CMAC and AES-GMAC
The request Cryptographic Parameters select the algorithm: Block Cipher Mode = CMAC for AES-CMAC and
Block Cipher Mode = GCM for AES-GMAC, with Cryptographic Algorithm = AES (any other algorithm returns
Bad_Cryptographic_Parameters). No Hashing Algorithm is needed. The key must be an AES key with the
MAC Generate / MAC Verify usage bits; an HMAC or any non-AES key returns Bad_Cryptographic_Parameters. A
default AES key does not carry these bits: create it with a KMIP Create request whose Cryptographic Usage Mask
includes them, or import it with ckms sym keys import -f aes <file> --key-usage mac-generate --key-usage mac-verify.
Both algorithms support multi-part requests. The CMAC block cipher mode is part of the default KMIP algorithm
policy; GMAC relies on the already allowed GCM.
- AES-CMAC:
MACDatais the 16-byte tag. - AES-GMAC: a GMAC IV must never repeat under one key, so by default the server generates a random 96-bit IV
and
MACDatais the 28 bytesIV (12 bytes) || tag (16 bytes). A FIPS build always generates it inside the OpenSSL FIPS provider (NIST SP 800-38D ยง9.1, FIPS 140-3 IG C.H) and refuses an IV in the request withInvalid_Field. A non-FIPS build lets a client that must choose the IV (PKCS#11CKM_AES_GMAC) send it in theIVCounterNoncefield of theMACrequest, a vendor extension (KMIP 2.1MAChas no IV field): it must be 12 bytes and is accepted for GMAC only, otherwiseInvalid_Field; on an HSM key it returnsFeature_Not_Supported.MACDatais stillIV || tag, and the caller must ensure the IV is unique. MAC Verify reads the IV from the first 12 bytes;MACDataof another length returnsInvalid_Field, and for a multi-part verificationMACDatamust be sent on the Init part because it carries the IV. The server counts the GMACs of each key and failsMACwithPermission_Deniedafter 2^32 of them (NIST SP 800-38D ยง8.3). - HMAC: a FIPS build refuses to generate an HMAC with a key under 14 bytes (112 bits, NIST SP 800-131A r2); the pedantic FIPS provider also refuses verification with such a key.
ckms mac compute --mac-key-id <AES_KEY_ID> --mode cmac --data 6bc1bee22e409f96e93d7e117393172a
ckms mac compute --mac-key-id <AES_KEY_ID> --mode gmac --data 6bc1bee22e409f96e93d7e117393172a
Example - Simple MAC
Computing MAC with SHA3-512 using a MAC key.
Corresponding KMS CLI command:
ckms mac --mac-key-id 027cced1-ff2b-4bd3-a200-db1041583bdc --algorithm sha3-512 --data 0011223344556677889900
{
"tag": "Mac",
"type": "Structure",
"value": [
{
"tag": "UniqueIdentifier",
"type": "TextString",
"value": "027cced1-ff2b-4bd3-a200-db1041583bdc"
},
{
"tag": "CryptographicParameters",
"type": "Structure",
"value": [
{
"tag": "HashingAlgorithm",
"type": "Enumeration",
"value": "SHA3512"
}
]
},
{
"tag": "Data",
"type": "ByteString",
"value": "0011223344556677889900"
}
]
}
Example - Stream MAC
Computing MAC for a large file in multiple parts using HMAC-SHA-256. The Init response returns a 16-byte random
Correlation Value; every later part sends it back unchanged. The MAC shown is the one of the
hmac_sha256_multi_part test vector, computed with that vector's key.
Corresponding KMS CLI commands:
# First part with init indicator
ckms mac --mac-key-id 027cced1-ff2b-4bd3-a200-db1041583bdc --algorithm sha256 --data 0102 -i
# Middle part using correlation value
ckms mac --mac-key-id 027cced1-ff2b-4bd3-a200-db1041583bdc --algorithm sha256 --correlation-value 0123456789ABCDEF0123456789ABCDEF --data 030405060708091011121314
# Final part with final indicator
ckms mac --mac-key-id 027cced1-ff2b-4bd3-a200-db1041583bdc --algorithm sha256 --correlation-value 0123456789ABCDEF0123456789ABCDEF -f --data 1516
{
"tag": "Mac",
"type": "Structure",
"value": [
{
"tag": "UniqueIdentifier",
"type": "TextString",
"value": "027cced1-ff2b-4bd3-a200-db1041583bdc"
},
{
"tag": "CryptographicParameters",
"type": "Structure",
"value": [
{
"tag": "HashingAlgorithm",
"type": "Enumeration",
"value": "SHA256"
}
]
},
{
"tag": "Data",
"type": "ByteString",
"value": "0102"
},
{
"tag": "InitIndicator",
"type": "Boolean",
"value": true
}
]
}