Package org.bouncycastle.crypto
Class SymmetricSecretKey
- java.lang.Object
-
- org.bouncycastle.crypto.SymmetricSecretKey
-
- All Implemented Interfaces:
javax.security.auth.Destroyable
,Key
,SymmetricKey
public final class SymmetricSecretKey extends java.lang.Object implements SymmetricKey, javax.security.auth.Destroyable
Basic class describing a secret key implementation. The key will be zeroized explicitly on garbage collection and is protected from being shared between approved an un-approved threads.Note: it the module is run under the SecurityManager only invokers with CryptoServicesPermission.FIPS_MODE_EXPORT_SECRET_KEY permission can successfully call the getKeyBytes() method.
-
-
Constructor Summary
Constructors Constructor Description SymmetricSecretKey(Algorithm algorithm, byte[] bytes)
Base constructor.SymmetricSecretKey(Parameters parameterSet, byte[] bytes)
Base constructor for a specific algorithm associated with a parameter set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
boolean
equals(java.lang.Object o)
Return true if o is an equivalent key to this.Algorithm
getAlgorithm()
Return the algorithm this secret key is for.byte[]
getKeyBytes()
Return the bytes representing this keys value.int
hashCode()
Return the hashCode for the key.boolean
isDestroyed()
-
-
-
Constructor Detail
-
SymmetricSecretKey
public SymmetricSecretKey(Algorithm algorithm, byte[] bytes)
Base constructor.- Parameters:
algorithm
- the algorithm this secret key is associated with.bytes
- the bytes representing the key's value.
-
SymmetricSecretKey
public SymmetricSecretKey(Parameters parameterSet, byte[] bytes)
Base constructor for a specific algorithm associated with a parameter set.- Parameters:
parameterSet
- the parameter set with the algorithm this secret key is associated with.bytes
- the bytes representing the key's value.
-
-
Method Detail
-
getAlgorithm
public Algorithm getAlgorithm()
Return the algorithm this secret key is for.- Specified by:
getAlgorithm
in interfaceKey
- Returns:
- the secret keys algorithm.
-
getKeyBytes
public byte[] getKeyBytes()
Return the bytes representing this keys value. See CryptoServicesPermission.FIPS_MODE_EXPORT_SECRET_KEY for the permission associated with this method.- Specified by:
getKeyBytes
in interfaceSymmetricKey
- Returns:
- the bytes making up this key.
-
equals
public boolean equals(java.lang.Object o)
Description copied from interface:Key
Return true if o is an equivalent key to this.
-
hashCode
public int hashCode()
Description copied from interface:Key
Return the hashCode for the key.
-
destroy
public void destroy() throws javax.security.auth.DestroyFailedException
- Specified by:
destroy
in interfacejavax.security.auth.Destroyable
- Throws:
javax.security.auth.DestroyFailedException
-
isDestroyed
public boolean isDestroyed()
- Specified by:
isDestroyed
in interfacejavax.security.auth.Destroyable
-
-