Rizin
unix-like reverse engineering framework and cli tools
aes-encrypt.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2002, 2013 Niels Möller
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 /* aes-encrypt.c
5 
6  Encryption function for the aes/rijndael block cipher.
7 
8  Copyright (C) 2002, 2013 Niels Möller
9 
10  This file is part of GNU Nettle.
11 
12  GNU Nettle is free software: you can redistribute it and/or
13  modify it under the terms of either:
14 
15  * the GNU Lesser General Public License as published by the Free
16  Software Foundation; either version 3 of the License, or (at your
17  option) any later version.
18 
19  or
20 
21  * the GNU General Public License as published by the Free
22  Software Foundation; either version 2 of the License, or (at your
23  option) any later version.
24 
25  or both in parallel, as here.
26 
27  GNU Nettle is distributed in the hope that it will be useful,
28  but WITHOUT ANY WARRANTY; without even the implied warranty of
29  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30  General Public License for more details.
31 
32  You should have received copies of the GNU General Public License and
33  the GNU Lesser General Public License along with this program. If
34  not, see http://www.gnu.org/licenses/.
35 */
36 
37 #if HAVE_CONFIG_H
38 # include "config.h"
39 #endif
40 
41 #include <stdlib.h>
42 
43 #include "aes-internal.h"
44 
45 /* The main point on this function is to help the assembler
46  implementations of _nettle_aes_encrypt to get the table pointer.
47  For PIC code, the details can be complex and system dependent. */
48 void
49 aes_encrypt(const struct aes_ctx *ctx,
50  size_t length, uint8_t *dst,
51  const uint8_t *src)
52 {
53  switch (ctx->key_size)
54  {
55  default: abort();
56  case AES128_KEY_SIZE:
57  aes128_encrypt(&ctx->u.ctx128, length, dst, src);
58  break;
59  case AES192_KEY_SIZE:
60  aes192_encrypt(&ctx->u.ctx192, length, dst, src);
61  break;
62  case AES256_KEY_SIZE:
63  aes256_encrypt(&ctx->u.ctx256, length, dst, src);
64  break;
65  }
66 }
void aes_encrypt(const struct aes_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
Definition: aes-encrypt.c:49
void aes128_encrypt(const struct aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
#define AES192_KEY_SIZE
Definition: aes.h:71
void aes192_encrypt(const struct aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
void aes256_encrypt(const struct aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
#define AES256_KEY_SIZE
Definition: aes.h:72
#define AES128_KEY_SIZE
Definition: aes.h:70
lzma_index * src
Definition: index.h:567
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 static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
char * dst
Definition: lz4.h:724
unsigned char uint8_t
Definition: sftypes.h:31
Definition: aes.h:151