Lines Matching +full:key +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * RSA key extract helper
19 struct rsa_key *key = context; in rsa_get_n() local
23 /* invalid key provided */ in rsa_get_n()
25 return -EINVAL; in rsa_get_n()
30 n_sz--; in rsa_get_n()
33 /* In FIPS mode only allow key size 2K and higher */ in rsa_get_n()
35 pr_err("RSA: key size not allowed in FIPS mode\n"); in rsa_get_n()
36 return -EINVAL; in rsa_get_n()
40 key->n = value; in rsa_get_n()
41 key->n_sz = vlen; in rsa_get_n()
49 struct rsa_key *key = context; in rsa_get_e() local
51 /* invalid key provided */ in rsa_get_e()
52 if (!value || !key->n_sz || !vlen || vlen > key->n_sz) in rsa_get_e()
53 return -EINVAL; in rsa_get_e()
55 key->e = value; in rsa_get_e()
56 key->e_sz = vlen; in rsa_get_e()
64 struct rsa_key *key = context; in rsa_get_d() local
66 /* invalid key provided */ in rsa_get_d()
67 if (!value || !key->n_sz || !vlen || vlen > key->n_sz) in rsa_get_d()
68 return -EINVAL; in rsa_get_d()
70 key->d = value; in rsa_get_d()
71 key->d_sz = vlen; in rsa_get_d()
79 struct rsa_key *key = context; in rsa_get_p() local
81 /* invalid key provided */ in rsa_get_p()
82 if (!value || !vlen || vlen > key->n_sz) in rsa_get_p()
83 return -EINVAL; in rsa_get_p()
85 key->p = value; in rsa_get_p()
86 key->p_sz = vlen; in rsa_get_p()
94 struct rsa_key *key = context; in rsa_get_q() local
96 /* invalid key provided */ in rsa_get_q()
97 if (!value || !vlen || vlen > key->n_sz) in rsa_get_q()
98 return -EINVAL; in rsa_get_q()
100 key->q = value; in rsa_get_q()
101 key->q_sz = vlen; in rsa_get_q()
109 struct rsa_key *key = context; in rsa_get_dp() local
111 /* invalid key provided */ in rsa_get_dp()
112 if (!value || !vlen || vlen > key->n_sz) in rsa_get_dp()
113 return -EINVAL; in rsa_get_dp()
115 key->dp = value; in rsa_get_dp()
116 key->dp_sz = vlen; in rsa_get_dp()
124 struct rsa_key *key = context; in rsa_get_dq() local
126 /* invalid key provided */ in rsa_get_dq()
127 if (!value || !vlen || vlen > key->n_sz) in rsa_get_dq()
128 return -EINVAL; in rsa_get_dq()
130 key->dq = value; in rsa_get_dq()
131 key->dq_sz = vlen; in rsa_get_dq()
139 struct rsa_key *key = context; in rsa_get_qinv() local
141 /* invalid key provided */ in rsa_get_qinv()
142 if (!value || !vlen || vlen > key->n_sz) in rsa_get_qinv()
143 return -EINVAL; in rsa_get_qinv()
145 key->qinv = value; in rsa_get_qinv()
146 key->qinv_sz = vlen; in rsa_get_qinv()
152 * rsa_parse_pub_key() - decodes the BER encoded buffer and stores in the
153 * provided struct rsa_key, pointers to the raw key as is,
156 * @rsa_key: struct rsa_key key representation
157 * @key: key in BER format
158 * @key_len: length of key
162 int rsa_parse_pub_key(struct rsa_key *rsa_key, const void *key, in rsa_parse_pub_key() argument
165 return asn1_ber_decoder(&rsapubkey_decoder, rsa_key, key, key_len); in rsa_parse_pub_key()
170 * rsa_parse_priv_key() - decodes the BER encoded buffer and stores in the
171 * provided struct rsa_key, pointers to the raw key
175 * @rsa_key: struct rsa_key key representation
176 * @key: key in BER format
177 * @key_len: length of key
181 int rsa_parse_priv_key(struct rsa_key *rsa_key, const void *key, in rsa_parse_priv_key() argument
184 return asn1_ber_decoder(&rsaprivkey_decoder, rsa_key, key, key_len); in rsa_parse_priv_key()