summaryrefslogtreecommitdiffstats
path: root/third_party/rust/ohttp/src/rh/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/ohttp/src/rh/mod.rs')
-rw-r--r--third_party/rust/ohttp/src/rh/mod.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/third_party/rust/ohttp/src/rh/mod.rs b/third_party/rust/ohttp/src/rh/mod.rs
new file mode 100644
index 0000000000..8f91a2ab17
--- /dev/null
+++ b/third_party/rust/ohttp/src/rh/mod.rs
@@ -0,0 +1,47 @@
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+pub mod aead;
+pub mod hkdf;
+pub mod hpke;
+
+use crate::err::Res;
+
+pub struct SymKey(Vec<u8>);
+
+impl SymKey {
+ #[allow(clippy::unnecessary_wraps)]
+ pub fn key_data(&self) -> Res<&[u8]> {
+ Ok(&self.0)
+ }
+}
+
+impl From<Vec<u8>> for SymKey {
+ fn from(v: Vec<u8>) -> Self {
+ SymKey(v)
+ }
+}
+impl From<&[u8]> for SymKey {
+ fn from(v: &[u8]) -> Self {
+ SymKey(v.to_owned())
+ }
+}
+
+impl AsRef<[u8]> for SymKey {
+ fn as_ref(&self) -> &[u8] {
+ &self.0
+ }
+}
+
+impl std::fmt::Debug for SymKey {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Ok(b) = self.key_data() {
+ write!(f, "SymKey {}", hex::encode(b))
+ } else {
+ write!(f, "Opaque SymKey")
+ }
+ }
+}