Replace SHA-1 with SHA-256 for X.509 SubjectKeyIdentifier computation - #21
Merged
Merged
Conversation
Ports cloudfoundry/config-server#41 to this repo, since config-server was archived and its code inlined here. Implements RFC 7093 Method 4: hashes the full DER-encoded SubjectPublicKeyInfo instead of just the RSA modulus, replacing the deprecated SHA-1-based bigIntHash.
beyhan
requested review from
a team,
Ivaylogi98 and
benjaminguttmann-avtq
and removed request for
a team
July 30, 2026 14:56
aramprice
self-requested a review
August 6, 2026 15:11
Member
|
GitHub workers are currently having issues, which is causing the PR checks to timeout: |
aramprice
approved these changes
Aug 6, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
crypto/sha1import andbigIntHash(*big.Int)method, which hashed only the RSA key modulus (privateKey.N) using SHA-1.computeSubjectKeyId(*rsa.PublicKey)implementing RFC 7093 Method 4: SHA-256 of the full DER-encodedSubjectPublicKeyInfostructure viax509.MarshalPKIXPublicKey.Why this matters
SHA-1 is deprecated by NIST SP 800-131A Rev 2 and is explicitly disallowed under FIPS 140-2/3 compliance requirements. Any deployment of config-server in a FIPS-enforcing environment (e.g. US Government, regulated industries) will fail cert generation at runtime with the current implementation.
What changed and why
privateKey.N(modulus only)SubjectPublicKeyInfoDERThe previous implementation was doubly incorrect: beyond using SHA-1, it only hashed the RSA modulus
N, omitting the public exponentEand the algorithm identifier. Two keys with the same modulus but different exponents could produce the same SubjectKeyId. The new implementation hashes the completeSubjectPublicKeyInfoas defined in RFC 5280 / RFC 7093.Impact on existing deployments
SubjectKeyIdfield, so it correctly reflects the CA's original 20-byte value. RFC 5280 does not require AKI and SKI to be the same size.Test plan
go build ./types/...compiles cleanlygo test ./types/...54/54 specs passSubjectKeyIdis non-nil on generated certsSubjectKeyId == AuthorityKeyIdAuthorityKeyId == signingCA.SubjectKeyIdReferences