 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Christian Vogt Guest
|
Posted: Thu Dec 08, 2005 8:39 am Post subject: Solaris10: InvalidKeyException |
|
|
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;
}
|
|
| Back to top |
|
 |
Christian Vogt Guest
|
Posted: Thu Dec 08, 2005 11:00 am Post subject: Re: Solaris10: InvalidKeyException |
|
|
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
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|