Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / December 2005

Tip: Looking for answers? Try searching our database.

Solaris10: InvalidKeyException

Thread view: 
Christian Vogt - 08 Dec 2005 08:39 GMT
Hallo,

I have a problem with public-key en/decryption on a Solaris10 box with java
1.4.2_9. Within the code below on 'cipher.init()' I receive an
InvalidKeyException: 'java.security.InvalidKeyException: Must be a PBEKey
in RAW format.: Key is invalid.'
The strange thing here is that the algorithm works Windows and Linux boxes
as well as on Solaris10. I'm a bit confused of where a can look to solve
this issue.

Any ideas?
Kind regards,
Christian

The relevant code for creating the cipher where the Exception is thrown:
[...]
/** salt byte array */
private static final byte[] PBE_SALT = new byte[] {
   (byte) 0xce, (byte) 0xfb, (byte) 0xde, (byte) 0xac,
   (byte) 0x05, (byte) 0x02, (byte) 0x19, (byte) 0x71};

private static final byte[] PASSWD_ARRAY = new byte[] {
   (byte) 0x72, (byte) 0x74, (byte) 0x21, (byte) 0x6c,
   (byte) 0x69, (byte) 0x63, (byte) 0x32, (byte) 0x30,
   (byte) 0x30, (byte) 0x35};

/** parameters for secret algorithm */
private static final AlgorithmParameterSpec ALGO_PARAM_SPEC =
   new PBEParameterSpec(PBE_SALT, 2005);

private static char[] passwd = null;

static {
   try {
       passwd = new String(
              PASSWD_ARRAY, BASE64_CHARSET).toCharArray();
       key = SecretKeyFactory.getInstance("PBEWithMD5AndDES")
           .generateSecret(new PBEKeySpec(passwd));
   } catch (InvalidKeySpecException e) {
       System.err.println("License initialization problems!");
   } catch (NoSuchAlgorithmException e) {
       System.err.println("License initialization problems!");
   } catch (UnsupportedEncodingException e) {
       System.err.println("License initialization problems!");
   }
}
[...]

static Cipher createCipher(final int opMode)
   throws NoSuchAlgorithmException, NoSuchPaddingException,
       InvalidKeyException, InvalidAlgorithmParameterException,
       LicenseException {
   if (key == null) {
       throw new CustomException("Secret key could not be created.");
   }
   Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");

   /* on init an InvalidKeyException is thrown */
   cipher.init(Cipher.DECRYPT_MODE, key, ALGO_PARAM_SPEC);    

   return cipher;
}
Christian Vogt - 08 Dec 2005 11:00 GMT
Hallo,

I was a bit too quick with my last post. The code snippet is not the one
responsible for the InvalidKeyException but the following. The
initialisation remains the same.

PublicKey verificationKey = (PublicKey) LicenseUtils.createKey(
                   new FileInputStream(pubKey), false);
Signature verificationEngine = Signature.getInstance("SHA1withDSA");
verificationEngine.initVerify(verificationKey);

Any Ideas? The strange thing here is that this issue only arises on a
Solaris Box. Is FileInputStream implementation a different one there?

Cheers,
Christian


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.