Page 1 of 1

javacardx.crypto package / jcdk 2.1.1

Posted: Tue Jan 03, 2017 10:02 am
by flytoUS2016
hi:
I'm devolping a java card applet with the jcdk 2.1.1. I can install some applets on the card and now I try to use the Cipher class and the KeyEncryption interface in package javacardx.crypto. But in the documentation I found that its in an optional package and not in the jcdk included. Where can I find crypto packages?and how to use it?

Thanks in advance!!!!

Re: javacardx.crypto package / jcdk 2.1.1

Posted: Wed Jan 04, 2017 1:31 am
by UNKNwYSHSA
It is only one interface.
You need to check if the class Key implements this interface.
Here's one piece of source code for its usage:

Code: Select all

// The last parameter of method KeyBuilder.buildKey is true, means the built key implements the Encryption interface;
// If key encryption interface is not supported, this method throws exception: CryptoException.NO_SUCH_ALGORITHM;
aesKeyEncryption = (AESKey) KeyBuilder.buildKey(keyType, KeyBuilder.LENGTH_AES_128, true);
if (!(aesKeyEncryption instanceof KeyEncryption)) {
    // Throw exception;
    // return;
}
// aesKeyEncryption.setKeyCipher(...);
// aesKeyEncryption.getKeyCipher();