mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
allow changing curve
This commit is contained in:
parent
7a997156ed
commit
cec39ba2ce
4 changed files with 71 additions and 38 deletions
17
README.md
17
README.md
|
@ -137,6 +137,15 @@ You can send with your own code phrase (must be more than 4 characters).
|
||||||
croc send --code [code-phrase] [file(s)-or-folder]
|
croc send --code [code-phrase] [file(s)-or-folder]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Allow overwriting without prompt
|
||||||
|
|
||||||
|
By default, croc will prompt whether to overwrite a file. You can automatically overwrite files by using the `--overwrite` flag (recipient only). For example, receive a file to automatically overwrite:
|
||||||
|
|
||||||
|
```
|
||||||
|
croc --yes --overwrite <code>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Use pipes - stdin and stdout
|
### Use pipes - stdin and stdout
|
||||||
|
|
||||||
You can pipe to `croc`:
|
You can pipe to `croc`:
|
||||||
|
@ -173,6 +182,14 @@ You can use a proxy as your connection to the relay by adding a proxy address wi
|
||||||
croc --socks5 "127.0.0.1:9050" send SOMEFILE
|
croc --socks5 "127.0.0.1:9050" send SOMEFILE
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Change encryption curve
|
||||||
|
|
||||||
|
You can choose from several different elliptic curves to use for encryption by using the `--curve` flag. Only the recipient can choose the curve. For example, receive a file using the P-521 curve:
|
||||||
|
|
||||||
|
```
|
||||||
|
croc --curve p521 <codephrase>
|
||||||
|
```
|
||||||
|
|
||||||
### Self-host relay
|
### Self-host relay
|
||||||
|
|
||||||
The relay is needed to staple the parallel incoming and outgoing connections. By default, `croc` uses a public relay but you can also run your own relay:
|
The relay is needed to staple the parallel incoming and outgoing connections. By default, `croc` uses a public relay but you can also run your own relay:
|
||||||
|
|
3
go.mod
3
go.mod
|
@ -1,9 +1,6 @@
|
||||||
module github.com/schollz/croc/v8
|
module github.com/schollz/croc/v8
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
replace github.com/schollz/pake3 => ../pake3
|
replace github.com/schollz/pake3 => ../pake3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/OneOfOne/xxhash v1.2.5 // indirect
|
github.com/OneOfOne/xxhash v1.2.5 // indirect
|
||||||
github.com/cespare/xxhash v1.1.0
|
github.com/cespare/xxhash v1.1.0
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/schollz/croc/v8/src/tcp"
|
"github.com/schollz/croc/v8/src/tcp"
|
||||||
"github.com/schollz/croc/v8/src/utils"
|
"github.com/schollz/croc/v8/src/utils"
|
||||||
log "github.com/schollz/logger"
|
log "github.com/schollz/logger"
|
||||||
|
pake "github.com/schollz/pake3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version specifies the version
|
// Version specifies the version
|
||||||
|
@ -87,6 +88,7 @@ func Run() (err error) {
|
||||||
&cli.BoolFlag{Name: "local", Usage: "force to use only local connections"},
|
&cli.BoolFlag{Name: "local", Usage: "force to use only local connections"},
|
||||||
&cli.BoolFlag{Name: "ignore-stdin", Usage: "ignore piped stdin"},
|
&cli.BoolFlag{Name: "ignore-stdin", Usage: "ignore piped stdin"},
|
||||||
&cli.BoolFlag{Name: "overwrite", Usage: "do not prompt to overwrite"},
|
&cli.BoolFlag{Name: "overwrite", Usage: "do not prompt to overwrite"},
|
||||||
|
&cli.StringFlag{Name: "curve", Value: "siec", Usage: "choose an encryption curve (" + strings.Join(pake.AvailableCurves(), ", ") + ")"},
|
||||||
&cli.StringFlag{Name: "ip", Value: "", Usage: "set sender ip if known e.g. 10.0.0.1:9009, [::1]:9009"},
|
&cli.StringFlag{Name: "ip", Value: "", Usage: "set sender ip if known e.g. 10.0.0.1:9009, [::1]:9009"},
|
||||||
&cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay", EnvVars: []string{"CROC_RELAY"}},
|
&cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay", EnvVars: []string{"CROC_RELAY"}},
|
||||||
&cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay", EnvVars: []string{"CROC_RELAY6"}},
|
&cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay", EnvVars: []string{"CROC_RELAY6"}},
|
||||||
|
@ -195,6 +197,7 @@ func send(c *cli.Context) (err error) {
|
||||||
SendingText: c.String("text") != "",
|
SendingText: c.String("text") != "",
|
||||||
NoCompress: c.Bool("no-compress"),
|
NoCompress: c.Bool("no-compress"),
|
||||||
Overwrite: c.Bool("overwrite"),
|
Overwrite: c.Bool("overwrite"),
|
||||||
|
Curve: c.String("curve"),
|
||||||
}
|
}
|
||||||
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
||||||
crocOptions.RelayAddress6 = ""
|
crocOptions.RelayAddress6 = ""
|
||||||
|
@ -391,6 +394,7 @@ func receive(c *cli.Context) (err error) {
|
||||||
OnlyLocal: c.Bool("local"),
|
OnlyLocal: c.Bool("local"),
|
||||||
IP: c.String("ip"),
|
IP: c.String("ip"),
|
||||||
Overwrite: c.Bool("overwrite"),
|
Overwrite: c.Bool("overwrite"),
|
||||||
|
Curve: c.String("curve"),
|
||||||
}
|
}
|
||||||
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
if crocOptions.RelayAddress != models.DEFAULT_RELAY {
|
||||||
crocOptions.RelayAddress6 = ""
|
crocOptions.RelayAddress6 = ""
|
||||||
|
|
|
@ -66,6 +66,7 @@ type Options struct {
|
||||||
NoCompress bool
|
NoCompress bool
|
||||||
IP string
|
IP string
|
||||||
Overwrite bool
|
Overwrite bool
|
||||||
|
Curve string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client holds the state of the croc transfer
|
// Client holds the state of the croc transfer
|
||||||
|
@ -165,11 +166,9 @@ func New(ops Options) (c *Client, err error) {
|
||||||
|
|
||||||
c.conn = make([]*comm.Comm, 16)
|
c.conn = make([]*comm.Comm, 16)
|
||||||
|
|
||||||
// initialize pake
|
// initialize pake for recipient
|
||||||
if c.Options.IsSender {
|
if !c.Options.IsSender {
|
||||||
c.Pake, err = pake.InitCurve([]byte(c.Options.SharedSecret[5:]), 1, "siec")
|
c.Pake, err = pake.InitCurve([]byte(c.Options.SharedSecret[5:]), 0, c.Options.Curve)
|
||||||
} else {
|
|
||||||
c.Pake, err = pake.InitCurve([]byte(c.Options.SharedSecret[5:]), 0, "siec")
|
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -696,6 +695,7 @@ func (c *Client) transfer(options TransferOptions) (err error) {
|
||||||
err = message.Send(c.conn[0], c.Key, message.Message{
|
err = message.Send(c.conn[0], c.Key, message.Message{
|
||||||
Type: "pake",
|
Type: "pake",
|
||||||
Bytes: c.Pake.Bytes(),
|
Bytes: c.Pake.Bytes(),
|
||||||
|
Bytes2: []byte(c.Options.Curve),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -825,12 +825,23 @@ func (c *Client) processMessageFileInfo(m message.Message) (done bool, err error
|
||||||
func (c *Client) processMessagePake(m message.Message) (err error) {
|
func (c *Client) processMessagePake(m message.Message) (err error) {
|
||||||
log.Debug("received pake payload")
|
log.Debug("received pake payload")
|
||||||
|
|
||||||
|
var salt []byte
|
||||||
|
if c.Options.IsSender {
|
||||||
|
// initialize curve based on the recipient's choice
|
||||||
|
log.Debugf("using curve %s", string(m.Bytes2))
|
||||||
|
c.Pake, err = pake.InitCurve([]byte(c.Options.SharedSecret[5:]), 1, string(m.Bytes2))
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// update the pake
|
||||||
err = c.Pake.Update(m.Bytes)
|
err = c.Pake.Update(m.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var salt []byte
|
|
||||||
if c.Options.IsSender {
|
// generate salt and send it back to recipient
|
||||||
log.Debug("generating salt")
|
log.Debug("generating salt")
|
||||||
salt = make([]byte, 8)
|
salt = make([]byte, 8)
|
||||||
if _, rerr := rand.Read(salt); err != nil {
|
if _, rerr := rand.Read(salt); err != nil {
|
||||||
|
@ -844,6 +855,10 @@ func (c *Client) processMessagePake(m message.Message) (err error) {
|
||||||
Bytes2: salt,
|
Bytes2: salt,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
err = c.Pake.Update(m.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
salt = m.Bytes2
|
salt = m.Bytes2
|
||||||
}
|
}
|
||||||
// generate key
|
// generate key
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue