#[repr(C, packed(1))]pub struct Blob<T: BlobLayout>(/* private fields */);
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>
impl Blob<DsaParameter>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DSA_PARAMETER_HEADER,
tail: &DsaParameterViewTail<'_>,
) -> Box<Self>
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>
impl Blob<DsaParameter>
Source§impl Blob<DsaParameterV2>
impl Blob<DsaParameterV2>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DSA_PARAMETER_HEADER_V2,
tail: &DsaParameterV2ViewTail<'_>,
) -> Box<Self>
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>
impl Blob<DsaParameterV2>
Source§impl Blob<DhParameter>
impl Blob<DhParameter>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DH_PARAMETER_HEADER,
tail: &DhParameterViewTail<'_>,
) -> Box<Self>
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>
impl Blob<DhParameter>
Source§impl<T> Blob<T>where
T: BlobLayout + KeyBlob,
impl<T> Blob<T>where
T: BlobLayout + KeyBlob,
Source§impl Blob<ErasedKeyBlob>
impl Blob<ErasedKeyBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_KEY_BLOB,
tail: &ErasedKeyPayload<'_>,
) -> Box<Self>
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<RsaKeyPublicBlob>
impl Blob<RsaKeyPublicBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_RSAKEY_BLOB,
tail: &RsaKeyPublicPayload<'_>,
) -> Box<Self>
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>
impl Blob<RsaKeyPublicBlob>
Source§impl Blob<RsaKeyPrivateBlob>
impl Blob<RsaKeyPrivateBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_RSAKEY_BLOB,
tail: &RsaKeyPrivatePayload<'_>,
) -> Box<Self>
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>
impl Blob<RsaKeyPrivateBlob>
Source§impl Blob<RsaKeyFullPrivateBlob>
impl Blob<RsaKeyFullPrivateBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_RSAKEY_BLOB,
tail: &RsaKeyFullPrivatePayload<'_>,
) -> Box<Self>
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>
impl Blob<RsaKeyFullPrivateBlob>
pub fn pub_exp(&self) -> &[u8] ⓘ
pub fn modulus(&self) -> &[u8] ⓘ
pub fn prime1(&self) -> &[u8] ⓘ
pub fn prime2(&self) -> &[u8] ⓘ
pub fn exponent1(&self) -> &[u8] ⓘ
pub fn exponent2(&self) -> &[u8] ⓘ
pub fn coeff(&self) -> &[u8] ⓘ
pub fn priv_exp(&self) -> &[u8] ⓘ
Source§impl Blob<DhKeyPublicBlob>
impl Blob<DhKeyPublicBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DH_KEY_BLOB,
tail: &DhKeyPublicPayload<'_>,
) -> Box<Self>
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>
impl Blob<DhKeyPublicBlob>
Source§impl Blob<DhKeyPrivateBlob>
impl Blob<DhKeyPrivateBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DH_KEY_BLOB,
tail: &DhKeyPrivatePayload<'_>,
) -> Box<Self>
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>
impl Blob<DhKeyPrivateBlob>
Source§impl Blob<DsaKeyPublicBlob>
impl Blob<DsaKeyPublicBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DSA_KEY_BLOB,
tail: &DsaKeyPublicPayload<'_>,
) -> Box<Self>
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>
impl Blob<DsaKeyPublicBlob>
Source§impl Blob<DsaKeyPrivateBlob>
impl Blob<DsaKeyPrivateBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DSA_KEY_BLOB,
tail: &DsaKeyPrivatePayload<'_>,
) -> Box<Self>
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>
impl Blob<DsaKeyPrivateBlob>
Source§impl Blob<DsaKeyPublicV2Blob>
impl Blob<DsaKeyPublicV2Blob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DSA_KEY_BLOB_V2,
tail: &DsaKeyPublicV2Payload<'_>,
) -> Box<Self>
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<DsaKeyPrivateV2Blob>
impl Blob<DsaKeyPrivateV2Blob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_DSA_KEY_BLOB_V2,
tail: &DsaKeyPrivateV2Payload<'_>,
) -> Box<Self>
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<EccKeyPublicBlob>
impl Blob<EccKeyPublicBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_ECCKEY_BLOB,
tail: &EccKeyPublicPayload<'_>,
) -> Box<Self>
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<EccKeyPrivateBlob>
impl Blob<EccKeyPrivateBlob>
Sourcepub fn clone_from_parts(
header: &BCRYPT_ECCKEY_BLOB,
tail: &EccKeyPrivatePayload<'_>,
) -> Box<Self>
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.