Repository navigation
Conversation
8572032 to
02083fd
Compare
|
3857c52 to
1ead3c0
Compare
|
Jenkins: retest this please |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11363
Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 5
5 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
84bb3a3 to
ea54e15
Compare
|
Jenkins: retest this please |
270c3da to
e08d01c
Compare
|
Jenkins: retest this please |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11363
Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
e08d01c to
7b7b697
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11363
Scan targets checked: wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src, wolfssl-bugs, wolfssl-src
Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
3b762b0 to
89239e9
Compare
89239e9 to
c55e940
Compare
074caaf to
f3c2741
Compare
julek-wolfssl
left a comment
There was a problem hiding this comment.
Please address reviews in new commits instead of amending existing ones.
| #if defined(WOLFSSL_EVP_AES_KEYWRAP) | ||
| /* Wrap or unwrap a key with AES-KW (RFC 3394). | ||
| * | ||
| * Not a streaming operation - hence no Update in the name: the whole key must |
There was a problem hiding this comment.
| * Not a streaming operation - hence no Update in the name: the whole key must | |
| * One-shot helper function: the whole key must |
| int wolfSSL_EVP_PKEY_get_raw_private_key(const WOLFSSL_EVP_PKEY* pkey, | ||
| unsigned char* priv, size_t* len) | ||
| { | ||
| #ifdef WOLFSSL_EVP_HAVE_RAW_KEYS | ||
| int ret = 0; | ||
| byte buf[128]; | ||
| word32 bufLen = (word32)sizeof(buf); | ||
| #endif | ||
|
|
||
| WOLFSSL_ENTER("wolfSSL_EVP_PKEY_get_raw_private_key"); | ||
|
|
||
| if (pkey == NULL || len == NULL) { | ||
| return 0; | ||
| } | ||
|
|
||
| #ifndef WOLFSSL_EVP_HAVE_RAW_KEYS | ||
| (void)priv; | ||
| WOLFSSL_MSG("build has no key type with a raw form"); | ||
| return 0; | ||
| #else | ||
|
|
||
| switch (pkey->type) { | ||
| #if defined(HAVE_ED25519) && defined(HAVE_ED25519_KEY_EXPORT) | ||
| case WC_EVP_PKEY_ED25519: | ||
| if (pkey->ed25519 == NULL) { | ||
| break; | ||
| } | ||
| /* Checked here rather than left to the export below: the | ||
| * released FIPS modules copy the private key buffer without | ||
| * checking that it holds a key, and so would answer with zeros | ||
| * for a key built from a public key alone. */ | ||
| if (!pkey->ed25519->privKeySet) { | ||
| WOLFSSL_MSG("ed25519 key has no private key to report"); | ||
| break; | ||
| } | ||
| if (wc_ed25519_export_private_only(pkey->ed25519, buf, &bufLen) | ||
| != 0) { | ||
| WOLFSSL_MSG("wc_ed25519_export_private_only failed"); | ||
| break; | ||
| } | ||
| if (wolfssl_evp_pkey_raw_cached(pkey)) { | ||
| ret = wolfssl_evp_pkey_raw_out((const byte*)pkey->pkey.ptr, | ||
| (word32)pkey->pkey_sz, priv, len); | ||
| } | ||
| else { | ||
| ret = wolfssl_evp_pkey_raw_out(buf, bufLen, priv, len); | ||
| } | ||
| break; | ||
| #endif | ||
| #if defined(HAVE_ED448) && defined(HAVE_ED448_KEY_EXPORT) | ||
| case WC_EVP_PKEY_ED448: | ||
| if (pkey->ed448 == NULL) { | ||
| break; | ||
| } | ||
| /* As for Ed25519 above: the released FIPS modules do not check | ||
| * that the key has a private part before copying it out. */ | ||
| if (!pkey->ed448->privKeySet) { | ||
| WOLFSSL_MSG("ed448 key has no private key to report"); | ||
| break; | ||
| } | ||
| if (wc_ed448_export_private_only(pkey->ed448, buf, &bufLen) != 0) { | ||
| WOLFSSL_MSG("wc_ed448_export_private_only failed"); | ||
| break; | ||
| } | ||
| if (wolfssl_evp_pkey_raw_cached(pkey)) { | ||
| ret = wolfssl_evp_pkey_raw_out((const byte*)pkey->pkey.ptr, | ||
| (word32)pkey->pkey_sz, priv, len); | ||
| } | ||
| else { | ||
| ret = wolfssl_evp_pkey_raw_out(buf, bufLen, priv, len); | ||
| } | ||
| break; | ||
| #endif | ||
| #if defined(HAVE_CURVE25519) && defined(HAVE_CURVE25519_KEY_EXPORT) | ||
| case WC_EVP_PKEY_X25519: | ||
| if (pkey->curve25519 == NULL) { | ||
| break; | ||
| } | ||
| /* Raw X25519 keys are little-endian (RFC 7748). */ | ||
| if (wc_curve25519_export_private_raw_ex(pkey->curve25519, buf, | ||
| &bufLen, EC25519_LITTLE_ENDIAN) != 0) { | ||
| WOLFSSL_MSG("wc_curve25519_export_private_raw_ex failed"); | ||
| break; | ||
| } | ||
| if (wolfssl_evp_pkey_raw_cached(pkey)) { | ||
| ret = wolfssl_evp_pkey_raw_out((const byte*)pkey->pkey.ptr, | ||
| (word32)pkey->pkey_sz, priv, len); | ||
| } | ||
| else { | ||
| #ifdef HAVE_CURVE25519_KEY_IMPORT | ||
| /* The export above clamped the scalar; prefer the bytes the key | ||
| * was decoded from, which is what OpenSSL reports. */ | ||
| (void)wolfssl_evp_pkey_orig_scalar(pkey, X25519k, buf, bufLen); | ||
| #endif | ||
| ret = wolfssl_evp_pkey_raw_out(buf, bufLen, priv, len); | ||
| } | ||
| break; | ||
| #endif | ||
| #if defined(HAVE_CURVE448) && defined(HAVE_CURVE448_KEY_EXPORT) | ||
| case WC_EVP_PKEY_X448: | ||
| if (pkey->curve448 == NULL) { | ||
| break; | ||
| } | ||
| if (wc_curve448_export_private_raw_ex(pkey->curve448, buf, &bufLen, | ||
| EC448_LITTLE_ENDIAN) != 0) { | ||
| WOLFSSL_MSG("wc_curve448_export_private_raw_ex failed"); | ||
| break; | ||
| } | ||
| if (wolfssl_evp_pkey_raw_cached(pkey)) { | ||
| ret = wolfssl_evp_pkey_raw_out((const byte*)pkey->pkey.ptr, | ||
| (word32)pkey->pkey_sz, priv, len); | ||
| } | ||
| else { | ||
| #ifdef HAVE_CURVE448_KEY_IMPORT | ||
| /* The export above clamped the scalar; prefer the bytes the key | ||
| * was decoded from, which is what OpenSSL reports. */ | ||
| (void)wolfssl_evp_pkey_orig_scalar(pkey, X448k, buf, bufLen); | ||
| #endif | ||
| ret = wolfssl_evp_pkey_raw_out(buf, bufLen, priv, len); | ||
| } | ||
| break; | ||
| #endif | ||
| default: | ||
| WOLFSSL_MSG("key type has no raw private form"); | ||
| break; | ||
| } | ||
|
|
||
| ForceZero(buf, sizeof(buf)); | ||
|
|
||
| return ret; | ||
| #endif /* WOLFSSL_EVP_HAVE_RAW_KEYS */ | ||
| } |
There was a problem hiding this comment.
Why do we export to buf when we return the cached version when available?
There was a problem hiding this comment.
Cached check hoisted above the export
| */ | ||
| const char* wolfSSL_X509_get_default_cert_file_env(void) | ||
| { | ||
| WOLFSSL_STUB("X509_get_default_cert_file_env"); | ||
| return ""; | ||
| return "SSL_CERT_FILE"; | ||
| } | ||
|
|
||
| const char* wolfSSL_X509_get_default_cert_file(void) | ||
| /* Get the name of the environment variable that overrides the default CA | ||
| * certificate directory. | ||
| * | ||
| * Returns the same name as OpenSSL's function of this name, and is the | ||
| * variable wolfSSL_CTX_load_system_CA_certs() already reads. | ||
| * | ||
| * @return Environment variable name. | ||
| */ | ||
| const char* wolfSSL_X509_get_default_cert_dir_env(void) | ||
| { | ||
| WOLFSSL_STUB("X509_get_default_cert_file"); | ||
| return ""; | ||
| return "SSL_CERT_DIR"; | ||
| } |
There was a problem hiding this comment.
Should these be defined as macros somewhere instead of repeating the string literal everywhere?
There was a problem hiding this comment.
I don't think that is necessary. No real repetition.
| return 0; | ||
| } | ||
|
|
||
| keyOID = wolfssl_x509_sig_key_type(x->sigOID); |
There was a problem hiding this comment.
Why not use SigOidMatchesKeyOid instead of creating a whole new function just for this check?
There was a problem hiding this comment.
Good call, but it's static in wolfcrypt/src/asn.c:18501, so src/x509.c can't call it without exposing it first. Happy to do that as a follow-up; it's not a drop-in substitution.
| static int wolfssl_x509_self_signed(WOLFSSL_X509* x) | ||
| { | ||
| int keyOID; | ||
|
|
||
| if (wolfSSL_X509_NAME_cmp(&x->issuer, &x->subject) != 0) { | ||
| return 0; | ||
| } | ||
|
|
||
| keyOID = wolfssl_x509_sig_key_type(x->sigOID); | ||
| if (keyOID == 0) { | ||
| /* An algorithm that cannot be mapped cannot be shown to match. */ | ||
| return 0; | ||
| } | ||
| /* An RSA key produces both PKCS #1 v1.5 and PSS signatures. */ | ||
| if ((keyOID == RSAPSSk) && (x->pubKeyOID == RSAk)) { | ||
| return 1; | ||
| } | ||
|
|
||
| return keyOID == x->pubKeyOID; | ||
| } |
There was a problem hiding this comment.
Copy over the value from dCert->selfSigned instead of re-implementing the check here.
There was a problem hiding this comment.
Two obstacles. It's never copied to WOLFSSL_X509, so this needs a new field plus a copy in CopyDecodedToX509(). More importantly the two aren't equivalent: dCert->selfSigned is selfIssued && (src/internal.c:18768), whereas wolfssl_x509_self_signed() only compares issuer/subject and matches the sig algorithm to the key type — it never verifies a signature. Yours is stricter and more correct, but only for certs that went through the verify path; a standalone parsed X509 wouldn't have it set. Worth doing deliberately rather than as a swap.
| int wolfSSL_X509_check_purpose(WOLFSSL_X509* x, int id, int ca) | ||
| { | ||
| byte ekuWanted; | ||
| word16 kuWanted; | ||
| byte nsWanted; | ||
| /* Which of OpenSSL's CA rules this role applies when ca is set. */ | ||
| enum { CA_RULE_SSL, CA_RULE_SMIME, CA_RULE_PLAIN } caRule = CA_RULE_PLAIN; | ||
|
|
||
| WOLFSSL_ENTER("wolfSSL_X509_check_purpose"); | ||
|
|
||
| if (x == NULL) { | ||
| return WOLFSSL_FATAL_ERROR; | ||
| } | ||
|
|
||
| /* -1 asks only that the extensions be readable. wolfSSL parses them when | ||
| * the certificate is decoded, so there is nothing to populate. */ | ||
| if (id == -1) { | ||
| return 1; | ||
| } | ||
|
|
||
| switch (id) { | ||
| case WOLFSSL_X509_PURPOSE_ANY: | ||
| /* Constrains nothing, for a CA as much as for a leaf. */ | ||
| return 1; | ||
| case WOLFSSL_X509_PURPOSE_OCSP_HELPER: | ||
| /* A leaf is left to the OCSP code to check, but a CA still has to | ||
| * be a valid one. */ | ||
| if (!ca) { | ||
| return 1; | ||
| } | ||
| /* OpenSSL returns check_ca()'s own value here, not a boolean. */ | ||
| return wolfssl_x509_check_ca(x); | ||
| case WOLFSSL_X509_PURPOSE_SSL_CLIENT: | ||
| ekuWanted = EXTKEYUSE_CLIENT_AUTH; | ||
| caRule = CA_RULE_SSL; | ||
| kuWanted = KEYUSE_DIGITAL_SIG | KEYUSE_KEY_AGREE; | ||
| nsWanted = WC_NS_SSL_CLIENT; | ||
| break; | ||
| case WOLFSSL_X509_PURPOSE_SSL_SERVER: | ||
| ekuWanted = EXTKEYUSE_SERVER_AUTH; | ||
| caRule = CA_RULE_SSL; | ||
| kuWanted = KEYUSE_DIGITAL_SIG | KEYUSE_KEY_ENCIPHER | | ||
| KEYUSE_KEY_AGREE; | ||
| nsWanted = WC_NS_SSL_SERVER; | ||
| break; | ||
| case WOLFSSL_X509_PURPOSE_NS_SSL_SERVER: | ||
| ekuWanted = EXTKEYUSE_SERVER_AUTH; | ||
| caRule = CA_RULE_SSL; | ||
| kuWanted = KEYUSE_KEY_ENCIPHER; | ||
| nsWanted = WC_NS_SSL_SERVER; | ||
| break; | ||
| case WOLFSSL_X509_PURPOSE_SMIME_SIGN: | ||
| ekuWanted = EXTKEYUSE_EMAILPROT; | ||
| caRule = CA_RULE_SMIME; | ||
| kuWanted = KEYUSE_DIGITAL_SIG | KEYUSE_CONTENT_COMMIT; | ||
| /* WC_NS_SSL_CLIENT is accepted alongside WC_NS_SMIME to match | ||
| * OpenSSL's workaround for certificates that set only the | ||
| * former. */ | ||
| nsWanted = WC_NS_SMIME | WC_NS_SSL_CLIENT; | ||
| break; | ||
| case WOLFSSL_X509_PURPOSE_SMIME_ENCRYPT: | ||
| ekuWanted = EXTKEYUSE_EMAILPROT; | ||
| caRule = CA_RULE_SMIME; | ||
| kuWanted = KEYUSE_KEY_ENCIPHER; | ||
| nsWanted = WC_NS_SMIME | WC_NS_SSL_CLIENT; | ||
| break; | ||
| case WOLFSSL_X509_PURPOSE_CRL_SIGN: | ||
| /* No extendedKeyUsage or netscape type is defined for CRL | ||
| * signing. */ | ||
| ekuWanted = 0; | ||
| kuWanted = KEYUSE_CRL_SIGN; | ||
| nsWanted = 0; | ||
| break; | ||
| case WOLFSSL_X509_PURPOSE_CODE_SIGN: | ||
| /* A CA for code signing is just a CA. */ | ||
| if (ca) { | ||
| return wolfssl_x509_check_ca(x); | ||
| } | ||
| /* CA/Browser Forum baseline requirements, as OpenSSL checks them: | ||
| * keyUsage has to be there, critical, allow digital signatures and | ||
| * allow neither certificate nor CRL signing; extendedKeyUsage has | ||
| * to be there, allow code signing, and allow neither any use nor | ||
| * server authentication. */ | ||
| if ((!x->keyUsageSet) || (!x->keyUsageCrit) || | ||
| ((x->keyUsage & KEYUSE_DIGITAL_SIG) == 0) || | ||
| ((x->keyUsage & | ||
| (KEYUSE_KEY_CERT_SIGN | KEYUSE_CRL_SIGN)) != 0)) { | ||
| WOLFSSL_MSG("Key usage does not allow code signing"); | ||
| return 0; | ||
| } | ||
| if ((x->extKeyUsageSrc == NULL) || | ||
| ((x->extKeyUsage & EXTKEYUSE_CODESIGN) == 0) || | ||
| ((x->extKeyUsage & | ||
| (EXTKEYUSE_ANY | EXTKEYUSE_SERVER_AUTH)) != 0)) { | ||
| WOLFSSL_MSG("Extended key usage does not allow code signing"); | ||
| return 0; | ||
| } | ||
| return 1; | ||
| case WOLFSSL_X509_PURPOSE_TIMESTAMP_SIGN: | ||
| /* A CA for timestamping is just a CA; the leaf rule below cannot | ||
| * be applied, so it is refused there. */ | ||
| if (ca) { | ||
| return wolfssl_x509_check_ca(x); | ||
| } | ||
| /* Needs the extendedKeyUsage to be exactly timeStamping and | ||
| * critical, which is not recorded when a certificate is parsed. */ | ||
| WOLFSSL_MSG("Cannot check timestamp signing on a leaf"); | ||
| return 0; | ||
| default: | ||
| /* A purpose this build does not know. Report "not permitted" | ||
| * rather than an error: OpenSSL answers 0 for these, and callers | ||
| * commonly write "if (X509_check_purpose(...))", where a negative | ||
| * return would read as permission granted. */ | ||
| WOLFSSL_MSG("Unsupported X509 purpose"); | ||
| return 0; | ||
| } | ||
|
|
||
| /* extendedKeyUsage: present and naming none of the accepted uses. This | ||
| * is checked before the CA rules, as OpenSSL does, so a CA whose | ||
| * extendedKeyUsage excludes the role is refused for it. | ||
| * anyExtendedKeyUsage deliberately does not satisfy a specific purpose: | ||
| * OpenSSL's xku_reject() treats it as its own bit and rejects such a | ||
| * certificate, and this is an authorization decision, so match it. */ | ||
| if ((ekuWanted != 0) && (x->extKeyUsageSrc != NULL) && | ||
| ((x->extKeyUsage & ekuWanted) == 0)) { | ||
| WOLFSSL_MSG("Certificate extended key usage does not allow purpose"); | ||
| return 0; | ||
| } | ||
|
|
||
| if (ca) { | ||
| int caRet; | ||
|
|
||
| if (caRule == CA_RULE_SSL) { | ||
| return wolfssl_x509_check_ssl_ca(x) != 0; | ||
| } | ||
| caRet = wolfssl_x509_check_ca(x); | ||
| if (caRet == 0) { | ||
| return 0; | ||
| } | ||
| #ifndef IGNORE_NETSCAPE_CERT_TYPE | ||
| /* A certificate only a netscape type vouched for has to have named | ||
| * the S/MIME CA type specifically. */ | ||
| if ((caRule == CA_RULE_SMIME) && (caRet == 5) && | ||
| ((x->nsCertType & WC_NS_SMIME_CA) == 0)) { | ||
| return 0; | ||
| } | ||
| #endif | ||
| /* Report how the decision was reached, as OpenSSL does: a caller may | ||
| * distinguish a certificate that only a netscape type vouched for | ||
| * from one basicConstraints named. */ | ||
| return caRet; | ||
| } | ||
|
|
||
| /* keyUsage: present and naming none of the accepted uses. */ | ||
| if ((kuWanted != 0) && x->keyUsageSet && | ||
| ((x->keyUsage & kuWanted) == 0)) { | ||
| WOLFSSL_MSG("Certificate key usage does not allow purpose"); | ||
| return 0; | ||
| } | ||
|
|
||
| if ((nsWanted != 0) && !wolfssl_x509_check_ns_cert_type(x, nsWanted)) { | ||
| return 0; | ||
| } | ||
|
|
||
| return 1; | ||
| } |
There was a problem hiding this comment.
A few problems in wolfSSL_X509_check_purpose() and its helpers:
1. An empty extendedKeyUsage is treated as absent (L18120, src/internal.c:16576)
CopyDecodedToX509() copies the EKU only when extExtKeyUsageSz > 0. The purpose check then reads extKeyUsageSrc == NULL as "no EKU". A leaf with extendedKeyUsage = SEQUENCE {} and keyUsage digitalSignature passes SSL_CLIENT, SSL_SERVER and SMIME_SIGN. OpenSSL refuses it, and RFC 5280 4.2.1.12 requires SIZE (1..MAX). With ca=1 the EKU check is skipped too.
Please add an EKU-present flag to WOLFSSL_X509 (from dCert->extExtKeyUsageSet) and test that. Consider also rejecting an empty EKU when decoding.
2. TIMESTAMP_SIGN always returns 0 for a leaf (L18095)
The comment says EKU criticality "is not recorded when a certificate is parsed". It is: extKeyUsageCrit, extKeyUsage and extKeyUsageCount are all filled in. As written, a compliant RFC 3161 TSA cert is refused, where OpenSSL says yes.
Please implement it like OpenSSL's check_purpose_timestamp_sign():
- EKU present and critical, and timeStamping is the only purpose (
extKeyUsageCount == 1matches RFC 3161 2.3 exactly); - keyUsage, if present, has digitalSignature and/or nonRepudiation and nothing else.
3. wolfSSL_X509_check_ca() disagrees with the new wolfssl_x509_check_ca() (L18164)
It returns 1 for any isCa and 4 for any critical EKU. Some results:
CA:FALSEwith a critical serverAuth EKU gives 4.CA:TRUEwith keyUsage digitalSignature only gives 1. It should be 0 (RFC 5280 4.2.1.3).- A v1 self-signed root gives 0. It should be 3.
This code predates the PR, but the correct helper now sits right next to it. Can wolfSSL_X509_check_ca() call wolfssl_x509_check_ca()?
Minor / compat (no change needed, just noting):
- SSL_SERVER does not accept the legacy SGC EKUs (msSGC/nsSGC), which OpenSSL does. This matches RFC 5280, so it's fine, but maybe say so in a comment.
- For certs OpenSSL flags invalid (e.g. empty keyUsage), OpenSSL returns -1 and this returns 0/1.
Tests for 1–3 would help: an empty-EKU leaf, a critical timeStamping-only leaf, and X509_check_ca() on a CA:FALSE leaf with a critical EKU.
There was a problem hiding this comment.
- New extKeyUsageSet flag, plumbed and consumed.
- Implemented the leaf rule; deleted the false comment.
- Confirmed on all three cases, and wolfssl_x509_check_ca() would indeed fix them. But it's pre-existing (no +/- line in this PR touches it) and changing it alters long-standing public-API behaviour, which would make this branch non-additive. Proposing a separate PR for this fix.
Added tests.
| ReadDirCtx* readCtx; | ||
|
|
||
| WOLFSSL_ENTER("wolfSSL_add_dir_cert_subjects_to_stack"); | ||
|
|
||
| if ((list == NULL) || (dir == NULL)) { | ||
| WOLFSSL_MSG("Bad parameter"); | ||
| return 0; | ||
| } | ||
|
|
||
| /* ReadDirCtx holds a full path buffer - keep it off the stack. */ | ||
| readCtx = (ReadDirCtx*)XMALLOC(sizeof(ReadDirCtx), NULL, | ||
| DYNAMIC_TYPE_TMP_BUFFER); | ||
| if (readCtx == NULL) { | ||
| WOLFSSL_MSG("Memory error"); | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
Do we want to use WC_DECLARE_VAR to reduce allocations?
f3c2741 to
3988bc8
Compare
|
@claude review |
There was a problem hiding this comment.
🟡 Changes recommended
ECH context switching can cause a critical use-after-free, with additional unresolved defects in timestamp certificates, CA-directory handling, and extension-type validation.
5 open issues
9 resolved since last review
Guard memio test helpers for OPENSSL_EXTRA and no-filesystem builds Honor present zero-bit Netscape certificate-type extensions Preserve wrap mode in EVP_CIPHER_mode Preserve original unclamped X25519/X448 private scalar bytes Associate decoded X25519 keys with the owning RNG Cache complete X25519/X448 public-key encodings Normalize verify-file load failures to OpenSSL-compatible 0 or 1 Propagate directory iteration errors from CA-name loading Report certificate decoding and resource failures from CA directory loading
Review effort: Balanced
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11363
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json, certs/any-eku-cert.pem, certs/check_cert_chains.sh, certs/code-sign-cert.pem, certs/empty-eku-cert.pem, certs/include.am, certs/ns-ca-only-cert.pem, certs/ns-cert-type-cert.pem, certs/ns-zero-mask-cert.pem, certs/renewcerts.sh, certs/renewcerts/wolfssl.cnf, certs/statickeys/gen-static.sh, certs/statickeys/include.am, certs/statickeys/x448-pub.der, certs/statickeys/x448-pub.pem, certs/statickeys/x448.der, certs/statickeys/x448.pem, certs/v1-root-cert.pem, certs/v1-self-issued-cert.pem, doc/dox_comments/header_files/evp.h and 10 more
Coverage: 21 of 33 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_aes.c, tests/api/test_evp_cipher.c, tests/api/test_evp_digest.c, tests/api/test_evp_pkey.c, tests/api/test_ocsp.c, tests/api/test_ossl_asn1.c, tests/api/test_ossl_obj.c, tests/api/test_ossl_rsa.c, tests/api/test_ssl_cert.c, tests/api/test_tls_bounds.c and 2 more
Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Max
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11363
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json, certs/any-eku-cert.pem, certs/check_cert_chains.sh, certs/code-sign-cert.pem, certs/empty-eku-cert.pem, certs/include.am, certs/ns-ca-only-cert.pem, certs/ns-cert-type-cert.pem, certs/ns-zero-mask-cert.pem, certs/renewcerts.sh, certs/renewcerts/wolfssl.cnf, certs/statickeys/gen-static.sh, certs/statickeys/include.am, certs/statickeys/x448-pub.der, certs/statickeys/x448-pub.pem, certs/statickeys/x448.der, certs/statickeys/x448.pem, certs/v1-root-cert.pem, certs/v1-self-issued-cert.pem, doc/dox_comments/header_files/evp.h and 10 more
Coverage: 6 of 9 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_evp_pkey.c, tests/api/test_ossl_x509.c, wolfssl/openssl/evp.h
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
|
@claude review |
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11363
Scan targets checked: wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Not reviewed (no scan target covers them): .github/configs/os-check-linux.json, certs/any-eku-cert.pem, certs/check_cert_chains.sh, certs/code-sign-cert.pem, certs/empty-eku-cert.pem, certs/include.am, certs/ns-ca-only-cert.pem, certs/ns-cert-type-cert.pem, certs/ns-zero-mask-cert.pem, certs/renewcerts.sh, certs/renewcerts/wolfssl.cnf, certs/statickeys/gen-static.sh, certs/statickeys/include.am, certs/statickeys/x448-pub.der, certs/statickeys/x448-pub.pem, certs/statickeys/x448.der, certs/statickeys/x448.pem, certs/v1-root-cert.pem, certs/v1-self-issued-cert.pem, doc/dox_comments/header_files/evp.h and 10 more
Coverage: 4 of 6 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_evp_cipher.c, tests/api/test_tls.c
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
Review tier: Lite
X509_check_purpose SSL_CTX_set0_tmp_dh_pkey SSL_get1_peer_certificate EVP_aes_*_wrap, EVP_aes_*_wrap_pad EVP_PKEY_get_raw_private_key, EVP_PKEY_get_raw_public_key EVP_CIPHER_CTX_iv, EVP_CIPHER_CTX_iv_noconst OCSP_crl_reason_str X509_get_default_cert_dir, X509_get_default_cert_dir_env X509_get_default_cert_file_env SSL_add_dir_cert_subjects_to_stack, SSL_add_file_cert_subjects_to_stack EVP_md_null SSL_CTX_set_client_hello_cb, SSL_client_hello_get0_ext i2a_ASN1_STRING SSL_CTX_load_verify_file, SSL_CTX_load_verify_dir WOLFSSL_X509 gains a flag recording whether the extendedKeyUsage extension was present, taken from DecodedCert's extExtKeyUsageSet. X509_check_purpose checks timestamp signing on a leaf rather than refusing it. The extendedKeyUsage set through X509_add_ext arrives as a bitmask with no KeyPurposeId list behind it, so the count the purpose checks use is derived from the bits, and any encoding left from a previous value is dropped rather than left to disagree with them. X509_set_ns_cert_type records a zero mask as an absent extension rather than one permitting nothing, since that is what the encoder writes. SSL_client_hello_get0_ext widens the stored extension type instead of narrowing the requested one, so a value no extension can carry reports absence instead of aliasing onto one that was sent. The ClientHello callback also runs for a ClientHello whose extensions the extension code declines to parse - an SSLv3 one - which otherwise let a client skip the application's policy by offering that version. EVP_PKEY_keygen drops the encoding a key was built from before regenerating into it, raw or DER, so the raw getters report the key that was generated rather than the one it replaced. A DER encoding left in place gave X25519 and X448 a private key read back out of the old key and a public key from the new one, a pair that does not go together. EVP_CIPHER_CTX_iv reports the working IV for SM4-CBC and SM4-CTR, which keep it in the cipher as the AES and DES modes do. SSL_CTX_load_verify_dir reports a resource failure while still treating a missing, empty or unreadable directory as success, as OpenSSL does. EVP_CIPHER_CTX_FLAG_WRAP_ALLOW is defined; the wrap ciphers here need no opt-in, so it is accepted and ignored. The ClientHello callback also runs for an SSLv2 format CLIENT-HELLO, handled by ProcessOldClientHello rather than DoClientHello, which otherwise let a client skip the application's policy by sending that format where OLD_HELLO_ALLOWED is built. An AES key wrap init that carries a key establishes the integrity check value: given one it is used, and without one the RFC default applies even where the context held a custom value before, as OpenSSL's aes_wrap_init_key does. Whether the caller passed one is recorded before a NULL IV is replaced with the context's own buffer, which on a reused context still held the previous value. An AES key wrap init that names a cipher takes that cipher. A context already set to a different wrap cipher kept its own, so re-initialising an AES-128-WRAP context for AES-256-WRAP wrapped under the first 16 bytes of the new KEK; the stored cipher is now read only by a partial re-init that names none. The extendedKeyUsage presence readers test the flag recording that the extension was there rather than the KeyPurposeId list, so a usage set through X509_add_ext as a bitmask, which has no list behind it, and a decoded empty extension both read as present. The ClientHello callback runs once per ClientHello the peer sent rather than once per pass over one: an accepted ECH hello is parsed twice, the outer hello and then the inner one it carried, and the inner pass no longer calls the callback again. The callback's documentation records what selecting a context from it cannot do, both of them properties of SSL_set_SSL_CTX: carry over the settings cached on the WOLFSSL, the ALPN selection callback among them, and admit a protocol version the original context refused, which is decided before the callback is reached.


Description
Testing
Regression tested TLS and OpenSSL API configurations.