From patchwork Wed Apr 8 07:55:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 26498 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B8AF6BDCBD for ; Wed, 8 Apr 2026 07:56:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D2A262DB7; Wed, 8 Apr 2026 09:56:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="SorPCmky"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2397362DA6 for ; Wed, 8 Apr 2026 09:56:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775634985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0O3fyPHHp57bswz2D8I6bzccBP1mTD6VJ226V09wIK8=; b=SorPCmkyopLfvJsfS9sc0NK1S5LlHeH7PDaKRwgnCRBDI8O4ZS6OV8XA+F6M4uP0omdOb+ 5GR7wxIRPf+A/DkrWJO12l9HqqK+dd1GdVDwOPVeXZ9gaHEI9dXpkO1neUXyxjLeaHtgDY 5Xv0VA8arAj5gjZvjzEda8dUiHsPxJo= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-J9BOVr2fO5eUdmzkXR2caQ-1; Wed, 08 Apr 2026 03:56:24 -0400 X-MC-Unique: J9BOVr2fO5eUdmzkXR2caQ-1 X-Mimecast-MFC-AGG-ID: J9BOVr2fO5eUdmzkXR2caQ_1775634983 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C19A1195608E for ; Wed, 8 Apr 2026 07:56:23 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.32.15]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3C3F830001BB; Wed, 8 Apr 2026 07:56:21 +0000 (UTC) From: Kate Hsuan To: libcamera-devel@lists.libcamera.org Cc: Kate Hsuan Subject: [PATCH 1/4] libcamera: pub_key: Add ML-DSA-65 signature algorithm for PQC compliance Date: Wed, 8 Apr 2026 15:55:37 +0800 Message-ID: <20260408075540.53309-2-hpa@redhat.com> In-Reply-To: <20260408075540.53309-1-hpa@redhat.com> References: <20260408075540.53309-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: zCRcpyGPtJ_Rp3c54g9OgiRLyOdtmv-TI--CTePgooU_1775634983 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" As quantum computing advances, traditional signature algorithms are becoming vulnerable. To ensure long-term data security, this change implements ML-DSA-65, the primary Post-Quantum Cryptography (PQC) standard finalized by NIST. This addition prepares for the transition away from RSA, which is slated for deprecation by 2035. Link: https://csrc.nist.gov/projects/post-quantum-cryptography/post-quantum-cryptography-standardization/evaluation-criteria/security-(evaluation-criteria) Link: https://nvlpubs.nist.gov/nistpubs/ir/2024/NIST.IR.8547.ipd.pdf Signed-off-by: Kate Hsuan --- src/libcamera/pub_key.cpp | 55 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pub_key.cpp b/src/libcamera/pub_key.cpp index f1d73a5c..20f13600 100644 --- a/src/libcamera/pub_key.cpp +++ b/src/libcamera/pub_key.cpp @@ -14,8 +14,13 @@ #include #elif HAVE_GNUTLS #include +#include #endif +#include "libcamera/internal/pub_key.h" +#include +#include + /** * \file pub_key.h * \brief Public key signature verification @@ -23,17 +28,24 @@ namespace libcamera { +LOG_DEFINE_CATEGORY(PubKey); /** * \class PubKey * \brief Public key wrapper for signature verification * * The PubKey class wraps a public key and implements signature verification. It - * only supports RSA keys and the RSA-SHA256 signature algorithm. + * supports RSA keys with the RSA-SHA256 signature algorithm, or ML-DSA-65 keys + * as specified in NIST FIPS 204. The signature algorithm is determined in + * compile time. */ /** * \brief Construct a PubKey from key data * \param[in] key Key data encoded in DER format + * + * The signature algorithm is determined in the compile + * Supported key types are RSA (verified with RSA-SHA256) and ML-DSA-65 + * (verified as ML-DSA-65 according to FIPS 204). */ PubKey::PubKey([[maybe_unused]] Span key) : valid_(false) @@ -83,7 +95,8 @@ PubKey::~PubKey() * \param[in] sig The signature * * Verify that the signature \a sig matches the signed \a data for the public - * key. The signture algorithm is hardcoded to RSA-SHA256. + * key. The signature algorithm is determined in compile time. RSA keys use + * RSA-SHA256, while ML-DSA keys use ML-DSA-65 mentioned in FIPS 204. * * \return True if the signature is valid, false otherwise */ @@ -94,6 +107,30 @@ bool PubKey::verify([[maybe_unused]] Span data, return false; #if HAVE_CRYPTO + +#if WITH_FIPS + /* ML-DSA */ + EVP_MD_CTX *ctx_dsa = EVP_MD_CTX_new(); + if (!ctx_dsa) { + LOG(PubKey, Error) << "Initialize context for ML-DSA failed"; + return false; + } + + if (EVP_DigestVerifyInit(ctx_dsa, nullptr, nullptr, nullptr, + pubkey_) <= 0) { + EVP_MD_CTX_free(ctx_dsa); + LOG(PubKey, Error) << "Initialize ML-DSA verification failed"; + return false; + } + + int ret = EVP_DigestVerify(ctx_dsa, sig.data(), sig.size(), + data.data(), data.size()); + EVP_MD_CTX_free(ctx_dsa); + LOG(PubKey, Error) << "Verify with ML-DSA-65: " << ret; + return ret == 1; +#else + /* RSA with SHA-256 */ + /* * Create and initialize a public key algorithm context for signature * verification. @@ -117,7 +154,11 @@ bool PubKey::verify([[maybe_unused]] Span data, int ret = EVP_PKEY_verify(ctx, sig.data(), sig.size(), digest, SHA256_DIGEST_LENGTH); EVP_PKEY_CTX_free(ctx); + + LOG(PubKey, Error) << "Verify with RSA-SHA256: " << ret; return ret == 1; +#endif + #elif HAVE_GNUTLS const gnutls_datum_t gnuTlsData{ const_cast(data.data()), @@ -129,9 +170,17 @@ bool PubKey::verify([[maybe_unused]] Span data, static_cast(sig.size()) }; - int ret = gnutls_pubkey_verify_data2(pubkey_, GNUTLS_SIGN_RSA_SHA256, 0, +#if WITH_FIPS + int ret = gnutls_pubkey_verify_data2(pubkey_, GNUTLS_SIGN_MLDSA65, 0, &gnuTlsData, &gnuTlsSig); + LOG(PubKey, Error) << "Verify with ML-DSA-65: " << ret; + return ret >= 0; +#else + int ret = gnutls_pubkey_verify_data2(pubkey_, GNUTLS_SIGN_RSA_SHA256, + 0, &gnuTlsData, &gnuTlsSig); + LOG(PubKey, Error) << "Verify with RSA-SHA256: " << ret; return ret >= 0; +#endif #else return false; #endif From patchwork Wed Apr 8 07:55:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 26499 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id D1CDEBDCBD for ; Wed, 8 Apr 2026 07:56:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D57962DA6; Wed, 8 Apr 2026 09:56:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="JAD1l8Eo"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EBBEC62DA6 for ; Wed, 8 Apr 2026 09:56:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775634990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GN9YNhagA0eufDqZjOfuC2jD3MT8RxrtcGF8nUE1pAQ=; b=JAD1l8EoprrCLaCZmhfemLYKc2RFWy9SMpyLGJA3RmIyCbTIyRewHzURq6RKidD/+S/cSZ 2w+I3r8/X2JCARN6hxPyK5fc+U9fGGOci3XPpH3zZFLH5YigVVT9kIKbIfrRgp0G0KmM8C hTLzini6+z5ge3Nsx3JDPr4ACfY3a3M= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-c8ILyD7dO8-QOrm4tARL5A-1; Wed, 08 Apr 2026 03:56:28 -0400 X-MC-Unique: c8ILyD7dO8-QOrm4tARL5A-1 X-Mimecast-MFC-AGG-ID: c8ILyD7dO8-QOrm4tARL5A_1775634987 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD8DE18005B6 for ; Wed, 8 Apr 2026 07:56:27 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.32.15]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1DD58300019F; Wed, 8 Apr 2026 07:56:25 +0000 (UTC) From: Kate Hsuan To: libcamera-devel@lists.libcamera.org Cc: Kate Hsuan Subject: [PATCH 2/4] utils: codegen: gen-ipa-pub-key: replace openssl rsa with openssl pkey Date: Wed, 8 Apr 2026 15:55:38 +0800 Message-ID: <20260408075540.53309-3-hpa@redhat.com> In-Reply-To: <20260408075540.53309-1-hpa@redhat.com> References: <20260408075540.53309-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Ps-RVIv3I041WRcvprFFtK-PcSdf1rLF-9goz0vT6aQ_1775634987 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The command "openssl ras" was replaced with "openssl pkey" to cover different key algorithms. Signed-off-by: Kate Hsuan --- utils/codegen/gen-ipa-pub-key.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/codegen/gen-ipa-pub-key.py b/utils/codegen/gen-ipa-pub-key.py index dc3e7d5f..9854c0c2 100755 --- a/utils/codegen/gen-ipa-pub-key.py +++ b/utils/codegen/gen-ipa-pub-key.py @@ -21,7 +21,7 @@ def main(argv): output = argv[3] try: - ret = subprocess.run(['openssl', 'rsa', '-pubout', '-in', priv_key, + ret = subprocess.run(['openssl', 'pkey', '-pubout', '-in', priv_key, '-outform', 'DER'], stdout=subprocess.PIPE) except FileNotFoundError: From patchwork Wed Apr 8 07:55:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 26500 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 84826BDCBD for ; Wed, 8 Apr 2026 07:56:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F10662DCC; Wed, 8 Apr 2026 09:56:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="duTjDQIZ"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E0E7762DB7 for ; Wed, 8 Apr 2026 09:56:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775634993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W4Qb6cfo+Co9PLrPFp9D+qadOaXt4IHAel3cbQUxS2E=; b=duTjDQIZth2ylRCA01Q/fGTcwLTz6mSLfS/kRt6p/aQF9ahWCqTYnNvkpyFvv+wTdBjc4J fnmVCR/FPuOjz0yu4wuG7+RRnq93JTEJLVNHKolfDANzQBKzgWgGhlpGXXSZRVNa9GcU9/ cnbWT3PoqgkAdcp9oY+AwXftgkEFlwo= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-tPLAu4WqMRCZGx0HpOTrnQ-1; Wed, 08 Apr 2026 03:56:32 -0400 X-MC-Unique: tPLAu4WqMRCZGx0HpOTrnQ-1 X-Mimecast-MFC-AGG-ID: tPLAu4WqMRCZGx0HpOTrnQ_1775634991 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9B40F19560A1 for ; Wed, 8 Apr 2026 07:56:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.32.15]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F0840300019F; Wed, 8 Apr 2026 07:56:29 +0000 (UTC) From: Kate Hsuan To: libcamera-devel@lists.libcamera.org Cc: Kate Hsuan Subject: [PATCH 3/4] ipa: ipa-sign: Sign IPA according to the signature algorithm of the key Date: Wed, 8 Apr 2026 15:55:39 +0800 Message-ID: <20260408075540.53309-4-hpa@redhat.com> In-Reply-To: <20260408075540.53309-1-hpa@redhat.com> References: <20260408075540.53309-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: _cy679BoVOuqj0lamILdkRTcVhwCrW1JbyPYMn3hSNk_1775634991 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Sign IPA according to the signature algorithm of the key. Signed-off-by: Kate Hsuan --- src/ipa/ipa-sign.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ipa/ipa-sign.sh b/src/ipa/ipa-sign.sh index 69024213..aa9c7d31 100755 --- a/src/ipa/ipa-sign.sh +++ b/src/ipa/ipa-sign.sh @@ -10,4 +10,9 @@ key="$1" input="$2" output="$3" -openssl dgst -sha256 -sign "${key}" -out "${output}" "${input}" +if openssl pkey -text -noout -in "${key}" 2>/dev/null | grep -q "ML-DSA"; then + openssl pkeyutl -sign -inkey "${key}" -rawin \ + -in "${input}" -out "${output}" +else + openssl dgst -sha256 -sign "${key}" -out "${output}" "${input}" +fi From patchwork Wed Apr 8 07:55:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kate Hsuan X-Patchwork-Id: 26501 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 73F32BDCBD for ; Wed, 8 Apr 2026 07:56:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F8F862DD3; Wed, 8 Apr 2026 09:56:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="gHJuV6Kt"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B6AD362DB7 for ; Wed, 8 Apr 2026 09:56:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775634997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zR3E2P0FfHLaNh+kZBSbcg+8eM35S78nVWlxvV9aViM=; b=gHJuV6Ktd9IoDpGeH3cJ6pq5R1XYexO6ADiHBI6pREgBVc4Fbb6GQAqMxrvp+jpaj+tc7g QPg9IOBvnLZpyGtvS2EFZH+jjeV4uoKpFFZl83PoOE9634+puz/rWvZi62QdbP2VjsIGPg MltaNu8pMwllZysDm+/jnhEgeCiVHQA= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-tTIq0DV8OTCCZbpFEmlzhg-1; Wed, 08 Apr 2026 03:56:36 -0400 X-MC-Unique: tTIq0DV8OTCCZbpFEmlzhg-1 X-Mimecast-MFC-AGG-ID: tTIq0DV8OTCCZbpFEmlzhg_1775634995 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6B2CC1956089 for ; Wed, 8 Apr 2026 07:56:35 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.67.32.15]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B1DAB300019F; Wed, 8 Apr 2026 07:56:33 +0000 (UTC) From: Kate Hsuan To: libcamera-devel@lists.libcamera.org Cc: Kate Hsuan Subject: [PATCH 4/4] meson: Add "fips" meson option to enable ML-DSA Date: Wed, 8 Apr 2026 15:55:40 +0800 Message-ID: <20260408075540.53309-5-hpa@redhat.com> In-Reply-To: <20260408075540.53309-1-hpa@redhat.com> References: <20260408075540.53309-1-hpa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: g973dwkU6IvoTWAA_Ddc3VM75SkLmQl4SnAc5cS_WwE_1775634995 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a boolean type "fips" meson option to enable ML-SDA. If fips=false, the RSA-SHA256 will be used. Signed-off-by: Kate Hsuan --- meson_options.txt | 5 +++++ src/libcamera/meson.build | 6 ++++++ src/meson.build | 13 ++++++++++--- utils/gen-ipa-priv-key.sh | 16 ++++++++++++++-- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index c27e377a..c89167fb 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -26,6 +26,11 @@ option('doc_werror', value : false, description : 'Treat documentation warnings as errors') +option('fips', + type : 'boolean', + value : false, + description : 'Sign IPA library using ML-DSA (FIPS 204)') + option('gstreamer', type : 'feature', value : 'auto', diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index d1594358..aed962c4 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -118,6 +118,12 @@ else endif endif +# comply with FIPS 204 +with_fips = get_option('fips') +if with_fips + config_h.set('WITH_FIPS', 1) +endif + if not libcrypto.found() warning('Neither gnutls nor libcrypto found, all IPA modules will be isolated') summary({'IPA modules signed with': 'None (modules will run isolated)'}, diff --git a/src/meson.build b/src/meson.build index 9b63c8e8..f1493341 100644 --- a/src/meson.build +++ b/src/meson.build @@ -15,11 +15,18 @@ summary({ }, section : 'Paths') # Module Signing +with_fips = get_option('fips') openssl = find_program('openssl', required : false) if openssl.found() - ipa_priv_key = custom_target('ipa-priv-key', - output : ['ipa-priv-key.pem'], - command : [gen_ipa_priv_key, '@OUTPUT@']) + if with_fips + ipa_priv_key = custom_target('ipa-priv-key', + output : ['ipa-priv-key.pem'], + command : [gen_ipa_priv_key, 'ML-DSA-65', '@OUTPUT@']) + else + ipa_priv_key = custom_target('ipa-priv-key', + output : ['ipa-priv-key.pem'], + command : [gen_ipa_priv_key, 'RSA', '@OUTPUT@']) + endif config_h.set('HAVE_IPA_PUBKEY', 1) ipa_sign_module = true else diff --git a/utils/gen-ipa-priv-key.sh b/utils/gen-ipa-priv-key.sh index 2ca7b883..374377fc 100755 --- a/utils/gen-ipa-priv-key.sh +++ b/utils/gen-ipa-priv-key.sh @@ -6,6 +6,18 @@ # # Generate an RSA private key to sign IPA modules -key="$1" +algo="$1" +key="$2" -openssl genpkey -algorithm RSA -out "${key}" -pkeyopt rsa_keygen_bits:2048 +# Two possible algorithms: RSA and ML-DSA-65 +# openssl genpkey -algorithm RSA -out "${key}" -pkeyopt rsa_keygen_bits:2048 +# openssl genpkey -algorithm ML-DSA-65 -out "${key}" + +if [ "$algo" == "RSA" ]; then + openssl genpkey -algorithm RSA -out "${key}" -pkeyopt rsa_keygen_bits:2048 +elif [ "$algo" == "ML-DSA-65" ]; then + openssl genpkey -algorithm ML-DSA-65 -out "${key}" +else + echo "Invalid algorithm: $algo" + exit 1 +fi \ No newline at end of file