winepulse: Remove AudioSessionManager.
[wine.git] / dlls / bcrypt / bcrypt_internal.h
blob98223e90ac690637ad6fe395b09becb3ba590cb8
1 /*
2 * Copyright 2016 Michael Müller
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #ifndef __BCRYPT_INTERNAL_H
21 #define __BCRYPT_INTERNAL_H
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winternl.h"
28 #include "wincrypt.h"
29 #include "bcrypt.h"
30 #include "wine/unixlib.h"
32 #define MAGIC_DSS1 ('D' | ('S' << 8) | ('S' << 16) | ('1' << 24))
33 #define MAGIC_DSS2 ('D' | ('S' << 8) | ('S' << 16) | ('2' << 24))
35 typedef struct
37 ULONG64 len;
38 DWORD h[8];
39 UCHAR buf[64];
40 } SHA256_CTX;
42 void sha256_init(SHA256_CTX *ctx) DECLSPEC_HIDDEN;
43 void sha256_update(SHA256_CTX *ctx, const UCHAR *buffer, ULONG len) DECLSPEC_HIDDEN;
44 void sha256_finalize(SHA256_CTX *ctx, UCHAR *buffer) DECLSPEC_HIDDEN;
46 typedef struct
48 ULONG64 len;
49 ULONG64 h[8];
50 UCHAR buf[128];
51 } SHA512_CTX;
53 void sha512_init(SHA512_CTX *ctx) DECLSPEC_HIDDEN;
54 void sha512_update(SHA512_CTX *ctx, const UCHAR *buffer, ULONG len) DECLSPEC_HIDDEN;
55 void sha512_finalize(SHA512_CTX *ctx, UCHAR *buffer) DECLSPEC_HIDDEN;
57 void sha384_init(SHA512_CTX *ctx) DECLSPEC_HIDDEN;
58 #define sha384_update sha512_update
59 void sha384_finalize(SHA512_CTX *ctx, UCHAR *buffer) DECLSPEC_HIDDEN;
61 typedef struct {
62 unsigned char chksum[16], X[48], buf[16];
63 unsigned long curlen;
64 } MD2_CTX;
66 void md2_init(MD2_CTX *ctx) DECLSPEC_HIDDEN;
67 void md2_update(MD2_CTX *ctx, const unsigned char *buf, ULONG len) DECLSPEC_HIDDEN;
68 void md2_finalize(MD2_CTX *ctx, unsigned char *hash) DECLSPEC_HIDDEN;
70 /* Definitions from advapi32 */
71 typedef struct tagMD4_CTX {
72 unsigned int buf[4];
73 unsigned int i[2];
74 unsigned char in[64];
75 unsigned char digest[16];
76 } MD4_CTX;
78 VOID WINAPI MD4Init(MD4_CTX *ctx);
79 VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len);
80 VOID WINAPI MD4Final(MD4_CTX *ctx);
82 typedef struct
84 unsigned int i[2];
85 unsigned int buf[4];
86 unsigned char in[64];
87 unsigned char digest[16];
88 } MD5_CTX;
90 VOID WINAPI MD5Init(MD5_CTX *ctx);
91 VOID WINAPI MD5Update(MD5_CTX *ctx, const unsigned char *buf, unsigned int len);
92 VOID WINAPI MD5Final(MD5_CTX *ctx);
94 typedef struct
96 ULONG Unknown[6];
97 ULONG State[5];
98 ULONG Count[2];
99 UCHAR Buffer[64];
100 } SHA_CTX;
102 VOID WINAPI A_SHAInit(SHA_CTX *ctx);
103 VOID WINAPI A_SHAUpdate(SHA_CTX *ctx, const UCHAR *buffer, UINT size);
104 VOID WINAPI A_SHAFinal(SHA_CTX *ctx, PULONG result);
106 #define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
107 #define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
108 #define MAGIC_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '0')
109 #define MAGIC_SECRET (('S' << 24) | ('C' << 16) | ('R' << 8) | 'T')
110 struct object
112 ULONG magic;
115 enum alg_id
117 /* cipher */
118 ALG_ID_3DES,
119 ALG_ID_AES,
121 /* hash */
122 ALG_ID_SHA256,
123 ALG_ID_SHA384,
124 ALG_ID_SHA512,
125 ALG_ID_SHA1,
126 ALG_ID_MD5,
127 ALG_ID_MD4,
128 ALG_ID_MD2,
130 /* asymmetric encryption */
131 ALG_ID_RSA,
133 /* secret agreement */
134 ALG_ID_ECDH_P256,
135 ALG_ID_ECDH_P384,
137 /* signature */
138 ALG_ID_RSA_SIGN,
139 ALG_ID_ECDSA_P256,
140 ALG_ID_ECDSA_P384,
141 ALG_ID_DSA,
143 /* rng */
144 ALG_ID_RNG,
147 enum chain_mode
149 CHAIN_MODE_CBC,
150 CHAIN_MODE_ECB,
151 CHAIN_MODE_CFB,
152 CHAIN_MODE_CCM,
153 CHAIN_MODE_GCM,
156 struct algorithm
158 struct object hdr;
159 enum alg_id id;
160 enum chain_mode mode;
161 unsigned flags;
164 struct key_symmetric
166 enum chain_mode mode;
167 ULONG block_size;
168 UCHAR *vector;
169 ULONG vector_len;
170 UCHAR *secret;
171 unsigned secret_len;
172 CRITICAL_SECTION cs;
175 #define KEY_FLAG_LEGACY_DSA_V2 0x00000001
177 struct key_asymmetric
179 ULONG bitlen; /* ignored for ECC keys */
180 unsigned flags;
181 DSSSEED dss_seed;
184 struct key
186 struct object hdr;
187 enum alg_id alg_id;
188 UINT64 private[2]; /* private data for backend */
189 union
191 struct key_symmetric s;
192 struct key_asymmetric a;
193 } u;
196 struct secret
198 struct object hdr;
201 struct key_symmetric_set_auth_data_params
203 struct key *key;
204 UCHAR *auth_data;
205 ULONG len;
208 struct key_symmetric_encrypt_params
210 struct key *key;
211 const UCHAR *input;
212 unsigned input_len;
213 UCHAR *output;
214 ULONG output_len;
217 struct key_symmetric_decrypt_params
219 struct key *key;
220 const UCHAR *input;
221 unsigned input_len;
222 UCHAR *output;
223 ULONG output_len;
226 struct key_symmetric_get_tag_params
228 struct key *key;
229 UCHAR *tag;
230 ULONG len;
233 struct key_asymmetric_decrypt_params
235 struct key *key;
236 UCHAR *input;
237 unsigned input_len;
238 UCHAR *output;
239 ULONG output_len;
240 ULONG *ret_len;
243 struct key_asymmetric_encrypt_params
245 struct key *key;
246 UCHAR *input;
247 unsigned input_len;
248 UCHAR *output;
249 ULONG output_len;
250 ULONG *ret_len;
253 struct key_asymmetric_duplicate_params
255 struct key *key_orig;
256 struct key *key_copy;
259 struct key_asymmetric_sign_params
261 struct key *key;
262 void *padding;
263 UCHAR *input;
264 unsigned input_len;
265 UCHAR *output;
266 ULONG output_len;
267 ULONG *ret_len;
268 unsigned flags;
271 struct key_asymmetric_verify_params
273 struct key *key;
274 void *padding;
275 UCHAR *hash;
276 unsigned hash_len;
277 UCHAR *signature;
278 ULONG signature_len;
279 unsigned flags;
282 #define KEY_EXPORT_FLAG_PUBLIC 0x00000001
283 #define KEY_EXPORT_FLAG_RSA_FULL 0x00000002
284 struct key_asymmetric_export_params
286 struct key *key;
287 ULONG flags;
288 UCHAR *buf;
289 ULONG len;
290 ULONG *ret_len;
293 #define KEY_IMPORT_FLAG_PUBLIC 0x00000001
294 struct key_asymmetric_import_params
296 struct key *key;
297 ULONG flags;
298 UCHAR *buf;
299 ULONG len;
302 enum key_funcs
304 unix_process_attach,
305 unix_process_detach,
306 unix_key_symmetric_vector_reset,
307 unix_key_symmetric_set_auth_data,
308 unix_key_symmetric_encrypt,
309 unix_key_symmetric_decrypt,
310 unix_key_symmetric_get_tag,
311 unix_key_symmetric_destroy,
312 unix_key_asymmetric_generate,
313 unix_key_asymmetric_decrypt,
314 unix_key_asymmetric_encrypt,
315 unix_key_asymmetric_duplicate,
316 unix_key_asymmetric_sign,
317 unix_key_asymmetric_verify,
318 unix_key_asymmetric_destroy,
319 unix_key_asymmetric_export,
320 unix_key_asymmetric_import,
323 #endif /* __BCRYPT_INTERNAL_H */