ReactOS 0.4.15-dev-8135-g1bc6c90
implglue.c
Go to the documentation of this file.
1/*
2 * dlls/rsaenh/implglue.c
3 * Glueing the RSAENH specific code to the crypto library
4 *
5 * Copyright (c) 2004, 2005 Michael Jung
6 * Copyright (c) 2007 Vijay Kiran Kamuju
7 *
8 * based on code by Mike McCormack and David Hammerton
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24#define WIN32_NO_STATUS
25#define WIN32_LEAN_AND_MEAN
26
27#include <config.h>
28
29//#include "wine/port.h"
30#include <wine/library.h>
31
32//#include "windef.h"
33#include <wincrypt.h>
34
35#include "implglue.h"
36
37//#include <stdio.h>
38
39/* Function prototypes copied from dlls/advapi32/crypt_md4.c */
41VOID WINAPI MD4Update( MD4_CTX *ctx, const unsigned char *buf, unsigned int len );
43/* Function prototypes copied from dlls/advapi32/crypt_md5.c */
45VOID WINAPI MD5Update( MD5_CTX *ctx, const unsigned char *buf, unsigned int len );
47/* Function prototypes copied from dlls/advapi32/crypt_sha.c */
51/* Function prototype copied from dlls/advapi32/crypt.c */
52BOOL WINAPI SystemFunction036(PVOID pbBuffer, ULONG dwLen);
53
54BOOL init_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext)
55{
56 switch (aiAlgid)
57 {
58 case CALG_MD2:
59 md2_init(&pHashContext->md2);
60 break;
61
62 case CALG_MD4:
63 MD4Init(&pHashContext->md4);
64 break;
65
66 case CALG_MD5:
67 MD5Init(&pHashContext->md5);
68 break;
69
70 case CALG_SHA:
71 A_SHAInit(&pHashContext->sha);
72 break;
73
74 case CALG_SHA_256:
75 SHA256_Init(&pHashContext->sha256);
76 break;
77
78 case CALG_SHA_384:
79 SHA384_Init(&pHashContext->sha384);
80 break;
81
82 case CALG_SHA_512:
83 SHA512_Init(&pHashContext->sha512);
84 break;
85 }
86
87 return TRUE;
88}
89
90BOOL update_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, const BYTE *pbData,
91 DWORD dwDataLen)
92{
93 switch (aiAlgid)
94 {
95 case CALG_MD2:
96 md2_process(&pHashContext->md2, pbData, dwDataLen);
97 break;
98
99 case CALG_MD4:
100 MD4Update(&pHashContext->md4, pbData, dwDataLen);
101 break;
102
103 case CALG_MD5:
104 MD5Update(&pHashContext->md5, pbData, dwDataLen);
105 break;
106
107 case CALG_SHA:
108 A_SHAUpdate(&pHashContext->sha, pbData, dwDataLen);
109 break;
110
111 case CALG_SHA_256:
112 SHA256_Update(&pHashContext->sha256, pbData, dwDataLen);
113 break;
114
115 case CALG_SHA_384:
116 SHA384_Update(&pHashContext->sha384, pbData, dwDataLen);
117 break;
118
119 case CALG_SHA_512:
120 SHA512_Update(&pHashContext->sha512, pbData, dwDataLen);
121 break;
122
123 default:
125 return FALSE;
126 }
127
128 return TRUE;
129}
130
131BOOL finalize_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, BYTE *pbHashValue)
132{
133 switch (aiAlgid)
134 {
135 case CALG_MD2:
136 md2_done(&pHashContext->md2, pbHashValue);
137 break;
138
139 case CALG_MD4:
140 MD4Final(&pHashContext->md4);
141 memcpy(pbHashValue, pHashContext->md4.digest, 16);
142 break;
143
144 case CALG_MD5:
145 MD5Final(&pHashContext->md5);
146 memcpy(pbHashValue, pHashContext->md5.digest, 16);
147 break;
148
149 case CALG_SHA:
150 A_SHAFinal(&pHashContext->sha, (PULONG)pbHashValue);
151 break;
152
153 case CALG_SHA_256:
154 SHA256_Final(pbHashValue, &pHashContext->sha256);
155 break;
156
157 case CALG_SHA_384:
158 SHA384_Final(pbHashValue, &pHashContext->sha384);
159 break;
160
161 case CALG_SHA_512:
162 SHA512_Final(pbHashValue, &pHashContext->sha512);
163 break;
164
165 default:
167 return FALSE;
168 }
169
170 return TRUE;
171}
172
173BOOL duplicate_hash_impl(ALG_ID aiAlgid, const HASH_CONTEXT *pSrcHashContext,
174 HASH_CONTEXT *pDestHashContext)
175{
176 *pDestHashContext = *pSrcHashContext;
177
178 return TRUE;
179}
180
181BOOL new_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen)
182{
183 switch (aiAlgid)
184 {
185 case CALG_RSA_KEYX:
186 case CALG_RSA_SIGN:
187 if (rsa_make_key((int)dwKeyLen, 65537, &pKeyContext->rsa) != CRYPT_OK) {
189 return FALSE;
190 }
191 return TRUE;
192 }
193
194 return TRUE;
195}
196
197BOOL free_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext)
198{
199 switch (aiAlgid)
200 {
201 case CALG_RSA_KEYX:
202 case CALG_RSA_SIGN:
203 rsa_free(&pKeyContext->rsa);
204 }
205
206 return TRUE;
207}
208
209BOOL setup_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
210 DWORD dwEffectiveKeyLen, DWORD dwSaltLen, BYTE *abKeyValue)
211{
212 switch (aiAlgid)
213 {
214 case CALG_RC4:
215 rc4_start(&pKeyContext->rc4);
216 rc4_add_entropy(abKeyValue, dwKeyLen + dwSaltLen, &pKeyContext->rc4);
217 rc4_ready(&pKeyContext->rc4);
218 break;
219
220 case CALG_RC2:
221 rc2_setup(abKeyValue, dwKeyLen + dwSaltLen, dwEffectiveKeyLen ?
222 dwEffectiveKeyLen : dwKeyLen << 3, 0, &pKeyContext->rc2);
223 break;
224
225 case CALG_3DES:
226 des3_setup(abKeyValue, 24, 0, &pKeyContext->des3);
227 break;
228
229 case CALG_3DES_112:
230 memcpy(abKeyValue+16, abKeyValue, 8);
231 des3_setup(abKeyValue, 24, 0, &pKeyContext->des3);
232 break;
233
234 case CALG_DES:
235 des_setup(abKeyValue, 8, 0, &pKeyContext->des);
236 break;
237
238 case CALG_AES:
239 case CALG_AES_128:
240 aes_setup(abKeyValue, 16, 0, &pKeyContext->aes);
241 break;
242
243 case CALG_AES_192:
244 aes_setup(abKeyValue, 24, 0, &pKeyContext->aes);
245 break;
246
247 case CALG_AES_256:
248 aes_setup(abKeyValue, 32, 0, &pKeyContext->aes);
249 break;
250 }
251
252 return TRUE;
253}
254
255BOOL duplicate_key_impl(ALG_ID aiAlgid, const KEY_CONTEXT *pSrcKeyContext,
256 KEY_CONTEXT *pDestKeyContext)
257{
258 switch (aiAlgid)
259 {
260 case CALG_RC4:
261 case CALG_RC2:
262 case CALG_3DES:
263 case CALG_3DES_112:
264 case CALG_DES:
265 case CALG_AES:
266 case CALG_AES_128:
267 case CALG_AES_192:
268 case CALG_AES_256:
269 *pDestKeyContext = *pSrcKeyContext;
270 break;
271 case CALG_RSA_KEYX:
272 case CALG_RSA_SIGN:
273 pDestKeyContext->rsa.type = pSrcKeyContext->rsa.type;
274 mp_init_copy(&pDestKeyContext->rsa.e, &pSrcKeyContext->rsa.e);
275 mp_init_copy(&pDestKeyContext->rsa.d, &pSrcKeyContext->rsa.d);
276 mp_init_copy(&pDestKeyContext->rsa.N, &pSrcKeyContext->rsa.N);
277 mp_init_copy(&pDestKeyContext->rsa.p, &pSrcKeyContext->rsa.p);
278 mp_init_copy(&pDestKeyContext->rsa.q, &pSrcKeyContext->rsa.q);
279 mp_init_copy(&pDestKeyContext->rsa.qP, &pSrcKeyContext->rsa.qP);
280 mp_init_copy(&pDestKeyContext->rsa.dP, &pSrcKeyContext->rsa.dP);
281 mp_init_copy(&pDestKeyContext->rsa.dQ, &pSrcKeyContext->rsa.dQ);
282 break;
283
284 default:
286 return FALSE;
287 }
288
289 return TRUE;
290}
291
292static inline void reverse_bytes(BYTE *pbData, DWORD dwLen) {
293 BYTE swap;
294 DWORD i;
295
296 for (i=0; i<dwLen/2; i++) {
297 swap = pbData[i];
298 pbData[i] = pbData[dwLen-i-1];
299 pbData[dwLen-i-1] = swap;
300 }
301}
302
303BOOL encrypt_block_impl(ALG_ID aiAlgid, DWORD dwKeySpec, KEY_CONTEXT *pKeyContext, const BYTE *in,
304 BYTE *out, DWORD enc)
305{
306 unsigned long inlen, outlen;
307 BYTE *in_reversed = NULL;
308
309 switch (aiAlgid) {
310 case CALG_RC2:
311 if (enc) {
312 rc2_ecb_encrypt(in, out, &pKeyContext->rc2);
313 } else {
314 rc2_ecb_decrypt(in, out, &pKeyContext->rc2);
315 }
316 break;
317
318 case CALG_3DES:
319 case CALG_3DES_112:
320 if (enc) {
321 des3_ecb_encrypt(in, out, &pKeyContext->des3);
322 } else {
323 des3_ecb_decrypt(in, out, &pKeyContext->des3);
324 }
325 break;
326
327 case CALG_DES:
328 if (enc) {
329 des_ecb_encrypt(in, out, &pKeyContext->des);
330 } else {
331 des_ecb_decrypt(in, out, &pKeyContext->des);
332 }
333 break;
334
335 case CALG_AES:
336 case CALG_AES_128:
337 case CALG_AES_192:
338 case CALG_AES_256:
339 if (enc) {
340 aes_ecb_encrypt(in, out, &pKeyContext->aes);
341 } else {
342 aes_ecb_decrypt(in, out, &pKeyContext->aes);
343 }
344 break;
345
346 case CALG_RSA_KEYX:
347 case CALG_RSA_SIGN:
348 case CALG_SSL3_SHAMD5:
349 outlen = inlen = (mp_count_bits(&pKeyContext->rsa.N)+7)/8;
350 if (enc) {
351 if (rsa_exptmod(in, inlen, out, &outlen, dwKeySpec, &pKeyContext->rsa) != CRYPT_OK) {
353 return FALSE;
354 }
355 reverse_bytes(out, outlen);
356 } else {
357 in_reversed = HeapAlloc(GetProcessHeap(), 0, inlen);
358 if (!in_reversed) {
360 return FALSE;
361 }
362 memcpy(in_reversed, in, inlen);
363 reverse_bytes(in_reversed, inlen);
364 if (rsa_exptmod(in_reversed, inlen, out, &outlen, dwKeySpec, &pKeyContext->rsa) != CRYPT_OK) {
365 HeapFree(GetProcessHeap(), 0, in_reversed);
367 return FALSE;
368 }
369 HeapFree(GetProcessHeap(), 0, in_reversed);
370 }
371 break;
372
373 default:
375 return FALSE;
376 }
377
378 return TRUE;
379}
380
382{
383 switch (aiAlgid) {
384 case CALG_RC4:
385 rc4_read(stream, dwLen, &pKeyContext->rc4);
386 break;
387
388 default:
390 return FALSE;
391 }
392
393 return TRUE;
394}
395
396BOOL gen_rand_impl(BYTE *pbBuffer, DWORD dwLen)
397{
398 return SystemFunction036(pbBuffer, dwLen);
399}
400
401BOOL export_public_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,DWORD *pdwPubExp)
402{
403 mp_to_unsigned_bin(&pKeyContext->rsa.N, pbDest);
404 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.N));
405 if (mp_unsigned_bin_size(&pKeyContext->rsa.N) < dwKeyLen)
406 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.N), 0,
407 dwKeyLen - mp_unsigned_bin_size(&pKeyContext->rsa.N));
408 *pdwPubExp = (DWORD)mp_get_int(&pKeyContext->rsa.e);
409 return TRUE;
410}
411
412BOOL import_public_key_impl(const BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
413 DWORD dwPubExp)
414{
415 BYTE *pbTemp;
416
417 if (mp_init_multi(&pKeyContext->rsa.e, &pKeyContext->rsa.d, &pKeyContext->rsa.N,
418 &pKeyContext->rsa.dQ,&pKeyContext->rsa.dP,&pKeyContext->rsa.qP,
419 &pKeyContext->rsa.p, &pKeyContext->rsa.q, NULL) != MP_OKAY)
420 {
422 return FALSE;
423 }
424
425 pbTemp = HeapAlloc(GetProcessHeap(), 0, dwKeyLen);
426 if (!pbTemp) return FALSE;
427 memcpy(pbTemp, pbSrc, dwKeyLen);
428
429 pKeyContext->rsa.type = PK_PUBLIC;
430 reverse_bytes(pbTemp, dwKeyLen);
431 mp_read_unsigned_bin(&pKeyContext->rsa.N, pbTemp, dwKeyLen);
432 HeapFree(GetProcessHeap(), 0, pbTemp);
433 mp_set_int(&pKeyContext->rsa.e, dwPubExp);
434
435 return TRUE;
436}
437
438BOOL export_private_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
439 DWORD *pdwPubExp)
440{
441 mp_to_unsigned_bin(&pKeyContext->rsa.N, pbDest);
442 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.N));
443 if (mp_unsigned_bin_size(&pKeyContext->rsa.N) < dwKeyLen)
444 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.N), 0,
445 dwKeyLen - mp_unsigned_bin_size(&pKeyContext->rsa.N));
446 pbDest += dwKeyLen;
447 mp_to_unsigned_bin(&pKeyContext->rsa.p, pbDest);
448 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.p));
449 if (mp_unsigned_bin_size(&pKeyContext->rsa.p) < (dwKeyLen+1)>>1)
450 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.p), 0,
451 ((dwKeyLen+1)>>1) - mp_unsigned_bin_size(&pKeyContext->rsa.p));
452 pbDest += (dwKeyLen+1)>>1;
453 mp_to_unsigned_bin(&pKeyContext->rsa.q, pbDest);
454 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.q));
455 if (mp_unsigned_bin_size(&pKeyContext->rsa.q) < (dwKeyLen+1)>>1)
456 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.q), 0,
457 ((dwKeyLen+1)>>1) - mp_unsigned_bin_size(&pKeyContext->rsa.q));
458 pbDest += (dwKeyLen+1)>>1;
459 mp_to_unsigned_bin(&pKeyContext->rsa.dP, pbDest);
460 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.dP));
461 if (mp_unsigned_bin_size(&pKeyContext->rsa.dP) < (dwKeyLen+1)>>1)
462 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.dP), 0,
463 ((dwKeyLen+1)>>1) - mp_unsigned_bin_size(&pKeyContext->rsa.dP));
464 pbDest += (dwKeyLen+1)>>1;
465 mp_to_unsigned_bin(&pKeyContext->rsa.dQ, pbDest);
466 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.dQ));
467 if (mp_unsigned_bin_size(&pKeyContext->rsa.dQ) < (dwKeyLen+1)>>1)
468 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.dQ), 0,
469 ((dwKeyLen+1)>>1) - mp_unsigned_bin_size(&pKeyContext->rsa.dQ));
470 pbDest += (dwKeyLen+1)>>1;
471 mp_to_unsigned_bin(&pKeyContext->rsa.qP, pbDest);
472 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.qP));
473 if (mp_unsigned_bin_size(&pKeyContext->rsa.qP) < (dwKeyLen+1)>>1)
474 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.qP), 0,
475 ((dwKeyLen+1)>>1) - mp_unsigned_bin_size(&pKeyContext->rsa.qP));
476 pbDest += (dwKeyLen+1)>>1;
477 mp_to_unsigned_bin(&pKeyContext->rsa.d, pbDest);
478 reverse_bytes(pbDest, mp_unsigned_bin_size(&pKeyContext->rsa.d));
479 if (mp_unsigned_bin_size(&pKeyContext->rsa.d) < dwKeyLen)
480 memset(pbDest + mp_unsigned_bin_size(&pKeyContext->rsa.d), 0,
481 dwKeyLen - mp_unsigned_bin_size(&pKeyContext->rsa.d));
482 *pdwPubExp = (DWORD)mp_get_int(&pKeyContext->rsa.e);
483
484 return TRUE;
485}
486
487BOOL import_private_key_impl(const BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen,
488 DWORD dwDataLen, DWORD dwPubExp)
489{
490 BYTE *pbTemp, *pbBigNum;
491
492 if (mp_init_multi(&pKeyContext->rsa.e, &pKeyContext->rsa.d, &pKeyContext->rsa.N,
493 &pKeyContext->rsa.dQ,&pKeyContext->rsa.dP,&pKeyContext->rsa.qP,
494 &pKeyContext->rsa.p, &pKeyContext->rsa.q, NULL) != MP_OKAY)
495 {
497 return FALSE;
498 }
499
500 pbTemp = HeapAlloc(GetProcessHeap(), 0, 2*dwKeyLen+5*((dwKeyLen+1)>>1));
501 if (!pbTemp) return FALSE;
502 memcpy(pbTemp, pbSrc, min(dwDataLen, 2*dwKeyLen+5*((dwKeyLen+1)>>1)));
503 pbBigNum = pbTemp;
504
505 pKeyContext->rsa.type = PK_PRIVATE;
506 reverse_bytes(pbBigNum, dwKeyLen);
507 mp_read_unsigned_bin(&pKeyContext->rsa.N, pbBigNum, dwKeyLen);
508 pbBigNum += dwKeyLen;
509 reverse_bytes(pbBigNum, (dwKeyLen+1)>>1);
510 mp_read_unsigned_bin(&pKeyContext->rsa.p, pbBigNum, (dwKeyLen+1)>>1);
511 pbBigNum += (dwKeyLen+1)>>1;
512 reverse_bytes(pbBigNum, (dwKeyLen+1)>>1);
513 mp_read_unsigned_bin(&pKeyContext->rsa.q, pbBigNum, (dwKeyLen+1)>>1);
514 pbBigNum += (dwKeyLen+1)>>1;
515 reverse_bytes(pbBigNum, (dwKeyLen+1)>>1);
516 mp_read_unsigned_bin(&pKeyContext->rsa.dP, pbBigNum, (dwKeyLen+1)>>1);
517 pbBigNum += (dwKeyLen+1)>>1;
518 reverse_bytes(pbBigNum, (dwKeyLen+1)>>1);
519 mp_read_unsigned_bin(&pKeyContext->rsa.dQ, pbBigNum, (dwKeyLen+1)>>1);
520 pbBigNum += (dwKeyLen+1)>>1;
521 reverse_bytes(pbBigNum, (dwKeyLen+1)>>1);
522 mp_read_unsigned_bin(&pKeyContext->rsa.qP, pbBigNum, (dwKeyLen+1)>>1);
523 pbBigNum += (dwKeyLen+1)>>1;
524 /* The size of the private exponent d is inferred from the remaining
525 * data length.
526 */
527 dwKeyLen = min(dwKeyLen, dwDataLen - (pbBigNum - pbTemp));
528 reverse_bytes(pbBigNum, dwKeyLen);
529 mp_read_unsigned_bin(&pKeyContext->rsa.d, pbBigNum, dwKeyLen);
530 mp_set_int(&pKeyContext->rsa.e, dwPubExp);
531
532 HeapFree(GetProcessHeap(), 0, pbTemp);
533 return TRUE;
534}
Definition: bufpool.h:45
#define rsa_free
Definition: compat-1.3.h:2238
#define md2_process
Definition: compat-1.3.h:2020
#define md2_init
Definition: compat-1.3.h:2019
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
void aes_ecb_encrypt(const unsigned char *pt, unsigned char *ct, aes_key *skey)
Definition: aes.c:1064
void aes_ecb_decrypt(const unsigned char *ct, unsigned char *pt, aes_key *skey)
Definition: aes.c:1165
int aes_setup(const unsigned char *key, int keylen, int rounds, aes_key *skey)
Definition: aes.c:937
int des_setup(const unsigned char *key, int keylen, int num_rounds, des_key *des)
Definition: des.c:1416
void des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const des_key *des)
Definition: des.c:1453
void des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const des_key *des)
Definition: des.c:1463
void des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, const des3_key *des3)
Definition: des.c:1473
void des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, const des3_key *des3)
Definition: des.c:1485
int des3_setup(const unsigned char *key, int keylen, int num_rounds, des3_key *des3)
Definition: des.c:1432
unsigned long rc4_read(unsigned char *buf, unsigned long len, prng_state *prng)
Definition: rc4.c:89
int rc4_ready(prng_state *prng)
Definition: rc4.c:61
int rc4_start(prng_state *prng)
Definition: rc4.c:33
int rc4_add_entropy(const unsigned char *buf, unsigned long len, prng_state *prng)
Definition: rc4.c:41
#define PK_PUBLIC
Definition: tomcrypt.h:450
@ CRYPT_OK
Definition: tomcrypt.h:43
#define MP_OKAY
Definition: tomcrypt.h:200
#define PK_PRIVATE
Definition: tomcrypt.h:449
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL finalize_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, BYTE *pbHashValue)
Definition: implglue.c:131
VOID WINAPI A_SHAFinal(PSHA_CTX Context, PULONG Result)
Definition: sha1.c:171
VOID WINAPI MD5Final(MD5_CTX *ctx)
Definition: md5.c:113
BOOL duplicate_key_impl(ALG_ID aiAlgid, const KEY_CONTEXT *pSrcKeyContext, KEY_CONTEXT *pDestKeyContext)
Definition: implglue.c:255
VOID WINAPI MD5Update(MD5_CTX *ctx, const unsigned char *buf, unsigned int len)
Definition: md5.c:59
BOOL encrypt_block_impl(ALG_ID aiAlgid, DWORD dwKeySpec, KEY_CONTEXT *pKeyContext, const BYTE *in, BYTE *out, DWORD enc)
Definition: implglue.c:303
BOOL encrypt_stream_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, BYTE *stream, DWORD dwLen)
Definition: implglue.c:381
BOOL new_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen)
Definition: implglue.c:181
BOOL free_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext)
Definition: implglue.c:197
VOID WINAPI A_SHAInit(PSHA_CTX Context)
Definition: sha1.c:102
BOOL export_public_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, DWORD *pdwPubExp)
Definition: implglue.c:401
BOOL duplicate_hash_impl(ALG_ID aiAlgid, const HASH_CONTEXT *pSrcHashContext, HASH_CONTEXT *pDestHashContext)
Definition: implglue.c:173
static void reverse_bytes(BYTE *pbData, DWORD dwLen)
Definition: implglue.c:292
VOID WINAPI MD5Init(MD5_CTX *ctx)
Definition: md5.c:45
VOID WINAPI MD4Final(MD4_CTX *ctx)
Definition: md4.c:113
BOOL update_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext, const BYTE *pbData, DWORD dwDataLen)
Definition: implglue.c:90
BOOL gen_rand_impl(BYTE *pbBuffer, DWORD dwLen)
Definition: implglue.c:396
VOID WINAPI MD4Update(MD4_CTX *ctx, const unsigned char *buf, unsigned int len)
Definition: md4.c:59
BOOL setup_key_impl(ALG_ID aiAlgid, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, DWORD dwEffectiveKeyLen, DWORD dwSaltLen, BYTE *abKeyValue)
Definition: implglue.c:209
BOOL import_public_key_impl(const BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, DWORD dwPubExp)
Definition: implglue.c:412
BOOL export_private_key_impl(BYTE *pbDest, const KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, DWORD *pdwPubExp)
Definition: implglue.c:438
VOID WINAPI MD4Init(MD4_CTX *ctx)
Definition: md4.c:45
BOOL init_hash_impl(ALG_ID aiAlgid, HASH_CONTEXT *pHashContext)
Definition: implglue.c:54
BOOL WINAPI SystemFunction036(PVOID pbBuffer, ULONG dwLen)
Definition: sysfunc.c:602
VOID WINAPI A_SHAUpdate(PSHA_CTX Context, const unsigned char *Buffer, UINT BufferSize)
Definition: sha1.c:128
BOOL import_private_key_impl(const BYTE *pbSrc, KEY_CONTEXT *pKeyContext, DWORD dwKeyLen, DWORD dwDataLen, DWORD dwPubExp)
Definition: implglue.c:487
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
int mp_to_unsigned_bin(const mp_int *a, unsigned char *b)
Definition: mpi.c:3875
unsigned long mp_get_int(const mp_int *a)
Definition: mpi.c:2320
int mp_unsigned_bin_size(const mp_int *a)
Definition: mpi.c:3899
int mp_count_bits(const mp_int *a)
Definition: mpi.c:1203
int mp_read_unsigned_bin(mp_int *a, const unsigned char *b, int c)
Definition: mpi.c:3502
int mp_init_copy(mp_int *a, const mp_int *b)
Definition: mpi.c:2344
int mp_set_int(mp_int *a, unsigned long b)
Definition: mpi.c:3687
int mp_init_multi(mp_int *mp,...)
Definition: mpi.c:2354
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define swap(a, b)
Definition: qsort.c:63
void rc2_ecb_encrypt(const unsigned char *plain, unsigned char *cipher, rc2_key *rc2)
Definition: rc2.c:111
int rc2_setup(const unsigned char *key, int keylen, int bits, int rounds, rc2_key *rc2)
Definition: rc2.c:53
void rc2_ecb_decrypt(const unsigned char *cipher, unsigned char *plain, rc2_key *rc2)
Definition: rc2.c:159
static FILE * out
Definition: regtests2xml.c:44
#define memset(x, y, z)
Definition: compat.h:39
void SHA384_Init(SHA384_CTX *context)
Definition: sha2.c:932
void SHA256_Init(SHA256_CTX *context)
Definition: sha2.c:275
void SHA256_Final(sha2_byte digest[], SHA256_CTX *context)
Definition: sha2.c:507
void SHA384_Update(SHA384_CTX *context, const sha2_byte *data, size_t len)
Definition: sha2.c:941
void SHA256_Update(SHA256_CTX *context, const sha2_byte *data, size_t len)
Definition: sha2.c:459
void SHA384_Final(sha2_byte digest[], SHA384_CTX *context)
Definition: sha2.c:945
void SHA512_Update(SHA512_CTX *context, const sha2_byte *data, size_t len)
Definition: sha2.c:781
void SHA512_Final(sha2_byte digest[], SHA512_CTX *context)
Definition: sha2.c:870
void SHA512_Init(SHA512_CTX *context)
Definition: sha2.c:603
Definition: util.c:82
Definition: msi.c:4013
mp_int p
Definition: tomcrypt.h:458
mp_int N
Definition: tomcrypt.h:458
mp_int q
Definition: tomcrypt.h:458
mp_int dP
Definition: tomcrypt.h:458
mp_int dQ
Definition: tomcrypt.h:458
mp_int e
Definition: tomcrypt.h:458
mp_int qP
Definition: tomcrypt.h:458
mp_int d
Definition: tomcrypt.h:458
int type
Definition: tomcrypt.h:457
Definition: addons.c:69
Definition: parse.h:23
unsigned char digest[16]
Definition: implglue.h:35
unsigned char digest[16]
Definition: implglue.h:44
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
SHA512_CTX sha512
Definition: implglue.h:63
SHA_CTX sha
Definition: implglue.h:60
md2_state md2
Definition: implglue.h:57
MD5_CTX md5
Definition: implglue.h:59
SHA256_CTX sha256
Definition: implglue.h:61
SHA384_CTX sha384
Definition: implglue.h:62
MD4_CTX md4
Definition: implglue.h:58
des3_key des3
Definition: implglue.h:69
prng_state rc4
Definition: implglue.h:71
rsa_key rsa
Definition: implglue.h:72
aes_key aes
Definition: implglue.h:70
des_key des
Definition: implglue.h:68
rc2_key rc2
Definition: implglue.h:67
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
int md2_done(md2_state *md2, unsigned char *hash)
Definition: md2.c:125
int rsa_make_key(int size, long e, rsa_key *key)
Definition: rsa.c:87
int rsa_exptmod(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen, int which, rsa_key *key)
Definition: rsa.c:180
#define CALG_RC2
Definition: wincrypt.h:1829
#define CALG_AES_128
Definition: wincrypt.h:1833
#define CALG_AES_192
Definition: wincrypt.h:1834
#define CALG_RSA_SIGN
Definition: wincrypt.h:1816
#define CALG_SHA_384
Definition: wincrypt.h:1814
#define CALG_RC4
Definition: wincrypt.h:1837
#define CALG_MD5
Definition: wincrypt.h:1805
#define CALG_SHA_256
Definition: wincrypt.h:1813
#define CALG_MD2
Definition: wincrypt.h:1803
#define CALG_3DES_112
Definition: wincrypt.h:1831
#define CALG_AES
Definition: wincrypt.h:1836
#define CALG_RSA_KEYX
Definition: wincrypt.h:1824
#define CALG_AES_256
Definition: wincrypt.h:1835
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201
#define CALG_3DES
Definition: wincrypt.h:1830
#define CALG_MD4
Definition: wincrypt.h:1804
#define CALG_SSL3_SHAMD5
Definition: wincrypt.h:1809
#define CALG_SHA
Definition: wincrypt.h:1806
#define CALG_DES
Definition: wincrypt.h:1828
#define CALG_SHA_512
Definition: wincrypt.h:1815
unsigned int ALG_ID
Definition: wincrypt.h:45
#define WINAPI
Definition: msvc.h:6
#define NTE_BAD_ALGID
Definition: winerror.h:2876
#define NTE_FAIL
Definition: winerror.h:2900
#define NTE_NO_MEMORY
Definition: winerror.h:2882
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char BYTE
Definition: xxhash.c:193