]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/aes.h
Copyright consolidation 03/10
[thirdparty/openssl.git] / include / openssl / aes.h
CommitLineData
21dcbebc
RS
1/*
2 * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
6f9079fd 3 *
21dcbebc
RS
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
6f9079fd
RL
8 */
9
10#ifndef HEADER_AES_H
0f113f3e 11# define HEADER_AES_H
6f9079fd 12
0f113f3e 13# include <openssl/opensslconf.h>
940767b0 14
0f113f3e 15# include <stddef.h>
3c27208f
RS
16# ifdef __cplusplus
17extern "C" {
18# endif
f768be81 19
0f113f3e
MC
20# define AES_ENCRYPT 1
21# define AES_DECRYPT 0
aa18245f 22
0f113f3e
MC
23/*
24 * Because array size can't be a const in C, the following two are macros.
25 * Both sizes are in bytes.
26 */
27# define AES_MAXNR 14
28# define AES_BLOCK_SIZE 16
6f9079fd 29
6f9079fd
RL
30/* This should be a hidden type, but EVP requires that the size be known */
31struct aes_key_st {
0f113f3e
MC
32# ifdef AES_LONG
33 unsigned long rd_key[4 * (AES_MAXNR + 1)];
34# else
35 unsigned int rd_key[4 * (AES_MAXNR + 1)];
36# endif
6f9079fd
RL
37 int rounds;
38};
39typedef struct aes_key_st AES_KEY;
40
41const char *AES_options(void);
42
97879bcd 43int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
0f113f3e 44 AES_KEY *key);
97879bcd 45int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
0f113f3e 46 AES_KEY *key);
6f9079fd 47
97879bcd 48void AES_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e 49 const AES_KEY *key);
97879bcd 50void AES_decrypt(const unsigned char *in, unsigned char *out,
0f113f3e 51 const AES_KEY *key);
6f9079fd
RL
52
53void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e 54 const AES_KEY *key, const int enc);
6f9079fd 55void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
56 size_t length, const AES_KEY *key,
57 unsigned char *ivec, const int enc);
97879bcd 58void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
59 size_t length, const AES_KEY *key,
60 unsigned char *ivec, int *num, const int enc);
8d1ebe0b 61void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
62 size_t length, const AES_KEY *key,
63 unsigned char *ivec, int *num, const int enc);
8d1ebe0b 64void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
65 size_t length, const AES_KEY *key,
66 unsigned char *ivec, int *num, const int enc);
97879bcd 67void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
68 size_t length, const AES_KEY *key,
69 unsigned char *ivec, int *num);
aa6d1a0c
BL
70/* NB: the IV is _two_ blocks long */
71void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
72 size_t length, const AES_KEY *key,
73 unsigned char *ivec, const int enc);
aa6d1a0c
BL
74/* NB: the IV is _four_ blocks long */
75void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
0f113f3e
MC
76 size_t length, const AES_KEY *key,
77 const AES_KEY *key2, const unsigned char *ivec,
78 const int enc);
97879bcd 79
6e3bc4f0 80int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
0f113f3e
MC
81 unsigned char *out,
82 const unsigned char *in, unsigned int inlen);
6e3bc4f0 83int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
0f113f3e
MC
84 unsigned char *out,
85 const unsigned char *in, unsigned int inlen);
6e3bc4f0 86
6f9079fd 87
3c27208f 88# ifdef __cplusplus
6f9079fd 89}
3c27208f 90# endif
6f9079fd 91
3c27208f 92#endif