2 * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
11 # define OPENSSL_AES_H
14 # include <openssl/macros.h>
15 # ifndef OPENSSL_NO_DEPRECATED_3_0
19 # include <openssl/opensslconf.h>
26 # define AES_BLOCK_SIZE 16
28 # ifndef OPENSSL_NO_DEPRECATED_3_0
30 # define AES_ENCRYPT 1
31 # define AES_DECRYPT 0
36 /* This should be a hidden type, but EVP requires that the size be known */
39 unsigned long rd_key[4 * (AES_MAXNR + 1)];
41 unsigned int rd_key[4 * (AES_MAXNR + 1)];
45 typedef struct aes_key_st AES_KEY;
49 DEPRECATEDIN_3_0(const char *AES_options(void))
52 AES_set_encrypt_key(const unsigned char *userKey,
53 const int bits, AES_KEY *key))
55 AES_set_decrypt_key(const unsigned char *userKey,
56 const int bits, AES_KEY *key))
59 AES_encrypt(const unsigned char *in, unsigned char *out,
62 AES_decrypt(const unsigned char *in, unsigned char *out,
66 AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
67 const AES_KEY *key, const int enc))
69 AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
70 size_t length, const AES_KEY *key,
71 unsigned char *ivec, const int enc))
73 AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
74 size_t length, const AES_KEY *key,
75 unsigned char *ivec, int *num,
78 AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
79 size_t length, const AES_KEY *key,
80 unsigned char *ivec, int *num, const int enc))
82 AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
83 size_t length, const AES_KEY *key,
84 unsigned char *ivec, int *num, const int enc))
86 AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
87 size_t length, const AES_KEY *key,
88 unsigned char *ivec, int *num))
90 /* NB: the IV is _two_ blocks long */
92 AES_ige_encrypt(const unsigned char *in, unsigned char *out,
93 size_t length, const AES_KEY *key,
94 unsigned char *ivec, const int enc))
95 /* NB: the IV is _four_ blocks long */
97 AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
98 size_t length, const AES_KEY *key,
100 const unsigned char *ivec, const int enc))
103 AES_wrap_key(AES_KEY *key, const unsigned char *iv,
104 unsigned char *out, const unsigned char *in,
107 AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
108 unsigned char *out, const unsigned char *in,