Package net.messagevortex.asn1
Class PrefixBlock
java.lang.Object
net.messagevortex.asn1.AbstractBlock
net.messagevortex.asn1.PrefixBlock
- All Implemented Interfaces:
Serializable,Block,Dumpable
ASN1 parser class for header reply.
- See Also:
-
Field Summary
FieldsFields inherited from class net.messagevortex.asn1.AbstractBlock
CRLF -
Constructor Summary
ConstructorsConstructorDescriptionCreates a prefix with a random symmetric key.PrefixBlock(byte[] to, AsymmetricKey ak) Creates a prefix from the provided byte array by decyphering it with the provided key.Creates a prefix with the given key.PrefixBlock(org.bouncycastle.asn1.ASN1Primitive to, AsymmetricKey ak) Creates a prefix by parsing to in plan (unencrypted). -
Method Summary
Modifier and TypeMethodDescriptiondumpValueNotation(String prefix, DumpType dumpType) booleanfinal AsymmetricKeygetKey()inthashCode()booleanget the encryption status of the prefix block.protected final voidparse(org.bouncycastle.asn1.ASN1Encodable to) final AsymmetricKeySets the decryption key for the prefix block.setKey(SymmetricKey dk) Sets the symmetric key contained in the block.org.bouncycastle.asn1.ASN1ObjecttoAsn1Object(DumpType dumpType) Dumps an ASN.1 representation of the object.byte[]Get the ASN.1 encoded prefix block in encrypted form.Methods inherited from class net.messagevortex.asn1.AbstractBlock
fromBase64, fromHex, parse, prepareDump, toBase64, toBitString, toBytes, toDer, toHex
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
-
Constructor Details
-
PrefixBlock
Creates a prefix with a random symmetric key.
- Throws:
IOException- if key generation fails
-
PrefixBlock
Creates a prefix with the given key.
- Parameters:
sk- symmetric key to embed in the prefix block- Throws:
IOException- if key generation fails
-
PrefixBlock
Creates a prefix by parsing to in plan (unencrypted).
- Parameters:
to- The primitive to be parsedak- the asymmetric key required to decrypt the block- Throws:
IOException- if parsing fails
-
PrefixBlock
Creates a prefix from the provided byte array by decyphering it with the provided key.
- Parameters:
to- the ASN1 OCTET STRING containing the encrypted prefixak- the host key- Throws:
IOException- if parsing of the prefix block fails
-
-
Method Details
-
parse
- Specified by:
parsein classAbstractBlock- Throws:
IOException
-
setDecryptionKey
Sets the decryption key for the prefix block.
If the prefixblock is already encrypted a decryption is attempted.
- Parameters:
dk- the decryption key to be used when decrypting the block- Returns:
- the previous decryption key
- Throws:
IOException- if decryption tails
-
getDecryptionKey
-
setKey
Sets the symmetric key contained in the block.
- Parameters:
dk- the decryption key for all subsequent blocks- Returns:
- the key set before the change
-
getKey
-
toAsn1Object
Description copied from interface:DumpableDumps an ASN.1 representation of the object.
- Specified by:
toAsn1Objectin interfaceDumpable- Parameters:
dumpType- the dump type to be used- Returns:
- the ASN.1 string representation of the object
- Throws:
IOException- if dumping of the object fails due to an illegal internal state of the object
-
dumpValueNotation
- Specified by:
dumpValueNotationin interfaceBlock- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
isEncrypted
public boolean isEncrypted()get the encryption status of the prefix block.
- Returns:
- true if the block is encrypted
-
toEncBytes
Get the ASN.1 encoded prefix block in encrypted form.
- Returns:
- the encrypted ASN.1 rncoded block
- Throws:
IOException- if encoding fails
-