]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Make eax_aes128 interface public.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 13 Feb 2014 06:25:51 +0000 (07:25 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 13 Feb 2014 06:25:51 +0000 (07:25 +0100)
ChangeLog
Makefile.in
eax-aes128-meta.c [new file with mode: 0644]
eax-aes128.c [new file with mode: 0644]
eax.h
examples/nettle-benchmark.c
nettle-internal.c
nettle-internal.h
nettle-meta.h

index cd43d9cafb8c510995a3c8487e4a00df352cd1db..fd75fe8caa5e738676d6e97885a280682de13b87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2014-02-13  Niels Möller  <nisse@lysator.liu.se>
 
+       * Makefile.in (nettle_SOURCES): Added eax-aes128.c
+       eax-aes128-meta.c.
+       * examples/nettle-benchmark.c: Include eax.h.
+       * nettle-meta.h (nettle_eax_aes128): Declare, moved from
+       nettle-internal.h.
+       * eax.h: Declare eax_aes128_ctx and related functions. Moved from
+       nettle-internal.h
+       (EAX_IV_SIZE): New constant.
+       * eax-aes128-meta.c (nettle_eax_aes128): Moved definition to new
+       file.
+       * eax-aes128.c (eax_aes128_set_key, eax_aes128_set_nonce)
+       (eax_aes128_update, eax_aes128_encrypt, eax_aes128_decrypt)
+       (eax_aes128_digest): Moved functions to a new file.
+       * nettle-internal.c: ... from old location.
+       * nettle-internal.h: Moved eax declarations elsewhere.
+
        * tools/nettle-pbkdf2.c (main): Added missing deallocation.
 
 2014-02-12  Niels Möller  <nisse@lysator.liu.se>
index dbb07aa6a389a5d4827d30cb10dad4d418bf65ea..180900539afac296656a9d7c3af8e07ee00668e6 100644 (file)
@@ -91,7 +91,8 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
                 chacha-poly1305.c chacha-poly1305-meta.c \
                 chacha-set-key.c chacha-set-nonce.c \
                 chacha128-set-key.c chacha256-set-key.c \
-                ctr.c des.c des3.c des-compat.c eax.c \
+                ctr.c des.c des3.c des-compat.c \
+                eax.c eax-aes128.c eax-aes128-meta.c \
                 gcm.c gcm-aes.c \
                 gcm-aes128.c gcm-aes128-meta.c \
                 gcm-aes192.c gcm-aes192-meta.c \
diff --git a/eax-aes128-meta.c b/eax-aes128-meta.c
new file mode 100644 (file)
index 0000000..09b76b7
--- /dev/null
@@ -0,0 +1,50 @@
+/* eax-aes128-meta.c
+ */
+
+/* nettle, low-level cryptographics library
+ *
+ * Copyright (C) 2013, 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 "eax.h"
+#include "nettle-meta.h"
+
+static nettle_set_key_func eax_aes128_set_nonce_wrapper;
+static void
+eax_aes128_set_nonce_wrapper (void *ctx, const uint8_t *nonce)
+{
+  eax_aes128_set_nonce (ctx, EAX_IV_SIZE, nonce);
+}
+
+const struct nettle_aead
+nettle_eax_aes128 =
+  { "eax_aes128", sizeof(struct eax_aes128_ctx),
+    EAX_BLOCK_SIZE, AES128_KEY_SIZE,
+    EAX_IV_SIZE, EAX_DIGEST_SIZE,
+    (nettle_set_key_func *) eax_aes128_set_key,
+    (nettle_set_key_func *) eax_aes128_set_key,
+    eax_aes128_set_nonce_wrapper,
+    (nettle_hash_update_func *) eax_aes128_update,
+    (nettle_crypt_func *) eax_aes128_encrypt,
+    (nettle_crypt_func *) eax_aes128_decrypt,
+    (nettle_hash_digest_func *) eax_aes128_digest
+  };
diff --git a/eax-aes128.c b/eax-aes128.c
new file mode 100644 (file)
index 0000000..3050bf9
--- /dev/null
@@ -0,0 +1,70 @@
+/* eax-aes128.c
+ */
+
+/* nettle, low-level cryptographics library
+ *
+ * Copyright (C) 2013, 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 "eax.h"
+
+void
+eax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key)
+{
+  EAX_SET_KEY(ctx,
+             aes128_set_encrypt_key, aes128_encrypt,
+             key);
+}
+
+void
+eax_aes128_set_nonce(struct eax_aes128_ctx *ctx,
+                    size_t length, const uint8_t *iv)
+{
+  EAX_SET_NONCE(ctx, aes128_encrypt, length, iv);
+}
+
+void
+eax_aes128_update(struct eax_aes128_ctx *ctx, size_t length, const uint8_t *data)
+{
+  EAX_UPDATE(ctx, aes128_encrypt, length, data);
+}
+
+void
+eax_aes128_encrypt(struct eax_aes128_ctx *ctx,
+                  size_t length, uint8_t *dst, const uint8_t *src)
+{
+  EAX_ENCRYPT(ctx, aes128_encrypt, length, dst, src);
+}
+
+void
+eax_aes128_decrypt(struct eax_aes128_ctx *ctx,
+                  size_t length, uint8_t *dst, const uint8_t *src)
+{
+  EAX_DECRYPT(ctx, aes128_encrypt, length, dst, src);
+}
+
+void
+eax_aes128_digest(struct eax_aes128_ctx *ctx,
+                 size_t length, uint8_t *digest)
+{
+  EAX_DIGEST(ctx, aes128_encrypt, length, digest);
+}
diff --git a/eax.h b/eax.h
index 23f62beeff31361969803a228cd0dd005f732868..4509f889d110eff059bea8d4493751f99063af77 100644 (file)
--- a/eax.h
+++ b/eax.h
@@ -40,18 +40,20 @@ extern "C" {
 #define eax_decrypt nettle_eax_decrypt
 #define eax_digest nettle_eax_digest
 
-#define eax_aes_set_key nettle_eax_aes_set_key
-#define eax_aes_set_nonce nettle_eax_aes_set_nonce
-#define eax_aes_update nettle_eax_aes_update
-#define eax_aes_encrypt nettle_eax_aes_encrypt
-#define eax_aes_decrypt nettle_eax_aes_decrypt
-#define eax_aes_digest nettle_eax_aes_digest
+#define eax_aes128_set_key nettle_eax_aes128_set_key
+#define eax_aes128_set_nonce nettle_eax_aes128_set_nonce
+#define eax_aes128_update nettle_eax_aes128_update
+#define eax_aes128_encrypt nettle_eax_aes128_encrypt
+#define eax_aes128_decrypt nettle_eax_aes128_decrypt
+#define eax_aes128_digest nettle_eax_aes128_digest
 
 /* Restricted to block ciphers with 128 bit block size. FIXME: Reflect
    this in naming? */
 
 #define EAX_BLOCK_SIZE 16
 #define EAX_DIGEST_SIZE 16
+/* FIXME: Reasonable default? */
+#define EAX_IV_SIZE 16
 
 /* Values independent of message and nonce */
 struct eax_key
@@ -138,6 +140,30 @@ eax_digest (struct eax_ctx *eax, const struct eax_key *key,
                 &(ctx)->cipher, (nettle_crypt_func *) (encrypt),       \
                 (length), (digest)))
 
+struct eax_aes128_ctx EAX_CTX(struct aes128_ctx);
+
+void
+eax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key);
+
+void
+eax_aes128_set_nonce(struct eax_aes128_ctx *ctx,
+                    size_t length, const uint8_t *iv);
+
+void
+eax_aes128_update(struct eax_aes128_ctx *ctx,
+                 size_t length, const uint8_t *data);
+
+void
+eax_aes128_encrypt(struct eax_aes128_ctx *ctx,
+                  size_t length, uint8_t *dst, const uint8_t *src);
+
+void
+eax_aes128_decrypt(struct eax_aes128_ctx *ctx,
+                  size_t length, uint8_t *dst, const uint8_t *src);
+
+void
+eax_aes128_digest(struct eax_aes128_ctx *ctx, size_t length, uint8_t *digest);
+
 #ifdef __cplusplus
 }
 #endif
index d66ce71ec1a34e8c99908822c902fb29971a4590..5cf7f625b0ba46c3f54c301c1ed8599a435da5aa 100644 (file)
@@ -47,6 +47,7 @@
 #include "cbc.h"
 #include "ctr.h"
 #include "des.h"
+#include "eax.h"
 #include "gcm.h"
 #include "memxor.h"
 #include "salsa20.h"
index 3970685bac4f8f04686adf468b27bf69876537d2..6b56b1dbae0ffb09bc3a4957d5e3fe1b83bac4de 100644 (file)
@@ -34,8 +34,6 @@
 #include "nettle-internal.h"
 #include "blowfish.h"
 #include "des.h"
-#include "eax.h"
-#include "gcm.h"
 #include "chacha.h"
 #include "salsa20.h"
 
@@ -120,70 +118,3 @@ nettle_salsa20r12 = {
   (nettle_crypt_func *) salsa20r12_crypt
 };
 
-
-/* eax-aes128 */
-void
-eax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key)
-{
-  EAX_SET_KEY(ctx,
-             aes128_set_encrypt_key, aes128_encrypt,
-             key);
-}
-
-void
-eax_aes128_set_nonce(struct eax_aes128_ctx *ctx,
-                    size_t length, const uint8_t *iv)
-{
-  EAX_SET_NONCE(ctx, aes128_encrypt, length, iv);
-}
-
-void
-eax_aes128_update(struct eax_aes128_ctx *ctx, size_t length, const uint8_t *data)
-{
-  EAX_UPDATE(ctx, aes128_encrypt, length, data);
-}
-
-void
-eax_aes128_encrypt(struct eax_aes128_ctx *ctx,
-               size_t length, uint8_t *dst, const uint8_t *src)
-{
-  EAX_ENCRYPT(ctx, aes128_encrypt, length, dst, src);
-}
-
-void
-eax_aes128_decrypt(struct eax_aes128_ctx *ctx,
-               size_t length, uint8_t *dst, const uint8_t *src)
-{
-  EAX_DECRYPT(ctx, aes128_encrypt, length, dst, src);
-}
-
-void
-eax_aes128_digest(struct eax_aes128_ctx *ctx,
-              size_t length, uint8_t *digest)
-{
-  EAX_DIGEST(ctx, aes128_encrypt, length, digest);
-}
-
-/* FIXME: Reasonable default? */
-#define EAX_IV_SIZE 16
-
-static nettle_set_key_func eax_aes128_set_nonce_wrapper;
-static void
-eax_aes128_set_nonce_wrapper (void *ctx, const uint8_t *nonce)
-{
-  eax_aes128_set_nonce (ctx, EAX_IV_SIZE, nonce);
-}
-
-const struct nettle_aead
-nettle_eax_aes128 =
-  { "eax_aes128", sizeof(struct eax_aes128_ctx),
-    EAX_BLOCK_SIZE, AES128_KEY_SIZE,
-    EAX_IV_SIZE, EAX_DIGEST_SIZE,
-    (nettle_set_key_func *) eax_aes128_set_key,
-    (nettle_set_key_func *) eax_aes128_set_key,
-    eax_aes128_set_nonce_wrapper,
-    (nettle_hash_update_func *) eax_aes128_update,
-    (nettle_crypt_func *) eax_aes128_encrypt,
-    (nettle_crypt_func *) eax_aes128_decrypt,
-    (nettle_hash_digest_func *) eax_aes128_digest
-  };
index 22d2b9e14414f45e2bf5117cc46300c214741195..d91a81f9d75d78ad55c5e2f7f207459524103fae 100644 (file)
@@ -29,8 +29,6 @@
 
 #include "nettle-meta.h"
 
-#include "eax.h"
-
 /* Temporary allocation, for systems that don't support alloca. Note
  * that the allocation requests should always be reasonably small, so
  * that they can fit on the stack. For non-alloca systems, we use a
@@ -82,32 +80,4 @@ extern const struct nettle_cipher nettle_openssl_cast128;
 extern const struct nettle_hash nettle_openssl_md5;
 extern const struct nettle_hash nettle_openssl_sha1;
 
-
-/* Tentative interface. */
-struct eax_aes128_ctx EAX_CTX(struct aes128_ctx);
-
-void
-eax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key);
-
-void
-eax_aes128_set_nonce(struct eax_aes128_ctx *ctx,
-                    size_t length, const uint8_t *iv);
-
-void
-eax_aes128_update(struct eax_aes128_ctx *ctx,
-                 size_t length, const uint8_t *data);
-
-void
-eax_aes128_encrypt(struct eax_aes128_ctx *ctx,
-                  size_t length, uint8_t *dst, const uint8_t *src);
-
-void
-eax_aes128_decrypt(struct eax_aes128_ctx *ctx,
-                  size_t length, uint8_t *dst, const uint8_t *src);
-
-void
-eax_aes128_digest(struct eax_aes128_ctx *ctx, size_t length, uint8_t *digest);
-
-extern const struct nettle_aead nettle_eax_aes128;
-
 #endif /* NETTLE_INTERNAL_H_INCLUDED */
index f167b54e7ab250ab11cde787c2ee5847841d4a93..4e33e79f50975c2bc35a642300047379e88dfa26 100644 (file)
@@ -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_chacha_poly1305;
+extern const struct nettle_aead nettle_eax_aes128;
 
 struct nettle_armor
 {