Extern crate crypto: error: source trait is private


Not sure if this is the right place, but there is very little support for the crypto crate: https://github.com/DaGenix/rust-crypto

I tried to decrypt something. The important part is:

let mut out = [0; 4096];
let mut in_buf = buffer::RefReadBuffer::new(&key);
let mut out_buf = buffer::RefWriteBuffer::new(&mut out);
let mut dec = aes::cbc_decryptor(
dec.decrypt(&mut in_buf, &mut out_buf, true);

With this code i get this error:

src/main.rs:98:9: 98:53 error: source trait is private
src/main.rs:98         dec.decrypt(&mut in_buf, &mut out_buf, true);
error: aborting due to previous error

I don’t have any clue why.

There is no published doc. I think this are the important parts:

pub fn cbc_decryptor<X: PaddingProcessor + Send + 'static>(key_size: KeySize, key: &[u8], iv: &[u8], padding: X) -> Box<Decryptor + 'static>
pub trait Decryptor {
    fn decrypt(&mut self, input: &mut RefReadBuffer, output: &mut RefWriteBuffer, eof: bool) -> Result<BufferResult, SymmetricCipherError>;
impl<T: BlockDecryptor, X: PaddingProcessor> Decryptor for CbcDecryptor<T, X>

Thanks for any help.


That’s a pretty weird error message… You can fix it by saying

use crypto::symmetriccipher::Decryptor;

See also https://github.com/rust-lang/rust/issues/22050


Thanks a lot. Now it works.