[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNU Crypto] Re: java application
From: |
Casey Marshall |
Subject: |
[GNU Crypto] Re: java application |
Date: |
Sun, 29 Aug 2004 12:34:34 -0700 |
User-agent: |
Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux) |
>>>>> "lilia" == lilia belghith <address@hidden> writes:
lilia> Hello, I created an RSA key pair with gpg for windows. Now,
lilia> I want to use the public key which is saved in a file
lilia> (pubring) on my disk to encrypt a string variable (I perform
lilia> this from external java application). I put this code:
lilia> import javax.crypto.*;
lilia> import gnu.crypto.jce.GnuCrypto;
lilia> import gnu.crypto.key.rsa.*;
lilia> java.security.Security.addProvider(new gnu.crypto.jce.GnuCrypto());
lilia> encrypt(java.security.PublicKey k,java.math.BigInteger m);
lilia> My questions are: How can I call the file that contain the
lilia> public key?
What kind of file is it? If it is a Java keystore, you should use the
java.security.KeyStore class. If it a GPG (that is, OpenPGP) public
keyring, then you will need a Java class that decodes those files and
returns public keys.
I think the BouncyCastle library has some OpenPGP support
<http://bouncycastle.org>, and there is Cryptix's OpenPGP
implementation <http://www.cryptix.org/>.
lilia> Where the parameter (string variable that will be encrypted)
lilia> have to be passed?
gnu.crypto.sig.rsa.RSA.encrypt is a fairly low-level class, and we
currently do not have an RSA encryption routine with a nicer
interface.
The common way to encrypt messages with RSA is to "pad" the message
with some markers, and with some random data. RSA Data Security's PKCS
#1 defines how to pad messages for encryption (in this case, you would
pad the message as a byte array, then create a BigInteger from those
bytes, then use RSA.encrypt).
PKCS #1 is described here:
<ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf>
Hope this helps,
--
Casey Marshall || address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNU Crypto] Re: java application,
Casey Marshall <=