2 * aes.h - Header file declaring AES functions.
5 * This file is Free Software. It has been modified to as part of its
6 * incorporation into secnet.
8 * Copyright 2000 Vincent Rijmen, Antoon Bosselaers, Paulo Barreto
9 * Copyright 2004 Fabrice Bellard
10 * Copyright 2013 Ian Jackson
12 * You may redistribute this file and/or modify it under the terms of
13 * the permissive licence shown below.
15 * You may redistribute secnet as a whole and/or modify it under the
16 * terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 3, or (at your option) any
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see
27 * https://www.gnu.org/licenses/gpl.html.
30 * Copied from the upstream qemu git tree revision
31 * 55616505876d6683130076b810a27c7889321560
32 * but was introduced there by Fabrice Bellard in
33 * e4d4fe3c34cdd6e26f9b9975efec7d1e81ad00b6
35 * git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1036 \
36 * c046a42c-6fe2-441c-8c8c-71466251a162
38 * Modified by Ian Jackson to change the guard #define from
39 * QEMU_AES_H to AES_H and to add some needed system #include's.
41 * The header file doesn't appear to have a separate copyright notice
42 * but is clearly a lightly edited (by Bellard) version of code from
43 * Rijmen, Bosselaers and Barreto.
45 * The original is from rijndael-alg-fst.c, with this copyright
50 * @version 3.0 (December 2000)
52 * Optimised ANSI C code for the Rijndael cipher (now AES)
54 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
55 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
56 * @author Paulo Barreto <paulo.barreto@terra.com.br>
58 * This code is hereby placed in the public domain.
60 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
61 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
64 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
65 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
66 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
67 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
68 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
69 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
70 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
82 #define AES_BLOCK_SIZE 16
85 uint32_t rd_key[4 *(AES_MAXNR + 1)];
88 typedef struct aes_key_st AES_KEY;
90 int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
92 int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
95 void AES_encrypt(const unsigned char *in, unsigned char *out,
97 void AES_decrypt(const unsigned char *in, unsigned char *out,
99 void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
100 const unsigned long length, const AES_KEY *key,
101 unsigned char *ivec, const int enc);