Rizin
unix-like reverse engineering framework and cli tools
aes-decrypt.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-decrypt.c
5 
6  Decryption function for 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 void
46 aes_decrypt(const struct aes_ctx *ctx,
47  size_t length, uint8_t *dst,
48  const uint8_t *src)
49 {
50  switch (ctx->key_size)
51  {
52  default: abort();
53  case AES128_KEY_SIZE:
54  aes128_decrypt(&ctx->u.ctx128, length, dst, src);
55  break;
56  case AES192_KEY_SIZE:
57  aes192_decrypt(&ctx->u.ctx192, length, dst, src);
58  break;
59  case AES256_KEY_SIZE:
60  aes256_decrypt(&ctx->u.ctx256, length, dst, src);
61  break;
62  }
63 }
void aes_decrypt(const struct aes_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
Definition: aes-decrypt.c:46
void aes128_decrypt(const struct aes128_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
#define AES192_KEY_SIZE
Definition: aes.h:71
#define AES256_KEY_SIZE
Definition: aes.h:72
void aes256_decrypt(const struct aes256_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
#define AES128_KEY_SIZE
Definition: aes.h:70
void aes192_decrypt(const struct aes192_ctx *ctx, size_t length, uint8_t *dst, const uint8_t *src)
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