aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Warner <warner@lothar.com>2017-05-06 01:25:23 -0700
committerBrian Warner <warner@lothar.com>2017-05-06 01:25:23 -0700
commit48fa27649f1cfeb27a1beffd2d28b8a746b4c558 (patch)
tree0ae7a5d0e4b8bf62bc1f21d5b6c6bb53b422f62d /src
downloadPAKEs-48fa27649f1cfeb27a1beffd2d28b8a746b4c558.tar.xz
initial sketches, help from hdevalence
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs22
-rw-r--r--src/spake2.rs44
2 files changed, 66 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..abab8b1
--- /dev/null
+++ b/src/lib.rs
@@ -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
index 0000000..7d813d9
--- /dev/null
+++ b/src/spake2.rs
@@ -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);
+}