Crate tls_codec[−][src]
Expand description
TLS Codec
This crate implements the TLS codec as defined in RFC 8446 as well as some extensions required by MLS.
With the feature derive
TlsSerialize
and TlsDeserialize
can be
derived.
This crate provides the following data structures that implement TLS serialization/deserialization
u8
,u16
,u32
,u64
TlsVecU8
,TlsVecU16
,TlsVecU32
SecretTlsVecU8
,SecretTlsVecU16
,SecretTlsVecU32
The same as theTlsVec*
versions but it implements zeroize, requiring the elements to implement zeroize as well.TlsSliceU8
,TlsSliceU16
,TlsSliceU32
are lightweight wrapper for slices that allow to serialize them without having to create aTlsVec*
.[u8; l]
, forl ∈ [1..128]
- Serialize for
Option<T>
whereT: Serialize
- Deserialize for
Option<T>
whereT: Deserialize
Usage
use tls_codec::{TlsVecU8, Serialize, Deserialize}; let mut b = &[1u8, 4, 77, 88, 1, 99] as &[u8]; let a = u8::tls_deserialize(&mut b).expect("Unable to tls_deserialize"); assert_eq!(1, a); println!("b: {:?}", b); let v = TlsVecU8::<u8>::tls_deserialize(&mut b).expect("Unable to tls_deserialize"); assert_eq!(&[77, 88, 1, 99], v.as_slice());
Structs
Enums
Errors that are thrown by this crate.
Traits
The Deserialize
trait provides functions to deserialize a byte slice to a
struct or enum.
The Serialize
trait provides functions to serialize a struct or enum.
The TlsSize
trait needs to be implemented by any struct that should be
efficiently serialized.
This allows to collect the length of a serialized structure before allocating
memory.