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>
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 \
--- /dev/null
+/* 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
+ };
--- /dev/null
+/* 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);
+}
#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
&(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
#include "cbc.h"
#include "ctr.h"
#include "des.h"
+#include "eax.h"
#include "gcm.h"
#include "memxor.h"
#include "salsa20.h"
#include "nettle-internal.h"
#include "blowfish.h"
#include "des.h"
-#include "eax.h"
-#include "gcm.h"
#include "chacha.h"
#include "salsa20.h"
(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
- };
#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
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 */
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
{