fix: private_encrypt/public_decrypt broken on OpenSSL 3.x#118
Conversation
|
view errors from smokers @toddr-bot rebase |
timlegge
left a comment
There was a problem hiding this comment.
Assigning to myself . I need to look at this closer
2b34b88 to
df8d955
Compare
Rebase: fix: private_encrypt/public_decrypt broken on OpenSSL 3.xBranch Diff: 4 files changed, 135 insertions(+), 18 deletions(-) Review feedback was analyzed and applied. Actions
CICI passed. Automated by Kōan |
|
@toddr-bot rebase |
- **Moved PSS-for-encrypt guard before `#if OPENSSL_VERSION_NUMBER >= 0x30000000L`** so it fires on all OpenSSL versions, not just 3.x. On pre-3.x smokers, `encrypt()` with PSS was falling through to the legacy RSA code path which produced a generic "unknown padding type" error instead of the friendly croak message. This matches how the Marvin attack (PKCS#1 v1.5) guard is already placed before the ifdef. - **Simplified test 9 in `t/private_encrypt.t`** to use `like()` unconditionally instead of branching on OpenSSL version, since the PSS croak now fires on all versions.
df8d955 to
4fa560a
Compare
Rebase: fix: private_encrypt/public_decrypt broken on OpenSSL 3.xBranch Diff: 4 files changed, 127 insertions(+), 16 deletions(-) Review feedback was analyzed and applied. Changes
Actions
CICI passed. Automated by Kōan |
|
@toddr-bot rebase this |
- **Moved PSS-for-encrypt guard before `#if OPENSSL_VERSION_NUMBER >= 0x30000000L`** so it fires on all OpenSSL versions, not just 3.x. On pre-3.x smokers, `encrypt()` with PSS was falling through to the legacy RSA code path which produced a generic "unknown padding type" error instead of the friendly croak message. This matches how the Marvin attack (PKCS#1 v1.5) guard is already placed before the ifdef. - **Simplified test 9 in `t/private_encrypt.t`** to use `like()` unconditionally instead of branching on OpenSSL version, since the PSS croak now fires on all versions.
4fa560a to
642c7d5
Compare
Rebase: fix: private_encrypt/public_decrypt broken on OpenSSL 3.xBranch Diff: 4 files changed, 127 insertions(+), 16 deletions(-) Review feedback was analyzed and applied. Actions
CICI passed. Automated by Kōan |
|
@toddr-bot rebase from main |
On OpenSSL 3.x, rsa_crypt() is shared by encrypt/decrypt (which use EVP_PKEY_encrypt/decrypt) and private_encrypt/public_decrypt (which use EVP_PKEY_sign/verify_recover). The code unconditionally forced OAEP padding for all non-NO_PADDING modes, but OAEP is only valid for encryption — not for sign/verify_recover operations. This meant private_encrypt() and public_decrypt() were broken with any padding except NO_PADDING. The fix replaces the unused `int public` parameter with `int is_encrypt` to distinguish the two operation types: - Encryption path (encrypt/decrypt): forces OAEP, rejects PSS - Sign path (private_encrypt/public_decrypt): passes through PKCS1 and NO_PADDING; rejects OAEP and PSS with clear error messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- **Moved PSS-for-encrypt guard before `#if OPENSSL_VERSION_NUMBER >= 0x30000000L`** so it fires on all OpenSSL versions, not just 3.x. On pre-3.x smokers, `encrypt()` with PSS was falling through to the legacy RSA code path which produced a generic "unknown padding type" error instead of the friendly croak message. This matches how the Marvin attack (PKCS#1 v1.5) guard is already placed before the ifdef. - **Simplified test 9 in `t/private_encrypt.t`** to use `like()` unconditionally instead of branching on OpenSSL version, since the PSS croak now fires on all versions.
Rebase: fix: private_encrypt/public_decrypt broken on OpenSSL 3.xBranch Diff: 4 files changed, 122 insertions(+), 11 deletions(-) Review feedback was analyzed and applied. Actions
CICI will be checked asynchronously. Automated by Kōan |
642c7d5 to
141a216
Compare
What
Fixes
private_encrypt()andpublic_decrypt()being broken on OpenSSL 3.x with any padding exceptNO_PADDING.Why
rsa_crypt()is shared by four operations:encrypt,decrypt,private_encrypt, andpublic_decrypt. On OpenSSL 3.x, it unconditionally forced OAEP padding for all non-NO_PADDINGmodes. Butprivate_encrypt/public_decryptuseEVP_PKEY_sign/EVP_PKEY_verify_recoverunder the hood, where OAEP is not a valid padding mode. This caused an OpenSSL error ("illegal or unsupported padding mode") for any call toprivate_encrypt()orpublic_decrypt()with the default padding.This is the same family of issues as #61 — the v0.35 Marvin attack mitigation broke signature-related operations. This fix complements #103 (which fixes
sign()/verify()).How
Replaced the unused
int publicparameter inrsa_crypt()withint is_encryptto distinguish encryption from sign/verify_recover operations:encrypt/decrypt): forces OAEP, rejects PSS (existing behavior)private_encrypt/public_decrypt): passes through the user's padding choice; rejects OAEP and PSS with clear error messages pointing to the correct APITesting
t/private_encrypt.t)private_encrypt/public_decryptroundtrip withNO_PADDINGencrypt/decryptbehavior unchanged🤖 Generated with Claude Code
Quality Report
Changes: 4 files changed, 131 insertions(+), 15 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline