tell user codephrase is wrong if PAKE fails

This commit is contained in:
Zack Scholl 2018-11-01 07:26:18 -07:00
parent a56334fc60
commit e0081ea8a8
3 changed files with 20 additions and 11 deletions

View File

@ -98,7 +98,7 @@ func Run() {
// if trying to send but forgot send, let the user know
if c.Args().First() != "" && utils.Exists(c.Args().First()) {
_, fname := filepath.Split(c.Args().First())
yn := utils.GetInput(fmt.Sprintf("Did you mean to send '%s'? (y/n)", fname))
yn := utils.GetInput(fmt.Sprintf("Did you mean to send '%s'? (y/n) ", fname))
if strings.ToLower(yn) == "y" {
return send(c)
}
@ -204,6 +204,9 @@ func send(c *cli.Context) error {
cr.Codephrase,
cr.Codephrase,
)
if cr.Debug {
croc.SetDebugLevel("debug")
}
return cr.Send(fname, cr.Codephrase)
}
@ -226,6 +229,9 @@ func receive(c *cli.Context) error {
if cr.Codephrase == "" {
cr.Codephrase = utils.GetInput("Enter receive code: ")
}
if cr.Debug {
croc.SetDebugLevel("debug")
}
err := cr.Receive(cr.Codephrase)
if err == nil && openFolder {
cwd, _ := os.Getwd()

View File

@ -178,13 +178,13 @@ func (cr *Croc) receive(forceSend int, serverAddress string, tcpPorts []string,
// Q receives u
log.Debugf("[%d] Q computes k, sends H(k), v back to P", step)
if err := Q.Update(message); err != nil {
return err
return fmt.Errorf("Recipient is using wrong code phrase.")
}
// Q has the session key now, but we will still check if its valid
sessionKey, err = Q.SessionKey()
if err != nil {
return err
return fmt.Errorf("Recipient is using wrong code phrase.")
}
log.Debugf("%x\n", sessionKey)
@ -221,7 +221,8 @@ func (cr *Croc) receive(forceSend int, serverAddress string, tcpPorts []string,
log.Debugf("[%d] Q recieves H(k) from P", step)
// check if everything is still kosher with our computed session key
if err := Q.Update(message); err != nil {
return err
log.Debug(err)
return fmt.Errorf("Recipient is using wrong code phrase.")
}
c.WriteMessage(websocket.BinaryMessage, []byte("ready"))
case 3:
@ -289,7 +290,7 @@ func (cr *Croc) receive(forceSend int, serverAddress string, tcpPorts []string,
)
if !noPrompt {
if "y" != utils.GetInput("ok? (y/N): ") {
fmt.Fprintf(os.Stderr, "cancelling request")
fmt.Fprintf(os.Stderr, "Cancelling request")
c.WriteMessage(websocket.BinaryMessage, []byte("no"))
return nil
}
@ -302,7 +303,7 @@ func (cr *Croc) receive(forceSend int, serverAddress string, tcpPorts []string,
if cr.WindowRecipientAccept {
break
} else {
fmt.Fprintf(os.Stderr, "cancelling request")
fmt.Fprintf(os.Stderr, "Cancelling request")
c.WriteMessage(websocket.BinaryMessage, []byte("no"))
return nil
}

View File

@ -219,10 +219,12 @@ func (cr *Croc) send(forceSend int, serverAddress string, tcpPorts []string, isL
case 2:
// P recieves H(k),v from Q
log.Debugf("[%d] P computes k, H(k), sends H(k) to Q", step)
if err := P.Update(message); err != nil {
return err
}
err := P.Update(message)
c.WriteMessage(websocket.BinaryMessage, P.Bytes())
if err != nil {
return fmt.Errorf("Recipient is using wrong code phrase.")
}
sessionKey, _ = P.SessionKey()
// check(err)
log.Debugf("%x\n", sessionKey)
@ -235,7 +237,7 @@ func (cr *Croc) send(forceSend int, serverAddress string, tcpPorts []string, isL
case 3:
log.Debugf("[%d] recipient declares readiness for file info", step)
if !bytes.HasPrefix(message, []byte("ready")) {
return errors.New("recipient refused file")
return errors.New("Recipient refused file")
}
err = <-fileReady // block until file is ready
@ -393,7 +395,7 @@ func (cr *Croc) send(forceSend int, serverAddress string, tcpPorts []string, isL
log.Debugf("[%d] recipient declares readiness for file data", step)
if !bytes.HasPrefix(message, []byte("ready")) {
return errors.New("recipient refused file")
return errors.New("Recipient refused file")
}
cr.StateString = "Transfer in progress..."
fmt.Fprintf(os.Stderr, "\rSending (->%s)...\n", cr.OtherIP)