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