/* automatically generated by rust-bindgen 0.65.1 */
extern crate libloading;
pub struct SSP {
__library: ::libloading::Library,
pub GetLastError: unsafe extern "C" fn() -> DWORD,
pub CertOpenStore: unsafe extern "C" fn(
lpszStoreProvider: LPCSTR,
dwEncodingType: DWORD,
hCryptProv: HCRYPTPROV,
dwFlags: DWORD,
pvPara: *const ::std::os::raw::c_void,
) -> HCERTSTORE,
pub CertCloseStore: unsafe extern "C" fn(hCertStore: HCERTSTORE, dwFlags: DWORD) -> BOOL,
pub CertEnumCertificatesInStore: unsafe extern "C" fn(
hCertStore: HCERTSTORE,
pPrevCertContext: PCCERT_CONTEXT,
) -> PCCERT_CONTEXT,
pub CertFindCertificateInStore: unsafe extern "C" fn(
hCertStore: HCERTSTORE,
dwCertEncodingType: DWORD,
dwFindFlags: DWORD,
dwFindType: DWORD,
pvFindPara: *const ::std::os::raw::c_void,
pPrevCertContext: PCCERT_CONTEXT,
) -> PCCERT_CONTEXT,
pub CertFreeCertificateContext: unsafe extern "C" fn(pCertContext: PCCERT_CONTEXT) -> BOOL,
pub CertGetCertificateContextProperty: unsafe extern "C" fn(
pCertContext: PCCERT_CONTEXT,
dwPropId: DWORD,
pvData: *mut ::std::os::raw::c_void,
pcbData: *mut DWORD,
) -> BOOL,
pub CertEnumCertificateContextProperties:
unsafe extern "C" fn(pCertContext: PCCERT_CONTEXT, dwPropId: DWORD) -> DWORD,
pub CertVerifyCertificateChainPolicy: unsafe extern "C" fn(
pszPolicyOID: LPCSTR,
pChainContext: PCCERT_CHAIN_CONTEXT,
pPolicyPara: PCERT_CHAIN_POLICY_PARA,
pPolicyStatus: PCERT_CHAIN_POLICY_STATUS,
) -> BOOL,
pub CryptAcquireContextW: unsafe extern "C" fn(
phProv: *mut HCRYPTPROV,
pszContainer: LPCWSTR,
pszProvider: LPCWSTR,
dwProvType: DWORD,
dwFlags: DWORD,
) -> BOOL,
pub CryptReleaseContext: unsafe extern "C" fn(hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL,
pub CryptGenKey: unsafe extern "C" fn(
hProv: HCRYPTPROV,
Algid: ALG_ID,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL,
pub CryptDeriveKey: unsafe extern "C" fn(
hProv: HCRYPTPROV,
Algid: ALG_ID,
hBaseData: HCRYPTHASH,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL,
pub CryptDestroyKey: unsafe extern "C" fn(hKey: HCRYPTKEY) -> BOOL,
pub CryptSetKeyParam: unsafe extern "C" fn(
hKey: HCRYPTKEY,
dwParam: DWORD,
pbData: *const BYTE,
dwFlags: DWORD,
) -> BOOL,
pub CryptGetKeyParam: unsafe extern "C" fn(
hKey: HCRYPTKEY,
dwParam: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwFlags: DWORD,
) -> BOOL,
pub CryptSetHashParam: unsafe extern "C" fn(
hHash: HCRYPTHASH,
dwParam: DWORD,
pbData: *const BYTE,
dwFlags: DWORD,
) -> BOOL,
pub CryptGetHashParam: unsafe extern "C" fn(
hHash: HCRYPTHASH,
dwParam: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwFlags: DWORD,
) -> BOOL,
pub CryptSetProvParam: unsafe extern "C" fn(
hProv: HCRYPTPROV,
dwParam: DWORD,
pbData: *const BYTE,
dwFlags: DWORD,
) -> BOOL,
pub CryptGetProvParam: unsafe extern "C" fn(
hProv: HCRYPTPROV,
dwParam: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwFlags: DWORD,
) -> BOOL,
pub CryptGenRandom:
unsafe extern "C" fn(hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: *mut BYTE) -> BOOL,
pub CryptGetUserKey: unsafe extern "C" fn(
hProv: HCRYPTPROV,
dwKeySpec: DWORD,
phUserKey: *mut HCRYPTKEY,
) -> BOOL,
pub CryptExportKey: unsafe extern "C" fn(
hKey: HCRYPTKEY,
hExpKey: HCRYPTKEY,
dwBlobType: DWORD,
dwFlags: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
) -> BOOL,
pub CryptImportKey: unsafe extern "C" fn(
hProv: HCRYPTPROV,
pbData: *const BYTE,
dwDataLen: DWORD,
hPubKey: HCRYPTKEY,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL,
pub CryptEncrypt: unsafe extern "C" fn(
hKey: HCRYPTKEY,
hHash: HCRYPTHASH,
Final: BOOL,
dwFlags: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwBufLen: DWORD,
) -> BOOL,
pub CryptDecrypt: unsafe extern "C" fn(
hKey: HCRYPTKEY,
hHash: HCRYPTHASH,
Final: BOOL,
dwFlags: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
) -> BOOL,
pub CryptCreateHash: unsafe extern "C" fn(
hProv: HCRYPTPROV,
Algid: ALG_ID,
hKey: HCRYPTKEY,
dwFlags: DWORD,
phHash: *mut HCRYPTHASH,
) -> BOOL,
pub CryptHashData: unsafe extern "C" fn(
hHash: HCRYPTHASH,
pbData: *const BYTE,
dwDataLen: DWORD,
dwFlags: DWORD,
) -> BOOL,
pub CryptHashSessionKey:
unsafe extern "C" fn(hHash: HCRYPTHASH, hKey: HCRYPTKEY, dwFlags: DWORD) -> BOOL,
pub CryptDestroyHash: unsafe extern "C" fn(hHash: HCRYPTHASH) -> BOOL,
pub CryptSignHashA: unsafe extern "C" fn(
hHash: HCRYPTHASH,
dwKeySpec: DWORD,
szDescription: LPCSTR,
dwFlags: DWORD,
pbSignature: *mut BYTE,
pdwSigLen: *mut DWORD,
) -> BOOL,
pub CryptVerifySignatureA: unsafe extern "C" fn(
hHash: HCRYPTHASH,
pbSignature: *const BYTE,
dwSigLen: DWORD,
hPubKey: HCRYPTKEY,
szDescription: LPCSTR,
dwFlags: DWORD,
) -> BOOL,
pub CryptDuplicateKey: unsafe extern "C" fn(
hKey: HCRYPTKEY,
pdwReserved: *mut DWORD,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL,
pub CryptDuplicateHash: unsafe extern "C" fn(
hHash: HCRYPTHASH,
pdwReserved: *mut DWORD,
dwFlags: DWORD,
phHash: *mut HCRYPTHASH,
) -> BOOL,
pub CryptEnumProvidersA: unsafe extern "C" fn(
dwIndex: DWORD,
pdwReserved: *mut DWORD,
dwFlags: DWORD,
pdwProvType: *mut DWORD,
szProvName: LPSTR,
pcbProvName: *mut DWORD,
) -> BOOL,
}
impl SSP {
pub unsafe fn new
(path: P) -> Result
where
P: AsRef<::std::ffi::OsStr>,
{
let library = ::libloading::Library::new(path)?;
Self::from_library(library)
}
pub unsafe fn from_library(library: L) -> Result
where
L: Into<::libloading::Library>,
{
let __library = library.into();
let GetLastError = __library.get(b"GetLastError\0").map(|sym| *sym)?;
let CertOpenStore = __library.get(b"CertOpenStore\0").map(|sym| *sym)?;
let CertCloseStore = __library.get(b"CertCloseStore\0").map(|sym| *sym)?;
let CertEnumCertificatesInStore = __library
.get(b"CertEnumCertificatesInStore\0")
.map(|sym| *sym)?;
let CertFindCertificateInStore = __library
.get(b"CertFindCertificateInStore\0")
.map(|sym| *sym)?;
let CertFreeCertificateContext = __library
.get(b"CertFreeCertificateContext\0")
.map(|sym| *sym)?;
let CertGetCertificateContextProperty = __library
.get(b"CertGetCertificateContextProperty\0")
.map(|sym| *sym)?;
let CertEnumCertificateContextProperties = __library
.get(b"CertEnumCertificateContextProperties\0")
.map(|sym| *sym)?;
let CertVerifyCertificateChainPolicy = __library
.get(b"CertVerifyCertificateChainPolicy\0")
.map(|sym| *sym)?;
let CryptAcquireContextW = __library.get(b"CryptAcquireContextW\0").map(|sym| *sym)?;
let CryptReleaseContext = __library.get(b"CryptReleaseContext\0").map(|sym| *sym)?;
let CryptGenKey = __library.get(b"CryptGenKey\0").map(|sym| *sym)?;
let CryptDeriveKey = __library.get(b"CryptDeriveKey\0").map(|sym| *sym)?;
let CryptDestroyKey = __library.get(b"CryptDestroyKey\0").map(|sym| *sym)?;
let CryptSetKeyParam = __library.get(b"CryptSetKeyParam\0").map(|sym| *sym)?;
let CryptGetKeyParam = __library.get(b"CryptGetKeyParam\0").map(|sym| *sym)?;
let CryptSetHashParam = __library.get(b"CryptSetHashParam\0").map(|sym| *sym)?;
let CryptGetHashParam = __library.get(b"CryptGetHashParam\0").map(|sym| *sym)?;
let CryptSetProvParam = __library.get(b"CryptSetProvParam\0").map(|sym| *sym)?;
let CryptGetProvParam = __library.get(b"CryptGetProvParam\0").map(|sym| *sym)?;
let CryptGenRandom = __library.get(b"CryptGenRandom\0").map(|sym| *sym)?;
let CryptGetUserKey = __library.get(b"CryptGetUserKey\0").map(|sym| *sym)?;
let CryptExportKey = __library.get(b"CryptExportKey\0").map(|sym| *sym)?;
let CryptImportKey = __library.get(b"CryptImportKey\0").map(|sym| *sym)?;
let CryptEncrypt = __library.get(b"CryptEncrypt\0").map(|sym| *sym)?;
let CryptDecrypt = __library.get(b"CryptDecrypt\0").map(|sym| *sym)?;
let CryptCreateHash = __library.get(b"CryptCreateHash\0").map(|sym| *sym)?;
let CryptHashData = __library.get(b"CryptHashData\0").map(|sym| *sym)?;
let CryptHashSessionKey = __library.get(b"CryptHashSessionKey\0").map(|sym| *sym)?;
let CryptDestroyHash = __library.get(b"CryptDestroyHash\0").map(|sym| *sym)?;
let CryptSignHashA = __library.get(b"CryptSignHashA\0").map(|sym| *sym)?;
let CryptVerifySignatureA = __library.get(b"CryptVerifySignatureA\0").map(|sym| *sym)?;
let CryptDuplicateKey = __library.get(b"CryptDuplicateKey\0").map(|sym| *sym)?;
let CryptDuplicateHash = __library.get(b"CryptDuplicateHash\0").map(|sym| *sym)?;
let CryptEnumProvidersA = __library.get(b"CryptEnumProvidersA\0").map(|sym| *sym)?;
Ok(SSP {
__library,
GetLastError,
CertOpenStore,
CertCloseStore,
CertEnumCertificatesInStore,
CertFindCertificateInStore,
CertFreeCertificateContext,
CertGetCertificateContextProperty,
CertEnumCertificateContextProperties,
CertVerifyCertificateChainPolicy,
CryptAcquireContextW,
CryptReleaseContext,
CryptGenKey,
CryptDeriveKey,
CryptDestroyKey,
CryptSetKeyParam,
CryptGetKeyParam,
CryptSetHashParam,
CryptGetHashParam,
CryptSetProvParam,
CryptGetProvParam,
CryptGenRandom,
CryptGetUserKey,
CryptExportKey,
CryptImportKey,
CryptEncrypt,
CryptDecrypt,
CryptCreateHash,
CryptHashData,
CryptHashSessionKey,
CryptDestroyHash,
CryptSignHashA,
CryptVerifySignatureA,
CryptDuplicateKey,
CryptDuplicateHash,
CryptEnumProvidersA,
})
}
pub unsafe fn GetLastError(&self) -> DWORD {
(self.GetLastError)()
}
pub unsafe fn CertOpenStore(
&self,
lpszStoreProvider: LPCSTR,
dwEncodingType: DWORD,
hCryptProv: HCRYPTPROV,
dwFlags: DWORD,
pvPara: *const ::std::os::raw::c_void,
) -> HCERTSTORE {
(self.CertOpenStore)(
lpszStoreProvider,
dwEncodingType,
hCryptProv,
dwFlags,
pvPara,
)
}
pub unsafe fn CertCloseStore(&self, hCertStore: HCERTSTORE, dwFlags: DWORD) -> BOOL {
(self.CertCloseStore)(hCertStore, dwFlags)
}
pub unsafe fn CertEnumCertificatesInStore(
&self,
hCertStore: HCERTSTORE,
pPrevCertContext: PCCERT_CONTEXT,
) -> PCCERT_CONTEXT {
(self.CertEnumCertificatesInStore)(hCertStore, pPrevCertContext)
}
pub unsafe fn CertFindCertificateInStore(
&self,
hCertStore: HCERTSTORE,
dwCertEncodingType: DWORD,
dwFindFlags: DWORD,
dwFindType: DWORD,
pvFindPara: *const ::std::os::raw::c_void,
pPrevCertContext: PCCERT_CONTEXT,
) -> PCCERT_CONTEXT {
(self.CertFindCertificateInStore)(
hCertStore,
dwCertEncodingType,
dwFindFlags,
dwFindType,
pvFindPara,
pPrevCertContext,
)
}
pub unsafe fn CertFreeCertificateContext(&self, pCertContext: PCCERT_CONTEXT) -> BOOL {
(self.CertFreeCertificateContext)(pCertContext)
}
pub unsafe fn CertGetCertificateContextProperty(
&self,
pCertContext: PCCERT_CONTEXT,
dwPropId: DWORD,
pvData: *mut ::std::os::raw::c_void,
pcbData: *mut DWORD,
) -> BOOL {
(self.CertGetCertificateContextProperty)(pCertContext, dwPropId, pvData, pcbData)
}
pub unsafe fn CertEnumCertificateContextProperties(
&self,
pCertContext: PCCERT_CONTEXT,
dwPropId: DWORD,
) -> DWORD {
(self.CertEnumCertificateContextProperties)(pCertContext, dwPropId)
}
pub unsafe fn CertVerifyCertificateChainPolicy(
&self,
pszPolicyOID: LPCSTR,
pChainContext: PCCERT_CHAIN_CONTEXT,
pPolicyPara: PCERT_CHAIN_POLICY_PARA,
pPolicyStatus: PCERT_CHAIN_POLICY_STATUS,
) -> BOOL {
(self.CertVerifyCertificateChainPolicy)(
pszPolicyOID,
pChainContext,
pPolicyPara,
pPolicyStatus,
)
}
pub unsafe fn CryptAcquireContextW(
&self,
phProv: *mut HCRYPTPROV,
pszContainer: LPCWSTR,
pszProvider: LPCWSTR,
dwProvType: DWORD,
dwFlags: DWORD,
) -> BOOL {
(self.CryptAcquireContextW)(phProv, pszContainer, pszProvider, dwProvType, dwFlags)
}
pub unsafe fn CryptReleaseContext(&self, hProv: HCRYPTPROV, dwFlags: DWORD) -> BOOL {
(self.CryptReleaseContext)(hProv, dwFlags)
}
pub unsafe fn CryptGenKey(
&self,
hProv: HCRYPTPROV,
Algid: ALG_ID,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL {
(self.CryptGenKey)(hProv, Algid, dwFlags, phKey)
}
pub unsafe fn CryptDeriveKey(
&self,
hProv: HCRYPTPROV,
Algid: ALG_ID,
hBaseData: HCRYPTHASH,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL {
(self.CryptDeriveKey)(hProv, Algid, hBaseData, dwFlags, phKey)
}
pub unsafe fn CryptDestroyKey(&self, hKey: HCRYPTKEY) -> BOOL {
(self.CryptDestroyKey)(hKey)
}
pub unsafe fn CryptSetKeyParam(
&self,
hKey: HCRYPTKEY,
dwParam: DWORD,
pbData: *const BYTE,
dwFlags: DWORD,
) -> BOOL {
(self.CryptSetKeyParam)(hKey, dwParam, pbData, dwFlags)
}
pub unsafe fn CryptGetKeyParam(
&self,
hKey: HCRYPTKEY,
dwParam: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwFlags: DWORD,
) -> BOOL {
(self.CryptGetKeyParam)(hKey, dwParam, pbData, pdwDataLen, dwFlags)
}
pub unsafe fn CryptSetHashParam(
&self,
hHash: HCRYPTHASH,
dwParam: DWORD,
pbData: *const BYTE,
dwFlags: DWORD,
) -> BOOL {
(self.CryptSetHashParam)(hHash, dwParam, pbData, dwFlags)
}
pub unsafe fn CryptGetHashParam(
&self,
hHash: HCRYPTHASH,
dwParam: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwFlags: DWORD,
) -> BOOL {
(self.CryptGetHashParam)(hHash, dwParam, pbData, pdwDataLen, dwFlags)
}
pub unsafe fn CryptSetProvParam(
&self,
hProv: HCRYPTPROV,
dwParam: DWORD,
pbData: *const BYTE,
dwFlags: DWORD,
) -> BOOL {
(self.CryptSetProvParam)(hProv, dwParam, pbData, dwFlags)
}
pub unsafe fn CryptGetProvParam(
&self,
hProv: HCRYPTPROV,
dwParam: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwFlags: DWORD,
) -> BOOL {
(self.CryptGetProvParam)(hProv, dwParam, pbData, pdwDataLen, dwFlags)
}
pub unsafe fn CryptGenRandom(
&self,
hProv: HCRYPTPROV,
dwLen: DWORD,
pbBuffer: *mut BYTE,
) -> BOOL {
(self.CryptGenRandom)(hProv, dwLen, pbBuffer)
}
pub unsafe fn CryptGetUserKey(
&self,
hProv: HCRYPTPROV,
dwKeySpec: DWORD,
phUserKey: *mut HCRYPTKEY,
) -> BOOL {
(self.CryptGetUserKey)(hProv, dwKeySpec, phUserKey)
}
pub unsafe fn CryptExportKey(
&self,
hKey: HCRYPTKEY,
hExpKey: HCRYPTKEY,
dwBlobType: DWORD,
dwFlags: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
) -> BOOL {
(self.CryptExportKey)(hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen)
}
pub unsafe fn CryptImportKey(
&self,
hProv: HCRYPTPROV,
pbData: *const BYTE,
dwDataLen: DWORD,
hPubKey: HCRYPTKEY,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL {
(self.CryptImportKey)(hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey)
}
pub unsafe fn CryptEncrypt(
&self,
hKey: HCRYPTKEY,
hHash: HCRYPTHASH,
Final: BOOL,
dwFlags: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
dwBufLen: DWORD,
) -> BOOL {
(self.CryptEncrypt)(hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen)
}
pub unsafe fn CryptDecrypt(
&self,
hKey: HCRYPTKEY,
hHash: HCRYPTHASH,
Final: BOOL,
dwFlags: DWORD,
pbData: *mut BYTE,
pdwDataLen: *mut DWORD,
) -> BOOL {
(self.CryptDecrypt)(hKey, hHash, Final, dwFlags, pbData, pdwDataLen)
}
pub unsafe fn CryptCreateHash(
&self,
hProv: HCRYPTPROV,
Algid: ALG_ID,
hKey: HCRYPTKEY,
dwFlags: DWORD,
phHash: *mut HCRYPTHASH,
) -> BOOL {
(self.CryptCreateHash)(hProv, Algid, hKey, dwFlags, phHash)
}
pub unsafe fn CryptHashData(
&self,
hHash: HCRYPTHASH,
pbData: *const BYTE,
dwDataLen: DWORD,
dwFlags: DWORD,
) -> BOOL {
(self.CryptHashData)(hHash, pbData, dwDataLen, dwFlags)
}
pub unsafe fn CryptHashSessionKey(
&self,
hHash: HCRYPTHASH,
hKey: HCRYPTKEY,
dwFlags: DWORD,
) -> BOOL {
(self.CryptHashSessionKey)(hHash, hKey, dwFlags)
}
pub unsafe fn CryptDestroyHash(&self, hHash: HCRYPTHASH) -> BOOL {
(self.CryptDestroyHash)(hHash)
}
pub unsafe fn CryptSignHashA(
&self,
hHash: HCRYPTHASH,
dwKeySpec: DWORD,
szDescription: LPCSTR,
dwFlags: DWORD,
pbSignature: *mut BYTE,
pdwSigLen: *mut DWORD,
) -> BOOL {
(self.CryptSignHashA)(
hHash,
dwKeySpec,
szDescription,
dwFlags,
pbSignature,
pdwSigLen,
)
}
pub unsafe fn CryptVerifySignatureA(
&self,
hHash: HCRYPTHASH,
pbSignature: *const BYTE,
dwSigLen: DWORD,
hPubKey: HCRYPTKEY,
szDescription: LPCSTR,
dwFlags: DWORD,
) -> BOOL {
(self.CryptVerifySignatureA)(
hHash,
pbSignature,
dwSigLen,
hPubKey,
szDescription,
dwFlags,
)
}
pub unsafe fn CryptDuplicateKey(
&self,
hKey: HCRYPTKEY,
pdwReserved: *mut DWORD,
dwFlags: DWORD,
phKey: *mut HCRYPTKEY,
) -> BOOL {
(self.CryptDuplicateKey)(hKey, pdwReserved, dwFlags, phKey)
}
pub unsafe fn CryptDuplicateHash(
&self,
hHash: HCRYPTHASH,
pdwReserved: *mut DWORD,
dwFlags: DWORD,
phHash: *mut HCRYPTHASH,
) -> BOOL {
(self.CryptDuplicateHash)(hHash, pdwReserved, dwFlags, phHash)
}
pub unsafe fn CryptEnumProvidersA(
&self,
dwIndex: DWORD,
pdwReserved: *mut DWORD,
dwFlags: DWORD,
pdwProvType: *mut DWORD,
szProvName: LPSTR,
pcbProvName: *mut DWORD,
) -> BOOL {
(self.CryptEnumProvidersA)(
dwIndex,
pdwReserved,
dwFlags,
pdwProvType,
szProvName,
pcbProvName,
)
}
}