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 #73

Open
zer0x64 opened this issue Nov 21, 2024 · 3 comments
Open

XTS mode #73

zer0x64 opened this issue Nov 21, 2024 · 3 comments

Comments

@zer0x64
Copy link

zer0x64 commented Nov 21, 2024

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 zer0x64 mentioned this issue Nov 21, 2024
5 tasks
@zer0x64
Copy link
Author

zer0x64 commented Nov 21, 2024

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
Copy link
Author

zer0x64 commented Nov 21, 2024

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
Copy link
Author

zer0x64 commented Nov 24, 2024

PR opened in draft:
#74

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

No branches or pull requests

1 participant