• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
        • R1cs
        • Interfaces
          • Definterface-hmac
            • Definterface-hmac-implementation
          • Definterface-encrypt-block
          • Definterface-hash
          • Definterface-encrypt-init
          • Definterface-pbkdf2
          • Aes-256-cbc-pkcs7-interface
          • Aes-192-cbc-pkcs7-interface
          • Aes-128-cbc-pkcs7-interface
          • Aes-256-interface
          • Aes-192-interface
          • Aes-128-interface
          • Pbkdf2-hmac-sha-512-interface
          • Keccak-256-interface
          • Sha-256-interface
          • Keccak-512-interface
          • Ripemd-160-interface
          • Sha-512-interface
          • Pbkdf2-hmac-sha-256-interface
          • Hmac-sha-512-interface
          • Hmac-sha-256-interface
          • Secp256k1-interface
          • Secp256k1-ecdsa-interface
        • Sha-2
        • Keccak
        • Kdf
        • Mimc
        • Padding
        • Hmac
        • Elliptic-curves
        • Attachments
        • Elliptic-curve-digital-signature-algorithm
      • Poseidon
      • Where-do-i-place-my-book
      • Axe
      • Bigmems
      • Builtins
      • Execloader
      • Aleo
      • Solidity
      • Paco
      • Concurrent-programs
      • Bls12-377-curves
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Interfaces

Definterface-hmac

Introduce an interface for a cryptographic hash-based message authentication (HMAC) function.

Introduction

HMAC is specified in the RFC 2104 standard. It is parameterized over a hash function, i.e. there is an HMAC variant for each choice of the hash function.

This macro introduces a weakly constrained ACL2 function for an HMAC function; the underlying hash function is specified via a reference to the name of an existing definterface-hash. The HMAC function takes two byte lists as arguments (the key and the text), and returns a byte list; the use of bytes (vs. bits) is consistent with RFC 2104. The guard of the function requires the arguments to be byte lists. The function is constrained to fix its arguments to byte lists, and to return a byte list whose size is the output size of the hash function.

If the referenced hash function has no limit on its input size, the HMAC function has no limit on the sizes of its inputs either. Otherwise, limits are derived as follows, and included in the guard of the generated constrained function. RFC 2104 says that the key size must not exceed the hash function's block size in order for the key to be used ``directly'', otherwise the key is hashed and its hash used: either way, the key or its hash is padded to the block size. RFC 2104 says that an inner hash is taken of the concatenation of (i) the (xor'd) padded key or key hash and (ii) the text, whose total size must therefore not exceed the hash function's maximum input size: it follows that the size of the text must not exceed the hash function's maximum input size dimished by the hash function's block size. Note that definterface-hash has no information about the hash function's block size, which is therefore supplied directly to definterface-hmac. RFC 2104 then takes an outer hash of the concatenation of the (xor'd) key and the inner hash output, but that is always well below the hash function's input size limit.

This macro also introduces a few theorems that follow from the constraints. It also introduces an XDOC topic for the generated function, constraints, and theorems.

General Form

(definterface-hmac name
                   :hash ...
                   :block-size ...
                   :topic ...
                   :parents ...
                   :short ...
                   :long ...
  )

Inputs

name

A symbol that names the HMAC function.

:hash

The name of an existing definterface-hash.

:block-size

A constant expression whose value is a positive integer. This is the hash function's block size in bytes. This input must be present if the hash function has an input size limit; otherwise, this input must be absent.

:topic

A symbol that names the generated XDOC topic that surrounds the generated functions and theorems.

If not supplied, it defaults to name followed by -interface.

:parents
:short
:long

These, if present, are added to the XDOC topic generated for the fixtype.

Generated Events

name

A constrained function that represents the HMAC function.

Its guard consists of byte-listp for both arguments and, if applicable, conditions on their lengths as explained above.

This function is constrained to:

  • Return a byte-listp of length equal to the output size of the hash function.
  • Fix its inputs to byte-listp.

The following additional theorems are also generated:

  • A type prescription rules saying that the function returns a true-listp.
  • A type prescription rule saying that the function returns a consp.

Subtopics

Definterface-hmac-implementation
Implementation of definterface-hmac.