• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // Copyright by contributors to this project.
3 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
4 
5 #![cfg_attr(not(feature = "std"), no_std)]
6 #![cfg_attr(coverage_nightly, feature(coverage_attribute))]
7 extern crate alloc;
8 
9 #[cfg(all(test, target_arch = "wasm32"))]
10 wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
11 
12 pub mod crypto;
13 pub mod debug;
14 pub mod error;
15 pub mod extension;
16 pub mod group;
17 pub mod identity;
18 pub mod key_package;
19 pub mod protocol_version;
20 pub mod psk;
21 pub mod secret;
22 pub mod time;
23 
24 pub use mls_rs_codec;
25 
26 #[cfg(feature = "arbitrary")]
27 pub use arbitrary;
28 
29 #[cfg(feature = "serde")]
30 pub mod zeroizing_serde {
31     use alloc::vec::Vec;
32     use serde::{Deserializer, Serializer};
33     use zeroize::Zeroizing;
34 
35     use crate::vec_serde;
36 
serialize<S: Serializer>(v: &Zeroizing<Vec<u8>>, s: S) -> Result<S::Ok, S::Error>37     pub fn serialize<S: Serializer>(v: &Zeroizing<Vec<u8>>, s: S) -> Result<S::Ok, S::Error> {
38         vec_serde::serialize(v, s)
39     }
40 
deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Zeroizing<Vec<u8>>, D::Error>41     pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Zeroizing<Vec<u8>>, D::Error> {
42         vec_serde::deserialize(d).map(Zeroizing::new)
43     }
44 }
45 
46 #[cfg(feature = "serde")]
47 pub mod vec_serde {
48     use alloc::vec::Vec;
49     use serde::{Deserializer, Serializer};
50 
serialize<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error>51     pub fn serialize<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error> {
52         if s.is_human_readable() {
53             hex::serde::serialize(v, s)
54         } else {
55             serde_bytes::serialize(v, s)
56         }
57     }
58 
deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error>59     pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
60         if d.is_human_readable() {
61             hex::serde::deserialize(d)
62         } else {
63             serde_bytes::deserialize(d)
64         }
65     }
66 }
67