From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE920489FD0; Thu, 10 Sep 2026 14:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789049163; cv=none; b=fQ5qUIvNLc/UCaY4uGWntvt7x9x5OxID1YmCXFd7ZR38Iw0Um/s4w+L3kLm9Ni4tXvLLaO+COVT12wWy2i4T1RQ+qcaWsNbDnpLV2H7p9BRmyn2TDo31KQcOn+Ot1EcaClnqFqnwLPDqbOxZw/evbbdM2nbW+tbau7YQHhM17lY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789049163; c=relaxed/simple; bh=6BCszsXk8d+Z0XLNFAG78fBDmY5OsPZxWRGyTYS9Amk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P2DvJ/UbvfMSYX48vjE/u4PJwHBE4wdgMdaVSuhLqzc8K194oiLITRYm23iycGZNqX1oz+JTyc1iiECsXWhrplYFi20p9sjP09dKe3pmwB5RcX3BIzYiufJx8KfFWuKHVfUJ39ng0pxJguZ5ePmWbgb0k0nekxq++BnxjQTuHPM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aEhHkPMI; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aEhHkPMI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5100A1F000FF; Thu, 10 Sep 2026 14:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789049161; bh=MJXs8QEQplpsD7TykCLygoPyjsSjXkWAK/IQrvHJzTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aEhHkPMI95R2HMm7OcFqIIp2t363j7h16Mbj3iZUXL1gUTYX4eK36EBuNlWmB9rr4 C0ACD2I851UWas5dLSimqai2XK2vDX2mn+lnfWeTk+BNdT2AAwhEvflzqLISHLY+2Z OInh+vVW6Ouh2lNlKcxn8+qkjiVf3/CPl4lBF25HZCXCq5H++sCi+GD+T1O0IZZ0TN qncCi9d8rpaToAvbm88rVOTyP8F+xSDUQu5t+PW1B3TLczcJq+LFZLQsky7HuLOdgL lLHPA8S2I5Bj7XijlAp2cnZRR2npvrXlYDHOeKqzsg6Iv97b8XpEMwoeYR4DFS5N0a Ddwh6iMGNxwFg== From: "Aneesh Kumar K.V (Arm)" To: linux-coco@lists.linux.dev, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: "Aneesh Kumar K.V (Arm)" , Alexey Kardashevskiy , Catalin Marinas , Dan Williams , Jason Gunthorpe , Jonathan Cameron , Marc Zyngier , Samuel Ortiz , Steven Price , Suzuki K Poulose , Will Deacon , Xu Yilun , Lukas Wunner , Wilfred Mallawa , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Jonathan Cameron Subject: [PATCH v5 06/15] X.509: Parse Subject Alternative Name in certificates Date: Thu, 10 Sep 2026 19:34:59 +0530 Message-ID: <20260910140509.868402-7-aneesh.kumar@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260910140509.868402-1-aneesh.kumar@kernel.org> References: <20260910140509.868402-1-aneesh.kumar@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Lukas Wunner The upcoming support for PCI device authentication with CMA-SPDM (PCIe r6.1 sec 6.31) requires validating the Subject Alternative Name in X.509 certificates. Store a pointer to the Subject Alternative Name upon parsing for consumption by CMA-SPDM. Signed-off-by: Lukas Wunner Reviewed-by: Wilfred Mallawa Reviewed-by: Ilpo Järvinen Reviewed-by: Jonathan Cameron Acked-by: Dan Williams Signed-off-by: Aneesh Kumar K.V (Arm) --- crypto/asymmetric_keys/x509_cert_parser.c | 9 +++++++++ include/keys/x509-parser.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c index bfd10f0195e0..c3ec2846695a 100644 --- a/crypto/asymmetric_keys/x509_cert_parser.c +++ b/crypto/asymmetric_keys/x509_cert_parser.c @@ -596,6 +596,15 @@ int x509_process_extension(void *context, size_t hdrlen, return 0; } + if (ctx->last_oid == OID_subjectAltName) { + if (ctx->cert->raw_san) + return -EBADMSG; + + ctx->cert->raw_san = v; + ctx->cert->raw_san_size = vlen; + return 0; + } + if (ctx->last_oid == OID_keyUsage) { /* * Get hold of the keyUsage bit string diff --git a/include/keys/x509-parser.h b/include/keys/x509-parser.h index 8b68e720693a..4e6a05a8c7a6 100644 --- a/include/keys/x509-parser.h +++ b/include/keys/x509-parser.h @@ -38,6 +38,8 @@ struct x509_certificate { unsigned raw_subject_size; unsigned raw_skid_size; const void *raw_skid; /* Raw subjectKeyId in ASN.1 */ + const void *raw_san; /* Raw subjectAltName in ASN.1 */ + unsigned raw_san_size; unsigned index; bool seen; /* Infinite recursion prevention */ bool verified; -- 2.43.0