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
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))
42 void sha256_init(SHA256_CTX
*ctx
);
43 void sha256_update(SHA256_CTX
*ctx
, const UCHAR
*buffer
, ULONG len
);
44 void sha256_finalize(SHA256_CTX
*ctx
, UCHAR
*buffer
);
53 void sha512_init(SHA512_CTX
*ctx
);
54 void sha512_update(SHA512_CTX
*ctx
, const UCHAR
*buffer
, ULONG len
);
55 void sha512_finalize(SHA512_CTX
*ctx
, UCHAR
*buffer
);
57 void sha384_init(SHA512_CTX
*ctx
);
58 #define sha384_update sha512_update
59 void sha384_finalize(SHA512_CTX
*ctx
, UCHAR
*buffer
);
62 unsigned char chksum
[16], X
[48], buf
[16];
66 void md2_init(MD2_CTX
*ctx
);
67 void md2_update(MD2_CTX
*ctx
, const unsigned char *buf
, ULONG len
);
68 void md2_finalize(MD2_CTX
*ctx
, unsigned char *hash
);
70 /* Definitions from advapi32 */
71 typedef struct tagMD4_CTX
{
75 unsigned char digest
[16];
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
);
87 unsigned char digest
[16];
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
);
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')
131 /* asymmetric encryption */
134 /* secret agreement */
162 enum chain_mode mode
;
168 enum chain_mode mode
;
177 #define KEY_FLAG_LEGACY_DSA_V2 0x00000001
178 #define KEY_FLAG_FINALIZED 0x00000002
180 struct key_asymmetric
182 ULONG bitlen
; /* ignored for ECC keys */
187 #define PRIVATE_DATA_SIZE 3
192 UINT64
private[PRIVATE_DATA_SIZE
]; /* private data for backend */
195 struct key_symmetric s
;
196 struct key_asymmetric a
;
207 struct key_symmetric_set_auth_data_params
214 struct key_symmetric_encrypt_params
223 struct key_symmetric_decrypt_params
232 struct key_symmetric_get_tag_params
239 struct key_asymmetric_decrypt_params
251 struct key_asymmetric_encrypt_params
263 struct key_asymmetric_duplicate_params
265 struct key
*key_orig
;
266 struct key
*key_copy
;
269 struct key_asymmetric_sign_params
281 struct key_asymmetric_verify_params
292 #define KEY_EXPORT_FLAG_PUBLIC 0x00000001
293 #define KEY_EXPORT_FLAG_RSA_FULL 0x00000002
294 #define KEY_EXPORT_FLAG_DH_PARAMETERS 0x00000004
296 struct key_asymmetric_export_params
305 #define KEY_IMPORT_FLAG_PUBLIC 0x00000001
306 #define KEY_IMPORT_FLAG_DH_PARAMETERS 0x00000002
308 struct key_asymmetric_import_params
316 struct key_asymmetric_derive_key_params
329 unix_key_symmetric_vector_reset
,
330 unix_key_symmetric_set_auth_data
,
331 unix_key_symmetric_encrypt
,
332 unix_key_symmetric_decrypt
,
333 unix_key_symmetric_get_tag
,
334 unix_key_symmetric_destroy
,
335 unix_key_asymmetric_generate
,
336 unix_key_asymmetric_decrypt
,
337 unix_key_asymmetric_encrypt
,
338 unix_key_asymmetric_duplicate
,
339 unix_key_asymmetric_sign
,
340 unix_key_asymmetric_verify
,
341 unix_key_asymmetric_destroy
,
342 unix_key_asymmetric_export
,
343 unix_key_asymmetric_import
,
344 unix_key_asymmetric_derive_key
,
348 #endif /* __BCRYPT_INTERNAL_H */