Package net.messagevortex.asn1
Class SymmetricKey
java.lang.Object
net.messagevortex.asn1.AbstractBlock
net.messagevortex.asn1.Key
net.messagevortex.asn1.SymmetricKey
- All Implemented Interfaces:
Serializable,Block,Dumpable
Represents a Symmetric Key in the ASN.1 structure
- See Also:
-
Field Summary
FieldsFields inherited from class net.messagevortex.asn1.AbstractBlock
CRLF -
Constructor Summary
ConstructorsConstructorDescriptionSymmetricKey(byte[] sk) SymmetricKey(byte[] sk, AsymmetricKey deckey) creates a new symmetric key from the given PKCS#1 blob.SymmetricKey(Algorithm sk, Padding pad, Mode mode) Creates a new symmetric key according to spec. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]decrypt(byte[] b) dumpValueNotation(String prefix, DumpType dumpType) byte[]encrypt(byte[] b) booleanbyte[]getIv()byte[]getKey()intGets the key size from the key generation parameters.getMode()inthashCode()protected final voidparse(org.bouncycastle.asn1.ASN1Encodable to) byte[]setIv(byte[] b) Sets a initialisation vector to be used by the keys default padding.byte[]setKey(byte[] b) Directly replaces the keys binary representation.org.bouncycastle.asn1.ASN1ObjecttoAsn1Object(DumpType dumpType) Dumps an ASN.1 representation of the object.toString()Gets a textual representation of the objects parameters (without the keys).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:
-
key
protected byte[] key
-
-
Constructor Details
-
SymmetricKey
- Throws:
IOException
-
SymmetricKey
- Throws:
IOException
-
SymmetricKey
Creates a new symmetric key according to spec.
- Parameters:
sk- the algrithm of the symmetric keypad- the default padding of the symmetric keymode- the default mode of the symmetric key- Throws:
IOException- if the algorithm is not known to the subsystem
-
SymmetricKey
- Throws:
IOException
-
SymmetricKey
creates a new symmetric key from the given PKCS#1 blob.
- Parameters:
sk- a binary PKCS#1 representation of the key to be constructeddeckey- the decryption key- Throws:
IOException- if failing to decrypt the symmetric key
-
-
Method Details
-
setIv
public byte[] setIv(byte[] b) Sets a initialisation vector to be used by the keys default padding.
- Parameters:
b- the initialisation vector- Returns:
- the previously set initialisation vector
-
getIv
public byte[] getIv() -
getParameter
-
getPadding
-
getKeySize
public int getKeySize()Gets the key size from the key generation parameters.
- Returns:
- the key size in bits or -1 if there is no key size set
-
getMode
-
getAlgorithm
-
encrypt
- Specified by:
encryptin classKey- Throws:
IOException
-
decrypt
- Specified by:
decryptin classKey- Throws:
IOException
-
parse
- Specified by:
parsein classAbstractBlock- Throws:
IOException
-
getKey
public byte[] getKey() -
setKey
public byte[] setKey(byte[] b) Directly replaces the keys binary representation.
- Parameters:
b- the binary representation of the symmetric key- Returns:
- the previously set key
-
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
-
equals
-
hashCode
public int hashCode() -
dumpValueNotation
- Specified by:
dumpValueNotationin interfaceBlock
-
toString
Gets a textual representation of the objects parameters (without the keys).
-