pub fn decrypt_protected<'a>(self, key: &[u8], ciphertext: &'a mut [u8]) -> Result<&'a [u8]> {
        info!("{}", hex::encode(&ciphertext));
        info!("protected decrypt");
        let iv_vec = vec![0u8; self.block_size()];
        let cv_len = ciphertext.len();
        let (prefix, res) = self.decrypt_with_iv(key, &iv_vec, ciphertext, false)?;
        info!("{}", hex::encode(&res));
        // MDC is 1 byte packet tag, 1 byte length prefix and 20 bytes SHA1 hash.
        let mdc_len = 22;
        let (data, mdc) = res.split_at(res.len() - mdc_len);
        info!(
            "decrypted {}b from {}b ({}|{})",
            res.len(),
            cv_len,
            data.len(),
            mdc.len()
        );

        info!("mdc: {}", hex::encode(mdc));

        ensure_eq!(mdc[0], 0xD3, "invalid MDC tag");
        ensure_eq!(mdc[1], 0x14, "invalid MDC length");

        checksum::sha1(&mdc[2..], &[prefix, data, &mdc[0..2]].concat())?;

        Ok(data)
    }
/// Decrypt the data using CFB mode, without padding. Overwrites the input.
/// Uses an IV of all zeroes, as specified in the openpgp cfb mode.
/// Does not do resynchronization.
Decrypt the data using CFB mode, without padding. Overwrites the input.
Uses an IV of all zeroes, as specified in the openpgp cfb mode.
Does not do resynchronization.
Decrypt the data using CFB mode without padding . Overwrites the input . Uses an IV of all zeroes as specified in the openpgp cfb mode . Does not do resynchronization .
pub fn decrypt_protected<'a>(self, key: &[u8], ciphertext: &'a mut [u8]) -> Result<&'a [u8]> {
        info!("{}", hex::encode(&ciphertext));
        info!("protected decrypt");
        let iv_vec = vec![0u8; self.block_size()];
        let cv_len = ciphertext.len();
        let (prefix, res) = self.decrypt_with_iv(key, &iv_vec, ciphertext, false)?;
        info!("{}", hex::encode(&res));
        // MDC is 1 byte packet tag, 1 byte length prefix and 20 bytes SHA1 hash.
        let mdc_len = 22;
        let (data, mdc) = res.split_at(res.len() - mdc_len);
        info!(
            "decrypted {}b from {}b ({}|{})",
            res.len(),
            cv_len,
            data.len(),
            mdc.len()
        );
        info!("mdc: {}", hex::encode(mdc));
        ensure_eq!(mdc[0], 0xD3, "invalid MDC tag");
        ensure_eq!(mdc[1], 0x14, "invalid MDC length");
        checksum::sha1(&mdc[2..], &[prefix, data, &mdc[0..2]].concat())?;
        Ok(data)
    }
pub fn decrypt_protected < ' a > ( self , key : & [ u8 ] , ciphertext : & ' a mut [ u8 ] ) -> Result < & ' a [ u8 ] > { info ! ( " " hex encode ( ciphertext ) ) ; info ! ( " " ) ; let iv_vec = vec ! [ 0u8 self block_size ( ) ] ; let cv_len = ciphertext . len ( ) ; let ( prefix , res ) = self . decrypt_with_iv ( key , & iv_vec , ciphertext , false ) ? ; info ! ( " " hex encode ( res ) ) ; // MDC is 1 byte packet tag, 1 byte length prefix and 20 bytes SHA1 hash. let mdc_len = 22 ; let ( data , mdc ) = res . split_at ( res . len ( ) - mdc_len ) ; info ! ( " " res len ( ) cv_len data len ( ) mdc len ( ) ) ; info ! ( " " hex encode ( mdc ) ) ; ensure_eq ! ( mdc [ 0 ] 0xD3 " " ) ; ensure_eq ! ( mdc [ 1 ] 0x14 " " ) ; checksum :: sha1 ( & mdc [ 2 .. ] , & [ prefix , data , & mdc [ 0 .. 2 ] ] . concat ( ) ) ? ; Ok ( data ) }
Decrypt the data using CFB mode, without padding.
Decrypt the data using CFB mode without padding .
self
key
&[u8]
ciphertext
&'a mut [u8]
self
key
&[u8]
ciphertext
&'a mut [u8]