Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-05 Thread Tadeusz Struk
On 06/05/2015 01:50 AM, Paul Bolle wrote:
> This builds two modules if PUBLIC_KEY_ALGO_RSA = 'm': rsa.ko and
> rsa_pkcs1_v1_5.ko. Is that what you want?

No, this not what I wanted.

> 
> public_key.c uses this, so it can end up in public_key.ko. But it's not
> exported. So a _quick and dirty_ build test generated:
> WARNING: "rsa_pkcs1_v1_5_verify_signature" 
> [[...]/crypto/asymmetric_keys/public_key.ko] undefined!
> 
> Also no MODULE_LICENSE() macro, so loading rsa_pkcs1_v1_5.ko should
> trigger a warning and taint the kernel.

Thank you Paul for taking the time to review the patches and for your feedback.
I'll have to change this again based on Herbert's feedback so this 
rsa_pkcs1_v1_5.c file
will go away anyway.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-05 Thread Paul Bolle
A few remarks, perhaps not of the kind you'd like for an RFC, that I
hope are still relevant after Herbert's comment.

On Wed, 2015-06-03 at 15:44 -0700, Tadeusz Struk wrote:
> --- a/crypto/asymmetric_keys/Makefile
> +++ b/crypto/asymmetric_keys/Makefile
> @@ -8,6 +8,7 @@ asymmetric_keys-y := asymmetric_type.o signature.o
>  
>  obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
>  obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa.o
> +obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa_pkcs1_v1_5.o

This builds two modules if PUBLIC_KEY_ALGO_RSA = 'm': rsa.ko and
rsa_pkcs1_v1_5.ko. Is that what you want?
 
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c

> +int rsa_pkcs1_v1_5_verify_signature(const struct public_key *pkey,
> + const struct public_key_signature *sig);
> +

> -int public_key_verify_signature(const struct public_key *pk,
> +int public_key_verify_signature(const struct public_key *pkey,
>   const struct public_key_signature *sig)
>  {
> [...]
> - return algo->verify_signature(pk, sig);
> + return rsa_pkcs1_v1_5_verify_signature(pkey, sig);
>  }


> --- a/crypto/asymmetric_keys/rsa.c
> +++ b/crypto/asymmetric_keys/rsa.c
 
>  MODULE_LICENSE("GPL");
>  MODULE_DESCRIPTION("RSA Public Key Algorithm");

> +static int rsa_init(void)
> +{
> + return crypto_register_akcipher();
> +}

Is there a reason not to mark this __init? (This is not a rhetorical
question, perhaps there really is.)

> +static void rsa_exit(void)
> +{
> + crypto_unregister_akcipher();
> +}

Ditto for __exit.

> +module_init(rsa_init);
> +module_exit(rsa_exit);
> +MODULE_ALIAS_CRYPTO("rsa");

Could the MODULE_* macros be grouped in one place please?

> --- /dev/null
> +++ b/crypto/asymmetric_keys/rsa_pkcs1_v1_5.c

> +/*
> + * Perform the verification step [RFC3447 sec 8.2.2].
> + */
> +int rsa_pkcs1_v1_5_verify_signature(const struct public_key *pkey,
> + const struct public_key_signature *sig)
> +{
> [...]
> +}

public_key.c uses this, so it can end up in public_key.ko. But it's not
exported. So a _quick and dirty_ build test generated:
WARNING: "rsa_pkcs1_v1_5_verify_signature" 
[[...]/crypto/asymmetric_keys/public_key.ko] undefined!

Also no MODULE_LICENSE() macro, so loading rsa_pkcs1_v1_5.ko should
trigger a warning and taint the kernel.

Thanks,


Paul Bolle

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-05 Thread Paul Bolle
A few remarks, perhaps not of the kind you'd like for an RFC, that I
hope are still relevant after Herbert's comment.

On Wed, 2015-06-03 at 15:44 -0700, Tadeusz Struk wrote:
 --- a/crypto/asymmetric_keys/Makefile
 +++ b/crypto/asymmetric_keys/Makefile
 @@ -8,6 +8,7 @@ asymmetric_keys-y := asymmetric_type.o signature.o
  
  obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
  obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa.o
 +obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa_pkcs1_v1_5.o

This builds two modules if PUBLIC_KEY_ALGO_RSA = 'm': rsa.ko and
rsa_pkcs1_v1_5.ko. Is that what you want?
 
 --- a/crypto/asymmetric_keys/public_key.c
 +++ b/crypto/asymmetric_keys/public_key.c

 +int rsa_pkcs1_v1_5_verify_signature(const struct public_key *pkey,
 + const struct public_key_signature *sig);
 +

 -int public_key_verify_signature(const struct public_key *pk,
 +int public_key_verify_signature(const struct public_key *pkey,
   const struct public_key_signature *sig)
  {
 [...]
 - return algo-verify_signature(pk, sig);
 + return rsa_pkcs1_v1_5_verify_signature(pkey, sig);
  }


 --- a/crypto/asymmetric_keys/rsa.c
 +++ b/crypto/asymmetric_keys/rsa.c
 
  MODULE_LICENSE(GPL);
  MODULE_DESCRIPTION(RSA Public Key Algorithm);

 +static int rsa_init(void)
 +{
 + return crypto_register_akcipher(rsa);
 +}

Is there a reason not to mark this __init? (This is not a rhetorical
question, perhaps there really is.)

 +static void rsa_exit(void)
 +{
 + crypto_unregister_akcipher(rsa);
 +}

Ditto for __exit.

 +module_init(rsa_init);
 +module_exit(rsa_exit);
 +MODULE_ALIAS_CRYPTO(rsa);

Could the MODULE_* macros be grouped in one place please?

 --- /dev/null
 +++ b/crypto/asymmetric_keys/rsa_pkcs1_v1_5.c

 +/*
 + * Perform the verification step [RFC3447 sec 8.2.2].
 + */
 +int rsa_pkcs1_v1_5_verify_signature(const struct public_key *pkey,
 + const struct public_key_signature *sig)
 +{
 [...]
 +}

public_key.c uses this, so it can end up in public_key.ko. But it's not
exported. So a _quick and dirty_ build test generated:
WARNING: rsa_pkcs1_v1_5_verify_signature 
[[...]/crypto/asymmetric_keys/public_key.ko] undefined!

Also no MODULE_LICENSE() macro, so loading rsa_pkcs1_v1_5.ko should
trigger a warning and taint the kernel.

Thanks,


Paul Bolle

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-05 Thread Tadeusz Struk
On 06/05/2015 01:50 AM, Paul Bolle wrote:
 This builds two modules if PUBLIC_KEY_ALGO_RSA = 'm': rsa.ko and
 rsa_pkcs1_v1_5.ko. Is that what you want?

No, this not what I wanted.

 
 public_key.c uses this, so it can end up in public_key.ko. But it's not
 exported. So a _quick and dirty_ build test generated:
 WARNING: rsa_pkcs1_v1_5_verify_signature 
 [[...]/crypto/asymmetric_keys/public_key.ko] undefined!
 
 Also no MODULE_LICENSE() macro, so loading rsa_pkcs1_v1_5.ko should
 trigger a warning and taint the kernel.

Thank you Paul for taking the time to review the patches and for your feedback.
I'll have to change this again based on Herbert's feedback so this 
rsa_pkcs1_v1_5.c file
will go away anyway.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-04 Thread Tadeusz Struk
On 06/03/2015 11:53 PM, Herbert Xu wrote:
> I'd like to see this split into multiple patches.  First of all
> the new crypto_akcipher implementation should coexist with the
> existing code.  That way the exiting users can be converted over
> one-by-one.
> 
> Also you should implement the crypto_akcipher completely before
> converting anybody over, that means doing encoding/wrapping in
> addition to the crypto.
> 
> That way we don't have to have craziness like converting in and
> out of MPI multiple times.

That's cool. It will make it easier for me. I wanted to convert
one to show that the interface is working.

> 
> Lastly you should consider adding an MPI helper that writes to
> an existing buffer instead of allocating a new one and copying
> it over.

I'll think about something.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-04 Thread Herbert Xu
On Wed, Jun 03, 2015 at 03:44:14PM -0700, Tadeusz Struk wrote:
> Change the existing rsa and public key code to integrate it
> with the new Public Key Encryption API.
> 
> Signed-off-by: Tadeusz Struk 

I'd like to see this split into multiple patches.  First of all
the new crypto_akcipher implementation should coexist with the
existing code.  That way the exiting users can be converted over
one-by-one.

Also you should implement the crypto_akcipher completely before
converting anybody over, that means doing encoding/wrapping in
addition to the crypto.

That way we don't have to have craziness like converting in and
out of MPI multiple times.

Lastly you should consider adding an MPI helper that writes to
an existing buffer instead of allocating a new one and copying
it over.

Thanks,
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-04 Thread Tadeusz Struk
On 06/03/2015 11:53 PM, Herbert Xu wrote:
 I'd like to see this split into multiple patches.  First of all
 the new crypto_akcipher implementation should coexist with the
 existing code.  That way the exiting users can be converted over
 one-by-one.
 
 Also you should implement the crypto_akcipher completely before
 converting anybody over, that means doing encoding/wrapping in
 addition to the crypto.
 
 That way we don't have to have craziness like converting in and
 out of MPI multiple times.

That's cool. It will make it easier for me. I wanted to convert
one to show that the interface is working.

 
 Lastly you should consider adding an MPI helper that writes to
 an existing buffer instead of allocating a new one and copying
 it over.

I'll think about something.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-04 Thread Herbert Xu
On Wed, Jun 03, 2015 at 03:44:14PM -0700, Tadeusz Struk wrote:
 Change the existing rsa and public key code to integrate it
 with the new Public Key Encryption API.
 
 Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com

I'd like to see this split into multiple patches.  First of all
the new crypto_akcipher implementation should coexist with the
existing code.  That way the exiting users can be converted over
one-by-one.

Also you should implement the crypto_akcipher completely before
converting anybody over, that means doing encoding/wrapping in
addition to the crypto.

That way we don't have to have craziness like converting in and
out of MPI multiple times.

Lastly you should consider adding an MPI helper that writes to
an existing buffer instead of allocating a new one and copying
it over.

Thanks,
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-03 Thread Tadeusz Struk
Change the existing rsa and public key code to integrate it
with the new Public Key Encryption API.

Signed-off-by: Tadeusz Struk 
---
 crypto/asymmetric_keys/Kconfig|1 
 crypto/asymmetric_keys/Makefile   |1 
 crypto/asymmetric_keys/pkcs7_parser.c |2 
 crypto/asymmetric_keys/pkcs7_trust.c  |2 
 crypto/asymmetric_keys/pkcs7_verify.c |2 
 crypto/asymmetric_keys/public_key.c   |   53 +--
 crypto/asymmetric_keys/public_key.h   |   36 --
 crypto/asymmetric_keys/rsa.c  |  467 -
 crypto/asymmetric_keys/rsa_pkcs1_v1_5.c   |  259 
 crypto/asymmetric_keys/x509_cert_parser.c |2 
 crypto/asymmetric_keys/x509_public_key.c  |4 
 include/crypto/public_key.h   |   11 -
 12 files changed, 540 insertions(+), 300 deletions(-)
 delete mode 100644 crypto/asymmetric_keys/public_key.h
 create mode 100644 crypto/asymmetric_keys/rsa_pkcs1_v1_5.c

diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig
index 4870f28..4d27116 100644
--- a/crypto/asymmetric_keys/Kconfig
+++ b/crypto/asymmetric_keys/Kconfig
@@ -23,6 +23,7 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
 config PUBLIC_KEY_ALGO_RSA
tristate "RSA public-key algorithm"
select MPILIB
+   select CRYPTO_AKCIPHER
help
  This option enables support for the RSA algorithm (PKCS#1, RFC3447).
 
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index e47fcd9..a9cb1b8 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -8,6 +8,7 @@ asymmetric_keys-y := asymmetric_type.o signature.o
 
 obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
 obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa.o
+obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa_pkcs1_v1_5.o
 
 #
 # X.509 Certificate handling
diff --git a/crypto/asymmetric_keys/pkcs7_parser.c 
b/crypto/asymmetric_keys/pkcs7_parser.c
index 3bd5a1e..054f110 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -15,7 +15,7 @@
 #include 
 #include 
 #include 
-#include "public_key.h"
+#include 
 #include "pkcs7_parser.h"
 #include "pkcs7-asn1.h"
 
diff --git a/crypto/asymmetric_keys/pkcs7_trust.c 
b/crypto/asymmetric_keys/pkcs7_trust.c
index 1d29376..68ebae2 100644
--- a/crypto/asymmetric_keys/pkcs7_trust.c
+++ b/crypto/asymmetric_keys/pkcs7_trust.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 #include 
-#include "public_key.h"
+#include 
 #include "pkcs7_parser.h"
 
 /**
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c 
b/crypto/asymmetric_keys/pkcs7_verify.c
index cd45545..c32a337 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -16,7 +16,7 @@
 #include 
 #include 
 #include 
-#include "public_key.h"
+#include 
 #include "pkcs7_parser.h"
 
 /*
diff --git a/crypto/asymmetric_keys/public_key.c 
b/crypto/asymmetric_keys/public_key.c
index 2f6e4fb..4685aed 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -18,30 +18,26 @@
 #include 
 #include 
 #include 
-#include "public_key.h"
+#include 
+#include 
 
 MODULE_LICENSE("GPL");
 
 const char *const pkey_algo_name[PKEY_ALGO__LAST] = {
-   [PKEY_ALGO_DSA] = "DSA",
-   [PKEY_ALGO_RSA] = "RSA",
+   [PKEY_ALGO_DSA] = "dsa",
+   [PKEY_ALGO_RSA] = "rsa",
 };
 EXPORT_SYMBOL_GPL(pkey_algo_name);
 
-const struct public_key_algorithm *pkey_algo[PKEY_ALGO__LAST] = {
-#if defined(CONFIG_PUBLIC_KEY_ALGO_RSA) || \
-   defined(CONFIG_PUBLIC_KEY_ALGO_RSA_MODULE)
-   [PKEY_ALGO_RSA] = _public_key_algorithm,
-#endif
-};
-EXPORT_SYMBOL_GPL(pkey_algo);
-
 const char *const pkey_id_type_name[PKEY_ID_TYPE__LAST] = {
[PKEY_ID_PGP]   = "PGP",
[PKEY_ID_X509]  = "X509",
 };
 EXPORT_SYMBOL_GPL(pkey_id_type_name);
 
+int rsa_pkcs1_v1_5_verify_signature(const struct public_key *pkey,
+   const struct public_key_signature *sig);
+
 /*
  * Provide a part of a description of the key for /proc/keys.
  */
@@ -52,7 +48,8 @@ static void public_key_describe(const struct key 
*asymmetric_key,
 
if (key)
seq_printf(m, "%s.%s",
-  pkey_id_type_name[key->id_type], key->algo->name);
+  pkey_id_type_name[key->id_type],
+  pkey_algo_name[key->pkey_algo]);
 }
 
 /*
@@ -74,37 +71,20 @@ EXPORT_SYMBOL_GPL(public_key_destroy);
 /*
  * Verify a signature using a public key.
  */
-int public_key_verify_signature(const struct public_key *pk,
+int public_key_verify_signature(const struct public_key *pkey,
const struct public_key_signature *sig)
 {
-   const struct public_key_algorithm *algo;
-
-   BUG_ON(!pk);
-   BUG_ON(!pk->mpi[0]);
-   BUG_ON(!pk->mpi[1]);
+   BUG_ON(!pkey);
+   BUG_ON(!pkey->mpi[0]);
+ 

[PATCH RFC v3 2/3] crypto: RSA: KEYS: convert rsa and public key to new PKE API

2015-06-03 Thread Tadeusz Struk
Change the existing rsa and public key code to integrate it
with the new Public Key Encryption API.

Signed-off-by: Tadeusz Struk tadeusz.st...@intel.com
---
 crypto/asymmetric_keys/Kconfig|1 
 crypto/asymmetric_keys/Makefile   |1 
 crypto/asymmetric_keys/pkcs7_parser.c |2 
 crypto/asymmetric_keys/pkcs7_trust.c  |2 
 crypto/asymmetric_keys/pkcs7_verify.c |2 
 crypto/asymmetric_keys/public_key.c   |   53 +--
 crypto/asymmetric_keys/public_key.h   |   36 --
 crypto/asymmetric_keys/rsa.c  |  467 -
 crypto/asymmetric_keys/rsa_pkcs1_v1_5.c   |  259 
 crypto/asymmetric_keys/x509_cert_parser.c |2 
 crypto/asymmetric_keys/x509_public_key.c  |4 
 include/crypto/public_key.h   |   11 -
 12 files changed, 540 insertions(+), 300 deletions(-)
 delete mode 100644 crypto/asymmetric_keys/public_key.h
 create mode 100644 crypto/asymmetric_keys/rsa_pkcs1_v1_5.c

diff --git a/crypto/asymmetric_keys/Kconfig b/crypto/asymmetric_keys/Kconfig
index 4870f28..4d27116 100644
--- a/crypto/asymmetric_keys/Kconfig
+++ b/crypto/asymmetric_keys/Kconfig
@@ -23,6 +23,7 @@ config ASYMMETRIC_PUBLIC_KEY_SUBTYPE
 config PUBLIC_KEY_ALGO_RSA
tristate RSA public-key algorithm
select MPILIB
+   select CRYPTO_AKCIPHER
help
  This option enables support for the RSA algorithm (PKCS#1, RFC3447).
 
diff --git a/crypto/asymmetric_keys/Makefile b/crypto/asymmetric_keys/Makefile
index e47fcd9..a9cb1b8 100644
--- a/crypto/asymmetric_keys/Makefile
+++ b/crypto/asymmetric_keys/Makefile
@@ -8,6 +8,7 @@ asymmetric_keys-y := asymmetric_type.o signature.o
 
 obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += public_key.o
 obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa.o
+obj-$(CONFIG_PUBLIC_KEY_ALGO_RSA) += rsa_pkcs1_v1_5.o
 
 #
 # X.509 Certificate handling
diff --git a/crypto/asymmetric_keys/pkcs7_parser.c 
b/crypto/asymmetric_keys/pkcs7_parser.c
index 3bd5a1e..054f110 100644
--- a/crypto/asymmetric_keys/pkcs7_parser.c
+++ b/crypto/asymmetric_keys/pkcs7_parser.c
@@ -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
 
diff --git a/crypto/asymmetric_keys/pkcs7_trust.c 
b/crypto/asymmetric_keys/pkcs7_trust.c
index 1d29376..68ebae2 100644
--- a/crypto/asymmetric_keys/pkcs7_trust.c
+++ b/crypto/asymmetric_keys/pkcs7_trust.c
@@ -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
 
 /**
diff --git a/crypto/asymmetric_keys/pkcs7_verify.c 
b/crypto/asymmetric_keys/pkcs7_verify.c
index cd45545..c32a337 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -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
 
 /*
diff --git a/crypto/asymmetric_keys/public_key.c 
b/crypto/asymmetric_keys/public_key.c
index 2f6e4fb..4685aed 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -18,30 +18,26 @@
 #include linux/slab.h
 #include linux/seq_file.h
 #include keys/asymmetric-subtype.h
-#include public_key.h
+#include crypto/public_key.h
+#include crypto/akcipher.h
 
 MODULE_LICENSE(GPL);
 
 const char *const pkey_algo_name[PKEY_ALGO__LAST] = {
-   [PKEY_ALGO_DSA] = DSA,
-   [PKEY_ALGO_RSA] = RSA,
+   [PKEY_ALGO_DSA] = dsa,
+   [PKEY_ALGO_RSA] = rsa,
 };
 EXPORT_SYMBOL_GPL(pkey_algo_name);
 
-const struct public_key_algorithm *pkey_algo[PKEY_ALGO__LAST] = {
-#if defined(CONFIG_PUBLIC_KEY_ALGO_RSA) || \
-   defined(CONFIG_PUBLIC_KEY_ALGO_RSA_MODULE)
-   [PKEY_ALGO_RSA] = RSA_public_key_algorithm,
-#endif
-};
-EXPORT_SYMBOL_GPL(pkey_algo);
-
 const char *const pkey_id_type_name[PKEY_ID_TYPE__LAST] = {
[PKEY_ID_PGP]   = PGP,
[PKEY_ID_X509]  = X509,
 };
 EXPORT_SYMBOL_GPL(pkey_id_type_name);
 
+int rsa_pkcs1_v1_5_verify_signature(const struct public_key *pkey,
+   const struct public_key_signature *sig);
+
 /*
  * Provide a part of a description of the key for /proc/keys.
  */
@@ -52,7 +48,8 @@ static void public_key_describe(const struct key 
*asymmetric_key,
 
if (key)
seq_printf(m, %s.%s,
-  pkey_id_type_name[key-id_type], key-algo-name);
+  pkey_id_type_name[key-id_type],
+  pkey_algo_name[key-pkey_algo]);
 }
 
 /*
@@ -74,37 +71,20 @@ EXPORT_SYMBOL_GPL(public_key_destroy);
 /*
  * Verify a signature using a public key.
  */
-int public_key_verify_signature(const struct public_key *pk,
+int public_key_verify_signature(const struct public_key *pkey,