refactor: extract setup_pss_sign_ctx() to deduplicate sign/verify PSS setup#158
Merged
atoomic merged 1 commit intocpan-authors:mainfrom Apr 3, 2026
Merged
Conversation
… setup The PSS context-setup logic (padding auto-promote, signature digest, MGF1 hash, salt length) was copy-pasted verbatim in both sign() and verify(). Any future change — e.g. configurable salt length — had to be applied in two places or the two operations would silently diverge. Extract a static helper setup_pss_sign_ctx() that encapsulates the shared logic. Both sign() and verify() now call it via THROW(), keeping the same error-path semantics. Remove the now-unused sign_pad and verify_pad local variables. Fixes cpan-authors#154 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
The PSS context-setup logic (padding auto-promote to PSS, signature digest, MGF1 hash, salt length) was copied verbatim into both
sign()andverify()on OpenSSL 3.x. Any future change — e.g. configurable salt length — had to be applied in two places or the two operations could silently diverge, risking sign/verify mismatches.Fixes #154
Changes
static int setup_pss_sign_ctx(EVP_PKEY_CTX *ctx, int padding, int hash_nid, EVP_MD **md_out)inside the#if >= 0x30000000Lblock, encapsulating the shared PSS/PKCS1 context-setup logicsign()with a singleTHROW(setup_pss_sign_ctx(...))callverify()with a singleTHROW(setup_pss_sign_ctx(...))callsign_padandverify_padlocal variablesTest plan
make test)sign_verify.tandpss_auto_promote.texercise the PSS code paths through the new helperGenerated by Kōan /fix
Quality Report
Changes: 1 file changed, 38 insertions(+), 29 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline