|
IAIK PKCS#11 Provider Micro Edition version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectiaik.pkcs.pkcs11.me.SecureRandom
An object of this class generates random bytes using the associated
token. The random bytes come directly from the token. There is no
intermediate pseudo random generator.
The application can also feed in seed bytes into the token's
random generator (if the token supports this feature). Note that
feeding in some seed bytes can never reduce the quality of the
generated random bytes, even if all seed bytes are constant or
zero. In most cases, it may not be required to feed in some seed
to get good random data. Please refer to your token documentation
for details.
A typical piece of code using this class may look like this.
Token token = ... if (!token.supportsSecureRandom()) { ... // token does not have a random generator } SecureRandom tokenRandom = token.getSecureRandom(); // optionally feed in some seed byte[] seed = ... // get some seed bytes tokenRandom.setSeed(seed); // get random bytes byte[] randomData = new byte[1024]; tokenRandom.nextBytes(randomData);The variable
randomData
will hold the random data.
This class is not thread safe.
Token
,
Token.getSecureRandom()
,
Token.supportsSecureRandom()
Method Summary | |
void |
nextBytes(byte[] buffer)
Get random bytes from the token's random generator. |
void |
setSeed(byte[] seed)
Feed some seed into the random generator of the token. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public void setSeed(byte[] seed) throws PKCS11RuntimeException
seed
- The seed bytes.
PKCS11RuntimeException
- If feeding the seeds into the token's
random generator fails; e.g. if the
token does not support this feature.public void nextBytes(byte[] buffer) throws PKCS11RuntimeException
buffer
- The buffer to receive the random data.
PKCS11RuntimeException
- If generating random data fails;
e.g. if the token does not support
this feature.
|
IAIK PKCS#11 Provider Micro Edition version 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |