[PATCH 8/8] X.509: Rename public_key* to software_pkey*

From: David Howells
Date: Fri Feb 19 2016 - 12:20:22 EST


Rename symbols beginning with "public_key" to symbols beginning with
"software_pkey" to reflect that this is the software implementation private
data rather than the only possible asymmetric key subtype that does public
key handling.

Note that struct public_key_signature is left unrenamed as that's a more
general feature.

Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---

crypto/asymmetric_keys/pkcs7_verify.c | 2 +
crypto/asymmetric_keys/software_pkey.c | 48 +++++++++++++++--------------
crypto/asymmetric_keys/software_pkey.h | 10 +++---
crypto/asymmetric_keys/x509_cert_parser.c | 4 +-
crypto/asymmetric_keys/x509_parser.h | 4 +-
crypto/asymmetric_keys/x509_public_key.c | 8 ++---
6 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index 6aad267f19bb..3828e801e003 100644
--- a/crypto/asymmetric_keys/pkcs7_verify.c
+++ b/crypto/asymmetric_keys/pkcs7_verify.c
@@ -332,7 +332,7 @@ static int pkcs7_verify_one(struct pkcs7_message *pkcs7,
}

/* Verify the PKCS#7 binary against the key */
- ret = public_key_verify_signature(sinfo->signer->pub, &sinfo->sig);
+ ret = software_pkey_verify_signature(sinfo->signer->pub, &sinfo->sig);
if (ret < 0)
return ret;

diff --git a/crypto/asymmetric_keys/software_pkey.c b/crypto/asymmetric_keys/software_pkey.c
index 3024081026c1..8732a41b1001 100644
--- a/crypto/asymmetric_keys/software_pkey.c
+++ b/crypto/asymmetric_keys/software_pkey.c
@@ -27,10 +27,10 @@ MODULE_LICENSE("GPL");
/*
* Provide a part of a description of the key for /proc/keys.
*/
-static void public_key_describe(const struct key *asymmetric_key,
+static void software_pkey_describe(const struct key *asymmetric_key,
struct seq_file *m)
{
- struct public_key *key = asymmetric_key->payload.data[asym_crypto];
+ struct software_pkey *key = asymmetric_key->payload.data[asym_crypto];

if (key)
seq_printf(m, "%s.%s", key->id_type, key->pkey_algo);
@@ -39,24 +39,24 @@ static void public_key_describe(const struct key *asymmetric_key,
/*
* Destroy a public key algorithm key.
*/
-void public_key_destroy(void *payload)
+void software_pkey_destroy(void *payload)
{
- struct public_key *key = payload;
+ struct software_pkey *key = payload;

if (key)
kfree(key->key);
kfree(key);
}
-EXPORT_SYMBOL_GPL(public_key_destroy);
+EXPORT_SYMBOL_GPL(software_pkey_destroy);

-struct public_key_completion {
+struct software_pkey_completion {
struct completion completion;
int err;
};

-static void public_key_verify_done(struct crypto_async_request *req, int err)
+static void software_pkey_verify_done(struct crypto_async_request *req, int err)
{
- struct public_key_completion *compl = req->data;
+ struct software_pkey_completion *compl = req->data;

if (err == -EINPROGRESS)
return;
@@ -68,10 +68,10 @@ static void public_key_verify_done(struct crypto_async_request *req, int err)
/*
* Verify a signature using a public key.
*/
-int public_key_verify_signature(const struct public_key *pkey,
- const struct public_key_signature *sig)
+int software_pkey_verify_signature(const struct software_pkey *pkey,
+ const struct public_key_signature *sig)
{
- struct public_key_completion compl;
+ struct software_pkey_completion compl;
struct crypto_akcipher *tfm;
struct akcipher_request *req;
struct scatterlist sig_sg, digest_sg;
@@ -104,7 +104,7 @@ int public_key_verify_signature(const struct public_key *pkey,
init_completion(&compl.completion);
akcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG |
CRYPTO_TFM_REQ_MAY_SLEEP,
- public_key_verify_done, &compl);
+ software_pkey_verify_done, &compl);

ret = crypto_akcipher_verify(req);
if (ret == -EINPROGRESS) {
@@ -119,24 +119,24 @@ error_free_tfm:
pr_devel("<==%s() = %d\n", __func__, ret);
return ret;
}
-EXPORT_SYMBOL_GPL(public_key_verify_signature);
+EXPORT_SYMBOL_GPL(software_pkey_verify_signature);

-static int public_key_verify_signature_2(const struct key *key,
- const struct public_key_signature *sig)
+static int software_pkey_verify_signature_2(const struct key *key,
+ const struct public_key_signature *sig)
{
- const struct public_key *pk = key->payload.data[asym_crypto];
- return public_key_verify_signature(pk, sig);
+ const struct software_pkey *pk = key->payload.data[asym_crypto];
+ return software_pkey_verify_signature(pk, sig);
}

/*
* Public key algorithm asymmetric key subtype
*/
-struct asymmetric_key_subtype public_key_subtype = {
+struct asymmetric_key_subtype software_pkey_subtype = {
.owner = THIS_MODULE,
- .name = "public_key",
- .name_len = sizeof("public_key") - 1,
- .describe = public_key_describe,
- .destroy = public_key_destroy,
- .verify_signature = public_key_verify_signature_2,
+ .name = "software_pkey",
+ .name_len = sizeof("software_pkey") - 1,
+ .describe = software_pkey_describe,
+ .destroy = software_pkey_destroy,
+ .verify_signature = software_pkey_verify_signature_2,
};
-EXPORT_SYMBOL_GPL(public_key_subtype);
+EXPORT_SYMBOL_GPL(software_pkey_subtype);
diff --git a/crypto/asymmetric_keys/software_pkey.h b/crypto/asymmetric_keys/software_pkey.h
index 06d6500e5825..696bce5daf08 100644
--- a/crypto/asymmetric_keys/software_pkey.h
+++ b/crypto/asymmetric_keys/software_pkey.h
@@ -11,7 +11,7 @@

#include <crypto/public_key.h>

-extern struct asymmetric_key_subtype public_key_subtype;
+extern struct asymmetric_key_subtype software_pkey_subtype;

/*
* Cryptographic data for the software public-key subtype of the asymmetric key
@@ -20,14 +20,14 @@ extern struct asymmetric_key_subtype public_key_subtype;
* Note that this may include private part of the key as well as the public
* part.
*/
-struct public_key {
+struct software_pkey {
void *key;
u32 keylen;
const char *id_type;
const char *pkey_algo;
};

-extern void public_key_destroy(void *payload);
+extern void software_pkey_destroy(void *payload);

-extern int public_key_verify_signature(const struct public_key *pkey,
- const struct public_key_signature *sig);
+extern int software_pkey_verify_signature(const struct software_pkey *pkey,
+ const struct public_key_signature *sig);
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index a008a945aa82..9cc629261fee 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -47,7 +47,7 @@ struct x509_parse_context {
void x509_free_certificate(struct x509_certificate *cert)
{
if (cert) {
- public_key_destroy(cert->pub);
+ software_pkey_destroy(cert->pub);
kfree(cert->issuer);
kfree(cert->subject);
kfree(cert->id);
@@ -75,7 +75,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
cert = kzalloc(sizeof(struct x509_certificate), GFP_KERNEL);
if (!cert)
goto error_no_cert;
- cert->pub = kzalloc(sizeof(struct public_key), GFP_KERNEL);
+ cert->pub = kzalloc(sizeof(struct software_pkey), GFP_KERNEL);
if (!cert->pub)
goto error_no_ctx;
ctx = kzalloc(sizeof(struct x509_parse_context), GFP_KERNEL);
diff --git a/crypto/asymmetric_keys/x509_parser.h b/crypto/asymmetric_keys/x509_parser.h
index dbeed6018e63..f9fe7c8b2002 100644
--- a/crypto/asymmetric_keys/x509_parser.h
+++ b/crypto/asymmetric_keys/x509_parser.h
@@ -16,7 +16,7 @@
struct x509_certificate {
struct x509_certificate *next;
struct x509_certificate *signer; /* Certificate that signed this one */
- struct public_key *pub; /* Public key details */
+ struct software_pkey *pub; /* Public key details */
struct public_key_signature sig; /* Signature parameters */
char *issuer; /* Name of certificate issuer */
char *subject; /* Name of certificate subject */
@@ -58,5 +58,5 @@ extern int x509_decode_time(time64_t *_t, size_t hdrlen,
* x509_public_key.c
*/
extern int x509_get_sig_params(struct x509_certificate *cert);
-extern int x509_check_signature(const struct public_key *pub,
+extern int x509_check_signature(const struct software_pkey *pub,
struct x509_certificate *cert);
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 0896f784cfda..55fdefc12069 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -220,7 +220,7 @@ EXPORT_SYMBOL_GPL(x509_get_sig_params);
/*
* Check the signature on a certificate using the provided public key
*/
-int x509_check_signature(const struct public_key *pub,
+int x509_check_signature(const struct software_pkey *pub,
struct x509_certificate *cert)
{
int ret;
@@ -231,7 +231,7 @@ int x509_check_signature(const struct public_key *pub,
if (ret < 0)
return ret;

- ret = public_key_verify_signature(pub, &cert->sig);
+ ret = software_pkey_verify_signature(pub, &cert->sig);
if (ret == -ENOPKG)
cert->unsupported_crypto = true;
pr_debug("Cert Verification: %d\n", ret);
@@ -350,8 +350,8 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
kids->id[1] = cert->skid;

/* We're pinning the module by being linked against it */
- __module_get(public_key_subtype.owner);
- prep->payload.data[asym_subtype] = &public_key_subtype;
+ __module_get(software_pkey_subtype.owner);
+ prep->payload.data[asym_subtype] = &software_pkey_subtype;
prep->payload.data[asym_key_ids] = kids;
prep->payload.data[asym_crypto] = cert->pub;
prep->description = desc;