Skip to content

Commit

Permalink
fix panic due to using wrong decrypt method
Browse files Browse the repository at this point in the history
This fix is to avoid crashing when trying to decrypt a cipher text
with the wrong version
  • Loading branch information
muhamadazmy committed Nov 18, 2020
1 parent 34cd098 commit d8cb7e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/crypto/encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func Decrypt(msg []byte, sk ed25519.PrivateKey) ([]byte, error) {
curvePriv := PrivateKeyToCurve25519(sk)
curvePub := PublicKeyToCurve25519(sk.Public().(ed25519.PublicKey))

if len(msg) < 48 {
return nil, fmt.Errorf("invalid cipher text too short")
}

return box.Open(msg, &curvePub, &curvePriv)
}

Expand Down

0 comments on commit d8cb7e3

Please sign in to comment.