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]
# 1
See my first response in http://forum.java.sun.com/thread.jspa?threadID=696649&tstart=50
sabre150a at 2007-7-13 17:31:49 > top of Java-index,Security,Cryptography...
# 2

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.

sviveka at 2007-7-13 17:31:49 > top of Java-index,Security,Cryptography...
# 3

> > 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*..)

sabre150a at 2007-7-13 17:31:49 > top of Java-index,Security,Cryptography...
# 4

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!

sviveka at 2007-7-13 17:31:49 > top of Java-index,Security,Cryptography...
# 5
I'm not following how 192 bits will be used in the context of Triple DES. Is BC just truncating 192 to 168, or are they doing something different?
wetmorea at 2007-7-13 17:31:49 > top of Java-index,Security,Cryptography...
# 6
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.
ghstarka at 2007-7-13 17:31:49 > top of Java-index,Security,Cryptography...