Hi,
I am just writing some code for generation a DES-Key on the card. Generally it's very simple, get the keylength, generate some random data and set it as the keyData:
RandomData secureRandom = RandomData.getInstance(RandomData.ALG_SECURE_RANDOM);
DESKey key = KeyBuilder.buildKey(KeyBuilder.TYPE_DES,KeyBuilder.LENGTH_DES3_3KEY,false);
byte[] keyData = new byte[key.getSize()/8];
secureRandom.generateData(keyData, (short) 0, (short) keyData.length);
key.setKey(keyData,(short) 0);
What I was wondering about is that I can not find anything in the JavaCard/JCOP documentation concerning the parity adjustment of the keyData. I want to use the DES-key for onCard encryption and offCard decryption. For the offCard decryption I need a DES-Key wich is partity-adjusted.
Do I have to test and adjust the parity bits of the keyData myself or does the DESKey makes that internally for me?