Skip to content

ocsp: bind responder authorization to CertID issuerKeyHash#10303

Open
julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
julek-wolfssl:zd/21675
Open

ocsp: bind responder authorization to CertID issuerKeyHash#10303
julek-wolfssl wants to merge 1 commit intowolfSSL:masterfrom
julek-wolfssl:zd/21675

Conversation

@julek-wolfssl
Copy link
Copy Markdown
Member

Addresses ZD21675

Copilot AI review requested due to automatic review settings April 24, 2026 17:38
@julek-wolfssl julek-wolfssl self-assigned this Apr 24, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR tightens OCSP responder authorization by binding delegated responder checks to the OCSP CertID issuerKeyHash (in addition to issuerNameHash), addressing ZD21675.

Changes:

  • Store issuer key hash on Signer and propagate it from parsed certificates.
  • Extend CheckOcspResponder (and chain-check helper) to require issuerKeyHash matches for delegated responders.
  • Adjust OCSP verification call sites to pass the extra key-hash context.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
wolfssl/wolfcrypt/asn.h Adds issuerKeyHash to Signer for OCSP authorization binding.
wolfssl/ocsp.h Updates CheckOcspResponder signature to include subject/issuer key hashes.
wolfcrypt/src/asn.c Populates issuerKeyHash and updates OCSP responder checks to pass new params.
src/ocsp.c Enforces name+key matching (CertID halves) for delegated OCSP responders and chain building.
Comments suppressed due to low confidence (1)

wolfcrypt/src/asn.c:1

  • OcspRespCheck() currently passes responder->subjectKeyHash as the first argument to CheckOcspResponder, but that parameter is compared against single->issuerHash (the CertID issuer name hash). This makes the issuer check compare a key-hash to a name-hash and will incorrectly fail/behave. Pass responder->subjectNameHash as subjectHash and responder->subjectKeyHash as subjectKeyHash.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ocsp.c
if (XMEMCMP(parent->subjectNameHash, issuerHash,
OCSP_DIGEST_SIZE) == 0 &&
XMEMCMP(parent->subjectKeyHash, issuerKeyHash,
OCSP_DIGEST_SIZE) == 0) {
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

Key-hash comparisons are using OCSP_DIGEST_SIZE, but subjectKeyHash/issuerKeyHash are key identifier hashes (typically KEYID_SIZE). If OCSP_DIGEST_SIZE differs from KEYID_SIZE (e.g., non-SHA1 OCSP digests), this will compare the wrong number of bytes and can cause false accept/reject. Use KEYID_SIZE (or sizeof(parent->subjectKeyHash) / sizeof(single->issuerKeyHash)) for key-hash comparisons.

Suggested change
OCSP_DIGEST_SIZE) == 0) {
sizeof(parent->subjectKeyHash)) == 0) {

Copilot uses AI. Check for mistakes.
Comment thread src/ocsp.c
Comment on lines +681 to +685
if (subjectKeyHash != NULL &&
XMEMCMP(subjectHash, single->issuerHash,
OCSP_DIGEST_SIZE) == 0 &&
XMEMCMP(subjectKeyHash, single->issuerKeyHash,
OCSP_DIGEST_SIZE) == 0) {
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

Same issue as above: single->issuerKeyHash is a key hash, but it's compared with OCSP_DIGEST_SIZE. This should use KEYID_SIZE (or sizeof(single->issuerKeyHash)) to avoid mismatched lengths when OCSP digest size differs from keyid size.

Copilot uses AI. Check for mistakes.
Comment thread wolfssl/ocsp.h
Comment on lines 77 to +79
WOLFSSL_LOCAL int CheckOcspResponder(OcspResponse *bs, byte* subjectHash,
byte extExtKeyUsage, byte* issuerHash, void* vp);
byte* subjectKeyHash, byte extExtKeyUsage, byte* issuerHash,
byte* issuerKeyHash, void* vp);
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

With the new logic, subjectHash is used as the responder certificate subject name hash (compared to CertID issuerNameHash), while subjectKeyHash is the responder's subject key hash. Renaming subjectHash/issuerHash to subjectNameHash/issuerNameHash (and similarly for key hashes) would reduce the risk of call-site mixups like the one in OcspRespCheck().

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Copy link
Copy Markdown
Contributor

@rizlik rizlik left a comment

Choose a reason for hiding this comment

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

need testing

Comment thread wolfssl/wolfcrypt/asn.h
#endif
#ifdef HAVE_OCSP
byte subjectKeyHash[KEYID_SIZE];
byte issuerKeyHash[KEYID_SIZE]; /* key hash of verifying parent CA */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this the issuer of the cert we are verifying? is this the root CA of the chain whose leaf certificate we are verifying?

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.

3 participants