public abstract class KeyPairGeneratorSpi
extends Object
| java.lang.Object | |
| ↳ | java.security.KeyPairGeneratorSpi |
| |
该类为 KeyPairGenerator类定义 ( SPI ),该类用于生成公钥和私钥对。
该类中的所有抽象方法都必须由每个希望为特定算法提供密钥对生成器实现的加密服务提供者来实现。
如果客户端未明确初始化KeyPairGenerator(通过调用initialize方法),则每个提供者都必须提供(并记录)默认初始化。 例如, Sun提供程序使用1024位的默认模数大小(密钥大小)。
Public constructors |
|
|---|---|
KeyPairGeneratorSpi() |
|
Public methods |
|
|---|---|
abstract KeyPair |
generateKeyPair() 生成密钥对。 |
void |
initialize(AlgorithmParameterSpec params, SecureRandom random) 使用指定的参数集和用户提供的随机源初始化密钥对生成器。 |
abstract void |
initialize(int keysize, SecureRandom random) 使用默认参数集初始化某个密钥大小的密钥对生成器。 |
Inherited methods |
|
|---|---|
java.lang.Object
|
|
KeyPair generateKeyPair ()
生成密钥对。 除非使用KeyPairGenerator接口调用初始化方法,否则将使用算法特定的默认值。 这将在每次调用时生成一个新的密钥对。
| Returns | |
|---|---|
KeyPair |
the newly generated KeyPair |
void initialize (AlgorithmParameterSpec params, SecureRandom random)
使用指定的参数集和用户提供的随机源初始化密钥对生成器。
这个具体的方法已被添加到这个以前定义的抽象类。 (为了向后兼容,它不能是抽象的。)供应商可能会重写它以初始化密钥对生成器。 如果一个参数不适合这个密钥对生成器,这样的覆盖预计会抛出一个InvalidAlgorithmParameterException异常。 如果这个方法没有被覆盖,它总是抛出一个UnsupportedOperationException异常。
| Parameters | |
|---|---|
params |
AlgorithmParameterSpec: the parameter set used to generate the keys. |
random |
SecureRandom: the source of randomness for this generator. |
| Throws | |
|---|---|
InvalidAlgorithmParameterException |
if the given parameters are inappropriate for this key pair generator. |
void initialize (int keysize,
SecureRandom random)
使用默认参数集初始化某个密钥大小的密钥对生成器。
| Parameters | |
|---|---|
keysize |
int: the keysize. This is an algorithm-specific metric, such as modulus length, specified in number of bits. |
random |
SecureRandom: the source of randomness for this generator. |
| Throws | |
|---|---|
InvalidParameterException |
if the keysize is not supported by this KeyPairGeneratorSpi object. |