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 8 #ifndef BOOST_WINAPI_BCRYPT_HPP_INCLUDED_ 9 #define BOOST_WINAPI_BCRYPT_HPP_INCLUDED_ 10 11 #include <boost/winapi/basic_types.hpp> 12 13 #ifdef BOOST_HAS_PRAGMA_ONCE 14 #pragma once 15 #endif 16 17 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 18 19 #if BOOST_WINAPI_PARTITION_APP_SYSTEM 20 21 #if defined(BOOST_USE_WINDOWS_H) 22 #include <bcrypt.h> 23 #endif 24 25 #include <boost/winapi/detail/header.hpp> 26 27 #if defined(BOOST_USE_WINDOWS_H) 28 29 namespace boost { namespace winapi { 30 typedef ::BCRYPT_ALG_HANDLE BCRYPT_ALG_HANDLE_; 31 }} 32 33 #else // defined(BOOST_USE_WINDOWS_H) 34 35 namespace boost { namespace winapi { 36 typedef PVOID_ BCRYPT_ALG_HANDLE_; 37 }} 38 39 extern "C" { 40 41 boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC 42 BCryptCloseAlgorithmProvider( 43 boost::winapi::BCRYPT_ALG_HANDLE_ hAlgorithm, 44 boost::winapi::ULONG_ dwFlags 45 ); 46 47 boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC 48 BCryptGenRandom( 49 boost::winapi::BCRYPT_ALG_HANDLE_ hAlgorithm, 50 boost::winapi::PUCHAR_ pbBuffer, 51 boost::winapi::ULONG_ cbBuffer, 52 boost::winapi::ULONG_ dwFlags 53 ); 54 55 boost::winapi::NTSTATUS_ BOOST_WINAPI_WINAPI_CC 56 BCryptOpenAlgorithmProvider( 57 boost::winapi::BCRYPT_ALG_HANDLE_ *phAlgorithm, 58 boost::winapi::LPCWSTR_ pszAlgId, 59 boost::winapi::LPCWSTR_ pszImplementation, 60 boost::winapi::DWORD_ dwFlags 61 ); 62 63 } // extern "C" 64 65 #endif // defined(BOOST_USE_WINDOWS_H) 66 67 namespace boost { 68 namespace winapi { 69 70 #if defined(BOOST_USE_WINDOWS_H) 71 const WCHAR_ BCRYPT_RNG_ALGORITHM_[] = BCRYPT_RNG_ALGORITHM; 72 #else 73 const WCHAR_ BCRYPT_RNG_ALGORITHM_[] = L"RNG"; 74 #endif 75 76 using ::BCryptCloseAlgorithmProvider; 77 using ::BCryptGenRandom; 78 using ::BCryptOpenAlgorithmProvider; 79 80 } // winapi 81 } // boost 82 83 #include <boost/winapi/detail/footer.hpp> 84 85 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM 86 87 #endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6 88 89 #endif // BOOST_WINAPI_BCRYPT_HPP_INCLUDED_ 90