All Packages Class Hierarchy This Package Previous Next Index
Interface java.security.ExtendedKeyGenerator
- public interface ExtendedKeyGenerator
The KeyGenerator class in JavaSoft's original version of JCE
does not provide these essential features:
- ability to set key lengths, for algorithms that support
more than one length.
- ability to query which key lengths are supported.
- creation of a key from an encoded byte array.
- checking for weak keys.
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.1.1.1 $
- Author:
- David Hopwood, Raif S. Naffah
-
generateKey()
- Generates a key.
-
generateKey(byte[])
- Generates a key from an encoded byte array.
-
getDefaultKeyLength()
- Returns the key length that will be used by
generateKey()
to create new random keys.
-
getMaximumKeyLength()
- Returns the maximum useful key length for this algorithm.
-
getMinimumKeyLength()
- Returns the minimum key length for this algorithm.
-
initialize(SecureRandom)
- Initializes the key generator.
-
initialize(SecureRandom, int)
- Initializes the key generator, and sets a specific key length
for use with algorithms that allow variable-length keys.
-
isValidKeyLength(int)
- Returns true iff length is a valid key length (in bytes)
for this algorithm.
-
isWeakAllowed()
- Returns true if this object is allowed to generate weak and
semi-weak keys; false otherwise.
-
setWeakAllowed(boolean)
- Sets whether this object is allowed to generate weak and
semi-weak keys.
initialize
public abstract void initialize(SecureRandom random)
- Initializes the key generator.
- Parameters:
- random - the source of randomness for this generator.
generateKey
public abstract SecretKey generateKey()
- Generates a key. This method generates a new random key every
time it is called.
If a source of random bytes has not been set using one of the
initialize
methods, new SecureRandom()
will be used.
- Returns:
- the new key.
initialize
public abstract void initialize(SecureRandom random,
int length)
- Initializes the key generator, and sets a specific key length
for use with algorithms that allow variable-length keys.
The length parameter only affects randomly generated
keys (i.e. the generateKey()
method without
parameters).
- Parameters:
- random - the source of randomness for this generator.
- length - the desired key length in bytes.
- Throws: IllegalArgumentException
- if length is not valid for
this algorithm.
generateKey
public abstract SecretKey generateKey(byte data[]) throws WeakKeyException, InvalidKeyException
- Generates a key from an encoded byte array. The format of the
secret key is "RAW". The contents of data will not be
modified.
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.
- Parameters:
- data - user supplied raw-encoded data from which a secret
key will be generated.
- Returns:
- the new key.
- Throws: NullPointerException
- if data == null
- Throws: WeakKeyException
- if isWeakAllowed() is false, and
data represents a weak key for this algorithm.
- Throws: InvalidKeyException
- if the length of data is not
valid for this algorithm.
isWeakAllowed
public abstract boolean isWeakAllowed()
- Returns true if this object is allowed to generate weak and
semi-weak keys; false otherwise.
setWeakAllowed
public abstract void setWeakAllowed(boolean allowWeak)
- Sets whether this object is allowed to generate weak and
semi-weak keys.
- Parameters:
- allowWeak - true if weak/semi-weak keys are allowed.
getMinimumKeyLength
public abstract int getMinimumKeyLength()
- Returns the minimum key length for this algorithm.
getDefaultKeyLength
public abstract int getDefaultKeyLength()
- Returns the key length that will be used by
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)
.
getMaximumKeyLength
public abstract int getMaximumKeyLength()
- Returns the maximum useful key length for this algorithm.
isValidKeyLength
public abstract boolean isValidKeyLength(int length)
- Returns true iff length is a valid key length (in bytes)
for this algorithm.
All Packages Class Hierarchy This Package Previous Next Index