public class PKCS11RandomSpi extends java.security.SecureRandomSpi implements PKCS11EngineClass
Modifier and Type | Field and Description |
---|---|
protected boolean |
pkcs11OperationInitialized_
Indicates, if the PKCS#11 signature/verify is already initialized for the next operation round.
|
protected iaik.pkcs.pkcs11.Session |
session_
The session this object works with.
|
protected static java.lang.String |
SOFTWARE_SECURE_RANDOM_ALGORITHM
The name of the algorithm to use for a software delegate.
|
protected java.security.SecureRandom |
softwareDelegate_
This is the software delegate object to use, if the token does not have a random generator.
|
protected TokenManager |
tokenManager_
Token manager used to access the token.
|
protected boolean |
useSoftwareDelegation_
If true, this object must use the software secure random, because the token does not have a
random number generator or there was no token present, when this object was created.
|
Constructor and Description |
---|
PKCS11RandomSpi()
This default constructor always links this random class to the first provider instance, because
there are no means in the JCE to find out our provider instance.
|
PKCS11RandomSpi(TokenManager tokenManager)
This constructor links this random class to the given token manager.
|
Modifier and Type | Method and Description |
---|---|
protected byte[] |
engineGenerateSeed(int numBytes)
Returns the given number of seed bytes.
|
protected void |
engineNextBytes(byte[] arrayToFill)
Generates a user-specified number of random bytes.
|
protected void |
engineSetSeed(byte[] seedBytes)
Reseeds this random object.
|
protected void |
finalize()
Tries to close the used session.
|
protected void |
finalizePkcs11Operation()
The internal session finalization method, if the current operation has been finished.
|
protected java.lang.String |
getSoftwareDelegateAlgorithm()
Return the name of the software algorithm to use, if this object must use a softwre delegation
object.
|
protected void |
initialize()
Initialize this secure random object.
|
protected void |
initializePkcs11Operation()
The internal session initialization method, if all necessary member variables are set.
|
protected void |
initializeSession()
Sets up an appropriate session.
|
protected void |
initializeSoftwareDelegate()
Initialize the software delegate secure random and store a reference in
softwareDelegate_ . |
boolean |
isSupportedBy(TokenManager tokenManager)
Check, if the current token of the given token manager supports the required features for this
engine class.
|
protected static final java.lang.String SOFTWARE_SECURE_RANDOM_ALGORITHM
protected TokenManager tokenManager_
protected iaik.pkcs.pkcs11.Session session_
protected boolean pkcs11OperationInitialized_
protected boolean useSoftwareDelegation_
protected java.security.SecureRandom softwareDelegate_
public PKCS11RandomSpi() throws IAIKPkcs11Exception
IAIKPkcs11Exception
- If there is no IAIKPkcs11 instance available.public PKCS11RandomSpi(TokenManager tokenManager) throws IAIKPkcs11Exception
tokenManager
- The manager of the token we use for random generation.IAIKPkcs11Exception
- If there is no IAIKPkcs11 instance available.public boolean isSupportedBy(TokenManager tokenManager)
isSupportedBy
in interface PKCS11EngineClass
tokenManager
- The token manager. Used to get information about the current token.protected void initialize()
protected void initializeSoftwareDelegate() throws java.security.GeneralSecurityException
softwareDelegate_
.java.security.GeneralSecurityException
- If initializing the software secure random fails.protected java.lang.String getSoftwareDelegateAlgorithm()
protected void engineNextBytes(byte[] arrayToFill) throws IAIKPkcs11Exception
engineNextBytes
in class java.security.SecureRandomSpi
arrayToFill
- the array to be filled in with random bytes.IAIKPkcs11Exception
- If generating random bytes fails.protected void engineSetSeed(byte[] seedBytes) throws IAIKPkcs11Exception
engineSetSeed
in class java.security.SecureRandomSpi
seedBytes
- The seed bytes.IAIKPkcs11Exception
- If seeding the random fails.protected byte[] engineGenerateSeed(int numBytes)
engineGenerateSeed
in class java.security.SecureRandomSpi
numBytes
- the number of seed bytes to generate.protected void initializeSession()
protected void initializePkcs11Operation()
protected void finalizePkcs11Operation()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- If disposing the session fails.IAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4