/* * Copyright 2014 Antony Polukhin * Copyright 2015 Andrey Semashev * * Distributed under the Boost Software License, Version 1.0. * See http://www.boost.org/LICENSE_1_0.txt */ #ifndef ACTIV_BOOST_WINAPI_CRYPT_HPP_INCLUDED_ #define ACTIV_BOOST_WINAPI_CRYPT_HPP_INCLUDED_ #include #if defined( ACTIV_BOOST_USE_WINDOWS_H ) // This header is not always included as part of windows.h #include #endif #include #ifdef ACTIV_BOOST_HAS_PRAGMA_ONCE #pragma once #endif #if !defined( ACTIV_BOOST_USE_WINDOWS_H ) namespace Boost { namespace winapi { typedef ULONG_PTR_ HCRYPTPROV_; }} extern "C" { #if ACTIV_BOOST_WINAPI_PARTITION_DESKTOP || ACTIV_BOOST_WINAPI_PARTITION_SYSTEM #if !defined( ACTIV_BOOST_NO_ANSI_APIS ) ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptEnumProvidersA( Boost::winapi::DWORD_ dwIndex, Boost::winapi::DWORD_ *pdwReserved, Boost::winapi::DWORD_ dwFlags, Boost::winapi::DWORD_ *pdwProvType, Boost::winapi::LPSTR_ szProvName, Boost::winapi::DWORD_ *pcbProvName); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptAcquireContextA( Boost::winapi::HCRYPTPROV_ *phProv, Boost::winapi::LPCSTR_ pszContainer, Boost::winapi::LPCSTR_ pszProvider, Boost::winapi::DWORD_ dwProvType, Boost::winapi::DWORD_ dwFlags); #endif // !defined( ACTIV_BOOST_NO_ANSI_APIS ) ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptEnumProvidersW( Boost::winapi::DWORD_ dwIndex, Boost::winapi::DWORD_ *pdwReserved, Boost::winapi::DWORD_ dwFlags, Boost::winapi::DWORD_ *pdwProvType, Boost::winapi::LPWSTR_ szProvName, Boost::winapi::DWORD_ *pcbProvName); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptAcquireContextW( Boost::winapi::HCRYPTPROV_ *phProv, Boost::winapi::LPCWSTR_ szContainer, Boost::winapi::LPCWSTR_ szProvider, Boost::winapi::DWORD_ dwProvType, Boost::winapi::DWORD_ dwFlags); ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptGenRandom( Boost::winapi::HCRYPTPROV_ hProv, Boost::winapi::DWORD_ dwLen, Boost::winapi::BYTE_ *pbBuffer); #endif // ACTIV_BOOST_WINAPI_PARTITION_DESKTOP || ACTIV_BOOST_WINAPI_PARTITION_SYSTEM #if ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM #if defined(_MSC_VER) && (_MSC_VER+0) >= 1500 && (_MSC_VER+0) < 1900 && ACTIV_BOOST_USE_NTDDI_VERSION < ACTIV_BOOST_WINAPI_NTDDI_WINXP // Standalone MS Windows SDK 6.0A and later until 10.0 provide a different declaration of CryptReleaseContext for Windows 2000 and older. // This is not the case for (a) MinGW and MinGW-w64, (b) MSVC 7.1 and 8, which are shipped with their own Windows SDK, // and (c) MSVC 14.0 and later, which are used with Windows SDK 10. ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptReleaseContext( Boost::winapi::HCRYPTPROV_ hProv, Boost::winapi::ULONG_PTR_ dwFlags); #else ACTIV_BOOST_WINAPI_IMPORT Boost::winapi::BOOL_ ACTIV_BOOST_WINAPI_WINAPI_CC CryptReleaseContext( Boost::winapi::HCRYPTPROV_ hProv, Boost::winapi::DWORD_ dwFlags); #endif #endif // ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM } #endif // !defined( ACTIV_BOOST_USE_WINDOWS_H ) namespace Boost { namespace winapi { #if defined( ACTIV_BOOST_USE_WINDOWS_H ) typedef ::HCRYPTPROV HCRYPTPROV_; #if ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ PROV_RSA_FULL_ = PROV_RSA_FULL; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_VERIFYCONTEXT_ = CRYPT_VERIFYCONTEXT; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_NEWKEYSET_ = CRYPT_NEWKEYSET; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_DELETEKEYSET_ = CRYPT_DELETEKEYSET; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_MACHINE_KEYSET_ = CRYPT_MACHINE_KEYSET; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_SILENT_ = CRYPT_SILENT; #endif #else #if ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ PROV_RSA_FULL_ = 1; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_VERIFYCONTEXT_ = 0xF0000000; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_NEWKEYSET_ = 8; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_DELETEKEYSET_ = 16; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_MACHINE_KEYSET_ = 32; ACTIV_BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_SILENT_ = 64; #endif #endif #if ACTIV_BOOST_WINAPI_PARTITION_DESKTOP || ACTIV_BOOST_WINAPI_PARTITION_SYSTEM #if !defined( ACTIV_BOOST_NO_ANSI_APIS ) using ::CryptEnumProvidersA; using ::CryptAcquireContextA; #endif using ::CryptEnumProvidersW; using ::CryptAcquireContextW; using ::CryptGenRandom; #if !defined( ACTIV_BOOST_NO_ANSI_APIS ) ACTIV_BOOST_FORCEINLINE BOOL_ crypt_enum_providers( DWORD_ dwIndex, DWORD_ *pdwReserved, DWORD_ dwFlags, DWORD_ *pdwProvType, LPSTR_ szProvName, DWORD_ *pcbProvName) { return ::CryptEnumProvidersA(dwIndex, pdwReserved, dwFlags, pdwProvType, szProvName, pcbProvName); } ACTIV_BOOST_FORCEINLINE BOOL_ crypt_acquire_context( HCRYPTPROV_ *phProv, LPCSTR_ pszContainer, LPCSTR_ pszProvider, DWORD_ dwProvType, DWORD_ dwFlags) { return ::CryptAcquireContextA(phProv, pszContainer, pszProvider, dwProvType, dwFlags); } #endif ACTIV_BOOST_FORCEINLINE BOOL_ crypt_enum_providers( DWORD_ dwIndex, DWORD_ *pdwReserved, DWORD_ dwFlags, DWORD_ *pdwProvType, LPWSTR_ szProvName, DWORD_ *pcbProvName) { return ::CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, szProvName, pcbProvName); } ACTIV_BOOST_FORCEINLINE BOOL_ crypt_acquire_context( HCRYPTPROV_ *phProv, LPCWSTR_ szContainer, LPCWSTR_ szProvider, DWORD_ dwProvType, DWORD_ dwFlags) { return ::CryptAcquireContextW(phProv, szContainer, szProvider, dwProvType, dwFlags); } #endif // ACTIV_BOOST_WINAPI_PARTITION_DESKTOP || ACTIV_BOOST_WINAPI_PARTITION_SYSTEM #if ACTIV_BOOST_WINAPI_PARTITION_APP_SYSTEM ACTIV_BOOST_FORCEINLINE BOOL_ CryptReleaseContext(HCRYPTPROV_ hProv, DWORD_ dwFlags) { return ::CryptReleaseContext(hProv, dwFlags); } #endif } } #include #endif // ACTIV_BOOST_WINAPI_CRYPT_HPP_INCLUDED_