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

    SRP  Interceptors

    Nuno Meira Newbie

      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...