Code Comments
Programming Forum and web based access to our favorite programming groups.Is there any way to access the DERIVED key (say a 3DES key) in J2SE and PBE? I think that although the internally derived IV is accessible, the derived key is not. Is that correct? e.g. String MYPBEALG = "PBEWithSHA1AndDESede" ; PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count); String password = "ssshh! a difficult secret" ; PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray()); keyFac = SecretKeyFactory.getInstance(MYPBEALG); SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec); Cipher pbeCipher = Cipher.getInstance(MYPBEALG); pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec); byte[] IV = pbeCipher.getIV() ; //actual internally generated IV byte[] key = pbeKey.getEncoded(); //this just returns the password as a by te[] - Mitch
Post Follow-up to this messageMichel Gallant wrote: > Is there any way to access the DERIVED key (say a 3DES key) > in J2SE and PBE? > I think that although the internally derived IV is accessible, the > derived key is not. Is that correct? > > e.g. > > String MYPBEALG = "PBEWithSHA1AndDESede" ; > PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, count); > String password = "ssshh! a difficult secret" ; > PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray()); > keyFac = SecretKeyFactory.getInstance(MYPBEALG); > SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec); > Cipher pbeCipher = Cipher.getInstance(MYPBEALG); > pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec); > > byte[] IV = pbeCipher.getIV() ; //actual internally generated IV > > byte[] key = pbeKey.getEncoded(); //this just returns the password as a byte[] There are some helper classes in BouncyCastle provider that will return derived key params. regards, Eugene
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.