Class SecureKeySpec
- All Implemented Interfaces:
Serializable, Loggeable
This class is not intended to use for key storage. It can contain confidentional data like key length. That is why they should not be kept persistently anywhere.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AlgorithmThe cryptographic algorithm with which the key contained in key block will be used.protected ExportabilityThe conditions under which the key can be exported outside the cryptographic domain.protected byte[]The key block MAC ensures the integrity of the key block, and is calculated over the Header, Optional Header Blocks and the encrypted Key Data.protected charIdentifies the method by which the key block is cryptographically protected and the content layout of the block.protected byte[]Secure Key Bytes.protected byte[]The keyCheckValue allows identifying which clear key does this secure key represent.protected intThe key length is expressed in bits and refers to clear key (before LMK protection).protected StringOptional key name.protected StringKey Type is useful for stating what this key can be used for.protected KeyUsageThe primary usage of the key contained in the key block.protected StringVersion number to optionally indicate that the contents of the key block is a component (key part), or to prevent re-injection of an old key.protected ModeOfUseThe operation that the key contained in the key block can perform.The TR-31 Key Block format allows a key block to contain up to 99 Optional Header Blocks which can be used to include additional (optional) data within the Key Block.protected StringThis element is not specified by TR-31 (should contain two ASCII zeros).protected KeySchemeKey scheme indicates protection metchod appiled to this key by a security module.protected intIndicates key protection variant metchod appiled to this key by a security module. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddump(PrintStream p, String indent) Dumps SecureKeySpec information.protected StringformKeyHeader(String indent) Renders the key-block header fields (version/usage/algorithm/etc.) as XML, indented fordump(PrintStream, String).The cryptographic algorithm with which the key contained in key block will be used.The conditions under which the key can be exported outside the cryptographic domain.byte[]The key block MAC ensures the integrity of the key block.charIdentifies the method by which the key block is cryptographically protected and the content layout of the block.byte[]Returns the secure (LMK-protected) key bytes.byte[]The Key Check Value is typically a 24-bits (3 bytes) formed by encrypting a block of zeros under the secure key when the secure key is clear.intGets the length of the key.Gets optional key name.Key Type is useful for stating what this key can be used for.The primary usage of the key contained in the key block.Version number to optionally indicate that the contents of the key block is a component (key part), or to prevent re-injection of an old key.The operation that the key contained in the key block can perform.The key blok Optional Header Blocks.This element is not specified by TR-31 (should contain two ASCII zeros).Gets the key scheme used to protect this key.intGets the key variant method used to protect this key.voidsetAlgorithm(Algorithm algorithm) Sets the cryptographic algorithm (byte 7 of the key block).voidsetExportability(Exportability exportability) Sets the exportability (byte 11 of the key block).voidsetKeyBlockMAC(byte[] keyBlockMAC) Sets the key block MAC.voidsetKeyBlockVersion(char keyBlockVersion) Sets the key-block version character (byte 0 of the key block).voidsetKeyBytes(byte[] keyBytes) Sets the secure key bytes.voidsetKeyCheckValue(byte[] keyCheckValue) The Key Check Value is typically a 24-bits (3 bytes) formed by encrypting a block of zeros under the secure key when the secure key is clear.voidsetKeyLength(int keyLength) Sets the length of the key.voidsetKeyName(String keyName) Sets optional key name.voidsetKeyType(String keyType) Key Type is useful for stating what this key can be used for.voidsetKeyUsage(KeyUsage keyUsage) Sets the primary key usage (bytes 5-6 of the key block).voidsetKeyVersion(String keyVersion) Sets the key version (bytes 9-10 of the key block).voidsetModeOfUse(ModeOfUse modeOfUse) Sets the mode of use (byte 8 of the key block).voidsetReserved(String reserved) Sets the reserved field (bytes 14-15 of the key block).voidKey scheme indicates protection metchod appiled to this key by the security module.voidsetVariant(int variant) Sets key protection variant metchod appiled to this key by the security module.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Loggeable
dumpModifier and TypeMethodDescriptiondefault voiddump(PrintStream p, String indent, LogRenderer.Type type) Dumps a representation of this object using the specified renderer type.
-
Field Details
-
scheme
-
keyLength
The key length is expressed in bits and refers to clear key (before LMK protection). -
keyType
Key Type is useful for stating what this key can be used for.The value of Key Type specifies whether this encryped key is a
SMAdapter.TYPE_TMKTerminal Master KeySMAdapter.TYPE_ZPKZone PIN Key- or others
-
variant
Indicates key protection variant metchod appiled to this key by a security module. -
keyBytes
Secure Key Bytes. -
keyCheckValue
The keyCheckValue allows identifying which clear key does this secure key represent. -
keyBlockVersion
Identifies the method by which the key block is cryptographically protected and the content layout of the block. -
keyUsage
-
algorithm
-
modeOfUse
-
keyVersion
Version number to optionally indicate that the contents of the key block is a component (key part), or to prevent re-injection of an old key. -
exportability
The conditions under which the key can be exported outside the cryptographic domain. -
reserved
-
optionalHeaders
The TR-31 Key Block format allows a key block to contain up to 99 Optional Header Blocks which can be used to include additional (optional) data within the Key Block. -
keyBlockMAC
The key block MAC ensures the integrity of the key block, and is calculated over the Header, Optional Header Blocks and the encrypted Key Data. -
keyName
-
-
Constructor Details
-
SecureKeySpec
public SecureKeySpec()Default constructor.
-
-
Method Details
-
setScheme
-
getScheme
-
setKeyLength
Sets the length of the key.The key length is expressed in bits and refers to clear key (before LMK protection) This might be different than the bit length of the secureKeyBytes.
- Parameters:
keyLength- clear key length in bits
-
getKeyLength
Gets the length of the key.The key length is expressed in bits and refers to clear key (before LMK protection)
- Returns:
- The length of the clear key
-
setKeyType
Key Type is useful for stating what this key can be used for.The value of Key Type specifies whether this secure key is a
SMAdapter.TYPE_TMKTerminal Master KeySMAdapter.TYPE_ZPKZone PIN Key- or others
- Parameters:
keyType- type of the key
-
getKeyType
Key Type is useful for stating what this key can be used for.The value of Key Type specifies whether this secure key is a
SMAdapter.TYPE_TMKTerminal Master KeySMAdapter.TYPE_ZPKZone PIN Key- or others
- Returns:
- keyType type of the key
-
setVariant
Sets key protection variant metchod appiled to this key by the security module.- Parameters:
variant- key variant method used to protect this key.
-
getVariant
Gets the key variant method used to protect this key.- Returns:
- key variant method used to protect this key.
-
getKeyBlockVersion
Identifies the method by which the key block is cryptographically protected and the content layout of the block.- Returns:
- The key block version that corresponds to byte 0 of the key block.
-
setKeyBlockVersion
Sets the key-block version character (byte 0 of the key block).- Parameters:
keyBlockVersion- the version character
-
getKeyUsage
The primary usage of the key contained in the key block.- Returns:
- The key usage that corresponds to bytes 5-6 of the key block.
-
setKeyUsage
Sets the primary key usage (bytes 5-6 of the key block).- Parameters:
keyUsage- the new key usage
-
getAlgorithm
The cryptographic algorithm with which the key contained in key block will be used.- Returns:
- The key algorithm that corresponds to byte 7 of the key block.
-
setAlgorithm
Sets the cryptographic algorithm (byte 7 of the key block).- Parameters:
algorithm- the new algorithm
-
getModeOfUse
The operation that the key contained in the key block can perform.- Returns:
- The mode of use that corresponds to byte 8 of the key block.
-
setModeOfUse
Sets the mode of use (byte 8 of the key block).- Parameters:
modeOfUse- the new mode of use
-
getKeyVersion
Version number to optionally indicate that the contents of the key block is a component (key part), or to prevent re-injection of an old key.- Returns:
- The key version that corresponds to bytes 9-10 of the key block.
-
setKeyVersion
Sets the key version (bytes 9-10 of the key block).- Parameters:
keyVersion- the new key version
-
getExportability
The conditions under which the key can be exported outside the cryptographic domain.- Returns:
- The key exportability that corresponds to byte 11 of the key block.
-
setExportability
Sets the exportability (byte 11 of the key block).- Parameters:
exportability- the new exportability flag
-
getReserved
This element is not specified by TR-31 (should contain two ASCII zeros).In proprietary derivatives can be used as e.g: LMK identifier.
- Returns:
- The reserved that corresponds to bytes 14-15 of the key block.
-
setReserved
Sets the reserved field (bytes 14-15 of the key block).- Parameters:
reserved- the new reserved value
-
getOptionalHeaders
The key blok Optional Header Blocks.The number of optional heders corresponds to bytes 12-13 of the key block.
The order of the elements in the map is preserved by
LinkedHashMap- Returns:
- map of Optional Key Blok Heders.
-
getKeyBlockMAC
The key block MAC ensures the integrity of the key block.It is calculated over the Header, Optional Header Blocks and the encrypted Key Data. The length of the MAC depends on the type of LMK key:
- 4 bytes for DES Key Block LMK
- 8 bytes for AES Key Block LMK
- Returns:
- calculated key block MAC value.
-
setKeyBlockMAC
Sets the key block MAC.- Parameters:
keyBlockMAC- the MAC bytes
-
setKeyBytes
Sets the secure key bytes.- Parameters:
keyBytes- bytes representing the secured key
-
getKeyBytes
Returns the secure (LMK-protected) key bytes.- Returns:
- The bytes representing the secured key
-
setKeyCheckValue
The Key Check Value is typically a 24-bits (3 bytes) formed by encrypting a block of zeros under the secure key when the secure key is clear.This check value allows identifying if two secure keys map to the same clear key.
- Parameters:
keyCheckValue- the Key Check Value
-
getKeyCheckValue
The Key Check Value is typically a 24-bits (3 bytes) formed by encrypting a block of zeros under the secure key when the secure key is clear.- Returns:
- the Key Check Value
-
getKeyName
-
setKeyName
Sets optional key name.- Parameters:
keyName- name of the key
-
dump
Dumps SecureKeySpec information. -
formKeyHeader
Renders the key-block header fields (version/usage/algorithm/etc.) as XML, indented fordump(PrintStream, String).- Parameters:
indent- indent prefix to apply to every emitted line- Returns:
- the rendered header XML, or
nullif no header fields are set
-