Package javacard.security
Interface SM4Key
-
public interface SM4Key extends SecretKey
SM4Key
contains a 128-bit key for SM4 computations.When the key data is set, the key is initialized and ready for use.
- Since:
- 3.1
- See Also:
KeyBuilder
,Signature
,Cipher
,KeyEncryption
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description byte
getKey(byte[] keyData, short kOff)
Returns theKey
data in plain text.void
setKey(byte[] keyData, short kOff)
Sets theKey
data.-
Methods inherited from interface javacard.security.Key
clearKey, getSize, getType, isInitialized
-
-
-
-
Method Detail
-
setKey
void setKey(byte[] keyData, short kOff) throws CryptoException, NullPointerException, ArrayIndexOutOfBoundsException
Sets theKey
data. The plain text length of input key data is 16 bytes. Input key data is copied into the internal representation.Note:
- If the key object implements the
javacardx.crypto.KeyEncryption
interface and theCipher
object specified viasetKeyCipher()
is notnull
,keyData
is decrypted using theCipher
object.
- Parameters:
keyData
- byte array containing key initialization datakOff
- offset within keyData to start- Throws:
CryptoException
- with the following reason code:CryptoException.ILLEGAL_VALUE
if input data decryption is required and fails.
ArrayIndexOutOfBoundsException
- ifkOff
is negative or thekeyData
array is too shortNullPointerException
- if thekeyData
parameter isnull
- If the key object implements the
-
getKey
byte getKey(byte[] keyData, short kOff)
Returns theKey
data in plain text. The length of output key data is 16 bytes.- Parameters:
keyData
- byte array to return key datakOff
- offset withinkeyData
to start- Returns:
- the byte length of the key data returned
- Throws:
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:
Key
-
-