mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
todo: make big.Ints part of channelData
This commit is contained in:
parent
f64427f70d
commit
283bf704a2
4 changed files with 31 additions and 2 deletions
|
@ -97,8 +97,11 @@ croc.Receive()
|
||||||
*Initialize*
|
*Initialize*
|
||||||
|
|
||||||
- Requests to join.
|
- Requests to join.
|
||||||
|
|
||||||
|
*Does X not exist?*
|
||||||
|
|
||||||
- Generates X from pw.
|
- Generates X from pw.
|
||||||
- Sender sends X to relay.
|
- Update relay with X.
|
||||||
|
|
||||||
*Is Y and Bcrypt(k_B) available?*
|
*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.
|
- Check that Bcrypt(k_B) comes from k_A. Abort here if it is incorrect.
|
||||||
- Encrypts data using *k_A*.
|
- Encrypts data using *k_A*.
|
||||||
- Connect to TCP ports of Relay.
|
- Connect to TCP ports of Relay.
|
||||||
- Send the Relay authentication *Bcrypt(k_A)*.
|
- Update relay with *Bcrypt(k_A)*.
|
||||||
|
|
||||||
*Are ports stapled?*
|
*Are ports stapled?*
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package croc
|
package croc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -143,5 +145,23 @@ func (c *Croc) processState(cd channelData) (err error) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// process the client state
|
// process the client state
|
||||||
log.Debugf("processing client state: %+v", c.cs.channel.String2())
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,9 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// TODO:
|
||||||
|
// MAKE EVERYTHING HERE PART OF THE CHANNELDATA!
|
||||||
|
|
||||||
// see PAKE setup for more info: https://play.golang.org/p/Sd0eTuuEIWu
|
// see PAKE setup for more info: https://play.golang.org/p/Sd0eTuuEIWu
|
||||||
// availableStates are the varaibles available to the parties involved
|
// availableStates are the varaibles available to the parties involved
|
||||||
availableStates = []string{"curve", "Xᵤ", "Xᵥ", "Yᵤ", "Yᵥ", "Uᵤ", "Uᵥ", "Vᵤ", "Vᵥ", "Bcrypt(Ak)", "Bcrypt(Bk)"}
|
availableStates = []string{"curve", "Xᵤ", "Xᵥ", "Yᵤ", "Yᵥ", "Uᵤ", "Uᵥ", "Vᵤ", "Vᵥ", "Bcrypt(Ak)", "Bcrypt(Bk)"}
|
||||||
|
|
|
@ -10,12 +10,14 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// startServer initiates the server which listens for websocket connections
|
||||||
func (c *Croc) startServer(tcpPorts []string, port string) (err error) {
|
func (c *Croc) startServer(tcpPorts []string, port string) (err error) {
|
||||||
// start cleanup on dangling channels
|
// start cleanup on dangling channels
|
||||||
go c.channelCleanup()
|
go c.channelCleanup()
|
||||||
|
|
||||||
var upgrader = websocket.Upgrader{} // use default options
|
var upgrader = websocket.Upgrader{} // use default options
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// incoming websocket request
|
||||||
ws, err := upgrader.Upgrade(w, r, nil)
|
ws, err := upgrader.Upgrade(w, r, nil)
|
||||||
log.Debugf("connecting remote addr: %s", ws.RemoteAddr().String())
|
log.Debugf("connecting remote addr: %s", ws.RemoteAddr().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,6 +25,7 @@ func (c *Croc) startServer(tcpPorts []string, port string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer ws.Close()
|
defer ws.Close()
|
||||||
|
|
||||||
var channel string
|
var channel string
|
||||||
for {
|
for {
|
||||||
log.Debug("waiting for next message")
|
log.Debug("waiting for next message")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue