Lines Matching +full:string +full:- +full:array +full:- +full:property
8 * top-level directory.
13 #include "qemu/guest-random.h"
18 #include "hw/virtio/virtio-nsm.h"
19 #include "hw/virtio/cbor-helpers.h"
20 #include "standard-headers/linux/virtio_ids.h"
72 * key = String("Error"),
73 * value = String(error_name)
104 len = cbor_serialize(root, response->iov_base, response->iov_len); in error_response()
110 response->iov_len = len; in error_response()
129 * key = String("GetRandom"),
131 * key = String("random"),
161 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_get_random()
169 response->iov_len = len; in handle_get_random()
188 * key = String("DescribeNSM"),
190 * key = String("digest"),
191 * value = String("SHA384"),
192 * key = String("max_pcrs"),
194 * key = String("module_id"),
195 * value = String("i-1234-enc5678"),
196 * key = String("locked_pcrs"),
197 * value = Array<Uint8>(),
198 * key = String("version_major"),
200 * key = String("version_minor"),
202 * key = String("version_patch"),
226 if (!qemu_cbor_add_string_to_map(nested_map, "digest", vnsm->digest)) { in handle_describe_nsm()
230 if (!qemu_cbor_add_uint8_to_map(nested_map, "max_pcrs", vnsm->max_pcrs)) { in handle_describe_nsm()
235 vnsm->module_id)) { in handle_describe_nsm()
240 if (vnsm->pcrs[i].locked) { in handle_describe_nsm()
250 vnsm->version_major)) { in handle_describe_nsm()
255 vnsm->version_minor)) { in handle_describe_nsm()
260 vnsm->version_patch)) { in handle_describe_nsm()
264 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_describe_nsm()
272 response->iov_len = len; in handle_describe_nsm()
291 * key = String("DescribePCR"),
293 * key = String("index"),
320 if (!cbor_isa_map(pair->value)) { in get_nsm_describe_pcr_req()
323 size = cbor_map_size(pair->value); in get_nsm_describe_pcr_req()
328 pair = cbor_map_handle(pair->value); in get_nsm_describe_pcr_req()
342 nsm_req->index = cbor_get_uint8(pair[i].value); in get_nsm_describe_pcr_req()
360 * key = String("DescribePCR"),
362 * key = String("data"),
364 * key = String("lock"),
381 type = get_nsm_describe_pcr_req(request->iov_base, request->iov_len, in handle_describe_pcr()
389 if (nsm_req.index >= vnsm->max_pcrs) { in handle_describe_pcr()
395 pcr = &(vnsm->pcrs[nsm_req.index]); in handle_describe_pcr()
406 if (!qemu_cbor_add_bytestring_to_map(nested_map, "data", pcr->data, in handle_describe_pcr()
411 if (!qemu_cbor_add_bool_to_map(nested_map, "lock", pcr->locked)) { in handle_describe_pcr()
415 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_describe_pcr()
423 response->iov_len = len; in handle_describe_pcr()
442 * key = String("ExtendPCR"),
444 * key = String("index"),
446 * key = String("data"),
447 * value = Byte_String(data) || String(data),
476 if (!cbor_isa_map(pair->value)) { in get_nsm_extend_pcr_req()
479 size = cbor_map_size(pair->value); in get_nsm_extend_pcr_req()
484 pair = cbor_map_handle(pair->value); in get_nsm_extend_pcr_req()
500 nsm_req->index = cbor_get_uint8(pair[i].value); in get_nsm_extend_pcr_req()
512 nsm_req->data_len = cbor_bytestring_length(pair[i].value); in get_nsm_extend_pcr_req()
518 nsm_req->data_len = cbor_string_length(pair[i].value); in get_nsm_extend_pcr_req()
523 * nsm_req->data_len will be smaller than NSM_REQUEST_MAX_SIZE as in get_nsm_extend_pcr_req()
527 memcpy(nsm_req->data, str, nsm_req->data_len); in get_nsm_extend_pcr_req()
549 * key = String("ExtendPCR"),
551 * key = String("data"),
568 type = get_nsm_extend_pcr_req(request->iov_base, request->iov_len, in handle_extend_pcr()
576 if (nsm_req->index >= vnsm->max_pcrs) { in handle_extend_pcr()
583 pcr = &(vnsm->pcrs[nsm_req->index]); in handle_extend_pcr()
585 if (pcr->locked) { in handle_extend_pcr()
592 if (!vnsm->extend_pcr(vnsm, nsm_req->index, nsm_req->data, in handle_extend_pcr()
593 nsm_req->data_len)) { in handle_extend_pcr()
609 if (!qemu_cbor_add_bytestring_to_map(nested_map, "data", pcr->data, in handle_extend_pcr()
614 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_extend_pcr()
622 response->iov_len = len; in handle_extend_pcr()
641 * key = String("LockPCR"),
643 * key = String("index"),
669 if (!cbor_isa_map(pair->value)) { in get_nsm_lock_pcr_req()
672 size = cbor_map_size(pair->value); in get_nsm_lock_pcr_req()
677 pair = cbor_map_handle(pair->value); in get_nsm_lock_pcr_req()
690 nsm_req->index = cbor_get_uint8(pair[i].value); in get_nsm_lock_pcr_req()
706 * String("LockPCR")
719 type = get_nsm_lock_pcr_req(request->iov_base, request->iov_len, &nsm_req); in handle_lock_pcr()
726 if (nsm_req.index >= vnsm->max_pcrs) { in handle_lock_pcr()
733 pcr = &(vnsm->pcrs[nsm_req.index]); in handle_lock_pcr()
735 if (pcr->locked) { in handle_lock_pcr()
742 pcr->locked = true; in handle_lock_pcr()
749 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_lock_pcr()
757 response->iov_len = len; in handle_lock_pcr()
776 * key = String("LockPCRs"),
778 * key = String("range"),
804 if (!cbor_isa_map(pair->value)) { in get_nsm_lock_pcrs_req()
807 size = cbor_map_size(pair->value); in get_nsm_lock_pcrs_req()
812 pair = cbor_map_handle(pair->value); in get_nsm_lock_pcrs_req()
825 nsm_req->range = cbor_get_uint8(pair[i].value); in get_nsm_lock_pcrs_req()
841 * String("LockPCRs")
853 type = get_nsm_lock_pcrs_req(request->iov_base, request->iov_len, &nsm_req); in handle_lock_pcrs()
860 if (nsm_req.range > vnsm->max_pcrs) { in handle_lock_pcrs()
868 vnsm->pcrs[i].locked = true; in handle_lock_pcrs()
876 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_lock_pcrs()
884 response->iov_len = len; in handle_lock_pcrs()
902 * key = String("Attestation"),
904 * key = String("user_data"),
906 * key = String("nonce"),
908 * key = String("public_key"),
916 bool is_null; /* True if property is not present in map or is null */
934 prop->is_null = true; in fill_attestation_property()
942 prop->len = cbor_bytestring_length(value); in fill_attestation_property()
948 prop->len = cbor_string_length(value); in fill_attestation_property()
954 * prop->len will be smaller than NSM_REQUEST_MAX_SIZE as we in fill_attestation_property()
958 memcpy(prop->buf, str, prop->len); in fill_attestation_property()
959 prop->is_null = false; in fill_attestation_property()
976 nsm_req->public_key.is_null = true; in get_nsm_attestation_req()
977 nsm_req->user_data.is_null = true; in get_nsm_attestation_req()
978 nsm_req->nonce.is_null = true; in get_nsm_attestation_req()
986 if (!cbor_isa_map(pair->value)) { in get_nsm_attestation_req()
989 size = cbor_map_size(pair->value); in get_nsm_attestation_req()
995 pair = cbor_map_handle(pair->value); in get_nsm_attestation_req()
1008 if (!fill_attestation_property(&(nsm_req->public_key), in get_nsm_attestation_req()
1017 if (!fill_attestation_property(&(nsm_req->user_data), in get_nsm_attestation_req()
1026 if (!fill_attestation_property(&(nsm_req->nonce), pair[i].value)) { in get_nsm_attestation_req()
1066 /* we don't actually sign the data, so we use -1 as the 'alg' value */ in add_protected_header_to_cose()
1182 if (!qemu_cbor_add_string_to_map(root, "module_id", vnsm->module_id)) { in add_payload_to_cose()
1185 if (!qemu_cbor_add_string_to_map(root, "digest", vnsm->digest)) { in add_payload_to_cose()
1195 if (vnsm->pcrs[i].locked) { in add_payload_to_cose()
1203 pcr = &(vnsm->pcrs[ind[i]]); in add_payload_to_cose()
1206 pcr->data, in add_payload_to_cose()
1218 if (req->public_key.is_null) { in add_payload_to_cose()
1223 req->public_key.buf, in add_payload_to_cose()
1224 req->public_key.len)) { in add_payload_to_cose()
1228 if (req->user_data.is_null) { in add_payload_to_cose()
1233 req->user_data.buf, in add_payload_to_cose()
1234 req->user_data.len)) { in add_payload_to_cose()
1238 if (req->nonce.is_null) { in add_payload_to_cose()
1243 req->nonce.buf, in add_payload_to_cose()
1244 req->nonce.len)) { in add_payload_to_cose()
1300 * key = String("Attestation"),
1302 * key = String("document"),
1310 * Array(4) {
1329 * [0] { key = String("module_id"), value = String(module_id) },
1330 * [1] { key = String("digest"), value = String("SHA384") },
1332 * key = String("timestamp"),
1336 * key = String("pcrs"),
1343 * key = String("certificate"),
1346 * [5] { key = String("cabundle"), value = Array(N) { ByteString()... } },
1347 * [6] { key = String("public_key"), value = ByteString() || null },
1348 * [7] { key = String("user_data"), value = ByteString() || null},
1349 * [8] { key = String("nonce"), value = ByteString() || null},
1366 nsm_req->public_key.is_null = true; in handle_attestation()
1367 nsm_req->user_data.is_null = true; in handle_attestation()
1368 nsm_req->nonce.is_null = true; in handle_attestation()
1370 type = get_nsm_attestation_req(request->iov_base, request->iov_len, in handle_attestation()
1412 len = cbor_serialize(root, response->iov_base, response->iov_len); in handle_attestation()
1420 response->iov_len = len; in handle_attestation()
1446 * 1) String(); "GetRandom", "DescribeNSM"
1447 * 2) Map(1) { key: String(), value: ... }
1481 if (cbor_isa_string(handle->key)) { in get_nsm_request_cmd()
1482 size = cbor_string_length(handle->key); in get_nsm_request_cmd()
1483 req = cbor_string_handle(handle->key); in get_nsm_request_cmd()
1517 if (req->iov_len > NSM_REQUEST_MAX_SIZE) { in get_nsm_request_response()
1525 cmd = get_nsm_request_cmd(req->iov_base, req->iov_len); in get_nsm_request_response()
1535 return cmd->response_fn(vnsm, req, resp, errp); in get_nsm_request_response()
1554 sz = iov_size(out_elem->out_sg, out_elem->out_num); in handle_input()
1556 virtio_error(vdev, "Expected non-zero sized request buffer in " in handle_input()
1567 if (iov_size(in_elem->in_sg, in_elem->in_num) != NSM_RESPONSE_BUF_SIZE) { in handle_input()
1573 req.iov_len = iov_to_buf(out_elem->out_sg, out_elem->out_num, 0, in handle_input()
1589 sz = iov_from_buf(in_elem->in_sg, in_elem->in_num, 0, res.iov_base, in handle_input()
1622 struct PCRInfo *pcr = &(vnsm->pcrs[ind]); in extend_pcr()
1627 { .iov_base = pcr->data, .iov_len = QCRYPTO_HASH_DIGEST_LEN_SHA384 }, in extend_pcr()
1636 memcpy(pcr->data, result, QCRYPTO_HASH_DIGEST_LEN_SHA384); in extend_pcr()
1642 vnsm->pcrs[ind].locked = true; in lock_pcr()
1650 vnsm->max_pcrs = NSM_MAX_PCRS; in virtio_nsm_device_realize()
1651 vnsm->digest = (char *) "SHA384"; in virtio_nsm_device_realize()
1652 if (vnsm->module_id == NULL) { in virtio_nsm_device_realize()
1653 vnsm->module_id = (char *) "i-234-enc5678"; in virtio_nsm_device_realize()
1655 vnsm->version_major = 1; in virtio_nsm_device_realize()
1656 vnsm->version_minor = 0; in virtio_nsm_device_realize()
1657 vnsm->version_patch = 0; in virtio_nsm_device_realize()
1658 vnsm->extend_pcr = extend_pcr; in virtio_nsm_device_realize()
1659 vnsm->lock_pcr = lock_pcr; in virtio_nsm_device_realize()
1663 vnsm->vq = virtio_add_queue(vdev, 2, handle_input); in virtio_nsm_device_realize()
1687 .name = "virtio-nsm-device",
1698 .name = "virtio-nsm",
1707 static const Property virtio_nsm_properties[] = {
1708 DEFINE_PROP_STRING("module-id", VirtIONSM, module_id),
1717 dc->vmsd = &vmstate_virtio_nsm; in virtio_nsm_class_init()
1718 set_bit(DEVICE_CATEGORY_MISC, dc->categories); in virtio_nsm_class_init()
1719 vdc->realize = virtio_nsm_device_realize; in virtio_nsm_class_init()
1720 vdc->unrealize = virtio_nsm_device_unrealize; in virtio_nsm_class_init()
1721 vdc->get_features = get_features; in virtio_nsm_class_init()
1722 vdc->vmsd = &vmstate_virtio_nsm_device; in virtio_nsm_class_init()