Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4900661

DESede (triple DES) encryption in 1.4.2 returns different results from 1.4.1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.4.2
    • security-libs



      Name: rl43681 Date: 08/04/2003


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      DESede (triple DES) encryption using JDK 1.4.2 produce different result from JDK 1.3.1 or JDK 1.4.1.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the sample code and execute:
      java -client tahiti.util.DESEncryption key "0123456789"

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      This is the result I get when running with JDK 1.3.1 or JDK 1.4.1
      0
      -34
      108
      -18
      14
      -118
      -107
      81
      -40
      -21
      120
      -15
      -115
      21
      -116
      -88
      ACTUAL -
      89
      -98
      104
      -77
      52
      -48
      -31
      -98
      -110
      84
      33
      95
      102
      116
      -54
      -77

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.security.*;

      import javax.crypto.*;


      public class DESEncryption {
      public static void main(String[] args) throws Exception {
      String key = args[0];
      SecureRandom sr = new SecureRandom(key.getBytes());
      KeyGenerator kg = KeyGenerator.getInstance("DESede");
      kg.init(sr);
      SecretKey sk = kg.generateKey();
      Cipher cipher = Cipher.getInstance("DESede");
      cipher.init(Cipher.ENCRYPT_MODE, sk);
      byte[] encrypted = cipher.doFinal(args[1].getBytes());
      for (int i=0;i<encrypted.length;i++)
      System.out.println((int)encrypted[i]);
      }



      }

      ---------- END SOURCE ----------
      (Incident Review ID: 193667)
      ======================================================================

            andreas Andreas Sterbenz
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: