File indexing completed on 2025-01-18 10:02:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef NETTLE_AES_H_INCLUDED
0035 #define NETTLE_AES_H_INCLUDED
0036
0037 #include "nettle-types.h"
0038
0039 #ifdef __cplusplus
0040 extern "C" {
0041 #endif
0042
0043
0044 #define aes_set_encrypt_key nettle_aes_set_encrypt_key
0045 #define aes_set_decrypt_key nettle_aes_set_decrypt_key
0046 #define aes_invert_key nettle_aes_invert_key
0047 #define aes_encrypt nettle_aes_encrypt
0048 #define aes_decrypt nettle_aes_decrypt
0049 #define aes128_set_encrypt_key nettle_aes128_set_encrypt_key
0050 #define aes128_set_decrypt_key nettle_aes128_set_decrypt_key
0051 #define aes128_invert_key nettle_aes128_invert_key
0052 #define aes128_encrypt nettle_aes128_encrypt
0053 #define aes128_decrypt nettle_aes128_decrypt
0054 #define aes192_set_encrypt_key nettle_aes192_set_encrypt_key
0055 #define aes192_set_decrypt_key nettle_aes192_set_decrypt_key
0056 #define aes192_invert_key nettle_aes192_invert_key
0057 #define aes192_encrypt nettle_aes192_encrypt
0058 #define aes192_decrypt nettle_aes192_decrypt
0059 #define aes256_set_encrypt_key nettle_aes256_set_encrypt_key
0060 #define aes256_set_decrypt_key nettle_aes256_set_decrypt_key
0061 #define aes256_invert_key nettle_aes256_invert_key
0062 #define aes256_encrypt nettle_aes256_encrypt
0063 #define aes256_decrypt nettle_aes256_decrypt
0064
0065 #define AES_BLOCK_SIZE 16
0066
0067 #define AES128_KEY_SIZE 16
0068 #define AES192_KEY_SIZE 24
0069 #define AES256_KEY_SIZE 32
0070 #define _AES128_ROUNDS 10
0071 #define _AES192_ROUNDS 12
0072 #define _AES256_ROUNDS 14
0073
0074 struct aes128_ctx
0075 {
0076 uint32_t keys[4 * (_AES128_ROUNDS + 1)];
0077 };
0078
0079 void
0080 aes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key);
0081 void
0082 aes128_set_decrypt_key(struct aes128_ctx *ctx, const uint8_t *key);
0083 void
0084 aes128_invert_key(struct aes128_ctx *dst,
0085 const struct aes128_ctx *src);
0086 void
0087 aes128_encrypt(const struct aes128_ctx *ctx,
0088 size_t length, uint8_t *dst,
0089 const uint8_t *src);
0090 void
0091 aes128_decrypt(const struct aes128_ctx *ctx,
0092 size_t length, uint8_t *dst,
0093 const uint8_t *src);
0094
0095 struct aes192_ctx
0096 {
0097 uint32_t keys[4 * (_AES192_ROUNDS + 1)];
0098 };
0099
0100 void
0101 aes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key);
0102 void
0103 aes192_set_decrypt_key(struct aes192_ctx *ctx, const uint8_t *key);
0104 void
0105 aes192_invert_key(struct aes192_ctx *dst,
0106 const struct aes192_ctx *src);
0107 void
0108 aes192_encrypt(const struct aes192_ctx *ctx,
0109 size_t length, uint8_t *dst,
0110 const uint8_t *src);
0111 void
0112 aes192_decrypt(const struct aes192_ctx *ctx,
0113 size_t length, uint8_t *dst,
0114 const uint8_t *src);
0115
0116 struct aes256_ctx
0117 {
0118 uint32_t keys[4 * (_AES256_ROUNDS + 1)];
0119 };
0120
0121 void
0122 aes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key);
0123 void
0124 aes256_set_decrypt_key(struct aes256_ctx *ctx, const uint8_t *key);
0125 void
0126 aes256_invert_key(struct aes256_ctx *dst,
0127 const struct aes256_ctx *src);
0128 void
0129 aes256_encrypt(const struct aes256_ctx *ctx,
0130 size_t length, uint8_t *dst,
0131 const uint8_t *src);
0132 void
0133 aes256_decrypt(const struct aes256_ctx *ctx,
0134 size_t length, uint8_t *dst,
0135 const uint8_t *src);
0136
0137
0138
0139
0140
0141
0142 #define AES_MIN_KEY_SIZE AES128_KEY_SIZE
0143 #define AES_MAX_KEY_SIZE AES256_KEY_SIZE
0144
0145 #define AES_KEY_SIZE 32
0146
0147 struct aes_ctx
0148 {
0149 unsigned key_size;
0150 union {
0151 struct aes128_ctx ctx128;
0152 struct aes192_ctx ctx192;
0153 struct aes256_ctx ctx256;
0154 } u;
0155 };
0156
0157 void
0158 aes_set_encrypt_key(struct aes_ctx *ctx,
0159 size_t length, const uint8_t *key)
0160 _NETTLE_ATTRIBUTE_DEPRECATED;
0161
0162 void
0163 aes_set_decrypt_key(struct aes_ctx *ctx,
0164 size_t length, const uint8_t *key)
0165 _NETTLE_ATTRIBUTE_DEPRECATED;
0166
0167 void
0168 aes_invert_key(struct aes_ctx *dst,
0169 const struct aes_ctx *src)
0170 _NETTLE_ATTRIBUTE_DEPRECATED;
0171
0172 void
0173 aes_encrypt(const struct aes_ctx *ctx,
0174 size_t length, uint8_t *dst,
0175 const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED;
0176 void
0177 aes_decrypt(const struct aes_ctx *ctx,
0178 size_t length, uint8_t *dst,
0179 const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED;
0180
0181 #ifdef __cplusplus
0182 }
0183 #endif
0184
0185 #endif