View Full Version : AES Encryption Issue
WorldIRC
11-18-2004, 04:41 PM
Mark Rejhon
11-18-2004, 04:43 PM
WorldIRC
11-18-2004, 05:03 PM
Dev2100
01-13-2005, 11:23 PM
This is Code on Client (RIM JDE)
AESKey key = new AESKey(128);
EncodedKey encodedKey = SymmetricKeyEncoder.encode(key, "PKCS8" );
System.out.println("Encoded Key Format" + encodedKey.getEncodingAlgorithm());
System.out.println("AES Key Algoritham" + key.getAlgorithm());
System.out.println("Encoded Key Length" + key.getLength());
System.out.println("Encoded Key BitLength" + key.getBitLength());
if(!sendMessage(encodedKey.getEncodedKey())){
System.out.println("Failed to send AES Key");
}
I m encoding the key and transmiting this key to server using UDP.
on server side(UDP server implemented in Java with Certicom API)
decoding the Key in PKCS#8 format to get AES Key
Here is the Code on Server
PKCS8EncodedKeySpec k1spec = new PKCS8EncodedKeySpec(receiveKey());
System.out.println("Encoding Format" + k1spec.getFormat());
SecretKeyFactory skf = SecretKeyFactory.getInstance("AES","Certicom");
SecretKey ssk = skf.generateSecret(k1spec);
Cipher eAESCipher = Cipher.getInstance("AES");
eAESCipher.init(Cipher.DECRYPT_MODE,ssk);
BUt server throw exception
Exception :java.security.spec.InvalidKeySpecException: Invalid key spec
As on client as well as server I chked the encoding Format and it says PKCS#8
then why I am geting this exception.
[Edited by Mark Rejhon to add and tags to put source code in formatted blocks]
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.