Skip to contentSkip to conversation

crypto: KEYS: convert public key to akcipher api

PATCH Superseded Tadeusz Struk 5 participants 12 messages Dec 13, 2015 – Dec 23, 2015

Subsystems (6)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover crypto: KEYS: convert public key to akcipher api

This patch set converts the module verification and digital signature code to the new akcipher API.
RSA implementation has been removed from crypto/asymmetric_keys and the new API is used for cryptographic primitives.
There is no need for MPI above the akcipher API anymore. Modules can be verified with software as well as HW RSA implementations.

Patches generated against cryptodev-2.6

Changes in v2:
- Fix the whey public_key_signature is setup. The pointer s needs to point to the signature instread of the signature_v2_hdr.
- Select CRYPTO_RSA when INTEGRITY_ASYMMETRIC_KEYS is selected.

---

Tadeusz Struk (2):
crypto: KEYS: convert public key to the akcipher api
integrity: convert digsig to akcipher api

 crypto/asymmetric_keys/Kconfig            |    2 
 crypto/asymmetric_keys/Makefile           |    7 -
 crypto/asymmetric_keys/pkcs7_parser.c     |   12 +-
 crypto/asymmetric_keys/pkcs7_trust.c      |    2 
 crypto/asymmetric_keys/pkcs7_verify.c     |    2 
 crypto/asymmetric_keys/public_key.c       |   64 +++------
 crypto/asymmetric_keys/public_key.h       |   36 -----
 crypto/asymmetric_keys/rsa.c              |  213 +++++++++++------------------
 crypto/asymmetric_keys/x509_cert_parser.c |   37 +----
 crypto/asymmetric_keys/x509_public_key.c  |   17 +-
 crypto/asymmetric_keys/x509_rsakey.asn1   |    4 -
 include/crypto/public_key.h               |   49 ++-----
 security/integrity/Kconfig                |    1 
 security/integrity/digsig_asymmetric.c    |   10 -
 14 files changed, 140 insertions(+), 316 deletions(-)
 delete mode 100644 crypto/asymmetric_keys/public_key.h
 delete mode 100644 crypto/asymmetric_keys/x509_rsakey.asn1

--
TS

#1 lore raw

PATCH v2 1/2 crypto: KEYS: convert public key to the akcipher api

This patch converts the module verification code to the new akcipher API.

---
 crypto/asymmetric_keys/Kconfig            |    2 
 crypto/asymmetric_keys/Makefile           |    7 -
 crypto/asymmetric_keys/pkcs7_parser.c     |   12 +-
 crypto/asymmetric_keys/pkcs7_trust.c      |    2 
 crypto/asymmetric_keys/pkcs7_verify.c     |    2 
 crypto/asymmetric_keys/public_key.c       |   64 +++------
 crypto/asymmetric_keys/public_key.h       |   36 -----
 crypto/asymmetric_keys/rsa.c              |  213 +++++++++++------------------
 crypto/asymmetric_keys/x509_cert_parser.c |   37 +----
 crypto/asymmetric_keys/x509_public_key.c  |   17 +-
 crypto/asymmetric_keys/x509_rsakey.asn1   |    4 -
 include/crypto/public_key.h               |   49 ++-----
 12 files changed, 136 insertions(+), 309 deletions(-)
 delete mode 100644 crypto/asymmetric_keys/public_key.h
 delete mode 100644 crypto/asymmetric_keys/x509_rsakey.asn1
crypto/asymmetric_keys/Kconfig +1 -1
index 4870f28..905d745 100644
@@ -22,7 +22,7 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
 
 config PUBLIC_KEY_ALGO_RSA
 	tristate "RSA public-key algorithm"
-	select MPILIB
+	select CRYPTO_RSA
 	help
 	  This option enables support for the RSA algorithm (PKCS#1, RFC3447).
 
crypto/asymmetric_keys/Makefile +2 -5
index cd1406f..b78a194 100644
@@ -16,21 +16,18 @@ obj-$(CONFIG_X509_CERTIFICATE_PARSER) += x509_key_parser.o
 x509_key_parser-y := \
 	x509-asn1.o \
 	x509_akid-asn1.o \
-	x509_rsakey-asn1.o \
 	x509_cert_parser.o \
 	x509_public_key.o
 
 $(obj)/x509_cert_parser.o: \
 	$(obj)/x509-asn1.h \
-	$(obj)/x509_akid-asn1.h \
-	$(obj)/x509_rsakey-asn1.h
+	$(obj)/x509_akid-asn1.h
+
 $(obj)/x509-asn1.o: $(obj)/x509-asn1.c $(obj)/x509-asn1.h
 $(obj)/x509_akid-asn1.o: $(obj)/x509_akid-asn1.c $(obj)/x509_akid-asn1.h
-$(obj)/x509_rsakey-asn1.o: $(obj)/x509_rsakey-asn1.c $(obj)/x509_rsakey-asn1.h
 
 clean-files	+= x509-asn1.c x509-asn1.h
 clean-files	+= x509_akid-asn1.c x509_akid-asn1.h
-clean-files	+= x509_rsakey-asn1.c x509_rsakey-asn1.h
 
 #
 # PKCS#7 message handling
crypto/asymmetric_keys/pkcs7_parser.c +5 -7
index 758acab..12912c1 100644
@@ -15,7 +15,7 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/oid_registry.h>
-#include "public_key.h"
+#include <crypto/public_key.h>
 #include "pkcs7_parser.h"
 #include "pkcs7-asn1.h"
 
@@ -44,7 +44,7 @@ struct pkcs7_parse_context {
 static void pkcs7_free_signed_info(struct pkcs7_signed_info *sinfo)
 {
 	if (sinfo) {
-		mpi_free(sinfo->sig.mpi[0]);
+		kfree(sinfo->sig.s);
 		kfree(sinfo->sig.digest);
 		kfree(sinfo->signing_cert_id);
 		kfree(sinfo);
@@ -616,16 +616,14 @@ int pkcs7_sig_note_signature(void *context, size_t hdrlen,
 			     const void *value, size_t vlen)
 {
 	struct pkcs7_parse_context *ctx = context;
-	MPI mpi;
 
 	BUG_ON(ctx->sinfo->sig.pkey_algo != PKEY_ALGO_RSA);
 
-	mpi = mpi_read_raw_data(value, vlen);
-	if (!mpi)
+	ctx->sinfo->sig.s = kmemdup(value, vlen, GFP_KERNEL);
+	if (!ctx->sinfo->sig.s)
 		return -ENOMEM;
 
-	ctx->sinfo->sig.mpi[0] = mpi;
-	ctx->sinfo->sig.nr_mpi = 1;
+	ctx->sinfo->sig.s_size = vlen;
 	return 0;
 }
 
crypto/asymmetric_keys/pkcs7_trust.c +1 -1
index 90d6d47..3bbdcc7 100644
@@ -17,7 +17,7 @@
 #include <linux/asn1.h>
 #include <linux/key.h>
 #include <keys/asymmetric-type.h>
-#include "public_key.h"
+#include <crypto/public_key.h>
 #include "pkcs7_parser.h"
 
 /**
crypto/asymmetric_keys/pkcs7_verify.c +1 -1
index 325575c..f5db137 100644
@@ -16,7 +16,7 @@
 #include <linux/err.h>
 #include <linux/asn1.h>
 #include <crypto/hash.h>
-#include "public_key.h"
+#include <crypto/public_key.h>
 #include "pkcs7_parser.h"
 
 /*
crypto/asymmetric_keys/public_key.c +22 -42

109 lines not on this page · raw message

crypto/asymmetric_keys/public_key.h deleted +0 -36
deleted file mode 100644
index 5c37a22..0000000
@@ -1,36 +0,0 @@
-/* Public key algorithm internals
- *
- * See Documentation/crypto/asymmetric-keys.txt
- *
- * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells ([email protected])
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public Licence
- * as published by the Free Software Foundation; either version
- * 2 of the Licence, or (at your option) any later version.
- */
-
-#include <crypto/public_key.h>
-
-extern struct asymmetric_key_subtype public_key_subtype;
-
-/*
- * Public key algorithm definition.
- */
-struct public_key_algorithm {
-	const char	*name;
-	u8		n_pub_mpi;	/* Number of MPIs in public key */
-	u8		n_sec_mpi;	/* Number of MPIs in secret key */
-	u8		n_sig_mpi;	/* Number of MPIs in a signature */
-	int (*verify_signature)(const struct public_key *key,
-				const struct public_key_signature *sig);
-};
-
-extern const struct public_key_algorithm RSA_public_key_algorithm;
-
-/*
- * public_key.c
- */
-extern int public_key_verify_signature(const struct public_key *pk,
-				       const struct public_key_signature *sig);
crypto/asymmetric_keys/rsa.c +79 -134

260 lines not on this page · raw message

crypto/asymmetric_keys/x509_cert_parser.c +7 -30
index 021d39c..7502029 100644
@@ -15,11 +15,10 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/oid_registry.h>
-#include "public_key.h"
+#include <crypto/public_key.h>
 #include "x509_parser.h"
 #include "x509-asn1.h"
 #include "x509_akid-asn1.h"
-#include "x509_rsakey-asn1.h"
 
 struct x509_parse_context {
 	struct x509_certificate	*cert;		/* Certificate being constructed */
@@ -56,7 +55,7 @@ void x509_free_certificate(struct x509_certificate *cert)
 		kfree(cert->akid_id);
 		kfree(cert->akid_skid);
 		kfree(cert->sig.digest);
-		mpi_free(cert->sig.rsa.s);
+		kfree(cert->sig.s);
 		kfree(cert);
 	}
 }
@@ -103,12 +102,12 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 		}
 	}
 
-	/* Decode the public key */
-	ret = asn1_ber_decoder(&x509_rsakey_decoder, ctx,
-			       ctx->key, ctx->key_size);
-	if (ret < 0)
+	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
+	if (!cert->pub->key)
 		goto error_decode;
 
+	cert->pub->keylen = ctx->key_size;
+
 	/* Generate cert issuer + serial number key ID */
 	kid = asymmetric_key_generate_id(cert->raw_serial,
 					 cert->raw_serial_size,
@@ -124,6 +123,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 	return cert;
 
 error_decode:
+	kfree(cert->pub->key);
 	kfree(ctx);
 error_no_ctx:
 	x509_free_certificate(cert);
@@ -404,29 +404,6 @@ int x509_extract_key_data(void *context, size_t hdrlen,
 	return 0;
 }
 
-/*
- * Extract a RSA public key value
- */
-int rsa_extract_mpi(void *context, size_t hdrlen,
-		    unsigned char tag,
-		    const void *value, size_t vlen)
-{
-	struct x509_parse_context *ctx = context;
-	MPI mpi;
-
-	if (ctx->nr_mpi >= ARRAY_SIZE(ctx->cert->pub->mpi)) {
-		pr_err("Too many public key MPIs in certificate\n");
-		return -EBADMSG;
-	}
-
-	mpi = mpi_read_raw_data(value, vlen);
-	if (!mpi)
-		return -ENOMEM;
-
-	ctx->cert->pub->mpi[ctx->nr_mpi++] = mpi;
-	return 0;
-}
-
 /* The keyIdentifier in AuthorityKeyIdentifier SEQUENCE is tag(CONT,PRIM,0) */
 #define SEQ_TAG_KEYID (ASN1_CONT << 6)
 
crypto/asymmetric_keys/x509_public_key.c +6 -11
index 2a44b37..2e18dfc 100644
@@ -13,15 +13,11 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/mpi.h>
-#include <linux/asn1_decoder.h>
 #include <keys/asymmetric-subtype.h>
 #include <keys/asymmetric-parser.h>
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
-#include "public_key.h"
 #include "x509_parser.h"
 
 static bool use_builtin_keys;
@@ -167,13 +163,15 @@ int x509_get_sig_params(struct x509_certificate *cert)
 
 	if (cert->unsupported_crypto)
 		return -ENOPKG;
-	if (cert->sig.rsa.s)
+	if (cert->sig.s)
 		return 0;
 
-	cert->sig.rsa.s = mpi_read_raw_data(cert->raw_sig, cert->raw_sig_size);
-	if (!cert->sig.rsa.s)
+	cert->sig.s = kmemdup(cert->raw_sig, cert->raw_sig_size,
+			      GFP_KERNEL);
+	if (!cert->sig.s)
 		return -ENOMEM;
-	cert->sig.nr_mpi = 1;
+
+	cert->sig.s_size = cert->raw_sig_size;
 
 	/* Allocate the hashing algorithm we're going to need and find out how
 	 * big the hash operational data will be.
@@ -296,8 +294,6 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
 	if (cert->pub->pkey_algo >= PKEY_ALGO__LAST ||
 	    cert->sig.pkey_algo >= PKEY_ALGO__LAST ||
 	    cert->sig.pkey_hash_algo >= PKEY_HASH__LAST ||
-	    !pkey_algo[cert->pub->pkey_algo] ||
-	    !pkey_algo[cert->sig.pkey_algo] ||
 	    !hash_algo_name[cert->sig.pkey_hash_algo]) {
 		ret = -ENOPKG;
 		goto error_free_cert;
@@ -309,7 +305,6 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
 		 pkey_algo_name[cert->sig.pkey_algo],
 		 hash_algo_name[cert->sig.pkey_hash_algo]);
 
-	cert->pub->algo = pkey_algo[cert->pub->pkey_algo];
 	cert->pub->id_type = PKEY_ID_X509;
 
 	/* Check the signature on the key if it appears to be self-signed */
crypto/asymmetric_keys/x509_rsakey.asn1 deleted +0 -4
deleted file mode 100644
index 4ec7cc6..0000000
@@ -1,4 +0,0 @@
-RSAPublicKey ::= SEQUENCE {
-	modulus			INTEGER ({ rsa_extract_mpi }),	-- n
-	publicExponent		INTEGER ({ rsa_extract_mpi })	-- e
-	}
include/crypto/public_key.h +12 -37

84 lines not on this page · raw message

#2 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

reproduce:

Hi Tadeusz,

[auto build test ERROR on crypto/master]
[also build test ERROR on v4.4-rc5 next-20151218]

url:    https://github.com/0day-ci/linux/commits/Tadeusz-Struk/crypto-KEYS-convert-public-key-to-akcipher-api/20151213-103429
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master
config: x86_64-randconfig-s4-12200710 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

In file included from include/crypto/public_key.h:17:0,

                    from include/linux/verify_pefile.h:15,
                    from arch/x86/kernel/kexec-bzimage64.c:22:
   include/keys/asymmetric-type.h: In function 'asymmetric_key_ids':
>> include/keys/asymmetric-type.h:74:12: error: dereferencing pointer to incomplete type 'const struct key'
     return key->payload.data[asym_key_ids];
               ^

vim +74 include/keys/asymmetric-type.h

7901c1a8 David Howells 2014-09-16  68  							    size_t len_1,
7901c1a8 David Howells 2014-09-16  69  							    const void *val_2,
7901c1a8 David Howells 2014-09-16  70  							    size_t len_2);
146aa8b1 David Howells 2015-10-21  71  static inline
146aa8b1 David Howells 2015-10-21  72  const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
146aa8b1 David Howells 2015-10-21  73  {
146aa8b1 David Howells 2015-10-21 @74  	return key->payload.data[asym_key_ids];
146aa8b1 David Howells 2015-10-21  75  }

7901c1a8 David Howells 2014-09-16 76
7901c1a8 David Howells 2014-09-16 77 /*

:::::: The code at line 74 was first introduced by commit
:::::: 146aa8b1453bd8f1ff2304ffb71b4ee0eb9acdcc KEYS: Merge the type-specific data with the payload data

:::::: TO: David Howells <[email protected]>
:::::: CC: David Howells <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

Quoted 32 lines · kbuild test robot

Hi Tadeusz,

[auto build test ERROR on crypto/master]
[also build test ERROR on v4.4-rc5 next-20151218]

url:    https://github.com/0day-ci/linux/commits/Tadeusz-Struk/crypto-KEYS-convert-public-key-to-akcipher-api/20151213-103429
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master
config: x86_64-randconfig-s4-12200710 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

In file included from include/crypto/public_key.h:17:0,

                    from include/linux/verify_pefile.h:15,
                    from arch/x86/kernel/kexec-bzimage64.c:22:

include/keys/asymmetric-type.h: In function 'asymmetric_key_ids':

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

include/keys/asymmetric-type.h:74:12: error: dereferencing pointer to incomplete type 'const struct key'

     return key->payload.data[asym_key_ids];
               ^

vim +74 include/keys/asymmetric-type.h

7901c1a8 David Howells 2014-09-16  68  							    size_t len_1,
7901c1a8 David Howells 2014-09-16  69  							    const void *val_2,
7901c1a8 David Howells 2014-09-16  70  							    size_t len_2);
146aa8b1 David Howells 2015-10-21  71  static inline
146aa8b1 David Howells 2015-10-21  72  const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
146aa8b1 David Howells 2015-10-21  73  {
146aa8b1 David Howells 2015-10-21 @74  	return key->payload.data[asym_key_ids];
146aa8b1 David Howells 2015-10-21  75  }
Quoted 8 lines

7901c1a8 David Howells 2014-09-16 76
7901c1a8 David Howells 2014-09-16 77 /*

:::::: The code at line 74 was first introduced by commit
:::::: 146aa8b1453bd8f1ff2304ffb71b4ee0eb9acdcc KEYS: Merge the type-specific data with the payload data

:::::: TO: David Howells <[email protected]>
:::::: CC: David Howells <[email protected]>

I think there is something missing in this configuration. cat .config | grep KEXEC_BZIMAGE_VERIFY_SIG gives nothing. Anyways, this patch should fix it.

---8<---

From: Tadeusz Struk <[email protected]>

Fix auto build test ERROR on crypto/master

(quoted diff) +0 -0

b/arch/x86/kernel/kexec-bzimage64.c
index 0f8a6bb..23aa625 100644

arch/x86/kernel/kexec-bzimage64.c +0 -0
@@ -19,9 +19,10 @@

#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/efi.h>
+#ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG
#include <linux/verify_pefile.h>
#include <keys/system_keyring.h>
-
+#endif
#include <asm/bootparam.h>
#include <asm/setup.h>
#include <asm/crash.h>

#4 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

In reply to kbuild test robot

Hi,

Quoted 32 lines · kbuild test robot

Hi Tadeusz,

[auto build test ERROR on crypto/master]
[also build test ERROR on v4.4-rc5 next-20151218]

url:    https://github.com/0day-ci/linux/commits/Tadeusz-Struk/crypto-KEYS-convert-public-key-to-akcipher-api/20151213-103429
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master
config: x86_64-randconfig-s4-12200710 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

In file included from include/crypto/public_key.h:17:0,

                    from include/linux/verify_pefile.h:15,
                    from arch/x86/kernel/kexec-bzimage64.c:22:

include/keys/asymmetric-type.h: In function 'asymmetric_key_ids':

Quoted 1 line
Quoted 1 line

include/keys/asymmetric-type.h:74:12: error: dereferencing pointer to incomplete type 'const struct key'

     return key->payload.data[asym_key_ids];
               ^

vim +74 include/keys/asymmetric-type.h

7901c1a8 David Howells 2014-09-16  68  							    size_t len_1,
7901c1a8 David Howells 2014-09-16  69  							    const void *val_2,
7901c1a8 David Howells 2014-09-16  70  							    size_t len_2);
146aa8b1 David Howells 2015-10-21  71  static inline
146aa8b1 David Howells 2015-10-21  72  const struct asymmetric_key_ids *asymmetric_key_ids(const struct key *key)
146aa8b1 David Howells 2015-10-21  73  {
146aa8b1 David Howells 2015-10-21 @74  	return key->payload.data[asym_key_ids];
146aa8b1 David Howells 2015-10-21  75  }
Quoted 9 lines

7901c1a8 David Howells 2014-09-16 76
7901c1a8 David Howells 2014-09-16 77 /*

:::::: The code at line 74 was first introduced by commit
:::::: 146aa8b1453bd8f1ff2304ffb71b4ee0eb9acdcc KEYS: Merge the type-specific data with the payload data

:::::: TO: David Howells <[email protected]>
:::::: CC: David Howells <[email protected]>

The previous patch was broken, re-sending again, sorry.

I think there is something missing in this configuration. cat .config | grep KEXEC_BZIMAGE_VERIFY_SIG gives nothing. Anyways, this patch should fix it.

---8<---

From: Tadeusz Struk <[email protected]>

Fix auto build test ERROR on crypto/master

(quoted diff) +0 -0

b/arch/x86/kernel/kexec-bzimage64.c
index 0f8a6bb..23aa625 100644

arch/x86/kernel/kexec-bzimage64.c +2 -1
@@ -19,9 +19,10 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/efi.h>
+#ifdef CONFIG_KEXEC_BZIMAGE_VERIFY_SIG
 #include <linux/verify_pefile.h>
 #include <keys/system_keyring.h>
-
+#endif
 #include <asm/bootparam.h>
 #include <asm/setup.h>
 #include <asm/crash.h>
maintainer
#5 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

Quoted 6 lines · Tadeusz Struk

The previous patch was broken, re-sending again, sorry.

I think there is something missing in this configuration. cat .config | grep KEXEC_BZIMAGE_VERIFY_SIG gives nothing. Anyways, this patch should fix it.

No this is unacceptable. Please fix it properly by making the header file self-contained, e.g., by using a forward declaration.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#6 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

Hi Herbert

Quoted 10 lines · Herbert Xu
Quoted 6 lines · Tadeusz Struk

The previous patch was broken, re-sending again, sorry.

I think there is something missing in this configuration. cat .config | grep KEXEC_BZIMAGE_VERIFY_SIG gives nothing. Anyways, this patch should fix it.

No this is unacceptable. Please fix it properly by making the header file self-contained, e.g., by using a forward declaration.

What about the first two. This one is completely unrelated. It only supposed to fix some random configuration issue reported by a build robot, which isn't really important now. The other two convert the module verifier to the new API. Thanks,

Signature · 1 line
TS
maintainer
#7 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

Quoted 5 lines · Tadeusz Struk

What about the first two. This one is completely unrelated. It only supposed to fix some random configuration issue reported by a build robot, which isn't really important now. The other two convert the module verifier to the new API.

No this compile breakage was introduced by your first two patches because you changed crypto/public_key.h which is used by entities outside of your patch.

So fix your first two patches by not breaking existing users of it.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#8 lore raw

Re: [PATCH v2 1/2] crypto: KEYS: convert public key to the akcipher api

Quoted 10 lines · Herbert Xu
Quoted 4 lines

What about the first two. This one is completely unrelated.

Quoted 3 lines

It only supposed to fix some random configuration issue reported by a build robot, which isn't really important now. The other two convert the module verifier to the new API.

No this compile breakage was introduced by your first two patches because you changed crypto/public_key.h which is used by entities outside of your patch.

So fix your first two patches by not breaking existing users of it.

Ok I can see the problem now. I just don't should not include the asymmetric-type.h in the public_key.h and it fixes it. Will send v3 soon.
Thanks,

Signature · 1 line
TS
#9 lore raw

PATCH v2 2/2 integrity: convert digsig to akcipher api

In reply to Tadeusz Struk

Convert asymmetric_verify to akcipher api.

---
 security/integrity/Kconfig             |    1 +
 security/integrity/digsig_asymmetric.c |   10 +++-------
 2 files changed, 4 insertions(+), 7 deletions(-)
security/integrity/Kconfig +1 -0
index 73c457b..f0b2463 100644
@@ -36,6 +36,7 @@ config INTEGRITY_ASYMMETRIC_KEYS
         select ASYMMETRIC_KEY_TYPE
         select ASYMMETRIC_PUBLIC_KEY_SUBTYPE
         select PUBLIC_KEY_ALGO_RSA
+        select CRYPTO_RSA
         select X509_CERTIFICATE_PARSER
 	help
 	  This option enables digital signature verification using
security/integrity/digsig_asymmetric.c +3 -7
index 4fec181..5629372 100644
@@ -92,13 +92,9 @@ int asymmetric_verify(struct key *keyring, const char *sig,
 	pks.pkey_hash_algo = hdr->hash_algo;
 	pks.digest = (u8 *)data;
 	pks.digest_size = datalen;
-	pks.nr_mpi = 1;
-	pks.rsa.s = mpi_read_raw_data(hdr->sig, siglen);
-
-	if (pks.rsa.s)
-		ret = verify_signature(key, &pks);
-
-	mpi_free(pks.rsa.s);
+	pks.s = hdr->sig;
+	pks.s_size = siglen;
+	ret = verify_signature(key, &pks);
 	key_put(key);
 	pr_debug("%s() = %d\n", __func__, ret);
 	return ret;
#10 lore raw

Re: [PATCH v2 2/2] integrity: convert digsig to akcipher api

Quoted 26 lines · Tadeusz Struk

Convert asymmetric_verify to akcipher api.

---
 security/integrity/Kconfig             |    1 +
 security/integrity/digsig_asymmetric.c |   10 +++-------
 2 files changed, 4 insertions(+), 7 deletions(-)
security/integrity/Kconfig +1 -0
index 73c457b..f0b2463 100644
@@ -36,6 +36,7 @@ config INTEGRITY_ASYMMETRIC_KEYS
         select ASYMMETRIC_KEY_TYPE
         select ASYMMETRIC_PUBLIC_KEY_SUBTYPE
         select PUBLIC_KEY_ALGO_RSA
+        select CRYPTO_RSA
         select X509_CERTIFICATE_PARSER
 	help
 	  This option enables digital signature verification using
security/integrity/digsig_asymmetric.c +0 -0
index 4fec181..5629372 100644
@@ -92,13 +92,9 @@ int asymmetric_verify(struct key *keyring, const char *sig,
 	pks.pkey_hash_algo = hdr->hash_algo;

security/integrity/digsig_asymmetric.c int asymmetric_verify(struct key *keyring, const char *sig, · line 95

Quoted 10 lines
security/integrity/digsig_asymmetric.c +1 -7
 	pks.digest = (u8 *)data;
 	pks.digest_size = datalen;
-	pks.nr_mpi = 1;
-	pks.rsa.s = mpi_read_raw_data(hdr->sig, siglen);
-
-	if (pks.rsa.s)
-		ret = verify_signature(key, &pks);
-
-	mpi_free(pks.rsa.s);
+	pks.s = hdr->sig;

Thanks! With this change, my system is now able to boot.

Mimi

Quoted 5 lines
security/integrity/digsig_asymmetric.c +2 -0
+	pks.s_size = siglen;
+	ret = verify_signature(key, &pks);
 	key_put(key);
 	pr_debug("%s() = %d\n", __func__, ret);
 	return ret;
#11 lore raw

Re: [PATCH v2 2/2] integrity: convert digsig to akcipher api

Quoted 31 lines · Mimi Zohar
Quoted 30 lines · Tadeusz Struk

Convert asymmetric_verify to akcipher api.

---
 security/integrity/Kconfig             |    1 +
 security/integrity/digsig_asymmetric.c |   10 +++-------
 2 files changed, 4 insertions(+), 7 deletions(-)
security/integrity/Kconfig +1 -0
index 73c457b..f0b2463 100644
@@ -36,6 +36,7 @@ config INTEGRITY_ASYMMETRIC_KEYS
         select ASYMMETRIC_KEY_TYPE
         select ASYMMETRIC_PUBLIC_KEY_SUBTYPE
         select PUBLIC_KEY_ALGO_RSA
+        select CRYPTO_RSA
         select X509_CERTIFICATE_PARSER
 	help
 	  This option enables digital signature verification using
security/integrity/digsig_asymmetric.c +0 -2
index 4fec181..5629372 100644
@@ -92,13 +92,9 @@ int asymmetric_verify(struct key *keyring, const char *sig,
 	pks.pkey_hash_algo = hdr->hash_algo;
 	pks.digest = (u8 *)data;
 	pks.digest_size = datalen;
-	pks.nr_mpi = 1;
-	pks.rsa.s = mpi_read_raw_data(hdr->sig, siglen);
Quoted 9 lines

security/integrity/digsig_asymmetric.c int asymmetric_verify(struct key *keyring, const char *sig, · line 95

Quoted 6 lines
security/integrity/digsig_asymmetric.c +1 -5
-
-	if (pks.rsa.s)
-		ret = verify_signature(key, &pks);
-
-	mpi_free(pks.rsa.s);
+	pks.s = hdr->sig;

Thanks! With this change, my system is now able to boot.

Thanks Mimi.

David, do you have any comments to this patch set? If not could you ACK please. Thanks,

Signature · 1 line
TS