1 /* aes-set-decrypt-key.c
3 * Inverse key setup for the aes/rijndael block cipher.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2000, 2001, 2002 Rafael R. Sevilla, Niels Möller
9 * Copyright (C) 2013 Niels Möller
11 * The nettle library is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or (at your
14 * option) any later version.
16 * The nettle library is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 * License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with the nettle library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 /* Originally written by Rafael R. Sevilla <dido@pacific.net.ph> */
33 #include "aes-internal.h"
36 aes_invert_key(struct aes_ctx *dst,
37 const struct aes_ctx *src)
39 _aes_invert (src->rounds, dst->keys, src->keys);
40 dst->rounds = src->rounds;
44 aes_set_decrypt_key(struct aes_ctx *ctx,
45 size_t keysize, const uint8_t *key)
47 /* We first create subkeys for encryption,
48 * then modify the subkeys for decryption. */
49 aes_set_encrypt_key(ctx, keysize, key);
50 aes_invert_key(ctx, ctx);