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 remove padding after RSA decryption??

843851Apr 13 2005 — edited Sep 17 2007
Hello,

I am testing my host apps ability to read public key that was saved in file after being exported from smart card where it was generated.
I have successfully used the private key on card to encrypt a small piece of data and the cryptogram is returned to the host.
On host side I retrieve public key from file and decrypt ciphertext
The on-card alg for Cipher is declared as follows-
RSAcipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, true);
and in the host app
Cipher rsaCipher = Cipher.getInstance("RSA","BC");
I can see from what is returned from
byte[] decrypted = rsaCipher.doFinal(this.encryptedData);
that the correct data is being returned, but is is padded by
01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF00
How do I know where the padding ends and the plaintext begins?
Can anyone help me with this?

Thanks in advance,
Ann
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 15 2007
Added on Apr 13 2005
4 comments
1,461 views