Search in sources :

Example 11 with ECPublicKeyParameters

use of org.bouncycastle.crypto.params.ECPublicKeyParameters in project XobotOS by xamarin.

the class ECKeyPairGenerator method generateKeyPair.

/**
     * Given the domain parameters this routine generates an EC key
     * pair in accordance with X9.62 section 5.2.1 pages 26, 27.
     */
public AsymmetricCipherKeyPair generateKeyPair() {
    BigInteger n = params.getN();
    int nBitLength = n.bitLength();
    BigInteger d;
    do {
        d = new BigInteger(nBitLength, random);
    } while (d.equals(ZERO) || (d.compareTo(n) >= 0));
    ECPoint Q = params.getG().multiply(d);
    return new AsymmetricCipherKeyPair(new ECPublicKeyParameters(Q, params), new ECPrivateKeyParameters(d, params));
}
Also used : ECPrivateKeyParameters(org.bouncycastle.crypto.params.ECPrivateKeyParameters) BigInteger(java.math.BigInteger) ECPoint(org.bouncycastle.math.ec.ECPoint) ECPublicKeyParameters(org.bouncycastle.crypto.params.ECPublicKeyParameters) ECPoint(org.bouncycastle.math.ec.ECPoint) AsymmetricCipherKeyPair(org.bouncycastle.crypto.AsymmetricCipherKeyPair)

Example 12 with ECPublicKeyParameters

use of org.bouncycastle.crypto.params.ECPublicKeyParameters in project Skein3Fish by wernerd.

the class ECDHBasicAgreement method calculateAgreement.

public BigInteger calculateAgreement(CipherParameters pubKey) {
    ECPublicKeyParameters pub = (ECPublicKeyParameters) pubKey;
    ECPoint P = pub.getQ().multiply(key.getD());
    return P.getX().toBigInteger();
}
Also used : ECPoint(org.bouncycastle.math.ec.ECPoint) ECPublicKeyParameters(org.bouncycastle.crypto.params.ECPublicKeyParameters)

Aggregations

ECPublicKeyParameters (org.bouncycastle.crypto.params.ECPublicKeyParameters)12 ECPoint (org.bouncycastle.math.ec.ECPoint)8 BigInteger (java.math.BigInteger)7 ECDomainParameters (org.bouncycastle.crypto.params.ECDomainParameters)4 AsymmetricCipherKeyPair (org.bouncycastle.crypto.AsymmetricCipherKeyPair)3 ECPrivateKeyParameters (org.bouncycastle.crypto.params.ECPrivateKeyParameters)3 InvalidKeyException (java.security.InvalidKeyException)2 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)2 DEROctetString (org.bouncycastle.asn1.DEROctetString)2 DHParameter (org.bouncycastle.asn1.pkcs.DHParameter)2 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)2 DSAParameter (org.bouncycastle.asn1.x509.DSAParameter)2 DHDomainParameters (org.bouncycastle.asn1.x9.DHDomainParameters)2 DHPublicKey (org.bouncycastle.asn1.x9.DHPublicKey)2 DHValidationParms (org.bouncycastle.asn1.x9.DHValidationParms)2 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)2 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)2 X9ECPoint (org.bouncycastle.asn1.x9.X9ECPoint)2 DHParameters (org.bouncycastle.crypto.params.DHParameters)2 DHPublicKeyParameters (org.bouncycastle.crypto.params.DHPublicKeyParameters)2