public class LunaKeyAgreementEcDhWithKdf1 extends LunaKeyAgreementEcDh
| Modifier and Type | Field and Description |
|---|---|
protected KeyFactory |
kf |
protected LunaKey |
privateKey |
| Constructor and Description |
|---|
LunaKeyAgreementEcDhWithKdf1() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkPublicKey(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 void |
engineInit(Key key,
AlgorithmParameterSpec params,
SecureRandom random)
Initializes this key agreement with the given key.
|
protected int |
getDerivedKeyLength(long algId)
Returns the derived key length in bytes for a key of the given algorithm.
|
engineDoPhase, engineGenerateSecret, engineGenerateSecret, engineGenerateSecretWantBytes, engineInit, getMaxSharedSecretLengthprotected LunaKey privateKey
protected final KeyFactory kf
protected void engineInit(Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException
engineInit in class KeyAgreementSpikey - The party's private information, typically the local party's
private keyparams - Any additional information required for the key agreement.random - Unused. The Luna HSM has its own source of randomnessInvalidKeyException - If the given key is of the wrong type for
this key agreement or has an incompatible algorithm typeInvalidAlgorithmParameterExceptionprotected void checkPublicKey(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateException
key - The other party's public keylastPhase - Must be set to trueIllegalStateException - If this key agreement has not been initialized,
or if lastPhase is falseInvalidKeyException - If the pubic key's slot doesn't match the
private key's slotprotected int engineGenerateSecret(byte[] sharedSecret,
int offset)
throws IllegalStateException,
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 KeyAgreementSpisharedSecret - The buffer for the shared secretoffset - The offset in sharedSecret where the shared
secret will be storedsharedSecretIllegalStateException - If this key agreement has not been completed yetShortBufferException - If the given output buffer is too small to
hold the secretprotected int getDerivedKeyLength(long algId)
throws NoSuchAlgorithmException
algId - Algorithm of the secret keyNoSuchAlgorithmException - If the algorithm id is not recognizedCopyright 2014-2016 SafeNet Inc