The Threefish tweak block cipher has a fixed size tweak (128 bits) and three different possible key/block sizes (256/512/1024 bits).
The MCOE on-line authenticated encryption mode presents three different implementations, one of which requires a native tweak block cipher and the other two can be implemented with an ordinary block cipher.
One of the requirements of the native tweak block cipher is that the tweak is the same size as the block, which is not the case for Threefish.
While Threefish as-is can be used in the other two methods (ie: fix tweak to a constant and use as ordinary block cipher), this method is not efficient. Ideally, Threefish would be modified to have its tweak size match the block size, leading to an optimal solution.
After looking at the Threefish sub-key generation, it appears that the tweak can be extended by simply increasing the tweak size to the block size and changing the tweak index modulus to fit the new block size (see code below).
/* NW = Number of 64-bit words for key and block size */
/* Note : Key and tweak array sizes are one 64-bit word larger to accomodate a 'parity' word */
auto subkey (U64 const key [NW+1] , U64 const tweak [3] , unsigned const s , unsigned const i) noexcept -> U64
{
auto const s_common = key [(s + i) % (NW + 1U)] ;
switch (i)
{
case NW - 1 : [[ unlikely ]] return s_common + s ;
case NW - 2 : [[ unlikely ]] return s_common + tweak [(s + 1U) % 3U] ;
case NW - 3 : [[ unlikely ]] return s_common + tweak [(s + 0U) % 3U] ;
default : [[ likely ]] return s_common ;
}
}
While this appears to generate "nice looking encryption", would this modification be secure or would it open new potential attack vectors?
If this modification is insecure, or if there is a better solution, please elaborate.
EDIT It occured to me after posting this question that simply modifiying the tweak modulus to match the increased tweak size is not enough. Each unique tweak should select a different permutation for the same key and should take into account the size of the tweak as well. Otherwise a 128 bit tweak of all zeroes would lead to the same encryption as 256/512/1024 bit tweak of all zeroes.
I modified the tweak parity to match that of the key parity, except with different constants for each tweak size (zero for 128 bit case to maintain compatibility).
This appears to address the issue, but prompts the question :
Will this modification create unique permutations for a given key and all possible tweak sizes and values?
If yes, how do you show this?