1 Reply Latest reply on Jan 6, 2005 7:46 AM by nmeira

    SRP  Interceptors

    nmeira

      Hello,

      I'm trying to use the

      org.jboss.test.security.interceptors.ClientEncryptionInterceptor
      org.jboss.test.security.interceptors.ServerEncryptionInterceptor

      but I'm having some problems.. .

      I get an exception

      ?private void initCipher(Subject subject) throws GeneralSecurityException?

      First I was getting an GeneralSecurityException on

      if( key == null )
      {
      System.out.println("Subject: "+subject);
      throw new GeneralSecurityException("Failed to find SecretKey in Subject.PrivateCredentials");
      }

      [ClientEncryptionInterceptor.java]


      I guessed that I had to specify a cipherAlgorithm when I was creating the VerifierInfo on my VerifierStore. So I tried specifying a cipherAlgorithm?

      public void addUser(String username, char[] password)
      {
      VerifierInfo info = new VerifierInfo();
      info.username = username;

      // info.cipherAlgorithm="PBEWithMD5AndDES";
      info.cipherAlgorithm="DES";

      // Create a random salt
      long r = Util.nextLong();
      String rs = Long.toHexString(r);
      info.salt = rs.getBytes();
      BigInteger g = SRPConf.getDefaultParams().g();
      BigInteger N = SRPConf.getDefaultParams().N();

      info.verifier = Util.calculateVerifier(username, password, info.salt, N, g);
      info.g = g.toByteArray();
      info.N = N.toByteArray();


      log.info("Added user: "+username);
      storeMap.put(username, info);

      }

      [VerifierStore.java]

      I get an Exception with both (PBEWithMD5AndDES and DES) always on


      encryptCipher.init(Cipher.ENCRYPT_MODE, key, iv);

      [ClientEncryptionInterceptor.java]

      With PBEWithMD5AndDES I get:

      java.lang.ClassCastException
      at com.sun.crypto.provider.SunJCE_ab.a(DashoA6275)
      at com.sun.crypto.provider.PBEWithMD5AndDESCipher.engineInit(DashoA6275)
      at javax.crypto.Cipher.init(DashoA6275)

      With DES I get:

      InvalidKeyException.. Invalid key length: 40 bytes



      I think my VerifierInfo must be initialized acording with the cipherAlgorithm or maybe doing something else wrong...

      I appreciate any help...

        • 1. Re: SRP  Interceptors
          nmeira


          JBoss Version is 3.2.6

          java version "1.4.2_05"
          Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_
          Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)