pub(crate) fn dh(&mut self, secret_handle: &Secret, public_key: &PublicKey) -> Result<()> {
        let ck = self.ck.as_ref().ok_or(XXError::InvalidState)?;

        let attributes_ck = SecretAttributes::new(
            SecretType::Buffer,
            SecretPersistence::Ephemeral,
            SHA256_SIZE,
        );

        let symmetric_secret_info = self.get_symmetric_key_type_and_length();

        let attributes_k = SecretAttributes::new(
            symmetric_secret_info.0,
            SecretPersistence::Ephemeral,
            symmetric_secret_info.1,
        );

        let ecdh = self.vault.ec_diffie_hellman(secret_handle, public_key)?;

        let mut hkdf_output =
            self.vault
                .hkdf_sha256(ck, b"", Some(&ecdh), vec![attributes_ck, attributes_k])?;

        if hkdf_output.len() != 2 {
            return Err(XXError::InternalVaultError.into());
        }

        let key = self.key.take();
        if key.is_some() {
            self.vault.secret_destroy(key.unwrap())?;
        }

        self.key = Some(hkdf_output.pop().unwrap());

        let ck = self.ck.take();

        self.vault.secret_destroy(ck.unwrap())?;
        self.ck = Some(hkdf_output.pop().unwrap());

        Ok(())
    }
/// Perform the diffie-hellman computation
Perform the diffie-hellman computation
Perform the diffie - hellman computation
pub(crate) fn dh(&mut self, secret_handle: &Secret, public_key: &PublicKey) -> Result<()> {
        let ck = self.ck.as_ref().ok_or(XXError::InvalidState)?;
        let attributes_ck = SecretAttributes::new(
            SecretType::Buffer,
            SecretPersistence::Ephemeral,
            SHA256_SIZE,
        );
        let symmetric_secret_info = self.get_symmetric_key_type_and_length();
        let attributes_k = SecretAttributes::new(
            symmetric_secret_info.0,
            SecretPersistence::Ephemeral,
            symmetric_secret_info.1,
        );
        let ecdh = self.vault.ec_diffie_hellman(secret_handle, public_key)?;
        let mut hkdf_output =
            self.vault
                .hkdf_sha256(ck, b"", Some(&ecdh), vec![attributes_ck, attributes_k])?;
        if hkdf_output.len() != 2 {
            return Err(XXError::InternalVaultError.into());
        }
        let key = self.key.take();
        if key.is_some() {
            self.vault.secret_destroy(key.unwrap())?;
        }
        self.key = Some(hkdf_output.pop().unwrap());
        let ck = self.ck.take();
        self.vault.secret_destroy(ck.unwrap())?;
        self.ck = Some(hkdf_output.pop().unwrap());
        Ok(())
    }
pub ( crate ) fn dh ( & mut self , secret_handle : & Secret , public_key : & PublicKey ) -> Result < ( ) > { let ck = self . ck . as_ref ( ) . ok_or ( XXError :: InvalidState ) ? ; let attributes_ck = SecretAttributes :: new ( SecretType :: Buffer , SecretPersistence :: Ephemeral , SHA256_SIZE , ) ; let symmetric_secret_info = self . get_symmetric_key_type_and_length ( ) ; let attributes_k = SecretAttributes :: new ( symmetric_secret_info . 0 , SecretPersistence :: Ephemeral , symmetric_secret_info . 1 , ) ; let ecdh = self . vault . ec_diffie_hellman ( secret_handle , public_key ) ? ; let mut hkdf_output = self . vault . hkdf_sha256 ( ck , b" " , Some ( & ecdh ) , vec ! [ attributes_ck attributes_k ] ) ? ; if hkdf_output . len ( ) != 2 { return Err ( XXError :: InternalVaultError . into ( ) ) ; } let key = self . key . take ( ) ; if key . is_some ( ) { self . vault . secret_destroy ( key . unwrap ( ) ) ? ; } self . key = Some ( hkdf_output . pop ( ) . unwrap ( ) ) ; let ck = self . ck . take ( ) ; self . vault . secret_destroy ( ck . unwrap ( ) ) ? ; self . ck = Some ( hkdf_output . pop ( ) . unwrap ( ) ) ; Ok ( ( ) ) }
Perform the diffie-hellman computation
Perform the diffie - hellman computation
&mut self
secret_handle
&Secret
public_key
&PublicKey
&mut self
secret_handle
&Secret
public_key
&PublicKey