public class SymmetricKey extends Key implements Serializable
Modifier and Type | Field and Description |
---|---|
protected byte[] |
key |
static long |
serialVersionUID |
CRLF
Constructor and Description |
---|
SymmetricKey() |
SymmetricKey(Algorithm sk) |
SymmetricKey(Algorithm sk,
Padding pad,
Mode mode)
Creates a new symmetric key according to spec.
|
SymmetricKey(byte[] sk) |
SymmetricKey(byte[] sk,
AsymmetricKey deckey)
creates a new symmetric key from the given PKCS#1 blob.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decrypt(byte[] b) |
String |
dumpValueNotation(String prefix,
DumpType dumpType) |
byte[] |
encrypt(byte[] b) |
boolean |
equals(Object t) |
Algorithm |
getAlgorithm() |
byte[] |
getIv() |
byte[] |
getKey() |
int |
getKeySize()
Gets the key size from the key generation parameters.
|
Mode |
getMode() |
Padding |
getPadding() |
AlgorithmParameter |
getParameter() |
int |
hashCode() |
protected void |
parse(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.ASN1Object |
toAsn1Object(DumpType dumpType)
Dumps an ASN.1 representation of the object.
|
String |
toString()
Gets a textual representation of the objects parameters (without the keys).
|
fromBase64, fromHex, parse, prepareDump, toBase64, toBitString, toBytes, toDer, toHex
public static final long serialVersionUID
protected byte[] key
public SymmetricKey() throws IOException
IOException
public SymmetricKey(Algorithm sk) throws IOException
IOException
public SymmetricKey(Algorithm sk, Padding pad, Mode mode) throws IOException
Creates a new symmetric key according to spec.
sk
- the algrithm of the symmetric keypad
- the default padding of the symmetric keymode
- the default mode of the symmetric keyIOException
- if the algorithm is not known to the subsystempublic SymmetricKey(byte[] sk) throws IOException
IOException
public SymmetricKey(byte[] sk, AsymmetricKey deckey) throws IOException
creates a new symmetric key from the given PKCS#1 blob.
sk
- a binary PKCS#1 representation of the key to be constructeddeckey
- the decryption keyIOException
- if failing to decrypt the symmetric keypublic byte[] setIv(byte[] b)
Sets a initialisation vector to be used by the keys default padding.
b
- the initialisation vectorpublic byte[] getIv()
public AlgorithmParameter getParameter()
public Padding getPadding()
public int getKeySize()
Gets the key size from the key generation parameters.
public Mode getMode()
public Algorithm getAlgorithm()
public byte[] encrypt(byte[] b) throws IOException
encrypt
in class Key
IOException
public byte[] decrypt(byte[] b) throws IOException
decrypt
in class Key
IOException
protected final void parse(org.bouncycastle.asn1.ASN1Encodable to) throws IOException
parse
in class AbstractBlock
IOException
public byte[] getKey()
public byte[] setKey(byte[] b)
Directly replaces the keys binary representation.
b
- the binary representation of the symmetric keypublic 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)
dumpValueNotation
in interface Block
Copyright © 2023. All rights reserved.