public class AESSymmetricKey extends java.lang.Object implements ISymEncryptionKey
HMACSymmetricKey
.Modifier and Type | Field and Description |
---|---|
static int |
STANDARD_AES_KEY_AND_BLOCK_SIZE
Standard key size is 128 bits.
|
TIMESTAMP_MANUAL, TIMESTAMP_MISSING
Constructor and Description |
---|
AESSymmetricKey(byte[] key,
long timestamp)
Creates a new AES key that can be used for encryption or decryption
|
AESSymmetricKey(byte[] key,
long timestamp,
SystemID systemID)
Creates a new AES key that can be used for encryption or decryption
|
Modifier and Type | Method and Description |
---|---|
static void |
checkAESKey(byte[] key)
Checks if the key supplied could be used as a valid AES key (ie. it conforms to the key sizes)
|
byte[] |
createSignature(byte[] message)
Since this key is not for signing, a runtime exception will be thrown.
|
byte[] |
decryptMessage(byte[] message)
Decrypts an encrypted message (with this private key).
|
byte[] |
encryptMessage(byte[] input)
Encrypts a message with this public key.
|
boolean |
forEncryption()
This key can be used for encryption and decryption, so this method will return true.
|
boolean |
forSigning()
This key cannot be used for signing, so this method will return false.
|
SystemID |
getCorrespondingSystemID() |
byte[] |
getKey()
Get the key as a byte array.
|
long |
getTimestamp()
Returns the time stamp of a symmetric key or TIMESTAMP_MISSING,
if there is no entry for the key.
|
boolean |
verifySignature(byte[] message,
byte[] signature)
Since this key is not for signing, a runtime exception will be thrown.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals
equals
public static final int STANDARD_AES_KEY_AND_BLOCK_SIZE
public AESSymmetricKey(byte[] key, long timestamp, SystemID systemID) throws java.lang.IllegalArgumentException
key
- A secret key as byte array, only keys of the size described in keySizes
are allowedjava.lang.IllegalArgumentException
- If the key does not conform to the specified key sizes, this exception is thrownpublic AESSymmetricKey(byte[] key, long timestamp) throws java.lang.IllegalArgumentException
key
- A secret key as byte array, only keys of the size described in keySizes
are allowedjava.lang.IllegalArgumentException
- If the key does not conform to the specified key sizes, this exception is thrownpublic static void checkAESKey(byte[] key) throws java.lang.IllegalArgumentException
key
- The key that should be checked as byte arrayjava.lang.IllegalArgumentException
- If the key is not a valid AES keypublic boolean forEncryption()
forEncryption
in interface ISymmetricKey
public boolean forSigning()
forSigning
in interface ISymmetricKey
public byte[] encryptMessage(byte[] input) throws java.io.IOException
encryptMessage
in interface IPublicKey
input
- The message which should be encryptedjava.io.IOException
- If not enough memory is available or if a key could not be read, this exception occurspublic boolean verifySignature(byte[] message, byte[] signature)
verifySignature
in interface IPublicKey
message
- A runtime exception will be thrown.signature
- A runtime exception will be thrown.public byte[] createSignature(byte[] message)
createSignature
in interface IPrivateKey
message
- A runtime exception will be thrown.public byte[] decryptMessage(byte[] message) throws java.lang.IndexOutOfBoundsException
decryptMessage
in interface IPrivateKey
message
- The encrypted message, which should be decryptedjava.lang.IndexOutOfBoundsException
public long getTimestamp()
ISymmetricKey
getTimestamp
in interface ISymmetricKey
public byte[] getKey()
ISymmetricKey
getKey
in interface ISymmetricKey
public SystemID getCorrespondingSystemID()
getCorrespondingSystemID
in interface ISymmetricKey