public class SecureKeySpec extends java.lang.Object implements java.io.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.
Modifier and Type | Field and Description |
---|---|
protected Algorithm |
algorithm
The cryptographic algorithm with which the key contained in key block
will be used.
|
protected Exportability |
exportability
The conditions under which the key can be exported outside the
cryptographic domain.
|
protected byte[] |
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.
|
protected char |
keyBlockVersion
Identifies the method by which the key block is cryptographically
protected and the content layout of the block.
|
protected byte[] |
keyBytes
Secure Key Bytes.
|
protected byte[] |
keyCheckValue
The keyCheckValue allows identifying which clear key does this
secure key represent.
|
protected int |
keyLength
The key length is expressed in bits and refers to clear key (before
LMK protection).
|
protected java.lang.String |
keyName
Optional key name.
|
protected java.lang.String |
keyType
Key Type is useful for stating what this key can be used for.
|
protected KeyUsage |
keyUsage
The primary usage of the key contained in the key block.
|
protected java.lang.String |
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.
|
protected ModeOfUse |
modeOfUse
The operation that the key contained in the key block can perform.
|
protected java.util.Map<java.lang.String,java.lang.String> |
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.
|
protected java.lang.String |
reserved
This element is not specified by TR-31 (should contain two ASCII zeros).
|
protected KeyScheme |
scheme
Key scheme indicates protection metchod appiled to this key by
a security module.
|
protected int |
variant
Indicates key protection variant metchod appiled to this key by a security module.
|
Constructor and Description |
---|
SecureKeySpec() |
Modifier and Type | Method and Description |
---|---|
void |
dump(java.io.PrintStream p,
java.lang.String indent)
Dumps SecureKeySpec information.
|
protected java.lang.String |
formKeyHeader(java.lang.String indent) |
Algorithm |
getAlgorithm()
The cryptographic algorithm with which the key contained in key block
will be used.
|
Exportability |
getExportability()
The conditions under which the key can be exported outside the
cryptographic domain.
|
byte[] |
getKeyBlockMAC()
The key block MAC ensures the integrity of the key block.
|
char |
getKeyBlockVersion()
Identifies the method by which the key block is cryptographically
protected and the content layout of the block.
|
byte[] |
getKeyBytes() |
byte[] |
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.
|
int |
getKeyLength()
Gets the length of the key.
|
java.lang.String |
getKeyName()
Gets optional key name.
|
java.lang.String |
getKeyType()
Key Type is useful for stating what this key can be used for.
|
KeyUsage |
getKeyUsage()
The primary usage of the key contained in the key block.
|
java.lang.String |
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.
|
ModeOfUse |
getModeOfUse()
The operation that the key contained in the key block can perform.
|
java.util.Map<java.lang.String,java.lang.String> |
getOptionalHeaders()
The key blok Optional Header Blocks.
|
java.lang.String |
getReserved()
This element is not specified by TR-31 (should contain two ASCII zeros).
|
KeyScheme |
getScheme()
Gets the key scheme used to protect this key.
|
int |
getVariant()
Gets the key variant method used to protect this key.
|
void |
setAlgorithm(Algorithm algorithm) |
void |
setExportability(Exportability exportability) |
void |
setKeyBlockMAC(byte[] keyBlockMAC) |
void |
setKeyBlockVersion(char keyBlockVersion) |
void |
setKeyBytes(byte[] keyBytes)
Sets the secure key bytes.
|
void |
setKeyCheckValue(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.
|
void |
setKeyLength(int keyLength)
Sets the length of the key.
|
void |
setKeyName(java.lang.String keyName)
Sets optional key name.
|
void |
setKeyType(java.lang.String keyType)
Key Type is useful for stating what this key can be used for.
|
void |
setKeyUsage(KeyUsage keyUsage) |
void |
setKeyVersion(java.lang.String keyVersion) |
void |
setModeOfUse(ModeOfUse modeOfUse) |
void |
setReserved(java.lang.String reserved) |
void |
setScheme(KeyScheme scheme)
Key scheme indicates protection metchod appiled to this key by
the security module.
|
void |
setVariant(int variant)
Sets key protection variant metchod appiled to this key by the security module.
|
protected KeyScheme scheme
protected int keyLength
protected java.lang.String keyType
The value of Key Type specifies whether this encryped key is a
SMAdapter.TYPE_TMK
Terminal Master Key
SMAdapter.TYPE_ZPK
Zone PIN Key
protected int variant
protected byte[] keyBytes
protected byte[] keyCheckValue
protected char keyBlockVersion
protected KeyUsage keyUsage
protected Algorithm algorithm
protected ModeOfUse modeOfUse
protected java.lang.String keyVersion
protected Exportability exportability
protected java.lang.String reserved
In proprietary derivatives can be used as e.g: LMK identifier.
protected final java.util.Map<java.lang.String,java.lang.String> optionalHeaders
protected byte[] keyBlockMAC
protected java.lang.String keyName
public void setScheme(KeyScheme scheme)
scheme
- key scheme used to protect this key.public KeyScheme getScheme()
public void setKeyLength(int keyLength)
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.
keyLength
- public int getKeyLength()
The key length is expressed in bits and refers to clear key (before LMK protection)
public void setKeyType(java.lang.String keyType)
The value of Key Type specifies whether this secure key is a
SMAdapter.TYPE_TMK
Terminal Master Key
SMAdapter.TYPE_ZPK
Zone PIN Key
keyType
- type of the keypublic java.lang.String getKeyType()
The value of Key Type specifies whether this secure key is a
SMAdapter.TYPE_TMK
Terminal Master Key
SMAdapter.TYPE_ZPK
Zone PIN Key
public void setVariant(int variant)
variant
- key variant method used to protect this key.public int getVariant()
public char getKeyBlockVersion()
public void setKeyBlockVersion(char keyBlockVersion)
public KeyUsage getKeyUsage()
public void setKeyUsage(KeyUsage keyUsage)
public Algorithm getAlgorithm()
public void setAlgorithm(Algorithm algorithm)
public ModeOfUse getModeOfUse()
public void setModeOfUse(ModeOfUse modeOfUse)
public java.lang.String getKeyVersion()
public void setKeyVersion(java.lang.String keyVersion)
public Exportability getExportability()
public void setExportability(Exportability exportability)
public java.lang.String getReserved()
In proprietary derivatives can be used as e.g: LMK identifier.
public void setReserved(java.lang.String reserved)
public java.util.Map<java.lang.String,java.lang.String> getOptionalHeaders()
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
public byte[] getKeyBlockMAC()
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:
public void setKeyBlockMAC(byte[] keyBlockMAC)
public void setKeyBytes(byte[] keyBytes)
keyBytes
- bytes representing the secured keypublic byte[] getKeyBytes()
public void setKeyCheckValue(byte[] keyCheckValue)
This check value allows identifying if two secure keys map to the same clear key.
keyCheckValue
- the Key Check Valuepublic byte[] getKeyCheckValue()
public java.lang.String getKeyName()
public void setKeyName(java.lang.String keyName)
keyName
- name of the keypublic void dump(java.io.PrintStream p, java.lang.String indent)
protected java.lang.String formKeyHeader(java.lang.String indent)