**javacard.security** ====Interface AESKey ==== *[[javacard:java-card-api:object|java.lang.Object]] \\ *[[javacard:java-card-api:throwable|java.lang.Throwable]] \\ *[[javacard:java-card-api:exception|java.lang.Exception]] \\ *[[javacard:java-card-api:runtimeexception|java.lang.RuntimeException]] \\ *[[javacard:java-card-api:cardruntimeexception|javacard.framework.CardRuntimeException]] \\ **All Superinterfaces:** [[javacard:java-card-api:Key|Key]] , [[javacard:java-card-api:SecretKey|SecretKey]] ---- public interface **AESKey**extends [[javacard:java-card-api:SecretKey|SecretKey]] AESKey contains a 16/24/32 byte key for AES computations based on the Rijndael algorithm. When the key data is set, the key is initialized and ready for use. **Since:** Java Card 2.2 **See Also:**[[javacard:java-card-api:KeyBuilder|KeyBuilder]] , [[javacard:java-card-api:Signature|Signature]] , [[javacard:java-card-api:Cipher|javacardx.crypto.Cipher]] , [[javacard:java-card-api:KeyEncryption|javacardx.crypto.KeyEncryption]] ---- ^ Method Summary ^^ | ** byte** | **[[javacard:java-card-api:AESKey#getKey(byte[], short)|getKey]] **(byte[] keyData,short kOff)          Returns the Key data in plain text. | | ** void** | **[[javacard:java-card-api:AESKey#setKey(byte[], short)|setKey]] **(byte[] keyData,short kOff)          Sets the Key data. |   ^ Methods inherited from interface javacard.security.Key ^ | [[javacard:java-card-api:Key#clearKey()|clearKey]] , [[javacard:java-card-api:Key#getSize()|getSize]] , [[javacard:java-card-api:Key#getType()|getType]] , [[javacard:java-card-api:Key#isInitialized()|isInitialized]] |   ^ Method Detail ^ === setKey === void **setKey**(byte[] keyData, short kOff) throws [[javacard:java-card-api:CryptoException|CryptoException]] , [[javacard:java-card-api:NullPointerException|NullPointerException]] , [[javacard:java-card-api:ArrayIndexOutOfBoundsException|ArrayIndexOutOfBoundsException]] Sets the Key data. The plaintext length of input key data is 16/24/32 bytes. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). Input key data is copied into the internal representation. Note: \\ *//If the key object implements the //javacardx.crypto.KeyEncryption// interface and the //Cipher// object specified via //setKeyCipher()// is not //null//, //keyData// is decrypted using the //Cipher// object.// \\ **Parameters:**keyData - byte array containing key initialization data kOff - offset within keyData to start **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason code: \\ *CryptoException.ILLEGAL_VALUE if input data decryption is required and fails. \\ [[javacard:java-card-api:ArrayIndexOutOfBoundsException|ArrayIndexOutOfBoundsException]] - if kOff is negative or the keyData array is too short. [[javacard:java-card-api:NullPointerException|NullPointerException]] - if the keyData parameter is null. ---- === getKey === byte **getKey**(byte[] keyData, short kOff) throws [[javacard:java-card-api:CryptoException|CryptoException]] Returns the Key data in plain text. The length of output key data is 16/24/32 bytes. The data format is big-endian and right-aligned (the least significant bit is the least significant bit of last byte). **Parameters:**keyData - byte array to return key data kOff - offset within keyData to start **Returns:**the byte length of the key data returned **Throws:** [[javacard:java-card-api:CryptoException|CryptoException]] - with the following reason code: \\ *CryptoException.UNINITIALIZED_KEY if the key data has not been successfully initialized since the time the initialized state of the key was set to false. \\ **See Also:**[[javacard:java-card-api:Key|Key]]