Java 类org.bouncycastle.crypto.params.ECPublicKeyParameters 实例源码

项目:fabric-api-archive    文件:BouncyCastleCrypto.java   
@Override
public boolean verify(byte[] hash, byte[] signature, byte[] publicKey) {
    ASN1InputStream asn1 = new ASN1InputStream(signature);
    try {
        ECDSASigner signer = new ECDSASigner();
        signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(publicKey), domain));

        DLSequence seq = (DLSequence) asn1.readObject();
        BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
        BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
        return signer.verifySignature(hash, r, s);
    } catch (Exception e) {
        return false;
    } finally {
        try {
            asn1.close();
        } catch (IOException ignored) {
        }
    }
}
项目:ipack    文件:JCEECPublicKey.java   
public JCEECPublicKey(
    String                  algorithm,
    ECPublicKeyParameters   params,
    ECParameterSpec         spec)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:ipack    文件:TlsECDHKeyExchange.java   
public void generateClientKeyExchange(OutputStream output)
    throws IOException
{
    if (agreementCredentials != null)
    {
        return;
    }

    AsymmetricCipherKeyPair ecAgreeClientKeyPair = TlsECCUtils.generateECKeyPair(context.getSecureRandom(),
        ecAgreeServerPublicKey.getParameters());
    this.ecAgreeClientPrivateKey = (ECPrivateKeyParameters)ecAgreeClientKeyPair.getPrivate();

    byte[] point = TlsECCUtils.serializeECPublicKey(serverECPointFormats,
        (ECPublicKeyParameters)ecAgreeClientKeyPair.getPublic());

    TlsUtils.writeOpaque8(point, output);
}
项目:ipack    文件:ECNewPublicKeyTransform.java   
/**
 * initialise the EC Elgamal engine.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
项目:ipack    文件:ECElGamalEncryptor.java   
/**
 * initialise the encryptor.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
项目:ipack    文件:DSTU4145Signer.java   
public void init(boolean forSigning, CipherParameters param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            param = rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
        }

        this.key = (ECPrivateKeyParameters)param;
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }

}
项目:ipack    文件:ECDSASigner.java   
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
项目:ipack    文件:ECNRSigner.java   
public void init(
    boolean          forSigning, 
    CipherParameters param) 
{
    this.forSigning = forSigning;

    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
项目:ipack    文件:BCDSTU4145PublicKey.java   
public BCDSTU4145PublicKey(
    String algorithm,
    ECPublicKeyParameters params,
    ECParameterSpec spec)
{
    ECDomainParameters dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:ipack    文件:BCECPublicKey.java   
public BCECPublicKey(
    String algorithm,
    ECPublicKeyParameters params,
    ECParameterSpec spec,
    ProviderConfiguration configuration)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }

    this.configuration = configuration;
}
项目:ipack    文件:BCECGOST3410PublicKey.java   
public BCECGOST3410PublicKey(
    String algorithm,
    ECPublicKeyParameters params,
    ECParameterSpec spec)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:Direct-File-Downloader    文件:JCEECPublicKey.java   
JCEECPublicKey(
    String                  algorithm,
    ECPublicKeyParameters   params,
    ECParameterSpec         spec)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        this.ecSpec = new ECParameterSpec(
                        dp.getCurve(),
                        dp.getG(),
                        dp.getN(),
                        dp.getH(),
                        dp.getSeed());
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:fabric-api    文件:BouncyCastleCrypto.java   
@Override
public boolean verify(byte[] hash, byte[] signature, byte[] publicKey) {
    ASN1InputStream asn1 = new ASN1InputStream(signature);
    try {
        ECDSASigner signer = new ECDSASigner();
        signer.init(false, new ECPublicKeyParameters(curve.getCurve().decodePoint(publicKey), domain));

        DLSequence seq = (DLSequence) asn1.readObject();
        BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getPositiveValue();
        BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getPositiveValue();
        return signer.verifySignature(hash, r, s);
    } catch (Exception e) {
        return false;
    } finally {
        try {
            asn1.close();
        } catch (IOException ignored) {
        }
    }
}
项目:Direct-File-Downloader    文件:ECDSASigner.java   
public void init(
       boolean                 forSigning,
       CipherParameters        param)
{
       if (forSigning)
       {
           if (param instanceof ParametersWithRandom)
           {
               ParametersWithRandom    rParam = (ParametersWithRandom)param;

               this.random = rParam.getRandom();
               this.key = (ECPrivateKeyParameters)rParam.getParameters();
           }
           else
           {
               this.random = new SecureRandom();
               this.key = (ECPrivateKeyParameters)param;
           }
       }
       else
       {
        this.key = (ECPublicKeyParameters)param;
       }
}
项目:Direct-File-Downloader    文件:ECKeyPairGenerator.java   
/**
    * 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));
}
项目:TLS-Attacker    文件:ECDHClientKeyExchangePreparator.java   
@Override
public void prepareAfterParse() {
    try {
        msg.prepareComputations();
        List<ECPointFormat> pointFormatList = chooser.getServerSupportedPointFormats();
        ECPointFormat[] formatArray = pointFormatList.toArray(new ECPointFormat[pointFormatList.size()]);
        short[] pointFormats = ECCUtilsBCWrapper.convertPointFormats(formatArray);
        ECPublicKeyParameters clientPublicKey = TlsECCUtils.deserializeECPublicKey(pointFormats,
                getDomainParameters(chooser.getEcCurveType(), chooser.getSelectedCurve()), msg.getPublicKey()
                        .getValue());
        CustomECPoint customClientKey = new CustomECPoint(clientPublicKey.getQ().getRawXCoord().toBigInteger(),
                clientPublicKey.getQ().getRawYCoord().toBigInteger());
        msg.getComputations().setClientPublicKey(customClientKey);

        BigInteger privatekey = chooser.getServerEcPrivateKey();
        computePremasterSecret(clientPublicKey,
                new ECPrivateKeyParameters(privatekey, clientPublicKey.getParameters()));
        preparePremasterSecret(msg);
        prepareClientRandom(msg);
    } catch (IOException ex) {
        throw new PreparationException("Could prepare ECDHClientKeyExchange Message after Parse", ex);
    }
}
项目:TLS-Attacker    文件:ECDHEServerKeyExchangeHandler.java   
protected void adjustECParameter(ECDHEServerKeyExchangeMessage message) {
    tlsContext.setSelectedCurve(NamedCurve.getNamedCurve(message.getNamedCurve().getValue()));
    // TODO avoid BC tool
    byte[] ecParams = ArrayConverter.concatenate(new byte[] { message.getCurveType().getValue() }, message
            .getNamedCurve().getValue(), ArrayConverter.intToBytes(message.getPublicKeyLength().getValue(), 1),
            message.getPublicKey().getValue());
    InputStream is = new ByteArrayInputStream(ecParams);
    ECPublicKeyParameters publicKeyParameters = null;
    try {
        publicKeyParameters = ECCUtilsBCWrapper.readECParametersWithPublicKey(is);
    } catch (TlsFatalAlert alert) {
        throw new AdjustmentException("Problematic EC parameters, we dont support these yet", alert);
    } catch (IOException ex) {
        throw new AdjustmentException("EC public key parsing failed", ex);
    }
    CustomECPoint publicKey = new CustomECPoint(publicKeyParameters.getQ().getRawXCoord().toBigInteger(),
            publicKeyParameters.getQ().getRawYCoord().toBigInteger());
    tlsContext.setServerEcPublicKey(publicKey);
}
项目:gwt-crypto    文件:ECDHCBasicAgreement.java   
public BigInteger calculateAgreement(
    CipherParameters pubKey)
{
    ECPublicKeyParameters pub = (ECPublicKeyParameters)pubKey;
    ECDomainParameters params = pub.getParameters();

    BigInteger hd = params.getH().multiply(key.getD()).mod(params.getN());

    ECPoint P = pub.getQ().multiply(hd).normalize();

    if (P.isInfinity())
    {
        throw new IllegalStateException("Infinity is not a valid agreement value for ECDHC");
    }

    return P.getAffineXCoord().toBigInteger();
}
项目:gwt-crypto    文件:ECNewPublicKeyTransform.java   
/**
 * initialise the EC Elgamal engine.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
项目:gwt-crypto    文件:ECElGamalEncryptor.java   
/**
 * initialise the encryptor.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
项目:gwt-crypto    文件:DSTU4145Signer.java   
public void init(boolean forSigning, CipherParameters param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            param = rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
        }

        this.key = (ECPrivateKeyParameters)param;
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }

}
项目:gwt-crypto    文件:ECNRSigner.java   
public void init(
    boolean          forSigning, 
    CipherParameters param) 
{
    this.forSigning = forSigning;

    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
项目:gwt-crypto    文件:ECGOST3410Signer.java   
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
项目:Aki-SSL    文件:BCECGOST3410PublicKey.java   
public BCECGOST3410PublicKey(
    String algorithm,
    ECPublicKeyParameters params,
    ECParameterSpec spec)
{
    ECDomainParameters dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:Aki-SSL    文件:BCECPublicKey.java   
public BCECPublicKey(
    String algorithm,
    ECPublicKeyParameters params,
    ECParameterSpec spec,
    ProviderConfiguration configuration)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }

    this.configuration = configuration;
}
项目:Aki-SSL    文件:JCEECPublicKey.java   
public JCEECPublicKey(
    String                  algorithm,
    ECPublicKeyParameters   params,
    ECParameterSpec         spec)
{
    ECDomainParameters      dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:Aki-SSL    文件:ECDHCBasicAgreement.java   
public BigInteger calculateAgreement(
    CipherParameters pubKey)
{
    ECPublicKeyParameters pub = (ECPublicKeyParameters)pubKey;
    ECDomainParameters params = pub.getParameters();

    BigInteger hd = params.getH().multiply(key.getD()).mod(params.getN());

    ECPoint P = pub.getQ().multiply(hd).normalize();

    if (P.isInfinity())
    {
        throw new IllegalStateException("Infinity is not a valid agreement value for ECDHC");
    }

    return P.getAffineXCoord().toBigInteger();
}
项目:Aki-SSL    文件:ECNewPublicKeyTransform.java   
/**
 * initialise the EC Elgamal engine.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for new public key transform.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
项目:Aki-SSL    文件:ECElGamalEncryptor.java   
/**
 * initialise the encryptor.
 *
 * @param param the necessary EC key parameters.
 */
public void init(
    CipherParameters    param)
{
    if (param instanceof ParametersWithRandom)
    {
        ParametersWithRandom    p = (ParametersWithRandom)param;

        if (!(p.getParameters() instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }
        this.key = (ECPublicKeyParameters)p.getParameters();
        this.random = p.getRandom();
    }
    else
    {
        if (!(param instanceof ECPublicKeyParameters))
        {
            throw new IllegalArgumentException("ECPublicKeyParameters are required for encryption.");
        }

        this.key = (ECPublicKeyParameters)param;
        this.random = new SecureRandom();
    }
}
项目:Aki-SSL    文件:DSTU4145Signer.java   
public void init(boolean forSigning, CipherParameters param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            param = rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
        }

        this.key = (ECPrivateKeyParameters)param;
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }

}
项目:Aki-SSL    文件:ECNRSigner.java   
public void init(
    boolean          forSigning, 
    CipherParameters param) 
{
    this.forSigning = forSigning;

    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
项目:Aki-SSL    文件:ECGOST3410Signer.java   
public void init(
    boolean                 forSigning,
    CipherParameters        param)
{
    if (forSigning)
    {
        if (param instanceof ParametersWithRandom)
        {
            ParametersWithRandom    rParam = (ParametersWithRandom)param;

            this.random = rParam.getRandom();
            this.key = (ECPrivateKeyParameters)rParam.getParameters();
        }
        else
        {
            this.random = new SecureRandom();
            this.key = (ECPrivateKeyParameters)param;
        }
    }
    else
    {
        this.key = (ECPublicKeyParameters)param;
    }
}
项目:Aki-SSL    文件:BCDSTU4145PublicKey.java   
public BCDSTU4145PublicKey(
    String algorithm,
    ECPublicKeyParameters params,
    ECParameterSpec spec)
{
    ECDomainParameters dp = params.getParameters();

    this.algorithm = algorithm;
    this.q = params.getQ();

    if (spec == null)
    {
        EllipticCurve ellipticCurve = EC5Util.convertCurve(dp.getCurve(), dp.getSeed());

        this.ecSpec = createSpec(ellipticCurve, dp);
    }
    else
    {
        this.ecSpec = spec;
    }
}
项目:mDL-ILP    文件:ECKABasicAgreement.java   
public ECPoint calculatePoint(CipherParameters pubKey) {
    ECPublicKeyParameters pub = (ECPublicKeyParameters) pubKey;
    ECPoint P = pub.getQ().multiply(key.getD()).normalize();

    if (P.isInfinity()) {
        throw new IllegalStateException("Infinity is not a valid agreement value for ECDH");
    }
    return P;
}
项目:mDL-ILP    文件:ECKABasicAgreement.java   
public ECPoint calculatePoint(CipherParameters pubKey) {
    ECPublicKeyParameters pub = (ECPublicKeyParameters) pubKey;
    ECPoint P = pub.getQ().multiply(key.getD()).normalize();

    if (P.isInfinity()) {
        throw new IllegalStateException("Infinity is not a valid agreement value for ECDH");
    }
    return P;
}
项目:ipack    文件:JCEECPublicKey.java   
public JCEECPublicKey(
    String                  algorithm,
    ECPublicKeyParameters   params)
{
    this.algorithm = algorithm;
    this.q = params.getQ();
    this.ecSpec = null;
}
项目:ipack    文件:TlsECCUtils.java   
public static ECPublicKeyParameters deserializeECPublicKey(short[] ecPointFormats, ECDomainParameters curve_params,
                                                           byte[] encoding)
    throws IOException
{

    try
    {
        ECPoint Y = deserializeECPoint(ecPointFormats, curve_params.getCurve(), encoding);
        return new ECPublicKeyParameters(Y, curve_params);
    }
    catch (RuntimeException e)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
}
项目:ipack    文件:TlsECCUtils.java   
public static byte[] calculateECDHBasicAgreement(ECPublicKeyParameters publicKey, ECPrivateKeyParameters privateKey)
{

    ECDHBasicAgreement basicAgreement = new ECDHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 4492 5.10. Note that this octet string (Z in IEEE 1363 terminology) as output by
     * FE2OSP, the Field Element to Octet String Conversion Primitive, has constant length for
     * any given field; leading zeros found in this octet string MUST NOT be truncated.
     */
    return BigIntegers.asUnsignedByteArray(basicAgreement.getFieldSize(), agreementValue);
}
项目:ipack    文件:ECDHBasicAgreement.java   
public BigInteger calculateAgreement(
    CipherParameters pubKey)
{
    ECPublicKeyParameters pub = (ECPublicKeyParameters)pubKey;
    ECPoint P = pub.getQ().multiply(key.getD());

    // if (p.isInfinity()) throw new RuntimeException("d*Q == infinity");

    return P.getX().toBigInteger();
}
项目:ipack    文件:ECDHCBasicAgreement.java   
public BigInteger calculateAgreement(
    CipherParameters pubKey)
{
    ECPublicKeyParameters   pub = (ECPublicKeyParameters)pubKey;
    ECDomainParameters      params = pub.getParameters();
    ECPoint P = pub.getQ().multiply(params.getH().multiply(key.getD()));

    // if (p.isInfinity()) throw new RuntimeException("Invalid public key");

    return P.getX().toBigInteger();
}