Skip to content

Commit

Permalink
p2p: return err on signChallenge (#4795)
Browse files Browse the repository at this point in the history
* remove panic & todo in secret_connection
  • Loading branch information
tac0turtle committed May 5, 2020
1 parent 9f50006 commit d37b8da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
- cleveldb: use cleveldb as db backend instead of goleveldb.
- race: pass -race to go build and enable data race detection.
- [state] [\#4781](https://github.com/tendermint/tendermint/pull/4781) Export `InitStateVersion` for the initial state version (@erikgrinaker)
- [p2p/conn] \#4795 Return err on `signChallenge()` instead of panic

### BUG FIXES:

Expand Down
12 changes: 7 additions & 5 deletions p2p/conn/secret_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ func MakeSecretConnection(conn io.ReadWriteCloser, locPrivKey crypto.PrivKey) (*
}

// Sign the challenge bytes for authentication.
locSignature := signChallenge(&challenge, locPrivKey)
locSignature, err := signChallenge(&challenge, locPrivKey)
if err != nil {
return nil, err
}

// Share (in secret) each other's pubkey & challenge signature
authSigMsg, err := shareAuthSignature(sc, locPubKey, locSignature)
Expand Down Expand Up @@ -377,13 +380,12 @@ func sort32(foo, bar *[32]byte) (lo, hi *[32]byte) {
return
}

func signChallenge(challenge *[32]byte, locPrivKey crypto.PrivKey) (signature []byte) {
func signChallenge(challenge *[32]byte, locPrivKey crypto.PrivKey) ([]byte, error) {
signature, err := locPrivKey.Sign(challenge[:])
// TODO(ismail): let signChallenge return an error instead
if err != nil {
panic(err)
return nil, err
}
return
return signature, nil
}

type authSigMessage struct {
Expand Down

0 comments on commit d37b8da

Please sign in to comment.