pub struct OpaqueMessage {
pub typ: ContentType,
pub version: ProtocolVersion,
/* private fields */
}
Expand description
A TLS frame, named TLSPlaintext in the standard.
This type owns all memory for its interior parts. It is used to read/write from/to I/O
buffers as well as for fragmenting, joining and encryption/decryption. It can be converted
into a Message
by decoding the payload.
§Decryption
Internally the message payload is stored as a Vec<u8>
; this can by mutably borrowed with
OpaqueMessage::payload_mut()
. This is useful for decrypting a message in-place.
After the message is decrypted, call OpaqueMessage::into_plain_message()
or
OpaqueMessage::into_tls13_unpadded_message()
(depending on the
protocol version).
Fields§
§typ: ContentType
§version: ProtocolVersion
Implementations§
source§impl OpaqueMessage
impl OpaqueMessage
sourcepub fn new(typ: ContentType, version: ProtocolVersion, body: Vec<u8>) -> Self
pub fn new(typ: ContentType, version: ProtocolVersion, body: Vec<u8>) -> Self
Construct a new OpaqueMessage
from constituent fields.
body
is moved into the payload
field.
sourcepub fn payload_mut(&mut self) -> &mut Vec<u8>
pub fn payload_mut(&mut self) -> &mut Vec<u8>
Access the message payload as a mutable Vec<u8>
.
sourcepub fn read(r: &mut Reader<'_>) -> Result<Self, MessageError>
pub fn read(r: &mut Reader<'_>) -> Result<Self, MessageError>
MessageError
allows callers to distinguish between valid prefixes (might
become valid if we read more data) and invalid data.
pub fn encode(self) -> Vec<u8>
sourcepub fn into_plain_message(self) -> PlainMessage
pub fn into_plain_message(self) -> PlainMessage
Force conversion into a plaintext message.
This should only be used for messages that are known to be in plaintext. Otherwise, the
OpaqueMessage
should be decrypted into a PlainMessage
using a MessageDecrypter
.
sourcepub fn into_tls13_unpadded_message(self) -> Result<PlainMessage, Error>
pub fn into_tls13_unpadded_message(self) -> Result<PlainMessage, Error>
For TLS1.3 (only), checks the length msg.payload is valid and removes the padding.
Returns an error if the message (pre-unpadding) is too long, or the padding is invalid, or the message (post-unpadding) is too long.
sourcepub const MAX_WIRE_SIZE: usize = 18_437usize
pub const MAX_WIRE_SIZE: usize = 18_437usize
Maximum on-wire message size.
Trait Implementations§
source§impl Clone for OpaqueMessage
impl Clone for OpaqueMessage
source§fn clone(&self) -> OpaqueMessage
fn clone(&self) -> OpaqueMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for OpaqueMessage
impl RefUnwindSafe for OpaqueMessage
impl Send for OpaqueMessage
impl Sync for OpaqueMessage
impl Unpin for OpaqueMessage
impl UnwindSafe for OpaqueMessage
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)