2 * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
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
15 typedef void (*block128_f) (const unsigned char in[16],
16 unsigned char out[16], const void *key);
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);
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]);
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]);
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);
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,
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);
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,
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);
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],
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],
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);
83 size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in,
84 unsigned char *out, size_t len,
86 unsigned char ivec[16],
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,
94 unsigned char ivec[16],
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);
100 typedef struct gcm128_context GCM128_CONTEXT;
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,
106 int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad,
108 int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
109 const unsigned char *in, unsigned char *out,
111 int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
112 const unsigned char *in, unsigned char *out,
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,
122 void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
123 void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx);
125 typedef struct ccm128_context CCM128_CONTEXT;
127 void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx,
128 unsigned int M, unsigned int L, void *key,
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,
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,
141 int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp,
142 unsigned char *out, size_t len,
144 size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len);
146 typedef struct xts128_context XTS128_CONTEXT;
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);
153 size_t CRYPTO_128_wrap(void *key, const unsigned char *iv,
155 const unsigned char *in, size_t inlen,
158 size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
160 const unsigned char *in, size_t inlen,
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);
169 #ifndef OPENSSL_NO_OCB
170 typedef struct ocb128_context OCB128_CONTEXT;
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]);
179 OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec,
180 block128_f encrypt, block128_f decrypt,
182 int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec,
183 block128_f encrypt, block128_f decrypt,
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,
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,
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 */