bcrypt.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #endif
  18. #include <boost/winapi/detail/header.hpp>
  19. #if defined(BOOST_USE_WINDOWS_H)
  20. namespace boost { namespace winapi {
  21. typedef ::BCRYPT_ALG_HANDLE BCRYPT_ALG_HANDLE_;
  22. }}
  23. #else // defined(BOOST_USE_WINDOWS_H)
  24. namespace boost { namespace winapi {
  25. typedef PVOID_ BCRYPT_ALG_HANDLE_;
  26. }}
  27. extern "C" {
  28. boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC
  29. BCryptCloseAlgorithmProvider(
  30. boost::winapi::BCRYPT_ALG_HANDLE_ hAlgorithm,
  31. boost::winapi::ULONG_ dwFlags
  32. );
  33. boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC
  34. BCryptGenRandom(
  35. boost::winapi::BCRYPT_ALG_HANDLE_ hAlgorithm,
  36. boost::winapi::PUCHAR_ pbBuffer,
  37. boost::winapi::ULONG_ cbBuffer,
  38. boost::winapi::ULONG_ dwFlags
  39. );
  40. boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC
  41. BCryptOpenAlgorithmProvider(
  42. boost::winapi::BCRYPT_ALG_HANDLE_ *phAlgorithm,
  43. boost::winapi::LPCWSTR_ pszAlgId,
  44. boost::winapi::LPCWSTR_ pszImplementation,
  45. boost::winapi::DWORD_ dwFlags
  46. );
  47. } // extern "C"
  48. #endif // defined(BOOST_USE_WINDOWS_H)
  49. namespace boost {
  50. namespace winapi {
  51. #if defined(BOOST_USE_WINDOWS_H)
  52. const WCHAR_ BCRYPT_RNG_ALGORITHM_[] = BCRYPT_RNG_ALGORITHM;
  53. #else
  54. const WCHAR_ BCRYPT_RNG_ALGORITHM_[] = L"RNG";
  55. #endif
  56. using ::BCryptCloseAlgorithmProvider;
  57. using ::BCryptGenRandom;
  58. using ::BCryptOpenAlgorithmProvider;
  59. } // winapi
  60. } // boost
  61. #include <boost/winapi/detail/footer.hpp>
  62. #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
  63. #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
  64. #endif // BOOST_WINAPI_BCRYPT_HPP_INCLUDED_