Skip to main content

How to Use Bouncy Castle on the CLDC KVM in Linux

18 replies [Last post]
Anonymous

Does anyone know how I would go about using Bouncy Castle on the CLDC
KVM in Linux. I have been trying to do this now for weeks and cannot
figure it out. I can use Bouncy Castle on Windows and on Linux using a
JVM but not using a KVM. Any help would be greatly appreciated.

Thank you.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Padilla, Alex D

Again, thank you everyone for your help.

Does anyone know anything about ROMizing? I have finally preverified
all my programs and their corresponding classes, but now I would like to
simply load the programs as standalone apps on the KVM. In other words,
I would like to execute the programs without having to include all
Bouncy Castle libraries in my classpath every time. Would it be
possible to use ROMizing to accomplish this on my custom built board
with a NIOSII processor?

Thank you.

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Robin Chaddock
Sent: Friday, July 20, 2007 3:39 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Just add whatever extra library classes your code has been compiled
against to the classpath when you execute the preverifier...

Also, I suggest you automate your build process using Ant (with the
Antenna extension for midp development); it'll make thing a lot simpler.

----- Original Message -----
From: Charles-Edouard Ruault
To: KVM-INTEREST@JAVA.SUN.COM
Sent: Friday, July 20, 2007 9:41 AM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Padilla, Alex D wrote:

Is there any way to modify the classes.zip file on the
KVM to allow it
to support otherwise unsupported classes? When I
preverify using
classes that are not inherent to the KVM infrastructure
(but are
supported on a JVM) I obviously get an error. I
basically need to
include the java.security library and a crypto provider
library like
Bouncy Castle. Many seem to have suggestions on what to
do if I was
using a development environment like NetBeans. However,
I need to find
a solution that is development environment free to save
memory space.
This means I develop the code in a text editor and
compile on a Linux
machine with javac. It also means I have to preverify
manually on the
Linux machine pointing to a zip file containing the
necessary supported
java libraries. Any help would be greatly appreciated.

It looks like you're trying to do something different than
building a j2me application including some bouncycastle classes.
Are you trying to modify the kvm itself to add support for
crypto to running midlets ?
If so, I would say that you should be able to included the
classes (source files) and compile them together with the other classes
of the KVM. However I've never done that, and therefore will not be able
to help you any further....

-----Original Message-----
From: A mailing list for KVM discussion

========================================================================
===
To unsubscribe, send email to listserv@java.sun.com and
include in the body
of the message "signoff KVM-INTEREST". For general
help, send email to
listserv@java.sun.com and include in the body of the
message "help".

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Charles-Edouard Ruault

[att1.html]

Robin Chaddock

Just add whatever extra library classes your code has been compiled against to the classpath when you execute the preverifier...

Also, I suggest you automate your build process using Ant (with the Antenna extension for midp development); it'll make thing a lot simpler.
----- Original Message -----
From: Charles-Edouard Ruault
To: KVM-INTEREST@JAVA.SUN.COM
Sent: Friday, July 20, 2007 9:41 AM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Padilla, Alex D wrote:
Is there any way to modify the classes.zip file on the KVM to allow it
to support otherwise unsupported classes? When I preverify using
classes that are not inherent to the KVM infrastructure (but are
supported on a JVM) I obviously get an error. I basically need to
include the java.security library and a crypto provider library like
Bouncy Castle. Many seem to have suggestions on what to do if I was
using a development environment like NetBeans. However, I need to find
a solution that is development environment free to save memory space.
This means I develop the code in a text editor and compile on a Linux
machine with javac. It also means I have to preverify manually on the
Linux machine pointing to a zip file containing the necessary supported
java libraries. Any help would be greatly appreciated.

It looks like you're trying to do something different than building a j2me application including some bouncycastle classes.
Are you trying to modify the kvm itself to add support for crypto to running midlets ?
If so, I would say that you should be able to included the classes (source files) and compile them together with the other classes of the KVM. However I've never done that, and therefore will not be able to help you any further....

-----Original Message-----
From: A mailing list for KVM discussion
===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Padilla, Alex D

Thank you everyone for your help. I finally was able to get past the
preverify step which I have been hounding everyone about. I was able to
do so per Robin's request to add the extra library classes that my code
has been compiled against to the classpath. It was actually something
really simple (as it always seems to be when you just can't figure
something out).

Now I have a question about the kvm command I will be using. I am using
a customized board with a NIOS II processor to load my java programs on.
Before I was using Bouncy Castle, I was running programs on the board
using the KVM with the following command:

kvm -classpath "./usr" classname

The "usr" directory is the directory containing the preverified class
file I want to run. Now, I would like to execute the program in the
same manner. However, I need to also point to the Bouncy Castle
libraries I am using in the program so the KVM will recognize them. I
have loaded these libraries onto the board in the "usr" directory in a
couple of zip files. Does anyone know the command to do this?

Thank you all in advance.

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Robin Chaddock
Sent: Friday, July 20, 2007 3:39 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Just add whatever extra library classes your code has been compiled
against to the classpath when you execute the preverifier...

Also, I suggest you automate your build process using Ant (with the
Antenna extension for midp development); it'll make thing a lot simpler.

----- Original Message -----
From: Charles-Edouard Ruault
To: KVM-INTEREST@JAVA.SUN.COM
Sent: Friday, July 20, 2007 9:41 AM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Padilla, Alex D wrote:

Is there any way to modify the classes.zip file on the
KVM to allow it
to support otherwise unsupported classes? When I
preverify using
classes that are not inherent to the KVM infrastructure
(but are
supported on a JVM) I obviously get an error. I
basically need to
include the java.security library and a crypto provider
library like
Bouncy Castle. Many seem to have suggestions on what to
do if I was
using a development environment like NetBeans. However,
I need to find
a solution that is development environment free to save
memory space.
This means I develop the code in a text editor and
compile on a Linux
machine with javac. It also means I have to preverify
manually on the
Linux machine pointing to a zip file containing the
necessary supported
java libraries. Any help would be greatly appreciated.

It looks like you're trying to do something different than
building a j2me application including some bouncycastle classes.
Are you trying to modify the kvm itself to add support for
crypto to running midlets ?
If so, I would say that you should be able to included the
classes (source files) and compile them together with the other classes
of the KVM. However I've never done that, and therefore will not be able
to help you any further....

-----Original Message-----
From: A mailing list for KVM discussion

========================================================================
===
To unsubscribe, send email to listserv@java.sun.com and
include in the body
of the message "signoff KVM-INTEREST". For general
help, send email to
listserv@java.sun.com and include in the body of the
message "help".

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Charles-Edouard Ruault

[att1.html]

Padilla, Alex D

Thank you Charles-Edouard Ruault. I think that sounds like a great way
to go about it. However, I have never done that before. How would one
go about importing only the sources I need on my project in Linux?
Thank you very much.

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Charles-Edouard Ruault
Sent: Wednesday, July 18, 2007 1:37 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Padilla, Alex D wrote:

Thank you very much for your reply. Do you know where
specifically that I save this download on the KVM and how I preverify
pointing at both the classes.zip file and this version of Bouncy Castle?

Thanks again.

The way i used it is importing the sources on my project ( i stripped
the sources to keep only the features i needed ) and then rebuilt my
application, including the bc classes that were compiled & preverified
together with my app. You cannot have this package on the KVM and have
it used by an app, it has to be included in the jar file of the
application .

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Charles-Edouard Ruault
Sent: Tuesday, July 17, 2007 12:22 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Padilla, Alex D wrote:

Does anyone know how I would go about using Bouncy
Castle on the CLDC KVM in Linux. I have been trying to do this now for
weeks and cannot figure it out. I can use Bouncy Castle on Windows and
on Linux using a JVM but not using a KVM. Any help would be greatly
appreciated.

Thank you.

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

The easy way is to use the specific j2me version (
lcrypto-j2me-136.tar.gz ) , it worked out of the box for me.
You can get it here :
http://www.bouncycastle.org/download/lcrypto-j2me-137.tar.gz

--
Charles-Edouard Ruault
GPG key Id E4D2B80C

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".
========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

--
Charles-Edouard Ruault
GPG key Id E4D2B80C
========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Joe Bowbeer

On 7/18/07, Padilla, Alex D wrote:
>
> Thank you Charles-Edouard Ruault. I think that sounds like a great way to
> go about it. However, I have never done that before. How would one go
> about importing only the sources I need on my project in Linux? Thank you
> very much.
>

See the proguard script in my previous message.

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Padilla, Alex D

Is there any way to modify the classes.zip file on the KVM to allow it
to support otherwise unsupported classes? When I preverify using
classes that are not inherent to the KVM infrastructure (but are
supported on a JVM) I obviously get an error. I basically need to
include the java.security library and a crypto provider library like
Bouncy Castle. Many seem to have suggestions on what to do if I was
using a development environment like NetBeans. However, I need to find
a solution that is development environment free to save memory space.
This means I develop the code in a text editor and compile on a Linux
machine with javac. It also means I have to preverify manually on the
Linux machine pointing to a zip file containing the necessary supported
java libraries. Any help would be greatly appreciated.

-----Original Message-----
From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Joe Bowbeer
Sent: Wednesday, July 18, 2007 2:21 PM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

On 7/18/07, Padilla, Alex D wrote:
>
> Thank you Charles-Edouard Ruault. I think that sounds like a great
> way to go about it. However, I have never done that before. How
> would one go about importing only the sources I need on my project in
> Linux? Thank you very much.
>

See the proguard script in my previous message.

========================================================================
===
To unsubscribe, send email to listserv@java.sun.com and include in the
body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Java

Hello,

> However, I need to find a solution that is development environment
> free to save memory space.

Does that means that you're trying to save memory on your development
workstation or do you want to save memory on your embedded device?

In the latter case, you should know that the development environnement
you use for J2ME applications does not make a difference in the final
code. Working with a text editor on Linux and compiling with Javac will
yield the exact same .jar file as working with NetBeans on Windows.

Your development platform matters only if you're working on adding a
native library to the KVM. Please note that this means that you're
rolling out your own J2ME device since it is impossible to load native
libraries in an existing device. Even this case, many people work with
Windows and cross-compile with something like MSYS.

If you're only trying to save memory on your PC, I suggest you to try
Ant and Antenna. Ant is a "scripting" langage targeted at building Java
application. It can be used to perform the compilation and packaging
steps automatically. It is compatible with Windows and Linux and can be
called from the command line or directly from Eclipse or Netbeans.

Best Regards,
David

Padilla, Alex D wrote:
> Is there any way to modify the classes.zip file on the KVM to allow it
> to support otherwise unsupported classes? When I preverify using
> classes that are not inherent to the KVM infrastructure (but are
> supported on a JVM) I obviously get an error. I basically need to
> include the java.security library and a crypto provider library like
> Bouncy Castle. Many seem to have suggestions on what to do if I was
> using a development environment like NetBeans. However, I need to find
> a solution that is development environment free to save memory space.
> This means I develop the code in a text editor and compile on a Linux
> machine with javac. It also means I have to preverify manually on the
> Linux machine pointing to a zip file containing the necessary supported
> java libraries. Any help would be greatly appreciated.
>
>
> -----Original Message-----
> From: A mailing list for KVM discussion
> [mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Joe Bowbeer
> Sent: Wednesday, July 18, 2007 2:21 PM
> To: KVM-INTEREST@JAVA.SUN.COM
> Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux
>
> On 7/18/07, Padilla, Alex D wrote:
>> Thank you Charles-Edouard Ruault. I think that sounds like a great
>> way to go about it. However, I have never done that before. How
>> would one go about importing only the sources I need on my project in
>> Linux? Thank you very much.
>>
>
> See the proguard script in my previous message.
>
> ========================================================================
> ===
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body of the message "signoff KVM-INTEREST". For general help, send
> email to listserv@java.sun.com and include in the body of the message
> "help".
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff KVM-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Charles-Edouard Ruault

[att1.html]

Padilla, Alex D

Thank you very much for your reply. Do you know where specifically that
I save this download on the KVM and how I preverify pointing at both the
classes.zip file and this version of Bouncy Castle?

Thanks again.

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Charles-Edouard Ruault
Sent: Tuesday, July 17, 2007 12:22 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

Padilla, Alex D wrote:

Does anyone know how I would go about using Bouncy Castle on the
CLDC KVM in Linux. I have been trying to do this now for weeks and
cannot figure it out. I can use Bouncy Castle on Windows and on Linux
using a JVM but not using a KVM. Any help would be greatly appreciated.

Thank you.

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

The easy way is to use the specific j2me version (
lcrypto-j2me-136.tar.gz ) , it worked out of the box for me.
You can get it here :
http://www.bouncycastle.org/download/lcrypto-j2me-137.tar.gz

--
Charles-Edouard Ruault
GPG key Id E4D2B80C
========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Joe Bowbeer

On 7/17/07, Padilla, Alex D wrote:
>
> Thank you very much for your reply. Do you know where specifically that
> I save this download on the KVM and how I preverify pointing at both the
> classes.zip file and this version of Bouncy Castle?
>
>

You can't install bouncycastle on the KVM. You need to bind the
bouncycastle classes that you are using into your application.

In NetBeans you can add bouncycastle as a library and then add the library
to your mobile project as a dependency.

If you're using Ant directly, look for bouncycastle references here:

http://developers.sun.com/mobility/midp/articles/security3/
http://developers.sun.com/mobility/midp/articles/security4/

--
Joe Bowbeer

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Padilla, Alex D

Again, thank you for your reply. I am simply using javac to compile my
programs in Linux. I would like to avoid using Netbeans or any other
development environment if possible as I am trying keep what I am
running on the KVM to a minimal level. I can compile using javac with
programs that run Bouncy Castle. However, it is when I try to preverify
that I get an error. Because I am compiling with javac, the classes.zip
file with the minimal set of java classes supported by the KVM is used
in this process. Therefore, when I preverify, if I point to another set
of java classes like those I need to run Bouncy Castle, I get a "Wrong
Name" error. Does anyone know how I would go about compiling using
javac pointing to the correct Bouncy Castle zip files in the process and
subsequently preverify pointing to the same set of zip files?

Thank you again for your help?

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Joe Bowbeer
Sent: Tuesday, July 17, 2007 11:27 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

On 7/17/07, Padilla, Alex D wrote:

Thank you very much for your reply. Do you know where
specifically that I save this download on the KVM and how I preverify
pointing at both the classes.zip file and this version of Bouncy Castle?

You can't install bouncycastle on the KVM. You need to bind the
bouncycastle classes that you are using into your application.

In NetBeans you can add bouncycastle as a library and then add the
library to your mobile project as a dependency.

If you're using Ant directly, look for bouncycastle references here:

http://developers.sun.com/mobility/midp/articles/security3/
http://developers.sun.com/mobility/midp/articles/security4/

--
Joe Bowbeer
========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Joe Bowbeer

As long as you're using Java, I suggest you use Ant in your tool chain.
(Netbeans will happily use your Ant script, too, by the way.)

The javac command in Ant looks something like this:

bootclasspathref="boot.classpath" classpath="${bouncycastle.lib}" source="
1.2" target="1.2"/>

Note that bootclasspathref points to the cldc/midp classes and the classpath
points to bouncycastle.

Then use proguard to compact everything and remove unreferenced classes:





The proguard step is crucial with bouncycastle.

Then preverify the result of that:







If you still run into trouble, please send more details.

On 7/17/07, Padilla, Alex D wrote:
>
> Again, thank you for your reply. I am simply using javac to compile my
> programs in Linux. I would like to avoid using Netbeans or any other
> development environment if possible as I am trying keep what I am running on
> the KVM to a minimal level. I can compile using javac with programs that
> run Bouncy Castle. However, it is when I try to preverify that I get an
> error. Because I am compiling with javac, the classes.zip file with the
> minimal set of java classes supported by the KVM is used in this process.
> Therefore, when I preverify, if I point to another set of java classes like
> those I need to run Bouncy Castle, I get a "Wrong Name" error. Does anyone
> know how I would go about compiling using javac pointing to the correct
> Bouncy Castle zip files in the process and subsequently preverify pointing
> to the same set of zip files?
>
> Thank you again for your help?
>
> ------------------------------
> *From:* A mailing list for KVM discussion [mailto:
> KVM-INTEREST@JAVA.SUN.COM] *On Behalf Of *Joe Bowbeer
> *Sent:* Tuesday, July 17, 2007 11:27 AM
> *To:* KVM-INTEREST@JAVA.SUN.COM
> *Subject:* Re: How to Use Bouncy Castle on the CLDC KVM in Linux
>
> On 7/17/07, Padilla, Alex D wrote:
> >
> > Thank you very much for your reply. Do you know where specifically
> > that I save this download on the KVM and how I preverify pointing at both
> > the classes.zip file and this version of Bouncy Castle?
> >
> >
>
> You can't install bouncycastle on the KVM. You need to bind the
> bouncycastle classes that you are using into your application.
>
> In NetBeans you can add bouncycastle as a library and then add the library
> to your mobile project as a dependency.
>
> If you're using Ant directly, look for bouncycastle references here:
>
> http://developers.sun.com/mobility/midp/articles/security3/
> http://developers.sun.com/mobility/midp/articles/security4/
>
> --
> Joe Bowbeer
>

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Padilla, Alex D

Thank you Joe for your response. However, I believe we are talking
about two totally different things. You are explaining how to use
Bouncy Castle via Ant in Netbeans from what I gather. I have done this
in Windows before. However, I am developing programs that use Bouncy
Castle and am trying to get them going on the KVM in Linux. Linux is
the key here. This means that I must use the javac compiler in Linux
and preverify in Linux because I will need to make a Linux image and use
that image later. Am I correct that we are talking about different
things? If I not, maybe I am missing something. If so, maybe someone
you or someone can help me get it going on Linux without a development
environment.

Thanks again.

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Joe Bowbeer
Sent: Tuesday, July 17, 2007 2:12 PM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

As long as you're using Java, I suggest you use Ant in your tool chain.
(Netbeans will happily use your Ant script, too, by the way.)

The javac command in Ant looks something like this:

bootclasspathref="boot.classpath" classpath="${bouncycastle.lib}"
source="1.2" target="1.2"/>

Note that bootclasspathref points to the cldc/midp classes and the
classpath points to bouncycastle.

Then use proguard to compact everything and remove unreferenced classes:

destfile="${build.dir}/before-obfuscation.jar"/>





The proguard step is crucial with bouncycastle.

Then preverify the result of that:







If you still run into trouble, please send more details.

On 7/17/07, Padilla, Alex D wrote:

Again, thank you for your reply. I am simply using javac to
compile my programs in Linux. I would like to avoid using Netbeans or
any other development environment if possible as I am trying keep what I
am running on the KVM to a minimal level. I can compile using javac
with programs that run Bouncy Castle. However, it is when I try to
preverify that I get an error. Because I am compiling with javac, the
classes.zip file with the minimal set of java classes supported by the
KVM is used in this process. Therefore, when I preverify, if I point to
another set of java classes like those I need to run Bouncy Castle, I
get a "Wrong Name" error. Does anyone know how I would go about
compiling using javac pointing to the correct Bouncy Castle zip files in
the process and subsequently preverify pointing to the same set of zip
files?

Thank you again for your help?

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Joe Bowbeer
Sent: Tuesday, July 17, 2007 11:27 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

On 7/17/07, Padilla, Alex D < adpadil@sandia.gov
> wrote:

Thank you very much for your reply. Do you know where
specifically that I save this download on the KVM and how I preverify
pointing at both the classes.zip file and this version of Bouncy Castle?

You can't install bouncycastle on the KVM. You need to bind the
bouncycastle classes that you are using into your application.

In NetBeans you can add bouncycastle as a library and then add
the library to your mobile project as a dependency.

If you're using Ant directly, look for bouncycastle references
here:

http://developers.sun.com/mobility/midp/articles/security3/
http://developers.sun.com/mobility/midp/articles/security4/

--
Joe Bowbeer

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Joe Bowbeer

On 7/17/07, Padilla, Alex D wrote:
>
> Thank you Joe for your response. However, I believe we are talking about
> two totally different things. You are explaining how to use Bouncy Castle
> via Ant in Netbeans from what I gather. I have done this in Windows before.
> However, I am developing programs that use Bouncy Castle and am trying
> to get them going on the KVM in Linux. Linux is the key here.

You're saying you have a build script for a MIDlet using bouncycastle
that builds on Windows but doesn't build/preverify on Linux?

If that is the case then I did misunderstand you.

Please let us see your build script and the error messages.

By the way, can I assume you're using proguard or some other
obfuscator to remove the unreferenced bouncy castle classes?
(Otherwise, you'd likely already encountered preverification problems
due to some extra stuff in the bouncycastle distribution, or, if not,
you'd likely already encountered problems installing on a real
device.)

Can I also assume that the build script for Windows and Linux are
identical up to the verification step?

--
Joe Bowbeer

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Padilla, Alex D

To compile on Linux I simply use:

javac -g:none -bootclasspath ~/download/j2me_cldc/api main.java

In the above example, main.java is a program I wrote using Bouncy
Castle. The ~/download/j2me_cldc/api directory is where I store my zip
files that contain Java classes.

To preverify I use:

./preverify classes.zip -verbose main

In the above example, main is the main.class file generated when I
successfully compile main.java; classes.zip is the pre-defined set of
java classes supported by the KVM. Of course, these do not include the
Bouncy Castle zips so I get a Class Not DefFound Error when I do this.
When I point to the cldc_crypto.zip (the J2ME zip from the Bouncy Castle
website) file instead of classes.zip, I get a Wrong Name error. This
means that the KVM did not find the same class files in the zip I am
pointing to as it did from it's pre-defined classes. So, is there a way
to load these Bouncy Castle zips into the KVM or point to them when I
preverify without getting these errors?

Thank you.

-----Original Message-----
From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of Joe Bowbeer
Sent: Tuesday, July 17, 2007 3:37 PM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: How to Use Bouncy Castle on the CLDC KVM in Linux

On 7/17/07, Padilla, Alex D wrote:
>
> Thank you Joe for your response. However, I believe we are talking
> about two totally different things. You are explaining how to use
> Bouncy Castle via Ant in Netbeans from what I gather. I have done
this in Windows before.
> However, I am developing programs that use Bouncy Castle and am trying

> to get them going on the KVM in Linux. Linux is the key here.

You're saying you have a build script for a MIDlet using bouncycastle
that builds on Windows but doesn't build/preverify on Linux?

If that is the case then I did misunderstand you.

Please let us see your build script and the error messages.

By the way, can I assume you're using proguard or some other obfuscator
to remove the unreferenced bouncy castle classes?
(Otherwise, you'd likely already encountered preverification problems
due to some extra stuff in the bouncycastle distribution, or, if not,
you'd likely already encountered problems installing on a real
device.)

Can I also assume that the build script for Windows and Linux are
identical up to the verification step?

--
Joe Bowbeer

========================================================================
===
To unsubscribe, send email to listserv@java.sun.com and include in the
body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Eric Giguere

Padilla, Alex D wrote:
> Does anyone know how I would go about using Bouncy Castle on the CLDC
> KVM in Linux. I have been trying to do this now for weeks and cannot
> figure it out. I can use Bouncy Castle on Windows and on Linux using a
> JVM but not using a KVM. Any help would be greatly appreciated.

Not all the classes in Bouncy Castle work in the CLDC. You have to
decide which ones you want to use and see if they're supported and then
extract them from the main jar. That's what I did, anyhow.

Eric

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".