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

AES can not work with mode "CBC" "OFB" "CFB" correctly

    XMLWordPrintable

Details

    • beagle
    • sparc
    • solaris_8
    • Verified

    Description

      AES can not work with mode "CBC" "OFB" "CFB" correctly. and Mode "PCBC" not available. The following program demonstrates this:


      import java.io.PrintStream;
      import java.security.*;
      import java.security.spec.*;
      import java.util.Random;

      import javax.crypto.*;
      import javax.crypto.spec.*;
      import java.security.Provider;
      import com.sun.advcrypto.provider.SunAES;

      public class test {

           public static void main( String argv[] ) {
           try{
          

               String algorithm = "AES";
           String mode = "CBC";
          String padding = "NoPadding";
        int keyStrength=128;
        AlgorithmParameterSpec aps = null;
       
        Cipher ci = Cipher.getInstance( algorithm + "/" + mode + "/" + padding, "SunAES" );
       
        KeyGenerator kg = KeyGenerator.getInstance( algorithm, "SunAES" );
           kg.init(keyStrength);
           SecretKey key = kg.generateKey();

           ci.init( Cipher.ENCRYPT_MODE, key, aps);

           }catch(Exception ex){
           System.out.println("FAILED");
           ex.printStackTrace();
          
           }
           }
      }

      lwang:/home/lw129730/AES/testcode/test( 277 )%java test
      FAILED
      java.lang.NullPointerException
              at cryptix.jce.provider.cipher.SunAES_j.b(DashoA6275)
              at cryptix.jce.provider.cipher.SunAES_i.a(DashoA6275)
              at cryptix.jce.provider.cipher.SunAES_h.a(DashoA6275)
              at cryptix.jce.provider.cipher.BlockCipher.engineInit(DashoA6275)
              at javax.crypto.Cipher.init(DashoA6275)
              at test.main(test.java:30)

      Attachments

        Activity

          People

            valeriep Valerie Peng
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: