Most visited

Recently visited

Added in API level 1

KeyPairGeneratorSpi

public abstract class KeyPairGeneratorSpi
extends Object

java.lang.Object
    java.security.KeyPairGeneratorSpi
Known Direct Subclasses


该类为 KeyPairGenerator类定义 ( SPI ),该类用于生成公钥和私钥对。

该类中的所有抽象方法都必须由每个希望为特定算法提供密钥对生成器实现的加密服务提供者来实现。

如果客户端未明确初始化KeyPairGenerator(通过调用initialize方法),则每个提供者都必须提供(并记录)默认初始化。 例如, Sun提供程序使用1024位的默认模数大小(密钥大小)。

也可以看看:

摘要(Summary)

Public constructors

KeyPairGeneratorSpi()

公共方法(Public methods)

abstract KeyPair generateKeyPair()

生成密钥对。

void initialize(AlgorithmParameterSpec params, SecureRandom random)

使用指定的参数集和用户提供的随机源初始化密钥对生成器。

abstract void initialize(int keysize, SecureRandom random)

使用默认参数集初始化某个密钥大小的密钥对生成器。

继承方法(Inherited methods)

From class java.lang.Object

Public constructors

KeyPairGeneratorSpi

Added in API level 1
KeyPairGeneratorSpi ()

公共方法(Public methods)

generateKeyPair

Added in API level 1
KeyPair generateKeyPair ()

生成密钥对。 除非使用KeyPairGenerator接口调用初始化方法,否则将使用算法特定的默认值。 这将在每次调用时生成一个新的密钥对。

返回(Returns)
KeyPair the newly generated KeyPair

initialize

Added in API level 1
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.

initialize

Added in API level 1
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.

Hooray!