Triple DES with a 16 bytes array
i have an array of 16 bytes containing my cipher key and i want to use it. what must i do ?
i have already tried to write this :
try {Cipher cipher = Cipher.getInstance("DESede"); }
SecretKey key = new SecretKeySpec (CLECHIFMERE, "DESede");
and
try {Cipher cipher = Cipher.getInstance("DES"); }
SecretKey key = new SecretKeySpec (CLECHIFMERE, "DES");
it does not work because, i think, DESede uses a 24 bytes array and DES need 8 bytes array !
Thanks for whose accept to help me and give me some java code .
[566 byte] By [
pinguin72a] at [2007-9-29 18:51:03]

Triple DES needs 24 bytes as key material. Try to get an original key of 24 bytes when possible.
If you only got 16 bytes, you could extend the number of bytes to 24 either by padding with a constant set of bytes, or by fiddling around with the 16 bytes (e.g. generate an MD5 and a SHA-1 from the 16-byte key, and concatenate these). Note that your strength of your key is still 16 bytes (the original key material from which the longer key is deduced).
When you got at least 24 bytes, you can create a javax.crypto.spec.DESedeKeySpec, which you can feed to the javax.crypto.SecretKeyFactory.generateSecret(...) to generate the SecretKey, which can be used for the Cipher.
Cheers,
--Arnout