]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-rpmb: send RPMB_REQ_READ_RESULT for authentication key programming
authorTokunori Ikegami <ikegami.t@gmail.com>
Fri, 28 Jun 2024 11:57:40 +0000 (20:57 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 9 Jul 2024 14:33:09 +0000 (16:33 +0200)
This follows the NVMe revision 2.0a authentication key data flow.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme-rpmb.c

index b35ce1d70f3bbd13d933598d0c41be8a7f85c199..692b062188c5523464a11cc8837dbebcd088301e 100644 (file)
@@ -601,9 +601,28 @@ static int rpmb_program_auth_key(int fd, unsigned char target,
                goto out;
        }
 
-       /* send request and read the result first */
-       rsp = rpmb_read_request(fd, req, req_size, rsp_size);
-       if (rsp == NULL || rsp->result != 0) {
+       /* send the request and get response */
+       err = send_rpmb_req(fd, req->target, req_size, req);
+       if (err) {
+               fprintf(stderr, "RPMB request 0x%04x for 0x%x, err: %d\n", req->type, req->target,
+                       err);
+               goto out;
+       }
+
+       /* send the request to get the result and then request to get the response */
+       rsp = (struct rpmb_data_frame_t *)calloc(rsp_size, 1);
+       if (!rsp) {
+               fprintf(stderr, "failed to allocate response buffer memory\n");
+               err = -ENOMEM;
+               goto out;
+       }
+
+       rsp->target = req->target;
+       rsp->type = RPMB_REQ_READ_RESULT;
+       err = send_rpmb_req(fd, req->target, rsp_size, rsp);
+       if (err || rsp->result) {
+               fprintf(stderr, "Program auth key read result 0x%x, error = 0x%x\n", rsp->result,
+                       err);
                goto out;
        }