summaryrefslogtreecommitdiffstats
path: root/include/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-02-09 16:18:01 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2016-02-09 16:18:01 +0800
commitf75516a81548074be331b3e41d2e3f448d1f8b8d (patch)
treeba6e557c7473389709cf7a3bc69e608dcd8584f2 /include/crypto
parented1afac9145c4517a2c84f93e04a35046ea206e3 (diff)
downloadlinux-f75516a81548074be331b3e41d2e3f448d1f8b8d.tar.gz
linux-f75516a81548074be331b3e41d2e3f448d1f8b8d.tar.bz2
linux-f75516a81548074be331b3e41d2e3f448d1f8b8d.zip
crypto: keys - Revert "convert public key to akcipher api"
This needs to go through the security tree so I'm reverting the patches for now. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto')
-rw-r--r--include/crypto/public_key.h48
1 files changed, 37 insertions, 11 deletions
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
index a1693ed77be6..cc2516df0efa 100644
--- a/include/crypto/public_key.h
+++ b/include/crypto/public_key.h
@@ -14,6 +14,7 @@
#ifndef _LINUX_PUBLIC_KEY_H
#define _LINUX_PUBLIC_KEY_H
+#include <linux/mpi.h>
#include <crypto/hash_info.h>
enum pkey_algo {
@@ -23,6 +24,7 @@ enum pkey_algo {
};
extern const char *const pkey_algo_name[PKEY_ALGO__LAST];
+extern const struct public_key_algorithm *pkey_algo[PKEY_ALGO__LAST];
/* asymmetric key implementation supports only up to SHA224 */
#define PKEY_HASH__LAST (HASH_ALGO_SHA224 + 1)
@@ -57,10 +59,31 @@ extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR];
* part.
*/
struct public_key {
- void *key;
- u32 keylen;
+ const struct public_key_algorithm *algo;
+ u8 capabilities;
+#define PKEY_CAN_ENCRYPT 0x01
+#define PKEY_CAN_DECRYPT 0x02
+#define PKEY_CAN_SIGN 0x04
+#define PKEY_CAN_VERIFY 0x08
enum pkey_algo pkey_algo : 8;
enum pkey_id_type id_type : 8;
+ union {
+ MPI mpi[5];
+ struct {
+ MPI p; /* DSA prime */
+ MPI q; /* DSA group order */
+ MPI g; /* DSA group generator */
+ MPI y; /* DSA public-key value = g^x mod p */
+ MPI x; /* DSA secret exponent (if present) */
+ } dsa;
+ struct {
+ MPI n; /* RSA public modulus */
+ MPI e; /* RSA public encryption exponent */
+ MPI d; /* RSA secret encryption exponent (if present) */
+ MPI p; /* RSA secret prime (if present) */
+ MPI q; /* RSA secret prime (if present) */
+ } rsa;
+ };
};
extern void public_key_destroy(void *payload);
@@ -69,15 +92,23 @@ extern void public_key_destroy(void *payload);
* Public key cryptography signature data
*/
struct public_key_signature {
- u8 *s; /* Signature */
- u32 s_size; /* Number of bytes in signature */
u8 *digest;
- u8 digest_size; /* Number of bytes in digest */
+ u8 digest_size; /* Number of bytes in digest */
+ u8 nr_mpi; /* Occupancy of mpi[] */
enum pkey_algo pkey_algo : 8;
enum hash_algo pkey_hash_algo : 8;
+ union {
+ MPI mpi[2];
+ struct {
+ MPI s; /* m^d mod n */
+ } rsa;
+ struct {
+ MPI r;
+ MPI s;
+ } dsa;
+ };
};
-extern struct asymmetric_key_subtype public_key_subtype;
struct key;
extern int verify_signature(const struct key *key,
const struct public_key_signature *sig);
@@ -88,9 +119,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);
-
-int rsa_verify_signature(const struct public_key *pkey,
- const struct public_key_signature *sig);
#endif /* _LINUX_PUBLIC_KEY_H */