Skip to content

Commit 572095f

Browse files
feat: add confidential compute gpu certificate functionality (#74)
This PR adds support for retrieving confidential compute GPU certificates from NVIDIA devices through the NVML API. The implementation includes: A new ConfidentialComputeGpuCertificate struct that encapsulates certificate data A method on the Device struct to retrieve the certificate information
1 parent 7ea1bc4 commit 572095f

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

nvml-wrapper/src/device.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,39 @@ impl<'nvml> Device<'nvml> {
791791
}
792792
}
793793

794+
/**
795+
Gets the confidential compute GPU certificate for this `Device`.
796+
797+
# Errors
798+
799+
* `Uninitialized` if the library has not been successfully initialized
800+
* `InvalidArg` if device is invalid or memory is NULL
801+
* `NotSupported` if this query is not supported by the device
802+
* `Unknown` on any unexpected error
803+
*/
804+
pub fn confidential_compute_gpu_certificate(
805+
&self,
806+
) -> Result<ConfidentialComputeGpuCertificate, NvmlError> {
807+
let sym = nvml_sym(
808+
self.nvml
809+
.lib
810+
.nvmlDeviceGetConfComputeGpuCertificate
811+
.as_ref(),
812+
)?;
813+
814+
unsafe {
815+
let mut certificate_chain: nvmlConfComputeGpuCertificate_t = mem::zeroed();
816+
nvml_try(sym(self.device, &mut certificate_chain))?;
817+
818+
Ok(ConfidentialComputeGpuCertificate {
819+
cert_chain_size: certificate_chain.certChainSize,
820+
attestation_cert_chain_size: certificate_chain.attestationCertChainSize,
821+
cert_chain: certificate_chain.certChain.to_vec(),
822+
attestation_cert_chain: certificate_chain.attestationCertChain.to_vec(),
823+
})
824+
}
825+
}
826+
794827
/**
795828
Gets the current PCIe link generation.
796829

nvml-wrapper/src/structs/device.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ pub struct ConfidentialComputeGpuAttestationReport {
2222
pub cec_attestation_report: Vec<u8>,
2323
}
2424

25+
/// Returned from `Device.confidential_compute_gpu_certificate()`
26+
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
27+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
28+
pub struct ConfidentialComputeGpuCertificate {
29+
/// The size of the certificate chain.
30+
pub cert_chain_size: u32,
31+
/// The size of the attestation certificate chain.
32+
pub attestation_cert_chain_size: u32,
33+
/// The certificate chain, of size
34+
/// `ffi::bindings::NVML_GPU_CERT_CHAIN_SIZE` == 4096 bytes.
35+
pub cert_chain: Vec<u8>,
36+
/// The attestation certificate chain, of size
37+
/// `ffi::bindings::NVML_GPU_ATTESTATION_CERT_CHAIN_SIZE` == 5120 bytes.
38+
pub attestation_cert_chain: Vec<u8>,
39+
}
40+
2541
/// Returned from `Device.auto_boosted_clocks_enabled()`
2642
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
2743
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]

0 commit comments

Comments
 (0)