Commit 8cd9f234 authored by Joachim Vandersmissen's avatar Joachim Vandersmissen Committed by Jarkko Sakkinen

certs: Move RSA self-test data to separate file

In preparation of adding new ECDSA self-tests, the existing data for
the RSA self-tests is moved to a separate file. This file is only
compiled if the new CONFIG_FIPS_SIGNATURE_SELFTEST_RSA configuration
option is set, which ensures that the required dependencies (RSA,
SHA-256) are present. Otherwise, the kernel would panic when trying to
execute the self-test.
The introduction of this new option, rather than adding the
dependencies to the existing CONFIG_FIPS_SIGNATURE_SELFTEST option,
allows for additional self-tests to be added for different algorithms.
The kernel can then be configured to only execute the self-tests for
those algorithms that are included.
Signed-off-by: default avatarJoachim Vandersmissen <git@jvdsn.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
parent 9d2fd8bd
......@@ -89,4 +89,11 @@ config FIPS_SIGNATURE_SELFTEST
depends on CRYPTO_RSA
depends on CRYPTO_SHA256
config FIPS_SIGNATURE_SELFTEST_RSA
bool
default y
depends on FIPS_SIGNATURE_SELFTEST
depends on CRYPTO_SHA256=y || CRYPTO_SHA256=FIPS_SIGNATURE_SELFTEST
depends on CRYPTO_RSA=y || CRYPTO_RSA=FIPS_SIGNATURE_SELFTEST
endif # ASYMMETRIC_KEY_TYPE
......@@ -24,6 +24,7 @@ x509_key_parser-y := \
x509_public_key.o
obj-$(CONFIG_FIPS_SIGNATURE_SELFTEST) += x509_selftest.o
x509_selftest-y += selftest.o
x509_selftest-$(CONFIG_FIPS_SIGNATURE_SELFTEST_RSA) += selftest_rsa.o
$(obj)/x509_cert_parser.o: \
$(obj)/x509.asn1.h \
......
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* Helper function for self-testing PKCS#7 signature verification.
*
* Copyright (C) 2024 Joachim Vandersmissen <git@jvdsn.com>
*/
void fips_signature_selftest(const char *name,
const u8 *keys, size_t keys_len,
const u8 *data, size_t data_len,
const u8 *sig, size_t sig_len);
#ifdef CONFIG_FIPS_SIGNATURE_SELFTEST_RSA
void __init fips_signature_selftest_rsa(void);
#else
static inline void __init fips_signature_selftest_rsa(void) { }
#endif
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment