1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
//! An experimental //! [OSCORE](https://tools.ietf.org/html/rfc8613) //! implementation with //! [EDHOC](https://tools.ietf.org/html/draft-selander-ace-cose-ecdhe-14) //! key exchange, intended for embedded devices. //! //! The EDHOC implementation is based on //! [draft 14](https://tools.ietf.org/html/draft-selander-ace-cose-ecdhe-14) //! of the EDHOC specification. It only does authentication with raw public //! keys (RPK), so it covers the asymmetric authentication scenario, but not //! the symmetric one using pre-shared keys (PSK). //! On the OSCORE side, it does key derivation using the master secret and //! master salt, which can be established with EDHOC. //! //! There is a //! [demo implementation](https://github.com/martindisch/oscore-demo) //! using this library, with a resource server on an STM32F3, a client on an //! STM32F4 and a CoAP proxy running on a Raspberry Pi. //! //! ## Security //! This should **not currently be used in production code**, use at your own //! risk. #![cfg_attr(not(feature = "std"), no_std)] #[macro_use] extern crate alloc; mod cbor; pub mod edhoc; pub mod oscore; /// Converts from `&Option<T>` to `Option<&T::Target>`. /// /// Leaves the original Option in-place, creating a new one with a reference /// to the original one, additionally coercing the contents via `Deref`. /// /// This is extracted from the `inner_deref` feature of unstable Rust /// (https://github.com/rust-lang/rust/issues/50264) and can be removed, as /// soon as the feature becomes stable. fn as_deref<T: core::ops::Deref>(option: &Option<T>) -> Option<&T::Target> { option.as_ref().map(|t| t.deref()) } #[cfg(test)] mod tests { use super::*; const REF_BYTES: [u8; 3] = [0x01, 0x02, 0x03]; #[test] fn deref() { let orig = Some(REF_BYTES.to_vec()); let derefed = as_deref(&orig).unwrap(); assert_eq!(&REF_BYTES, derefed); } }