public class LunaKeyAgreementEcDhWithNistKdf256 extends LunaKeyAgreementEcDh
Modifier and Type | Field and Description |
---|---|
protected java.security.KeyFactory |
kf |
protected LunaKey |
privateKey |
Constructor and Description |
---|
LunaKeyAgreementEcDhWithNistKdf256() |
LunaKeyAgreementEcDhWithNistKdf256(LunaECDHParameterSpec params) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkPublicKey(java.security.Key key,
boolean lastPhase)
Checks the parameters to engineDoPhase().
|
protected int |
engineGenerateSecret(byte[] sharedSecret,
int offset)
Generates the shared secret, and places it into the buffer
sharedSecret , beginning at
offset inclusive. |
protected int |
getDerivedKeyLength(long algId)
Returns the derived key length in bytes for a key of the given algorithm.
|
engineDoPhase, engineGenerateSecret, engineGenerateSecret, engineGenerateSecretWantBytes, engineInit, engineInit, getMaxSharedSecretLength, getParameterSpec
protected LunaKey privateKey
protected final java.security.KeyFactory kf
public LunaKeyAgreementEcDhWithNistKdf256()
public LunaKeyAgreementEcDhWithNistKdf256(LunaECDHParameterSpec params)
protected void checkPublicKey(java.security.Key key, boolean lastPhase) throws java.security.InvalidKeyException, java.lang.IllegalStateException
key
- The other party's public keylastPhase
- Must be set to truejava.lang.IllegalStateException
- If this key agreement has not been initialized, or if lastPhase
is falsejava.security.InvalidKeyException
- If the pubic key's slot doesn't match the private key's slotprotected int engineGenerateSecret(byte[] sharedSecret, int offset) throws java.lang.IllegalStateException, javax.crypto.ShortBufferException
sharedSecret
, beginning at
offset
inclusive.
If the sharedSecret
buffer is too small to hold the result, a ShortBufferException
is
thrown. In this case, the key agreement is not reset and the call can be repeated with a larger output buffer.
Successful completion of this method resets this KeyAgreement
object, so that it can be reused for
further key agreements. Unless this key agreement is reinitialized with one of the init
methods, the
same private information will be used for subsequent key agreements. However, doPhase
will have to be
called after every call to generateSecret
in order to re-initialize the public information.
engineGenerateSecret
in class javax.crypto.KeyAgreementSpi
sharedSecret
- The buffer for the shared secretoffset
- The offset in sharedSecret
where the shared secret will be storedsharedSecret
java.lang.IllegalStateException
- If this key agreement has not been completed yetjavax.crypto.ShortBufferException
- If the given output buffer is too small to hold the secretprotected int getDerivedKeyLength(long algId) throws java.security.NoSuchAlgorithmException
algId
- Algorithm of the secret keyjava.security.NoSuchAlgorithmException
- If the algorithm id is not recognizedCopyright 2014-2018 SafeNet. All rights reserved.