pub fn read_full(
    context: &mut Context,
    auth_handle: NvAuth,
    nv_index_handle: NvIndexTpmHandle,
) -> Result<Vec<u8>> {
    let maxsize = context
        .get_tpm_property(PropertyTag::NvBufferMax)?
        .unwrap_or(512) as usize;

    let nv_idx = TpmHandle::NvIndex(nv_index_handle);
    let nv_idx = context.execute_without_session(|ctx| ctx.tr_from_tpm_public(nv_idx))?;
    let nv_idx: NvIndexHandle = nv_idx.into();

    let (nvpub, _) = context.execute_without_session(|ctx| ctx.nv_read_public(nv_idx))?;
    let nvsize = nvpub.data_size();

    let mut result = Vec::new();
    result.reserve_exact(nvsize);

    for offset in (0..nvsize).step_by(maxsize) {
        let size: u16 = std::cmp::min(maxsize, nvsize - offset) as u16;

        let res = context.nv_read(auth_handle, nv_idx, size, offset as u16)?;
        result.extend_from_slice(&res);
    }
    context.execute_without_session(|ctx| ctx.tr_close(&mut nv_idx.into()))?;

    Ok(result)
}
/// Allows reading an NV Index completely, regardless of the max TPM NV buffer size
Allows reading an NV Index completely, regardless of the max TPM NV buffer size
Allows reading an NV Index completely regardless of the max TPM NV buffer size
pub fn read_full(
    context: &mut Context,
    auth_handle: NvAuth,
    nv_index_handle: NvIndexTpmHandle,
) -> Result<Vec<u8>> {
    let maxsize = context
        .get_tpm_property(PropertyTag::NvBufferMax)?
        .unwrap_or(512) as usize;
    let nv_idx = TpmHandle::NvIndex(nv_index_handle);
    let nv_idx = context.execute_without_session(|ctx| ctx.tr_from_tpm_public(nv_idx))?;
    let nv_idx: NvIndexHandle = nv_idx.into();
    let (nvpub, _) = context.execute_without_session(|ctx| ctx.nv_read_public(nv_idx))?;
    let nvsize = nvpub.data_size();
    let mut result = Vec::new();
    result.reserve_exact(nvsize);
    for offset in (0..nvsize).step_by(maxsize) {
        let size: u16 = std::cmp::min(maxsize, nvsize - offset) as u16;
        let res = context.nv_read(auth_handle, nv_idx, size, offset as u16)?;
        result.extend_from_slice(&res);
    }
    context.execute_without_session(|ctx| ctx.tr_close(&mut nv_idx.into()))?;
    Ok(result)
}
pub fn read_full ( context : & mut Context , auth_handle : NvAuth , nv_index_handle : NvIndexTpmHandle , ) -> Result < Vec < u8 > > { let maxsize = context . get_tpm_property ( PropertyTag :: NvBufferMax ) ? . unwrap_or ( 512 ) as usize ; let nv_idx = TpmHandle :: NvIndex ( nv_index_handle ) ; let nv_idx = context . execute_without_session ( | ctx | ctx . tr_from_tpm_public ( nv_idx ) ) ? ; let nv_idx : NvIndexHandle = nv_idx . into ( ) ; let ( nvpub , _ ) = context . execute_without_session ( | ctx | ctx . nv_read_public ( nv_idx ) ) ? ; let nvsize = nvpub . data_size ( ) ; let mut result = Vec :: new ( ) ; result . reserve_exact ( nvsize ) ; for offset in ( 0 .. nvsize ) . step_by ( maxsize ) { let size : u16 = std :: cmp :: min ( maxsize , nvsize - offset ) as u16 ; let res = context . nv_read ( auth_handle , nv_idx , size , offset as u16 ) ? ; result . extend_from_slice ( & res ) ; } context . execute_without_session ( | ctx | ctx . tr_close ( & mut nv_idx . into ( ) ) ) ? ; Ok ( result ) }
Allows reading an NV Index completely, regardless of the max TPM NV buffer size
Allows reading an NV Index completely regardless of the max TPM NV buffer size
context
&mut Context
auth_handle
NvAuth
nv_index_handle
NvIndexTpmHandle
context
&mut Context
auth_handle
NvAuth
nv_index_handle
NvIndexTpmHandle