Struct tlspuffin::tls::rustls::record_layer::RecordLayer
source · pub struct RecordLayer {
message_encrypter: Box<dyn MessageEncrypter>,
message_decrypter: Box<dyn MessageDecrypter>,
write_seq: u64,
read_seq: u64,
encrypt_state: DirectionState,
decrypt_state: DirectionState,
trial_decryption_len: Option<usize>,
}
Fields§
§message_encrypter: Box<dyn MessageEncrypter>
§message_decrypter: Box<dyn MessageDecrypter>
§write_seq: u64
§read_seq: u64
§encrypt_state: DirectionState
§decrypt_state: DirectionState
§trial_decryption_len: Option<usize>
Implementations§
source§impl RecordLayer
impl RecordLayer
pub fn new() -> Self
pub fn is_encrypting(&self) -> bool
pub fn is_decrypting(&self) -> bool
pub fn doing_trial_decryption(&mut self, requested: usize) -> bool
sourcepub fn prepare_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
pub fn prepare_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
Prepare to use the given MessageEncrypter
for future message encryption.
It is not used until you call start_encrypting
.
sourcepub fn prepare_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
pub fn prepare_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
Prepare to use the given MessageDecrypter
for future message decryption.
It is not used until you call start_decrypting
.
sourcepub fn start_encrypting(&mut self)
pub fn start_encrypting(&mut self)
Start using the MessageEncrypter
previously provided to the previous
call to prepare_message_encrypter
.
sourcepub fn start_decrypting(&mut self)
pub fn start_decrypting(&mut self)
Start using the MessageDecrypter
previously provided to the previous
call to prepare_message_decrypter
.
sourcepub fn set_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
pub fn set_message_encrypter(&mut self, cipher: Box<dyn MessageEncrypter>)
Set and start using the given MessageEncrypter
for future outgoing
message encryption.
sourcepub fn set_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
pub fn set_message_decrypter(&mut self, cipher: Box<dyn MessageDecrypter>)
Set and start using the given MessageDecrypter
for future incoming
message decryption.
sourcepub fn set_message_decrypter_with_trial_decryption(
&mut self,
cipher: Box<dyn MessageDecrypter>,
max_length: usize,
)
pub fn set_message_decrypter_with_trial_decryption( &mut self, cipher: Box<dyn MessageDecrypter>, max_length: usize, )
Set and start using the given MessageDecrypter
for future incoming
message decryption, and enable “trial decryption” mode for when TLS1.3
0-RTT is attempted but rejected by the server.
pub fn finish_trial_decryption(&mut self)
sourcepub fn wants_close_before_decrypt(&self) -> bool
pub fn wants_close_before_decrypt(&self) -> bool
Return true if the peer appears to getting close to encrypting too many messages with this key.
Perhaps if we send an alert well before their counter wraps, a buggy peer won’t make a terrible mistake here?
Note that there’s no reason to refuse to decrypt: the security failure has already happened.
sourcepub fn wants_close_before_encrypt(&self) -> bool
pub fn wants_close_before_encrypt(&self) -> bool
Return true if we are getting close to encrypting too many messages with our encryption key.
sourcepub fn encrypt_exhausted(&self) -> bool
pub fn encrypt_exhausted(&self) -> bool
Return true if we outright refuse to do anything with the encryption key.
sourcepub fn decrypt_incoming(
&mut self,
encr: OpaqueMessage,
) -> Result<PlainMessage, Error>
pub fn decrypt_incoming( &mut self, encr: OpaqueMessage, ) -> Result<PlainMessage, Error>
Decrypt a TLS message.
encr
is a decoded message allegedly received from the peer.
If it can be decrypted, its decryption is returned. Otherwise,
an error is returned.
sourcepub fn encrypt_outgoing(
&mut self,
plain: BorrowedPlainMessage<'_>,
) -> OpaqueMessage
pub fn encrypt_outgoing( &mut self, plain: BorrowedPlainMessage<'_>, ) -> OpaqueMessage
Encrypt a TLS message.
plain
is a TLS message we’d like to send. This function
panics if the requisite keying material hasn’t been established yet.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RecordLayer
impl !RefUnwindSafe for RecordLayer
impl Send for RecordLayer
impl Sync for RecordLayer
impl Unpin for RecordLayer
impl !UnwindSafe for RecordLayer
Blanket Implementations§
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<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
§type PreprendResult = Tail
type PreprendResult = Tail
TupleList
], of an [Prepend::prepend()
] call,
including the prepended entry.