The SAMATE Project Department of Homeland Security
Downloads:  Selected

Back to the previous page...Back to the previous page

Test Case IDCandidate58
Bad / GoodBadBad test case
AuthorN/A
Associated test caseN/A
ContributorSecureSoftware
LanguageJava
Type of test caseSource Code
Input stringN/A
Expected OutputN/A
InstructionsN/A
Submission date2005-11-02
DescriptioniconNot using a a random initialization vector with Cipher Block Chaining (CBC) Mode causes algorithms to be susceptible to dictionary attacks. (from TCCLASP-5_5_22_10-J)
Filename

There is no comments :: Submit a comment :: RSS

>./Not_using_a_random_IV_with_CBC_mode.java
  1. public class SymmetricCipherTest {
  2. public static void main() {
  3. byte[] text =”Secret".getBytes();
  4. byte[] iv ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
  5. KeyGenerator kg = KeyGenerator.getInstance("DES");
  6. kg.init(56);
  7. SecretKey key = kg.generateKey();
  8. Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
  9. IvParameterSpec ips = new IvParameterSpec(iv);
  10. cipher.init(Cipher.ENCRYPT_MODE, key, ips);
  11. return cipher.doFinal(inpBytes);
  12. }
  13. }