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) 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[]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) voidsetExportability(Exportability exportability) voidsetKeyBlockMAC(byte[] keyBlockMAC) voidsetKeyBlockVersion(char keyBlockVersion) 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) voidsetKeyVersion(String keyVersion) voidsetModeOfUse(ModeOfUse modeOfUse) voidsetReserved(String reserved) 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.
-
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()
-
-
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-
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
setKeyBytes
Sets the secure key bytes.- Parameters:
keyBytes- bytes representing the secured key
-
getKeyBytes
- 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
-