From 283bf704a242dc6afc7f55a23f46f6c998e23ef2 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Fri, 29 Jun 2018 08:01:21 -0700 Subject: [PATCH] todo: make big.Ints part of channelData --- README.md | 7 +++++-- src/client.go | 20 ++++++++++++++++++++ src/models.go | 3 +++ src/server.go | 3 +++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 652c911..cd6aa68 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,11 @@ croc.Receive() *Initialize* - Requests to join. + +*Does X not exist?* + - Generates X from pw. -- Sender sends X to relay. +- Update relay with X. *Is Y and Bcrypt(k_B) available?* @@ -106,7 +109,7 @@ croc.Receive() - Check that Bcrypt(k_B) comes from k_A. Abort here if it is incorrect. - Encrypts data using *k_A*. - Connect to TCP ports of Relay. -- Send the Relay authentication *Bcrypt(k_A)*. +- Update relay with *Bcrypt(k_A)*. *Are ports stapled?* diff --git a/src/client.go b/src/client.go index 5092fe7..2ced47e 100644 --- a/src/client.go +++ b/src/client.go @@ -1,6 +1,8 @@ package croc import ( + "bytes" + "crypto/rand" "errors" "net/url" "os" @@ -143,5 +145,23 @@ func (c *Croc) processState(cd channelData) (err error) { // TODO: // process the client state log.Debugf("processing client state: %+v", c.cs.channel.String2()) + if c.cs.channel.Role == 0 { + // processing for sender + + // *Does X not exist?* + // - Generates X from pw. + // - Update relay with X. + if bytes.Equal(c.cs.channel.State["Xᵤ"], []byte{}) { + random1 := make([]byte, 8) + rand.Read(random1) + random2 := make([]byte, 8) + rand.Read(random2) + c.cs.channel.State["Uᵤ"], c.cs.channel.State["Uᵥ"] = []byte(c.cs.channel.curve.ScalarBaseMult(random1)) + c.cs.channel.State["Vᵤ"], c.cs.channel.State["Vᵥ"] = []byte(c.cs.channel.curve.ScalarBaseMult(random2)) + } + + } else if c.cs.channel.Role == 1 { + // processing for recipient + } return } diff --git a/src/models.go b/src/models.go index 359b5e7..0a9bdf3 100644 --- a/src/models.go +++ b/src/models.go @@ -17,6 +17,9 @@ const ( ) var ( + // TODO: + // MAKE EVERYTHING HERE PART OF THE CHANNELDATA! + // see PAKE setup for more info: https://play.golang.org/p/Sd0eTuuEIWu // availableStates are the varaibles available to the parties involved availableStates = []string{"curve", "Xᵤ", "Xᵥ", "Yᵤ", "Yᵥ", "Uᵤ", "Uᵥ", "Vᵤ", "Vᵥ", "Bcrypt(Ak)", "Bcrypt(Bk)"} diff --git a/src/server.go b/src/server.go index e3f9bc0..07a9501 100644 --- a/src/server.go +++ b/src/server.go @@ -10,12 +10,14 @@ import ( "github.com/pkg/errors" ) +// startServer initiates the server which listens for websocket connections func (c *Croc) startServer(tcpPorts []string, port string) (err error) { // start cleanup on dangling channels go c.channelCleanup() var upgrader = websocket.Upgrader{} // use default options http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + // incoming websocket request ws, err := upgrader.Upgrade(w, r, nil) log.Debugf("connecting remote addr: %s", ws.RemoteAddr().String()) if err != nil { @@ -23,6 +25,7 @@ func (c *Croc) startServer(tcpPorts []string, port string) (err error) { return } defer ws.Close() + var channel string for { log.Debug("waiting for next message")