Alessandro Brawerman

Greenhorn
+ Follow
since Sep 22, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Alessandro Brawerman

Hi all,
I just downloaded the personal profile binaries from SUN. However, whenever I try to use the CVM binary file, I get the following message: cannot execute binary file.
Has anyone had this problem?
Thanks.
18 years ago
It might be useful to mention also that this zaurus uses PersonalJava, not Personal Profile.
Thanks.
19 years ago
Hi,
it has the Jeode VM. I have executed code that connects using http and socket connections, I think the problem here is when I use the crypto files from the JCE jar (not sure).
19 years ago
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.
19 years ago
The arraycopy works.
Thanks.

This is the small test I ran to check.
byte[] t = "test".getBytes();
byte[] t1 = "test".getBytes();
byte[] t2 = new byte[8];
System.arraycopy(t,0,t2,0,4);
System.arraycopy(t1,0,t2,4,4);
byte[] t3 = "testtest".getBytes();
if(Arrays.equals(t2,t3)) System.out.println("SAME");
else System.out.println("NO");
19 years ago
Hi all,
just a quick question.
I have 2 different byte arrays. They are of the same size.
How can I put then together in a third byte arrays? Like concatenating 2 string in a third one.
Thanks,
Alessandro.
19 years ago
Hi all,
I'm trying to send an encrypted byte array through a socket. The other side (the client) has to read it and decrypt it. The problem is that the client is not receiving the encrypted byte array correct. Below follows the code I have:
---- sending the encrypted byte array (server side)
byte[] data = "test".getBytes();
byte[] result = cipher1.doFinal(data);
OutputStream os = connection.getOutputStream();
os.write(result);
os.flush();
----- receiving the encrypted byte array (client side)
InputStream bin = connection.getInputStream();
byte[] input = new byte[64];
for(int i = 0; i < input.length; i++) {
int b = bin.read();
if(b == -1) break;
input[i] = (byte) b;
}

When I check if input is equal to result, I get a no as answer. Is anything wrong with my code?
Thanks a lot.
Alessandro.
19 years ago
Hi all,
I'm trying to send an encrypted byte array through a socket. The other side (the client) has to read it and decrypt it. The problem is that the client is not receiving the encrypted byte array correct. Below follows the code I have:
---- sending the encrypted byte array (server side)
byte[] data = "test".getBytes();
byte[] result = cipher1.doFinal(data);
BufferedOutputStream bos = new BufferedOutputStream(connection.getOutputStream());
bos.write(result);
bos.flush();
----- receiving the encrypted byte array (client side)
BufferedInputStream bin = new BufferedInputStream(connection.getInputStream());
byte[] input = new byte[64];
for(int i = 0; i < input.length; i++) {
int b = bin.read();
if(b == -1) break;
input[i] = (byte) b;
}

When I check if input is equal to result, I get a no as answer. Is anything wrong with my code?
Thanks a lot.
Alessandro.
Never mind. I was comparing the wrong arrays.
It should be:
if(Arrays.equals(data, original))
and not:
if(Arrays.equals(result, original))

Sorry.
19 years ago
Thanks Sherry, comparing the byte arrays with the Arrays.equals worked.
Just one more question. In the code below result and original are still different, is there something that you think is wrong or missing?

Cipher cipher1 = Cipher.getInstance("AES", "BC");
Cipher cipher2 = Cipher.getInstance("AES", "BC");
cipher1.init(Cipher.ENCRYPT_MODE, key);
cipher2.init(Cipher.DECRYPT_MODE, key);
byte[] data = "test".getBytes();
byte[] result = cipher1.doFinal("test".getBytes());
byte[] original = cipher2.doFinal(result);

if(Arrays.equals(result, original)) System.out.println("YES");
else System.out.println("NO");
19 years ago
Hi all,
I'd like to know how to compare the contents of 2 byte arrays.
I have tried the following:

byte[] data = "test".getBytes();
byte[] data2 = "test".getBytes();
if(data2.equals(data)) System.out.println("YES");
else System.out.println("NO");

It didn't work, I thought that using .equals would work, but no.
Thanks,
Alessandro.
19 years ago
The questions are different. On the J2ME forum I was interested in one answer refarding mobile devices, here I'm asking if it is possible to do parallel downloads with Java (not J2ME). So please, let the people read and maybe answer this.
20 years ago
Hi all,
I need to improve performance on one experiment I'm currently working on. I have a client that currently connects to a server (via HTTP connection) and downloads a certain file. I was wondering if it is possible to have this client connecting to say, at least, 2 servers and download half of the file from each server at the same time. Since the bottleneck in my scenario is not the network doing this would probably increase overall performance.
Thanks,
Alessandro.
20 years ago
Is it possible to download pieces of the same file from different sources using Java? Can several socket connections be openned at the same time to different hosts?
The thing is I want to increase the performance of my application when downloading files either through sockets or URLConnections and I thought that downloading pieces of the same file from different hosts would be a good idea. Is there a way to do it? How?
Thanks,
Alessandro.
Is it possible to download pieces of the same file from different sources using J2ME? Can several socket connections be openned at the same time to different hosts?
The thing is I want to increase the performance of my application when downloading files either through sockets or URLConnections and I thought that downloading pieces of the same file from different hosts would be a good idea. Is there a way to do it? How?
Thanks,
Alessandro.
20 years ago