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

XTS mode #48

Closed
theli-ua opened this issue May 9, 2019 · 4 comments
Closed

XTS mode #48

theli-ua opened this issue May 9, 2019 · 4 comments

Comments

@theli-ua
Copy link

theli-ua commented May 9, 2019

Any plans for XTS?

@newpavlov
Copy link
Member

Currently I don't have plans on implementing it myself, but I will gladly accept PRs!

Probably it will be better to introduce this mode as a separate crate, independent from block-modes.

@pheki
Copy link

pheki commented Jan 15, 2020

I actually implemented XTS, but I'm having a little trouble conforming to the BlockMode trait:

  • The new and new_fix signatures doesn't make much sense, as XTS needs two ciphers (usually two different keys with the same algorithm).

Other details:

  • XTS itself cannot be implemented in term of en(de)crypt_blocks, as encrypt_blocks expects padded, full blocks and XTS use unpadded blocks to perform the stealing, encrypt_blocks will need to be implemented in terms of encrypt, instead of the opposite.

  • Padding is not used, so the generic argument P: Padding will just be completely ignored.

For reference, the signatures I'm using (the tweak could be moved to the struct so its like an IV):

pub struct Xts128<C: BlockCipher> {
    cipher_1: C,
    cipher_2: C,
}

pub fn new(cipher_1: C, cipher_2: C) -> Xts128<C>;

pub fn encrypt_sector(&mut self, sector: &mut [u8], mut tweak: [u8; 0x10]);

pub fn decrypt_sector(&mut self, sector: &mut [u8], mut tweak: [u8; 0x10]);

What do you think? Does it even make sense to impl BlockMode for Xts128?

@pheki
Copy link

pheki commented Apr 30, 2020

I've published a crate with XTS support (currently only 128-bits): xts-mode (docs.rs, repository).

@newpavlov
Copy link
Member

Closing it in favor of RustCrypto/block-modes#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants