mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: keyrings@vger.kernel.org
Cc: dhowells@redhat.com, linux-security-module@vger.kernel.org,
	zohar@linux.vnet.ibm.com, linux-kernel@vger.kernel.org,
	tadeusz.struk@intel.com
Subject: [PATCH 6/8] X.509: Make the public_key asymmetric key type internal data private
Date: Fri, 19 Feb 2016 17:18:51 +0000	[thread overview]
Message-ID: <20160219171851.17223.69299.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20160219171806.17223.91381.stgit@warthog.procyon.org.uk>

Make the public_key asymmetric key type internal data (struct public_key)
private by moving it to the asymmetric keys directory.

Whilst struct public_key_signature needs to be available, since that's part
of the asymmetric key API to verify a signature, anyone using asymmetric
keys should not be poking around inside the subtype internals, but should
rather use API functions, such as verify_signature(), in case the internals
turn out not to be of the subtype expected.

An exception is made for the X.509 and PKCS#7 parsers as they don't create
keys but rather use the public key routines directly.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 crypto/asymmetric_keys/pkcs7_verify.c     |    2 +-
 crypto/asymmetric_keys/public_key.c       |    2 +-
 crypto/asymmetric_keys/software_pkey.h    |   33 +++++++++++++++++++++++++++++
 crypto/asymmetric_keys/x509_cert_parser.c |    2 +-
 crypto/asymmetric_keys/x509_public_key.c  |    1 +
 include/crypto/public_key.h               |   19 -----------------
 6 files changed, 37 insertions(+), 22 deletions(-)
 create mode 100644 crypto/asymmetric_keys/software_pkey.h

diff --git a/crypto/asymmetric_keys/pkcs7_verify.c b/crypto/asymmetric_keys/pkcs7_verify.c
index 50be2a15e531..6aad267f19bb 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 <crypto/public_key.h>
+#include "software_pkey.h"
 #include "pkcs7_parser.h"
 
 /*
diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index 16895996c2e2..3024081026c1 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -19,7 +19,7 @@
 #include <linux/seq_file.h>
 #include <linux/scatterlist.h>
 #include <keys/asymmetric-subtype.h>
-#include <crypto/public_key.h>
+#include "software_pkey.h"
 #include <crypto/akcipher.h>
 
 MODULE_LICENSE("GPL");
diff --git a/crypto/asymmetric_keys/software_pkey.h b/crypto/asymmetric_keys/software_pkey.h
new file mode 100644
index 000000000000..06d6500e5825
--- /dev/null
+++ b/crypto/asymmetric_keys/software_pkey.h
@@ -0,0 +1,33 @@
+/* Internal definitions for the software public key subtype
+ *
+ * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * 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;
+
+/*
+ * Cryptographic data for the software public-key subtype of the asymmetric key
+ * type.
+ *
+ * Note that this may include private part of the key as well as the public
+ * part.
+ */
+struct public_key {
+	void *key;
+	u32 keylen;
+	const char *id_type;
+	const char *pkey_algo;
+};
+
+extern void public_key_destroy(void *payload);
+
+extern int public_key_verify_signature(const struct public_key *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 dffd30f107cd..a008a945aa82 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -15,7 +15,7 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/oid_registry.h>
-#include <crypto/public_key.h>
+#include "software_pkey.h"
 #include "x509_parser.h"
 #include "x509-asn1.h"
 #include "x509_akid-asn1.h"
diff --git a/crypto/asymmetric_keys/x509_public_key.c b/crypto/asymmetric_keys/x509_public_key.c
index 733c046aacc6..0896f784cfda 100644
--- a/crypto/asymmetric_keys/x509_public_key.c
+++ b/crypto/asymmetric_keys/x509_public_key.c
@@ -18,6 +18,7 @@
 #include <keys/system_keyring.h>
 #include <crypto/hash.h>
 #include "asymmetric_keys.h"
+#include "software_pkey.h"
 #include "x509_parser.h"
 
 static bool use_builtin_keys;
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index aa730ea7faf8..d55f9f9bfd65 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -29,21 +29,6 @@ enum key_being_used_for {
 extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
 
 /*
- * Cryptographic data for the public-key subtype of the asymmetric key type.
- *
- * Note that this may include private part of the key as well as the public
- * part.
- */
-struct public_key {
-	void *key;
-	u32 keylen;
-	const char *id_type;
-	const char *pkey_algo;
-};
-
-extern void public_key_destroy(void *payload);
-
-/*
  * Public key cryptography signature data
  */
 struct public_key_signature {
@@ -55,7 +40,6 @@ struct public_key_signature {
 	const char *hash_algo;
 };
 
-extern struct asymmetric_key_subtype public_key_subtype;
 struct key;
 extern int verify_signature(const struct key *key,
 			    const struct public_key_signature *sig);
@@ -66,7 +50,4 @@ extern struct key *x509_request_asymmetric_key(struct key *keyring,
 					       const struct asymmetric_key_id *skid,
 					       bool partial);
 
-int public_key_verify_signature(const struct public_key *pkey,
-				const struct public_key_signature *sig);
-
 #endif /* _LINUX_PUBLIC_KEY_H */

  parent reply	other threads:[~2016-02-19 17:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 17:18 [PATCH 0/8] X.509: Software public key subtype changes David Howells
2016-02-19 17:18 ` [PATCH 1/8] crypto: KEYS: convert public key and digsig asym to the akcipher api David Howells
2016-02-19 17:18 ` [PATCH 2/8] integrity: convert digsig to " David Howells
2016-02-19 17:18 ` [PATCH 3/8] crypto: public_key: remove MPIs from public_key_signature struct David Howells
2016-02-19 17:18 ` [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer David Howells
2016-02-22 19:59   ` Tadeusz Struk
2016-02-22 22:28   ` David Howells
2016-02-22 23:35     ` Tadeusz Struk
2016-02-23  0:01     ` Andrew Zaborowski
2016-02-23 10:53     ` David Howells
2016-02-24 17:12       ` [PATCH 0/2] KEYS: Use pkcs1pad for padding in software_pkey Tadeusz Struk
2016-02-24 17:12         ` [PATCH 1/2] crypto: Add hash param to pkcs1pad Tadeusz Struk
2016-02-24 17:12         ` [PATCH 2/2] crypto: remove padding logic from rsa.c Tadeusz Struk
2016-02-27 18:40           ` Herbert Xu
2016-02-28  3:20             ` Tadeusz Struk
2016-02-26 14:00         ` David Howells
2016-02-26 15:02         ` David Howells
2016-02-24 17:28       ` [PATCH 0/2] KEYS: Use pkcs1pad for padding in software_pkey David Howells
2016-02-23 10:55     ` [PATCH 4/8] akcipher: Move the RSA DER encoding to the crypto layer David Howells
2016-02-23 11:25       ` Andrew Zaborowski
2016-02-26 11:42       ` David Howells
2016-02-24  5:04   ` Mimi Zohar
2016-02-24  5:59     ` Mimi Zohar
2016-02-29 15:37     ` David Howells
2016-02-19 17:18 ` [PATCH 5/8] X.509: Make algo identifiers text instead of enum David Howells
2016-02-19 17:18 ` David Howells [this message]
2016-02-19 17:18 ` [PATCH 7/8] X.509: Rename public_key.c to software_pkey.c David Howells
2016-02-19 17:19 ` [PATCH 8/8] X.509: Rename public_key* to software_pkey* David Howells
2016-02-22 18:57 ` [PATCH 0/8] X.509: Software public key subtype changes Mimi Zohar
2016-02-22 19:59 ` Tadeusz Struk
2016-02-22 22:29 ` David Howells
2016-02-23  0:03   ` Mimi Zohar
2016-02-23 10:16   ` David Howells
2016-02-23 12:28     ` Mimi Zohar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160219171851.17223.69299.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=tadeusz.struk@intel.com \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®