Lines Matching +full:key +full:-
1 /* SPDX-License-Identifier: GPL-2.0+ */
21 * mapping for the cca private ME key token.
25 * mapping for the cca key token header
40 * In a private key, the modulus doesn't appear in the public
51 unsigned short modulus_byte_len; /* In a private key, this is 0 */
55 * mapping for the cca private CRT key 'token'
92 * Set up private key fields of a type6 MEX message.
95 * @p: pointer to memory area for the key
97 * Returns the size of the key area or negative errno value.
112 } __packed *key = p; in zcrypt_type6_mex_key_en() local
121 if (WARN_ON_ONCE(mex->inputdatalength > 512)) in zcrypt_type6_mex_key_en()
122 return -EINVAL; in zcrypt_type6_mex_key_en()
124 memset(key, 0, sizeof(*key)); in zcrypt_type6_mex_key_en()
126 key->pubhdr = static_pub_hdr; in zcrypt_type6_mex_key_en()
127 key->pubsec = static_pub_sec; in zcrypt_type6_mex_key_en()
129 /* key parameter block */ in zcrypt_type6_mex_key_en()
130 ptr = key->exponent; in zcrypt_type6_mex_key_en()
131 if (copy_from_user(ptr, mex->b_key, mex->inputdatalength)) in zcrypt_type6_mex_key_en()
132 return -EFAULT; in zcrypt_type6_mex_key_en()
133 ptr += mex->inputdatalength; in zcrypt_type6_mex_key_en()
135 if (copy_from_user(ptr, mex->n_modulus, mex->inputdatalength)) in zcrypt_type6_mex_key_en()
136 return -EFAULT; in zcrypt_type6_mex_key_en()
138 key->pubsec.modulus_bit_len = 8 * mex->inputdatalength; in zcrypt_type6_mex_key_en()
139 key->pubsec.modulus_byte_len = mex->inputdatalength; in zcrypt_type6_mex_key_en()
140 key->pubsec.exponent_len = mex->inputdatalength; in zcrypt_type6_mex_key_en()
141 key->pubsec.section_length = sizeof(key->pubsec) + in zcrypt_type6_mex_key_en()
142 2 * mex->inputdatalength; in zcrypt_type6_mex_key_en()
143 key->pubhdr.token_length = in zcrypt_type6_mex_key_en()
144 key->pubsec.section_length + sizeof(key->pubhdr); in zcrypt_type6_mex_key_en()
145 key->t6_hdr.ulen = key->pubhdr.token_length + 4; in zcrypt_type6_mex_key_en()
146 key->t6_hdr.blen = key->pubhdr.token_length + 6; in zcrypt_type6_mex_key_en()
148 return sizeof(*key) + 2 * mex->inputdatalength; in zcrypt_type6_mex_key_en()
152 * Set up private key fields of a type6 CRT message.
155 * @p: pointer to memory area for the key
157 * Returns the size of the key area or -EFAULT
172 } __packed *key = p; in zcrypt_type6_crt_key() local
182 if (WARN_ON_ONCE(crt->inputdatalength > 512)) in zcrypt_type6_crt_key()
183 return -EINVAL; in zcrypt_type6_crt_key()
185 memset(key, 0, sizeof(*key)); in zcrypt_type6_crt_key()
187 short_len = (crt->inputdatalength + 1) / 2; in zcrypt_type6_crt_key()
189 pad_len = -(3 * long_len + 2 * short_len) & 7; in zcrypt_type6_crt_key()
190 key_len = 3 * long_len + 2 * short_len + pad_len + crt->inputdatalength; in zcrypt_type6_crt_key()
191 size = sizeof(*key) + key_len + sizeof(*pub) + 3; in zcrypt_type6_crt_key()
193 /* parameter block.key block */ in zcrypt_type6_crt_key()
194 key->t6_hdr.blen = size; in zcrypt_type6_crt_key()
195 key->t6_hdr.ulen = size - 2; in zcrypt_type6_crt_key()
197 /* key token header */ in zcrypt_type6_crt_key()
198 key->token.token_identifier = CCA_TKN_HDR_ID_EXT; in zcrypt_type6_crt_key()
199 key->token.token_length = size - 6; in zcrypt_type6_crt_key()
202 key->pvt.section_identifier = CCA_PVT_EXT_CRT_SEC_ID_PVT; in zcrypt_type6_crt_key()
203 key->pvt.section_length = sizeof(key->pvt) + key_len; in zcrypt_type6_crt_key()
204 key->pvt.key_format = CCA_PVT_EXT_CRT_SEC_FMT_CL; in zcrypt_type6_crt_key()
205 key->pvt.key_use_flags[0] = CCA_PVT_USAGE_ALL; in zcrypt_type6_crt_key()
206 key->pvt.p_len = key->pvt.dp_len = key->pvt.u_len = long_len; in zcrypt_type6_crt_key()
207 key->pvt.q_len = key->pvt.dq_len = short_len; in zcrypt_type6_crt_key()
208 key->pvt.mod_len = crt->inputdatalength; in zcrypt_type6_crt_key()
209 key->pvt.pad_len = pad_len; in zcrypt_type6_crt_key()
211 /* key parts */ in zcrypt_type6_crt_key()
212 if (copy_from_user(key->key_parts, crt->np_prime, long_len) || in zcrypt_type6_crt_key()
213 copy_from_user(key->key_parts + long_len, in zcrypt_type6_crt_key()
214 crt->nq_prime, short_len) || in zcrypt_type6_crt_key()
215 copy_from_user(key->key_parts + long_len + short_len, in zcrypt_type6_crt_key()
216 crt->bp_key, long_len) || in zcrypt_type6_crt_key()
217 copy_from_user(key->key_parts + 2 * long_len + short_len, in zcrypt_type6_crt_key()
218 crt->bq_key, short_len) || in zcrypt_type6_crt_key()
219 copy_from_user(key->key_parts + 2 * long_len + 2 * short_len, in zcrypt_type6_crt_key()
220 crt->u_mult_inv, long_len)) in zcrypt_type6_crt_key()
221 return -EFAULT; in zcrypt_type6_crt_key()
222 memset(key->key_parts + 3 * long_len + 2 * short_len + pad_len, in zcrypt_type6_crt_key()
223 0xff, crt->inputdatalength); in zcrypt_type6_crt_key()
224 pub = (struct cca_public_sec *)(key->key_parts + key_len); in zcrypt_type6_crt_key()
226 pub->modulus_bit_len = 8 * crt->inputdatalength; in zcrypt_type6_crt_key()
228 * In a private key, the modulus doesn't appear in the public in zcrypt_type6_crt_key()