Key size for Triple DES
We are using triple DES for symmetric key encryption and we specify the key size from a property file.
SYSTEM.SYM_KEY_ALGORITHM = DESede
SYSTEM.SYM_KEY_PROVIDER = BC
SYSTEM.SYM_KEY_SIZE = 192
Now triple DES uses a 168 bit key with 24 parity bits (168+24=192) , so should the key size in the property file be 168 or 192.
SYSTEM.SYM_KEY_SIZE = 168. ie, is parity bit also included as the key size
[434 byte] By [
sviveka] at [2007-10-2 16:29:49]

Ok.. i got what you are saying!So i cant have a key size of 192 right? It has to be either only 168 or 112.
KeyGenerator kgen = KeyGenerator.getInstance("DESede");
kgen.init(192);
SecretKey skey = kgen.generateKey();
would throw an exception i think.
> > KeyGenerator kgen =
> KeyGenerator.getInstance("DESede");
> kgen.init(192);
> SecretKey skey = kgen.generateKey();
>
>
> would throw an exception i think.
It does on my system -
Caused by: java.security.InvalidParameterException: Wrong keysize: must be equal to 112 or 168
at com.sun.crypto.provider.DESedeKeyGenerator.engineInit(DashoA13*..)
at javax.crypto.KeyGenerator.init(DashoA13*..)
at javax.crypto.KeyGenerator.init(DashoA13*..)
Ok if i use bouncy castle as provider, i am able to use the keysize of 192
KeyGenerator kgen = KeyGenerator.getInstance("DESede",new BouncyCastleProvider());
kgen.init(192);
SecretKey skey = kgen.generateKey();
I think the SUN's provider does not allow a keysize of 192 to be specified. So i think the keysize is provider specific!
192 bits is often used as the keysize of triple DES. It's a consequence of the fact that 64 bits is often specified as the keysize for single DES, with 1 bit per byte (usually the low-order bit) reserved for parity. 3*64 is 192.So yes, essentially BC is just truncating 192 to 168.