diff --git a/main.go b/main.go index 5b88e04..cb60b34 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "strings" "time" croc "github.com/schollz/croc/src" @@ -57,6 +58,7 @@ func main() { Flags: []cli.Flag{ cli.StringFlag{Name: "tcp", Value: "27130,27131,27132,27133", Usage: "ports for the tcp connections"}, cli.StringFlag{Name: "port", Value: "8130", Usage: "port that the websocket listens on"}, + cli.StringFlag{Name: "curve", Value: "siec", Usage: "specify elliptic curve to use (p224, p256, p384, p521, siec)"}, }, HelpName: "croc relay", Action: func(c *cli.Context) error { @@ -112,6 +114,9 @@ func receive(c *cli.Context) error { } func relay(c *cli.Context) error { + cr.TcpPorts = strings.Split(c.GlobalString("tcp"), ",") + cr.ServerPort = c.GlobalString("port") + cr.CurveType = c.GlobalString("curve") fmt.Println("relay") return nil } diff --git a/src/models.go b/src/models.go index 3ee78b6..97e9b9f 100644 --- a/src/models.go +++ b/src/models.go @@ -143,7 +143,8 @@ type channelData struct { // passPhrase is used to generate a session key passPhrase string // sessionKey - sessionKey []byte + sessionKey []byte + // isReady specifies whether the current client isReady bool fileReady bool fileMetaData FileMetaData diff --git a/src/pake/pake_test.go b/src/pake/pake_test.go index 6eec644..e03bec0 100644 --- a/src/pake/pake_test.go +++ b/src/pake/pake_test.go @@ -1,12 +1,61 @@ package pake import ( + "crypto/elliptic" "testing" "github.com/stretchr/testify/assert" "github.com/tscholl2/siec" ) +func BenchmarkPakeSIEC255(b *testing.B) { + curve := siec.SIEC255() + for i := 0; i < b.N; i++ { + // initialize A + A, _ := Init([]byte{1, 2, 3}, 0, curve) + // initialize B + B, _ := Init([]byte{1, 2, 3}, 1, curve) + // send A's stuff to B + B.Update(A.Bytes()) + // send B's stuff to A + A.Update(B.Bytes()) + // send A's stuff back to B + B.Update(A.Bytes()) + } +} + +func BenchmarkPakeP521(b *testing.B) { + curve := elliptic.P521() + for i := 0; i < b.N; i++ { + // initialize A + A, _ := Init([]byte{1, 2, 3}, 0, curve) + // initialize B + B, _ := Init([]byte{1, 2, 3}, 1, curve) + // send A's stuff to B + B.Update(A.Bytes()) + // send B's stuff to A + A.Update(B.Bytes()) + // send A's stuff back to B + B.Update(A.Bytes()) + } +} + +func BenchmarkPakeP224(b *testing.B) { + curve := elliptic.P224() + for i := 0; i < b.N; i++ { + // initialize A + A, _ := Init([]byte{1, 2, 3}, 0, curve) + // initialize B + B, _ := Init([]byte{1, 2, 3}, 1, curve) + // send A's stuff to B + B.Update(A.Bytes()) + // send B's stuff to A + A.Update(B.Bytes()) + // send A's stuff back to B + B.Update(A.Bytes()) + } +} + func TestPake(t *testing.T) { curve := siec.SIEC255() // successful (both have same k)