Struct SecurityBufferRef

Source
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>

Source

pub fn data_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a Data buffer type and empty buffer flags.

Source

pub fn token_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a Token buffer type and empty buffer flags.

Source

pub fn stream_header_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a StreamHeader buffer type and empty buffer flags.

Source

pub fn stream_trailer_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a StreamTrailer buffer type and empty buffer flags.

Source

pub fn stream_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a Stream buffer type and empty buffer flags.

Source

pub fn extra_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a Extra buffer type and empty buffer flags.

Source

pub fn padding_buf(data: &mut [u8]) -> SecurityBufferRef<'_>

Creates a SecurityBufferRef with a Padding buffer type and empty buffer flags.

Source

pub fn missing_buf<'a>(count: usize) -> SecurityBufferRef<'a>

Creates a SecurityBufferRef with a Missing buffer type and empty buffer flags.

Source

pub fn with_flags(self, buffer_flags: SecurityBufferFlags) -> Self

Set buffer flags.

Source

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.

Source

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.

Source

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.

Source

pub fn set_data(&mut self, buf: &'data mut [u8]) -> Result<()>

Sets the buffer data.

Attention: the buffer type must not be BufferType::Missing.

Source

pub fn buffer_type(&self) -> BufferType

Determines the BufferType of security buffer.

Source

pub fn buffer_flags(&self) -> SecurityBufferFlags

Source

pub fn owned_security_buffer_type(&self) -> SecurityBufferType

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn buf_data<'a>( buffers: &'a [SecurityBufferRef<'a>], buffer_type: BufferType, ) -> Result<&'a [u8]>

Returns the immutable reference to the inner buffer data.

Source

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.

Source

pub fn buf_len(&self) -> usize

Calculates the buffer data length.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for SecurityBufferRef<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'data> Freeze for SecurityBufferRef<'data>

§

impl<'data> RefUnwindSafe for SecurityBufferRef<'data>

§

impl<'data> Send for SecurityBufferRef<'data>

§

impl<'data> Sync for SecurityBufferRef<'data>

§

impl<'data> Unpin for SecurityBufferRef<'data>

§

impl<'data> !UnwindSafe for SecurityBufferRef<'data>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,