Top Description Fields Constructors Methods
org.bouncycastle.crypto

public final Class SymmetricSecretKey

extends Object
implements SymmetricKey, Destroyable
Class Inheritance
All Implemented Interfaces
javax.security.auth.Destroyable, org.bouncycastle.crypto.SymmetricKey, org.bouncycastle.crypto.Key
Imports
java.util.concurrent.atomic.AtomicBoolean, javax.security.auth.DestroyFailedException, .Destroyable, org.bouncycastle.crypto.fips.FipsOperationError, org.bouncycastle.crypto.internal.Permissions, org.bouncycastle.util.Arrays

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.

Field Summary

Modifier and TypeField and Description
private Algorithm
private final boolean
private byte[]
private final AtomicBoolean
private int

Constructor Summary

AccessConstructor and Description
public
SymmetricSecretKey(Algorithm
the algorithm this secret key is associated with.
algorithm
,
byte[]
the bytes representing the key's value.
bytes
)

Base constructor.

public
SymmetricSecretKey(Parameters
the parameter set with the algorithm this secret key is associated with.
parameterSet
,
byte[]
the bytes representing the key's value.
bytes
)

Base constructor for a specific algorithm associated with a parameter set.

Method Summary

Modifier and TypeMethod and Description
private int
pack-priv final void
private void
public void
destroy()

Overrides default javax.security.auth.Destroyable.destroy.

Destroy this Object.
public boolean
equals(Object
object to compare to.
o
)

Overrides java.lang.Object.equals.

Implements org.bouncycastle.crypto.Key.equals.

Return true if o is an equivalent key to this.
public Algorithm

Returns:

the secret keys algorithm.
getAlgorithm
()

Implements org.bouncycastle.crypto.Key.getAlgorithm.

Return the algorithm this secret key is for.
public byte[]

Returns:

the bytes making up this key.
getKeyBytes
()

Implements org.bouncycastle.crypto.SymmetricKey.getKeyBytes.

Return the bytes representing this keys value.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements org.bouncycastle.crypto.Key.hashCode.

Return the hashCode for the key.
public boolean
isDestroyed()

Overrides default javax.security.auth.Destroyable.isDestroyed.

Determine if this Object has been destroyed.
private void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

algorithmback to summary
private Algorithm algorithm
approvedModeOnlyback to summary
private final boolean approvedModeOnly
bytesback to summary
private byte[] bytes
hasBeenDestroyedback to summary
private final AtomicBoolean hasBeenDestroyed
hashCodeback to summary
private int hashCode

Constructor Detail

SymmetricSecretKeyback to summary
public SymmetricSecretKey(Algorithm algorithm, byte[] bytes)

Base constructor.

Parameters
algorithm:Algorithm

the algorithm this secret key is associated with.

bytes:byte[]

the bytes representing the key's value.

SymmetricSecretKeyback to summary
public SymmetricSecretKey(Parameters parameterSet, byte[] bytes)

Base constructor for a specific algorithm associated with a parameter set.

Parameters
parameterSet:Parameters

the parameter set with the algorithm this secret key is associated with.

bytes:byte[]

the bytes representing the key's value.

Method Detail

calculateHashCodeback to summary
private int calculateHashCode()
checkApprovedOnlyModeStatusback to summary
pack-priv final void checkApprovedOnlyModeStatus()
checkDestroyedback to summary
private void checkDestroyed()
destroyback to summary
public void destroy() throws DestroyFailedException

Overrides default javax.security.auth.Destroyable.destroy.

Doc from javax.security.auth.Destroyable.destroy.

Destroy this Object.

Sensitive information associated with this Object is destroyed or cleared. Subsequent calls to certain methods on this Object will result in an IllegalStateException being thrown.

Exceptions
DestroyFailedException:
if the destroy operation fails.
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements org.bouncycastle.crypto.Key.equals.

Doc from org.bouncycastle.crypto.Key.equals.

Return true if o is an equivalent key to this.

Parameters
o:Object

object to compare to.

Returns:boolean

true if o is the same or equivalent key, false otherwise.

Annotations
@Override
getAlgorithmback to summary
public Algorithm getAlgorithm()

Implements org.bouncycastle.crypto.Key.getAlgorithm.

Return the algorithm this secret key is for.

Returns:Algorithm

the secret keys algorithm.

getKeyBytesback to summary
public byte[] getKeyBytes()

Implements org.bouncycastle.crypto.SymmetricKey.getKeyBytes.

Return the bytes representing this keys value. See CryptoServicesPermission.FIPS_MODE_EXPORT_SECRET_KEY for the permission associated with this method.

Returns:byte[]

the bytes making up this key.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.bouncycastle.crypto.Key.hashCode.

Doc from org.bouncycastle.crypto.Key.hashCode.

Return the hashCode for the key.

Returns:int

the key's hashCode.

Annotations
@Override
isDestroyedback to summary
public boolean isDestroyed()

Overrides default javax.security.auth.Destroyable.isDestroyed.

Doc from javax.security.auth.Destroyable.isDestroyed.

Determine if this Object has been destroyed.

Returns:boolean

true if this Object has been destroyed, false otherwise.

zeroizeback to summary
private void zeroize()