ReactOS  0.4.13-dev-66-gc714b7f
bcrypt_main.c
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  *
18  */
19 
20 #include <wine/config.h>
21 #include <wine/port.h>
22 
23 #include <ntstatus.h>
24 #define WIN32_NO_STATUS
25 #include <windef.h>
26 #include <winbase.h>
27 #include <ntsecapi.h>
28 #include <bcrypt.h>
29 
30 #include <wine/debug.h>
31 #include <wine/unicode.h>
32 #include <wine/library.h>
33 
34 #ifdef SONAME_LIBMBEDTLS
35 #include <mbedtls/md.h>
36 #include <mbedtls/md5.h>
37 #include <mbedtls/sha1.h>
38 #include <mbedtls/sha256.h>
39 #include <mbedtls/sha512.h>
40 #endif
41 
43 
45 
46 #if defined(HAVE_GNUTLS_HASH) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
48 
49 static void *libgnutls_handle;
50 #define MAKE_FUNCPTR(f) static typeof(f) * p##f
51 MAKE_FUNCPTR(gnutls_global_deinit);
52 MAKE_FUNCPTR(gnutls_global_init);
53 MAKE_FUNCPTR(gnutls_global_set_log_function);
54 MAKE_FUNCPTR(gnutls_global_set_log_level);
55 MAKE_FUNCPTR(gnutls_hash);
56 MAKE_FUNCPTR(gnutls_hash_deinit);
57 MAKE_FUNCPTR(gnutls_hash_init);
58 MAKE_FUNCPTR(gnutls_hmac);
59 MAKE_FUNCPTR(gnutls_hmac_deinit);
60 MAKE_FUNCPTR(gnutls_hmac_init);
61 MAKE_FUNCPTR(gnutls_perror);
62 #undef MAKE_FUNCPTR
63 
64 static void gnutls_log( int level, const char *msg )
65 {
66  TRACE( "<%d> %s", level, msg );
67 }
68 
69 static BOOL gnutls_initialize(void)
70 {
71  int ret;
72 
73  if (!(libgnutls_handle = wine_dlopen( SONAME_LIBGNUTLS, RTLD_NOW, NULL, 0 )))
74  {
75  ERR_(winediag)( "failed to load libgnutls, no support for crypto hashes\n" );
76  return FALSE;
77  }
78 
79 #define LOAD_FUNCPTR(f) \
80  if (!(p##f = wine_dlsym( libgnutls_handle, #f, NULL, 0 ))) \
81  { \
82  ERR( "failed to load %s\n", #f ); \
83  goto fail; \
84  }
85 
86  LOAD_FUNCPTR(gnutls_global_deinit)
87  LOAD_FUNCPTR(gnutls_global_init)
88  LOAD_FUNCPTR(gnutls_global_set_log_function)
89  LOAD_FUNCPTR(gnutls_global_set_log_level)
90  LOAD_FUNCPTR(gnutls_hash);
91  LOAD_FUNCPTR(gnutls_hash_deinit);
92  LOAD_FUNCPTR(gnutls_hash_init);
93  LOAD_FUNCPTR(gnutls_hmac);
94  LOAD_FUNCPTR(gnutls_hmac_deinit);
95  LOAD_FUNCPTR(gnutls_hmac_init);
96  LOAD_FUNCPTR(gnutls_perror)
97 #undef LOAD_FUNCPTR
98 
99  if ((ret = pgnutls_global_init()) != GNUTLS_E_SUCCESS)
100  {
101  pgnutls_perror( ret );
102  goto fail;
103  }
104 
105  if (TRACE_ON( bcrypt ))
106  {
107  pgnutls_global_set_log_level( 4 );
108  pgnutls_global_set_log_function( gnutls_log );
109  }
110 
111  return TRUE;
112 
113 fail:
114  wine_dlclose( libgnutls_handle, NULL, 0 );
115  libgnutls_handle = NULL;
116  return FALSE;
117 }
118 
119 static void gnutls_uninitialize(void)
120 {
121  pgnutls_global_deinit();
122  wine_dlclose( libgnutls_handle, NULL, 0 );
123  libgnutls_handle = NULL;
124 }
125 #elif defined(SONAME_LIBMBEDTLS) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H) && !defined(__REACTOS__)
127 
128 void *libmbedtls_handle;
129 
130 #define MAKE_FUNCPTR(f) static typeof(f) * p##f
157 #undef MAKE_FUNCPTR
158 
159 #define mbedtls_md_init pmbedtls_md_init
160 #define mbedtls_md_setup pmbedtls_md_setup
161 #define mbedtls_md_update pmbedtls_md_update
162 #define mbedtls_md_hmac_starts pmbedtls_md_hmac_starts
163 #define mbedtls_md_hmac_finish pmbedtls_md_hmac_finish
164 #define mbedtls_md_free pmbedtls_md_free
165 #define mbedtls_md5_init pmbedtls_md5_init
166 #define mbedtls_md5_starts pmbedtls_md5_starts
167 #define mbedtls_md5_update pmbedtls_md5_update
168 #define mbedtls_md5_finish pmbedtls_md5_finish
169 #define mbedtls_md5_free pmbedtls_md5_free
170 #define mbedtls_sha1_init pmbedtls_sha1_init
171 #define mbedtls_sha1_starts pmbedtls_sha1_starts
172 #define mbedtls_sha1_update pmbedtls_sha1_update
173 #define mbedtls_sha1_finish pmbedtls_sha1_finish
174 #define mbedtls_sha1_free pmbedtls_sha1_free
175 #define mbedtls_sha256_init pmbedtls_sha256_init
176 #define mbedtls_sha256_starts pmbedtls_sha256_starts
177 #define mbedtls_sha256_update pmbedtls_sha256_update
178 #define mbedtls_sha256_finish pmbedtls_sha256_finish
179 #define mbedtls_sha256_free pmbedtls_sha256_free
180 #define mbedtls_sha512_init pmbedtls_sha512_init
181 #define mbedtls_sha512_starts pmbedtls_sha512_starts
182 #define mbedtls_sha512_update pmbedtls_sha512_update
183 #define mbedtls_sha512_finish pmbedtls_sha512_finish
184 #define mbedtls_sha512_free pmbedtls_sha512_free
185 
186 static BOOL mbedtls_initialize(void)
187 {
189  {
190  ERR_(winediag)( "failed to load libmbedtls, no support for crypto hashes\n" );
191  return FALSE;
192  }
193 
194 #define LOAD_FUNCPTR(f) \
195  if (!(p##f = wine_dlsym( libmbedtls_handle, #f, NULL, 0 ))) \
196  { \
197  ERR( "failed to load %s\n", #f ); \
198  goto fail; \
199  }
200 
227 #undef LOAD_FUNCPTR
228 
229  return TRUE;
230 
231 fail:
234  return FALSE;
235 }
236 
237 static void mbedtls_uninitialize(void)
238 {
241 }
242 #endif /* SONAME_LIBMBEDTLS && !HAVE_COMMONCRYPTO_COMMONDIGEST_H && !__REACTOS__ */
243 
244 NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount,
246 {
247  FIXME("%08x, %p, %p, %08x - stub\n", dwAlgOperations, pAlgCount, ppAlgList, dwFlags);
248 
249  *ppAlgList=NULL;
250  *pAlgCount=0;
251 
252  return STATUS_NOT_IMPLEMENTED;
253 }
254 
255 #define MAGIC_ALG (('A' << 24) | ('L' << 16) | ('G' << 8) | '0')
256 #define MAGIC_HASH (('H' << 24) | ('A' << 16) | ('S' << 8) | 'H')
257 struct object
258 {
260 };
261 
262 enum alg_id
263 {
270 };
271 
272 static const struct {
274  const WCHAR *alg_name;
275 } alg_props[] = {
276  /* ALG_ID_MD5 */ { 16, BCRYPT_MD5_ALGORITHM },
277  /* ALG_ID_RNG */ { 0, BCRYPT_RNG_ALGORITHM },
278  /* ALG_ID_SHA1 */ { 20, BCRYPT_SHA1_ALGORITHM },
279  /* ALG_ID_SHA256 */ { 32, BCRYPT_SHA256_ALGORITHM },
280  /* ALG_ID_SHA384 */ { 48, BCRYPT_SHA384_ALGORITHM },
281  /* ALG_ID_SHA512 */ { 64, BCRYPT_SHA512_ALGORITHM }
282 };
283 
284 struct algorithm
285 {
286  struct object hdr;
287  enum alg_id id;
289 };
290 
292 {
293  const DWORD supported_flags = BCRYPT_USE_SYSTEM_PREFERRED_RNG;
294  struct algorithm *algorithm = handle;
295 
296  TRACE("%p, %p, %u, %08x - semi-stub\n", handle, buffer, count, flags);
297 
298  if (!algorithm)
299  {
300  /* It's valid to call without an algorithm if BCRYPT_USE_SYSTEM_PREFERRED_RNG
301  * is set. In this case the preferred system RNG is used.
302  */
304  return STATUS_INVALID_HANDLE;
305  }
306  else if (algorithm->hdr.magic != MAGIC_ALG || algorithm->id != ALG_ID_RNG)
307  return STATUS_INVALID_HANDLE;
308 
309  if (!buffer)
311 
312  if (flags & ~supported_flags)
313  FIXME("unsupported flags %08x\n", flags & ~supported_flags);
314 
315  if (algorithm)
316  FIXME("ignoring selected algorithm\n");
317 
318  /* When zero bytes are requested the function returns success too. */
319  if (!count)
320  return STATUS_SUCCESS;
321 
323  {
324  if (RtlGenRandom(buffer, count))
325  return STATUS_SUCCESS;
326  }
327 
328  FIXME("called with unsupported parameters, returning error\n");
329  return STATUS_NOT_IMPLEMENTED;
330 }
331 
333 {
334  struct algorithm *alg;
335  enum alg_id alg_id;
336 
337  const DWORD supported_flags = BCRYPT_ALG_HANDLE_HMAC_FLAG;
338 
339  TRACE( "%p, %s, %s, %08x\n", handle, wine_dbgstr_w(id), wine_dbgstr_w(implementation), flags );
340 
341  if (!handle || !id) return STATUS_INVALID_PARAMETER;
342  if (flags & ~supported_flags)
343  {
344  FIXME( "unsupported flags %08x\n", flags & ~supported_flags);
345  return STATUS_NOT_IMPLEMENTED;
346  }
347 
349  else if (!strcmpW( id, BCRYPT_MD5_ALGORITHM )) alg_id = ALG_ID_MD5;
350  else if (!strcmpW( id, BCRYPT_RNG_ALGORITHM )) alg_id = ALG_ID_RNG;
354  else
355  {
356  FIXME( "algorithm %s not supported\n", debugstr_w(id) );
357  return STATUS_NOT_IMPLEMENTED;
358  }
359  if (implementation && strcmpW( implementation, MS_PRIMITIVE_PROVIDER ))
360  {
361  FIXME( "implementation %s not supported\n", debugstr_w(implementation) );
362  return STATUS_NOT_IMPLEMENTED;
363  }
364 
365  if (!(alg = HeapAlloc( GetProcessHeap(), 0, sizeof(*alg) ))) return STATUS_NO_MEMORY;
366  alg->hdr.magic = MAGIC_ALG;
367  alg->id = alg_id;
369 
370  *handle = alg;
371  return STATUS_SUCCESS;
372 }
373 
375 {
376  struct algorithm *alg = handle;
377 
378  TRACE( "%p, %08x\n", handle, flags );
379 
380  if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
381  HeapFree( GetProcessHeap(), 0, alg );
382  return STATUS_SUCCESS;
383 }
384 
386 {
387  FIXME("%p - semi-stub\n", enabled);
388 
389  if (!enabled)
391 
392  *enabled = FALSE;
393  return STATUS_SUCCESS;
394 }
395 
396 #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H
397 struct hash
398 {
399  struct object hdr;
400  enum alg_id alg_id;
401  BOOL hmac;
402  union
403  {
404  CC_MD5_CTX md5_ctx;
405  CC_SHA1_CTX sha1_ctx;
406  CC_SHA256_CTX sha256_ctx;
407  CC_SHA512_CTX sha512_ctx;
408  CCHmacContext hmac_ctx;
409  } u;
410 };
411 
412 static NTSTATUS hash_init( struct hash *hash )
413 {
414  switch (hash->alg_id)
415  {
416  case ALG_ID_MD5:
417  CC_MD5_Init( &hash->u.md5_ctx );
418  break;
419 
420  case ALG_ID_SHA1:
421  CC_SHA1_Init( &hash->u.sha1_ctx );
422  break;
423 
424  case ALG_ID_SHA256:
425  CC_SHA256_Init( &hash->u.sha256_ctx );
426  break;
427 
428  case ALG_ID_SHA384:
429  CC_SHA384_Init( &hash->u.sha512_ctx );
430  break;
431 
432  case ALG_ID_SHA512:
433  CC_SHA512_Init( &hash->u.sha512_ctx );
434  break;
435 
436  default:
437  ERR( "unhandled id %u\n", hash->alg_id );
438  return STATUS_NOT_IMPLEMENTED;
439  }
440  return STATUS_SUCCESS;
441 }
442 
443 static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
444 {
445  CCHmacAlgorithm cc_algorithm;
446  switch (hash->alg_id)
447  {
448  case ALG_ID_MD5:
449  cc_algorithm = kCCHmacAlgMD5;
450  break;
451 
452  case ALG_ID_SHA1:
453  cc_algorithm = kCCHmacAlgSHA1;
454  break;
455 
456  case ALG_ID_SHA256:
457  cc_algorithm = kCCHmacAlgSHA256;
458  break;
459 
460  case ALG_ID_SHA384:
461  cc_algorithm = kCCHmacAlgSHA384;
462  break;
463 
464  case ALG_ID_SHA512:
465  cc_algorithm = kCCHmacAlgSHA512;
466  break;
467 
468  default:
469  ERR( "unhandled id %u\n", hash->alg_id );
470  return STATUS_NOT_IMPLEMENTED;
471  }
472 
473  CCHmacInit( &hash->u.hmac_ctx, cc_algorithm, key, key_size );
474  return STATUS_SUCCESS;
475 }
476 
477 
478 static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
479 {
480  switch (hash->alg_id)
481  {
482  case ALG_ID_MD5:
483  CC_MD5_Update( &hash->u.md5_ctx, input, size );
484  break;
485 
486  case ALG_ID_SHA1:
487  CC_SHA1_Update( &hash->u.sha1_ctx, input, size );
488  break;
489 
490  case ALG_ID_SHA256:
491  CC_SHA256_Update( &hash->u.sha256_ctx, input, size );
492  break;
493 
494  case ALG_ID_SHA384:
495  CC_SHA384_Update( &hash->u.sha512_ctx, input, size );
496  break;
497 
498  case ALG_ID_SHA512:
499  CC_SHA512_Update( &hash->u.sha512_ctx, input, size );
500  break;
501 
502  default:
503  ERR( "unhandled id %u\n", hash->alg_id );
504  return STATUS_NOT_IMPLEMENTED;
505  }
506  return STATUS_SUCCESS;
507 }
508 
509 static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size )
510 {
511  CCHmacUpdate( &hash->u.hmac_ctx, input, size );
512  return STATUS_SUCCESS;
513 }
514 
515 static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
516 {
517  switch (hash->alg_id)
518  {
519  case ALG_ID_MD5:
520  CC_MD5_Final( output, &hash->u.md5_ctx );
521  break;
522 
523  case ALG_ID_SHA1:
524  CC_SHA1_Final( output, &hash->u.sha1_ctx );
525  break;
526 
527  case ALG_ID_SHA256:
528  CC_SHA256_Final( output, &hash->u.sha256_ctx );
529  break;
530 
531  case ALG_ID_SHA384:
532  CC_SHA384_Final( output, &hash->u.sha512_ctx );
533  break;
534 
535  case ALG_ID_SHA512:
536  CC_SHA512_Final( output, &hash->u.sha512_ctx );
537  break;
538 
539  default:
540  ERR( "unhandled id %u\n", hash->alg_id );
541  break;
542  }
543  return STATUS_SUCCESS;
544 }
545 
546 static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
547 {
548  CCHmacFinal( &hash->u.hmac_ctx, output );
549 
550  return STATUS_SUCCESS;
551 }
552 #elif defined(HAVE_GNUTLS_HASH)
553 struct hash
554 {
555  struct object hdr;
556  enum alg_id alg_id;
557  BOOL hmac;
558  union
559  {
560  gnutls_hash_hd_t hash_handle;
561  gnutls_hmac_hd_t hmac_handle;
562  } u;
563 };
564 
565 static NTSTATUS hash_init( struct hash *hash )
566 {
567  gnutls_digest_algorithm_t alg;
568 
569  if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
570 
571  switch (hash->alg_id)
572  {
573  case ALG_ID_MD5:
574  alg = GNUTLS_DIG_MD5;
575  break;
576  case ALG_ID_SHA1:
577  alg = GNUTLS_DIG_SHA1;
578  break;
579 
580  case ALG_ID_SHA256:
581  alg = GNUTLS_DIG_SHA256;
582  break;
583 
584  case ALG_ID_SHA384:
585  alg = GNUTLS_DIG_SHA384;
586  break;
587 
588  case ALG_ID_SHA512:
589  alg = GNUTLS_DIG_SHA512;
590  break;
591 
592  default:
593  ERR( "unhandled id %u\n", hash->alg_id );
594  return STATUS_NOT_IMPLEMENTED;
595  }
596 
597  if (pgnutls_hash_init( &hash->u.hash_handle, alg )) return STATUS_INTERNAL_ERROR;
598  return STATUS_SUCCESS;
599 }
600 
601 static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
602 {
603  gnutls_mac_algorithm_t alg;
604 
605  if (!libgnutls_handle) return STATUS_INTERNAL_ERROR;
606 
607  switch (hash->alg_id)
608  {
609  case ALG_ID_MD5:
610  alg = GNUTLS_MAC_MD5;
611  break;
612  case ALG_ID_SHA1:
613  alg = GNUTLS_MAC_SHA1;
614  break;
615 
616  case ALG_ID_SHA256:
617  alg = GNUTLS_MAC_SHA256;
618  break;
619 
620  case ALG_ID_SHA384:
621  alg = GNUTLS_MAC_SHA384;
622  break;
623 
624  case ALG_ID_SHA512:
625  alg = GNUTLS_MAC_SHA512;
626  break;
627 
628  default:
629  ERR( "unhandled id %u\n", hash->alg_id );
630  return STATUS_NOT_IMPLEMENTED;
631  }
632 
633  if (pgnutls_hmac_init( &hash->u.hmac_handle, alg, key, key_size )) return STATUS_INTERNAL_ERROR;
634  return STATUS_SUCCESS;
635 }
636 
637 static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
638 {
639  if (pgnutls_hash( hash->u.hash_handle, input, size )) return STATUS_INTERNAL_ERROR;
640  return STATUS_SUCCESS;
641 }
642 
643 static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size )
644 {
645  if (pgnutls_hmac( hash->u.hmac_handle, input, size )) return STATUS_INTERNAL_ERROR;
646  return STATUS_SUCCESS;
647 }
648 
649 static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
650 {
651  pgnutls_hash_deinit( hash->u.hash_handle, output );
652  return STATUS_SUCCESS;
653 }
654 
655 static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
656 {
657  pgnutls_hmac_deinit( hash->u.hmac_handle, output );
658  return STATUS_SUCCESS;
659 }
660 #elif defined(SONAME_LIBMBEDTLS)
661 struct hash
662 {
663  struct object hdr;
664  BOOL hmac;
665  enum alg_id alg_id;
666  union
667  {
668  mbedtls_md5_context md5_ctx;
669  mbedtls_sha1_context sha1_ctx;
670  mbedtls_sha256_context sha256_ctx;
671  mbedtls_sha512_context sha512_ctx;
672  mbedtls_md_context_t hmac_ctx;
673  } u;
674 };
675 
676 static NTSTATUS hash_init( struct hash *hash )
677 {
678 #ifndef __REACTOS__
680 #endif
681  switch (hash->alg_id)
682  {
683  case ALG_ID_MD5:
684  mbedtls_md5_init(&hash->u.md5_ctx);
685  mbedtls_md5_starts(&hash->u.md5_ctx);
686  break;
687 
688  case ALG_ID_SHA1:
689  mbedtls_sha1_init(&hash->u.sha1_ctx);
690  mbedtls_sha1_starts(&hash->u.sha1_ctx);
691  break;
692 
693  case ALG_ID_SHA256:
694  mbedtls_sha256_init(&hash->u.sha256_ctx);
695  mbedtls_sha256_starts(&hash->u.sha256_ctx, FALSE);
696  break;
697 
698  case ALG_ID_SHA384:
699  case ALG_ID_SHA512:
700  mbedtls_sha512_init(&hash->u.sha512_ctx);
701  mbedtls_sha512_starts(&hash->u.sha512_ctx, hash->alg_id==ALG_ID_SHA384);
702  break;
703 
704  default:
705  ERR( "unhandled id %u\n", hash->alg_id );
706  return STATUS_NOT_IMPLEMENTED;
707  }
708 
709  return STATUS_SUCCESS;
710 }
711 
712 static NTSTATUS hmac_init( struct hash *hash, UCHAR *key, ULONG key_size )
713 {
714  const mbedtls_md_info_t *md_info;
715  mbedtls_md_type_t md_type;
716  int ret;
717 #ifndef __REACTOS__
719 #endif
720  mbedtls_md_init(&hash->u.hmac_ctx);
721  switch (hash->alg_id)
722  {
723  case ALG_ID_MD5:
724  md_type = MBEDTLS_MD_MD5;
725  break;
726 
727  case ALG_ID_SHA1:
728  md_type = MBEDTLS_MD_SHA1;
729  break;
730 
731  case ALG_ID_SHA256:
732  md_type = MBEDTLS_MD_SHA256;
733  break;
734 
735  case ALG_ID_SHA384:
736  md_type = MBEDTLS_MD_SHA384;
737  break;
738 
739  case ALG_ID_SHA512:
740  md_type = MBEDTLS_MD_SHA512;
741  break;
742 
743  default:
744  ERR("unhandled id %u\n", hash->alg_id);
745  return STATUS_NOT_IMPLEMENTED;
746  }
747  if ((md_info = mbedtls_md_info_from_type(md_type)) == NULL)
748  {
749  mbedtls_md_free(&hash->u.hmac_ctx);
750  return STATUS_INTERNAL_ERROR;
751  }
752 
753  if ((ret = mbedtls_md_setup(&hash->u.hmac_ctx, md_info, 1)) != 0)
754  {
755  mbedtls_md_free(&hash->u.hmac_ctx);
756  return STATUS_INTERNAL_ERROR;
757  }
758 
759  mbedtls_md_hmac_starts(&hash->u.hmac_ctx, key, key_size);
760 
761  return STATUS_SUCCESS;
762 }
763 
764 static NTSTATUS hash_update( struct hash *hash, UCHAR *input, ULONG size )
765 {
766 #ifndef __REACTOS__
768 #endif
769  switch (hash->alg_id)
770  {
771  case ALG_ID_MD5:
772  mbedtls_md5_update(&hash->u.md5_ctx, input, size);
773  break;
774 
775  case ALG_ID_SHA1:
776  mbedtls_sha1_update(&hash->u.sha1_ctx, input, size);
777  break;
778 
779  case ALG_ID_SHA256:
780  mbedtls_sha256_update(&hash->u.sha256_ctx, input, size);
781  break;
782 
783  case ALG_ID_SHA384:
784  case ALG_ID_SHA512:
785  mbedtls_sha512_update(&hash->u.sha512_ctx, input, size);
786  break;
787 
788  default:
789  ERR( "unhandled id %u\n", hash->alg_id );
790  return STATUS_NOT_IMPLEMENTED;
791  }
792 
793  return STATUS_SUCCESS;
794 }
795 
796 static NTSTATUS hmac_update( struct hash *hash, UCHAR *input, ULONG size )
797 {
798 #ifndef __REACTOS__
800 #endif
801  mbedtls_md_update(&hash->u.hmac_ctx, input, size);
802 
803  return STATUS_SUCCESS;
804 }
805 
806 static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
807 {
808 #ifndef __REACTOS__
810 #endif
811  switch (hash->alg_id)
812  {
813  case ALG_ID_MD5:
814  mbedtls_md5_finish(&hash->u.md5_ctx, output);
815  mbedtls_md5_free(&hash->u.md5_ctx);
816  break;
817 
818  case ALG_ID_SHA1:
819  mbedtls_sha1_finish(&hash->u.sha1_ctx, output);
820  mbedtls_sha1_free(&hash->u.sha1_ctx);
821  break;
822 
823  case ALG_ID_SHA256:
824  mbedtls_sha256_finish(&hash->u.sha256_ctx, output);
825  mbedtls_sha256_free(&hash->u.sha256_ctx);
826  break;
827 
828  case ALG_ID_SHA384:
829  case ALG_ID_SHA512:
830  mbedtls_sha512_finish(&hash->u.sha512_ctx, output);
831  mbedtls_sha512_free(&hash->u.sha512_ctx);
832  break;
833 
834  default:
835  ERR( "unhandled id %u\n", hash->alg_id );
836  return STATUS_NOT_IMPLEMENTED;
837  }
838 
839  return STATUS_SUCCESS;
840 }
841 
842 static NTSTATUS hmac_finish( struct hash *hash, UCHAR *output, ULONG size )
843 {
844 #ifndef __REACTOS__
846 #endif
847  mbedtls_md_hmac_finish(&hash->u.hmac_ctx, output);
848  mbedtls_md_free(&hash->u.hmac_ctx);
849 
850  return STATUS_SUCCESS;
851 }
852 #endif
853 
854 #define OBJECT_LENGTH_MD5 274
855 #define OBJECT_LENGTH_SHA1 278
856 #define OBJECT_LENGTH_SHA256 286
857 #define OBJECT_LENGTH_SHA384 382
858 #define OBJECT_LENGTH_SHA512 382
859 
860 static NTSTATUS generic_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
861 {
862  if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
863  {
864  *ret_size = sizeof(ULONG);
865  if (size < sizeof(ULONG))
867  if(buf)
868  *(ULONG*)buf = alg_props[id].hash_length;
869  return STATUS_SUCCESS;
870  }
871 
872  if (!strcmpW( prop, BCRYPT_ALGORITHM_NAME ))
873  {
874  *ret_size = (strlenW(alg_props[id].alg_name)+1)*sizeof(WCHAR);
875  if (size < *ret_size)
877  if(buf)
878  memcpy(buf, alg_props[id].alg_name, *ret_size);
879  return STATUS_SUCCESS;
880  }
881 
882  return STATUS_NOT_IMPLEMENTED;
883 }
884 
885 static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
886 {
888  ULONG value;
889 
890  status = generic_alg_property( id, prop, buf, size, ret_size );
892  return status;
893 
894  switch (id)
895  {
896  case ALG_ID_MD5:
897  if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
898  {
900  break;
901  }
902  FIXME( "unsupported md5 algorithm property %s\n", debugstr_w(prop) );
903  return STATUS_NOT_IMPLEMENTED;
904 
905  case ALG_ID_RNG:
906  if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH )) return STATUS_NOT_SUPPORTED;
907  FIXME( "unsupported rng algorithm property %s\n", debugstr_w(prop) );
908  return STATUS_NOT_IMPLEMENTED;
909 
910  case ALG_ID_SHA1:
911  if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
912  {
914  break;
915  }
916  FIXME( "unsupported sha1 algorithm property %s\n", debugstr_w(prop) );
917  return STATUS_NOT_IMPLEMENTED;
918 
919  case ALG_ID_SHA256:
920  if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
921  {
923  break;
924  }
925  FIXME( "unsupported sha256 algorithm property %s\n", debugstr_w(prop) );
926  return STATUS_NOT_IMPLEMENTED;
927 
928  case ALG_ID_SHA384:
929  if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
930  {
932  break;
933  }
934  FIXME( "unsupported sha384 algorithm property %s\n", debugstr_w(prop) );
935  return STATUS_NOT_IMPLEMENTED;
936 
937  case ALG_ID_SHA512:
938  if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
939  {
941  break;
942  }
943  FIXME( "unsupported sha512 algorithm property %s\n", debugstr_w(prop) );
944  return STATUS_NOT_IMPLEMENTED;
945 
946  default:
947  FIXME( "unsupported algorithm %u\n", id );
948  return STATUS_NOT_IMPLEMENTED;
949  }
950 
951  if (size < sizeof(ULONG))
952  {
953  *ret_size = sizeof(ULONG);
955  }
956  if (buf) *(ULONG *)buf = value;
957  *ret_size = sizeof(ULONG);
958 
959  return STATUS_SUCCESS;
960 }
961 
962 static NTSTATUS get_hash_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
963 {
965 
966  status = generic_alg_property( id, prop, buf, size, ret_size );
968  FIXME( "unsupported property %s\n", debugstr_w(prop) );
969  return status;
970 }
971 
973 {
974  struct object *object = handle;
975 
976  TRACE( "%p, %s, %p, %u, %p, %08x\n", handle, wine_dbgstr_w(prop), buffer, count, res, flags );
977 
978  if (!object) return STATUS_INVALID_HANDLE;
979  if (!prop || !res) return STATUS_INVALID_PARAMETER;
980 
981  switch (object->magic)
982  {
983  case MAGIC_ALG:
984  {
985  const struct algorithm *alg = (const struct algorithm *)object;
986  return get_alg_property( alg->id, prop, buffer, count, res );
987  }
988  case MAGIC_HASH:
989  {
990  const struct hash *hash = (const struct hash *)object;
991  return get_hash_property( hash->alg_id, prop, buffer, count, res );
992  }
993  default:
994  WARN( "unknown magic %08x\n", object->magic );
995  return STATUS_INVALID_HANDLE;
996  }
997 }
998 
1001 {
1002  struct algorithm *alg = algorithm;
1003  struct hash *hash;
1004  NTSTATUS status;
1005 
1006  TRACE( "%p, %p, %p, %u, %p, %u, %08x - stub\n", algorithm, handle, object, objectlen,
1007  secret, secretlen, flags );
1008  if (flags)
1009  {
1010  FIXME( "unimplemented flags %08x\n", flags );
1011  return STATUS_NOT_IMPLEMENTED;
1012  }
1013 
1014  if (!alg || alg->hdr.magic != MAGIC_ALG) return STATUS_INVALID_HANDLE;
1015  if (object) FIXME( "ignoring object buffer\n" );
1016 
1017  if (!(hash = HeapAlloc( GetProcessHeap(), 0, sizeof(*hash) ))) return STATUS_NO_MEMORY;
1018  hash->hdr.magic = MAGIC_HASH;
1019  hash->alg_id = alg->id;
1020  hash->hmac = alg->hmac;
1021 
1022  if (hash->hmac)
1023  {
1024  status = hmac_init( hash, secret, secretlen );
1025  }
1026  else
1027  {
1028  status = hash_init( hash );
1029  }
1030 
1031  if (status != STATUS_SUCCESS)
1032  {
1033  HeapFree( GetProcessHeap(), 0, hash );
1034  return status;
1035  }
1036 
1037  *handle = hash;
1038  return STATUS_SUCCESS;
1039 }
1040 
1042 {
1043  struct hash *hash = handle;
1044 
1045  TRACE( "%p\n", handle );
1046 
1047  if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
1048  HeapFree( GetProcessHeap(), 0, hash );
1049  return STATUS_SUCCESS;
1050 }
1051 
1053 {
1054  struct hash *hash = handle;
1055 
1056  TRACE( "%p, %p, %u, %08x\n", handle, input, size, flags );
1057 
1058  if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
1059  if (!input) return STATUS_SUCCESS;
1060 
1061  if (hash->hmac)
1062  {
1063  return hmac_update( hash, input, size );
1064  }
1065  else
1066  {
1067  return hash_update( hash, input, size );
1068  }
1069 }
1070 
1072 {
1073  struct hash *hash = handle;
1074 
1075  TRACE( "%p, %p, %u, %08x\n", handle, output, size, flags );
1076 
1077  if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
1078  if (!output) return STATUS_INVALID_PARAMETER;
1079 
1080  if (hash->hmac)
1081  {
1082  return hmac_finish( hash, output, size );
1083  }
1084  else
1085  {
1086  return hash_finish( hash, output, size );
1087  }
1088 }
1089 
1092 {
1093  NTSTATUS status;
1095 
1096  TRACE( "%p, %p, %u, %p, %u, %p, %u\n", algorithm, secret, secretlen,
1098 
1100  if (status != STATUS_SUCCESS)
1101  {
1102  return status;
1103  }
1104 
1106  if (status != STATUS_SUCCESS)
1107  {
1109  return status;
1110  }
1111 
1113  if (status != STATUS_SUCCESS)
1114  {
1116  return status;
1117  }
1118 
1119  return BCryptDestroyHash( handle );
1120 }
1121 
1123 {
1124  switch (reason)
1125  {
1126  case DLL_PROCESS_ATTACH:
1127  instance = hinst;
1129 #if defined(HAVE_GNUTLS_HASH) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
1130  gnutls_initialize();
1131 #elif defined(SONAME_LIBMBEDTLS) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H) && !defined(__REACTOS__)
1132  mbedtls_initialize();
1133 #endif
1134  break;
1135 
1136  case DLL_PROCESS_DETACH:
1137  if (reserved) break;
1138 #if defined(HAVE_GNUTLS_HASH) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
1139  gnutls_uninitialize();
1140 #elif defined(SONAME_LIBMBEDTLS) && !defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H) && !defined(__REACTOS__)
1141  mbedtls_uninitialize();
1142 #endif
1143  break;
1144  }
1145  return TRUE;
1146 }
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 * u
Definition: glfuncs.h:240
static UCHAR ULONG UCHAR ULONG UCHAR ULONG outputlen
Definition: bcrypt.c:29
#define MS_PRIMITIVE_PROVIDER
Definition: bcrypt.h:69
MBEDTLS_DEPRECATED void mbedtls_sha1_starts(mbedtls_sha1_context *ctx)
SHA-1 context setup.
const WCHAR * alg_name
Definition: bcrypt_main.c:274
MBEDTLS_DEPRECATED void mbedtls_sha1_update(mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen)
SHA-1 process buffer.
GLint level
Definition: gl.h:1546
NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount, BCRYPT_ALGORITHM_IDENTIFIER **ppAlgList, ULONG dwFlags)
Definition: bcrypt_main.c:244
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE handle, UCHAR *buffer, ULONG count, ULONG flags)
Definition: bcrypt_main.c:291
#define BCRYPT_USE_SYSTEM_PREFERRED_RNG
Definition: bcrypt.h:171
char hdr[14]
Definition: iptest.cpp:33
void mbedtls_sha512_init(mbedtls_sha512_context *ctx)
This function initializes a SHA-512 context.
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void * libmbedtls_handle
void mbedtls_sha1_init(mbedtls_sha1_context *ctx)
This function initializes a SHA-1 context.
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define OBJECT_LENGTH_MD5
Definition: bcrypt_main.c:854
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
MBEDTLS_DEPRECATED void mbedtls_sha256_finish(mbedtls_sha256_context *ctx, unsigned char output[32])
This function finishes the SHA-256 operation, and writes the result to the output buffer.
#define BCRYPT_OBJECT_LENGTH
Definition: bcrypt.h:56
void mbedtls_sha256_init(mbedtls_sha256_context *ctx)
This function initializes a SHA-256 context.
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define BCRYPT_MD5_ALGORITHM
Definition: bcrypt.h:72
#define WARN(fmt,...)
Definition: debug.h:111
#define ERR_(ch,...)
Definition: debug.h:156
WINE_DEFAULT_DEBUG_CHANNEL(bcrypt)
static NTSTATUS get_hash_property(enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size)
Definition: bcrypt_main.c:962
NTSTATUS WINAPI BCryptCloseAlgorithmProvider(BCRYPT_ALG_HANDLE handle, DWORD flags)
Definition: bcrypt_main.c:374
LONG NTSTATUS
Definition: precomp.h:26
#define OBJECT_LENGTH_SHA512
Definition: bcrypt_main.c:858
MBEDTLS_DEPRECATED void mbedtls_md5_finish(mbedtls_md5_context *ctx, unsigned char output[16])
MD5 final digest.
MBEDTLS_DEPRECATED void mbedtls_sha512_update(mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-512 checksum calculation.
#define wine_dbgstr_w
Definition: kernel32.h:34
static NTSTATUS get_alg_property(enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size)
Definition: bcrypt_main.c:885
NTSTATUS WINAPI BCryptHashData(BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG size, ULONG flags)
Definition: bcrypt_main.c:1052
void mbedtls_sha256_free(mbedtls_sha256_context *ctx)
This function clears a SHA-256 context.
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
GLuint buffer
Definition: glext.h:5915
#define BCRYPT_SHA256_ALGORITHM
Definition: bcrypt.h:75
ULONG magic
Definition: bcrypt_main.c:259
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
void mbedtls_md_free(mbedtls_md_context_t *ctx)
This function clears the internal structure of ctx and frees any embedded internal structure,...
void mbedtls_md_init(mbedtls_md_context_t *ctx)
This function initializes a message-digest context without binding it to a particular message-digest ...
void mbedtls_md5_free(mbedtls_md5_context *ctx)
Clear MD5 context.
NTSTATUS WINAPI BCryptFinishHash(BCRYPT_HASH_HANDLE handle, UCHAR *output, ULONG size, ULONG flags)
Definition: bcrypt_main.c:1071
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
#define BCRYPT_ALG_HANDLE_HMAC_FLAG
Definition: bcrypt.h:172
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
static UCHAR ULONG secretlen
Definition: bcrypt.c:29
ULONG hash_length
Definition: bcrypt_main.c:273
#define BCRYPT_ALGORITHM_NAME
Definition: bcrypt.h:43
enum alg_id id
Definition: bcrypt_main.c:287
NTSTATUS WINAPI BCryptOpenAlgorithmProvider(BCRYPT_ALG_HANDLE *handle, LPCWSTR id, LPCWSTR implementation, DWORD flags)
Definition: bcrypt_main.c:332
int hash
Definition: main.c:58
unsigned int BOOL
Definition: ntddk_ex.h:94
void mbedtls_sha1_free(mbedtls_sha1_context *ctx)
This function clears a SHA-1 context.
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
r reserved
Definition: btrfs.c:2655
int mbedtls_md_hmac_finish(mbedtls_md_context_t *ctx, unsigned char *output)
This function finishes the HMAC operation, and writes the result to the output buffer.
unsigned char BOOLEAN
#define MAGIC_ALG
Definition: bcrypt_main.c:255
smooth NULL
Definition: ftsmooth.c:416
int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac)
This function selects the message digest algorithm to use, and allocates internal structures.
NTSTATUS WINAPI BCryptHash(BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG secretlen, UCHAR *input, ULONG inputlen, UCHAR *output, ULONG outputlen)
Definition: bcrypt_main.c:1090
void * wine_dlopen(const char *filename, int flag, char *error, size_t errorsize)
Definition: loader.c:53
#define DLL_PROCESS_DETACH
Definition: compat.h:119
The SHA-512 context structure.
Definition: sha512.h:55
#define LOAD_FUNCPTR(f)
#define TRACE(s)
Definition: solgame.cpp:4
MBEDTLS_DEPRECATED void mbedtls_sha1_finish(mbedtls_sha1_context *ctx, unsigned char output[20])
SHA-1 final digest.
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
NTSTATUS WINAPI BCryptGetFipsAlgorithmMode(BOOLEAN *enabled)
Definition: bcrypt_main.c:385
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define OBJECT_LENGTH_SHA1
Definition: bcrypt_main.c:855
MBEDTLS_DEPRECATED void mbedtls_sha256_update(mbedtls_sha256_context *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing SHA-256 checksum calculation.
#define WINAPI
Definition: msvc.h:8
BOOLEAN WINAPI RtlGenRandom(PVOID, ULONG)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RTLD_NOW
Definition: port.h:100
#define BCRYPT_SHA384_ALGORITHM
Definition: bcrypt.h:76
GLbitfield flags
Definition: glext.h:7161
#define OBJECT_LENGTH_SHA256
Definition: bcrypt_main.c:856
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
unsigned char UCHAR
Definition: xmlstorage.h:181
static UCHAR * secret
Definition: bcrypt.c:29
int ret
The SHA-256 context structure.
Definition: sha256.h:55
static const struct @312 alg_props[]
MBEDTLS_DEPRECATED void mbedtls_sha512_finish(mbedtls_sha512_context *ctx, unsigned char output[64])
This function finishes the SHA-512 operation, and writes the result to the output buffer.
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
MBEDTLS_DEPRECATED void mbedtls_md5_update(mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen)
MD5 process buffer.
#define SONAME_LIBMBEDTLS
Definition: config.h:1245
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:37
GLsizei const GLfloat * value
Definition: glext.h:6069
#define OBJECT_LENGTH_SHA384
Definition: bcrypt_main.c:857
const mbedtls_md_info_t * mbedtls_md_info_from_type(mbedtls_md_type_t md_type)
This function returns the message-digest information associated with the given digest type.
The generic message-digest wrapper.
#define ERR(fmt,...)
Definition: debug.h:109
MBEDTLS_DEPRECATED void mbedtls_md5_starts(mbedtls_md5_context *ctx)
MD5 context setup.
#define BCRYPT_SHA512_ALGORITHM
Definition: bcrypt.h:77
GLenum GLenum GLenum input
Definition: glext.h:9031
MD5 context structure.
Definition: md5.h:60
struct object hdr
Definition: bcrypt_main.c:286
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MAKE_FUNCPTR(f)
void mbedtls_sha512_free(mbedtls_sha512_context *ctx)
This function clears a SHA-512 context.
The SHA-1 context structure.
Definition: sha1.h:60
The SHA-384 and SHA-512 cryptographic hash function.
int mbedtls_md_hmac_starts(mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen)
This function sets the HMAC key and prepares to authenticate a new message.
#define msg(x)
Definition: auth_time.c:54
NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *buffer, ULONG count, ULONG *res, ULONG flags)
Definition: bcrypt_main.c:972
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
GLuint res
Definition: glext.h:9613
static UCHAR ULONG UCHAR ULONG inputlen
Definition: bcrypt.c:29
static HINSTANCE instance
Definition: bcrypt_main.c:44
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
static HINSTANCE hinst
Definition: edit.c:551
void mbedtls_md5_init(mbedtls_md5_context *ctx)
Initialize MD5 context.
MBEDTLS_DEPRECATED void mbedtls_sha512_starts(mbedtls_sha512_context *ctx, int is384)
This function starts a SHA-384 or SHA-512 checksum calculation.
mbedtls_md_type_t
Enumeration of supported message digests.
Definition: md.h:58
#define BCRYPT_RNG_ALGORITHM
Definition: bcrypt.h:73
return STATUS_SUCCESS
Definition: btrfs.c:2725
The SHA-224 and SHA-256 cryptographic hash function.
Definition: _hash_fun.h:40
#define BCRYPT_SHA1_ALGORITHM
Definition: bcrypt.h:74
alg_id
Definition: bcrypt_main.c:262
static SERVICE_STATUS status
Definition: service.c:31
#define TRACE_ON(x)
Definition: compat.h:65
MBEDTLS_DEPRECATED void mbedtls_sha256_starts(mbedtls_sha256_context *ctx, int is224)
This function starts a SHA-256 checksum calculation.
#define MAGIC_HASH
Definition: bcrypt_main.c:256
#define HeapFree(x, y, z)
Definition: compat.h:394
static FT_Error hash_init(FT_Hash hash, FT_Bool is_num, FT_Memory memory)
Definition: fthash.c:166
#define BCRYPT_HASH_LENGTH
Definition: bcrypt.h:50
int wine_dlclose(void *handle, char *error, size_t errorsize)
Definition: loader.c:58
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
Definition: bcrypt_main.c:1122
int mbedtls_md_update(mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen)
This function feeds an input buffer into an ongoing message-digest computation.
Definition: path.c:42
NTSTATUS WINAPI BCryptDestroyHash(BCRYPT_HASH_HANDLE handle)
Definition: bcrypt_main.c:1041
NTSTATUS WINAPI BCryptCreateHash(BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen, UCHAR *secret, ULONG secretlen, ULONG flags)
Definition: bcrypt_main.c:999
static NTSTATUS generic_alg_property(enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size)
Definition: bcrypt_main.c:860
Definition: ps.c:97