Lines Matching refs:chap

123 		struct nvme_dhchap_queue_context *chap)  in nvme_auth_set_dhchap_negotiate_data()  argument
125 struct nvmf_auth_dhchap_negotiate_data *data = chap->buf; in nvme_auth_set_dhchap_negotiate_data()
129 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_set_dhchap_negotiate_data()
132 memset((u8 *)chap->buf, 0, size); in nvme_auth_set_dhchap_negotiate_data()
135 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_negotiate_data()
136 if (ctrl->opts->concat && chap->qid == 0) { in nvme_auth_set_dhchap_negotiate_data()
161 struct nvme_dhchap_queue_context *chap) in nvme_auth_process_dhchap_challenge() argument
163 struct nvmf_auth_dhchap_challenge_data *data = chap->buf; in nvme_auth_process_dhchap_challenge()
170 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_process_dhchap_challenge()
178 chap->qid, data->hashid); in nvme_auth_process_dhchap_challenge()
179 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; in nvme_auth_process_dhchap_challenge()
183 if (chap->hash_id == data->hashid && chap->shash_tfm && in nvme_auth_process_dhchap_challenge()
184 !strcmp(crypto_shash_alg_name(chap->shash_tfm), hmac_name) && in nvme_auth_process_dhchap_challenge()
185 crypto_shash_digestsize(chap->shash_tfm) == data->hl) { in nvme_auth_process_dhchap_challenge()
188 chap->qid, hmac_name); in nvme_auth_process_dhchap_challenge()
193 if (chap->shash_tfm) { in nvme_auth_process_dhchap_challenge()
194 crypto_free_shash(chap->shash_tfm); in nvme_auth_process_dhchap_challenge()
195 chap->hash_id = 0; in nvme_auth_process_dhchap_challenge()
196 chap->hash_len = 0; in nvme_auth_process_dhchap_challenge()
198 chap->shash_tfm = crypto_alloc_shash(hmac_name, 0, in nvme_auth_process_dhchap_challenge()
200 if (IS_ERR(chap->shash_tfm)) { in nvme_auth_process_dhchap_challenge()
203 chap->qid, hmac_name, PTR_ERR(chap->shash_tfm)); in nvme_auth_process_dhchap_challenge()
204 chap->shash_tfm = NULL; in nvme_auth_process_dhchap_challenge()
205 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_process_dhchap_challenge()
209 if (crypto_shash_digestsize(chap->shash_tfm) != data->hl) { in nvme_auth_process_dhchap_challenge()
212 chap->qid, data->hl); in nvme_auth_process_dhchap_challenge()
213 crypto_free_shash(chap->shash_tfm); in nvme_auth_process_dhchap_challenge()
214 chap->shash_tfm = NULL; in nvme_auth_process_dhchap_challenge()
215 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; in nvme_auth_process_dhchap_challenge()
219 chap->hash_id = data->hashid; in nvme_auth_process_dhchap_challenge()
220 chap->hash_len = data->hl; in nvme_auth_process_dhchap_challenge()
222 chap->qid, hmac_name); in nvme_auth_process_dhchap_challenge()
229 chap->qid, data->dhgid); in nvme_auth_process_dhchap_challenge()
230 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; in nvme_auth_process_dhchap_challenge()
235 if (chap->dhgroup_id == data->dhgid && in nvme_auth_process_dhchap_challenge()
236 (data->dhgid == NVME_AUTH_DHGROUP_NULL || chap->dh_tfm)) { in nvme_auth_process_dhchap_challenge()
239 chap->qid, gid_name); in nvme_auth_process_dhchap_challenge()
244 if (chap->dh_tfm) { in nvme_auth_process_dhchap_challenge()
245 crypto_free_kpp(chap->dh_tfm); in nvme_auth_process_dhchap_challenge()
246 chap->dh_tfm = NULL; in nvme_auth_process_dhchap_challenge()
253 chap->qid); in nvme_auth_process_dhchap_challenge()
254 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; in nvme_auth_process_dhchap_challenge()
258 chap->dh_tfm = crypto_alloc_kpp(kpp_name, 0, 0); in nvme_auth_process_dhchap_challenge()
259 if (IS_ERR(chap->dh_tfm)) { in nvme_auth_process_dhchap_challenge()
260 int ret = PTR_ERR(chap->dh_tfm); in nvme_auth_process_dhchap_challenge()
264 chap->qid, ret, gid_name); in nvme_auth_process_dhchap_challenge()
265 chap->status = NVME_AUTH_DHCHAP_FAILURE_DHGROUP_UNUSABLE; in nvme_auth_process_dhchap_challenge()
266 chap->dh_tfm = NULL; in nvme_auth_process_dhchap_challenge()
270 chap->qid, gid_name); in nvme_auth_process_dhchap_challenge()
274 chap->qid); in nvme_auth_process_dhchap_challenge()
275 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_process_dhchap_challenge()
278 chap->dhgroup_id = data->dhgid; in nvme_auth_process_dhchap_challenge()
281 chap->s1 = le32_to_cpu(data->seqnum); in nvme_auth_process_dhchap_challenge()
282 memcpy(chap->c1, data->cval, chap->hash_len); in nvme_auth_process_dhchap_challenge()
284 chap->ctrl_key = kmalloc(dhvlen, GFP_KERNEL); in nvme_auth_process_dhchap_challenge()
285 if (!chap->ctrl_key) { in nvme_auth_process_dhchap_challenge()
286 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_process_dhchap_challenge()
289 chap->ctrl_key_len = dhvlen; in nvme_auth_process_dhchap_challenge()
290 memcpy(chap->ctrl_key, data->cval + chap->hash_len, in nvme_auth_process_dhchap_challenge()
293 (int)chap->ctrl_key_len, chap->ctrl_key); in nvme_auth_process_dhchap_challenge()
300 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_reply_data() argument
302 struct nvmf_auth_dhchap_reply_data *data = chap->buf; in nvme_auth_set_dhchap_reply_data()
305 size += 2 * chap->hash_len; in nvme_auth_set_dhchap_reply_data()
307 if (chap->host_key_len) in nvme_auth_set_dhchap_reply_data()
308 size += chap->host_key_len; in nvme_auth_set_dhchap_reply_data()
311 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_set_dhchap_reply_data()
315 memset(chap->buf, 0, size); in nvme_auth_set_dhchap_reply_data()
318 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_reply_data()
319 data->hl = chap->hash_len; in nvme_auth_set_dhchap_reply_data()
320 data->dhvlen = cpu_to_le16(chap->host_key_len); in nvme_auth_set_dhchap_reply_data()
321 memcpy(data->rval, chap->response, chap->hash_len); in nvme_auth_set_dhchap_reply_data()
323 chap->bi_directional = true; in nvme_auth_set_dhchap_reply_data()
325 get_random_bytes(chap->c2, chap->hash_len); in nvme_auth_set_dhchap_reply_data()
327 memcpy(data->rval + chap->hash_len, chap->c2, in nvme_auth_set_dhchap_reply_data()
328 chap->hash_len); in nvme_auth_set_dhchap_reply_data()
330 __func__, chap->qid, (int)chap->hash_len, chap->c2); in nvme_auth_set_dhchap_reply_data()
332 memset(chap->c2, 0, chap->hash_len); in nvme_auth_set_dhchap_reply_data()
335 chap->s2 = 0; in nvme_auth_set_dhchap_reply_data()
337 chap->s2 = nvme_auth_get_seqnum(); in nvme_auth_set_dhchap_reply_data()
338 data->seqnum = cpu_to_le32(chap->s2); in nvme_auth_set_dhchap_reply_data()
339 if (chap->host_key_len) { in nvme_auth_set_dhchap_reply_data()
341 __func__, chap->qid, in nvme_auth_set_dhchap_reply_data()
342 chap->host_key_len, chap->host_key); in nvme_auth_set_dhchap_reply_data()
343 memcpy(data->rval + 2 * chap->hash_len, chap->host_key, in nvme_auth_set_dhchap_reply_data()
344 chap->host_key_len); in nvme_auth_set_dhchap_reply_data()
351 struct nvme_dhchap_queue_context *chap) in nvme_auth_process_dhchap_success1() argument
353 struct nvmf_auth_dhchap_success1_data *data = chap->buf; in nvme_auth_process_dhchap_success1()
354 size_t size = sizeof(*data) + chap->hash_len; in nvme_auth_process_dhchap_success1()
357 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_process_dhchap_success1()
361 if (data->hl != chap->hash_len) { in nvme_auth_process_dhchap_success1()
364 chap->qid, data->hl); in nvme_auth_process_dhchap_success1()
365 chap->status = NVME_AUTH_DHCHAP_FAILURE_HASH_UNUSABLE; in nvme_auth_process_dhchap_success1()
370 if (chap->qid == 0) in nvme_auth_process_dhchap_success1()
373 nvme_auth_hmac_name(chap->hash_id), in nvme_auth_process_dhchap_success1()
374 nvme_auth_dhgroup_name(chap->dhgroup_id)); in nvme_auth_process_dhchap_success1()
380 if (memcmp(chap->response, data->rval, data->hl)) { in nvme_auth_process_dhchap_success1()
382 __func__, chap->qid, (int)chap->hash_len, data->rval); in nvme_auth_process_dhchap_success1()
384 __func__, chap->qid, (int)chap->hash_len, in nvme_auth_process_dhchap_success1()
385 chap->response); in nvme_auth_process_dhchap_success1()
388 chap->qid); in nvme_auth_process_dhchap_success1()
389 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_process_dhchap_success1()
394 if (chap->qid == 0) in nvme_auth_process_dhchap_success1()
401 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_success2_data() argument
403 struct nvmf_auth_dhchap_success2_data *data = chap->buf; in nvme_auth_set_dhchap_success2_data()
406 memset(chap->buf, 0, size); in nvme_auth_set_dhchap_success2_data()
409 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_success2_data()
415 struct nvme_dhchap_queue_context *chap) in nvme_auth_set_dhchap_failure2_data() argument
417 struct nvmf_auth_dhchap_failure_data *data = chap->buf; in nvme_auth_set_dhchap_failure2_data()
420 memset(chap->buf, 0, size); in nvme_auth_set_dhchap_failure2_data()
423 data->t_id = cpu_to_le16(chap->transaction); in nvme_auth_set_dhchap_failure2_data()
425 data->rescode_exp = chap->status; in nvme_auth_set_dhchap_failure2_data()
431 struct nvme_dhchap_queue_context *chap) in nvme_auth_dhchap_setup_host_response() argument
433 SHASH_DESC_ON_STACK(shash, chap->shash_tfm); in nvme_auth_dhchap_setup_host_response()
434 u8 buf[4], *challenge = chap->c1; in nvme_auth_dhchap_setup_host_response()
438 __func__, chap->qid, chap->s1, chap->transaction); in nvme_auth_dhchap_setup_host_response()
440 if (!chap->transformed_key) { in nvme_auth_dhchap_setup_host_response()
441 chap->transformed_key = nvme_auth_transform_key(ctrl->host_key, in nvme_auth_dhchap_setup_host_response()
443 if (IS_ERR(chap->transformed_key)) { in nvme_auth_dhchap_setup_host_response()
444 ret = PTR_ERR(chap->transformed_key); in nvme_auth_dhchap_setup_host_response()
445 chap->transformed_key = NULL; in nvme_auth_dhchap_setup_host_response()
450 __func__, chap->qid); in nvme_auth_dhchap_setup_host_response()
453 ret = crypto_shash_setkey(chap->shash_tfm, in nvme_auth_dhchap_setup_host_response()
454 chap->transformed_key->key, chap->transformed_key->len); in nvme_auth_dhchap_setup_host_response()
457 chap->qid, ret); in nvme_auth_dhchap_setup_host_response()
461 if (chap->dh_tfm) { in nvme_auth_dhchap_setup_host_response()
462 challenge = kmalloc(chap->hash_len, GFP_KERNEL); in nvme_auth_dhchap_setup_host_response()
467 ret = nvme_auth_augmented_challenge(chap->hash_id, in nvme_auth_dhchap_setup_host_response()
468 chap->sess_key, in nvme_auth_dhchap_setup_host_response()
469 chap->sess_key_len, in nvme_auth_dhchap_setup_host_response()
470 chap->c1, challenge, in nvme_auth_dhchap_setup_host_response()
471 chap->hash_len); in nvme_auth_dhchap_setup_host_response()
476 shash->tfm = chap->shash_tfm; in nvme_auth_dhchap_setup_host_response()
480 ret = crypto_shash_update(shash, challenge, chap->hash_len); in nvme_auth_dhchap_setup_host_response()
483 put_unaligned_le32(chap->s1, buf); in nvme_auth_dhchap_setup_host_response()
487 put_unaligned_le16(chap->transaction, buf); in nvme_auth_dhchap_setup_host_response()
509 ret = crypto_shash_final(shash, chap->response); in nvme_auth_dhchap_setup_host_response()
511 if (challenge != chap->c1) in nvme_auth_dhchap_setup_host_response()
517 struct nvme_dhchap_queue_context *chap) in nvme_auth_dhchap_setup_ctrl_response() argument
519 SHASH_DESC_ON_STACK(shash, chap->shash_tfm); in nvme_auth_dhchap_setup_ctrl_response()
521 u8 buf[4], *challenge = chap->c2; in nvme_auth_dhchap_setup_ctrl_response()
531 ret = crypto_shash_setkey(chap->shash_tfm, in nvme_auth_dhchap_setup_ctrl_response()
535 chap->qid, ret); in nvme_auth_dhchap_setup_ctrl_response()
539 if (chap->dh_tfm) { in nvme_auth_dhchap_setup_ctrl_response()
540 challenge = kmalloc(chap->hash_len, GFP_KERNEL); in nvme_auth_dhchap_setup_ctrl_response()
545 ret = nvme_auth_augmented_challenge(chap->hash_id, in nvme_auth_dhchap_setup_ctrl_response()
546 chap->sess_key, in nvme_auth_dhchap_setup_ctrl_response()
547 chap->sess_key_len, in nvme_auth_dhchap_setup_ctrl_response()
548 chap->c2, challenge, in nvme_auth_dhchap_setup_ctrl_response()
549 chap->hash_len); in nvme_auth_dhchap_setup_ctrl_response()
554 __func__, chap->qid, chap->s2, chap->transaction); in nvme_auth_dhchap_setup_ctrl_response()
556 __func__, chap->qid, (int)chap->hash_len, challenge); in nvme_auth_dhchap_setup_ctrl_response()
558 __func__, chap->qid, ctrl->opts->subsysnqn); in nvme_auth_dhchap_setup_ctrl_response()
560 __func__, chap->qid, ctrl->opts->host->nqn); in nvme_auth_dhchap_setup_ctrl_response()
561 shash->tfm = chap->shash_tfm; in nvme_auth_dhchap_setup_ctrl_response()
565 ret = crypto_shash_update(shash, challenge, chap->hash_len); in nvme_auth_dhchap_setup_ctrl_response()
568 put_unaligned_le32(chap->s2, buf); in nvme_auth_dhchap_setup_ctrl_response()
572 put_unaligned_le16(chap->transaction, buf); in nvme_auth_dhchap_setup_ctrl_response()
594 ret = crypto_shash_final(shash, chap->response); in nvme_auth_dhchap_setup_ctrl_response()
596 if (challenge != chap->c2) in nvme_auth_dhchap_setup_ctrl_response()
603 struct nvme_dhchap_queue_context *chap) in nvme_auth_dhchap_exponential() argument
607 if (chap->host_key && chap->host_key_len) { in nvme_auth_dhchap_exponential()
609 "qid %d: reusing host key\n", chap->qid); in nvme_auth_dhchap_exponential()
612 ret = nvme_auth_gen_privkey(chap->dh_tfm, chap->dhgroup_id); in nvme_auth_dhchap_exponential()
614 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_dhchap_exponential()
618 chap->host_key_len = crypto_kpp_maxsize(chap->dh_tfm); in nvme_auth_dhchap_exponential()
620 chap->host_key = kzalloc(chap->host_key_len, GFP_KERNEL); in nvme_auth_dhchap_exponential()
621 if (!chap->host_key) { in nvme_auth_dhchap_exponential()
622 chap->host_key_len = 0; in nvme_auth_dhchap_exponential()
623 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_dhchap_exponential()
626 ret = nvme_auth_gen_pubkey(chap->dh_tfm, in nvme_auth_dhchap_exponential()
627 chap->host_key, chap->host_key_len); in nvme_auth_dhchap_exponential()
631 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_dhchap_exponential()
636 chap->sess_key_len = chap->host_key_len; in nvme_auth_dhchap_exponential()
637 chap->sess_key = kmalloc(chap->sess_key_len, GFP_KERNEL); in nvme_auth_dhchap_exponential()
638 if (!chap->sess_key) { in nvme_auth_dhchap_exponential()
639 chap->sess_key_len = 0; in nvme_auth_dhchap_exponential()
640 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_auth_dhchap_exponential()
644 ret = nvme_auth_gen_shared_secret(chap->dh_tfm, in nvme_auth_dhchap_exponential()
645 chap->ctrl_key, chap->ctrl_key_len, in nvme_auth_dhchap_exponential()
646 chap->sess_key, chap->sess_key_len); in nvme_auth_dhchap_exponential()
650 chap->status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_PAYLOAD; in nvme_auth_dhchap_exponential()
654 (int)chap->sess_key_len, chap->sess_key); in nvme_auth_dhchap_exponential()
658 static void nvme_auth_reset_dhchap(struct nvme_dhchap_queue_context *chap) in nvme_auth_reset_dhchap() argument
660 nvme_auth_free_key(chap->transformed_key); in nvme_auth_reset_dhchap()
661 chap->transformed_key = NULL; in nvme_auth_reset_dhchap()
662 kfree_sensitive(chap->host_key); in nvme_auth_reset_dhchap()
663 chap->host_key = NULL; in nvme_auth_reset_dhchap()
664 chap->host_key_len = 0; in nvme_auth_reset_dhchap()
665 kfree_sensitive(chap->ctrl_key); in nvme_auth_reset_dhchap()
666 chap->ctrl_key = NULL; in nvme_auth_reset_dhchap()
667 chap->ctrl_key_len = 0; in nvme_auth_reset_dhchap()
668 kfree_sensitive(chap->sess_key); in nvme_auth_reset_dhchap()
669 chap->sess_key = NULL; in nvme_auth_reset_dhchap()
670 chap->sess_key_len = 0; in nvme_auth_reset_dhchap()
671 chap->status = 0; in nvme_auth_reset_dhchap()
672 chap->error = 0; in nvme_auth_reset_dhchap()
673 chap->s1 = 0; in nvme_auth_reset_dhchap()
674 chap->s2 = 0; in nvme_auth_reset_dhchap()
675 chap->bi_directional = false; in nvme_auth_reset_dhchap()
676 chap->transaction = 0; in nvme_auth_reset_dhchap()
677 memset(chap->c1, 0, sizeof(chap->c1)); in nvme_auth_reset_dhchap()
678 memset(chap->c2, 0, sizeof(chap->c2)); in nvme_auth_reset_dhchap()
679 mempool_free(chap->buf, nvme_chap_buf_pool); in nvme_auth_reset_dhchap()
680 chap->buf = NULL; in nvme_auth_reset_dhchap()
683 static void nvme_auth_free_dhchap(struct nvme_dhchap_queue_context *chap) in nvme_auth_free_dhchap() argument
685 nvme_auth_reset_dhchap(chap); in nvme_auth_free_dhchap()
686 chap->authenticated = false; in nvme_auth_free_dhchap()
687 if (chap->shash_tfm) in nvme_auth_free_dhchap()
688 crypto_free_shash(chap->shash_tfm); in nvme_auth_free_dhchap()
689 if (chap->dh_tfm) in nvme_auth_free_dhchap()
690 crypto_free_kpp(chap->dh_tfm); in nvme_auth_free_dhchap()
704 struct nvme_dhchap_queue_context *chap) in nvme_auth_secure_concat() argument
711 if (!chap->sess_key) { in nvme_auth_secure_concat()
714 __func__, chap->qid); in nvme_auth_secure_concat()
718 if (chap->qid) { in nvme_auth_secure_concat()
721 chap->qid); in nvme_auth_secure_concat()
724 ret = nvme_auth_generate_psk(chap->hash_id, chap->sess_key, in nvme_auth_secure_concat()
725 chap->sess_key_len, in nvme_auth_secure_concat()
726 chap->c1, chap->c2, in nvme_auth_secure_concat()
727 chap->hash_len, &psk, &psk_len); in nvme_auth_secure_concat()
731 __func__, chap->qid, ret); in nvme_auth_secure_concat()
737 ret = nvme_auth_generate_digest(chap->hash_id, psk, psk_len, in nvme_auth_secure_concat()
743 __func__, chap->qid, ret); in nvme_auth_secure_concat()
748 ret = nvme_auth_derive_tls_psk(chap->hash_id, psk, psk_len, in nvme_auth_secure_concat()
753 __func__, chap->qid, ret); in nvme_auth_secure_concat()
759 ctrl->opts->subsysnqn, chap->hash_id, in nvme_auth_secure_concat()
765 __func__, chap->qid, ret); in nvme_auth_secure_concat()
781 struct nvme_dhchap_queue_context *chap = in nvme_queue_auth_work() local
783 struct nvme_ctrl *ctrl = chap->ctrl; in nvme_queue_auth_work()
791 chap->buf = mempool_alloc(nvme_chap_buf_pool, GFP_KERNEL); in nvme_queue_auth_work()
792 if (!chap->buf) { in nvme_queue_auth_work()
793 chap->error = -ENOMEM; in nvme_queue_auth_work()
797 chap->transaction = ctrl->transaction++; in nvme_queue_auth_work()
801 __func__, chap->qid); in nvme_queue_auth_work()
802 ret = nvme_auth_set_dhchap_negotiate_data(ctrl, chap); in nvme_queue_auth_work()
804 chap->error = ret; in nvme_queue_auth_work()
808 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in nvme_queue_auth_work()
810 chap->error = ret; in nvme_queue_auth_work()
816 __func__, chap->qid); in nvme_queue_auth_work()
818 memset(chap->buf, 0, CHAP_BUF_SIZE); in nvme_queue_auth_work()
819 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, CHAP_BUF_SIZE, in nvme_queue_auth_work()
824 chap->qid, ret < 0 ? "error" : "nvme status", ret); in nvme_queue_auth_work()
825 chap->error = ret; in nvme_queue_auth_work()
828 ret = nvme_auth_receive_validate(ctrl, chap->qid, chap->buf, chap->transaction, in nvme_queue_auth_work()
831 chap->status = ret; in nvme_queue_auth_work()
832 chap->error = -EKEYREJECTED; in nvme_queue_auth_work()
836 ret = nvme_auth_process_dhchap_challenge(ctrl, chap); in nvme_queue_auth_work()
839 chap->error = ret; in nvme_queue_auth_work()
843 if (chap->ctrl_key_len) { in nvme_queue_auth_work()
846 __func__, chap->qid); in nvme_queue_auth_work()
847 ret = nvme_auth_dhchap_exponential(ctrl, chap); in nvme_queue_auth_work()
849 chap->error = ret; in nvme_queue_auth_work()
855 __func__, chap->qid); in nvme_queue_auth_work()
857 ret = nvme_auth_dhchap_setup_host_response(ctrl, chap); in nvme_queue_auth_work()
860 chap->error = ret; in nvme_queue_auth_work()
866 __func__, chap->qid); in nvme_queue_auth_work()
867 ret = nvme_auth_set_dhchap_reply_data(ctrl, chap); in nvme_queue_auth_work()
869 chap->error = ret; in nvme_queue_auth_work()
874 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in nvme_queue_auth_work()
876 chap->error = ret; in nvme_queue_auth_work()
882 __func__, chap->qid); in nvme_queue_auth_work()
884 memset(chap->buf, 0, CHAP_BUF_SIZE); in nvme_queue_auth_work()
885 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, CHAP_BUF_SIZE, in nvme_queue_auth_work()
890 chap->qid, ret < 0 ? "error" : "nvme status", ret); in nvme_queue_auth_work()
891 chap->error = ret; in nvme_queue_auth_work()
894 ret = nvme_auth_receive_validate(ctrl, chap->qid, in nvme_queue_auth_work()
895 chap->buf, chap->transaction, in nvme_queue_auth_work()
898 chap->status = ret; in nvme_queue_auth_work()
899 chap->error = -EKEYREJECTED; in nvme_queue_auth_work()
907 __func__, chap->qid); in nvme_queue_auth_work()
908 ret = nvme_auth_dhchap_setup_ctrl_response(ctrl, chap); in nvme_queue_auth_work()
911 chap->error = ret; in nvme_queue_auth_work()
917 ret = nvme_auth_process_dhchap_success1(ctrl, chap); in nvme_queue_auth_work()
920 chap->error = -EKEYREJECTED; in nvme_queue_auth_work()
924 if (chap->bi_directional) { in nvme_queue_auth_work()
927 __func__, chap->qid); in nvme_queue_auth_work()
928 tl = nvme_auth_set_dhchap_success2_data(ctrl, chap); in nvme_queue_auth_work()
929 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in nvme_queue_auth_work()
931 chap->error = ret; in nvme_queue_auth_work()
934 chap->error = 0; in nvme_queue_auth_work()
935 chap->authenticated = true; in nvme_queue_auth_work()
937 (ret = nvme_auth_secure_concat(ctrl, chap))) { in nvme_queue_auth_work()
940 __func__, chap->qid); in nvme_queue_auth_work()
941 chap->error = ret; in nvme_queue_auth_work()
942 chap->authenticated = false; in nvme_queue_auth_work()
948 if (chap->status == 0) in nvme_queue_auth_work()
949 chap->status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvme_queue_auth_work()
951 __func__, chap->qid, chap->status); in nvme_queue_auth_work()
952 tl = nvme_auth_set_dhchap_failure2_data(ctrl, chap); in nvme_queue_auth_work()
953 ret = nvme_auth_submit(ctrl, chap->qid, chap->buf, tl, true); in nvme_queue_auth_work()
958 if (ret && !chap->error) in nvme_queue_auth_work()
959 chap->error = ret; in nvme_queue_auth_work()
964 struct nvme_dhchap_queue_context *chap; in nvme_auth_negotiate() local
976 chap = &ctrl->dhchap_ctxs[qid]; in nvme_auth_negotiate()
977 cancel_work_sync(&chap->auth_work); in nvme_auth_negotiate()
978 queue_work(nvme_auth_wq, &chap->auth_work); in nvme_auth_negotiate()
985 struct nvme_dhchap_queue_context *chap; in nvme_auth_wait() local
988 chap = &ctrl->dhchap_ctxs[qid]; in nvme_auth_wait()
989 flush_work(&chap->auth_work); in nvme_auth_wait()
990 ret = chap->error; in nvme_auth_wait()
992 nvme_auth_reset_dhchap(chap); in nvme_auth_wait()
1030 struct nvme_dhchap_queue_context *chap = in nvme_ctrl_auth_work() local
1036 if (!chap->authenticated) in nvme_ctrl_auth_work()
1038 cancel_work_sync(&chap->auth_work); in nvme_ctrl_auth_work()
1039 queue_work(nvme_auth_wq, &chap->auth_work); in nvme_ctrl_auth_work()
1047 struct nvme_dhchap_queue_context *chap = in nvme_ctrl_auth_work() local
1049 if (!chap->authenticated) in nvme_ctrl_auth_work()
1051 flush_work(&chap->auth_work); in nvme_ctrl_auth_work()
1052 ret = chap->error; in nvme_ctrl_auth_work()
1053 nvme_auth_reset_dhchap(chap); in nvme_ctrl_auth_work()
1062 struct nvme_dhchap_queue_context *chap; in nvme_auth_init_ctrl() local
1082 sizeof(*chap), GFP_KERNEL); in nvme_auth_init_ctrl()
1089 chap = &ctrl->dhchap_ctxs[i]; in nvme_auth_init_ctrl()
1090 chap->qid = i; in nvme_auth_init_ctrl()
1091 chap->ctrl = ctrl; in nvme_auth_init_ctrl()
1092 chap->authenticated = false; in nvme_auth_init_ctrl()
1093 INIT_WORK(&chap->auth_work, nvme_queue_auth_work); in nvme_auth_init_ctrl()