Harden OpenSSL crypto error checking and resource management#7817
Conversation
…CK1 macro Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/50322bc9-cbe7-4e3d-ac98-08b1e2a4097e Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com>
…a_public_key.cpp Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/6fad0029-75d6-4e92-a595-807024dc64d3 Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com>
|
@copilot based on the last commit I've done, update the PR title and description if needed Also make them as concise as possible w/o losing any useful info |
Updated the PR description to cover all four changes including the |
achamayou
left a comment
There was a problem hiding this comment.
Goes in the right direction but please see and fix comment.
Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/3a2bc942-163a-454f-bd12-a7cd8d2060bb Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com>
…GELOG entry for CHECK0 removal Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/4d6d118d-4cf4-46fb-93c6-3fd4806cf748 Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com>
Updated the PR description to include the latest changes: |
…sa_pss_saltlen Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/0f3e27d5-e85b-427c-9bc6-94634e2acbbb Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com>
Harden OpenSSL error checking and resource management in
ccf::crypto:CHECK1(openssl_wrappers.h): Threw only when error queue was non-empty. Now throws unconditionally onrc != 1; error message includesrc,ec, and best-effort error string.CHECK0removed: Ambiguous semantics replaced byCHECKPOSITIVE(). Removal noted in CHANGELOG (Harden OpenSSL crypto error checking and resource management #7817).CHECKPOSITIVE(new): For OpenSSL APIs returning positive-on-success. IncludesERR_get_error()/error_string()andrc/ecin diagnostics.RSA OAEP params (
rsa_key_pair.cpp,rsa_public_key.cpp):EVP_PKEY_CTX_set_rsa_padding,_set_rsa_oaep_md,_set_rsa_mgf1_mdreturn values were unchecked. Wrapped withCHECKPOSITIVE().HKDF context leak (
hash.cpp): RawEVP_PKEY_CTX*leaked on throw. Replaced withUnique_EVP_PKEY_CTXRAII wrapper.Wrong check macro (
ec_key_pair.cpp):X509_REQ_signreturns signature size (positive) on success, 0 on failure — corrected fromCHECK1toCHECKPOSITIVE.salt_length overflow (
rsa_key_pair.cpp,rsa_public_key.cpp):size_t salt_lengthwas passed directly toEVP_PKEY_CTX_set_rsa_pss_saltlen(int)without range checking. Added validation throwingstd::invalid_argumentifsalt_length > INT_MAX.OpenSSL doc links for
CHECK1→CHECKPOSITIVEreplacements: