xref: /src/crypto/openssl/include/openssl/aes.h (revision f25b8c9fb4f58cf61adb47d7570abe7caa6d385d)
1 /*
2  * Copyright 2002-2020 The OpenSSL Project Authors. All Rights Reserved.
3  *
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
8  */
9 
10 #ifndef OPENSSL_AES_H
11 #define OPENSSL_AES_H
12 #pragma once
13 
14 #include <openssl/macros.h>
15 #ifndef OPENSSL_NO_DEPRECATED_3_0
16 #define HEADER_AES_H
17 #endif
18 
19 #include <openssl/opensslconf.h>
20 
21 #include <stddef.h>
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define AES_BLOCK_SIZE 16
27 
28 #ifndef OPENSSL_NO_DEPRECATED_3_0
29 
30 #define AES_ENCRYPT 1
31 #define AES_DECRYPT 0
32 
33 #define AES_MAXNR 14
34 
35 /* This should be a hidden type, but EVP requires that the size be known */
36 struct aes_key_st {
37 #ifdef AES_LONG
38     unsigned long rd_key[4 * (AES_MAXNR + 1)];
39 #else
40     unsigned int rd_key[4 * (AES_MAXNR + 1)];
41 #endif
42     int rounds;
43 };
44 typedef struct aes_key_st AES_KEY;
45 
46 #endif
47 #ifndef OPENSSL_NO_DEPRECATED_3_0
48 OSSL_DEPRECATEDIN_3_0 const char *AES_options(void);
49 OSSL_DEPRECATEDIN_3_0
50 int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
51     AES_KEY *key);
52 OSSL_DEPRECATEDIN_3_0
53 int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
54     AES_KEY *key);
55 OSSL_DEPRECATEDIN_3_0
56 void AES_encrypt(const unsigned char *in, unsigned char *out,
57     const AES_KEY *key);
58 OSSL_DEPRECATEDIN_3_0
59 void AES_decrypt(const unsigned char *in, unsigned char *out,
60     const AES_KEY *key);
61 OSSL_DEPRECATEDIN_3_0
62 void AES_ecb_encrypt(const unsigned char *in, unsigned char *out,
63     const AES_KEY *key, const int enc);
64 OSSL_DEPRECATEDIN_3_0
65 void AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
66     size_t length, const AES_KEY *key,
67     unsigned char *ivec, const int enc);
68 OSSL_DEPRECATEDIN_3_0
69 void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out,
70     size_t length, const AES_KEY *key,
71     unsigned char *ivec, int *num, const int enc);
72 OSSL_DEPRECATEDIN_3_0
73 void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out,
74     size_t length, const AES_KEY *key,
75     unsigned char *ivec, int *num, const int enc);
76 OSSL_DEPRECATEDIN_3_0
77 void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out,
78     size_t length, const AES_KEY *key,
79     unsigned char *ivec, int *num, const int enc);
80 OSSL_DEPRECATEDIN_3_0
81 void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out,
82     size_t length, const AES_KEY *key,
83     unsigned char *ivec, int *num);
84 
85 /* NB: the IV is _two_ blocks long */
86 OSSL_DEPRECATEDIN_3_0
87 void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
88     size_t length, const AES_KEY *key,
89     unsigned char *ivec, const int enc);
90 /* NB: the IV is _four_ blocks long */
91 OSSL_DEPRECATEDIN_3_0
92 void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
93     size_t length, const AES_KEY *key, const AES_KEY *key2,
94     const unsigned char *ivec, const int enc);
95 OSSL_DEPRECATEDIN_3_0
96 int AES_wrap_key(AES_KEY *key, const unsigned char *iv,
97     unsigned char *out, const unsigned char *in,
98     unsigned int inlen);
99 OSSL_DEPRECATEDIN_3_0
100 int AES_unwrap_key(AES_KEY *key, const unsigned char *iv,
101     unsigned char *out, const unsigned char *in,
102     unsigned int inlen);
103 #endif
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif
110