pub fn decrypt_aes_128_ecb(
    b: &[u8],
    k: &[u8],
) -> Result<Vec<u8>, symmetriccipher::SymmetricCipherError> {
    let mut decryptor = aes::ecb_decryptor(aes::KeySize::KeySize128, k, blockmodes::NoPadding);

    let mut final_result = Vec::<u8>::new();
    let mut read_buffer = buffer::RefReadBuffer::new(b);
    let mut buffer = [0; 4096];
    let mut write_buffer = buffer::RefWriteBuffer::new(&mut buffer);

    loop {
        let result = decryptor.decrypt(&mut read_buffer, &mut write_buffer, true)?;

        final_result.extend(
            write_buffer
                .take_read_buffer()
                .take_remaining()
                .iter()
                .map(|&i| i),
        );

        match result {
            BufferResult::BufferUnderflow => break,
            BufferResult::BufferOverflow => {}
        }
    }

    Ok(final_result)
}
/// AES in ECB mode
///
/// Solution for problem 7 from set 1: <https://cryptopals.com/sets/1/challenges/7>
AES in ECB mode
Solution for problem 7 from set 1.
AES in ECB mode Solution for problem 7 from set 1 .
pub fn decrypt_aes_128_ecb(
    b: &[u8],
    k: &[u8],
) -> Result<Vec<u8>, symmetriccipher::SymmetricCipherError> {
    let mut decryptor = aes::ecb_decryptor(aes::KeySize::KeySize128, k, blockmodes::NoPadding);
    let mut final_result = Vec::<u8>::new();
    let mut read_buffer = buffer::RefReadBuffer::new(b);
    let mut buffer = [0; 4096];
    let mut write_buffer = buffer::RefWriteBuffer::new(&mut buffer);
    loop {
        let result = decryptor.decrypt(&mut read_buffer, &mut write_buffer, true)?;
        final_result.extend(
            write_buffer
                .take_read_buffer()
                .take_remaining()
                .iter()
                .map(|&i| i),
        );
        match result {
            BufferResult::BufferUnderflow => break,
            BufferResult::BufferOverflow => {}
        }
    }
    Ok(final_result)
}
pub fn decrypt_aes_128_ecb ( b : & [ u8 ] , k : & [ u8 ] , ) -> Result < Vec < u8 > , symmetriccipher :: SymmetricCipherError > { let mut decryptor = aes :: ecb_decryptor ( aes :: KeySize :: KeySize128 , k , blockmodes :: NoPadding ) ; let mut final_result = Vec :: < u8 > :: new ( ) ; let mut read_buffer = buffer :: RefReadBuffer :: new ( b ) ; let mut buffer = [ 0 ; 4096 ] ; let mut write_buffer = buffer :: RefWriteBuffer :: new ( & mut buffer ) ; loop { let result = decryptor . decrypt ( & mut read_buffer , & mut write_buffer , true ) ? ; final_result . extend ( write_buffer . take_read_buffer ( ) . take_remaining ( ) . iter ( ) . map ( | & i | i ) , ) ; match result { BufferResult :: BufferUnderflow => break , BufferResult :: BufferOverflow => { } } } Ok ( final_result ) }
AES in ECB mode
Solution for problem 7 from set 1: <https://cryptopals.com/sets/1/challenges/7>
AES in ECB mode Solution for problem 7 from set 1 : <https : // cryptopals . com / sets / 1 / challenges / 7 >
b
&[u8]
k
&[u8]