summaryrefslogtreecommitdiff
path: root/aes.h
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2013-09-28 12:01:07 +0200
committerNiels Möller <nisse@lysator.liu.se>2013-09-28 12:01:07 +0200
commitfd976f57e00b2a0a747e48da8649b99fd282d5ab (patch)
treea734296e507231127d987baa78c25bd63287083e /aes.h
parent4ae04a64e1c044df67f2d00a9d372373e8c9531d (diff)
parent7f0c28dc59e0f87f1132a8688760dc95ce51b203 (diff)
downloadnettle-fd976f57e00b2a0a747e48da8649b99fd282d5ab.tar.gz
Merged aes-reorg branch.
Diffstat (limited to 'aes.h')
-rw-r--r--aes.h100
1 files changed, 92 insertions, 8 deletions
diff --git a/aes.h b/aes.h
index b3bb9659..0982aa69 100644
--- a/aes.h
+++ b/aes.h
@@ -5,7 +5,7 @@
/* nettle, low-level cryptographics library
*
- * Copyright (C) 2001 Niels Möller
+ * Copyright (C) 2001, 2013 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
@@ -38,23 +38,44 @@ extern "C" {
#define aes_invert_key nettle_aes_invert_key
#define aes_encrypt nettle_aes_encrypt
#define aes_decrypt nettle_aes_decrypt
+#define aes128_set_encrypt_key nettle_aes128set_encrypt_key
+#define aes128_set_decrypt_key nettle_aes128set_decrypt_key
+#define aes128_invert_key nettle_aes128invert_key
+#define aes128_encrypt nettle_aes128encrypt
+#define aes128_decrypt nettle_aes128decrypt
+#define aes192_set_encrypt_key nettle_aes192set_encrypt_key
+#define aes192_set_decrypt_key nettle_aes192set_decrypt_key
+#define aes192_invert_key nettle_aes192invert_key
+#define aes192_encrypt nettle_aes192encrypt
+#define aes192_decrypt nettle_aes192decrypt
+#define aes256_set_encrypt_key nettle_aes256_set_encrypt_key
+#define aes256_set_decrypt_key nettle_aes256_set_decrypt_key
+#define aes256_invert_key nettle_aes256_invert_key
+#define aes256_encrypt nettle_aes256_encrypt
+#define aes256_decrypt nettle_aes256_decrypt
#define AES_BLOCK_SIZE 16
+#define AES128_KEY_SIZE 16
+#define AES192_KEY_SIZE 24
+#define AES256_KEY_SIZE 32
+#define _AES128_ROUNDS 10
+#define _AES192_ROUNDS 12
+#define _AES256_ROUNDS 14
+
/* Variable key size between 128 and 256 bits. But the only valid
* values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */
-#define AES_MIN_KEY_SIZE 16
-#define AES_MAX_KEY_SIZE 32
+#define AES_MIN_KEY_SIZE AES128_KEY_SIZE
+#define AES_MAX_KEY_SIZE AES256_KEY_SIZE
+
+/* Older nettle-2.7 interface */
#define AES_KEY_SIZE 32
-/* FIXME: Change to put nrounds first, to make it possible to use a
- truncated ctx struct, with less subkeys, for the shorter key
- sizes? */
struct aes_ctx
{
- uint32_t keys[60]; /* maximum size of key schedule */
- unsigned nrounds; /* number of rounds to use for our key size */
+ unsigned rounds; /* number of rounds to use for our key size */
+ uint32_t keys[4*(_AES256_ROUNDS + 1)]; /* maximum size of key schedule */
};
void
@@ -78,6 +99,69 @@ aes_decrypt(const struct aes_ctx *ctx,
size_t length, uint8_t *dst,
const uint8_t *src);
+struct aes128_ctx
+{
+ uint32_t keys[4 * (_AES128_ROUNDS + 1)];
+};
+
+void
+aes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key);
+void
+aes128_set_decrypt_key(struct aes128_ctx *ctx, const uint8_t *key);
+void
+aes128_invert_key(struct aes128_ctx *dst,
+ const struct aes128_ctx *src);
+void
+aes128_encrypt(const struct aes128_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+void
+aes128_decrypt(const struct aes128_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+
+struct aes192_ctx
+{
+ uint32_t keys[4 * (_AES192_ROUNDS + 1)];
+};
+
+void
+aes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key);
+void
+aes192_set_decrypt_key(struct aes192_ctx *ctx, const uint8_t *key);
+void
+aes192_invert_key(struct aes192_ctx *dst,
+ const struct aes192_ctx *src);
+void
+aes192_encrypt(const struct aes192_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+void
+aes192_decrypt(const struct aes192_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+
+struct aes256_ctx
+{
+ uint32_t keys[4 * (_AES256_ROUNDS + 1)];
+};
+
+void
+aes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key);
+void
+aes256_set_decrypt_key(struct aes256_ctx *ctx, const uint8_t *key);
+void
+aes256_invert_key(struct aes256_ctx *dst,
+ const struct aes256_ctx *src);
+void
+aes256_encrypt(const struct aes256_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+void
+aes256_decrypt(const struct aes256_ctx *ctx,
+ size_t length, uint8_t *dst,
+ const uint8_t *src);
+
#ifdef __cplusplus
}
#endif