From: Daiki Ueno dueno@redhat.com
Signed-off-by: Daiki Ueno dueno@redhat.com --- Makefile.in | 1 + nettle-meta.h | 17 +++++++++++++++++ umac128-meta.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ umac32-meta.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ umac64-meta.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ umac96-meta.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 206 insertions(+) create mode 100644 umac128-meta.c create mode 100644 umac32-meta.c create mode 100644 umac64-meta.c create mode 100644 umac96-meta.c
diff --git a/Makefile.in b/Makefile.in index 9031d959..4cfc5005 100644 --- a/Makefile.in +++ b/Makefile.in @@ -138,6 +138,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \ umac-nh.c umac-nh-n.c umac-l2.c umac-l3.c \ umac-poly64.c umac-poly128.c umac-set-key.c \ umac32.c umac64.c umac96.c umac128.c \ + umac32-meta.c umac64-meta.c umac96-meta.c umac128-meta.c \ version.c \ write-be32.c write-le32.c write-le64.c \ yarrow256.c yarrow_key_event.c \ diff --git a/nettle-meta.h b/nettle-meta.h index f2a73d9b..55229501 100644 --- a/nettle-meta.h +++ b/nettle-meta.h @@ -284,6 +284,18 @@ struct nettle_mac (nettle_hash_digest_func *) name##_digest, \ }
+#define _NETTLE_UMAC(name, NAME) { \ + #name, \ + sizeof(struct name##_ctx), \ + NAME##_DIGEST_SIZE, \ + UMAC_BLOCK_SIZE, \ + AES_BLOCK_SIZE, \ + (nettle_set_key_func *) name##_set_key, \ + name##_set_nonce_wrapper, \ + (nettle_hash_update_func *) name##_update, \ + (nettle_hash_digest_func *) name##_digest, \ +} + extern const struct nettle_mac nettle_cmac_aes128; extern const struct nettle_mac nettle_cmac_aes256;
@@ -295,6 +307,11 @@ extern const struct nettle_mac nettle_hmac_sha256; extern const struct nettle_mac nettle_hmac_sha384; extern const struct nettle_mac nettle_hmac_sha512;
+extern const struct nettle_mac nettle_umac32; +extern const struct nettle_mac nettle_umac64; +extern const struct nettle_mac nettle_umac96; +extern const struct nettle_mac nettle_umac128; + #ifdef __cplusplus } #endif diff --git a/umac128-meta.c b/umac128-meta.c new file mode 100644 index 00000000..9f6a7e34 --- /dev/null +++ b/umac128-meta.c @@ -0,0 +1,47 @@ +/* umac128-meta.c + + Copyright (C) 2013 Niels Möller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include "nettle-meta.h" + +#include "umac.h" + +static void +umac128_set_nonce_wrapper (void *ctx, const uint8_t *key) +{ + umac128_set_nonce (ctx, AES_BLOCK_SIZE, key); +} + +const struct nettle_mac nettle_umac128 += _NETTLE_UMAC(umac128, UMAC128); diff --git a/umac32-meta.c b/umac32-meta.c new file mode 100644 index 00000000..2b4f9c14 --- /dev/null +++ b/umac32-meta.c @@ -0,0 +1,47 @@ +/* umac32-meta.c + + Copyright (C) 2013 Niels Möller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include "nettle-meta.h" + +#include "umac.h" + +static void +umac32_set_nonce_wrapper (void *ctx, const uint8_t *key) +{ + umac32_set_nonce (ctx, AES_BLOCK_SIZE, key); +} + +const struct nettle_mac nettle_umac32 += _NETTLE_UMAC(umac32, UMAC32); diff --git a/umac64-meta.c b/umac64-meta.c new file mode 100644 index 00000000..0351aaed --- /dev/null +++ b/umac64-meta.c @@ -0,0 +1,47 @@ +/* umac64-meta.c + + Copyright (C) 2013 Niels Möller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include "nettle-meta.h" + +#include "umac.h" + +static void +umac64_set_nonce_wrapper (void *ctx, const uint8_t *key) +{ + umac64_set_nonce (ctx, AES_BLOCK_SIZE, key); +} + +const struct nettle_mac nettle_umac64 += _NETTLE_UMAC(umac64, UMAC64); diff --git a/umac96-meta.c b/umac96-meta.c new file mode 100644 index 00000000..2feba8c8 --- /dev/null +++ b/umac96-meta.c @@ -0,0 +1,47 @@ +/* umac96-meta.c + + Copyright (C) 2013 Niels Möller + + This file is part of GNU Nettle. + + GNU Nettle is free software: you can redistribute it and/or + modify it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your + option) any later version. + + or both in parallel, as here. + + GNU Nettle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see http://www.gnu.org/licenses/. +*/ + +#if HAVE_CONFIG_H +# include "config.h" +#endif + +#include "nettle-meta.h" + +#include "umac.h" + +static void +umac96_set_nonce_wrapper (void *ctx, const uint8_t *key) +{ + umac96_set_nonce (ctx, AES_BLOCK_SIZE, key); +} + +const struct nettle_mac nettle_umac96 += _NETTLE_UMAC(umac96, UMAC96);