Do not overide the user provided padding croak instead#168
Conversation
Koan-Bot
left a comment
There was a problem hiding this comment.
Good change — croaking is the right call. Silently overriding user padding to OAEP was a hidden footgun: the code "worked" but didn't do what the user asked. Explicit failure is better.
The crypt_pad variable removal is clean. In the !is_encrypt branch it was a pure copy of p_rsa->padding, and in the is_encrypt branch it was the silent override being removed. Using p_rsa->padding directly simplifies the code.
One issue:
Bug in croak message — the new croak suggests calling use_pkcs1_padding():
croak("Only OAEP padding or no padding is supported for encrypt/decrypt. "
"Call \"use_pkcs1_padding()\" or \"use_no_padding()\" first.");But use_pkcs1_padding() for encryption will immediately hit the Marvin attack croak at line 449:
croak("PKCS#1 v1.5 padding for encryption is vulnerable to the Marvin attack. ...")The message should suggest use_pkcs1_oaep_padding() instead of use_pkcs1_padding():
croak("Only OAEP padding or no padding is supported for encrypt/decrypt. "
"Call \"use_pkcs1_oaep_padding()\" or \"use_no_padding()\" first.");Note: on OpenSSL 3.x this croak is effectively a safety net that can't trigger under normal usage — use_sslv23_padding() is #if'd out on 3.x, and PKCS1/PSS are already caught earlier. But the message should still be correct for anyone reading the code or if a future padding mode is added.
|
@Koan-Bot review again |
PR Review — Do not overide the user provided padding croak insteadThe previous review's blocking issue (incorrect croak message suggesting Checklist
SummaryThe previous review's blocking issue (incorrect croak message suggesting |
@Koan-Bot @Koan-Bot Please review