Skip to content

Commit

Permalink
Merge pull request #24 from djgilcrease/bugfix/digest-not-ok
Browse files Browse the repository at this point in the history
Add the payload digest
  • Loading branch information
jarondl authored Oct 4, 2019
2 parents e413234 + bbcbbc8 commit 07246cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example_bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ container_image(
docker_diff(
name = "fedora_V",
base = ":fedora_with_rpm",
cmd = "echo ===marker=== && rpm --nodigest -i /root/rpmtest.rpm && rpm -Vv rpmtest",
cmd = "echo ===marker=== && rpm -i /root/rpmtest.rpm && rpm -Vv rpmtest",
golden = ":golden_V.txt",
)
5 changes: 3 additions & 2 deletions rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ func (r *RPM) writeGenIndexes(h *index) {
h.Add(tagLicence, entry(r.Licence))
h.Add(tagPackager, entry(r.Packager))
h.Add(tagURL, entry(r.URL))
h.Add(tagPayloadDigest, entry([]string{fmt.Sprintf("%x", sha256.Sum256(r.payload.Bytes()))}))
h.Add(tagPayloadDigestAlgo, entry([]int32{hashAlgoSHA256}))

// rpm utilities look for the sourcerpm tag to deduce if this is not a source rpm (if it has a sourcerpm,
// it is NOT a source rpm).
Expand Down Expand Up @@ -297,8 +299,7 @@ func (r *RPM) writeFileIndexes(h *index) {
for ii := range inodes {
// is inodes just a range from 1..len(dirindexes)? maybe different with hard links
inodes[ii] = int32(ii + 1)
// We only use the sha256 digest algo, tag=8
digestAlgo[ii] = int32(8)
digestAlgo[ii] = hashAlgoSHA256
// With regular files, it seems like we can always enable all of the verify flags
verifyFlags[ii] = int32(-1)
fileRDevs[ii] = int16(1)
Expand Down
5 changes: 5 additions & 0 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const (
sigSize = 0x03e8 // 1000
sigPayloadSize = 0x03ef // 1007

// https://github.com/rpm-software-management/rpm/blob/92eadae94c48928bca90693ad63c46ceda37d81f/rpmio/rpmpgp.h#L258
hashAlgoSHA256 = 0x0008 // 8

tagName = 0x03e8 // 1000
tagVersion = 0x03e9 // 1001
tagRelease = 0x03ea // 1002
Expand Down Expand Up @@ -81,4 +84,6 @@ const (
tagSuggests = 0x13b9 // 5049
tagSuggestVersion = 0x13ba // 5050
tagSuggestFlags = 0x13bb // 5051
tagPayloadDigest = 0x13e4 // 5092
tagPayloadDigestAlgo = 0x13e5 // 5093
)

0 comments on commit 07246cf

Please sign in to comment.