1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-23 23:54:17 +03:00

todo: make big.Ints part of channelData

This commit is contained in:
Zack Scholl 2018-06-29 08:01:21 -07:00
parent f64427f70d
commit 283bf704a2
4 changed files with 31 additions and 2 deletions

View File

@ -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?*

View File

@ -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
}

View File

@ -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)"}

View File

@ -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")