add packaging
[platform/upstream/nettle.git] / aes.h
1 /* aes.h
2  *
3  * The aes/rijndael block cipher.
4  */
5
6 /* nettle, low-level cryptographics library
7  *
8  * Copyright (C) 2001 Niels Möller
9  *  
10  * The nettle library is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation; either version 2.1 of the License, or (at your
13  * option) any later version.
14  * 
15  * The nettle library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
18  * License for more details.
19  * 
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the nettle library; see the file COPYING.LIB.  If not, write to
22  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23  * MA 02111-1301, USA.
24  */
25  
26 #ifndef NETTLE_AES_H_INCLUDED
27 #define NETTLE_AES_H_INCLUDED
28
29 #include "nettle-types.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* Name mangling */
36 #define aes_set_encrypt_key nettle_aes_set_encrypt_key
37 #define aes_set_decrypt_key nettle_aes_set_decrypt_key
38 #define aes_invert_key nettle_aes_invert_key
39 #define aes_encrypt nettle_aes_encrypt
40 #define aes_decrypt nettle_aes_decrypt
41
42 #define AES_BLOCK_SIZE 16
43
44 /* Variable key size between 128 and 256 bits. But the only valid
45  * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */
46 #define AES_MIN_KEY_SIZE 16
47 #define AES_MAX_KEY_SIZE 32
48
49 #define AES_KEY_SIZE 32
50
51 /* FIXME: Change to put nrounds first, to make it possible to use a
52    truncated ctx struct, with less subkeys, for the shorter key
53    sizes? */
54 struct aes_ctx
55 {
56   uint32_t keys[60];  /* maximum size of key schedule */
57   unsigned  nrounds;  /* number of rounds to use for our key size */
58 };
59
60 void
61 aes_set_encrypt_key(struct aes_ctx *ctx,
62                     unsigned length, const uint8_t *key);
63
64 void
65 aes_set_decrypt_key(struct aes_ctx *ctx,
66                    unsigned length, const uint8_t *key);
67
68 void
69 aes_invert_key(struct aes_ctx *dst,
70                const struct aes_ctx *src);
71
72 void
73 aes_encrypt(const struct aes_ctx *ctx,
74             unsigned length, uint8_t *dst,
75             const uint8_t *src);
76 void
77 aes_decrypt(const struct aes_ctx *ctx,
78             unsigned length, uint8_t *dst,
79             const uint8_t *src);
80
81 #ifdef __cplusplus
82 }
83 #endif
84
85 #endif /* NETTLE_AES_H_INCLUDED */