1 /* aes-set-decrypt-key.c
3 Inverse key setup for the aes/rijndael block cipher.
5 Copyright (C) 2000, 2001, 2002 Rafael R. Sevilla, Niels Möller
6 Copyright (C) 2013 Niels Möller
8 This file is part of GNU Nettle.
10 GNU Nettle is free software: you can redistribute it and/or
11 modify it under the terms of either:
13 * the GNU Lesser General Public License as published by the Free
14 Software Foundation; either version 3 of the License, or (at your
15 option) any later version.
19 * the GNU General Public License as published by the Free
20 Software Foundation; either version 2 of the License, or (at your
21 option) any later version.
23 or both in parallel, as here.
25 GNU Nettle is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 General Public License for more details.
30 You should have received copies of the GNU General Public License and
31 the GNU Lesser General Public License along with this program. If
32 not, see http://www.gnu.org/licenses/.
39 /* This file implements and uses deprecated functions */
40 #define _NETTLE_ATTRIBUTE_DEPRECATED
42 #include "aes-internal.h"
45 aes_invert_key(struct aes_ctx *dst,
46 const struct aes_ctx *src)
48 _aes_invert (src->rounds, dst->keys, src->keys);
49 dst->rounds = src->rounds;
53 aes_set_decrypt_key(struct aes_ctx *ctx,
54 size_t keysize, const uint8_t *key)
56 /* We first create subkeys for encryption,
57 * then modify the subkeys for decryption. */
58 aes_set_encrypt_key(ctx, keysize, key);
59 aes_invert_key(ctx, ctx);