#[cfg(feature = "Security_Cryptography_Certificates")]
pub mod Certificates;
#[cfg(feature = "Security_Cryptography_Core")]
pub mod Core;
#[cfg(feature = "Security_Cryptography_DataProtection")]
pub mod DataProtection;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct BinaryStringEncoding(pub i32);
impl BinaryStringEncoding {
pub const Utf8: Self = Self(0i32);
pub const Utf16LE: Self = Self(1i32);
pub const Utf16BE: Self = Self(2i32);
}
impl windows_core::TypeKind for BinaryStringEncoding {
type TypeKind = windows_core::CopyType;
}
impl windows_core::RuntimeType for BinaryStringEncoding {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::from_slice(b"enum(Windows.Security.Cryptography.BinaryStringEncoding;i4)");
}
pub struct CryptographicBuffer;
impl CryptographicBuffer {
#[cfg(feature = "Storage_Streams")]
pub fn Compare<P0, P1>(object1: P0, object2: P1) -> windows_core::Result<bool>
where
P0: windows_core::Param<super::super::Storage::Streams::IBuffer>,
P1: windows_core::Param<super::super::Storage::Streams::IBuffer>,
{
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).Compare)(windows_core::Interface::as_raw(this), object1.param().abi(), object2.param().abi(), &mut result__).map(|| result__)
})
}
#[cfg(feature = "Storage_Streams")]
pub fn GenerateRandom(length: u32) -> windows_core::Result<super::super::Storage::Streams::IBuffer> {
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).GenerateRandom)(windows_core::Interface::as_raw(this), length, &mut result__).and_then(|| windows_core::Type::from_abi(result__))
})
}
pub fn GenerateRandomNumber() -> windows_core::Result<u32> {
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).GenerateRandomNumber)(windows_core::Interface::as_raw(this), &mut result__).map(|| result__)
})
}
#[cfg(feature = "Storage_Streams")]
pub fn CreateFromByteArray(value: &[u8]) -> windows_core::Result<super::super::Storage::Streams::IBuffer> {
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).CreateFromByteArray)(windows_core::Interface::as_raw(this), value.len().try_into().unwrap(), value.as_ptr(), &mut result__).and_then(|| windows_core::Type::from_abi(result__))
})
}
#[cfg(feature = "Storage_Streams")]
pub fn CopyToByteArray<P0>(buffer: P0, value: &mut windows_core::Array<u8>) -> windows_core::Result<()>
where
P0: windows_core::Param<super::super::Storage::Streams::IBuffer>,
{
Self::ICryptographicBufferStatics(|this| unsafe { (windows_core::Interface::vtable(this).CopyToByteArray)(windows_core::Interface::as_raw(this), buffer.param().abi(), value.set_abi_len(), value as *mut _ as _).ok() })
}
#[cfg(feature = "Storage_Streams")]
pub fn DecodeFromHexString(value: &windows_core::HSTRING) -> windows_core::Result<super::super::Storage::Streams::IBuffer> {
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).DecodeFromHexString)(windows_core::Interface::as_raw(this), core::mem::transmute_copy(value), &mut result__).and_then(|| windows_core::Type::from_abi(result__))
})
}
#[cfg(feature = "Storage_Streams")]
pub fn EncodeToHexString<P0>(buffer: P0) -> windows_core::Result<windows_core::HSTRING>
where
P0: windows_core::Param<super::super::Storage::Streams::IBuffer>,
{
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).EncodeToHexString)(windows_core::Interface::as_raw(this), buffer.param().abi(), &mut result__).map(|| core::mem::transmute(result__))
})
}
#[cfg(feature = "Storage_Streams")]
pub fn DecodeFromBase64String(value: &windows_core::HSTRING) -> windows_core::Result<super::super::Storage::Streams::IBuffer> {
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).DecodeFromBase64String)(windows_core::Interface::as_raw(this), core::mem::transmute_copy(value), &mut result__).and_then(|| windows_core::Type::from_abi(result__))
})
}
#[cfg(feature = "Storage_Streams")]
pub fn EncodeToBase64String<P0>(buffer: P0) -> windows_core::Result<windows_core::HSTRING>
where
P0: windows_core::Param<super::super::Storage::Streams::IBuffer>,
{
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).EncodeToBase64String)(windows_core::Interface::as_raw(this), buffer.param().abi(), &mut result__).map(|| core::mem::transmute(result__))
})
}
#[cfg(feature = "Storage_Streams")]
pub fn ConvertStringToBinary(value: &windows_core::HSTRING, encoding: BinaryStringEncoding) -> windows_core::Result<super::super::Storage::Streams::IBuffer> {
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).ConvertStringToBinary)(windows_core::Interface::as_raw(this), core::mem::transmute_copy(value), encoding, &mut result__).and_then(|| windows_core::Type::from_abi(result__))
})
}
#[cfg(feature = "Storage_Streams")]
pub fn ConvertBinaryToString<P1>(encoding: BinaryStringEncoding, buffer: P1) -> windows_core::Result<windows_core::HSTRING>
where
P1: windows_core::Param<super::super::Storage::Streams::IBuffer>,
{
Self::ICryptographicBufferStatics(|this| unsafe {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(this).ConvertBinaryToString)(windows_core::Interface::as_raw(this), encoding, buffer.param().abi(), &mut result__).map(|| core::mem::transmute(result__))
})
}
fn ICryptographicBufferStatics<R, F: FnOnce(&ICryptographicBufferStatics) -> windows_core::Result<R>>(callback: F) -> windows_core::Result<R> {
static SHARED: windows_core::imp::FactoryCache<CryptographicBuffer, ICryptographicBufferStatics> = windows_core::imp::FactoryCache::new();
SHARED.call(callback)
}
}
impl windows_core::RuntimeName for CryptographicBuffer {
const NAME: &'static str = "Windows.Security.Cryptography.CryptographicBuffer";
}
windows_core::imp::define_interface!(ICryptographicBufferStatics, ICryptographicBufferStatics_Vtbl, 0x320b7e22_3cb0_4cdf_8663_1d28910065eb);
impl windows_core::RuntimeType for ICryptographicBufferStatics {
const SIGNATURE: windows_core::imp::ConstBuffer = windows_core::imp::ConstBuffer::for_interface::<Self>();
}
#[repr(C)]
#[doc(hidden)]
pub struct ICryptographicBufferStatics_Vtbl {
pub base__: windows_core::IInspectable_Vtbl,
#[cfg(feature = "Storage_Streams")]
pub Compare: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, *mut core::ffi::c_void, *mut bool) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
Compare: usize,
#[cfg(feature = "Storage_Streams")]
pub GenerateRandom: unsafe extern "system" fn(*mut core::ffi::c_void, u32, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
GenerateRandom: usize,
pub GenerateRandomNumber: unsafe extern "system" fn(*mut core::ffi::c_void, *mut u32) -> windows_core::HRESULT,
#[cfg(feature = "Storage_Streams")]
pub CreateFromByteArray: unsafe extern "system" fn(*mut core::ffi::c_void, u32, *const u8, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
CreateFromByteArray: usize,
#[cfg(feature = "Storage_Streams")]
pub CopyToByteArray: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, *mut u32, *mut *mut u8) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
CopyToByteArray: usize,
#[cfg(feature = "Storage_Streams")]
pub DecodeFromHexString: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
DecodeFromHexString: usize,
#[cfg(feature = "Storage_Streams")]
pub EncodeToHexString: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
EncodeToHexString: usize,
#[cfg(feature = "Storage_Streams")]
pub DecodeFromBase64String: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
DecodeFromBase64String: usize,
#[cfg(feature = "Storage_Streams")]
pub EncodeToBase64String: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
EncodeToBase64String: usize,
#[cfg(feature = "Storage_Streams")]
pub ConvertStringToBinary: unsafe extern "system" fn(*mut core::ffi::c_void, *mut core::ffi::c_void, BinaryStringEncoding, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
ConvertStringToBinary: usize,
#[cfg(feature = "Storage_Streams")]
pub ConvertBinaryToString: unsafe extern "system" fn(*mut core::ffi::c_void, BinaryStringEncoding, *mut core::ffi::c_void, *mut *mut core::ffi::c_void) -> windows_core::HRESULT,
#[cfg(not(feature = "Storage_Streams"))]
ConvertBinaryToString: usize,
}