api-ms-win-core-comm-l1-1-0: Add dll.
[wine.git] / dlls / bcrypt / bcrypt_internal.h
bloba40f9d1a4b76419f914ca54e38e3e85d4ac97f69
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>
24 #ifdef HAVE_GNUTLS_CIPHER_INIT
25 #include <gnutls/gnutls.h>
26 #include <gnutls/crypto.h>
27 #include <gnutls/abstract.h>
28 #elif HAVE_COMMONCRYPTO_COMMONCRYPTOR_H
29 #include <AvailabilityMacros.h>
30 #include <CommonCrypto/CommonCryptor.h>
31 #endif
33 #include "windef.h"
34 #include "winbase.h"
35 #include "bcrypt.h"
37 typedef struct
39 ULONG64 len;
40 DWORD h[8];
41 UCHAR buf[64];
42 } SHA256_CTX;
44 void sha256_init(SHA256_CTX *ctx) DECLSPEC_HIDDEN;
45 void sha256_update(SHA256_CTX *ctx, const UCHAR *buffer, ULONG len) DECLSPEC_HIDDEN;
46 void sha256_finalize(SHA256_CTX *ctx, UCHAR *buffer) DECLSPEC_HIDDEN;
48 typedef struct
50 ULONG64 len;
51 ULONG64 h[8];
52 UCHAR buf[128];
53 } SHA512_CTX;
55 void sha512_init(SHA512_CTX *ctx) DECLSPEC_HIDDEN;
56 void sha512_update(SHA512_CTX *ctx, const UCHAR *buffer, ULONG len) DECLSPEC_HIDDEN;
57 void sha512_finalize(SHA512_CTX *ctx, UCHAR *buffer) DECLSPEC_HIDDEN;
59 void sha384_init(SHA512_CTX *ctx) DECLSPEC_HIDDEN;
60 #define sha384_update sha512_update
61 void sha384_finalize(SHA512_CTX *ctx, UCHAR *buffer) DECLSPEC_HIDDEN;
63 typedef struct {
64 unsigned char chksum[16], X[48], buf[16];
65 unsigned long curlen;
66 } MD2_CTX;
68 void md2_init(MD2_CTX *ctx) DECLSPEC_HIDDEN;
69 void md2_update(MD2_CTX *ctx, const unsigned char *buf, ULONG len) DECLSPEC_HIDDEN;
70 void md2_finalize(MD2_CTX *ctx, unsigned char *hash) DECLSPEC_HIDDEN;
72 /* Definitions from advapi32 */
73 typedef struct tagMD4_CTX {
74 unsigned int buf[4];
75 unsigned int i[2];
76 unsigned char in[64];
77 unsigned char digest[16];
78 } MD4_CTX;
80 VOID WINAPI MD4Init(MD4_CTX *ctx);
81 VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len);
82 VOID WINAPI MD4Final(MD4_CTX *ctx);
84 typedef struct
86 unsigned int i[2];
87 unsigned int buf[4];
88 unsigned char in[64];
89 unsigned char digest[16];
90 } MD5_CTX;
92 VOID WINAPI MD5Init(MD5_CTX *ctx);
93 VOID WINAPI MD5Update(MD5_CTX *ctx, const unsigned char *buf, unsigned int len);
94 VOID WINAPI MD5Final(MD5_CTX *ctx);
96 typedef struct
98 ULONG Unknown[6];
99 ULONG State[5];
100 ULONG Count[2];
101 UCHAR Buffer[64];
102 } SHA_CTX;
104 VOID WINAPI A_SHAInit(SHA_CTX *ctx);
105 VOID WINAPI A_SHAUpdate(SHA_CTX *ctx, const UCHAR *buffer, UINT size);
106 VOID WINAPI A_SHAFinal(SHA_CTX *ctx, PULONG result);
108 #define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
109 #define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
110 #define MAGIC_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '0')
111 struct object
113 ULONG magic;
116 enum alg_id
118 ALG_ID_AES,
119 ALG_ID_MD2,
120 ALG_ID_MD4,
121 ALG_ID_MD5,
122 ALG_ID_RNG,
123 ALG_ID_RSA,
124 ALG_ID_SHA1,
125 ALG_ID_SHA256,
126 ALG_ID_SHA384,
127 ALG_ID_SHA512,
128 ALG_ID_ECDSA_P256,
129 ALG_ID_ECDSA_P384,
132 enum mode_id
134 MODE_ID_ECB,
135 MODE_ID_CBC,
136 MODE_ID_GCM
139 struct algorithm
141 struct object hdr;
142 enum alg_id id;
143 enum mode_id mode;
144 BOOL hmac;
147 #if defined(HAVE_GNUTLS_CIPHER_INIT)
148 struct key_symmetric
150 enum mode_id mode;
151 ULONG block_size;
152 gnutls_cipher_hd_t handle;
153 UCHAR *secret;
154 ULONG secret_len;
157 struct key_asymmetric
159 UCHAR *pubkey;
160 ULONG pubkey_len;
163 struct key
165 struct object hdr;
166 enum alg_id alg_id;
167 union
169 struct key_symmetric s;
170 struct key_asymmetric a;
171 } u;
173 #elif defined(HAVE_COMMONCRYPTO_COMMONCRYPTOR_H) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
174 struct key_symmetric
176 enum mode_id mode;
177 ULONG block_size;
178 CCCryptorRef ref_encrypt;
179 CCCryptorRef ref_decrypt;
180 UCHAR *secret;
181 ULONG secret_len;
184 struct key_asymmetric
186 UCHAR *pubkey;
187 ULONG pubkey_len;
190 struct key
192 struct object hdr;
193 enum alg_id alg_id;
194 union
196 struct key_symmetric s;
197 struct key_asymmetric a;
198 } u;
200 #else
201 struct key
203 struct object hdr;
205 #endif
207 NTSTATUS get_alg_property( const struct algorithm *, const WCHAR *, UCHAR *, ULONG, ULONG * ) DECLSPEC_HIDDEN;
209 NTSTATUS key_set_property( struct key *, const WCHAR *, UCHAR *, ULONG, ULONG ) DECLSPEC_HIDDEN;
210 NTSTATUS key_symmetric_init( struct key *, struct algorithm *, const UCHAR *, ULONG ) DECLSPEC_HIDDEN;
211 NTSTATUS key_symmetric_set_params( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
212 NTSTATUS key_symmetric_set_auth_data( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
213 NTSTATUS key_symmetric_encrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
214 NTSTATUS key_symmetric_decrypt( struct key *, const UCHAR *, ULONG, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
215 NTSTATUS key_symmetric_get_tag( struct key *, UCHAR *, ULONG ) DECLSPEC_HIDDEN;
216 NTSTATUS key_asymmetric_init( struct key *, struct algorithm *, const UCHAR *, ULONG ) DECLSPEC_HIDDEN;
217 NTSTATUS key_asymmetric_verify( struct key *, void *, UCHAR *, ULONG, UCHAR *, ULONG, DWORD ) DECLSPEC_HIDDEN;
218 NTSTATUS key_destroy( struct key * ) DECLSPEC_HIDDEN;
219 BOOL key_is_symmetric( struct key * ) DECLSPEC_HIDDEN;
221 BOOL gnutls_initialize(void) DECLSPEC_HIDDEN;
222 void gnutls_uninitialize(void) DECLSPEC_HIDDEN;
224 #endif /* __BCRYPT_INTERNAL_H */