public class PrefixBlock extends AbstractBlock implements Serializable
ASN1 parser class for header reply.
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
CRLF
Constructor and Description |
---|
PrefixBlock()
Creates a prefix with a random symmetric key.
|
PrefixBlock(org.bouncycastle.asn1.ASN1Primitive to,
AsymmetricKey ak)
Creates a prefix by parsing to in plan (unencrypted).
|
PrefixBlock(byte[] to,
AsymmetricKey ak)
Creates a prefix from the provided byte array by decyphering it with the provided key.
|
PrefixBlock(SymmetricKey sk)
Creates a prefix with the given key.
|
Modifier and Type | Method and Description |
---|---|
String |
dumpValueNotation(String prefix,
DumpType dumpType) |
boolean |
equals(Object o) |
AsymmetricKey |
getDecryptionKey() |
SymmetricKey |
getKey() |
int |
hashCode() |
boolean |
isEncrypted()
get the encryption status of the prefix block.
|
protected void |
parse(org.bouncycastle.asn1.ASN1Encodable to) |
AsymmetricKey |
setDecryptionKey(AsymmetricKey dk)
Sets the decryption key for the prefix block.
|
SymmetricKey |
setKey(SymmetricKey dk)
Sets the symmetric key contained in the block.
|
org.bouncycastle.asn1.ASN1Object |
toAsn1Object(DumpType dumpType)
Dumps an ASN.1 representation of the object.
|
byte[] |
toEncBytes()
Get the ASN.1 encoded prefix block in encrypted form.
|
fromBase64, fromHex, parse, prepareDump, toBase64, toBitString, toBytes, toDer, toHex
public static final long serialVersionUID
public PrefixBlock() throws IOException
Creates a prefix with a random symmetric key.
IOException
- if key generation failspublic PrefixBlock(SymmetricKey sk) throws IOException
Creates a prefix with the given key.
sk
- symmetric key to embed in the prefix blockIOException
- if key generation failspublic PrefixBlock(org.bouncycastle.asn1.ASN1Primitive to, AsymmetricKey ak) throws IOException
Creates a prefix by parsing to in plan (unencrypted).
to
- The primitive to be parsedak
- the asymmetric key required to decrypt the blockIOException
- if parsing failspublic PrefixBlock(byte[] to, AsymmetricKey ak) throws IOException
Creates a prefix from the provided byte array by decyphering it with the provided key.
to
- the ASN1 OCTET STRING containing the encrypted prefixak
- the host keyIOException
- if parsing of the prefix block failsprotected final void parse(org.bouncycastle.asn1.ASN1Encodable to) throws IOException
parse
in class AbstractBlock
IOException
public final AsymmetricKey setDecryptionKey(AsymmetricKey dk) throws IOException
Sets the decryption key for the prefix block.
If the prefixblock is already encrypted a decryption is attempted.
dk
- the decryption key to be used when decrypting the blockIOException
- if decryption tailspublic final AsymmetricKey getDecryptionKey()
public SymmetricKey setKey(SymmetricKey dk)
Sets the symmetric key contained in the block.
dk
- the decryption key for all subsequent blockspublic SymmetricKey getKey()
public org.bouncycastle.asn1.ASN1Object toAsn1Object(DumpType dumpType) throws IOException
Dumpable
Dumps an ASN.1 representation of the object.
toAsn1Object
in interface Dumpable
dumpType
- the dump type to be usedIOException
- if dumping of the object fails due to an illegal internal state of the
objectpublic String dumpValueNotation(String prefix, DumpType dumpType) throws IOException
dumpValueNotation
in interface Block
IOException
public boolean isEncrypted()
get the encryption status of the prefix block.
public byte[] toEncBytes() throws IOException
Get the ASN.1 encoded prefix block in encrypted form.
IOException
- if encoding failsCopyright © 2023. All rights reserved.