1 /* 2 * XML Security Library (http://www.aleksey.com/xmlsec). 3 * 4 * THIS IS A PRIVATE XMLSEC HEADER FILE 5 * DON'T USE IT IN YOUR APPLICATION 6 * 7 * This is free software; see Copyright file in the source 8 * distribution for preciese wording. 9 * 10 * Copyright (C) 2010-2016 Aleksey Sanin <aleksey@aleksey.com>. All Rights Reserved. 11 */ 12 #ifndef __XMLSEC_MSCRYPTO_PRIVATE_H__ 13 #define __XMLSEC_MSCRYPTO_PRIVATE_H__ 14 15 #ifndef XMLSEC_PRIVATE 16 #error "private.h file contains private xmlsec definitions and should not be used outside xmlsec or xmlsec-$crypto libraries" 17 #endif /* XMLSEC_PRIVATE */ 18 19 #if defined(__MINGW32__) && defined(XMLSEC_CUSTOM_CRYPT32) 20 # include "xmlsec-mingw.h" 21 #endif 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif /* __cplusplus */ 26 27 /******************************************************************** 28 * 29 * Utils 30 * 31 ********************************************************************/ 32 int ConvertEndian (const xmlSecByte * src, 33 xmlSecByte * dst, 34 xmlSecSize size); 35 int ConvertEndianInPlace (xmlSecByte * buf, 36 xmlSecSize size); 37 38 /******************************************************************** 39 * 40 * Crypto Providers 41 * 42 ********************************************************************/ 43 44 /* We need to redefine both to ensure that we can pick the right one at runtime (instead of compile time) */ 45 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE_A "Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)" 46 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE_W L"Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)" 47 #ifdef UNICODE 48 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE_W 49 #else 50 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_PROTOTYPE_A 51 #endif 52 53 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_A "Microsoft Enhanced RSA and AES Cryptographic Provider" 54 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_W L"Microsoft Enhanced RSA and AES Cryptographic Provider" 55 #ifdef UNICODE 56 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_W 57 #else 58 #define XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV XMLSEC_CRYPTO_MS_ENH_RSA_AES_PROV_A 59 #endif 60 61 /** 62 * xmlSecMSCryptoProviderInfo: 63 * 64 * Contains information for looking up provider from MS Crypto. 65 */ 66 typedef struct _xmlSecMSCryptoProviderInfo { 67 LPCTSTR providerName; 68 DWORD providerType; 69 } xmlSecMSCryptoProviderInfo; 70 71 HCRYPTPROV xmlSecMSCryptoFindProvider (const xmlSecMSCryptoProviderInfo * providers, 72 LPCTSTR pszContainer, 73 DWORD dwFlags, 74 BOOL bUseXmlSecContainer); 75 76 77 /****************************************************************************** 78 * 79 * SymKey Util functions 80 * 81 * Low level helper routines for importing plain text keys in MS HKEY handle, 82 * since MSCrypto API does not support import of plain text (session) keys 83 * just like that. These functions are based upon MS kb article #228786 84 * and "Base Provider Key BLOBs" article for priv key blob format. 85 * 86 ******************************************************************************/ 87 BOOL xmlSecMSCryptoCreatePrivateExponentOneKey (HCRYPTPROV hProv, 88 HCRYPTKEY *hPrivateKey); 89 90 BOOL xmlSecMSCryptoImportPlainSessionBlob (HCRYPTPROV hProv, 91 HCRYPTKEY hPrivateKey, 92 ALG_ID dwAlgId, 93 LPBYTE pbKeyMaterial, 94 DWORD dwKeyMaterial, 95 BOOL bCheckKeyLength, 96 HCRYPTKEY *hSessionKey); 97 98 /****************************************************************************** 99 * 100 * X509 Util functions 101 * 102 ******************************************************************************/ 103 #ifndef XMLSEC_NO_X509 104 PCCERT_CONTEXT xmlSecMSCryptoX509FindCertBySubject (HCERTSTORE store, 105 const LPTSTR wcSubject, 106 DWORD dwCertEncodingType); 107 108 PCCERT_CONTEXT xmlSecMSCryptoX509StoreFindCert (xmlSecKeyDataStorePtr store, 109 xmlChar *subjectName, 110 xmlChar *issuerName, 111 xmlChar *issuerSerial, 112 xmlChar *ski, 113 xmlSecKeyInfoCtx* keyInfoCtx); 114 115 xmlChar * xmlSecMSCryptoX509GetNameString (PCCERT_CONTEXT pCertContext, 116 DWORD dwType, 117 DWORD dwFlags, 118 void *pvTypePara); 119 120 PCCERT_CONTEXT xmlSecMSCryptoX509StoreVerify (xmlSecKeyDataStorePtr store, 121 HCERTSTORE certs, 122 xmlSecKeyInfoCtx* keyInfoCtx); 123 124 #endif /* XMLSEC_NO_X509 */ 125 126 #ifdef __cplusplus 127 } 128 #endif /* __cplusplus */ 129 130 #endif /* __XMLSEC_MSCRYPTO_PRIVATE_H__ */ 131