Struct StreamingEncryptingKey
pub struct StreamingEncryptingKey { /* private fields */ }
Expand description
A key for streaming encryption operations.
Implementations§
§impl StreamingEncryptingKey
impl StreamingEncryptingKey
pub fn update<'a>(
&mut self,
input: &[u8],
output: &'a mut [u8],
) -> Result<BufferUpdate<'a>, Unspecified>
pub fn update<'a>( &mut self, input: &[u8], output: &'a mut [u8], ) -> Result<BufferUpdate<'a>, Unspecified>
Updates the internal state of the key with the provided ciphertext input
,
potentially writing bytes of ciphertext to output
.
The number of bytes written to output
can be up to input.len()
plus the block length of the algorithm (e.g., Algorithm::block_len
).
§Errors
- Returns an error if the
output
buffer is smaller than the length of theinput
plus the algorithm’s block length (e.g.Algorithm::block_len
) minus one. - May return an error if the length of
input
plus the algorithm’s block length is larger thani32::MAX
.
pub fn finish(
self,
output: &mut [u8],
) -> Result<(DecryptionContext, BufferUpdate<'_>), Unspecified>
pub fn finish( self, output: &mut [u8], ) -> Result<(DecryptionContext, BufferUpdate<'_>), Unspecified>
Finishes the encryption operation, writing any remaining ciphertext to
output
.
The number of bytes written to output
can be up to the block length of
Algorithm::block_len
.
§Errors
- Returns an error if the
output
buffer is smaller than the algorithm’s block length.
pub fn mode(&self) -> OperatingMode
pub fn mode(&self) -> OperatingMode
Returns the cipher operating mode.
pub fn ctr(key: UnboundCipherKey) -> Result<StreamingEncryptingKey, Unspecified>
pub fn ctr(key: UnboundCipherKey) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting data using the CTR cipher mode.
The resulting ciphertext will be the same length as the plaintext.
§Errors
Returns and error on an internal failure.
pub fn less_safe_ctr(
key: UnboundCipherKey,
context: EncryptionContext,
) -> Result<StreamingEncryptingKey, Unspecified>
pub fn less_safe_ctr( key: UnboundCipherKey, context: EncryptionContext, ) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting data using the CTR cipher mode.
The resulting ciphertext will be the same length as the plaintext.
This is considered less safe because the caller could potentially construct
an EncryptionContext
from a previously used initialization vector (IV).
§Errors
Returns an error on an internal failure.
pub fn cbc_pkcs7(
key: UnboundCipherKey,
) -> Result<StreamingEncryptingKey, Unspecified>
pub fn cbc_pkcs7( key: UnboundCipherKey, ) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting data using the CBC cipher mode
with pkcs7 padding.
The resulting ciphertext will be longer than the plaintext; padding is added
to fill the next block of ciphertext.
§Errors
Returns an error on an internal failure.
pub fn cfb128(
key: UnboundCipherKey,
) -> Result<StreamingEncryptingKey, Unspecified>
pub fn cfb128( key: UnboundCipherKey, ) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting data using the CFB128 cipher mode.
The resulting ciphertext will be the same length as the plaintext.
§Errors
Returns and error on an internal failure.
pub fn ecb_pkcs7(
key: UnboundCipherKey,
) -> Result<StreamingEncryptingKey, Unspecified>
pub fn ecb_pkcs7( key: UnboundCipherKey, ) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting using ECB cipher mode with PKCS7 padding.
The resulting plaintext will be the same length as the ciphertext.
§☠️ ️️️DANGER ☠️
Offered for computability purposes only. This is an extremely dangerous mode, and very likely not what you want to use.
§Errors
Returns an error on an internal failure.
pub fn less_safe_cfb128(
key: UnboundCipherKey,
context: EncryptionContext,
) -> Result<StreamingEncryptingKey, Unspecified>
pub fn less_safe_cfb128( key: UnboundCipherKey, context: EncryptionContext, ) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting data using the CFB128 cipher mode.
The resulting ciphertext will be the same length as the plaintext.
This is considered less safe because the caller could potentially construct
an EncryptionContext
from a previously used initialization vector (IV).
§Errors
Returns an error on an internal failure.
pub fn less_safe_cbc_pkcs7(
key: UnboundCipherKey,
context: EncryptionContext,
) -> Result<StreamingEncryptingKey, Unspecified>
pub fn less_safe_cbc_pkcs7( key: UnboundCipherKey, context: EncryptionContext, ) -> Result<StreamingEncryptingKey, Unspecified>
Constructs a StreamingEncryptingKey
for encrypting data using the CBC cipher mode
with pkcs7 padding.
The resulting ciphertext will be longer than the plaintext; padding is added
to fill the next block of ciphertext.
This is considered less safe because the caller could potentially construct
an EncryptionContext
from a previously used initialization vector (IV).
§Errors
Returns an error on an internal failure.
Auto Trait Implementations§
impl Freeze for StreamingEncryptingKey
impl RefUnwindSafe for StreamingEncryptingKey
impl !Send for StreamingEncryptingKey
impl !Sync for StreamingEncryptingKey
impl Unpin for StreamingEncryptingKey
impl UnwindSafe for StreamingEncryptingKey
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more