Skip to content

Lowercase file SHA1s in the SpdxFile verification code path - #458

Merged
goneall merged 1 commit into
spdx:masterfrom
arpitjain099:fix/verification-code-lowercase-sha1
Nov 13, 2026
Merged

goneall merged 1 commit into
spdx:masterfrom
arpitjain099:fix/verification-code-lowercase-sha1

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

generatePackageVerificationCode(SpdxFile[], ...) adds each file's SHA1 to the digest verbatim, while the directory overload in the same class lowercases every checksum it computes. SpdxVerificationHelper.verifyChecksumString accepts A-F, so a document with uppercase checksums gets a code the sibling overload will not reproduce. Clause 7.9 of the 2.3 spec: SHA1(file) "returns the result in lowercase hexadecimal digits".

The test builds the same three files twice, the second time uppercase. It produces 512bdc71 where the spec algorithm gives 06b88323; both agree after the change. getSha1() returns an empty string rather than null, so the added call cannot NPE. Full suite passes, 370 tests.

Please say if you would rather have Locale.ROOT on both call sites.

generatePackageVerificationCode(SpdxFile[], ...) added each file's SHA1 to the digest input verbatim, while the directory overload in the same class lowercases every checksum it computes. verifyChecksumString accepts A-F, so a document carrying uppercase checksums produced a verification code that neither the sibling overload nor spec clause 7.9 reproduces.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>

@goneall goneall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @arpitjain099 - I don't think we need to have Locale.ROOT, so this looks good as is.

@goneall
goneall merged commit d0a6708 into spdx:master Nov 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants