How to unwrap a key on java card
Posted: Tue Jan 19, 2016 4:45 am
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:
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);