pub fn decrypt(self, key: AesKey) -> Result<Gbl<NotEncrypted<'a>, NotSigned<'a>>, Error> {
        let enc_header = &self.enc.enc_header;
        let nonce = enc_header.nonce.0;

        let decrypted = crypto::crypt(key, nonce, &self.enc.enc_sections);
        info!("parsing {} decrypted sections", decrypted.len());

        // Preallocate section storage. 1 encrypted section is the AppData, so subtract 1.
        let mut sections = Vec::with_capacity(self.enc.enc_sections.len() - 1);
        let mut appinfo = None;

        for section in decrypted {
            let section = Blob(section);
            debug!("decrypted data: {:?}", section);

            let reader: &mut &[u8] = &mut &*section;
            let tag = Tag::parse(reader)?;
            if !reader.is_empty() {
                return Err(Error::parse_err(format!(
                    "trailing bytes in encrypted section of {} bytes",
                    section.len()
                )));
            }

            match tag {
                Tag::AppInfo(info) => {
                    if appinfo.is_some() {
                        return Err(Error::parse_err("duplicate appinfo section"));
                    }

                    appinfo = Some(info);
                }
                Tag::ProgramData(data) => sections.push(data.into_owned()),
                _ => {
                    return Err(Error::parse_err(format!(
                        "decrypted tag {:?} is invalid in an encrypted section",
                        tag.tag_id()
                    )));
                }
            }
        }

        Ok(Gbl {
            enc: NotEncrypted {
                app_info: appinfo.unwrap(),
                sections,
            },
            sig: NotSigned::new(),
        })
    }
/// Decrypts the content of this GBL file using a raw AES-128 key.
///
/// The decrypted data will be parsed into GBL tags and returned as a new
/// `Gbl` object based on `self`.
///
/// Note that the validity of the key cannot be checked: Passing an invalid
/// key will result in decryption succeeding, but results in garbage data,
/// which will then fail to parse properly.
Decrypts the content of this GBL file using a raw AES-128 key.
The decrypted data will be parsed into GBL tags and returned as a new
`Gbl` object based on `self`.

Note that the validity of the key cannot be checked: Passing an invalid
key will result in decryption succeeding, but results in garbage data,
which will then fail to parse properly.
Decrypts the content of this GBL file using a raw AES - 128 key . The decrypted data will be parsed into GBL tags and returned as a new ` Gbl ` object based on ` self ` . Note that the validity of the key cannot be checked : Passing an invalid key will result in decryption succeeding but results in garbage data which will then fail to parse properly .
pub fn decrypt(self, key: AesKey) -> Result<Gbl<NotEncrypted<'a>, NotSigned<'a>>, Error> {
        let enc_header = &self.enc.enc_header;
        let nonce = enc_header.nonce.0;
        let decrypted = crypto::crypt(key, nonce, &self.enc.enc_sections);
        info!("parsing {} decrypted sections", decrypted.len());
        // Preallocate section storage. 1 encrypted section is the AppData, so subtract 1.
        let mut sections = Vec::with_capacity(self.enc.enc_sections.len() - 1);
        let mut appinfo = None;
        for section in decrypted {
            let section = Blob(section);
            debug!("decrypted data: {:?}", section);
            let reader: &mut &[u8] = &mut &*section;
            let tag = Tag::parse(reader)?;
            if !reader.is_empty() {
                return Err(Error::parse_err(format!(
                    "trailing bytes in encrypted section of {} bytes",
                    section.len()
                )));
            }
            match tag {
                Tag::AppInfo(info) => {
                    if appinfo.is_some() {
                        return Err(Error::parse_err("duplicate appinfo section"));
                    }
                    appinfo = Some(info);
                }
                Tag::ProgramData(data) => sections.push(data.into_owned()),
                _ => {
                    return Err(Error::parse_err(format!(
                        "decrypted tag {:?} is invalid in an encrypted section",
                        tag.tag_id()
                    )));
                }
            }
        }
        Ok(Gbl {
            enc: NotEncrypted {
                app_info: appinfo.unwrap(),
                sections,
            },
            sig: NotSigned::new(),
        })
    }
pub fn decrypt ( self , key : AesKey ) -> Result < Gbl < NotEncrypted < ' a > , NotSigned < ' a > > , Error > { let enc_header = & self . enc . enc_header ; let nonce = enc_header . nonce . 0 ; let decrypted = crypto :: crypt ( key , nonce , & self . enc . enc_sections ) ; info ! ( " " decrypted len ( ) ) ; // Preallocate section storage. 1 encrypted section is the AppData, so subtract 1. let mut sections = Vec :: with_capacity ( self . enc . enc_sections . len ( ) - 1 ) ; let mut appinfo = None ; for section in decrypted { let section = Blob ( section ) ; debug ! ( " " section ) ; let reader : & mut & [ u8 ] = & mut & * section ; let tag = Tag :: parse ( reader ) ? ; if ! reader . is_empty ( ) { return Err ( Error :: parse_err ( format ! ( " " section len ( ) ) ) ) ; } match tag { Tag :: AppInfo ( info ) => { if appinfo . is_some ( ) { return Err ( Error :: parse_err ( " " ) ) ; } appinfo = Some ( info ) ; } Tag :: ProgramData ( data ) => sections . push ( data . into_owned ( ) ) , _ => { return Err ( Error :: parse_err ( format ! ( " " tag tag_id ( ) ) ) ) ; } } } Ok ( Gbl { enc : NotEncrypted { app_info : appinfo . unwrap ( ) , sections , } , sig : NotSigned :: new ( ) , } ) }
Decrypts the content of this GBL file using a raw AES-128 key.
Decrypts the content of this GBL file using a raw AES - 128 key .
self
key
AesKey