mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00

Nitro Secure Module (NSM)[1] device is used in AWS Nitro Enclaves[2] for stripped down TPM functionality like cryptographic attestation. The requests to and responses from NSM device are CBOR[3] encoded. This commit adds support for NSM device in QEMU. Although related to AWS Nitro Enclaves, the virito-nsm device is independent and can be used in other machine types as well. The libcbor[4] library has been used for the CBOR encoding and decoding functionalities. [1] https://lists.oasis-open.org/archives/virtio-comment/202310/msg00387.html [2] https://docs.aws.amazon.com/enclaves/latest/user/nitro-enclave.html [3] http://cbor.io/ [4] https://libcbor.readthedocs.io/en/latest/ Signed-off-by: Dorjoy Chowdhury <dorjoychy111@gmail.com> Reviewed-by: Alexander Graf <graf@amazon.com> Link: https://lore.kernel.org/r/20241008211727.49088-3-dorjoychy111@gmail.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
45 lines
1.6 KiB
C
45 lines
1.6 KiB
C
/*
|
|
* QEMU CBOR helpers
|
|
*
|
|
* Copyright (c) 2024 Dorjoy Chowdhury <dorjoychy111@gmail.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or
|
|
* (at your option) any later version. See the COPYING file in the
|
|
* top-level directory.
|
|
*/
|
|
|
|
#ifndef QEMU_VIRTIO_CBOR_HELPERS_H
|
|
#define QEMU_VIRTIO_CBOR_HELPERS_H
|
|
|
|
#include <cbor.h>
|
|
|
|
bool qemu_cbor_map_add(cbor_item_t *map, cbor_item_t *key, cbor_item_t *value);
|
|
|
|
bool qemu_cbor_array_push(cbor_item_t *array, cbor_item_t *value);
|
|
|
|
bool qemu_cbor_add_bool_to_map(cbor_item_t *map, const char *key, bool value);
|
|
|
|
bool qemu_cbor_add_uint8_to_map(cbor_item_t *map, const char *key,
|
|
uint8_t value);
|
|
|
|
bool qemu_cbor_add_map_to_map(cbor_item_t *map, const char *key,
|
|
size_t nested_map_size,
|
|
cbor_item_t **nested_map);
|
|
|
|
bool qemu_cbor_add_bytestring_to_map(cbor_item_t *map, const char *key,
|
|
uint8_t *arr, size_t len);
|
|
|
|
bool qemu_cbor_add_null_to_map(cbor_item_t *map, const char *key);
|
|
|
|
bool qemu_cbor_add_string_to_map(cbor_item_t *map, const char *key,
|
|
const char *value);
|
|
|
|
bool qemu_cbor_add_uint8_array_to_map(cbor_item_t *map, const char *key,
|
|
uint8_t *arr, size_t len);
|
|
|
|
bool qemu_cbor_add_uint8_key_bytestring_to_map(cbor_item_t *map, uint8_t key,
|
|
uint8_t *buf, size_t len);
|
|
|
|
bool qemu_cbor_add_uint64_to_map(cbor_item_t *map, const char *key,
|
|
uint64_t value);
|
|
#endif
|