eBPF-based security platform
crypto: take the CMS signer only from the certificate given
Daniel Borkmanne86026f9aeb0
diff --git a/Documentation/security/cryptography.rst b/Documentation/security/cryptography.rstindex 803156d0..63bd7572 100644--- a/Documentation/security/cryptography.rst+++ b/Documentation/security/cryptography.rst@@ -58,7 +58,9 @@ All five use one format, produced by one function on the operator:- Algorithm: ML-DSA-87 (FIPS 204). The signing code refuses any otherkey, the smaller ML-DSA parameter sets included- Container: a detached CMS ``SignedData`` with no certificates; the- signer is named by its subject key identifier+ signer is named by its subject key identifier. shirudo's own checks+ take the signer only from the certificate they are given, never from+ one the container carries- With OpenSSL 3.x: signed attributes with a SHA-512 message digest andno signing time, because OpenSSL 3.x cannot sign ML-DSA withoutsigned attributes and the kernel accepts only SHA-512 for ML-DSA indiff --git a/testing/fuzz/fuzz-cms.c b/testing/fuzz/fuzz-cms.cindex c5e102d2..82e8f89e 100644--- a/testing/fuzz/fuzz-cms.c+++ b/testing/fuzz/fuzz-cms.c@@ -36,9 +36,9 @@ int LLVMFuzzerTestOneInput(const __u8 *data, size_t size)if (!cert_read_der(der, der_len, &cert)) {int signed_by = cms_signed_by(sig, sig_len, &cert);- /* A signature that verifies is one that parses. */+ /* A signature that verifies is one the certificate made. */if (!verify_detached(der, der_len, sig, sig_len, &cert) &&- signed_by < 0)+ signed_by != 1)abort();if (!cert_pubkey(&cert, &pub) && pub.n_len > sizeof(pub.n))abort();diff --git a/util/crypto_openssl.c b/util/crypto_openssl.cindex 3f6b13f9..95549f11 100644--- a/util/crypto_openssl.c+++ b/util/crypto_openssl.c@@ -404,7 +404,7 @@ int verify_detached(const __u8 *payload, size_t payload_len,goto done;cms = read_cms(signature, signature_len);if (cms && CMS_verify(cms, signers, store, data, out,- CMS_BINARY | CMS_DETACHED) == 1)+ CMS_BINARY | CMS_DETACHED | CMS_NOINTERN) == 1)ret = 0;done:if (ret)@@ -673,7 +673,8 @@ int cert_verify_chain(const struct cert *cert,goto out;}/* An intermediate in the bundle is a trust anchor too. */- X509_STORE_set_flags(store, X509_V_FLAG_PARTIAL_CHAIN);+ if (X509_STORE_set_flags(store, X509_V_FLAG_PARTIAL_CHAIN) != 1)+ goto out;ctx = X509_STORE_CTX_new();if (!ctx || X509_STORE_CTX_init(ctx, store, cert->impl, NULL) != 1)goto out;