|
| 1 | +// |
| 2 | +// Copyright 2020-2025 NVIDIA Corporation. All rights reserved. |
| 3 | +// |
| 4 | +// NOTICE TO USER: |
| 5 | +// |
| 6 | +// This source code is subject to NVIDIA ownership rights under U.S. and |
| 7 | +// international Copyright laws. Users and possessors of this source code |
| 8 | +// are hereby granted a nonexclusive, royalty-free license to use this code |
| 9 | +// in individual and commercial software. |
| 10 | +// |
| 11 | +// NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE |
| 12 | +// CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR |
| 13 | +// IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH |
| 14 | +// REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 15 | +// MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. |
| 16 | +// IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, |
| 17 | +// OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS |
| 18 | +// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
| 19 | +// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE |
| 20 | +// OR PERFORMANCE OF THIS SOURCE CODE. |
| 21 | +// |
| 22 | +// U.S. Government End Users. This source code is a "commercial item" as |
| 23 | +// that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of |
| 24 | +// "commercial computer software" and "commercial computer software |
| 25 | +// documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) |
| 26 | +// and is provided to the U.S. Government only as a commercial end item. |
| 27 | +// Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through |
| 28 | +// 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the |
| 29 | +// source code with only those rights set forth herein. |
| 30 | +// |
| 31 | +// Any use of this source code in individual and commercial software must |
| 32 | +// include, in the user documentation and internal comments to the code, |
| 33 | +// the above Disclaimer and U.S. Government End Users Notice. |
| 34 | +// |
| 35 | + |
| 36 | +#ifndef _NSCQ_ATTESTATION_H_ |
| 37 | +#define _NSCQ_ATTESTATION_H_ |
| 38 | + |
| 39 | +#ifdef __cplusplus |
| 40 | +extern "C" { |
| 41 | +#endif |
| 42 | + |
| 43 | +#include <stdbool.h> |
| 44 | +#include <stdint.h> |
| 45 | + |
| 46 | +#define NSCQ_API_VERSION(major, minor, patch) \ |
| 47 | + (((((uint32_t)major) & 0xFFu) << 24u) | ((((uint32_t)minor) & 0xFFFu) << 12u) | \ |
| 48 | + ((((uint32_t)patch) & 0xFFFu) << 0u)) |
| 49 | +#define NSCQ_API_VERSION_CODE_MAJOR(code) (((code) >> 24u) & 0xFFu) |
| 50 | +#define NSCQ_API_VERSION_CODE_MINOR(code) (((code) >> 12u) & 0xFFFu) |
| 51 | +#define NSCQ_API_VERSION_CODE_PATCH(code) (((code) >> 0u) & 0xFFFu) |
| 52 | + |
| 53 | +#define NSCQ_API_VERSION_CODE \ |
| 54 | + NSCQ_API_VERSION(2, 0, 0) |
| 55 | + |
| 56 | +extern const uint32_t nscq_api_version; |
| 57 | + |
| 58 | +// nscq_rc_t value ranges: |
| 59 | +// 0 : success |
| 60 | +// 1 to 127 : warnings (success, but with caveats) |
| 61 | +// -128 to -1 : errors |
| 62 | +#define NSCQ_RC_SUCCESS (0) |
| 63 | +#define NSCQ_RC_WARNING_RDT_INIT_FAILURE (1) |
| 64 | +#define NSCQ_RC_ERROR_NOT_IMPLEMENTED (-1) |
| 65 | +#define NSCQ_RC_ERROR_INVALID_UUID (-2) |
| 66 | +#define NSCQ_RC_ERROR_RESOURCE_NOT_MOUNTABLE (-3) |
| 67 | +#define NSCQ_RC_ERROR_OVERFLOW (-4) |
| 68 | +#define NSCQ_RC_ERROR_UNEXPECTED_VALUE (-5) |
| 69 | +#define NSCQ_RC_ERROR_UNSUPPORTED_DRV (-6) |
| 70 | +#define NSCQ_RC_ERROR_DRV (-7) |
| 71 | +#define NSCQ_RC_ERROR_TIMEOUT (-8) |
| 72 | +#define NSCQ_RC_ERROR_EXT (-127) |
| 73 | +#define NSCQ_RC_ERROR_UNSPECIFIED (-128) |
| 74 | + |
| 75 | +// The pointer-cast-dereference is done so that these macros can also be used |
| 76 | +// with the nscq_*_result_t types, which embed the result code as the first |
| 77 | +// member of the result struct. |
| 78 | +#ifdef __cplusplus |
| 79 | +#define NSCQ_SUCCESS(result) (*(reinterpret_cast<nscq_rc_t*>(&(result))) == NSCQ_RC_SUCCESS) |
| 80 | +#define NSCQ_WARNING(result) (*(reinterpret_cast<nscq_rc_t*>(&(result))) > NSCQ_RC_SUCCESS) |
| 81 | +#define NSCQ_ERROR(result) (*(reinterpret_cast<nscq_rc_t*>(&(result))) < NSCQ_RC_SUCCESS) |
| 82 | +#else |
| 83 | +#define NSCQ_SUCCESS(result) (*((nscq_rc_t*)&(result)) == NSCQ_RC_SUCCESS) |
| 84 | +#define NSCQ_WARNING(result) (*((nscq_rc_t*)&(result)) > NSCQ_RC_SUCCESS) |
| 85 | +#define NSCQ_ERROR(result) (*((nscq_rc_t*)&(result)) < NSCQ_RC_SUCCESS) |
| 86 | +#endif |
| 87 | + |
| 88 | +#define _NSCQ_RESULT_TYPE(t, m) \ |
| 89 | + typedef struct { \ |
| 90 | + nscq_rc_t rc; \ |
| 91 | + t m; \ |
| 92 | + } nscq_##m##_result_t |
| 93 | + |
| 94 | +typedef int8_t nscq_rc_t; |
| 95 | +typedef struct nscq_session_st* nscq_session_t; |
| 96 | +typedef struct nscq_observer_st* nscq_observer_t; |
| 97 | +typedef struct nscq_writer_st* nscq_writer_t; |
| 98 | + |
| 99 | +// All function callbacks (e.g., used for path observers) are passed using a single type. |
| 100 | +// These are cast internally to the appropriate function types internally before use. |
| 101 | +typedef void (*nscq_fn_t)(void); |
| 102 | + |
| 103 | +// Convenience macro for casting a function pointer to the common nscq_fn_t type. |
| 104 | +#ifdef __cplusplus |
| 105 | +#define NSCQ_FN(fn) reinterpret_cast<nscq_fn_t>(fn) |
| 106 | +#else |
| 107 | +#define NSCQ_FN(fn) ((nscq_fn_t)&fn) |
| 108 | +#endif |
| 109 | + |
| 110 | +typedef struct { |
| 111 | + uint8_t bytes[16]; |
| 112 | +} nscq_uuid_t; |
| 113 | + |
| 114 | +#define NSCQ_ARCH_SV10 (0) |
| 115 | +#define NSCQ_ARCH_LR10 (1) |
| 116 | +#define NSCQ_ARCH_LS10 (2) |
| 117 | + |
| 118 | +typedef int8_t nscq_arch_t; |
| 119 | + |
| 120 | +typedef struct { |
| 121 | + char data[64]; |
| 122 | +} nscq_label_t; |
| 123 | + |
| 124 | +#define NSCQ_DEVICE_TNVL_MODE_UNKNOWN (-1) |
| 125 | +#define NSCQ_DEVICE_TNVL_MODE_DISABLED (0) |
| 126 | +#define NSCQ_DEVICE_TNVL_MODE_ENABLED (1) |
| 127 | +#define NSCQ_DEVICE_TNVL_MODE_FAILURE (2) |
| 128 | +#define NSCQ_DEVICE_TNVL_MODE_LOCKED (3) |
| 129 | + |
| 130 | +typedef int8_t nscq_tnvl_status_t; |
| 131 | + |
| 132 | +#define NSCQ_ATTESTATION_REPORT_NONCE_SIZE 0x20 |
| 133 | +#define NSCQ_ATTESTATION_REPORT_SIZE 0x2000 |
| 134 | + |
| 135 | +typedef struct |
| 136 | +{ |
| 137 | + uint32_t report_size; |
| 138 | + uint8_t report[NSCQ_ATTESTATION_REPORT_SIZE]; |
| 139 | +} nscq_attestation_report_t; |
| 140 | + |
| 141 | +#define NSCQ_CERTIFICATE_CERT_CHAIN_MAX_SIZE 0x1400 |
| 142 | + |
| 143 | +typedef struct |
| 144 | +{ |
| 145 | + uint8_t cert_chain[NSCQ_CERTIFICATE_CERT_CHAIN_MAX_SIZE]; |
| 146 | + uint32_t cert_chain_size; |
| 147 | +} nscq_attestation_certificate_t; |
| 148 | + |
| 149 | +_NSCQ_RESULT_TYPE(nscq_session_t, session); |
| 150 | +_NSCQ_RESULT_TYPE(nscq_observer_t, observer); |
| 151 | +_NSCQ_RESULT_TYPE(nscq_writer_t, writer); |
| 152 | + |
| 153 | +nscq_rc_t nscq_uuid_to_label(const nscq_uuid_t*, nscq_label_t*, uint32_t); |
| 154 | + |
| 155 | +#define NSCQ_SESSION_CREATE_MOUNT_DEVICES (0x1u) |
| 156 | + |
| 157 | +nscq_session_result_t nscq_session_create(uint32_t); |
| 158 | +void nscq_session_destroy(nscq_session_t); |
| 159 | + |
| 160 | +nscq_rc_t nscq_session_path_observe(nscq_session_t, const char*, nscq_fn_t, void*, uint32_t); |
| 161 | + |
| 162 | +nscq_rc_t nscq_session_set_input(nscq_session_t, uint32_t, void*, uint32_t); |
| 163 | + |
| 164 | +#ifdef __cplusplus |
| 165 | +} |
| 166 | +#endif |
| 167 | + |
| 168 | +#endif // _NSCQ_ATTESTATION_H_ |
0 commit comments