Lines Matching refs:key

24 	int private_key; /* whether private key is set */
62 * crypto_rsa_import_public_key - Import an RSA public key
63 * @buf: Key buffer (DER encoded RSA public key)
65 * Returns: Pointer to the public key or %NULL on failure
70 struct crypto_rsa_key *key;
74 key = os_zalloc(sizeof(*key));
75 if (key == NULL)
78 key->n = bignum_init();
79 key->e = bignum_init();
80 if (key->n == NULL || key->e == NULL) {
81 crypto_rsa_free(key);
97 "(public key) - found class %d tag 0x%x",
104 pos = crypto_rsa_parse_integer(pos, end, key->n);
105 pos = crypto_rsa_parse_integer(pos, end, key->e);
112 "RSA: Extra data in public key SEQUENCE",
117 return key;
120 crypto_rsa_free(key);
126 * crypto_rsa_import_private_key - Import an RSA private key
127 * @buf: Key buffer (DER encoded RSA private key)
129 * Returns: Pointer to the private key or %NULL on failure
134 struct crypto_rsa_key *key;
139 key = os_zalloc(sizeof(*key));
140 if (key == NULL)
143 key->private_key = 1;
145 key->n = bignum_init();
146 key->e = bignum_init();
147 key->d = bignum_init();
148 key->p = bignum_init();
149 key->q = bignum_init();
150 key->dmp1 = bignum_init();
151 key->dmq1 = bignum_init();
152 key->iqmp = bignum_init();
154 if (key->n == NULL || key->e == NULL || key->d == NULL ||
155 key->p == NULL || key->q == NULL || key->dmp1 == NULL ||
156 key->dmq1 == NULL || key->iqmp == NULL) {
157 crypto_rsa_free(key);
181 "(public key) - found class %d tag 0x%x",
194 "beginning of private key; not found");
200 pos = crypto_rsa_parse_integer(pos, end, key->n);
201 pos = crypto_rsa_parse_integer(pos, end, key->e);
202 pos = crypto_rsa_parse_integer(pos, end, key->d);
203 pos = crypto_rsa_parse_integer(pos, end, key->p);
204 pos = crypto_rsa_parse_integer(pos, end, key->q);
205 pos = crypto_rsa_parse_integer(pos, end, key->dmp1);
206 pos = crypto_rsa_parse_integer(pos, end, key->dmq1);
207 pos = crypto_rsa_parse_integer(pos, end, key->iqmp);
214 "RSA: Extra data in public key SEQUENCE",
219 return key;
222 crypto_rsa_free(key);
228 * crypto_rsa_get_modulus_len - Get the modulus length of the RSA key
229 * @key: RSA key
230 * Returns: Modulus length of the key
232 size_t crypto_rsa_get_modulus_len(struct crypto_rsa_key *key)
234 return bignum_get_unsigned_bin_len(key->n);
244 * @key: RSA key
245 * @use_private: 1 = Use RSA private key, 0 = Use RSA public key
249 struct crypto_rsa_key *key, int use_private)
255 if (use_private && !key->private_key)
264 if (bignum_cmp(key->n, tmp) < 0) {
265 /* Too large input value for the RSA key modulus */
289 if (bignum_exptmod(tmp, key->dmp1, key->p, a) < 0)
293 if (bignum_exptmod(tmp, key->dmq1, key->q, b) < 0)
298 bignum_mulmod(tmp, key->iqmp, key->p, tmp) < 0)
302 if (bignum_mul(tmp, key->q, tmp) < 0 ||
308 if (bignum_exptmod(tmp, key->e, key->n, tmp) < 0)
312 modlen = crypto_rsa_get_modulus_len(key);
339 * crypto_rsa_free - Free RSA key
340 * @key: RSA key to be freed
342 * This function frees an RSA key imported with either
345 void crypto_rsa_free(struct crypto_rsa_key *key)
347 if (key) {
348 bignum_deinit(key->n);
349 bignum_deinit(key->e);
350 bignum_deinit(key->d);
351 bignum_deinit(key->p);
352 bignum_deinit(key->q);
353 bignum_deinit(key->dmp1);
354 bignum_deinit(key->dmq1);
355 bignum_deinit(key->iqmp);
356 os_free(key);