Commit 16ab7cb5 authored by Dimitri John Ledkov's avatar Dimitri John Ledkov Committed by Herbert Xu
Browse files

crypto: pkcs7 - remove sha1 support



Removes support for sha1 signed kernel modules, importing sha1 signed
x.509 certificates.

rsa-pkcs1pad keeps sha1 padding support, which seems to be used by
virtio driver.

sha1 remains available as there are many drivers and subsystems using
it. Note only hmac(sha1) with secret keys remains cryptographically
secure.

In the kernel there are filesystems, IMA, tpm/pcr that appear to be
using sha1. Maybe they can all start to be slowly upgraded to
something else i.e. blake3, ParallelHash, SHAKE256 as needed.

Signed-off-by: default avatarDimitri John Ledkov <dimitri.ledkov@canonical.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent c35b581e
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -75,9 +75,6 @@ int mscode_note_digest_algo(void *context, size_t hdrlen,

	oid = look_up_OID(value, vlen);
	switch (oid) {
	case OID_sha1:
		ctx->digest_algo = "sha1";
		break;
	case OID_sha256:
		ctx->digest_algo = "sha256";
		break;
+0 −4
Original line number Diff line number Diff line
@@ -227,9 +227,6 @@ int pkcs7_sig_note_digest_algo(void *context, size_t hdrlen,
	struct pkcs7_parse_context *ctx = context;

	switch (ctx->last_oid) {
	case OID_sha1:
		ctx->sinfo->sig->hash_algo = "sha1";
		break;
	case OID_sha256:
		ctx->sinfo->sig->hash_algo = "sha256";
		break;
@@ -272,7 +269,6 @@ int pkcs7_sig_note_pkey_algo(void *context, size_t hdrlen,
		ctx->sinfo->sig->pkey_algo = "rsa";
		ctx->sinfo->sig->encoding = "pkcs1";
		break;
	case OID_id_ecdsa_with_sha1:
	case OID_id_ecdsa_with_sha224:
	case OID_id_ecdsa_with_sha256:
	case OID_id_ecdsa_with_sha384:
+1 −2
Original line number Diff line number Diff line
@@ -116,8 +116,7 @@ software_key_determine_akcipher(const struct public_key *pkey,
		 */
		if (!hash_algo)
			return -EINVAL;
		if (strcmp(hash_algo, "sha1") != 0 &&
		    strcmp(hash_algo, "sha224") != 0 &&
		if (strcmp(hash_algo, "sha224") != 0 &&
		    strcmp(hash_algo, "sha256") != 0 &&
		    strcmp(hash_algo, "sha384") != 0 &&
		    strcmp(hash_algo, "sha512") != 0)
+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(decrypt_blob);
 * Sign the specified data blob using the private key specified by params->key.
 * The signature is wrapped in an encoding if params->encoding is specified
 * (eg. "pkcs1").  If the encoding needs to know the digest type, this can be
 * passed through params->hash_algo (eg. "sha1").
 * passed through params->hash_algo (eg. "sha512").
 *
 * Returns the length of the data placed in the signature buffer or an error.
 */
+0 −8
Original line number Diff line number Diff line
@@ -198,10 +198,6 @@ int x509_note_sig_algo(void *context, size_t hdrlen, unsigned char tag,
	default:
		return -ENOPKG; /* Unsupported combination */

	case OID_sha1WithRSAEncryption:
		ctx->cert->sig->hash_algo = "sha1";
		goto rsa_pkcs1;

	case OID_sha256WithRSAEncryption:
		ctx->cert->sig->hash_algo = "sha256";
		goto rsa_pkcs1;
@@ -218,10 +214,6 @@ int x509_note_sig_algo(void *context, size_t hdrlen, unsigned char tag,
		ctx->cert->sig->hash_algo = "sha224";
		goto rsa_pkcs1;

	case OID_id_ecdsa_with_sha1:
		ctx->cert->sig->hash_algo = "sha1";
		goto ecdsa;

	case OID_id_ecdsa_with_sha224:
		ctx->cert->sig->hash_algo = "sha224";
		goto ecdsa;
Loading