Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update hashTag functions to use PrepareVerify #210

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions openpgp/packet/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,11 @@
// VerifyKeyHashTag returns nil iff sig appears to be a plausible signature over this
// primary key and subkey, based solely on its HashTag.
func (pk *PublicKey) VerifyKeyHashTag(signed *PublicKey, sig *Signature) error {
h, err := keySignatureHash(pk, signed, sig.Hash)
preparedHash, err := sig.PrepareVerify()

Check failure on line 852 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v2-api

cannot use sig.Hash (variable of type crypto.Hash) as hash.Hash value in argument to keySignatureHash: crypto.Hash does not implement hash.Hash (missing method BlockSize)

Check failure on line 852 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v1-api

cannot use sig.Hash (variable of type crypto.Hash) as hash.Hash value in argument to keySignatureHash: crypto.Hash does not implement hash.Hash (missing method BlockSize)
if err != nil {
return err
}
h, err := keySignatureHash(pk, signed, preparedHash)
if err != nil {
return err
}
Expand Down Expand Up @@ -898,15 +902,19 @@
func keyRevocationHash(pk signingKey, hashFunc hash.Hash) (err error) {
return pk.SerializeForHash(hashFunc)
}

Check failure on line 905 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v2-api

assignment mismatch: 2 variables but keyRevocationHash returns 1 value

Check failure on line 905 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v2-api

cannot use sig.Hash (variable of type crypto.Hash) as hash.Hash value in argument to keyRevocationHash: crypto.Hash does not implement hash.Hash (missing method BlockSize)

Check failure on line 905 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v1-api

assignment mismatch: 2 variables but keyRevocationHash returns 1 value

Check failure on line 905 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v1-api

cannot use sig.Hash (variable of type crypto.Hash) as hash.Hash value in argument to keyRevocationHash: crypto.Hash does not implement hash.Hash (missing method BlockSize)
// VerifyRevocationHashTag returns nil iff sig appears to be a plausible signature
// over this public key, based solely on its HashTag.
func (pk *PublicKey) VerifyRevocationHashTag(sig *Signature) (err error) {
h, err := keyRevocationHash(pk, sig.Hash)
preparedHash, err := sig.PrepareVerify()
if err != nil {
return err
}
return VerifyHashTag(h, sig)
err = keyRevocationHash(pk, preparedHash)
if err != nil {
return err
}
return VerifyHashTag(preparedHash, sig)
}

// VerifyRevocationSignature returns nil iff sig is a valid signature, made by this
Expand Down Expand Up @@ -960,7 +968,7 @@
return nil
}

// directKeySignatureHash returns a Hash of the message that needs to be signed.

Check failure on line 971 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v2-api

assignment mismatch: 2 variables but userIdSignatureHash returns 1 value

Check failure on line 971 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v2-api

cannot use sig.Hash (variable of type crypto.Hash) as hash.Hash value in argument to userIdSignatureHash: crypto.Hash does not implement hash.Hash (missing method BlockSize)

Check failure on line 971 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v1-api

assignment mismatch: 2 variables but userIdSignatureHash returns 1 value

Check failure on line 971 in openpgp/packet/public_key.go

View workflow job for this annotation

GitHub Actions / Build gosop from main v1-api

cannot use sig.Hash (variable of type crypto.Hash) as hash.Hash value in argument to userIdSignatureHash: crypto.Hash does not implement hash.Hash (missing method BlockSize)
func directKeySignatureHash(pk *PublicKey, h hash.Hash) (err error) {
return pk.SerializeForHash(h)
}
Expand All @@ -968,11 +976,15 @@
// VerifyUserIdHashTag returns nil iff sig appears to be a plausible signature over this
// public key and UserId, based solely on its HashTag
func (pk *PublicKey) VerifyUserIdHashTag(id string, sig *Signature) (err error) {
h, err := userIdSignatureHash(id, pk, sig.Hash)
preparedHash, err := sig.PrepareVerify()
if err != nil {
return err
}
return VerifyHashTag(h, sig)
err = userIdSignatureHash(id, pk, preparedHash)
if err != nil {
return err
}
return VerifyHashTag(preparedHash, sig)
}

// VerifyUserIdSignature returns nil iff sig is a valid signature, made by this
Expand Down
Loading