Skip to content

Implement: rsa_crypt no longer needs public/private arguement#166

Closed
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/implement-165
Closed

Implement: rsa_crypt no longer needs public/private arguement#166
Koan-Bot wants to merge 1 commit intocpan-authors:mainfrom
atoomic:koan.atoomic/implement-165

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Apr 6, 2026

Summary

Implements #165

  • fix: extract check_max_message_length() and use get_digest_length()

Closes #165


Generated by Kōan /implement


Quality Report

Changes: 5 files changed, 71 insertions(+), 43 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Extract plaintext length validation from rsa_crypt() into a dedicated
static check_max_message_length() function. Call it only from encrypt()
and private_encrypt() — not from decrypt/public_decrypt where the input
is already-sized ciphertext.

Use get_digest_length(p_rsa->hashMode) for OAEP max-length formula
(RFC 8017 §7.1.1: mLen ≤ k − 2·hLen − 2) instead of the hardcoded 42
that assumed SHA-1. Works on all OpenSSL versions without allocation.

Remove the now-redundant `public` parameter from rsa_crypt(). Use
sv_len() instead of SvCUR() at call sites to ensure the SV is
stringified. Use STRLEN for from_length parameter type.

Update tests to compute OAEP overhead from actual hash size.

Co-Authored-By: Claude <noreply@anthropic.com>
@timlegge
Copy link
Copy Markdown
Member

timlegge commented Apr 6, 2026

Closing #165 implements

@timlegge timlegge closed this Apr 6, 2026
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