Skip to content

Commit

Permalink
Add assertion on errors of key parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Asra Ali <asraa@google.com>
  • Loading branch information
asraa committed Sep 2, 2022
1 parent c20e18a commit 25dbbe4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/keys/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ type EcdsaVerifier struct {

func (p *EcdsaVerifier) Public() string {
// This is already verified to succeed when unmarshalling a public key.
r, _ := x509.MarshalPKIXPublicKey(p.ecdsaKey)
r, err := x509.MarshalPKIXPublicKey(p.ecdsaKey)
if err != nil {
// TODO: Gracefully handle these errors.
// See https://github.com/theupdateframework/go-tuf/issues/363
panic(err)
}
return string(r)
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/keys/rsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ type rsaVerifier struct {

func (p *rsaVerifier) Public() string {
// This is already verified to succeed when unmarshalling a public key.
r, _ := x509.MarshalPKIXPublicKey(p.rsaKey)
r, err := x509.MarshalPKIXPublicKey(p.rsaKey)
if err != nil {
// TODO: Gracefully handle these errors.
// See https://github.com/theupdateframework/go-tuf/issues/363
panic(err)
}
return string(r)
}

Expand Down

0 comments on commit 25dbbe4

Please sign in to comment.