3 * The aes/rijndael block cipher.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2001 Niels Möller
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.
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.
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., 59 Temple Place - Suite 330, Boston,
26 #ifndef NETTLE_AES_INTERNAL_H_INCLUDED
27 #define NETTLE_AES_INTERNAL_H_INCLUDED
31 /* Define to use only small tables. */
37 # define AES_TABLE_SIZE 1
39 # define AES_TABLE_SIZE 4
43 #define _aes_crypt _nettle_aes_crypt
45 /* Assembler code using the table should get link errors if linked
46 * against a small table. */
48 # define _aes_encrypt_table _nettle_aes_encrypt_table_small
49 # define _aes_decrypt_table _nettle_aes_decrypt_table_small
51 # define _aes_encrypt_table _nettle_aes_encrypt_table
52 # define _aes_decrypt_table _nettle_aes_decrypt_table
60 /* Variant of the idx array suitable for the sparc
63 * sparc_idx[0][i] = idx[0][i] * 4 + 2
64 * sparc_idx[1][i] = idx[2][i] * 4
67 unsigned sparc_idx
[2][4];
69 uint32_t table
[AES_TABLE_SIZE
][0x100];
73 _aes_crypt(const struct aes_ctx
*ctx
,
74 const struct aes_table
*T
,
75 unsigned length
, uint8_t *dst
,
79 #define ROTBYTE(x) (((x) >> 8) | (((x) & 0xff) << 24))
80 #define ROTRBYTE(x) (((x) << 8) | (((x) >> 24) & 0xff))
81 #define SUBBYTE(x, box) (((box)[((x) & 0xff)]) | \
82 ((box)[(((x) >> 8) & 0xff)] << 8) | \
83 ((box)[(((x) >> 16) & 0xff)] << 16) | \
84 ((box)[(((x) >> 24) & 0xff)] << 24))
87 extern const struct aes_table _aes_encrypt_table
;
88 extern const struct aes_table _aes_decrypt_table
;
90 #define aes_sbox (_aes_encrypt_table.sbox)
92 #endif /* NETTLE_AES_INTERNAL_H_INCLUDED */