|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The KeyGenerator class in JavaSoft's original version of JCE does not provide these essential features:
This interface provides a standard API for KeyGenerators that implement the above features.
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.2 $
Method Summary | |
SecretKey |
generateKey()
Generates a key. |
SecretKey |
generateKey(byte[] data)
Generates a key from an encoded byte array. |
int |
getDefaultKeyLength()
Returns the key length that will be used by generateKey() to create new random keys. |
int |
getMaximumKeyLength()
Returns the maximum useful key length for this algorithm. |
int |
getMinimumKeyLength()
Returns the minimum key length for this algorithm. |
void |
initialize(java.security.SecureRandom random)
Initializes the key generator. |
void |
initialize(java.security.SecureRandom random,
int length)
Initializes the key generator, and sets a specific key length for use with algorithms that allow variable-length keys. |
boolean |
isValidKeyLength(int length)
Returns true iff length is a valid key length (in bytes) for this algorithm. |
boolean |
isWeakAllowed()
Returns true if this object is allowed to generate weak and semi-weak keys; false otherwise. |
void |
setWeakAllowed(boolean allowWeak)
Sets whether this object is allowed to generate weak and semi-weak keys. |
Method Detail |
public void initialize(java.security.SecureRandom random)
random
- the source of randomness for this generator.public SecretKey generateKey()
If a source of random bytes has not been set using one of the
initialize
methods, new SecureRandom()
will be used.
public void initialize(java.security.SecureRandom random, int length)
The length parameter only affects randomly generated
keys (i.e. the generateKey()
method without
parameters).
random
- the source of randomness for this generator.length
- the desired key length in bytes.java.lang.IllegalArgumentException
- if length is not valid for
this algorithm.public SecretKey generateKey(byte[] data) throws WeakKeyException, java.security.InvalidKeyException
The encoded key bytes may differ from data in order to make sure that they represent a valid key. For example, if keys for this algorithm conventionally include parity bits, those bits will be set correctly. For most algorithms, data is used unchanged.
data
- user supplied raw-encoded data from which a secret
key will be generated.NullPointerException
- if data == nullWeakKeyException
- if isWeakAllowed() is false, and
data represents a weak key for this algorithm.java.security.InvalidKeyException
- if the length of data is not
valid for this algorithm.public boolean isWeakAllowed()
public void setWeakAllowed(boolean allowWeak)
allowWeak
- true if weak/semi-weak keys are allowed.public int getMinimumKeyLength()
public int getDefaultKeyLength()
generateKey()
to create new random keys. This is
either the default key length determined by the KeyGenerator
for this algorithm, or the length set using
initialize(SecureRandom random, int length)
.public int getMaximumKeyLength()
public boolean isValidKeyLength(int length)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |