Merge branch 'dev' of feistymeow.org:feisty_meow into dev
[feisty_meow.git] / production / 3rdparty / deprecated / openssl / include / openssl / modes.h
1 /*
2  * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
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
8  */
9
10 #include <stddef.h>
11
12 #ifdef  __cplusplus
13 extern "C" {
14 #endif
15 typedef void (*block128_f) (const unsigned char in[16],
16                             unsigned char out[16], const void *key);
17
18 typedef void (*cbc128_f) (const unsigned char *in, unsigned char *out,
19                           size_t len, const void *key,
20                           unsigned char ivec[16], int enc);
21
22 typedef void (*ctr128_f) (const unsigned char *in, unsigned char *out,
23                           size_t blocks, const void *key,
24                           const unsigned char ivec[16]);
25
26 typedef void (*ccm128_f) (const unsigned char *in, unsigned char *out,
27                           size_t blocks, const void *key,
28                           const unsigned char ivec[16],
29                           unsigned char cmac[16]);
30
31 void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
32                            size_t len, const void *key,
33                            unsigned char ivec[16], block128_f block);
34 void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
35                            size_t len, const void *key,
36                            unsigned char ivec[16], block128_f block);
37
38 void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out,
39                            size_t len, const void *key,
40                            unsigned char ivec[16],
41                            unsigned char ecount_buf[16], unsigned int *num,
42                            block128_f block);
43
44 void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out,
45                                  size_t len, const void *key,
46                                  unsigned char ivec[16],
47                                  unsigned char ecount_buf[16],
48                                  unsigned int *num, ctr128_f ctr);
49
50 void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out,
51                            size_t len, const void *key,
52                            unsigned char ivec[16], int *num,
53                            block128_f block);
54
55 void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out,
56                            size_t len, const void *key,
57                            unsigned char ivec[16], int *num,
58                            int enc, block128_f block);
59 void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out,
60                              size_t length, const void *key,
61                              unsigned char ivec[16], int *num,
62                              int enc, block128_f block);
63 void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out,
64                              size_t bits, const void *key,
65                              unsigned char ivec[16], int *num,
66                              int enc, block128_f block);
67
68 size_t CRYPTO_cts128_encrypt_block(const unsigned char *in,
69                                    unsigned char *out, size_t len,
70                                    const void *key, unsigned char ivec[16],
71                                    block128_f block);
72 size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out,
73                              size_t len, const void *key,
74                              unsigned char ivec[16], cbc128_f cbc);
75 size_t CRYPTO_cts128_decrypt_block(const unsigned char *in,
76                                    unsigned char *out, size_t len,
77                                    const void *key, unsigned char ivec[16],
78                                    block128_f block);
79 size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out,
80                              size_t len, const void *key,
81                              unsigned char ivec[16], cbc128_f cbc);
82
83 size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,
84                                        unsigned char *out, size_t len,
85                                        const void *key,
86                                        unsigned char ivec[16],
87                                        block128_f block);
88 size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out,
89                                  size_t len, const void *key,
90                                  unsigned char ivec[16], cbc128_f cbc);
91 size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in,
92                                        unsigned char *out, size_t len,
93                                        const void *key,
94                                        unsigned char ivec[16],
95                                        block128_f block);
96 size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out,
97                                  size_t len, const void *key,
98                                  unsigned char ivec[16], cbc128_f cbc);
99
100 typedef struct gcm128_context GCM128_CONTEXT;
101
102 GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block);
103 void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block);
104 void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv,
105                          size_t len);
106 int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
107                       size_t len);
108 int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
109                           const unsigned char *in, unsigned char *out,
110                           size_t len);
111 int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
112                           const unsigned char *in, unsigned char *out,
113                           size_t len);
114 int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx,
115                                 const unsigned char *in, unsigned char *out,
116                                 size_t len, ctr128_f stream);
117 int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx,
118                                 const unsigned char *in, unsigned char *out,
119                                 size_t len, ctr128_f stream);
120 int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag,
121                          size_t len);
122 void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
123 void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
124
125 typedef struct ccm128_context CCM128_CONTEXT;
126
127 void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
128                         unsigned int M, unsigned int L, void *key,
129                         block128_f block);
130 int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce,
131                         size_t nlen, size_t mlen);
132 void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad,
133                        size_t alen);
134 int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,
135                           unsigned char *out, size_t len);
136 int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp,
137                           unsigned char *out, size_t len);
138 int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
139                                 unsigned char *out, size_t len,
140                                 ccm128_f stream);
141 int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
142                                 unsigned char *out, size_t len,
143                                 ccm128_f stream);
144 size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
145
146 typedef struct xts128_context XTS128_CONTEXT;
147
148 int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx,
149                           const unsigned char iv[16],
150                           const unsigned char *inp, unsigned char *out,
151                           size_t len, int enc);
152
153 size_t CRYPTO_128_wrap(void *key, const unsigned char *iv,
154                        unsigned char *out,
155                        const unsigned char *in, size_t inlen,
156                        block128_f block);
157
158 size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
159                          unsigned char *out,
160                          const unsigned char *in, size_t inlen,
161                          block128_f block);
162 size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv,
163                            unsigned char *out, const unsigned char *in,
164                            size_t inlen, block128_f block);
165 size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv,
166                              unsigned char *out, const unsigned char *in,
167                              size_t inlen, block128_f block);
168
169 #ifndef OPENSSL_NO_OCB
170 typedef struct ocb128_context OCB128_CONTEXT;
171
172 typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out,
173                           size_t blocks, const void *key,
174                           size_t start_block_num,
175                           unsigned char offset_i[16],
176                           const unsigned char L_[][16],
177                           unsigned char checksum[16]);
178
179 OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
180                                   block128_f encrypt, block128_f decrypt,
181                                   ocb128_f stream);
182 int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec,
183                        block128_f encrypt, block128_f decrypt,
184                        ocb128_f stream);
185 int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src,
186                            void *keyenc, void *keydec);
187 int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv,
188                         size_t len, size_t taglen);
189 int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad,
190                       size_t len);
191 int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in,
192                           unsigned char *out, size_t len);
193 int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in,
194                           unsigned char *out, size_t len);
195 int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag,
196                          size_t len);
197 int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len);
198 void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx);
199 #endif                          /* OPENSSL_NO_OCB */
200
201 #ifdef  __cplusplus
202 }
203 #endif