diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2015-10-08 12:26:55 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-10-14 10:23:16 -0400 |
commit | 22287b0b5988b603b5f0daa282c89aaf2b877313 (patch) | |
tree | c8a1d714f4184feafc2885ab4a2968451397da03 /crypto/rsa_helper.c | |
parent | 2d4d1eea540b27c72488fd1914674c42473d53df (diff) |
crypto: akcipher - Changes to asymmetric key API
Setkey function has been split into set_priv_key and set_pub_key.
Akcipher requests takes sgl for src and dst instead of void *.
Users of the API i.e. two existing RSA implementation and
test mgr code have been updated accordingly.
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/rsa_helper.c')
-rw-r--r-- | crypto/rsa_helper.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/crypto/rsa_helper.c b/crypto/rsa_helper.c index 8d96ce969b44..d226f48d0907 100644 --- a/crypto/rsa_helper.c +++ b/crypto/rsa_helper.c | |||
@@ -15,7 +15,8 @@ | |||
15 | #include <linux/err.h> | 15 | #include <linux/err.h> |
16 | #include <linux/fips.h> | 16 | #include <linux/fips.h> |
17 | #include <crypto/internal/rsa.h> | 17 | #include <crypto/internal/rsa.h> |
18 | #include "rsakey-asn1.h" | 18 | #include "rsapubkey-asn1.h" |
19 | #include "rsaprivkey-asn1.h" | ||
19 | 20 | ||
20 | int rsa_get_n(void *context, size_t hdrlen, unsigned char tag, | 21 | int rsa_get_n(void *context, size_t hdrlen, unsigned char tag, |
21 | const void *value, size_t vlen) | 22 | const void *value, size_t vlen) |
@@ -94,8 +95,8 @@ void rsa_free_key(struct rsa_key *key) | |||
94 | EXPORT_SYMBOL_GPL(rsa_free_key); | 95 | EXPORT_SYMBOL_GPL(rsa_free_key); |
95 | 96 | ||
96 | /** | 97 | /** |
97 | * rsa_parse_key() - extracts an rsa key from BER encoded buffer | 98 | * rsa_parse_pub_key() - extracts an rsa public key from BER encoded buffer |
98 | * and stores it in the provided struct rsa_key | 99 | * and stores it in the provided struct rsa_key |
99 | * | 100 | * |
100 | * @rsa_key: struct rsa_key key representation | 101 | * @rsa_key: struct rsa_key key representation |
101 | * @key: key in BER format | 102 | * @key: key in BER format |
@@ -103,13 +104,13 @@ EXPORT_SYMBOL_GPL(rsa_free_key); | |||
103 | * | 104 | * |
104 | * Return: 0 on success or error code in case of error | 105 | * Return: 0 on success or error code in case of error |
105 | */ | 106 | */ |
106 | int rsa_parse_key(struct rsa_key *rsa_key, const void *key, | 107 | int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, |
107 | unsigned int key_len) | 108 | unsigned int key_len) |
108 | { | 109 | { |
109 | int ret; | 110 | int ret; |
110 | 111 | ||
111 | free_mpis(rsa_key); | 112 | free_mpis(rsa_key); |
112 | ret = asn1_ber_decoder(&rsakey_decoder, rsa_key, key, key_len); | 113 | ret = asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len); |
113 | if (ret < 0) | 114 | if (ret < 0) |
114 | goto error; | 115 | goto error; |
115 | 116 | ||
@@ -118,4 +119,31 @@ error: | |||
118 | free_mpis(rsa_key); | 119 | free_mpis(rsa_key); |
119 | return ret; | 120 | return ret; |
120 | } | 121 | } |
121 | EXPORT_SYMBOL_GPL(rsa_parse_key); | 122 | EXPORT_SYMBOL_GPL(rsa_parse_pub_key); |
123 | |||
124 | /** | ||
125 | * rsa_parse_pub_key() - extracts an rsa private key from BER encoded buffer | ||
126 | * and stores it in the provided struct rsa_key | ||
127 | * | ||
128 | * @rsa_key: struct rsa_key key representation | ||
129 | * @key: key in BER format | ||
130 | * @key_len: length of key | ||
131 | * | ||
132 | * Return: 0 on success or error code in case of error | ||
133 | */ | ||
134 | int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key, | ||
135 | unsigned int key_len) | ||
136 | { | ||
137 | int ret; | ||
138 | |||
139 | free_mpis(rsa_key); | ||
140 | ret = asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len); | ||
141 | if (ret < 0) | ||
142 | goto error; | ||
143 | |||
144 | return 0; | ||
145 | error: | ||
146 | free_mpis(rsa_key); | ||
147 | return ret; | ||
148 | } | ||
149 | EXPORT_SYMBOL_GPL(rsa_parse_priv_key); | ||