block-modes icon indicating copy to clipboard operation
block-modes copied to clipboard

XTS mode

Open zer0x64 opened this issue 1 year ago • 3 comments

Currently working on the implementation of XTS. I might have to do a bunch of hacks and not use some traits for now because XTS uses two engines (one to encrypt the teak and one to encrypt the data), which does not seems to be compatible with the current traits. I'm currently investigating.

zer0x64 avatar Nov 21 '24 02:11 zer0x64

~~Idea 1: The second engine is only used once on the IV/Tweak at the start of the encryption/decryption, so it could be processed before creating the block cipher using a custom function. This seems to be the easiest method for now so I'll go with that, although it makes the API pretty ugly~~

EDIT: Found my way around the traits and I've been able to implement this correctly

zer0x64 avatar Nov 21 '24 02:11 zer0x64

My work is being tracked here: https://github.com/zer0x64/block-modes/tree/xts

~~For now, I've implemented a custom new_xts method on Encryptor and Decryptor that accepts two keys. Unfortunately I don't think I can "Block" trait blanket implementations for KeyIvInit to make it harder to misuse. Still investigating.~~

Next hurdle is the ciphertext stealing part. The cts crate does all the work in BlockCipherEnc/DecClosure, which doesn't work for a parallellized implementation I think. My guess is that's I'll have to override implementations of BlockModeEnc/DecClosure?

zer0x64 avatar Nov 21 '24 05:11 zer0x64

PR opened in draft: https://github.com/RustCrypto/block-modes/pull/74

zer0x64 avatar Nov 24 '24 01:11 zer0x64