public class EncryptedData
extends java.lang.Object
implements org.apache.directory.api.asn1.Asn1Object
EncryptedData ::= SEQUENCE {
etype [0] Int32 -- EncryptionType --,
kvno [1] UInt32 OPTIONAL,
cipher [2] OCTET STRING -- ciphertext
}
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
cipher
The field containing the enciphered text
|
private int |
cipherTagLength |
private int |
encryptedDataSeqLength |
private EncryptionType |
eType
The used encryption algorithm
|
private int |
eTypeTagLength |
static boolean |
HAS_KVNO
A constant used when the key is not present
|
private boolean |
hasKvno
A flag used to tell if a kvno has been added, as the kvno is optional.
|
private static boolean |
IS_DEBUG
Speedup for logs
|
private int |
kvno
Version number of the key under which data is encrypted
|
private int |
kvnoTagLength |
private static org.slf4j.Logger |
log
The logger
|
| Constructor and Description |
|---|
EncryptedData()
Creates a new instance of EncryptedData.
|
EncryptedData(EncryptionType eType,
byte[] cipher)
Creates a new instance of EncryptedData.
|
EncryptedData(EncryptionType eType,
int kvno,
byte[] cipher)
Creates a new instance of EncryptedData.
|
| Modifier and Type | Method and Description |
|---|---|
int |
computeLength()
Compute the EncryptedData length
|
java.nio.ByteBuffer |
encode(java.nio.ByteBuffer buffer)
Encode the EncryptedData message to a PDU.
|
boolean |
equals(java.lang.Object obj) |
byte[] |
getCipher()
Returns the raw cipher text.
|
EncryptionType |
getEType()
Returns the
EncryptionType. |
int |
getKvno()
Returns the key version.
|
int |
hashCode() |
boolean |
hasKvno()
Tells if there is a key version.
|
void |
setCipher(byte[] cipher)
Set the cipher text
|
void |
setEType(EncryptionType eType)
Set the EncryptionType
|
void |
setKvno(int kvno)
Set the key version
|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String tabs) |
private static final org.slf4j.Logger log
private static final boolean IS_DEBUG
private EncryptionType eType
private int kvno
private boolean hasKvno
private byte[] cipher
public static final boolean HAS_KVNO
private int eTypeTagLength
private int kvnoTagLength
private int cipherTagLength
private int encryptedDataSeqLength
public EncryptedData()
public EncryptedData(EncryptionType eType, int kvno, byte[] cipher)
eType - The encription algorithmkvno - The key versioncipher - the encrypted textpublic EncryptedData(EncryptionType eType, byte[] cipher)
eType - The encription algorithmcipher - the encrypted textpublic EncryptionType getEType()
EncryptionType.EncryptionType.public void setEType(EncryptionType eType)
eType - the EncryptionTypepublic int getKvno()
public void setKvno(int kvno)
kvno - The key versionpublic boolean hasKvno()
true if there is a key version.public byte[] getCipher()
public void setCipher(byte[] cipher)
cipher - The cipher textpublic int computeLength()
EncryptedData :
0x30 L1 EncryptedData sequence
|
+--> 0xA1 L2 etype tag
| |
| +--> 0x02 L2-1 etype (int)
|
+--> [0xA2 L3 kvno tag
| |
| +--> 0x30 L3-1 kvno (int)] (optional)
|
+--> 0xA2 L4 cipher tag
|
+--> 0x04 L4-1 cipher (OCTET STRING)
computeLength in interface org.apache.directory.api.asn1.Asn1Objectpublic java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
throws org.apache.directory.api.asn1.EncoderException
EncryptedData :
0x30 LL
0xA0 LL
0x02 0x01 etype (integer)
[0xA1 LL
0x02 0x01 kvno (integer)] (optional)
0xA2 LL
0x04 LL cipher (OCTET STRING)
encode in interface org.apache.directory.api.asn1.Asn1Objectbuffer - The buffer where to put the PDU. It should have been allocated
before, with the right size.org.apache.directory.api.asn1.EncoderExceptionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public java.lang.String toString(java.lang.String tabs)
Object.toString()