WinStd
Additional templates and function helpers for Microsoft Windows using Standard C++ classes
Classes | Functions
Crypt.h File Reference

Integrates WinStd classes with Microsoft Cryptography API. More...

#include "Common.h"
#include <assert.h>
#include <WinCrypt.h>
#include <algorithm>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

class  winstd::cert_context
 PCCERT_CONTEXT wrapper class. More...
 
class  winstd::cert_chain_context
 PCCERT_CHAIN_CONTEXT wrapper class. More...
 
class  winstd::cert_store
 HCERTSTORE wrapper class. More...
 
class  winstd::crypt_prov
 HCRYPTPROV wrapper class. More...
 
class  winstd::crypt_hash
 HCRYPTHASH wrapper class. More...
 
class  winstd::crypt_key
 HCRYPTKEY wrapper class. More...
 
class  winstd::data_blob
 DATA_BLOB wrapper class. More...
 

Functions

template<class _Traits , class _Ax >
static DWORD CertGetNameStringA (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara, std::basic_string< char, _Traits, _Ax > &sNameString)
 Obtains the subject or issuer name from a certificate CERT_CONTEXT structure and stores it in a std::wstring string. More...
 
template<class _Traits , class _Ax >
static DWORD CertGetNameStringW (PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara, std::basic_string< wchar_t, _Traits, _Ax > &sNameString)
 Obtains the subject or issuer name from a certificate CERT_CONTEXT structure and stores it in a std::wstring string. More...
 
template<class _Ty , class _Ax >
static BOOL WINAPI CertGetCertificateContextProperty (PCCERT_CONTEXT pCertContext, DWORD dwPropId, std::vector< _Ty, _Ax > &aData)
 Retrieves the information contained in an extended property of a certificate context. More...
 
template<class _Ty , class _Ax >
static BOOL CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, std::vector< _Ty, _Ax > &aData, DWORD dwFlags)
 Retrieves data that governs the operations of a hash object. The actual hash value can be retrieved by using this function. More...
 
template<class T >
static BOOL CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, T &data, DWORD dwFlags)
 Retrieves data that governs the operations of a hash object. The actual hash value can be retrieved by using this function. More...
 
template<class _Ty , class _Ax >
static BOOL CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, std::vector< _Ty, _Ax > &aData, DWORD dwFlags)
 Retrieves data that governs the operations of a key. More...
 
template<class T >
static BOOL CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, T &data, DWORD dwFlags)
 Retrieves data that governs the operations of a key. More...
 
template<class _Ty , class _Ax >
static BOOL CryptExportKey (HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
 Exports a cryptographic key or a key pair from a cryptographic service provider (CSP) in a secure manner. More...
 
template<class _Ty , class _Ax >
static BOOL CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
 Encrypts data. More...
 
template<class _Ty , class _Ax >
static BOOL CryptDecrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, std::vector< _Ty, _Ax > &aData)
 Decrypts data previously encrypted by using the CryptEncrypt function. More...
 
static BOOL CertGetCertificateChain (HCERTCHAINENGINE hChainEngine, PCCERT_CONTEXT pCertContext, LPFILETIME pTime, HCERTSTORE hAdditionalStore, PCERT_CHAIN_PARA pChainPara, DWORD dwFlags, LPVOID pvReserved, winstd::cert_chain_context &ctx)
 The CertGetCertificateChain function builds a certificate chain context starting from an end certificate and going back, if possible, to a trusted root certificate. More...
 
static BOOL CryptAcquireContextA (winstd::crypt_prov &prov, LPCSTR szContainer, LPCSTR szProvider, DWORD dwProvType, DWORD dwFlags)
 Acquires the cryptographic context. More...
 
static BOOL CryptAcquireContextW (winstd::crypt_prov &prov, LPCWSTR szContainer, LPCWSTR szProvider, DWORD dwProvType, DWORD dwFlags)
 Acquires the cryptographic context. More...
 
static BOOL CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, winstd::crypt_hash &hash)
 Creates the hash context. More...
 
static BOOL CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, winstd::crypt_key &key)
 Generates the key. More...
 
static bool CryptImportKey (HCRYPTPROV hProv, __in_bcount(dwDataLen) LPCBYTE pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, winstd::crypt_key &key)
 Imports the key. More...
 
static bool CryptImportPublicKeyInfo (HCRYPTPROV hCryptProv, DWORD dwCertEncodingType, PCERT_PUBLIC_KEY_INFO pInfo, winstd::crypt_key &key)
 Imports the public key. More...
 
static bool CryptDeriveKey (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, winstd::crypt_key &key)
 Generates cryptographic session keys derived from a base data value. More...
 

Detailed Description

Integrates WinStd classes with Microsoft Cryptography API.