pub(crate) fn open_raw(
        &self,
        randomized_pwd_hasher: Hkdf<CS::Hash>,
        aad: &[u8],
    ) -> Result<OpenedInnerEnvelope<CS::Hash>, InternalError> {
        let mut hmac_key = vec![0u8; Self::hmac_key_size()];
        let mut export_key = vec![0u8; Self::export_key_size()];

        randomized_pwd_hasher
            .expand(
                &[self.nonce.clone(), STR_AUTH_KEY.to_vec()].concat(),
                &mut hmac_key,
            )
            .map_err(|_| InternalError::HkdfError)?;
        randomized_pwd_hasher
            .expand(
                &[self.nonce.clone(), STR_EXPORT_KEY.to_vec()].concat(),
                &mut export_key,
            )
            .map_err(|_| InternalError::HkdfError)?;

        let mut hmac =
            Hmac::<CS::Hash>::new_from_slice(&hmac_key).map_err(|_| InternalError::HmacError)?;
        hmac.update(&self.nonce);
        hmac.update(aad);
        if hmac.verify(&self.hmac).is_err() {
            return Err(InternalError::SealOpenHmacError);
        }

        Ok(OpenedInnerEnvelope {
            export_key: GenericArray::<u8, <CS::Hash as Digest>::OutputSize>::clone_from_slice(
                &export_key,
            ),
        })
    }
/// Attempts to decrypt the envelope using a key, which is successful only if the key and
/// aad used to construct the envelope are the same.
Attempts to decrypt the envelope using a key, which is successful only if the key and
aad used to construct the envelope are the same.
Attempts to decrypt the envelope using a key which is successful only if the key and aad used to construct the envelope are the same .
pub(crate) fn open_raw(
        &self,
        randomized_pwd_hasher: Hkdf<CS::Hash>,
        aad: &[u8],
    ) -> Result<OpenedInnerEnvelope<CS::Hash>, InternalError> {
        let mut hmac_key = vec![0u8; Self::hmac_key_size()];
        let mut export_key = vec![0u8; Self::export_key_size()];
        randomized_pwd_hasher
            .expand(
                &[self.nonce.clone(), STR_AUTH_KEY.to_vec()].concat(),
                &mut hmac_key,
            )
            .map_err(|_| InternalError::HkdfError)?;
        randomized_pwd_hasher
            .expand(
                &[self.nonce.clone(), STR_EXPORT_KEY.to_vec()].concat(),
                &mut export_key,
            )
            .map_err(|_| InternalError::HkdfError)?;
        let mut hmac =
            Hmac::<CS::Hash>::new_from_slice(&hmac_key).map_err(|_| InternalError::HmacError)?;
        hmac.update(&self.nonce);
        hmac.update(aad);
        if hmac.verify(&self.hmac).is_err() {
            return Err(InternalError::SealOpenHmacError);
        }
        Ok(OpenedInnerEnvelope {
            export_key: GenericArray::<u8, <CS::Hash as Digest>::OutputSize>::clone_from_slice(
                &export_key,
            ),
        })
    }
pub ( crate ) fn open_raw ( & self , randomized_pwd_hasher : Hkdf < CS :: Hash > , aad : & [ u8 ] , ) -> Result < OpenedInnerEnvelope < CS :: Hash > , InternalError > { let mut hmac_key = vec ! [ 0u8 Self hmac_key_size ( ) ] ; let mut export_key = vec ! [ 0u8 Self export_key_size ( ) ] ; randomized_pwd_hasher . expand ( & [ self . nonce . clone ( ) , STR_AUTH_KEY . to_vec ( ) ] . concat ( ) , & mut hmac_key , ) . map_err ( | _ | InternalError :: HkdfError ) ? ; randomized_pwd_hasher . expand ( & [ self . nonce . clone ( ) , STR_EXPORT_KEY . to_vec ( ) ] . concat ( ) , & mut export_key , ) . map_err ( | _ | InternalError :: HkdfError ) ? ; let mut hmac = Hmac :: < CS :: Hash > :: new_from_slice ( & hmac_key ) . map_err ( | _ | InternalError :: HmacError ) ? ; hmac . update ( & self . nonce ) ; hmac . update ( aad ) ; if hmac . verify ( & self . hmac ) . is_err ( ) { return Err ( InternalError :: SealOpenHmacError ) ; } Ok ( OpenedInnerEnvelope { export_key : GenericArray :: < u8 , < CS :: Hash as Digest > :: OutputSize > :: clone_from_slice ( & export_key , ) , } ) }
Attempts to decrypt the envelope using a key, which is successful only if the key and
aad used to construct the envelope are the same.
Attempts to decrypt the envelope using a key which is successful only if the key and aad used to construct the envelope are the same .
&self
randomized_pwd_hasher
Hkdf<CS::Hash>
aad
&[u8]
&self
randomized_pwd_hasher
Hkdf<CS::Hash>
aad
&[u8]