-6

Could I use "PBKDF2WithHmacSHA1" algorithm with "DES" encryption.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
The VOYOU
  • 522
  • 4
  • 14
  • try it and see what happens. – President James K. Polk Jan 21 '13 at 13:20
  • You could, but it's certainly not secure. – CodesInChaos Jan 21 '13 at 13:20
  • @RenatoLochetti it seems like you are pretty much over smart, it a question as obvious so i wish you rather focus on solution if you could... – The VOYOU Jan 21 '13 at 13:30
  • Guys i asked such because I am not able to use this Random number generating algorithm with "AES" but with "DES" I can't...I just want to know why? – The VOYOU Jan 21 '13 at 13:32
  • hehehe some body down voting me ... but i can't figure it out why ? – The VOYOU Jan 21 '13 at 13:33
  • You didn't post your code. This question can't be answered, because it doesn't contain enough information about what you're doing. You certainly can generate DES keys any way you like, be it a KDF or PRNG. It's also unclear why you want to use DES. Its 56 bit key means that it's very weak. – CodesInChaos Jan 21 '13 at 14:57

1 Answers1

0

you are probably using PBKDF2WithHmacSHA1 to generate a key with 128 bits or more, which won't work with DES since it uses a 56 bit key.

I don't know what language you are trying to generate a key in, but there should be a parameter to specify key length. make sure its specified to output a 56-bit key.

the 56 bit key length for DES is also why you shouldn't use DES. your key will be brute forcable in under a day. Use AES.

Peter Elliott
  • 3,273
  • 16
  • 30
  • I could use see following `SecretKeyFactory factory = SecretKeyFactory .getInstance("PBKDF2WithHmacSHA1"); KeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), SALT, ITERATION_COUNT, KEY_LENGTH); SecretKey tmp = factory.generateSecret(spec); SecretKey secret = new SecretKeySpec(tmp.getEncoded(), "DES"); ecipher = Cipher.getInstance("DES/CBC/PKCS5Padding"); ecipher.init(Cipher.ENCRYPT_MODE, secret)` – The VOYOU Jan 22 '13 at 12:46
  • make sure `KEY_LENGTH` is equal to 56 – Peter Elliott Jan 22 '13 at 14:58
  • that's the confusion i am having right now see when i put `KEY_LENGTH` to 56 it gives me error `Invalid key length` don't know why? **according to 'DES' specs 'KEY_LENGTH' has to be of 56 length** and for `KEY_LENGTH=64;` it's working fine. _also i am afraid of posting new question.each time i post any question here you guys are down voting me. HEHEHEHHAHA ;)_ – The VOYOU Jan 23 '13 at 06:09
  • 1
    @TheVOYOU Some implementations of DES expect a 64 bit key, and ignore 8 of them. Dumb historical artifact. DES is pre-historic crypto that shouldn't be used anymore. – CodesInChaos Jan 24 '13 at 21:06