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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

XTS Mode #74

wants to merge 23 commits into from

Conversation

zer0x64
Copy link

@zer0x64 zer0x64 commented Nov 24, 2024

I implemented the trait on the pre release of cipher.

Suggestions for the cipher crate:

  • There does not seem to be a way to return errors using the traits. In ciphertext stealing case, this happens when the plain/ciphertext is shorter then the blocksize. The cts crate simply bypasses the trait system and implement the encryption methods directly on the struct.
  • The macros for tests does not work for ciphertext stealing as the tests asserts that the inputs are a multiple of the blocksize.
  • There are no traits for seeking, for block ciphers that supports it (another good use case is CBC decryption)

Missing:

  • Find out how to integrate ciphertext stealing with the cipher traits correctly (cannot actually be done, see comment below)
  • Ciphertext stealing tests
  • Benchmarks
  • Optimise use of the InOut-based methods, as I initially wrote the implementation in-place.
  • Finish up documentation
  • Make GF operations constant time

If you've got any suggestion for the first point, it would be appreciated!

@zer0x64 zer0x64 mentioned this pull request Nov 24, 2024
@zer0x64
Copy link
Author

zer0x64 commented Nov 24, 2024

Okay, I found the underlying issue: BlockModeEncrypt/Decrypt simply does not support encrypting/decrypting data that's not aligned to a block without using padding. Therefore, it simply cannot provide ciphertext stealing.

For now, I will do like the cts crate is doing and manually implement the encrypt/decrypt methods on the Encryptor/Decryptor

@zer0x64 zer0x64 marked this pull request as ready for review November 24, 2024 21:58
@zer0x64
Copy link
Author

zer0x64 commented Nov 24, 2024

Opened up for review, since the InOut refactoring to do can be done in a separate PR.

All IEEE 1619-2018 tests passes, parallel computing is supported, and doc is done.

@zer0x64
Copy link
Author

zer0x64 commented Nov 26, 2024

Made a rookie mistake, the GF operations are not constant time. This should be an easy fix

@newpavlov
Copy link
Member

Right now I work on other things, so I will try to take a look at this in a week or two.

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

Successfully merging this pull request may close these issues.

2 participants