aboutsummaryrefslogtreecommitdiffstats
path: root/src/types/keys.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-17 16:31:08 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-17 16:31:08 +0200
commit78ab1a93e6d519bf404fbe61fc7ec3c3ab35a72a (patch)
tree75106e1ff89a03a6869184994b902a70315dfc30 /src/types/keys.rs
parentBegin drafting cross-platform interface (diff)
downloadwireguard-rs-78ab1a93e6d519bf404fbe61fc7ec3c3ab35a72a.tar.xz
wireguard-rs-78ab1a93e6d519bf404fbe61fc7ec3c3ab35a72a.zip
Remove peer from cryptkey router on drop
Diffstat (limited to 'src/types/keys.rs')
-rw-r--r--src/types/keys.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/types/keys.rs b/src/types/keys.rs
new file mode 100644
index 0000000..0b52d18
--- /dev/null
+++ b/src/types/keys.rs
@@ -0,0 +1,26 @@
+use std::time::Instant;
+
+/* This file holds types passed between components.
+ * Whenever a type cannot be held local to a single module.
+ */
+
+#[derive(Debug, Clone, Copy)]
+pub struct Key {
+ pub key: [u8; 32],
+ pub id: u32,
+}
+
+#[cfg(test)]
+impl PartialEq for Key {
+ fn eq(&self, other: &Self) -> bool {
+ self.id == other.id && self.key[..] == other.key[..]
+ }
+}
+
+#[derive(Debug, Clone, Copy)]
+pub struct KeyPair {
+ pub birth: Instant, // when was the key-pair created
+ pub confirmed: bool, // has the key-pair been confirmed?
+ pub send: Key, // key for outbound messages
+ pub recv: Key, // key for inbound messages
+} \ No newline at end of file