Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assertion failed: dst.len() * 4 == input.len() #455

Open
lamualfa opened this issue Sep 24, 2019 · 0 comments
Open

assertion failed: dst.len() * 4 == input.len() #455

lamualfa opened this issue Sep 24, 2019 · 0 comments

Comments

@lamualfa
Copy link

Dependencies

rand="0.7.2"
rust-crypto = "0.2.36"
rustc-serialize = "0.3.24"
use rand;
use crypto::aessafe::AesSafe128Encryptor;
use crypto::symmetriccipher::BlockEncryptor;

fn encrypt(key: &[u8], input: &[u8], output: &mut [u8]) {
    let encryptor = AesSafe128Encryptor::new(key);

    encryptor.encrypt_block(input, output);
}

fn main() {
    let mut key = [0u8; 128 / 8];

    for v in key.iter_mut() {
        *v = rand::random();
    }

    let mut output = Vec::<u8>::new();

    encrypt(&key, "hello".as_bytes(), &mut output);
}

Output:

user@user:~/Projects/rust/encrypt-file$ cargo run
   Compiling encrypt-file v0.1.0 (/home/user/Projects/rust/encrypt-file)
    Finished dev [unoptimized + debuginfo] target(s) in 0.48s
     Running `target/debug/encrypt-file`
thread 'main' panicked at 'assertion failed: dst.len() * 4 == input.len()', /home/user/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/rust-crypto-0.2.36/src/cryptoutil.rs:143:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant