Hi all,
I'm not sure if this is the right place to post this topic, but I'll try it anyway.
I've been developing some code in java to run my experiments with the Sharp Zaurus SL5600 PDA. Everything was working fine until the time I had to create chipers and perform encryption/decryption operations.
Currently, I'm using the Bouncy Castle and JCE APIs. The problem is that when I try to run my code in the zaurus vm, I get several errors.
This is a piece of code I think the errors are:
Socket connection = new Socket(host, port);
Security.addProvider(new com.sun.crypto.provider.SunJCE());
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
Date bg = new Date(); // Time before generating random number
SecureRandom random = new SecureRandom();
random.nextBytes(bytes);
Date ag = new Date(); // Time after generating random number
long tg = ag.getTime()-bg.getTime();
System.out.println("Time to generate rand num = " + tg + " ms");
// Imports EK
ObjectInputStream keyin = new ObjectInputStream(new FileInputStream(EK_path));
Key EK = (Key) keyin.readObject();
keyin.close();
// Encrypts random number with EK and sends it to the CA
Cipher cipher1 = Cipher.getInstance("AES", "BC");
Cipher cipher2 = Cipher.getInstance("AES", "BC");
cipher1.init(Cipher.ENCRYPT_MODE, EK);
cipher2.init(Cipher.DECRYPT_MODE, EK);
Date be = new Date(); // Time before encrypting/sending random number
byte[] result = cipher1.doFinal(bytes);
ObjectOutputStream out = new ObjectOutputStream(connection.getOutputStream());
out.write(result);
out.flush();
Date ae = new Date(); // Time after encrypting/sending random number
long te = ae.getTime()-be.getTime();
System.out.println("Time to encrypt/send rand num = " + te + " ms");
When I run this code, it does print out the part related to the random number, but it never gets to the second print, which is the time to encrypt.
The erros I get follow below:
Exception in threa "main", java.lang.NoClassDefFoundError: java/net/JarURLConnection
at javax.crypto.SunJCE_d.a (bytecode43)
at javax.crypto.SunJCE_b.i (bytecode12)
at javax.crypto.SunJCE_x.run
at java.security.AccessControler.doPrivileged
at javax.crypto.Cipher.a
at javax.crypto.Cipher.getinstance
In my executable script, class path, I have included the jce1_2_2.jar, the bcprov.jar, the sunjce.jar and some other related to security. In my opinion, I'm missing something in the script, maybe I should include something I'm not. The code works fine whem I ran it in my Mac. So, I think there is something missing in the PDA. Any ideas? Please help, I have searched in the web and had no luck.
Here's my executable script in the PDA:
. /home/QtPalmtop/bin/installdir.sh #set INSTALLDIR
$QPEDIR/bin/evm -XappName=runacp2 -cp $QPEDIR/extra_jar/local_policy.jar:$QPEDIR
/extra_jar/US_export_policy.jar:$QPEDIR/extra_jar/sunjce_provider.jar:$QPEDIR/ex
tra_jar/lcrypto-jdk13-130.zip:$QPEDIR/extra_jar/bcprov-jdk13-120.jar:$INSTALLDIR
/java rand_client
Thanks,
Alessandro.