mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 16:12:02 +00:00
747ae81883
Commit c27b2d2012
("crypto: testmgr - allow ecdsa-nist-p256 and -p384
in FIPS mode") enabled support for ECDSA in crypto/testmgr.c. The
PKCS#7 signature verification API builds upon the KCAPI primitives to
perform its high-level operations. Therefore, this change in testmgr.c
also allows ECDSA to be used by the PKCS#7 signature verification API
(in FIPS mode).
However, from a FIPS perspective, the PKCS#7 signature verification API
is a distinct "service" from the KCAPI primitives. This is because the
PKCS#7 API performs a "full" signature verification, which consists of
both hashing the data to be verified, and the public key operation.
On the other hand, the KCAPI primitive does not perform this hashing
step - it accepts pre-hashed data from the caller and only performs the
public key operation.
For this reason, the ECDSA self-tests in crypto/testmgr.c are not
sufficient to cover ECDSA signature verification offered by the PKCS#7
API. This is reflected by the self-test already present in this file
for RSA PKCS#1 v1.5 signature verification.
The solution is simply to add a second self-test here for ECDSA. P-256
with SHA-256 hashing was chosen as those parameters should remain
FIPS-approved for the foreseeable future, while keeping the performance
impact to a minimum. The ECDSA certificate and PKCS#7 signed data was
generated using OpenSSL. The input data is identical to the input data
for the existing RSA self-test.
Signed-off-by: Joachim Vandersmissen <git@jvdsn.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
107 lines
3.4 KiB
Plaintext
107 lines
3.4 KiB
Plaintext
# SPDX-License-Identifier: GPL-2.0
|
|
menuconfig ASYMMETRIC_KEY_TYPE
|
|
bool "Asymmetric (public-key cryptographic) key type"
|
|
depends on KEYS
|
|
help
|
|
This option provides support for a key type that holds the data for
|
|
the asymmetric keys used for public key cryptographic operations such
|
|
as encryption, decryption, signature generation and signature
|
|
verification.
|
|
|
|
if ASYMMETRIC_KEY_TYPE
|
|
|
|
config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
|
|
tristate "Asymmetric public-key crypto algorithm subtype"
|
|
select MPILIB
|
|
select CRYPTO_HASH_INFO
|
|
select CRYPTO_AKCIPHER
|
|
select CRYPTO_SIG
|
|
select CRYPTO_HASH
|
|
help
|
|
This option provides support for asymmetric public key type handling.
|
|
If signature generation and/or verification are to be used,
|
|
appropriate hash algorithms (such as SHA-1) must be available.
|
|
ENOPKG will be reported if the requisite algorithm is unavailable.
|
|
|
|
config X509_CERTIFICATE_PARSER
|
|
tristate "X.509 certificate parser"
|
|
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
|
|
select ASN1
|
|
select OID_REGISTRY
|
|
help
|
|
This option provides support for parsing X.509 format blobs for key
|
|
data and provides the ability to instantiate a crypto key from a
|
|
public key packet found inside the certificate.
|
|
|
|
config PKCS8_PRIVATE_KEY_PARSER
|
|
tristate "PKCS#8 private key parser"
|
|
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE
|
|
select ASN1
|
|
select OID_REGISTRY
|
|
help
|
|
This option provides support for parsing PKCS#8 format blobs for
|
|
private key data and provides the ability to instantiate a crypto key
|
|
from that data.
|
|
|
|
config PKCS7_MESSAGE_PARSER
|
|
tristate "PKCS#7 message parser"
|
|
depends on X509_CERTIFICATE_PARSER
|
|
select CRYPTO_HASH
|
|
select ASN1
|
|
select OID_REGISTRY
|
|
help
|
|
This option provides support for parsing PKCS#7 format messages for
|
|
signature data and provides the ability to verify the signature.
|
|
|
|
config PKCS7_TEST_KEY
|
|
tristate "PKCS#7 testing key type"
|
|
depends on SYSTEM_DATA_VERIFICATION
|
|
help
|
|
This option provides a type of key that can be loaded up from a
|
|
PKCS#7 message - provided the message is signed by a trusted key. If
|
|
it is, the PKCS#7 wrapper is discarded and reading the key returns
|
|
just the payload. If it isn't, adding the key will fail with an
|
|
error.
|
|
|
|
This is intended for testing the PKCS#7 parser.
|
|
|
|
config SIGNED_PE_FILE_VERIFICATION
|
|
bool "Support for PE file signature verification"
|
|
depends on PKCS7_MESSAGE_PARSER=y
|
|
depends on SYSTEM_DATA_VERIFICATION
|
|
select CRYPTO_HASH
|
|
select ASN1
|
|
select OID_REGISTRY
|
|
help
|
|
This option provides support for verifying the signature(s) on a
|
|
signed PE binary.
|
|
|
|
config FIPS_SIGNATURE_SELFTEST
|
|
tristate "Run FIPS selftests on the X.509+PKCS7 signature verification"
|
|
help
|
|
This option causes some selftests to be run on the signature
|
|
verification code, using some built in data. This is required
|
|
for FIPS.
|
|
depends on KEYS
|
|
depends on ASYMMETRIC_KEY_TYPE
|
|
depends on PKCS7_MESSAGE_PARSER=X509_CERTIFICATE_PARSER
|
|
depends on X509_CERTIFICATE_PARSER
|
|
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
|
|
|
|
config FIPS_SIGNATURE_SELFTEST_ECDSA
|
|
bool
|
|
default y
|
|
depends on FIPS_SIGNATURE_SELFTEST
|
|
depends on CRYPTO_SHA256=y || CRYPTO_SHA256=FIPS_SIGNATURE_SELFTEST
|
|
depends on CRYPTO_ECDSA=y || CRYPTO_ECDSA=FIPS_SIGNATURE_SELFTEST
|
|
|
|
endif # ASYMMETRIC_KEY_TYPE
|