MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / extend_rtmr

Function extend_rtmr

tdx-attest/src/linux.rs:221–237  ·  view source on GitHub ↗

Extend a TDX RTMR (Runtime Measurement Register). RTMR[index] = SHA384(RTMR[index] || digest) Only RTMR indices 2 and 3 are user-extensible. Tries two methods: 1. sysfs interface at `/sys/devices/virtual/misc/tdx_guest/measurements/rtmrN:sha384` 2. ioctl on `/dev/tdx_guest` (legacy)

(index: u32, _event_type: u32, digest: [u8; 48])

Source from the content-addressed store, hash-verified

219/// 1. sysfs interface at `/sys/devices/virtual/misc/tdx_guest/measurements/rtmrN:sha384`
220/// 2. ioctl on `/dev/tdx_guest` (legacy)
221pub fn extend_rtmr(index: u32, _event_type: u32, digest: [u8; 48]) -> Result<()> {
222 if index > 3 {
223 return Err(TdxAttestError::InvalidRtmrIndex(index));
224 }
225
226 if is_rtmr_sysfs_available() {
227 return extend_rtmr_via_sysfs(index, &digest);
228 }
229
230 if Path::new(TDX_GUEST_DEVICE).exists() {
231 return extend_rtmr_via_ioctl(index, digest);
232 }
233
234 Err(TdxAttestError::NotSupported(
235 "no extend_rtmr method available (no sysfs measurements, no /dev/tdx_guest)".to_string(),
236 ))
237}
238
239fn is_rtmr_sysfs_available() -> bool {
240 Path::new(RTMR_SYSFS_BASE).is_dir()

Callers 2

emit_runtime_eventFunction · 0.50
mainFunction · 0.50

Calls 3

is_rtmr_sysfs_availableFunction · 0.85
extend_rtmr_via_sysfsFunction · 0.85
extend_rtmr_via_ioctlFunction · 0.85

Tested by 1

mainFunction · 0.40