bcrypt.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright 2017 James E. King, III
  3. *
  4. * Distributed under the Boost Software License, Version 1.0.
  5. * See http://www.boost.org/LICENSE_1_0.txt
  6. */
  7. #ifndef BOOST_WINAPI_BCRYPT_HPP_INCLUDED_
  8. #define BOOST_WINAPI_BCRYPT_HPP_INCLUDED_
  9. #include <boost/winapi/basic_types.hpp>
  10. #ifdef BOOST_HAS_PRAGMA_ONCE
  11. #pragma once
  12. #endif
  13. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  14. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  15. #if defined(BOOST_USE_WINDOWS_H)
  16. #include <bcrypt.h>
  17. namespace boost { namespace winapi {
  18. typedef ::BCRYPT_ALG_HANDLE BCRYPT_ALG_HANDLE_;
  19. }}
  20. #else // defined(BOOST_USE_WINDOWS_H)
  21. namespace boost { namespace winapi {
  22. typedef PVOID_ BCRYPT_ALG_HANDLE_;
  23. }}
  24. extern "C" {
  25. boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC
  26. BCryptCloseAlgorithmProvider(
  27. boost::winapi::BCRYPT_ALG_HANDLE_ hAlgorithm,
  28. boost::winapi::ULONG_ dwFlags
  29. );
  30. boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC
  31. BCryptGenRandom(
  32. boost::winapi::BCRYPT_ALG_HANDLE_ hAlgorithm,
  33. boost::winapi::PUCHAR_ pbBuffer,
  34. boost::winapi::ULONG_ cbBuffer,
  35. boost::winapi::ULONG_ dwFlags
  36. );
  37. boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC
  38. BCryptOpenAlgorithmProvider(
  39. boost::winapi::BCRYPT_ALG_HANDLE_ *phAlgorithm,
  40. boost::winapi::LPCWSTR_ pszAlgId,
  41. boost::winapi::LPCWSTR_ pszImplementation,
  42. boost::winapi::DWORD_ dwFlags
  43. );
  44. } // extern "C"
  45. #endif // defined(BOOST_USE_WINDOWS_H)
  46. namespace boost {
  47. namespace winapi {
  48. #if defined(BOOST_USE_WINDOWS_H)
  49. const WCHAR_ BCRYPT_RNG_ALGORITHM_[] = BCRYPT_RNG_ALGORITHM;
  50. #else
  51. const WCHAR_ BCRYPT_RNG_ALGORITHM_[] = L"RNG";
  52. #endif
  53. using ::BCryptCloseAlgorithmProvider;
  54. using ::BCryptGenRandom;
  55. using ::BCryptOpenAlgorithmProvider;
  56. } // winapi
  57. } // boost
  58. #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
  59. #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  60. #endif // BOOST_WINAPI_BCRYPT_HPP_INCLUDED_