mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
update the secret variables
This commit is contained in:
parent
87c935dc1e
commit
7d07ccfe40
2 changed files with 38 additions and 24 deletions
18
src/api.go
18
src/api.go
|
@ -1,23 +1,5 @@
|
||||||
package croc
|
package croc
|
||||||
|
|
||||||
import "time"
|
|
||||||
|
|
||||||
// Init will initialize the croc relay
|
|
||||||
func Init() (c *Croc) {
|
|
||||||
c = new(Croc)
|
|
||||||
c.TcpPorts = []string{"27001", "27002", "27003", "27004"}
|
|
||||||
c.ServerPort = "8003"
|
|
||||||
c.Timeout = 10 * time.Minute
|
|
||||||
c.UseEncryption = true
|
|
||||||
c.UseCompression = true
|
|
||||||
c.AllowLocalDiscovery = true
|
|
||||||
c.CurveType = "p521"
|
|
||||||
c.rs.Lock()
|
|
||||||
c.rs.channel = make(map[string]*channelData)
|
|
||||||
c.rs.Unlock()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relay initiates a relay
|
// Relay initiates a relay
|
||||||
func (c *Croc) Relay() error {
|
func (c *Croc) Relay() error {
|
||||||
// start relay
|
// start relay
|
||||||
|
|
|
@ -15,8 +15,11 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// availableStates are the states available to the parties involved
|
// see PAKE setup for more info: https://play.golang.org/p/QLHvINK4qFG
|
||||||
availableStates = []string{"curve", "h_k", "hh_k", "x", "y"}
|
// availableStates are the varaibles available to the parties involved
|
||||||
|
availableStates = []string{"curve", "Xᵤ", "Xᵥ", "Yᵤ", "Yᵥ", "Uᵤ", "Uᵥ", "Vᵤ", "Vᵥ", "HHBk", "HAk"}
|
||||||
|
// availableSecrets are the variables available only to a specific client, and not shared
|
||||||
|
availableSecrets = []string{"pw", "Upwᵤ", "Upwᵥ", "α", "αᵤ", "αᵥ", "Vpwᵤ", "Vpwᵥ", "β", "gβᵤ", "gβᵥ", "BZᵤ", "BZᵥ", "BZᵤ", "BZᵥ", "AZᵤ", "AZᵥ", "AZᵤ", "AZᵥ", "Bk", "Ak"}
|
||||||
)
|
)
|
||||||
|
|
||||||
type Croc struct {
|
type Croc struct {
|
||||||
|
@ -36,6 +39,22 @@ type Croc struct {
|
||||||
cs clientState
|
cs clientState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init will initialize the croc relay
|
||||||
|
func Init() (c *Croc) {
|
||||||
|
c = new(Croc)
|
||||||
|
c.TcpPorts = []string{"27001", "27002", "27003", "27004"}
|
||||||
|
c.ServerPort = "8003"
|
||||||
|
c.Timeout = 10 * time.Minute
|
||||||
|
c.UseEncryption = true
|
||||||
|
c.UseCompression = true
|
||||||
|
c.AllowLocalDiscovery = true
|
||||||
|
c.CurveType = "p521"
|
||||||
|
c.rs.Lock()
|
||||||
|
c.rs.channel = make(map[string]*channelData)
|
||||||
|
c.rs.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
type relayState struct {
|
type relayState struct {
|
||||||
channel map[string]*channelData
|
channel map[string]*channelData
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
|
@ -69,12 +88,21 @@ type channelData struct {
|
||||||
Role int `json:"role"`
|
Role int `json:"role"`
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
// client parameters
|
||||||
|
|
||||||
|
// secret are the computed secretes
|
||||||
|
// contains "curve", "h_k", "hh_k", "x", "y"
|
||||||
|
secret map[string][]byte `json:"secret"`
|
||||||
|
|
||||||
|
// relay + client parameters
|
||||||
|
// curve is the type of elliptic curve used for PAKE
|
||||||
|
curve elliptic.Curve
|
||||||
|
|
||||||
|
// relay parameters
|
||||||
// isopen determine whether or not the channel has been opened
|
// isopen determine whether or not the channel has been opened
|
||||||
isopen bool
|
isopen bool
|
||||||
// store a UUID of the parties to prevent other parties from joining
|
// store a UUID of the parties to prevent other parties from joining
|
||||||
uuids [2]string // 0 is sender, 1 is recipient
|
uuids [2]string // 0 is sender, 1 is recipient
|
||||||
// curve is the type of elliptic curve used for PAKE
|
|
||||||
curve elliptic.Curve
|
|
||||||
// connection information is stored when the clients do connect over TCP
|
// connection information is stored when the clients do connect over TCP
|
||||||
connection [2]net.Conn
|
connection [2]net.Conn
|
||||||
// websocket connections
|
// websocket connections
|
||||||
|
@ -119,8 +147,12 @@ func newChannelData(name string) (cd *channelData) {
|
||||||
cd = new(channelData)
|
cd = new(channelData)
|
||||||
cd.Channel = name
|
cd.Channel = name
|
||||||
cd.State = make(map[string][]byte)
|
cd.State = make(map[string][]byte)
|
||||||
for _, state := range availableStates {
|
for _, s := range availableStates {
|
||||||
cd.State[state] = []byte{}
|
cd.State[s] = []byte{}
|
||||||
|
}
|
||||||
|
cd.secret = make(map[string][]byte)
|
||||||
|
for _, s := range availableSecrets {
|
||||||
|
cd.secret[s] = []byte{}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue