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

Develop trait for tweakable block ciphers #6

Closed
newpavlov opened this issue May 8, 2017 · 3 comments
Closed

Develop trait for tweakable block ciphers #6

newpavlov opened this issue May 8, 2017 · 3 comments
Assignees

Comments

@newpavlov
Copy link
Member

newpavlov commented May 8, 2017

Recently added Threefish is a tweakable block cipher, thus we need an appropriate trait for it.

Currently I am thinking of using this:

pub trait TweakableBlockCipher {
    type BlockSize: ArrayLength<u8>;
    type TweakSize: ArrayLength<u8>;

    fn encrypt(&self, block: &mut Block<Self::BlockSize>,  tweak: &Block<Self::TweakSize>);

    fn decrypt(&self, block: &mut Block<Self::BlockSize>, tweak: &Block<Self::TweakSize>);
}

In addition to it I think tweakable ciphers should auto implement BlockCipher using zero tweak.

@newpavlov newpavlov self-assigned this May 8, 2017
@eternaleye
Copy link

eternaleye commented Sep 10, 2018

One thing worth noting is that tweak changes aren't necessarily free (some constructions even use tweak-dependent keys for the underlying block cipher), and an interface that can amortize this may be beneficial.

EDIT: Optimally Secure Tweakable Blockciphers may be of interest; it shows tweakable block cipher constructions that can break the birthday bound, though they make use of tweak-dependent keys.

EDIT 2: Even in LRW2, the construction works as Ẽ(k, t, m) = E(k, m ^ h(t)) ^ h(t) - precomputing h(t) may have nontrivial benefit.

@WildCryptoFox
Copy link

For HCTR the TBC trait would need to recognize Variable Input Lengths and variable tweaks (depending on the AXU it is instantiated with).

I don't think GenericArray can currently capture variable lengths.

@newpavlov
Copy link
Member Author

I will close it in favor of RustCrypto/traits#177.

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

3 participants