-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Description
Hi thanks for making the cfb-mode crate, think it will work well for my purposes, so I started converting from openssl, however, I'm seeing different decryption output after the first call as compared to openssl. Reduced to this example:
extern crate aes;
extern crate cfb_mode;
use aes::Aes128;
use cfb_mode::Cfb;
type Aes128Cfb = Cfb<Aes128>;
fn main() {
let key = &[17, 72, 215, 19, 142, 61, 79, 230, 54, 89, 66, 160, 184, 156, 232, 31];
let mut cipher = Aes128Cfb::new_var(key, key).unwrap();
let mut data = [130];
cipher.decrypt(&mut data);
println!("decrypted = {:?}", data);
let mut data2 = [238, 158, 146];
cipher.decrypt(&mut data2);
println!("decrypted2 = {:?}", data2);
}and for ease of comparison (although I also see the correct output with the openssl 0.7.8 crate), this Python script using PyCrypto decrypting the same data:
from Crypto.Cipher import AES
key=b'\x11H\xd7\x13\x8e=O\xe66YB\xa0\xb8\x9c\xe8\x1f'
iv=key
cipher=AES.new(key, AES.MODE_CFB, iv, segment_size=8)
print "decrypted =",map(ord, cipher.decrypt("\x82")) # expect [3]
print "decrypted2 =",map(ord, cipher.decrypt("\xee\x9e\x92")) # expect [3, 128, 2]Python (and OpenSSL) decrypts to what I expect:
decrypted = [3]
decrypted2 = [3, 128, 2]
Rust with cfb-mode decrypts the first time ok, but then the second decrypted2 result is different:
decrypted = [3]
decrypted2 = [210, 218, 215]
Metadata
Metadata
Assignees
Labels
No labels