pub struct SecurityBufferRef<'data> { /* private fields */ }Expand description
A special security buffer type is used for the data decryption. Basically, it’s almost the same
as SecurityBuffer but for decryption.
DecryptMessage “The encrypted message is decrypted in place, overwriting the original contents of its buffer.”
So, the already defined SecurityBuffer is not suitable for decryption because it uses Vec inside.
We use reference in the SecurityBufferRef structure to avoid data cloning as much as possible.
Decryption/encryption input buffers can be very large. Even up to 32 KiB if we are using this crate as a TSSSP(CREDSSP)
security package.
Implementations§
Source§impl<'data> SecurityBufferRef<'data>
impl<'data> SecurityBufferRef<'data>
Sourcepub fn data_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn data_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a Data buffer type and empty buffer flags.
Sourcepub fn token_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn token_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a Token buffer type and empty buffer flags.
Sourcepub fn stream_header_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn stream_header_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a StreamHeader buffer type and empty buffer flags.
Sourcepub fn stream_trailer_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn stream_trailer_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a StreamTrailer buffer type and empty buffer flags.
Sourcepub fn stream_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn stream_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a Stream buffer type and empty buffer flags.
Sourcepub fn extra_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn extra_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a Extra buffer type and empty buffer flags.
Sourcepub fn padding_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
pub fn padding_buf(data: &mut [u8]) -> SecurityBufferRef<'_>
Creates a SecurityBufferRef with a Padding buffer type and empty buffer flags.
Sourcepub fn missing_buf<'a>(count: usize) -> SecurityBufferRef<'a>
pub fn missing_buf<'a>(count: usize) -> SecurityBufferRef<'a>
Creates a SecurityBufferRef with a Missing buffer type and empty buffer flags.
Sourcepub fn with_flags(self, buffer_flags: SecurityBufferFlags) -> Self
pub fn with_flags(self, buffer_flags: SecurityBufferFlags) -> Self
Set buffer flags.
Sourcepub fn with_security_buffer_type(
security_buffer_type: BufferType,
) -> Result<Self>
pub fn with_security_buffer_type( security_buffer_type: BufferType, ) -> Result<Self>
Creates a SecurityBufferRef from based on provided BufferType.
Inner buffers will be empty.
Sourcepub fn with_owned_security_buffer_type(
security_buffer_type: SecurityBufferType,
) -> Result<Self>
pub fn with_owned_security_buffer_type( security_buffer_type: SecurityBufferType, ) -> Result<Self>
Created a SecurityBufferRef from based on provided BufferType.
Inner buffers will be empty.
Sourcepub fn with_data(self, data: &'data mut [u8]) -> Result<Self>
pub fn with_data(self, data: &'data mut [u8]) -> Result<Self>
Creates a new SecurityBufferRef with the provided buffer data saving the old buffer type.
Attention: the buffer type must not be BufferType::Missing.
Sourcepub fn set_data(&mut self, buf: &'data mut [u8]) -> Result<()>
pub fn set_data(&mut self, buf: &'data mut [u8]) -> Result<()>
Sets the buffer data.
Attention: the buffer type must not be BufferType::Missing.
Sourcepub fn buffer_type(&self) -> BufferType
pub fn buffer_type(&self) -> BufferType
Determines the BufferType of security buffer.
pub fn buffer_flags(&self) -> SecurityBufferFlags
pub fn owned_security_buffer_type(&self) -> SecurityBufferType
Sourcepub fn find_buffer<'a>(
buffers: &'a [SecurityBufferRef<'data>],
buffer_type: BufferType,
) -> Result<&'a SecurityBufferRef<'data>>
pub fn find_buffer<'a>( buffers: &'a [SecurityBufferRef<'data>], buffer_type: BufferType, ) -> Result<&'a SecurityBufferRef<'data>>
Returns the immutable reference to the SecurityBufferRef with specified buffer type.
If a slice contains more than one buffer with a specified buffer type, then the first one will be returned.
Sourcepub fn buffers_of_type<'a>(
buffers: &'a [SecurityBufferRef<'data>],
buffer_type: BufferType,
) -> impl Iterator<Item = &'a SecurityBufferRef<'data>>
pub fn buffers_of_type<'a>( buffers: &'a [SecurityBufferRef<'data>], buffer_type: BufferType, ) -> impl Iterator<Item = &'a SecurityBufferRef<'data>>
Returns the vector of immutable references to the SecurityBufferRef with specified buffer type.
Sourcepub fn buffers_of_type_mut<'a>(
buffers: &'a mut [SecurityBufferRef<'data>],
buffer_type: BufferType,
) -> impl Iterator<Item = &'a mut SecurityBufferRef<'data>>
pub fn buffers_of_type_mut<'a>( buffers: &'a mut [SecurityBufferRef<'data>], buffer_type: BufferType, ) -> impl Iterator<Item = &'a mut SecurityBufferRef<'data>>
Returns the vector of immutable references to the SecurityBufferRef with specified buffer type.
Sourcepub fn buffers_of_type_and_flags<'a>(
buffers: &'a [SecurityBufferRef<'data>],
buffer_type: BufferType,
buffer_flags: SecurityBufferFlags,
) -> impl Iterator<Item = &'a SecurityBufferRef<'data>>
pub fn buffers_of_type_and_flags<'a>( buffers: &'a [SecurityBufferRef<'data>], buffer_type: BufferType, buffer_flags: SecurityBufferFlags, ) -> impl Iterator<Item = &'a SecurityBufferRef<'data>>
Returns the vector of immutable references to the SecurityBufferRef with specified buffer type and flags.
Sourcepub fn buffers_of_type_and_flags_mut<'a>(
buffers: &'a mut [SecurityBufferRef<'data>],
buffer_type: BufferType,
buffer_flags: SecurityBufferFlags,
) -> impl Iterator<Item = &'a mut SecurityBufferRef<'data>>
pub fn buffers_of_type_and_flags_mut<'a>( buffers: &'a mut [SecurityBufferRef<'data>], buffer_type: BufferType, buffer_flags: SecurityBufferFlags, ) -> impl Iterator<Item = &'a mut SecurityBufferRef<'data>>
Returns the vector of immutable references to the SecurityBufferRef with specified buffer type and flags.
Sourcepub fn find_buffer_mut<'a>(
buffers: &'a mut [SecurityBufferRef<'data>],
buffer_type: BufferType,
) -> Result<&'a mut SecurityBufferRef<'data>>
pub fn find_buffer_mut<'a>( buffers: &'a mut [SecurityBufferRef<'data>], buffer_type: BufferType, ) -> Result<&'a mut SecurityBufferRef<'data>>
Returns the mutable reference to the SecurityBufferRef with specified buffer type.
If a slice contains more than one buffer with a specified buffer type, then the first one will be returned.
Sourcepub fn buf_data<'a>(
buffers: &'a [SecurityBufferRef<'a>],
buffer_type: BufferType,
) -> Result<&'a [u8]>
pub fn buf_data<'a>( buffers: &'a [SecurityBufferRef<'a>], buffer_type: BufferType, ) -> Result<&'a [u8]>
Returns the immutable reference to the inner buffer data.
Sourcepub fn data(&self) -> &[u8] ⓘ
pub fn data(&self) -> &[u8] ⓘ
Returns the immutable reference to the inner data.
Some buffer types can not hold the data, so the empty slice will be returned.
Sourcepub fn take_buf_data_mut<'a>(
buffers: &'a mut [SecurityBufferRef<'data>],
buffer_type: BufferType,
) -> Result<&'data mut [u8]>
pub fn take_buf_data_mut<'a>( buffers: &'a mut [SecurityBufferRef<'data>], buffer_type: BufferType, ) -> Result<&'data mut [u8]>
Returns the mutable reference to the inner buffer data leaving the empty buffer on its place.
Sourcepub fn take_data(&mut self) -> &'data mut [u8] ⓘ
pub fn take_data(&mut self) -> &'data mut [u8] ⓘ
Returns the mutable reference to the inner data leaving the empty buffer on its place.
Some buffer types can not hold the data, so the empty slice will be returned.
Sourcepub fn write_data(&mut self, data: &[u8]) -> Result<()>
pub fn write_data(&mut self, data: &[u8]) -> Result<()>
Writes the provided data into the inner buffer.
Returns error if the inner buffer is not big enough. If the inner buffer is larger than provided data, then it’ll be shrunk to the size of the data.