diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2016-02-02 13:08:53 -0500 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2016-02-10 05:13:27 -0500 |
commit | db6c43bd2132dc2dd63d73a6d1ed601cffd0ae06 (patch) | |
tree | 419c6b0bf5716e79a7047d2ba9eced1a1b0e5cd8 /include/crypto | |
parent | 50d35015ff0c00a464e35b109231145d2beec1bd (diff) |
crypto: KEYS: convert public key and digsig asym to the akcipher api
This patch converts the module verification code to the new akcipher API.
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/crypto')
-rw-r--r-- | include/crypto/public_key.h | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h index cc2516df0efa..50ac8759d7ee 100644 --- a/include/crypto/public_key.h +++ b/include/crypto/public_key.h | |||
@@ -24,7 +24,6 @@ enum pkey_algo { | |||
24 | }; | 24 | }; |
25 | 25 | ||
26 | extern const char *const pkey_algo_name[PKEY_ALGO__LAST]; | 26 | extern const char *const pkey_algo_name[PKEY_ALGO__LAST]; |
27 | extern const struct public_key_algorithm *pkey_algo[PKEY_ALGO__LAST]; | ||
28 | 27 | ||
29 | /* asymmetric key implementation supports only up to SHA224 */ | 28 | /* asymmetric key implementation supports only up to SHA224 */ |
30 | #define PKEY_HASH__LAST (HASH_ALGO_SHA224 + 1) | 29 | #define PKEY_HASH__LAST (HASH_ALGO_SHA224 + 1) |
@@ -59,31 +58,10 @@ extern const char *const key_being_used_for[NR__KEY_BEING_USED_FOR]; | |||
59 | * part. | 58 | * part. |
60 | */ | 59 | */ |
61 | struct public_key { | 60 | struct public_key { |
62 | const struct public_key_algorithm *algo; | 61 | void *key; |
63 | u8 capabilities; | 62 | u32 keylen; |
64 | #define PKEY_CAN_ENCRYPT 0x01 | ||
65 | #define PKEY_CAN_DECRYPT 0x02 | ||
66 | #define PKEY_CAN_SIGN 0x04 | ||
67 | #define PKEY_CAN_VERIFY 0x08 | ||
68 | enum pkey_algo pkey_algo : 8; | 63 | enum pkey_algo pkey_algo : 8; |
69 | enum pkey_id_type id_type : 8; | 64 | enum pkey_id_type id_type : 8; |
70 | union { | ||
71 | MPI mpi[5]; | ||
72 | struct { | ||
73 | MPI p; /* DSA prime */ | ||
74 | MPI q; /* DSA group order */ | ||
75 | MPI g; /* DSA group generator */ | ||
76 | MPI y; /* DSA public-key value = g^x mod p */ | ||
77 | MPI x; /* DSA secret exponent (if present) */ | ||
78 | } dsa; | ||
79 | struct { | ||
80 | MPI n; /* RSA public modulus */ | ||
81 | MPI e; /* RSA public encryption exponent */ | ||
82 | MPI d; /* RSA secret encryption exponent (if present) */ | ||
83 | MPI p; /* RSA secret prime (if present) */ | ||
84 | MPI q; /* RSA secret prime (if present) */ | ||
85 | } rsa; | ||
86 | }; | ||
87 | }; | 65 | }; |
88 | 66 | ||
89 | extern void public_key_destroy(void *payload); | 67 | extern void public_key_destroy(void *payload); |
@@ -92,6 +70,8 @@ extern void public_key_destroy(void *payload); | |||
92 | * Public key cryptography signature data | 70 | * Public key cryptography signature data |
93 | */ | 71 | */ |
94 | struct public_key_signature { | 72 | struct public_key_signature { |
73 | u8 *s; /* Signature */ | ||
74 | u32 s_size; /* Number of bytes in signature */ | ||
95 | u8 *digest; | 75 | u8 *digest; |
96 | u8 digest_size; /* Number of bytes in digest */ | 76 | u8 digest_size; /* Number of bytes in digest */ |
97 | u8 nr_mpi; /* Occupancy of mpi[] */ | 77 | u8 nr_mpi; /* Occupancy of mpi[] */ |
@@ -109,6 +89,7 @@ struct public_key_signature { | |||
109 | }; | 89 | }; |
110 | }; | 90 | }; |
111 | 91 | ||
92 | extern struct asymmetric_key_subtype public_key_subtype; | ||
112 | struct key; | 93 | struct key; |
113 | extern int verify_signature(const struct key *key, | 94 | extern int verify_signature(const struct key *key, |
114 | const struct public_key_signature *sig); | 95 | const struct public_key_signature *sig); |
@@ -119,4 +100,9 @@ extern struct key *x509_request_asymmetric_key(struct key *keyring, | |||
119 | const struct asymmetric_key_id *skid, | 100 | const struct asymmetric_key_id *skid, |
120 | bool partial); | 101 | bool partial); |
121 | 102 | ||
103 | int public_key_verify_signature(const struct public_key *pkey, | ||
104 | const struct public_key_signature *sig); | ||
105 | |||
106 | int rsa_verify_signature(const struct public_key *pkey, | ||
107 | const struct public_key_signature *sig); | ||
122 | #endif /* _LINUX_PUBLIC_KEY_H */ | 108 | #endif /* _LINUX_PUBLIC_KEY_H */ |