fix: eliminate duplicate NID→name table in get_message_digest()#157
Merged
Merged
Conversation
On OpenSSL 3.x, get_message_digest() duplicated the NID→algorithm-name switch already present in get_md_bynid(). A new hash added to one table but not the other would cause sign/verify to silently diverge. Replace the 3.x switch in get_message_digest() with a call to get_md_bynid() + EVP_Digest(), making get_md_bynid() the single source of truth for NID→algorithm mapping. Pre-3.x path is unchanged. As a side effect, fixes whirlpool on OpenSSL 3.x: the old code fell through to WHIRLPOOL() (deprecated low-level API), now uses the correct EVP_MD_fetch() path via get_md_bynid(). Fixes cpan-authors#153 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
timlegge
approved these changes
Apr 3, 2026
Member
timlegge
left a comment
There was a problem hiding this comment.
THis looks fine and reduces some code repetition
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
On OpenSSL 3.x,
get_message_digest()duplicated theswitch(hash_method)NID→algorithm-name table already present inget_md_bynid(). A new hash algorithm added to one table but missed in the other would causesign()/verify()to silently use different digest algorithms, making every signature fail verification.Fixes #153
Changes
switchinget_message_digest()withget_md_bynid()+EVP_Digest()— one NID→name mapping, one source of truthMD5(),SHA*(), etc.) is unchangedWHIRLPOOL()low-level API; now uses the correctEVP_MD_fetch()path viaget_md_bynid()Test plan
make test)Generated by Kōan /fix
Quality Report
Changes: 1 file changed, 11 insertions(+), 26 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline