Page 1 of 1

How to unwrap a key on java card

Posted: Tue Jan 19, 2016 4:45 am
by marclo
I have a problem when I do the unwrapping in the off card application. For unwrapping, the private key is needed. And the private key can not leave the java card. So I send the wrapped bytes to the card. But I can't find in javavardx.crypto.Cipher something like UNWRAP_MODE.
How can I use a javacard to unwrap a key?

Here is part of my code in the off card application:

Code: Select all

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1PADDING", "BC"); 
cipher.init(Cipher.UNWRAP_MODE, privateKey);
SecretKey key = (SecretKey)cipher.unwrap(wrappedKeyBytes, "AES", Cipher.SECRET_KEY);

Re: How to unwrap a key on java card

Posted: Wed Jan 20, 2016 5:39 am
by UNKNwYSHSA
You need to implement the unwrap method in your applet yourself. This method is not supported by the JC api.