public interface HMACKey extends SecretKey
HMACKey
contains a key for HMAC operations. This key can be of
any length, but it is strongly recommended that the key is not shorter than
the byte length of the hash output used in the HMAC implementation. Keys with
length greater than the hash block length are first hashed with the hash
algorithm used for the HMAC implementation.
Implementations must support an HMAC key length equal to the length of the supported hash algorithm block size (e.g 64 bytes for SHA-1)
When the key data is set, the key is initialized and ready for use.
KeyBuilder
,
Signature
,
javacardx.crypto.Cipher
,
javacardx.crypto.KeyEncryption
Modifier and Type | Method and Description |
---|---|
byte |
getKey(byte[] keyData,
short kOff)
Returns the
Key data in plain text. |
void |
setKey(byte[] keyData,
short kOff,
short kLen)
Sets the
Key data. |
clearKey, getSize, getType, isInitialized
void setKey(byte[] keyData, short kOff, short kLen) throws CryptoException, NullPointerException, ArrayIndexOutOfBoundsException
Key
data. 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:
javacardx.crypto.KeyEncryption
interface and the Cipher
object specified via setKeyCipher()
is not null
, keyData
is decrypted using the Cipher
object.
keyData
- byte array containing key initialization datakOff
- offset within keyData to startkLen
- the byte length of the key initialization dataCryptoException
- with the following reason code:
CryptoException.ILLEGAL_VALUE
if the
kLen
parameter is 0 or invalid or if the
keyData
parameter is inconsistent with the key length
or if input data decryption is required and fails.
ArrayIndexOutOfBoundsException
- if kOff
is negative or the
keyData
array is too shortNullPointerException
- if the keyData
parameter is
null
byte getKey(byte[] keyData, short kOff)
Key
data in plain text. The key can be any
length, but should be longer than the byte length of the hash algorithm
output used. The data format is big-endian and right-aligned (the least
significant bit is the least significant bit of last byte).
Note:
keyData
buffer if
it fits.
Please use the getSize()
method to obtain the actual key
length in bits.
keyData
- byte array to return key datakOff
- offset within keyData
to startCryptoException
- 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.
Key
Copyright © 1998, 2015, Oracle and/or its affiliates. All rights reserved.