public abstract class BaseAgreementSpi
extends javax.crypto.KeyAgreementSpi
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
kaAlgorithm |
protected DerivationFunction |
kdf |
protected byte[] |
ukmParameters |
protected byte[] |
ukmParametersSalt |
| Constructor and Description |
|---|
BaseAgreementSpi(java.lang.String kaAlgorithm,
DerivationFunction kdf) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
agreementCompleted()
Record that the agreement has run to completion and its shared secret may now be generated.
|
protected void |
checkAgreementCompleted()
Refuse a shared secret asked for before the agreement has completed. javax.crypto.KeyAgreement
specifies IllegalStateException for that state; without this each SPI would hand back whatever
its result field happened to hold, which for DH was the private value itself.
|
protected void |
checkKdfSalt(UserKeyingMaterialSpec spec)
Refuse a UserKeyingMaterialSpec whose salt this agreement would have no use for.
|
protected abstract byte[] |
doCalcSecret() |
protected abstract void |
doInitFromKey(java.security.Key key,
java.security.spec.AlgorithmParameterSpec parameterSpec,
java.security.SecureRandom random) |
protected byte[] |
engineGenerateSecret() |
protected int |
engineGenerateSecret(byte[] sharedSecret,
int offset) |
protected javax.crypto.SecretKey |
engineGenerateSecret(java.lang.String algorithm) |
protected void |
engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random) |
protected void |
engineInit(java.security.Key key,
java.security.SecureRandom random) |
protected static java.lang.String |
getAlgorithm(java.lang.String algDetails) |
protected void |
resetAgreement()
Require a fresh agreement before the next shared secret.
|
protected static byte[] |
trimZeroes(byte[] secret) |
protected final java.lang.String kaAlgorithm
protected final DerivationFunction kdf
protected byte[] ukmParameters
protected byte[] ukmParametersSalt
public BaseAgreementSpi(java.lang.String kaAlgorithm,
DerivationFunction kdf)
protected static java.lang.String getAlgorithm(java.lang.String algDetails)
protected static byte[] trimZeroes(byte[] secret)
protected void engineInit(java.security.Key key,
java.security.SecureRandom random)
throws java.security.InvalidKeyException
engineInit in class javax.crypto.KeyAgreementSpijava.security.InvalidKeyExceptionprotected void engineInit(java.security.Key key,
java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
engineInit in class javax.crypto.KeyAgreementSpijava.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterExceptionprotected void agreementCompleted()
protected void resetAgreement()
protected void checkKdfSalt(UserKeyingMaterialSpec spec) throws java.security.InvalidAlgorithmParameterException
spec - the user keying material the agreement was initialised with.java.security.InvalidAlgorithmParameterException - if the spec carries a salt and the KDF is not HKDF.protected void checkAgreementCompleted()
java.lang.IllegalStateException - if no doPhase has completed the agreement since the last init.protected byte[] engineGenerateSecret()
throws java.lang.IllegalStateException
engineGenerateSecret in class javax.crypto.KeyAgreementSpijava.lang.IllegalStateExceptionprotected int engineGenerateSecret(byte[] sharedSecret,
int offset)
throws java.lang.IllegalStateException,
javax.crypto.ShortBufferException
engineGenerateSecret in class javax.crypto.KeyAgreementSpijava.lang.IllegalStateExceptionjavax.crypto.ShortBufferExceptionprotected javax.crypto.SecretKey engineGenerateSecret(java.lang.String algorithm)
throws java.security.NoSuchAlgorithmException
engineGenerateSecret in class javax.crypto.KeyAgreementSpijava.security.NoSuchAlgorithmExceptionprotected abstract byte[] doCalcSecret()
protected abstract void doInitFromKey(java.security.Key key,
java.security.spec.AlgorithmParameterSpec parameterSpec,
java.security.SecureRandom random)
throws java.security.InvalidKeyException,
java.security.InvalidAlgorithmParameterException
java.security.InvalidKeyExceptionjava.security.InvalidAlgorithmParameterException