Methods Summary |
---|
public java.security.Key | doPhase(java.security.Key key, boolean lastPhase)
return( engineDoPhase( key, lastPhase ));
|
protected java.security.Key | engineDoPhase(java.security.Key key, boolean lastPhase)
if (privKey == null)
{
throw new IllegalStateException("EC Diffie-Hellman not initialised.");
}
if (!lastPhase)
{
throw new IllegalStateException("EC Diffie-Hellman can only be between two parties.");
}
if (!(key instanceof ECPublicKey))
{
throw new InvalidKeyException("EC Key Agreement doPhase requires ECPublicKey");
}
CipherParameters pubKey = ECUtil.generatePublicKeyParameter((PublicKey)key);
result = agreement.calculateAgreement(pubKey);
return null;
|
protected byte[] | engineGenerateSecret()
return result.toByteArray();
|
protected int | engineGenerateSecret(byte[] sharedSecret, int offset)
byte[] secret = result.toByteArray();
if (sharedSecret.length - offset < secret.length)
{
throw new ShortBufferException("ECKeyAgreement - buffer too short");
}
System.arraycopy(secret, 0, sharedSecret, offset, secret.length);
return secret.length;
|
protected javax.crypto.SecretKey | engineGenerateSecret(java.lang.String algorithm)
return new SecretKeySpec(result.toByteArray(), algorithm);
|
protected void | engineInit(java.security.Key key, java.security.SecureRandom random)
if (!(key instanceof ECPrivateKey))
{
throw new InvalidKeyException("ECKeyAgreement requires ECPrivateKey");
}
privKey = ECUtil.generatePrivateKeyParameter((PrivateKey)key);
agreement.init(privKey);
|
protected void | engineInit(java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
if (!(key instanceof ECPrivateKey))
{
throw new InvalidKeyException("ECKeyAgreement requires ECPrivateKey for initialisation");
}
privKey = ECUtil.generatePrivateKeyParameter((PrivateKey)key);
agreement.init(privKey);
|
public byte[] | generateSecret()
return( engineGenerateSecret());
|
public void | init(java.security.Key key)
engineInit( key, null );
|