Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to export RSA public key from card?

843851Feb 11 2004 — edited Feb 17 2004
hi, first, i�m sorry if my english is not very good

i�m using a Cryproflex 32k. First, i�ve generated a RSA pair keys into the card. after that, i would like to export the public key to use into an "standard" aplication (with IAIK).

for this, i�ve tried succesfully to extract exponent & modulus, and i send them to the CAD in two byte arrays, then the external application takes them (supossing the byte arrays to save them are: 'exp' and 'mod')

In IAIK, to construct a RSAPublicKey I need to transform exponent and modulus into BigInteger. I make it this way:
BigInteger bi_exp = new BigInteger(exp);
BigInteger bi_mod = new BigInteger(mod);

then IAIK generates a public key with both values, but when i try to use it for encrypt/decrypt, I get an error:

java.lang.ArithmeticException: BigInteger: modulus not positive
at java.math.BigInteger.modPow(BigInteger.java:1428)
at iaik.security.rsa.RSAPrivateKey.crypt(Unknown Source)
at iaik.pkcs.pkcs1.RSACipher.rawCrypt(Unknown Source)
at iaik.pkcs.pkcs1.RSACipher.b(Unknown Source)
at iaik.pkcs.pkcs1.RSACipher.engineDoFinal(Unknown Source)
at javax.crypto.Cipher.doFinal(DashoA6275)


why modulus sent by the card is not positive? what is wrong about this?

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 16 2004
Added on Feb 11 2004
2 comments
545 views