/* automatically generated by rust-bindgen 0.65.1 */
extern crate libloading;
pub struct Cades {
__library: ::libloading::Library,
pub GetLastError: unsafe extern "C" fn() -> DWORD,
pub CadesSignMessage: unsafe extern "C" fn(
pSignPara: PCADES_SIGN_MESSAGE_PARA,
fDetachedSignature: BOOL,
cToBeSigned: DWORD,
rgpbToBeSigned: *mut *const BYTE,
rgcbToBeSigned: *mut DWORD,
ppSignedBlob: *mut PCRYPT_DATA_BLOB,
) -> BOOL,
pub CadesSignHash: unsafe extern "C" fn(
pSignPara: PCADES_SIGN_MESSAGE_PARA,
pbHash: *const BYTE,
cbHash: DWORD,
pszInnerContentObjID: LPCSTR,
ppSignedBlob: *mut PCRYPT_DATA_BLOB,
) -> BOOL,
pub CadesVerifyHash: unsafe extern "C" fn(
pVerifyPara: PCADES_VERIFY_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbDetachedSignBlob: *const BYTE,
cbDetachedSignBlob: DWORD,
pbHash: *const BYTE,
cbHash: DWORD,
pHashAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER,
ppVerificationInfo: *mut PCADES_VERIFICATION_INFO,
) -> BOOL,
pub CadesVerifyMessage: unsafe extern "C" fn(
pVerifyPara: PCADES_VERIFY_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbSignedBlob: *const BYTE,
cbSignedBlob: DWORD,
ppDecodedBlob: *mut PCRYPT_DATA_BLOB,
ppVerificationInfo: *mut PCADES_VERIFICATION_INFO,
) -> BOOL,
pub CadesVerifyDetachedMessage: unsafe extern "C" fn(
pVerifyPara: PCADES_VERIFY_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbDetachedSignBlob: *const BYTE,
cbDetachedSignBlob: DWORD,
cToBeSigned: DWORD,
rgpbToBeSigned: *mut *const BYTE,
rgcbToBeSigned: *mut DWORD,
ppVerificationInfo: *mut PCADES_VERIFICATION_INFO,
) -> BOOL,
pub CadesEnhanceMessage: unsafe extern "C" fn(
pEnhancePara: PCADES_ENHANCE_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbSignedBlob: *const BYTE,
cbSignedBlob: DWORD,
ppEnhancedBlob: *mut PCRYPT_DATA_BLOB,
) -> BOOL,
pub CadesFreeVerificationInfo:
unsafe extern "C" fn(pVerificationInfo: PCADES_VERIFICATION_INFO) -> BOOL,
pub CadesFreeBlob: unsafe extern "C" fn(pBlob: PCRYPT_DATA_BLOB) -> BOOL,
pub CadesFormatMessage: unsafe extern "C" fn(
dwFlags: DWORD,
lpSource: LPCVOID,
dwMessageId: DWORD,
dwLanguageId: DWORD,
lpBuffer: LPTSTR,
nSize: DWORD,
Arguments: *mut va_list,
) -> DWORD,
}
impl Cades {
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 CadesSignMessage = __library.get(b"CadesSignMessage\0").map(|sym| *sym)?;
let CadesSignHash = __library.get(b"CadesSignHash\0").map(|sym| *sym)?;
let CadesVerifyHash = __library.get(b"CadesVerifyHash\0").map(|sym| *sym)?;
let CadesVerifyMessage = __library.get(b"CadesVerifyMessage\0").map(|sym| *sym)?;
let CadesVerifyDetachedMessage = __library
.get(b"CadesVerifyDetachedMessage\0")
.map(|sym| *sym)?;
let CadesEnhanceMessage = __library.get(b"CadesEnhanceMessage\0").map(|sym| *sym)?;
let CadesFreeVerificationInfo = __library
.get(b"CadesFreeVerificationInfo\0")
.map(|sym| *sym)?;
let CadesFreeBlob = __library.get(b"CadesFreeBlob\0").map(|sym| *sym)?;
let CadesFormatMessage = __library.get(b"CadesFormatMessage\0").map(|sym| *sym)?;
Ok(Cades {
__library,
GetLastError,
CadesSignMessage,
CadesSignHash,
CadesVerifyHash,
CadesVerifyMessage,
CadesVerifyDetachedMessage,
CadesEnhanceMessage,
CadesFreeVerificationInfo,
CadesFreeBlob,
CadesFormatMessage,
})
}
pub unsafe fn GetLastError(&self) -> DWORD {
(self.GetLastError)()
}
pub unsafe fn CadesSignMessage(
&self,
pSignPara: PCADES_SIGN_MESSAGE_PARA,
fDetachedSignature: BOOL,
cToBeSigned: DWORD,
rgpbToBeSigned: *mut *const BYTE,
rgcbToBeSigned: *mut DWORD,
ppSignedBlob: *mut PCRYPT_DATA_BLOB,
) -> BOOL {
(self.CadesSignMessage)(
pSignPara,
fDetachedSignature,
cToBeSigned,
rgpbToBeSigned,
rgcbToBeSigned,
ppSignedBlob,
)
}
pub unsafe fn CadesSignHash(
&self,
pSignPara: PCADES_SIGN_MESSAGE_PARA,
pbHash: *const BYTE,
cbHash: DWORD,
pszInnerContentObjID: LPCSTR,
ppSignedBlob: *mut PCRYPT_DATA_BLOB,
) -> BOOL {
(self.CadesSignHash)(
pSignPara,
pbHash,
cbHash,
pszInnerContentObjID,
ppSignedBlob,
)
}
pub unsafe fn CadesVerifyHash(
&self,
pVerifyPara: PCADES_VERIFY_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbDetachedSignBlob: *const BYTE,
cbDetachedSignBlob: DWORD,
pbHash: *const BYTE,
cbHash: DWORD,
pHashAlgorithm: PCRYPT_ALGORITHM_IDENTIFIER,
ppVerificationInfo: *mut PCADES_VERIFICATION_INFO,
) -> BOOL {
(self.CadesVerifyHash)(
pVerifyPara,
dwSignerIndex,
pbDetachedSignBlob,
cbDetachedSignBlob,
pbHash,
cbHash,
pHashAlgorithm,
ppVerificationInfo,
)
}
pub unsafe fn CadesVerifyMessage(
&self,
pVerifyPara: PCADES_VERIFY_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbSignedBlob: *const BYTE,
cbSignedBlob: DWORD,
ppDecodedBlob: *mut PCRYPT_DATA_BLOB,
ppVerificationInfo: *mut PCADES_VERIFICATION_INFO,
) -> BOOL {
(self.CadesVerifyMessage)(
pVerifyPara,
dwSignerIndex,
pbSignedBlob,
cbSignedBlob,
ppDecodedBlob,
ppVerificationInfo,
)
}
pub unsafe fn CadesVerifyDetachedMessage(
&self,
pVerifyPara: PCADES_VERIFY_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbDetachedSignBlob: *const BYTE,
cbDetachedSignBlob: DWORD,
cToBeSigned: DWORD,
rgpbToBeSigned: *mut *const BYTE,
rgcbToBeSigned: *mut DWORD,
ppVerificationInfo: *mut PCADES_VERIFICATION_INFO,
) -> BOOL {
(self.CadesVerifyDetachedMessage)(
pVerifyPara,
dwSignerIndex,
pbDetachedSignBlob,
cbDetachedSignBlob,
cToBeSigned,
rgpbToBeSigned,
rgcbToBeSigned,
ppVerificationInfo,
)
}
pub unsafe fn CadesEnhanceMessage(
&self,
pEnhancePara: PCADES_ENHANCE_MESSAGE_PARA,
dwSignerIndex: DWORD,
pbSignedBlob: *const BYTE,
cbSignedBlob: DWORD,
ppEnhancedBlob: *mut PCRYPT_DATA_BLOB,
) -> BOOL {
(self.CadesEnhanceMessage)(
pEnhancePara,
dwSignerIndex,
pbSignedBlob,
cbSignedBlob,
ppEnhancedBlob,
)
}
pub unsafe fn CadesFreeVerificationInfo(
&self,
pVerificationInfo: PCADES_VERIFICATION_INFO,
) -> BOOL {
(self.CadesFreeVerificationInfo)(pVerificationInfo)
}
pub unsafe fn CadesFreeBlob(&self, pBlob: PCRYPT_DATA_BLOB) -> BOOL {
(self.CadesFreeBlob)(pBlob)
}
pub unsafe fn CadesFormatMessage(
&self,
dwFlags: DWORD,
lpSource: LPCVOID,
dwMessageId: DWORD,
dwLanguageId: DWORD,
lpBuffer: LPTSTR,
nSize: DWORD,
Arguments: *mut va_list,
) -> DWORD {
(self.CadesFormatMessage)(
dwFlags,
lpSource,
dwMessageId,
dwLanguageId,
lpBuffer,
nSize,
Arguments,
)
}
}