summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--Makefile.in1
-rw-r--r--gcm-camellia256-meta.c51
-rw-r--r--gcm-camellia256.c71
-rw-r--r--gcm.h23
-rw-r--r--nettle-meta.h1
-rw-r--r--testsuite/gcm-test.c98
7 files changed, 254 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c2d570be..8446b8d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2014-02-16 Niels Möller <nisse@lysator.liu.se>
+ * gcm.h: Declarations for gcm-camellia256.
+ * gcm-camellia256.c: New file.
+ * gcm-camellia256-meta.c: New file.
+ * nettle-meta.h (nettle_gcm_camellia256): Declare.
+ * Makefile.in (nettle_SOURCES): Added gcm-camellia256.c and
+ gcm-camellia256-meta.c.
+ * testsuite/gcm-test.c (test_main): Test cases for
+ nettle_gcm_camellia256.
+
* gcm.h: Include camellia.h. Declarations for gcm-camellia128.
* gcm-camellia128.c: New file.
* gcm-camellia128-meta.c: New file.
diff --git a/Makefile.in b/Makefile.in
index bdd64ce8..274689c7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -98,6 +98,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
gcm-aes192.c gcm-aes192-meta.c \
gcm-aes256.c gcm-aes256-meta.c \
gcm-camellia128.c gcm-camellia128-meta.c \
+ gcm-camellia256.c gcm-camellia256-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/gcm-camellia256-meta.c b/gcm-camellia256-meta.c
new file mode 100644
index 00000000..022b1bcb
--- /dev/null
+++ b/gcm-camellia256-meta.c
@@ -0,0 +1,51 @@
+/* gcm-camellia256-meta.c */
+
+/* nettle, low-level cryptographics library
+ *
+ * Copyright (C) 2014 Niels Möller
+ *
+ * The nettle library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * The nettle library 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the nettle library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02111-1301, USA.
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+
+#include "nettle-meta.h"
+
+#include "gcm.h"
+
+static nettle_set_key_func gcm_camellia256_set_nonce_wrapper;
+static void
+gcm_camellia256_set_nonce_wrapper (void *ctx, const uint8_t *nonce)
+{
+ gcm_camellia256_set_iv (ctx, GCM_IV_SIZE, nonce);
+}
+
+const struct nettle_aead nettle_gcm_camellia256 =
+ { "gcm_camellia256", sizeof(struct gcm_camellia256_ctx),
+ GCM_BLOCK_SIZE, CAMELLIA256_KEY_SIZE,
+ GCM_IV_SIZE, GCM_DIGEST_SIZE,
+ (nettle_set_key_func *) gcm_camellia256_set_key,
+ (nettle_set_key_func *) gcm_camellia256_set_key,
+ gcm_camellia256_set_nonce_wrapper,
+ (nettle_hash_update_func *) gcm_camellia256_update,
+ (nettle_crypt_func *) gcm_camellia256_encrypt,
+ (nettle_crypt_func *) gcm_camellia256_decrypt,
+ (nettle_hash_digest_func *) gcm_camellia256_digest,
+ };
diff --git a/gcm-camellia256.c b/gcm-camellia256.c
new file mode 100644
index 00000000..f4cce066
--- /dev/null
+++ b/gcm-camellia256.c
@@ -0,0 +1,71 @@
+/* gcm-camellia256.c
+ */
+
+/* nettle, low-level cryptographics library
+ *
+ * Copyright (C) 2011, 2014 Niels Möller
+ *
+ * The nettle library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * The nettle library 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the nettle library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02111-1301, USA.
+ */
+
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+
+#include "gcm.h"
+
+void
+gcm_camellia256_set_key(struct gcm_camellia256_ctx *ctx, const uint8_t *key)
+{
+ GCM_SET_KEY(ctx, camellia256_set_encrypt_key, camellia256_crypt, key);
+}
+
+void
+gcm_camellia256_set_iv (struct gcm_camellia256_ctx *ctx,
+ size_t length, const uint8_t *iv)
+{
+ GCM_SET_IV (ctx, length, iv);
+}
+
+void
+gcm_camellia256_update (struct gcm_camellia256_ctx *ctx,
+ size_t length, const uint8_t *data)
+{
+ GCM_UPDATE (ctx, length, data);
+}
+
+void
+gcm_camellia256_encrypt(struct gcm_camellia256_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src)
+{
+ GCM_ENCRYPT(ctx, camellia256_crypt, length, dst, src);
+}
+
+void
+gcm_camellia256_decrypt(struct gcm_camellia256_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src)
+{
+ GCM_DECRYPT(ctx, camellia256_crypt, length, dst, src);
+}
+
+void
+gcm_camellia256_digest(struct gcm_camellia256_ctx *ctx,
+ size_t length, uint8_t *digest)
+{
+ GCM_DIGEST(ctx, camellia256_crypt, length, digest);
+}
diff --git a/gcm.h b/gcm.h
index 33d4c256..5cc4276b 100644
--- a/gcm.h
+++ b/gcm.h
@@ -81,6 +81,13 @@ extern "C" {
#define gcm_camellia128_decrypt nettle_gcm_camellia128_decrypt
#define gcm_camellia128_digest nettle_gcm_camellia128_digest
+#define gcm_camellia256_set_key nettle_gcm_camellia256_set_key
+#define gcm_camellia256_set_iv nettle_gcm_camellia256_set_iv
+#define gcm_camellia256_update nettle_gcm_camellia256_update
+#define gcm_camellia256_encrypt nettle_gcm_camellia256_encrypt
+#define gcm_camellia256_decrypt nettle_gcm_camellia256_decrypt
+#define gcm_camellia256_digest nettle_gcm_camellia256_digest
+
#define GCM_BLOCK_SIZE 16
#define GCM_IV_SIZE (GCM_BLOCK_SIZE - 4)
#define GCM_DIGEST_SIZE 16
@@ -288,6 +295,22 @@ void gcm_camellia128_decrypt(struct gcm_camellia128_ctx *ctx,
void gcm_camellia128_digest(struct gcm_camellia128_ctx *ctx,
size_t length, uint8_t *digest);
+
+struct gcm_camellia256_ctx GCM_CTX(struct camellia256_ctx);
+
+void gcm_camellia256_set_key(struct gcm_camellia256_ctx *ctx,
+ const uint8_t *key);
+void gcm_camellia256_set_iv(struct gcm_camellia256_ctx *ctx,
+ size_t length, const uint8_t *iv);
+void gcm_camellia256_update(struct gcm_camellia256_ctx *ctx,
+ size_t length, const uint8_t *data);
+void gcm_camellia256_encrypt(struct gcm_camellia256_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src);
+void gcm_camellia256_decrypt(struct gcm_camellia256_ctx *ctx,
+ size_t length, uint8_t *dst, const uint8_t *src);
+void gcm_camellia256_digest(struct gcm_camellia256_ctx *ctx,
+ size_t length, uint8_t *digest);
+
#ifdef __cplusplus
}
diff --git a/nettle-meta.h b/nettle-meta.h
index eb70a2a4..2c9506b5 100644
--- a/nettle-meta.h
+++ b/nettle-meta.h
@@ -151,6 +151,7 @@ extern const struct nettle_aead nettle_gcm_aes128;
extern const struct nettle_aead nettle_gcm_aes192;
extern const struct nettle_aead nettle_gcm_aes256;
extern const struct nettle_aead nettle_gcm_camellia128;
+extern const struct nettle_aead nettle_gcm_camellia256;
extern const struct nettle_aead nettle_eax_aes128;
extern const struct nettle_aead nettle_chacha_poly1305;
diff --git a/testsuite/gcm-test.c b/testsuite/gcm-test.c
index 81977ffb..9595766a 100644
--- a/testsuite/gcm-test.c
+++ b/testsuite/gcm-test.c
@@ -416,6 +416,104 @@ test_main(void)
"c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b"), /* IV */
SHEX("ceae5569b2af8641572622731aed3e53")); /* tag */
+ /* gcm-camellia256 */
+
+ /* Test case 13 */
+ test_aead(&nettle_gcm_camellia256,
+ (nettle_hash_update_func *) gcm_camellia256_set_iv,
+ SHEX("0000000000000000 0000000000000000"
+ "0000000000000000 0000000000000000"), /* key */
+ SHEX(""), /* auth data */
+ SHEX(""), /* plaintext */
+ SHEX(""), /* ciphertext */
+ SHEX("000000000000000000000000"), /* iv */
+ SHEX("9cdb269b5d293bc5db9c55b057d9b591")); /* tag */
+
+ /* Test case 14 */
+ test_aead(&nettle_gcm_camellia256,
+ (nettle_hash_update_func *) gcm_camellia256_set_iv,
+ SHEX("0000000000000000 0000000000000000"
+ "0000000000000000 0000000000000000"), /* key */
+ SHEX(""), /* auth data */
+ SHEX("0000000000000000 0000000000000000"), /* plaintext */
+ SHEX("3d4b2cde666761ba 5dfb305178e667fb"), /* ciphertext */
+ SHEX("000000000000000000000000"), /* iv */
+ SHEX("284b63bb143c40ce100fb4dea6bb617b")); /* tag */
+
+ /* Test case 15 */
+ test_aead(&nettle_gcm_camellia256,
+ (nettle_hash_update_func *) gcm_camellia256_set_iv,
+ SHEX("feffe9928665731c 6d6a8f9467308308"
+ "feffe9928665731c 6d6a8f9467308308"), /* key */
+ SHEX(""), /* auth data */
+ SHEX("d9313225f88406e5 a55909c5aff5269a"
+ "86a7a9531534f7da 2e4c303d8a318a72"
+ "1c3c0c9595680953 2fcf0e2449a6b525"
+ "b16aedf5aa0de657 ba637b391aafd255"), /* plaintext */
+ SHEX("ad142c11579dd95e 41f3c1f324dabc25"
+ "5864d920f1b65759 d8f560d4948d4477"
+ "58dfdcf77aa9f625 81c7ff572a037f81"
+ "0cb1a9c4b3ca6ed6 38179b776549e092"), /* ciphertext */
+ SHEX("cafebabefacedbaddecaf888"), /* iv */
+ SHEX("c912686270a2b9966415fca3be75c468")); /* tag */
+
+ /* Test case 16 */
+ test_aead(&nettle_gcm_camellia256,
+ (nettle_hash_update_func *) gcm_camellia256_set_iv,
+ SHEX("feffe9928665731c 6d6a8f9467308308"
+ "feffe9928665731c 6d6a8f9467308308"), /* key */
+ SHEX("feedfacedeadbeef feedfacedeadbeef"
+ "abaddad2"), /* auth data */
+ SHEX("d9313225f88406e5 a55909c5aff5269a"
+ "86a7a9531534f7da 2e4c303d8a318a72"
+ "1c3c0c9595680953 2fcf0e2449a6b525"
+ "b16aedf5aa0de657 ba637b39"), /* plaintext */
+ SHEX("ad142c11579dd95e 41f3c1f324dabc25"
+ "5864d920f1b65759 d8f560d4948d4477"
+ "58dfdcf77aa9f625 81c7ff572a037f81"
+ "0cb1a9c4b3ca6ed6 38179b77"), /* ciphertext */
+ SHEX("cafebabefacedbaddecaf888"), /* iv */
+ SHEX("4e4b178d8fe26fdc95e2e7246dd94bec")); /* tag */
+
+ /* Test case 17 */
+ test_aead(&nettle_gcm_camellia256,
+ (nettle_hash_update_func *) gcm_camellia256_set_iv,
+ SHEX("feffe9928665731c 6d6a8f9467308308"
+ "feffe9928665731c 6d6a8f9467308308"), /* key */
+ SHEX("feedfacedeadbeef feedfacedeadbeef"
+ "abaddad2"), /* auth data */
+ SHEX("d9313225f88406e5 a55909c5aff5269a"
+ "86a7a9531534f7da 2e4c303d8a318a72"
+ "1c3c0c9595680953 2fcf0e2449a6b525"
+ "b16aedf5aa0de657 ba637b39"), /* plaintext */
+ SHEX("6ca95fbb7d16577a 9ef2fded94dc85b5"
+ "d40c629f6bef2c64 9888e3cbb0ededc7"
+ "810c04b12c2983bb bbc482e16e45c921"
+ "5ae12c15c55f2f48 09d06652"), /* ciphertext */
+ SHEX("cafebabefacedbad"), /* iv */
+ SHEX("e6472b8ebd331bfcc7c0fa63ce094461")); /* tag */
+
+ /* Test case 18 */
+ test_aead(&nettle_gcm_camellia256,
+ (nettle_hash_update_func *) gcm_camellia256_set_iv,
+ SHEX("feffe9928665731c 6d6a8f9467308308"
+ "feffe9928665731c 6d6a8f9467308308"), /* key */
+ SHEX("feedfacedeadbeef feedfacedeadbeef"
+ "abaddad2"), /* auth data */
+ SHEX("d9313225f88406e5 a55909c5aff5269a"
+ "86a7a9531534f7da 2e4c303d8a318a72"
+ "1c3c0c9595680953 2fcf0e2449a6b525"
+ "b16aedf5aa0de657 ba637b39"), /* plaintext */
+ SHEX("e0cddd7564d09c4d c522dd65949262bb"
+ "f9dcdb07421cf67f 3032becb7253c284"
+ "a16e5bf0f556a308 043f53fab9eebb52"
+ "6be7f7ad33d697ac 77c67862"), /* ciphertext */
+ SHEX("9313225df88406e5 55909c5aff5269aa"
+ "6a7a9538534f7da1 e4c303d2a318a728"
+ "c3c0c95156809539 fcf0e2429a6b5254"
+ "16aedbf5a0de6a57 a637b39b"), /* iv */
+ SHEX("5791883f822013f8bd136fc36fb9946b")); /* tag */
+
/* Test gcm_hash, with varying message size, keys and iv all zero.
Not compared to any other implementation. */
test_gcm_hash (SDATA("a"),