pub fn load_ak(
    context: &mut Context,
    parent: KeyHandle,
    ak_auth_value: Option<&Auth>,
    private: Private,
    public: Public,
) -> Result<KeyHandle> {
    let policy_auth_session = context
        .start_auth_session(
            None,
            None,
            None,
            SessionType::Policy,
            Cipher::aes_128_cfb().try_into()?,
            HashingAlgorithm::Sha256,
        )?
        .ok_or_else(|| Error::local_error(WrapperErrorKind::WrongValueFromTpm))?;

    let (session_attributes, session_attributes_mask) = SessionAttributesBuilder::new()
        .with_decrypt(true)
        .with_encrypt(true)
        .build();
    context.tr_sess_set_attributes(
        policy_auth_session,
        session_attributes,
        session_attributes_mask,
    )?;

    let key_handle = context.execute_with_temporary_object(
        SessionHandle::from(policy_auth_session).into(),
        |ctx, _| {
            let _ = ctx.execute_with_nullauth_session(|ctx| {
                ctx.policy_secret(
                    PolicySession::try_from(policy_auth_session)?,
                    AuthHandle::Endorsement,
                    Default::default(),
                    Default::default(),
                    Default::default(),
                    None,
                )
            })?;

            ctx.execute_with_session(Some(policy_auth_session), |ctx| {
                ctx.load(parent, private, &public)
            })
        },
    )?;

    if let Some(ak_auth_value) = ak_auth_value {
        context.tr_set_auth(key_handle.into(), ak_auth_value)?;
    }

    Ok(key_handle)
}
/// This loads an Attestation Key previously generated under the Endorsement hierarchy
This loads an Attestation Key previously generated under the Endorsement hierarchy
This loads an Attestation Key previously generated under the Endorsement hierarchy
pub fn load_ak(
    context: &mut Context,
    parent: KeyHandle,
    ak_auth_value: Option<&Auth>,
    private: Private,
    public: Public,
) -> Result<KeyHandle> {
    let policy_auth_session = context
        .start_auth_session(
            None,
            None,
            None,
            SessionType::Policy,
            Cipher::aes_128_cfb().try_into()?,
            HashingAlgorithm::Sha256,
        )?
        .ok_or_else(|| Error::local_error(WrapperErrorKind::WrongValueFromTpm))?;
    let (session_attributes, session_attributes_mask) = SessionAttributesBuilder::new()
        .with_decrypt(true)
        .with_encrypt(true)
        .build();
    context.tr_sess_set_attributes(
        policy_auth_session,
        session_attributes,
        session_attributes_mask,
    )?;
    let key_handle = context.execute_with_temporary_object(
        SessionHandle::from(policy_auth_session).into(),
        |ctx, _| {
            let _ = ctx.execute_with_nullauth_session(|ctx| {
                ctx.policy_secret(
                    PolicySession::try_from(policy_auth_session)?,
                    AuthHandle::Endorsement,
                    Default::default(),
                    Default::default(),
                    Default::default(),
                    None,
                )
            })?;
            ctx.execute_with_session(Some(policy_auth_session), |ctx| {
                ctx.load(parent, private, &public)
            })
        },
    )?;
    if let Some(ak_auth_value) = ak_auth_value {
        context.tr_set_auth(key_handle.into(), ak_auth_value)?;
    }
    Ok(key_handle)
}
pub fn load_ak ( context : & mut Context , parent : KeyHandle , ak_auth_value : Option < & Auth > , private : Private , public : Public , ) -> Result < KeyHandle > { let policy_auth_session = context . start_auth_session ( None , None , None , SessionType :: Policy , Cipher :: aes_128_cfb ( ) . try_into ( ) ? , HashingAlgorithm :: Sha256 , ) ? . ok_or_else ( | | Error :: local_error ( WrapperErrorKind :: WrongValueFromTpm ) ) ? ; let ( session_attributes , session_attributes_mask ) = SessionAttributesBuilder :: new ( ) . with_decrypt ( true ) . with_encrypt ( true ) . build ( ) ; context . tr_sess_set_attributes ( policy_auth_session , session_attributes , session_attributes_mask , ) ? ; let key_handle = context . execute_with_temporary_object ( SessionHandle :: from ( policy_auth_session ) . into ( ) , | ctx , _ | { let _ = ctx . execute_with_nullauth_session ( | ctx | { ctx . policy_secret ( PolicySession :: try_from ( policy_auth_session ) ? , AuthHandle :: Endorsement , Default :: default ( ) , Default :: default ( ) , Default :: default ( ) , None , ) } ) ? ; ctx . execute_with_session ( Some ( policy_auth_session ) , | ctx | { ctx . load ( parent , private , & public ) } ) } , ) ? ; if let Some ( ak_auth_value ) = ak_auth_value { context . tr_set_auth ( key_handle . into ( ) , ak_auth_value ) ? ; } Ok ( key_handle ) }
This loads an Attestation Key previously generated under the Endorsement hierarchy
This loads an Attestation Key previously generated under the Endorsement hierarchy
context
&mut Context
parent
KeyHandle
ak_auth_value
Option<&Auth>
private
Private
public
Public
context
&mut Context
parent
KeyHandle
ak_auth_value
Option<&Auth>
private
Private
public
Public