#tls #deserialize #serialization #mls #zeroize #rfc #codec

no-std tls_codec

A pure Rust implementation of the TLS (de)serialization

22 releases

0.4.2-pre.1 Jul 19, 2024
0.4.1 Jan 26, 2024
0.4.0 Nov 21, 2023
0.3.0 Jun 22, 2023
0.1.4 Jul 8, 2021

#1977 in Cryptography

Download history 18175/week @ 2024-07-18 23264/week @ 2024-07-25 18730/week @ 2024-08-01 18932/week @ 2024-08-08 25317/week @ 2024-08-15 22692/week @ 2024-08-22 20116/week @ 2024-08-29 25666/week @ 2024-09-05 21024/week @ 2024-09-12 23001/week @ 2024-09-19 26171/week @ 2024-09-26 29873/week @ 2024-10-03 27386/week @ 2024-10-10 28375/week @ 2024-10-17 33302/week @ 2024-10-24 28507/week @ 2024-10-31

123,687 downloads per month
Used in 29 crates (9 directly)

Apache-2.0 OR MIT

86KB
2K SLoC

RustCrypto: TLS Codec

MIT licensed Project Chat Rust Version

crates.io docs.rs
tls_codec Docs
tls_codec_derive Docs

This crate implements the TLS codec as defined in RFC 8446 as well as some extensions required by MLS.

With the derive feature TlsSerialize and TlsDeserialize can be derived.

The crate also provides the following data structures that implement TLS serialization/deserialization

  • u8, u16, u32, u64
  • TlsVecU8, TlsVecU16, TlsVecU32
  • SecretTlsVecU8, SecretTlsVecU16, SecretTlsVecU32 The same as the TlsVec* 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 a TlsVec*.
  • TlsByteSliceU8, TlsByteSliceU16, TlsByteSliceU32, and TlsByteVecU8, TlsByteVecU16, TlsByteVecU32 are provided with optimized implementations for byte vectors.
  • [u8; l], for l ∈ [1..128]
  • Serialize for Option<T> where T: Serialize
  • Deserialize for Option<T> where T: Deserialize
  • Serialize for (T, U) and (T, U, V) where T, U, V implement Serialize`
  • Deserialize for (T, U) and (T, U, V) where T, U, V implement Deserialize`

Minimum Supported Rust Version

This crate requires Rust 1.60.0 at a minimum.

We may change the MSRV in the future, but it will be accompanied by a minor version bump.

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0.3–0.8MB
~18K SLoC