public abstract class KeyAgreementSpi extends Object
KeyAgreement
类。在这个类中的所有的抽象方法必须实现由每个密码服务提供商,谁希望提供一个特定的密钥协商算法的实现。
参与建立一个共享的秘密密钥的密钥生成器创建(KeyPairGenerator
或KeyGenerator
),一个KeyFactory
,或由于密钥协商协议的一个中间阶段(engineDoPhase
)。
每个记者在密钥交换,engineDoPhase
需要叫。例如,如果密钥交换与另一方,engineDoPhase
需要调用一次,将true
的lastPhase
旗。如果密钥交换与其他两方,engineDoPhase
需要调用两次,第一次设置lastPhase
旗false
,第二时间设置为true
。有可能有任何数量的参与密钥交换的缔约方。
KeyGenerator
,
SecretKey
Constructor and Description |
---|
KeyAgreementSpi() |
Modifier and Type | Method and Description |
---|---|
protected abstract Key |
engineDoPhase(Key key, boolean lastPhase)
执行本密钥协议的下一阶段,该密钥协议的下一阶段是从该密钥协议中的另一方接收的给定密钥中执行的。
|
protected abstract byte[] |
engineGenerateSecret()
生成共享密钥,并将其返回到一个新的缓冲区中。
|
protected abstract int |
engineGenerateSecret(byte[] sharedSecret, int offset)
生成共享密钥,并将其写入缓冲区,
sharedSecret ,在
offset 包容开始。
|
protected abstract SecretKey |
engineGenerateSecret(String algorithm)
创建共享密钥,并将其作为所请求的算法类型的密钥对象返回。
|
protected abstract void |
engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random)
初始化密钥协商与给定的键,设置算法参数,并随机源。
|
protected abstract void |
engineInit(Key key, SecureRandom random)
初始化密钥协商的密钥和随机源。
|
protected abstract void engineInit(Key key, SecureRandom random) throws InvalidKeyException
如果密钥协议算法需要随机字节,它会从随机给定的源,random
。然而,如果底层算法的实现不需要任何随机字节,random
被忽略。
key
-党的私人信息。例如,在Diffie-Hellman密钥交换协议的情况下,这将是党自身的Diffie-Hellman密钥。
random
-随机源
InvalidKeyException
-如果它的键是不适合这个关键协议,例如,是错误的类型或具有不兼容的算法类型。
protected abstract void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
key
-党的私人信息。例如,在Diffie-Hellman密钥交换协议的情况下,这将是党自身的Diffie-Hellman密钥。
params
的关键协议参数
random
-随机源
InvalidKeyException
-如果它的键是不适合这个关键协议,例如,是错误的类型或具有不兼容的算法类型。
InvalidAlgorithmParameterException
如果给定参数的密钥协商是不合适的。
protected abstract Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateException
key
-这一阶段的关键。例如,在Diffie-Hellman之间2方的情况下,这将是另一方的Diffie-Hellman公钥。
lastPhase
国旗说明这是否是这个关键协议的最后阶段。
InvalidKeyException
-如果给定的关键是不适合这个阶段。
IllegalStateException
-如果这关键协议尚未初始化。
protected abstract byte[] engineGenerateSecret() throws IllegalStateException
这个方式将这KeyAgreementSpi
对象,这样可以进一步关键协议。除非这个关键协议初始化的一个engineInit
方法相同的私人信息和算法参数将用于后续的关键协议。
IllegalStateException
-如果这关键协议尚未完成
protected abstract int engineGenerateSecret(byte[] sharedSecret, int offset) throws IllegalStateException, ShortBufferException
sharedSecret
,在
offset
包容开始。
如果sharedSecret
缓冲太小装不下的结果,一个ShortBufferException
抛出。在这种情况下,这个调用应该重复一个较大的输出缓冲区。
这个方式将这KeyAgreementSpi
对象,这样可以进一步关键协议。除非这个关键协议初始化的一个engineInit
方法相同的私人信息和算法参数将用于后续的关键协议。
sharedSecret
-共享秘密的缓冲
offset
-抵消
sharedSecret
在共享的秘密将被存储
sharedSecret
字节数
IllegalStateException
-如果这关键协议尚未完成
ShortBufferException
如果给定的输出缓冲区太小,容纳的秘密
protected abstract SecretKey engineGenerateSecret(String algorithm) throws IllegalStateException, NoSuchAlgorithmException, InvalidKeyException
这个方式将这KeyAgreementSpi
对象,这样可以进一步关键协议。除非这个关键协议初始化的一个engineInit
方法相同的私人信息和算法参数将用于后续的关键协议。
algorithm
-请求的密钥算法
IllegalStateException
-如果这关键协议尚未完成
NoSuchAlgorithmException
如果请求的密钥算法是不可
InvalidKeyException
如果共享密钥材料不能用于生成一个密钥请求算法的类型(例如,关键材料太短)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.