Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > public key encryption javax.crypto

Reply
Thread Tools

public key encryption javax.crypto

 
 
Larry Grant
Guest
Posts: n/a
 
      05-07-2004
My primary eperience with crypto is using PGP, but now I'd like to use
crypto in a Java application. I've been wading therough the javadocs
for the "javax.crypto" package, and I'm having a hard time finding any
straightforward way to just perform basic public key encryption like
PGP does. I've found references to ElGamal and Diffie-Hellman
algorithms, but they seem to be all about "key agreements", not
encryption.

Is there anything in javax.crypto that will just let me generate key
pairs and then perform encryptions to public keys and decryptions from
private keys?
 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      05-07-2004
Larry Grant wrote:

> My primary eperience with crypto is using PGP, but now I'd like to use
> crypto in a Java application. I've been wading therough the javadocs
> for the "javax.crypto" package, and I'm having a hard time finding any
> straightforward way to just perform basic public key encryption like
> PGP does. I've found references to ElGamal and Diffie-Hellman
> algorithms, but they seem to be all about "key agreements", not
> encryption.
>
> Is there anything in javax.crypto that will just let me generate key
> pairs and then perform encryptions to public keys and decryptions from
> private keys?


 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      05-07-2004
Larry Grant wrote:

> My primary eperience with crypto is using PGP, but now I'd like to use
> crypto in a Java application. I've been wading therough the javadocs
> for the "javax.crypto" package, and I'm having a hard time finding any
> straightforward way to just perform basic public key encryption like
> PGP does. I've found references to ElGamal and Diffie-Hellman
> algorithms, but they seem to be all about "key agreements", not
> encryption.
>
> Is there anything in javax.crypto that will just let me generate key
> pairs and then perform encryptions to public keys and decryptions from
> private keys?


CipherInputStream and CipherOutputStream sounds promising to me...
 
Reply With Quote
 
Carl Howells
Guest
Posts: n/a
 
      05-07-2004
Larry Grant wrote:
> My primary eperience with crypto is using PGP, but now I'd like to use
> crypto in a Java application. I've been wading therough the javadocs
> for the "javax.crypto" package, and I'm having a hard time finding any
> straightforward way to just perform basic public key encryption like
> PGP does. I've found references to ElGamal and Diffie-Hellman
> algorithms, but they seem to be all about "key agreements", not
> encryption.
>
> Is there anything in javax.crypto that will just let me generate key
> pairs and then perform encryptions to public keys and decryptions from
> private keys?


Having done this recently:

Kind of.

javax.crypto and java.security provide an interface with which
public-key encryption can be performed. However, they don't provide a
default implementation of most algorithms, instead providing only the a
common interface for provider to use.

I ended up using bouncycastle <http://www.bouncycastle.org/> as the
provider, using the javax.crypto and java.security interfaces.
 
Reply With Quote
 
Larry Grant
Guest
Posts: n/a
 
      05-07-2004
Michael Borgwardt <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Larry Grant wrote:
> >
> > Is there anything in javax.crypto that will just let me generate key
> > pairs and then perform encryptions to public keys and decryptions from
> > private keys?

>
> CipherInputStream and CipherOutputStream sounds promising to me...


I'd seen those, but I thought they were only for symmetric-key (not
public key) encryption. I'll take another look. Thanks.
 
Reply With Quote
 
Michael Borgwardt
Guest
Posts: n/a
 
      05-08-2004
Larry Grant wrote:
>>>Is there anything in javax.crypto that will just let me generate key
>>>pairs and then perform encryptions to public keys and decryptions from
>>>private keys?

>>
>>CipherInputStream and CipherOutputStream sounds promising to me...

>
>
> I'd seen those, but I thought they were only for symmetric-key (not
> public key) encryption. I'll take another look. Thanks.


Note that PGP and all similar programs do NOT use public key cryprography on
the actual content; they use it only to encrypt a session key which is then
used with a symmetric-key algorithm.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-08-2004
On Sat, 08 May 2004 02:29:09 +0200, Michael Borgwardt
<(E-Mail Removed)> wrote or quoted :

>Note that PGP and all similar programs do NOT use public key cryprography on
>the actual content; they use it only to encrypt a session key which is then
>used with a symmetric-key algorithm.


To use these classes, you don't need to be aware of how it works under
the covers. You just feed PGP keys and text and both ends and it does
it thing.


BouncyCastle is a JCE (Java Cryptographic Extension)-compatible
library that also handles PGP. It is well regarded. The source is not
well formatted or commented. The JavaDoc is sparce and inaccurate.

You will want to download the BouncyCastle jars for:
JCE Provider
open PGP
test examples
Java Source for Open PGP

Put the jars in your ext directory.

Generating Keys

Generate a binary private/public key with:

java org.BouncyCastle.openpgp.examples.RSAKeyPairGenera tor charlie
"open sesame"

The public and private keys will appear as pub.bpg, and secret.bpg.
You can generate ascii *.asc ascii armoured file instead by using the
-a option like this:

java org.bouncycastle.openpgp.examples.RSAKeyPairGenera tor -a charlie
"open sesame"

To generate variants look at the source code in bcpg-jdk14-122/src/
org/bouncycastleopenpgp/examples/RSAKeyPairGenerator.java

Signing A Binary File

java org.bouncycastle.openpgp.examples.SignedFileProces sor -s
anyfile.dat secret.bpg "open sesame"

Resulting signed file will appear in anyfile.dat.bpg signed, but not
encrypted.

Verifying a Signed Binary File

java org.bouncycastle.openpgp.examples.SignedFileProces sor -v
anyfile.dat.bpg pub.bpg
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments