-
Notifications
You must be signed in to change notification settings - Fork 230
Description
All of the AES-based AEADs we've implemented are based on AES-CTR (as implemented in various forms in the ctr crate).
CTR notably only needs the encryption component of AES, but right now if we use aes-soft in combination with ctr, we still pay an eager key schedule setup penalty for decryption, even if that code is never used (I think... it'd be nice if if LLVM were smart enough to elide it that'd, and also reduce code size).
Perhaps we should have traits like crypto::block::Encrypt and crypto::block::Decrypt, which could be combined into BlockCipher? For example, BlockCipher could have a blanket impls for both Encrypt and Decrypt, so you can use a BlockCipher anywhere that Encrypt or Decrypt are required, and we could find ways to make it easy to construct a BlockCipher out of separate Encrypt and Decrypt impls for cases like aes-soft where the two are really independent.
I think ideally in cases where we're using AES-CTR, we can avoid the key schedule setup penalty for decryption, and ideally all of the decryption-related code as well.