Giter VIP home page Giter VIP logo

Comments (6)

newpavlov avatar newpavlov commented on September 25, 2024 2

Sorry for the delay!

I've published cfb8 crate. Feel free to open new issues if you'll have any problems with RustCrypto crates or will need additional primitives!

from stream-ciphers.

iceiix avatar iceiix commented on September 25, 2024

Found these test vectors: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf F.3.8 CFB8-AES128.Decrypt (8-bit CFB)

Example in Python:

from Crypto.Cipher import AES

key="2b7e151628aed2a6abf7158809cf4f3c".decode("hex")
iv="000102030405060708090a0b0c0d0e0f".decode("hex")

cipher=AES.new(key, AES.MODE_CFB, iv, segment_size=8)
decrypted=cipher.decrypt("3b79424c9c0dd436bace9e0ed4586a4f32b9".decode("hex"))
print "decrypted = ",decrypted.encode("hex")
print "expected  = ","6bc1bee22e409f96e93d7e117393172aae2d"

Rust:

use aes::Aes128;
use cfb_mode::Cfb;

type Aes128Cfb = Cfb<Aes128>;

fn main() {
    let key = hex!("2b7e151628aed2a6abf7158809cf4f3c");
    let iv = hex!("000102030405060708090a0b0c0d0e0f");
    let mut cipher = Aes128Cfb::new_var(&key, &iv).unwrap();

    let mut data = hex!("3b79424c9c0dd436bace9e0ed4586a4f32b9");
    cipher.decrypt(&mut data);
    println!("decrypted = {:?}", data);

    let expected = hex!("6bc1bee22e409f96e93d7e117393172aae2d");
    println!("expected  = {:?}", expected);
}

output:

decrypted = [107, 135, 37, 128, 5, 96, 230, 128, 96, 199, 169, 231, 79, 247, 134, 47, 174, 70]
expected  = [107, 193, 190, 226, 46, 64, 159, 150, 233, 61, 126, 17, 115, 147, 23, 42, 174, 45]

from stream-ciphers.

newpavlov avatar newpavlov commented on September 25, 2024

cfb-mode currently implements CFB which XORs with full blocks (i.e. for AES it's CFB128). It's successfully passes CFB128 tests from the recommendations. Do you need CFB8 for compatibility reasons? Because they only differ in the rate of error recovery, while performance is significantly worse.

It shouldn't be that difficult to add CFB8, but I will be able to work on it probably only on this weekend,

from stream-ciphers.

iceiix avatar iceiix commented on September 25, 2024

Yes I'm porting a client where the server uses CFB8 for some reason. Appreciate your work on this

from stream-ciphers.

iceiix avatar iceiix commented on September 25, 2024

How would this be implemented? Should Cfb be generic over the block size (Cfb<8>, Cfb<128>, can you do that in Rust?) Or separate classes? (Cfb8, Cfb128, etc.)

from stream-ciphers.

iceiix avatar iceiix commented on September 25, 2024

Thanks! Ported my code over to use cfb8, works great.

from stream-ciphers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.