]> git.lizzy.rs Git - PAKEs.git/commitdiff
initial sketches, help from hdevalence
authorBrian Warner <warner@lothar.com>
Sat, 6 May 2017 08:25:23 +0000 (01:25 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 6 May 2017 08:25:23 +0000 (01:25 -0700)
.gitignore [new file with mode: 0644]
Cargo.toml [new file with mode: 0644]
src/lib.rs [new file with mode: 0644]
src/spake2.rs [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..4308d82
--- /dev/null
@@ -0,0 +1,3 @@
+target/
+**/*.rs.bk
+Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644 (file)
index 0000000..f470646
--- /dev/null
@@ -0,0 +1,8 @@
+[package]
+name = "spake2"
+version = "0.1.0"
+authors = ["Brian Warner <warner@lothar.com>"]
+
+[dependencies]
+#rust-crypto = "^0.2"
+curve25519-dalek = "0.2.0"
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644 (file)
index 0000000..abab8b1
--- /dev/null
@@ -0,0 +1,22 @@
+
+pub mod spake2;
+//use spake2::*;
+
+#[cfg(test)]
+mod tests {
+    use spake2;
+    #[test]
+    fn test_foo() {
+        assert_eq!(spake2::foo(), 1);
+    }
+
+    #[test]
+    fn it_works() {
+    }
+
+    #[test]
+    #[should_panic(expected = "nope")]
+    fn it_panics() {
+        assert!(false, "nope");
+    }
+}
diff --git a/src/spake2.rs b/src/spake2.rs
new file mode 100644 (file)
index 0000000..7d813d9
--- /dev/null
@@ -0,0 +1,44 @@
+
+pub fn foo() -> u8 {
+    1
+}
+
+
+trait Group {
+    type Scalar;
+    type Element;
+    pub fn scalarmult(s: Scalar) -> Element;
+    pub fn scalar_from_integer(u8) -> Scalar;
+}
+
+
+struct SPAKE2<G: Group> {
+    x: G::Scalar,
+    password: Vec<u8>,
+    idA: Vec<u8>,
+    idB: Vec<u8>,
+    pw: G::Scalar,
+}
+
+impl<G> for SPAKE2 {
+    pub fn new<G>(password: &[u8], idA: &[u8], idB: &[u8]) -> SPAKE2<G> {
+        let pw: G::Scalar = hash_to_scalar::<G::Scalar>(password);
+        let x: G::Scalar = random_scalar::<G::Scalar>;
+
+        let M1 G::Element = MAGIC();
+        let msg1 = ...
+        let mut pv = Vec::new();
+        pv.extend_from_slice(password);
+        (SPAKE2 {x: x, password: pv, ... }, msg1)
+    }
+    
+    pub fn finish(self, msg2: &[u8]) -> Result<Key, SPAKEErr> {
+    }
+}
+
+
+{
+    let (mut s, msg1) = SPAKE2::<Ed25519>(&password, &idA, &idB);
+    //let msg1 = s.msg1;
+    let key = s.finish(msg2);
+}