Rizin
unix-like reverse engineering framework and cli tools
aes-set-encrypt-key.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2000, 2001, 2002 Rafael R. Sevilla, Niels Möller
2 // SPDX-FileCopyrightText: 2013 Niels Möller
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 /* aes-set-encrypt-key.c
6 
7  Key setup for the aes/rijndael block cipher.
8 
9  Copyright (C) 2000, 2001, 2002 Rafael R. Sevilla, Niels Möller
10  Copyright (C) 2013 Niels Möller
11 
12  This file is part of GNU Nettle.
13 
14  GNU Nettle is free software: you can redistribute it and/or
15  modify it under the terms of either:
16 
17  * the GNU Lesser General Public License as published by the Free
18  Software Foundation; either version 3 of the License, or (at your
19  option) any later version.
20 
21  or
22 
23  * the GNU General Public License as published by the Free
24  Software Foundation; either version 2 of the License, or (at your
25  option) any later version.
26 
27  or both in parallel, as here.
28 
29  GNU Nettle is distributed in the hope that it will be useful,
30  but WITHOUT ANY WARRANTY; without even the implied warranty of
31  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32  General Public License for more details.
33 
34  You should have received copies of the GNU General Public License and
35  the GNU Lesser General Public License along with this program. If
36  not, see http://www.gnu.org/licenses/.
37 */
38 
39 #if HAVE_CONFIG_H
40 # include "config.h"
41 #endif
42 
43 #include <stdlib.h>
44 
45 #include "aes.h"
46 
47 void
49  size_t key_size, const uint8_t *key)
50 {
51  switch (key_size)
52  {
53  default: abort();
54  case AES128_KEY_SIZE:
55  aes128_set_encrypt_key(&ctx->u.ctx128, key);
56  break;
57  case AES192_KEY_SIZE:
58  aes192_set_encrypt_key(&ctx->u.ctx192, key);
59  break;
60  case AES256_KEY_SIZE:
61  aes256_set_encrypt_key(&ctx->u.ctx256, key);
62  break;
63  }
64 
65  ctx->key_size = key_size;
66 }
void aes_set_encrypt_key(struct aes_ctx *ctx, size_t key_size, const uint8_t *key)
void aes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key)
#define AES192_KEY_SIZE
Definition: aes.h:71
#define AES256_KEY_SIZE
Definition: aes.h:72
void aes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key)
#define AES128_KEY_SIZE
Definition: aes.h:70
void aes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
Definition: sflib.h:118
unsigned char uint8_t
Definition: sftypes.h:31
Definition: aes.h:151