Struct win_crypto_ng::helpers::Blob

source ·
#[repr(C, packed)]
pub struct Blob<T: BlobLayout>(_, _);
Expand description

C-compatible dynamic inline structure.

Can be used to house data with a header structure of a statically known size but with trailing data of size dependent on the header field values.

Layout

The structure is marked as #[repr(C, packed)] to be layout-compatible with regular byte slice ([u8]) since it’s mostly constructed from Box<[u8]> via C FFI.

It’s worth noting that heap allocation will often align to pointer size, so no unaligned load should happen once the value is constructed from heap-allocated bytes.

Implementations§

source§

impl Blob<DsaParameter>

source

pub fn clone_from_parts( header: &BCRYPT_DSA_PARAMETER_HEADER, tail: &DsaParameterViewTail<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DsaParameter>

source

pub fn prime(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source§

impl Blob<DsaParameterV2>

source

pub fn clone_from_parts( header: &BCRYPT_DSA_PARAMETER_HEADER_V2, tail: &DsaParameterV2ViewTail<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DsaParameterV2>

source

pub fn prime(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source§

impl Blob<DhParameter>

source

pub fn clone_from_parts( header: &BCRYPT_DH_PARAMETER_HEADER, tail: &DhParameterViewTail<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DhParameter>

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source§

impl<T> Blob<T>where T: BlobLayout + KeyBlob,

source

pub fn magic(&self) -> ULONG

source

pub fn blob_type(&self) -> Option<BlobType>

source

pub fn as_erased(&self) -> &Blob<ErasedKeyBlob>

source

pub fn try_into<U>(self: Box<Self>) -> Result<Box<Blob<U>>, Box<Self>>where U: BlobLayout + KeyBlob,

source§

impl Blob<ErasedKeyBlob>

source

pub fn clone_from_parts( header: &BCRYPT_KEY_BLOB, tail: &ErasedKeyPayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<ErasedKeyBlob>

source

pub fn phantom(&self) -> &[u8]

source§

impl Blob<RsaKeyPublicBlob>

source

pub fn clone_from_parts( header: &BCRYPT_RSAKEY_BLOB, tail: &RsaKeyPublicPayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<RsaKeyPublicBlob>

source

pub fn pub_exp(&self) -> &[u8]

source

pub fn modulus(&self) -> &[u8]

source§

impl Blob<RsaKeyPrivateBlob>

source

pub fn clone_from_parts( header: &BCRYPT_RSAKEY_BLOB, tail: &RsaKeyPrivatePayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<RsaKeyPrivateBlob>

source

pub fn pub_exp(&self) -> &[u8]

source

pub fn modulus(&self) -> &[u8]

source

pub fn prime1(&self) -> &[u8]

source

pub fn prime2(&self) -> &[u8]

source§

impl Blob<RsaKeyFullPrivateBlob>

source

pub fn clone_from_parts( header: &BCRYPT_RSAKEY_BLOB, tail: &RsaKeyFullPrivatePayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<RsaKeyFullPrivateBlob>

source

pub fn pub_exp(&self) -> &[u8]

source

pub fn modulus(&self) -> &[u8]

source

pub fn prime1(&self) -> &[u8]

source

pub fn prime2(&self) -> &[u8]

source

pub fn exponent1(&self) -> &[u8]

source

pub fn exponent2(&self) -> &[u8]

source

pub fn coeff(&self) -> &[u8]

source

pub fn priv_exp(&self) -> &[u8]

source§

impl Blob<DhKeyPublicBlob>

source

pub fn clone_from_parts( header: &BCRYPT_DH_KEY_BLOB, tail: &DhKeyPublicPayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DhKeyPublicBlob>

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source

pub fn public(&self) -> &[u8]

source§

impl Blob<DhKeyPrivateBlob>

source

pub fn clone_from_parts( header: &BCRYPT_DH_KEY_BLOB, tail: &DhKeyPrivatePayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DhKeyPrivateBlob>

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source

pub fn public(&self) -> &[u8]

source

pub fn priv_exp(&self) -> &[u8]

source§

impl Blob<DsaKeyPublicBlob>

source

pub fn clone_from_parts( header: &BCRYPT_DSA_KEY_BLOB, tail: &DsaKeyPublicPayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DsaKeyPublicBlob>

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source

pub fn public(&self) -> &[u8]

source§

impl Blob<DsaKeyPrivateBlob>

source

pub fn clone_from_parts( header: &BCRYPT_DSA_KEY_BLOB, tail: &DsaKeyPrivatePayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DsaKeyPrivateBlob>

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source

pub fn public(&self) -> &[u8]

source

pub fn priv_exp(&self) -> &[u8]

source§

impl Blob<DsaKeyPublicV2Blob>

source

pub fn clone_from_parts( header: &BCRYPT_DSA_KEY_BLOB_V2, tail: &DsaKeyPublicV2Payload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DsaKeyPublicV2Blob>

source

pub fn seed(&self) -> &[u8]

source

pub fn group(&self) -> &[u8]

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source

pub fn public(&self) -> &[u8]

source§

impl Blob<DsaKeyPrivateV2Blob>

source

pub fn clone_from_parts( header: &BCRYPT_DSA_KEY_BLOB_V2, tail: &DsaKeyPrivateV2Payload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<DsaKeyPrivateV2Blob>

source

pub fn seed(&self) -> &[u8]

source

pub fn group(&self) -> &[u8]

source

pub fn modulus(&self) -> &[u8]

source

pub fn generator(&self) -> &[u8]

source

pub fn public(&self) -> &[u8]

source

pub fn priv_exp(&self) -> &[u8]

source§

impl Blob<EccKeyPublicBlob>

source

pub fn clone_from_parts( header: &BCRYPT_ECCKEY_BLOB, tail: &EccKeyPublicPayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<EccKeyPublicBlob>

source

pub fn x(&self) -> &[u8]

source

pub fn y(&self) -> &[u8]

source§

impl Blob<EccKeyPrivateBlob>

source

pub fn clone_from_parts( header: &BCRYPT_ECCKEY_BLOB, tail: &EccKeyPrivatePayload<'_> ) -> Box<Self>

Create a [$wrapper_ident] blob instance from its parts.

SAFETY: The header might contain length information about the payload (i.e. the tail argument). An mismatch between the two won’t cause a memory corruption, but it will panic. Careful validation of the arguments must be done to ensure proper behaviour.

source§

impl Blob<EccKeyPrivateBlob>

source

pub fn x(&self) -> &[u8]

source

pub fn y(&self) -> &[u8]

source

pub fn d(&self) -> &[u8]

source§

impl<T: BlobLayout> Blob<T>

source

pub fn header(&self) -> &T::Header

source

pub fn as_bytes(&self) -> &[u8]

source

pub fn into_bytes(self: Box<Self>) -> Box<[u8]>

source

pub fn from_boxed(boxed: Box<[u8]>) -> Box<Self>

Trait Implementations§

source§

impl<T: BlobLayout> AsBytes for Blob<T>

source§

fn as_bytes(&self) -> &[u8]

source§

fn into_bytes(self: Box<Self>) -> Box<[u8]>

source§

impl<T> AsRef<Blob<ErasedKeyBlob>> for Blob<T>where T: BlobLayout + KeyBlob,

source§

fn as_ref(&self) -> &Blob<ErasedKeyBlob>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<Blob<ErasedKeyBlob>> for DsaPrivateBlob

source§

fn as_ref(&self) -> &Blob<ErasedKeyBlob>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<Blob<ErasedKeyBlob>> for DsaPublicBlob

source§

fn as_ref(&self) -> &Blob<ErasedKeyBlob>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: BlobLayout> FromBytes for Blob<T>

source§

const MIN_LAYOUT: Layout = _

Specified the minimum layout requirements for the allocation: Read more
source§

fn from_bytes(bytes: &[u8]) -> &Self

source§

fn from_boxed(boxed: Box<[u8]>) -> Box<Self>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Blob<T>where <T as BlobLayout>::Header: RefUnwindSafe,

§

impl<T> Send for Blob<T>where <T as BlobLayout>::Header: Send,

§

impl<T> !Sized for Blob<T>

§

impl<T> Sync for Blob<T>where <T as BlobLayout>::Header: Sync,

§

impl<T> Unpin for Blob<T>where <T as BlobLayout>::Header: Unpin,

§

impl<T> UnwindSafe for Blob<T>where <T as BlobLayout>::Header: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.