.. index:: single: cmac_protocol .. _cmac_protocol/0: .. rst-class:: right **protocol** ``cmac_protocol`` ================= Protocol for one-shot CMAC digest computation using block cipher objects implementing ``block_cipher_prepared_key_protocol``. | **Availability:** | ``logtalk_load(cmac(loader))`` | **Author:** Paulo Moura | **Version:** 1:0:0 | **Date:** 2026-08-08 | **Compilation flags:** | ``static`` | **Dependencies:** | (none) | **Remarks:** | (none) | **Inherited public predicates:** | (none) .. contents:: :local: :backlinks: top Public predicates ----------------- .. index:: digest/4 .. _cmac_protocol/0::digest/4: ``digest/4`` ^^^^^^^^^^^^ Computes the full CMAC digest for a block cipher object, key bytes, and message bytes. | **Compilation flags:** | ``static`` | **Template:** | ``digest(Cipher,KeyBytes,MessageBytes,DigestBytes)`` | **Mode and number of proofs:** | ``digest(+object_identifier,+list(byte),+list(byte),--list(byte))`` - ``one_or_error`` | **Exceptions:** | ``Cipher`` or ``MessageBytes`` is a variable or a partial list: | ``instantiation_error`` | ``Cipher`` does not implement the required prepared-key block cipher protocol: | ``domain_error(cmac_cipher,Cipher)`` | ``Cipher`` reports a block size other than 8 or 16 bytes: | ``domain_error(cmac_block_size,BlockSize)`` | ``MessageBytes`` is neither a variable nor a list: | ``type_error(list(byte),MessageBytes)`` | ``MessageBytes`` contains a non-integer byte: | ``type_error(integer,Byte)`` | ``MessageBytes`` contains an integer outside the byte range: | ``domain_error(byte,Byte)`` ------------ .. index:: hex_digest/4 .. _cmac_protocol/0::hex_digest/4: ``hex_digest/4`` ^^^^^^^^^^^^^^^^ Computes the full CMAC digest for a block cipher object, key bytes, and message bytes, returning a lowercase hexadecimal atom. | **Compilation flags:** | ``static`` | **Template:** | ``hex_digest(Cipher,KeyBytes,MessageBytes,HexDigest)`` | **Mode and number of proofs:** | ``hex_digest(+object_identifier,+list(byte),+list(byte),--atom)`` - ``one_or_error`` | **Exceptions:** | ``Cipher`` or ``MessageBytes`` is a variable or a partial list: | ``instantiation_error`` | ``Cipher`` does not implement the required prepared-key block cipher protocol: | ``domain_error(cmac_cipher,Cipher)`` | ``Cipher`` reports a block size other than 8 or 16 bytes: | ``domain_error(cmac_block_size,BlockSize)`` | ``MessageBytes`` is neither a variable nor a list: | ``type_error(list(byte),MessageBytes)`` | An element ``Byte`` of the `MessageBytes`` list is neither a variable nor an integer: | ``type_error(integer,Byte)`` | An element ``Byte`` of the ``MessageBytes`` list is an integer but not a valid byte: | ``domain_error(byte,Byte)`` ------------ .. index:: digest/5 .. _cmac_protocol/0::digest/5: ``digest/5`` ^^^^^^^^^^^^ Computes a truncated CMAC digest containing the requested number of leftmost bytes. | **Compilation flags:** | ``static`` | **Template:** | ``digest(Cipher,KeyBytes,MessageBytes,Length,DigestBytes)`` | **Mode and number of proofs:** | ``digest(+object_identifier,+list(byte),+list(byte),+integer,--list(byte))`` - ``one_or_error`` | **Exceptions:** | ``Length`` is a variable: | ``instantiation_error`` | ``Length`` is neither a variable nor an integer: | ``type_error(integer,Length)`` | ``Length`` is an integer outside the range from one through the cipher block size: | ``domain_error(cmac_output_length(1,BlockSize),Length)`` ------------ .. index:: hex_digest/5 .. _cmac_protocol/0::hex_digest/5: ``hex_digest/5`` ^^^^^^^^^^^^^^^^ Computes a truncated CMAC digest containing the requested number of leftmost bytes and returns it as a lowercase hexadecimal atom. | **Compilation flags:** | ``static`` | **Template:** | ``hex_digest(Cipher,KeyBytes,MessageBytes,Length,HexDigest)`` | **Mode and number of proofs:** | ``hex_digest(+object_identifier,+list(byte),+list(byte),+integer,--atom)`` - ``one_or_error`` | **Exceptions:** | ``Cipher``, ``MessageBytes``, or ``Length`` is a variable or a partial list: | ``instantiation_error`` | ``Cipher`` does not implement the required prepared-key block cipher protocol: | ``domain_error(cmac_cipher,Cipher)`` | ``Cipher`` reports a block size other than 8 or 16 bytes: | ``domain_error(cmac_block_size,BlockSize)`` | ``MessageBytes`` is neither a variable nor a list: | ``type_error(list(byte),MessageBytes)`` | An element ``Byte`` of the `MessageBytes`` list is neither a variable nor an integer: | ``type_error(integer,Byte)`` | An element ``Byte`` of the ``MessageBytes`` list is an integer but not a valid byte: | ``domain_error(byte,Byte)`` | ``Length`` is neither a variable nor an integer: | ``type_error(integer,Length)`` | ``Length`` is an integer outside the range from one through the cipher block size: | ``domain_error(cmac_output_length(1,BlockSize),Length)`` ------------ Protected predicates -------------------- (none) Private predicates ------------------ (none) Operators --------- (none) .. seealso:: :ref:`block_cipher_prepared_key_protocol `