Search in sources :

Example 1 with ECDomainParameters

use of org.gudy.bouncycastle.crypto.params.ECDomainParameters 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.");
}
Also used : ECPublicKey(org.gudy.bouncycastle.jce.interfaces.ECPublicKey) ECDomainParameters(org.gudy.bouncycastle.crypto.params.ECDomainParameters) ECParameterSpec(org.gudy.bouncycastle.jce.spec.ECParameterSpec) InvalidKeyException(java.security.InvalidKeyException) ECPublicKeyParameters(org.gudy.bouncycastle.crypto.params.ECPublicKeyParameters)

Example 2 with ECDomainParameters

use of org.gudy.bouncycastle.crypto.params.ECDomainParameters in project BiglyBT by BiglySoftware.

the class ECUtil method generatePrivateKeyParameter.

public static AsymmetricKeyParameter generatePrivateKeyParameter(PrivateKey key) throws InvalidKeyException {
    if (key instanceof ECPrivateKey) {
        ECPrivateKey k = (ECPrivateKey) key;
        ECParameterSpec s = k.getParams();
        return new ECPrivateKeyParameters(k.getD(), new ECDomainParameters(s.getCurve(), s.getG(), s.getN()));
    }
    throw new InvalidKeyException("can't identify EC private key.");
}
Also used : ECPrivateKey(org.gudy.bouncycastle.jce.interfaces.ECPrivateKey) ECPrivateKeyParameters(org.gudy.bouncycastle.crypto.params.ECPrivateKeyParameters) ECDomainParameters(org.gudy.bouncycastle.crypto.params.ECDomainParameters) ECParameterSpec(org.gudy.bouncycastle.jce.spec.ECParameterSpec) InvalidKeyException(java.security.InvalidKeyException)

Aggregations

InvalidKeyException (java.security.InvalidKeyException)2 ECDomainParameters (org.gudy.bouncycastle.crypto.params.ECDomainParameters)2 ECParameterSpec (org.gudy.bouncycastle.jce.spec.ECParameterSpec)2 ECPrivateKeyParameters (org.gudy.bouncycastle.crypto.params.ECPrivateKeyParameters)1 ECPublicKeyParameters (org.gudy.bouncycastle.crypto.params.ECPublicKeyParameters)1 ECPrivateKey (org.gudy.bouncycastle.jce.interfaces.ECPrivateKey)1 ECPublicKey (org.gudy.bouncycastle.jce.interfaces.ECPublicKey)1