Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:44

0001 /*
0002  * Copyright 2014 Antony Polukhin
0003  * Copyright 2015 Andrey Semashev
0004  *
0005  * Distributed under the Boost Software License, Version 1.0.
0006  * See http://www.boost.org/LICENSE_1_0.txt
0007  */
0008 
0009 #ifndef BOOST_WINAPI_CRYPT_HPP_INCLUDED_
0010 #define BOOST_WINAPI_CRYPT_HPP_INCLUDED_
0011 
0012 #include <boost/winapi/basic_types.hpp>
0013 #if defined( BOOST_USE_WINDOWS_H )
0014 // This header is not always included as part of windows.h
0015 #include <wincrypt.h>
0016 #endif
0017 #include <boost/winapi/detail/header.hpp>
0018 
0019 #ifdef BOOST_HAS_PRAGMA_ONCE
0020 #pragma once
0021 #endif
0022 
0023 #if !defined( BOOST_USE_WINDOWS_H )
0024 namespace boost { namespace winapi {
0025 typedef ULONG_PTR_ HCRYPTPROV_;
0026 }}
0027 
0028 extern "C" {
0029 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
0030 #if !defined( BOOST_NO_ANSI_APIS )
0031 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0032 CryptEnumProvidersA(
0033     boost::winapi::DWORD_ dwIndex,
0034     boost::winapi::DWORD_ *pdwReserved,
0035     boost::winapi::DWORD_ dwFlags,
0036     boost::winapi::DWORD_ *pdwProvType,
0037     boost::winapi::LPSTR_ szProvName,
0038     boost::winapi::DWORD_ *pcbProvName);
0039 
0040 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0041 CryptAcquireContextA(
0042     boost::winapi::HCRYPTPROV_ *phProv,
0043     boost::winapi::LPCSTR_ pszContainer,
0044     boost::winapi::LPCSTR_ pszProvider,
0045     boost::winapi::DWORD_ dwProvType,
0046     boost::winapi::DWORD_ dwFlags);
0047 #endif // !defined( BOOST_NO_ANSI_APIS )
0048 
0049 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0050 CryptEnumProvidersW(
0051     boost::winapi::DWORD_ dwIndex,
0052     boost::winapi::DWORD_ *pdwReserved,
0053     boost::winapi::DWORD_ dwFlags,
0054     boost::winapi::DWORD_ *pdwProvType,
0055     boost::winapi::LPWSTR_ szProvName,
0056     boost::winapi::DWORD_ *pcbProvName);
0057 
0058 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0059 CryptAcquireContextW(
0060     boost::winapi::HCRYPTPROV_ *phProv,
0061     boost::winapi::LPCWSTR_ szContainer,
0062     boost::winapi::LPCWSTR_ szProvider,
0063     boost::winapi::DWORD_ dwProvType,
0064     boost::winapi::DWORD_ dwFlags);
0065 
0066 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0067 CryptGenRandom(
0068     boost::winapi::HCRYPTPROV_ hProv,
0069     boost::winapi::DWORD_ dwLen,
0070     boost::winapi::BYTE_ *pbBuffer);
0071 #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
0072 
0073 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0074 #if defined(_MSC_VER) && (_MSC_VER+0) >= 1500 && (_MSC_VER+0) < 1900 && BOOST_USE_NTDDI_VERSION < BOOST_WINAPI_NTDDI_WINXP
0075 // Standalone MS Windows SDK 6.0A and later until 10.0 provide a different declaration of CryptReleaseContext for Windows 2000 and older.
0076 // 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,
0077 // and (c) MSVC 14.0 and later, which are used with Windows SDK 10.
0078 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0079 CryptReleaseContext(
0080     boost::winapi::HCRYPTPROV_ hProv,
0081     boost::winapi::ULONG_PTR_ dwFlags);
0082 #else
0083 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
0084 CryptReleaseContext(
0085     boost::winapi::HCRYPTPROV_ hProv,
0086     boost::winapi::DWORD_ dwFlags);
0087 #endif
0088 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
0089 }
0090 #endif // !defined( BOOST_USE_WINDOWS_H )
0091 
0092 namespace boost {
0093 namespace winapi {
0094 
0095 #if defined( BOOST_USE_WINDOWS_H )
0096 
0097 typedef ::HCRYPTPROV HCRYPTPROV_;
0098 
0099 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0100 BOOST_CONSTEXPR_OR_CONST DWORD_ PROV_RSA_FULL_         = PROV_RSA_FULL;
0101 
0102 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_VERIFYCONTEXT_   = CRYPT_VERIFYCONTEXT;
0103 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_NEWKEYSET_       = CRYPT_NEWKEYSET;
0104 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_DELETEKEYSET_    = CRYPT_DELETEKEYSET;
0105 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_MACHINE_KEYSET_  = CRYPT_MACHINE_KEYSET;
0106 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_SILENT_          = CRYPT_SILENT;
0107 #endif
0108 
0109 #else
0110 
0111 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0112 BOOST_CONSTEXPR_OR_CONST DWORD_ PROV_RSA_FULL_         = 1;
0113 
0114 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_VERIFYCONTEXT_   = 0xF0000000;
0115 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_NEWKEYSET_       = 8;
0116 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_DELETEKEYSET_    = 16;
0117 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_MACHINE_KEYSET_  = 32;
0118 BOOST_CONSTEXPR_OR_CONST DWORD_ CRYPT_SILENT_          = 64;
0119 #endif
0120 
0121 #endif
0122 
0123 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
0124 
0125 #if !defined( BOOST_NO_ANSI_APIS )
0126 using ::CryptEnumProvidersA;
0127 using ::CryptAcquireContextA;
0128 #endif
0129 using ::CryptEnumProvidersW;
0130 using ::CryptAcquireContextW;
0131 using ::CryptGenRandom;
0132 
0133 #if !defined( BOOST_NO_ANSI_APIS )
0134 BOOST_FORCEINLINE BOOL_ crypt_enum_providers(
0135     DWORD_ dwIndex,
0136     DWORD_ *pdwReserved,
0137     DWORD_ dwFlags,
0138     DWORD_ *pdwProvType,
0139     LPSTR_ szProvName,
0140     DWORD_ *pcbProvName)
0141 {
0142     return ::CryptEnumProvidersA(dwIndex, pdwReserved, dwFlags, pdwProvType, szProvName, pcbProvName);
0143 }
0144 
0145 BOOST_FORCEINLINE BOOL_ crypt_acquire_context(
0146     HCRYPTPROV_ *phProv,
0147     LPCSTR_ pszContainer,
0148     LPCSTR_ pszProvider,
0149     DWORD_ dwProvType,
0150     DWORD_ dwFlags)
0151 {
0152     return ::CryptAcquireContextA(phProv, pszContainer, pszProvider, dwProvType, dwFlags);
0153 }
0154 #endif
0155 
0156 BOOST_FORCEINLINE BOOL_ crypt_enum_providers(
0157     DWORD_ dwIndex,
0158     DWORD_ *pdwReserved,
0159     DWORD_ dwFlags,
0160     DWORD_ *pdwProvType,
0161     LPWSTR_ szProvName,
0162     DWORD_ *pcbProvName)
0163 {
0164     return ::CryptEnumProvidersW(dwIndex, pdwReserved, dwFlags, pdwProvType, szProvName, pcbProvName);
0165 }
0166 
0167 BOOST_FORCEINLINE BOOL_ crypt_acquire_context(
0168     HCRYPTPROV_ *phProv,
0169     LPCWSTR_ szContainer,
0170     LPCWSTR_ szProvider,
0171     DWORD_ dwProvType,
0172     DWORD_ dwFlags)
0173 {
0174     return ::CryptAcquireContextW(phProv, szContainer, szProvider, dwProvType, dwFlags);
0175 }
0176 
0177 #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
0178 
0179 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
0180 BOOST_FORCEINLINE BOOL_ CryptReleaseContext(HCRYPTPROV_ hProv, DWORD_ dwFlags)
0181 {
0182     return ::CryptReleaseContext(hProv, dwFlags);
0183 }
0184 #endif
0185 
0186 }
0187 }
0188 
0189 #include <boost/winapi/detail/footer.hpp>
0190 
0191 #endif // BOOST_WINAPI_CRYPT_HPP_INCLUDED_