|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.security.KeyPairGeneratorSpi | +--java.security.KeyPairGenerator | +--iaik.security.rsa.RSAKeyPairGenerator
The RSAKeyPairGenerator class is used to generate keys for the RSA algorithm.
The modulus of the generated KeyPair always has 1024+256x bits. The value x
is internally created from the key length. If no initialize()
method of
this key pair generator is called, it defaults to initialize(1024).
The algorithm used for key generation was published in RSA LABORATORIES' CryptoBytes, Volume 3, Number 1 - Spring 1997, page 9
For creating a RSA key pair, a KeyPairGenerator has to be instantiated, properly
initialized and directed to actually generate the keys by calling the
generateKeyPair
method. If the generator
is not initialized by explicitly calling an initialize
method,
the modulus length per default is set to 1024 bits.
Generating RSA keys using a modulus length of, e.g. 512 bits, may be done by:
KeyPairGenerator key_gen = KeyPairGenerator.getIntance("RSA"); key_gen.initialize(512, sec_random); KeyPair key_pair = key_gen.generateKeyPair();
The example above initializes the key pair generator algorithm-independent by only specifying the length of the modulus. For performing an algorithm-specific initialization, an explicit cast to RSAKeyPairGenerator would be necessary:
RSAKeyPairGenerator dsa_key_gen = (RSAKeyPairGenerator)key_gen; rsa_key_gen.initialize(512, pub_exponent, sec_random);
Guidelines on how to create some key using a KeyPairGenerator can be found in http://java.sun.com/products/JDK/1.2/docs/guide/security/CryptoSpec.html.
KeyPairGenerator
,
KeyPair
,
RSACipher
,
RSAKey
,
RSAPublicKey
,
RSAPrivateKey
,
RSAKeyFactory
Constructor Summary | |
RSAKeyPairGenerator()
Default constructor for creating a RSAKeyPairGenerator object. |
Method Summary | |
KeyPair |
generateKeyPair()
Actually generates the requested RSA KeyPair. |
void |
initialize(int strength)
Initializes the RSAKeyPairGenerator for a certain key length with the default random seed. |
void |
initialize(int strength,
BigInteger publicExponent,
SecureRandom secureRandom)
Initializes the key pair generator using the specified "strength" (desired key length in bits), public exponent, and source of random bits. |
void |
initialize(int strength,
SecureRandom secureRandom)
Initializes the RSAKeyPairGenerator for a certain key length with the given random seed. |
Methods inherited from class java.security.KeyPairGenerator |
genKeyPair, getAlgorithm, getInstance, getInstance, getProvider, initialize, initialize |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RSAKeyPairGenerator()
Method Detail |
public void initialize(int strength)
initialize
in class KeyPairGenerator
strength
- the length of the key in bits.public void initialize(int strength, SecureRandom secureRandom)
initialize
in class KeyPairGenerator
strength
- the length of the key in bits.secureRandom
- the random seed.public void initialize(int strength, BigInteger publicExponent, SecureRandom secureRandom) throws InvalidParameterException
strength
- keyLength the length of the key in bits.publicExponent
- the public exponentsecureRandom
- the random seedpublic KeyPair generateKeyPair()
generateKeyPair
in class KeyPairGenerator
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |