2 * Copyright 2002-2016 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>
19 # include <openssl/opensslconf.h>
26 # define AES_ENCRYPT 1
27 # define AES_DECRYPT 0
30 * Because array size can't be a const in C, the following two are macros.
31 * Both sizes are in bytes.
34 # define AES_BLOCK_SIZE 16
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;
47 const char *AES_options(void);
49 int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
51 int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
54 void AES_encrypt(const unsigned char *in, unsigned char *out,
56 void AES_decrypt(const unsigned char *in, unsigned char *out,
59 void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
60 const AES_KEY *key, const int enc);
61 void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
62 size_t length, const AES_KEY *key,
63 unsigned char *ivec, const int enc);
64 void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
65 size_t length, const AES_KEY *key,
66 unsigned char *ivec, int *num, const int enc);
67 void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
68 size_t length, const AES_KEY *key,
69 unsigned char *ivec, int *num, const int enc);
70 void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
71 size_t length, const AES_KEY *key,
72 unsigned char *ivec, int *num, const int enc);
73 void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
74 size_t length, const AES_KEY *key,
75 unsigned char *ivec, int *num);
77 /* NB: the IV is _two_ blocks long */
78 void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
79 size_t length, const AES_KEY *key,
80 unsigned char *ivec, const int enc);
81 /* NB: the IV is _four_ blocks long */
82 void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
83 size_t length, const AES_KEY *key,
84 const AES_KEY *key2, const unsigned char *ivec,
88 int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
90 const unsigned char *in, unsigned int inlen);
91 int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
93 const unsigned char *in, unsigned int inlen);