CiphertextHeaderV2
@Deprecated public class CiphertextHeader extends Object
Data format:
+-----+----------+-------+------------+---------+ | Len | NonceLen | Nonce | KeyNameLen | KeyName | +-----+----------+-------+------------+---------+
Where fields are defined as follows:
The last two fields are optional and provide support for multiple keys at the encryption provider. A common case for multiple keys is key rotation; by tagging encrypted data with a key name, an old key may be retrieved by name to decrypt outstanding data which will be subsequently re-encrypted with a new key.
Modifier and Type | Field and Description |
---|---|
protected String |
keyName
Deprecated.
Header key name field value.
|
protected int |
length
Deprecated.
Header length in bytes.
|
protected static int |
MAX_KEYNAME_LEN
Deprecated.
Maximum key name length in bytes.
|
protected static int |
MAX_NONCE_LEN
Deprecated.
Maximum nonce length in bytes.
|
protected byte[] |
nonce
Deprecated.
Header nonce field value.
|
Constructor and Description |
---|
CiphertextHeader(byte[] nonce)
Deprecated.
Creates a new instance with only a nonce.
|
CiphertextHeader(byte[] nonce,
String keyName)
Deprecated.
Creates a new instance with a nonce and named key.
|
Modifier and Type | Method and Description |
---|---|
protected int |
computeLength()
Deprecated.
|
static CiphertextHeader |
decode(byte[] data)
Deprecated.
Creates a header from encrypted data containing a cleartext header prepended to the start.
|
static CiphertextHeader |
decode(InputStream input)
Deprecated.
Creates a header from encrypted data containing a cleartext header prepended to the start.
|
byte[] |
encode()
Deprecated.
Encodes the header into bytes.
|
String |
getKeyName()
Deprecated.
Gets the encryption key name stored in the header.
|
int |
getLength()
Deprecated.
Gets the header length in bytes.
|
byte[] |
getNonce()
Deprecated.
Gets the bytes of the nonce/IV.
|
protected static final int MAX_NONCE_LEN
protected static final int MAX_KEYNAME_LEN
protected final byte[] nonce
protected String keyName
protected int length
public CiphertextHeader(byte[] nonce)
nonce
- Nonce bytes.public CiphertextHeader(byte[] nonce, String keyName)
nonce
- Nonce bytes.keyName
- Key name.public int getLength()
public byte[] getNonce()
public String getKeyName()
public byte[] encode()
protected int computeLength()
public static CiphertextHeader decode(byte[] data) throws EncodingException
data
- Encrypted data with prepended header data.EncodingException
- when ciphertext header cannot be decoded.public static CiphertextHeader decode(InputStream input) throws EncodingException, StreamException
input
- Input stream that is positioned at the start of ciphertext header data.EncodingException
- when ciphertext header cannot be decoded.StreamException
- on stream IO errors.Copyright © 2003-2024 Virginia Tech. All Rights Reserved.