Skip to content

Commit

Permalink
Merge branch 'main' into certificate-getter
Browse files Browse the repository at this point in the history
Signed-off-by: Cody Soyland <[email protected]>
  • Loading branch information
codysoyland committed Dec 10, 2024
2 parents 03dba66 + b9aa21c commit 8f86e6e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/bundle/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,8 @@ func TestVerificationContent(t *testing.T) {
return
}
if tt.wantPublicKey {
_, hasPubKey := got.HasPublicKey()
require.True(t, hasPubKey)
k := got.PublicKey()
require.NotNil(t, k)
return
}
})
Expand Down
8 changes: 4 additions & 4 deletions pkg/bundle/verification_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func (c *Certificate) Certificate() *x509.Certificate {
return c.certificate
}

func (c *Certificate) HasPublicKey() (verify.PublicKeyProvider, bool) {
return PublicKey{}, false
func (c *Certificate) PublicKey() verify.PublicKeyProvider {
return nil
}

func (pk *PublicKey) CompareKey(key any, tm root.TrustedMaterial) bool {
Expand Down Expand Up @@ -87,6 +87,6 @@ func (pk *PublicKey) Certificate() *x509.Certificate {
return nil
}

func (pk *PublicKey) HasPublicKey() (verify.PublicKeyProvider, bool) {
return *pk, true
func (pk *PublicKey) PublicKey() verify.PublicKeyProvider {
return pk
}
2 changes: 1 addition & 1 deletion pkg/verify/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type VerificationContent interface {
CompareKey(any, root.TrustedMaterial) bool
ValidAtTime(time.Time, root.TrustedMaterial) bool
Certificate() *x509.Certificate
HasPublicKey() (PublicKeyProvider, bool)
PublicKey() PublicKeyProvider
}

type SignatureContent interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/verify/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func getSignatureVerifier(verificationContent VerificationContent, tm root.Trust
if leafCert := verificationContent.Certificate(); leafCert != nil {
// TODO: Inspect certificate's SignatureAlgorithm to determine hash function
return signature.LoadVerifier(leafCert.PublicKey, crypto.SHA256)
} else if pk, ok := verificationContent.HasPublicKey(); ok {
} else if pk := verificationContent.PublicKey(); pk != nil {
return tm.PublicKeyVerifier(pk.Hint())
}

Expand Down

0 comments on commit 8f86e6e

Please sign in to comment.