Skip to contentSkip to conversation

XTS and 64-bit block

DISCUSSION [email protected] 1 participant 1 message May 6, 2015 Crypto API

lore
Share & tools
lore
#0 lore raw

Hi,

I'm implementing a new block cipher algorithm which is GOST 28147-89. This is a 256-bit key and 64-bit block algorithm. This algorithm works well with ECB, CBC and CTR modes. But, when I try to use the XTS mode, the encryption fails. So I tried to find the problem and it seems to come from the file crypto/xts.c, function init_tfm :

	if (crypto_cipher_blocksize(cipher) != XTS_BLOCK_SIZE) {
		*flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
		crypto_free_cipher(cipher);
		return -EINVAL;
	}

So, I checked the value of XTS_BLOCK_SIZE which is 0x10. The snag is that the block size of GOST is 0x8. So I changed the block value of my algorithm to 0x10, and then I tried again with the XTS mode, and it works!

Because of what just happened, I've two questions:

Q1: Why does the GOST algorithm still work? Despite I changed the block size.
Q2: Why in the code, was the block size of XTS fixed? As far as I know, operations modes should adapt to the size of the block cipher.

Regards,
Thanks in advance
--
Jonathan "Coldshell" Thieuleux
Mail : [email protected]
IRC : coldshell [Freenode, OFTC]
Shaarli : https://links.stdcall.me/

"If you write interfaces with more than 4 or 5 function arguments, it's possible that you and I cannot be friends." -- David Miller