From: Daiki Ueno <[email protected]>

As discussed in:
https://lists.lysator.liu.se/pipermail/nettle-bugs/2019/007662.html

This moves `struct nettle_mac` to nettle-meta.h and provide the meta
interface for all defined MAC algorithms.

Each meta interface shall provide the following 4 functions:

  nettle_set_key_func *set_key;
  nettle_set_key_func *set_nonce;
  nettle_hash_update_func *update;
  nettle_hash_digest_func *digest;

where set_nonce is only used by UMAC, and expects that the nonce has
always the same length as AES_BLOCK_SIZE.  For CMAC and HMAC, a no-op
set_nonce function is defined.

Also the signature of set_key is slightly different from
hmac_*_set_key in that it doesn't take key length as an argument.  A
wrapper function is provided to clamp the length to hash block size.

Daiki Ueno (7):
  hmac: Add set_key_expanded function
  nettle-meta: Move struct nettle_mac to nettle-meta.h
  nettle-meta: Add meta interface for CMAC functions
  nettle-meta: Add meta interface for HMAC functions
  nettle-meta: Add meta interface for UMAC functions
  nettle-meta: Expose all defined MACs through nettle_macs
  tests: Add test for meta interface for MAC algorithms

 Makefile.in                |  7 +++-
 cmac-aes128-meta.c         | 48 ++++++++++++++++++++++
 cmac-aes256-meta.c         | 48 ++++++++++++++++++++++
 hmac-md5-meta.c            | 46 ++++++++++++++++++++++
 hmac-md5.c                 |  7 ++++
 hmac-ripemd160-meta.c      | 46 ++++++++++++++++++++++
 hmac-ripemd160.c           |  7 ++++
 hmac-sha1-meta.c           | 46 ++++++++++++++++++++++
 hmac-sha1.c                |  7 ++++
 hmac-sha224-meta.c         | 46 ++++++++++++++++++++++
 hmac-sha224.c              |  7 ++++
 hmac-sha256-meta.c         | 46 ++++++++++++++++++++++
 hmac-sha256.c              |  7 ++++
 hmac-sha384-meta.c         | 46 ++++++++++++++++++++++
 hmac-sha384.c              |  7 ++++
 hmac-sha512-meta.c         | 46 ++++++++++++++++++++++
 hmac-sha512.c              |  7 ++++
 hmac.c                     | 48 ++++++++++++++--------
 hmac.h                     | 45 +++++++++++++++++++++
 nettle-meta-macs.c         | 61 ++++++++++++++++++++++++++++
 nettle-meta.h              | 81 ++++++++++++++++++++++++++++++++++++++
 testsuite/.gitignore       |  1 +
 testsuite/.test-rules.make |  3 ++
 testsuite/Makefile.in      |  2 +-
 testsuite/cmac-test.c      | 24 -----------
 testsuite/meta-mac-test.c  | 37 +++++++++++++++++
 testsuite/testutils.h      | 29 --------------
 umac128-meta.c             | 47 ++++++++++++++++++++++
 umac32-meta.c              | 47 ++++++++++++++++++++++
 umac64-meta.c              | 47 ++++++++++++++++++++++
 umac96-meta.c              | 47 ++++++++++++++++++++++
 31 files changed, 922 insertions(+), 71 deletions(-)
 create mode 100644 cmac-aes128-meta.c
 create mode 100644 cmac-aes256-meta.c
 create mode 100644 hmac-md5-meta.c
 create mode 100644 hmac-ripemd160-meta.c
 create mode 100644 hmac-sha1-meta.c
 create mode 100644 hmac-sha224-meta.c
 create mode 100644 hmac-sha256-meta.c
 create mode 100644 hmac-sha384-meta.c
 create mode 100644 hmac-sha512-meta.c
 create mode 100644 nettle-meta-macs.c
 create mode 100644 testsuite/meta-mac-test.c
 create mode 100644 umac128-meta.c
 create mode 100644 umac32-meta.c
 create mode 100644 umac64-meta.c
 create mode 100644 umac96-meta.c

-- 
2.21.0

_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs

Reply via email to