Lines Matching refs:crypto

45 	struct snp_guest_crypto *crypto;  member
146 struct snp_guest_crypto *crypto; in init_crypto() local
148 crypto = kzalloc(sizeof(*crypto), GFP_KERNEL_ACCOUNT); in init_crypto()
149 if (!crypto) in init_crypto()
152 crypto->tfm = crypto_alloc_aead("gcm(aes)", 0, 0); in init_crypto()
153 if (IS_ERR(crypto->tfm)) in init_crypto()
156 if (crypto_aead_setkey(crypto->tfm, key, keylen)) in init_crypto()
159 crypto->iv_len = crypto_aead_ivsize(crypto->tfm); in init_crypto()
160 crypto->iv = kmalloc(crypto->iv_len, GFP_KERNEL_ACCOUNT); in init_crypto()
161 if (!crypto->iv) in init_crypto()
164 if (crypto_aead_authsize(crypto->tfm) > MAX_AUTHTAG_LEN) { in init_crypto()
165 if (crypto_aead_setauthsize(crypto->tfm, MAX_AUTHTAG_LEN)) { in init_crypto()
171 crypto->a_len = crypto_aead_authsize(crypto->tfm); in init_crypto()
172 crypto->authtag = kmalloc(crypto->a_len, GFP_KERNEL_ACCOUNT); in init_crypto()
173 if (!crypto->authtag) in init_crypto()
176 return crypto; in init_crypto()
179 kfree(crypto->iv); in init_crypto()
181 crypto_free_aead(crypto->tfm); in init_crypto()
183 kfree(crypto); in init_crypto()
188 static void deinit_crypto(struct snp_guest_crypto *crypto) in deinit_crypto() argument
190 crypto_free_aead(crypto->tfm); in deinit_crypto()
191 kfree(crypto->iv); in deinit_crypto()
192 kfree(crypto->authtag); in deinit_crypto()
193 kfree(crypto); in deinit_crypto()
196 static int enc_dec_message(struct snp_guest_crypto *crypto, struct snp_guest_msg *msg, in enc_dec_message() argument
205 req = aead_request_alloc(crypto->tfm, GFP_KERNEL); in enc_dec_message()
220 sg_set_buf(&src[2], hdr->authtag, crypto->a_len); in enc_dec_message()
225 sg_set_buf(&dst[2], hdr->authtag, crypto->a_len); in enc_dec_message()
228 aead_request_set_tfm(req, crypto->tfm); in enc_dec_message()
231 aead_request_set_crypt(req, src, dst, len, crypto->iv); in enc_dec_message()
241 struct snp_guest_crypto *crypto = snp_dev->crypto; in __enc_payload() local
244 memset(crypto->iv, 0, crypto->iv_len); in __enc_payload()
245 memcpy(crypto->iv, &hdr->msg_seqno, sizeof(hdr->msg_seqno)); in __enc_payload()
247 return enc_dec_message(crypto, msg, plaintext, msg->payload, len, true); in __enc_payload()
253 struct snp_guest_crypto *crypto = snp_dev->crypto; in dec_payload() local
257 memset(crypto->iv, 0, crypto->iv_len); in dec_payload()
258 memcpy(crypto->iv, &hdr->msg_seqno, sizeof(hdr->msg_seqno)); in dec_payload()
260 return enc_dec_message(crypto, msg, msg->payload, plaintext, len, false); in dec_payload()
265 struct snp_guest_crypto *crypto = snp_dev->crypto; in verify_and_dec_payload() local
287 if (unlikely((resp_hdr->msg_sz + crypto->a_len) > sz)) in verify_and_dec_payload()
291 return dec_payload(snp_dev, resp, payload, resp_hdr->msg_sz + crypto->a_len); in verify_and_dec_payload()
424 struct snp_guest_crypto *crypto = snp_dev->crypto; in get_report() local
442 resp_len = sizeof(resp->data) + crypto->a_len; in get_report()
463 struct snp_guest_crypto *crypto = snp_dev->crypto; in get_derived_key() local
480 resp_len = sizeof(resp.data) + crypto->a_len; in get_derived_key()
505 struct snp_guest_crypto *crypto = snp_dev->crypto; in get_ext_report() local
543 resp_len = sizeof(resp->data) + crypto->a_len; in get_ext_report()
752 snp_dev->crypto = init_crypto(snp_dev, snp_dev->vmpck, VMPCK_KEY_LEN); in sev_guest_probe()
753 if (!snp_dev->crypto) in sev_guest_probe()
791 deinit_crypto(snp_dev->crypto); in sev_guest_remove()