From: Dmitry Eremin-Solenikov <[email protected]>
Signed-off-by: Dmitry Eremin-Solenikov <[email protected]>
---
Makefile.in | 2 +-
cmac-des3-meta.c | 43 +++++++++++++++++++++++++++++++++++++++
nettle-meta-macs.c | 1 +
nettle-meta.h | 13 ++++++++++++
testsuite/cmac-test.c | 12 -----------
testsuite/meta-mac-test.c | 1 +
6 files changed, 59 insertions(+), 13 deletions(-)
create mode 100644 cmac-des3-meta.c
diff --git a/Makefile.in b/Makefile.in
index 409c655b2cee..de46bb5619f3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -103,7 +103,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
gcm-camellia128.c gcm-camellia128-meta.c \
gcm-camellia256.c gcm-camellia256-meta.c \
cmac.c cmac64.c cmac-aes128.c cmac-aes256.c cmac-des3.c \
- cmac-aes128-meta.c cmac-aes256-meta.c \
+ cmac-aes128-meta.c cmac-aes256-meta.c cmac-des3-meta.c \
gosthash94.c gosthash94-meta.c \
hmac.c hmac-md5.c hmac-ripemd160.c hmac-sha1.c \
hmac-sha224.c hmac-sha256.c hmac-sha384.c hmac-sha512.c \
diff --git a/cmac-des3-meta.c b/cmac-des3-meta.c
new file mode 100644
index 000000000000..40b27feaccdc
--- /dev/null
+++ b/cmac-des3-meta.c
@@ -0,0 +1,43 @@
+/* cmac-des3-meta.c
+
+ Copyright (C) 2013, 2014 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 <assert.h>
+
+#include "nettle-meta.h"
+
+#include "cmac.h"
+
+const struct nettle_mac nettle_cmac_des3
+= _NETTLE_CMAC64(cmac_des3, DES3);
diff --git a/nettle-meta-macs.c b/nettle-meta-macs.c
index 6575ed661db3..201b30847147 100644
--- a/nettle-meta-macs.c
+++ b/nettle-meta-macs.c
@@ -40,6 +40,7 @@
const struct nettle_mac * const _nettle_macs[] = {
&nettle_cmac_aes128,
&nettle_cmac_aes256,
+ &nettle_cmac_des3,
&nettle_hmac_md5,
&nettle_hmac_ripemd160,
&nettle_hmac_sha1,
diff --git a/nettle-meta.h b/nettle-meta.h
index 4b4d312dfe0f..668c90924f1f 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -303,8 +303,21 @@ nettle_get_macs (void);
#define nettle_macs (nettle_get_macs())
+#define _NETTLE_CMAC64(name, AES) { \
+ #name, \
+ sizeof(struct name##_ctx), \
+ CMAC64_DIGEST_SIZE, \
+ AES##_KEY_SIZE, \
+ 0, \
+ (nettle_set_key_func *) name##_set_key, \
+ NULL, \
+ (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;
+extern const struct nettle_mac nettle_cmac_des3;
extern const struct nettle_mac nettle_hmac_md5;
extern const struct nettle_mac nettle_hmac_ripemd160;
diff --git a/testsuite/cmac-test.c b/testsuite/cmac-test.c
index 1a2cd0e591cf..a71baa086d01 100644
--- a/testsuite/cmac-test.c
+++ b/testsuite/cmac-test.c
@@ -2,18 +2,6 @@
#include "nettle-internal.h"
#include "cmac.h"
-const struct nettle_mac nettle_cmac_des3 =
-{
- "CMAC-3DES",
- sizeof(struct cmac_des3_ctx),
- CMAC64_DIGEST_SIZE,
- DES3_KEY_SIZE,
-
- (nettle_set_key_func*) cmac_des3_set_key,
- (nettle_hash_update_func*) cmac_des3_update,
- (nettle_hash_digest_func*) cmac_des3_digest
-};
-
#define test_cmac_aes128(key, msg, ref)
\
test_mac(&nettle_cmac_aes128, key, msg, ref)
diff --git a/testsuite/meta-mac-test.c b/testsuite/meta-mac-test.c
index 09cb5e9fd11c..4f61c3173ec3 100644
--- a/testsuite/meta-mac-test.c
+++ b/testsuite/meta-mac-test.c
@@ -5,6 +5,7 @@
const char* macs[] = {
"cmac_aes128",
"cmac_aes256",
+ "cmac_des3",
"hmac_md5",
"hmac_ripemd160",
"hmac_sha1",
--
2.20.1
_______________________________________________
nettle-bugs mailing list
[email protected]
http://lists.lysator.liu.se/mailman/listinfo/nettle-bugs