use of org.gudy.bouncycastle.jce.interfaces.ECPublicKey in project BiglyBT by BiglySoftware.
the class JCEECDHKeyAgreement method engineDoPhase.
@Override
protected Key engineDoPhase(Key key, boolean lastPhase) throws InvalidKeyException, IllegalStateException {
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;
}
use of org.gudy.bouncycastle.jce.interfaces.ECPublicKey in project BiglyBT by BiglySoftware.
the class ECUtil method generatePublicKeyParameter.
public static AsymmetricKeyParameter generatePublicKeyParameter(PublicKey key) throws InvalidKeyException {
if (key instanceof ECPublicKey) {
ECPublicKey k = (ECPublicKey) key;
ECParameterSpec s = k.getParams();
return new ECPublicKeyParameters(k.getQ(), new ECDomainParameters(s.getCurve(), s.getG(), s.getN()));
}
throw new InvalidKeyException("can't identify EC public key.");
}
Aggregations