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

Add support for variable block sizes #408

Closed
noloader opened this issue May 2, 2017 · 1 comment
Closed

Add support for variable block sizes #408

noloader opened this issue May 2, 2017 · 1 comment

Comments

@noloader
Copy link
Collaborator

noloader commented May 2, 2017

This ticket tracks support for variable sizes. Variable block sizes are becoming increasing popular in modern block ciphers. We need the support Threefish and Kalyna.

Also see Block Ciphers and variable block sizes on the mailing list.

noloader referenced this issue May 2, 2017
This should lead the way for more modern block ciphers like Threefish and Kalyna. It tested well with both regular cipher modes (the mode has an instance of the cipher) and external cipher modes (the cipher and mode are distinct objects, and the mode holds a reference to the cipher).

We still have to work out the details of naming a cipher. For example, Kalyna with a 128-bit key can use a 128-bit or 256-bit block size. Kalyna-128 is not enough to describe the algorithm and locate it in the object registry. Kalyna-128-128 looks kind of weird; maybe Kalyna-128(128) or Kalyna-128(256) would be better.

Here are the initial test cases to verify functionality:

byte key[64] = {}, iv[32] = {};

ECB_Mode<Kalyna>::Encryption enc1;
enc1.SetKey(key, 16);

CBC_Mode<Kalyna>::Encryption enc2;
enc2.SetKeyWithIV(key, 16, iv);

AlgorithmParameters params = MakeParameters
                        (Name::BlockSize(), 32)
                        (Name::IV(), ConstByteArrayParameter(iv, 32));

CTR_Mode<Kalyna>::Encryption enc3;
enc3.SetKey(key, 16, params);

CBC_Mode<Kalyna>::Encryption enc4;
enc4.SetKey(key, 32, params);

Kalyna::Encryption enc5;
ECB_Mode_ExternalCipher::Encryption ecb(enc5);
ecb.SetKey(key, 16, params);

Kalyna::Encryption enc6;
ECB_Mode_ExternalCipher::Encryption cbc(enc6);
cbc.SetKey(key, 32, params);
noloader referenced this issue May 4, 2017
VariableBlockSize and VariableBlockCipherImpl were added at Commit bd8edfa. Reflecting on FixedKeyLength and VariableKeyLength, the const KEYLENGTH is only provided by FixedKeyLength. VariableKeyLength provides DEFAULT_KEYLENGTH. This check-in makes VariableBlockSize follow VariableKeyLength.
This check-in also splits block size and iv length. Its conceivable we will encounter a cipher with a block size of 128-bits with an iv of 256-bits. The bd8edfa check-in could not handle the difference, so we fix it now.
noloader referenced this issue May 4, 2017
This also follows the pattern set forth by FxiedKeyLength and VariableKeyLength
noloader referenced this issue May 4, 2017
CRYPTOPP_COVERAGE was added at 9614307 to increase code coverage support. This commit enables additional validation routines when  CRYPTOPP_COVERAGE is in effect.
noloader referenced this issue Aug 12, 2017
GCM is still only defined for 16-byte ciphers, but this is where we need to be when we add the larger polynomials
@noloader
Copy link
Collaborator Author

noloader commented Jan 4, 2018

Variable block sizes had good intentions but it was a failed experiment. We are removing the support under Issue 535, Remove variable block size support for block ciphers.

Closing this ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant