RustCrypto / block-modes

Collection of generic block mode algorithms written in pure Rust
61 stars 12 forks source link

Example code in crate doc not run-able #33

Closed Ainevsia closed 1 year ago

Ainevsia commented 1 year ago

The crate doc has the following example code which I find is not run-able?

let res = Aes128CbcEnc::new(&key.into(), &iv.into())
    .encrypt_padded_vec_mut::<Pkcs7>(&plaintext);
assert_eq!(res[..], ciphertext[..]);
let res = Aes128CbcDec::new(&key.into(), &iv.into())
    .decrypt_padded_vec_mut::<Pkcs7>(&res)
    .unwrap();
assert_eq!(res[..], plaintext[..]);

compiles with the following error:

error[E0599]: no method named `encrypt_padded_vec_mut` found for struct `Encryptor` in the current scope
  --> src\utils\crypto.rs:20:6
   |
20 |     .encrypt_padded_vec_mut(&plaintext);
   |      ^^^^^^^^^^^^^^^^^^^^^^ method not found in `Encryptor<Aes128>`

Maybe the doc is some sort of outdated or I am missing something?

newpavlov commented 1 year ago

Pay attention to the following line in the docs:

With enabled alloc (or std) feature you also can use allocating convenience methods:

Ainevsia commented 1 year ago

Oh sorry for the disrupt, I didn't notice that std/alloc is the crate's feature