Skip to content

Commit 68a5533

Browse files
committed
Various fixes
- Fix duplicate entry in locale - Re-generate hash before verification since they are consumed
1 parent 1ecdea6 commit 68a5533

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

models/gpg_key.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,16 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
400400
}
401401
}
402402

403-
//Generating hash of commit
404-
hash, err := populateHash(sig.Hash, []byte(c.Signature.Payload))
405-
if err != nil { //Skipping ailed to generate hash
406-
log.Error(3, "PopulateHash: %v", err)
407-
return &CommitVerification{
408-
Verified: false,
409-
Reason: "gpg.error.generate_hash",
410-
}
411-
}
412-
413403
for _, k := range keys {
404+
//Generating hash of commit
405+
hash, err := populateHash(sig.Hash, []byte(c.Signature.Payload))
406+
if err != nil { //Skipping ailed to generate hash
407+
log.Error(3, "PopulateHash: %v", err)
408+
return &CommitVerification{
409+
Verified: false,
410+
Reason: "gpg.error.generate_hash",
411+
}
412+
}
414413
//We get PK
415414
if err := verifySign(sig, hash, k); err == nil {
416415
return &CommitVerification{ //Everything is ok
@@ -422,6 +421,16 @@ func ParseCommitWithSignature(c *git.Commit) *CommitVerification {
422421
}
423422
//And test also SubsKey
424423
for _, sk := range k.SubsKey {
424+
425+
//Generating hash of commit
426+
hash, err := populateHash(sig.Hash, []byte(c.Signature.Payload))
427+
if err != nil { //Skipping ailed to generate hash
428+
log.Error(3, "PopulateHash: %v", err)
429+
return &CommitVerification{
430+
Verified: false,
431+
Reason: "gpg.error.generate_hash",
432+
}
433+
}
425434
if err := verifySign(sig, hash, sk); err == nil {
426435
return &CommitVerification{ //Everything is ok
427436
Verified: true,

options/locale/locale_en-US.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,6 @@ mark_as_unread = Mark as unread
13731373
error.extract_sign = Failed to extract signature
13741374
error.generate_hash = Failed to generate hash of commit
13751375
error.no_committer_account = No account linked to committer email
1376-
error.no_gpg_keys_found = "Failed to retrieve publics keys of committer"
13771376
error.no_gpg_keys_found = "No known key found for this signature in database"
13781377
error.not_signed_commit = "Not a signed commit"
13791378
error.failed_retrieval_gpg_keys = "Failed to retrieve any key attached to the commiter account"

0 commit comments

Comments
 (0)