Java 类org.bouncycastle.crypto.agreement.ECMQVBasicAgreement 实例源码

项目:gwt-crypto    文件:ECTest.java   
private static BigInteger calculateAgreement(
    AsymmetricCipherKeyPair U1,
    AsymmetricCipherKeyPair U2,
    AsymmetricCipherKeyPair V1,
    AsymmetricCipherKeyPair V2)
{
    ECMQVBasicAgreement u = new ECMQVBasicAgreement();
    u.init(new MQVPrivateParameters(
        (ECPrivateKeyParameters)U1.getPrivate(),
        (ECPrivateKeyParameters)U2.getPrivate(),
        (ECPublicKeyParameters)U2.getPublic()));
    BigInteger ux = u.calculateAgreement(new MQVPublicParameters(
        (ECPublicKeyParameters)V1.getPublic(),
        (ECPublicKeyParameters)V2.getPublic()));

    ECMQVBasicAgreement v = new ECMQVBasicAgreement();
    v.init(new MQVPrivateParameters(
        (ECPrivateKeyParameters)V1.getPrivate(),
        (ECPrivateKeyParameters)V2.getPrivate(),
        (ECPublicKeyParameters)V2.getPublic()));
    BigInteger vx = v.calculateAgreement(new MQVPublicParameters(
        (ECPublicKeyParameters)U1.getPublic(),
        (ECPublicKeyParameters)U2.getPublic()));

    if (ux.equals(vx))
    {
        return ux;
    }

    return null;
}
项目:irma_future_id    文件:ECTest.java   
private static BigInteger calculateAgreement(
    AsymmetricCipherKeyPair U1,
    AsymmetricCipherKeyPair U2,
    AsymmetricCipherKeyPair V1,
    AsymmetricCipherKeyPair V2)
{
    ECMQVBasicAgreement u = new ECMQVBasicAgreement();
    u.init(new MQVPrivateParameters(
        (ECPrivateKeyParameters)U1.getPrivate(),
        (ECPrivateKeyParameters)U2.getPrivate(),
        (ECPublicKeyParameters)U2.getPublic()));
    BigInteger ux = u.calculateAgreement(new MQVPublicParameters(
        (ECPublicKeyParameters)V1.getPublic(),
        (ECPublicKeyParameters)V2.getPublic()));

    ECMQVBasicAgreement v = new ECMQVBasicAgreement();
    v.init(new MQVPrivateParameters(
        (ECPrivateKeyParameters)V1.getPrivate(),
        (ECPrivateKeyParameters)V2.getPrivate(),
        (ECPublicKeyParameters)V2.getPublic()));
    BigInteger vx = v.calculateAgreement(new MQVPublicParameters(
        (ECPublicKeyParameters)U1.getPublic(),
        (ECPublicKeyParameters)U2.getPublic()));

    if (ux.equals(vx))
    {
        return ux;
    }

    return null;
}
项目:bc-java    文件:ECTest.java   
private static BigInteger calculateAgreement(
    AsymmetricCipherKeyPair U1,
    AsymmetricCipherKeyPair U2,
    AsymmetricCipherKeyPair V1,
    AsymmetricCipherKeyPair V2)
{
    ECMQVBasicAgreement u = new ECMQVBasicAgreement();
    u.init(new MQVPrivateParameters(
        (ECPrivateKeyParameters)U1.getPrivate(),
        (ECPrivateKeyParameters)U2.getPrivate(),
        (ECPublicKeyParameters)U2.getPublic()));
    BigInteger ux = u.calculateAgreement(new MQVPublicParameters(
        (ECPublicKeyParameters)V1.getPublic(),
        (ECPublicKeyParameters)V2.getPublic()));

    ECMQVBasicAgreement v = new ECMQVBasicAgreement();
    v.init(new MQVPrivateParameters(
        (ECPrivateKeyParameters)V1.getPrivate(),
        (ECPrivateKeyParameters)V2.getPrivate(),
        (ECPublicKeyParameters)V2.getPublic()));
    BigInteger vx = v.calculateAgreement(new MQVPublicParameters(
        (ECPublicKeyParameters)U1.getPublic(),
        (ECPublicKeyParameters)U2.getPublic()));

    if (ux.equals(vx))
    {
        return ux;
    }

    return null;
}
项目:ipack    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:ipack    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDF()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDFAndSharedInfo()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(new SHA1Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA224KDFAndSharedInfo()
{
    super("ECMQVwithSHA224KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(new SHA224Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA256KDFAndSharedInfo()
{
    super("ECMQVwithSHA256KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(new SHA256Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA384KDFAndSharedInfo()
{
    super("ECMQVwithSHA384KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(new SHA384Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA512KDFAndSharedInfo()
{
    super("ECMQVwithSHA512KDF", new ECMQVBasicAgreement(), new KDF2BytesGenerator(new SHA512Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA1CKDF()
{
    super("ECMQVwithSHA1CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(new SHA1Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA224CKDF()
{
    super("ECMQVwithSHA224CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(new SHA224Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA256CKDF()
{
    super("ECMQVwithSHA256CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(new SHA256Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA384CKDF()
{
    super("ECMQVwithSHA384CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(new SHA384Digest()));
}
项目:Aki-SSL    文件:KeyAgreementSpi.java   
public MQVwithSHA512CKDF()
{
    super("ECMQVwithSHA512CKDF", new ECMQVBasicAgreement(), new ConcatenationKDFGenerator(new SHA512Digest()));
}
项目:CryptMeme    文件:KeyAgreementSpi.java   
private void initFromKey(Key key)
    throws InvalidKeyException
{
    if (agreement instanceof ECMQVBasicAgreement)
    {
        if (!(key instanceof MQVPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(MQVPrivateKey.class) + " for initialisation");
        }

        MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
        ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
        ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());

        ECPublicKeyParameters ephemPubKey = null;
        if (mqvPrivKey.getEphemeralPublicKey() != null)
        {
            ephemPubKey = (ECPublicKeyParameters)
                ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
        }

        MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
        this.parameters = staticPrivKey.getParameters();

        // TODO Validate that all the keys are using the same parameters?

        agreement.init(localParams);
    }
    else
    {
        if (!(key instanceof PrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(ECPrivateKey.class) + " for initialisation");
        }

        ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key);
        this.parameters = privKey.getParameters();

        agreement.init(privKey);
    }
}
项目:CryptMeme    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:CryptMeme    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDF()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
private void initFromKey(Key key)
    throws InvalidKeyException
{
    if (agreement instanceof ECMQVBasicAgreement)
    {
        if (!(key instanceof MQVPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(MQVPrivateKey.class) + " for initialisation");
        }

        MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
        ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
        ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());

        ECPublicKeyParameters ephemPubKey = null;
        if (mqvPrivKey.getEphemeralPublicKey() != null)
        {
            ephemPubKey = (ECPublicKeyParameters)
                ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
        }

        MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
        this.parameters = staticPrivKey.getParameters();

        // TODO Validate that all the keys are using the same parameters?

        agreement.init(localParams);
    }
    else
    {
        if (!(key instanceof PrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(ECPrivateKey.class) + " for initialisation");
        }

        ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key);
        this.parameters = privKey.getParameters();

        agreement.init(privKey);
    }
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDF()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
private void initFromKey(Key key)
    throws InvalidKeyException
{
    if (agreement instanceof ECMQVBasicAgreement)
    {
        if (!(key instanceof MQVPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(MQVPrivateKey.class) + " for initialisation");
        }

        MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
        ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
        ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());

        ECPublicKeyParameters ephemPubKey = null;
        if (mqvPrivKey.getEphemeralPublicKey() != null)
        {
            ephemPubKey = (ECPublicKeyParameters)
                ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
        }

        MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
        this.parameters = staticPrivKey.getParameters();

        // TODO Validate that all the keys are using the same parameters?

        agreement.init(localParams);
    }
    else
    {
        if (!(key instanceof ECPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(ECPrivateKey.class) + " for initialisation");
        }

        ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key);
        this.parameters = privKey.getParameters();

        agreement.init(privKey);
    }
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:irma_future_id    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDF()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
}
项目:bc-java    文件:KeyAgreementSpi.java   
private void initFromKey(Key key)
    throws InvalidKeyException
{
    if (agreement instanceof ECMQVBasicAgreement)
    {
        if (!(key instanceof MQVPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(MQVPrivateKey.class) + " for initialisation");
        }

        MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
        ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
        ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());

        ECPublicKeyParameters ephemPubKey = null;
        if (mqvPrivKey.getEphemeralPublicKey() != null)
        {
            ephemPubKey = (ECPublicKeyParameters)
                ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
        }

        MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
        this.parameters = staticPrivKey.getParameters();

        // TODO Validate that all the keys are using the same parameters?

        agreement.init(localParams);
    }
    else
    {
        if (!(key instanceof PrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(ECPrivateKey.class) + " for initialisation");
        }

        ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key);
        this.parameters = privKey.getParameters();

        agreement.init(privKey);
    }
}
项目:bc-java    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:bc-java    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDF()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
}
项目:bc-java    文件:KeyAgreementSpi.java   
private void initFromKey(Key key)
    throws InvalidKeyException
{
    if (agreement instanceof ECMQVBasicAgreement)
    {
        if (!(key instanceof MQVPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(MQVPrivateKey.class) + " for initialisation");
        }

        MQVPrivateKey mqvPrivKey = (MQVPrivateKey)key;
        ECPrivateKeyParameters staticPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getStaticPrivateKey());
        ECPrivateKeyParameters ephemPrivKey = (ECPrivateKeyParameters)
            ECUtil.generatePrivateKeyParameter(mqvPrivKey.getEphemeralPrivateKey());

        ECPublicKeyParameters ephemPubKey = null;
        if (mqvPrivKey.getEphemeralPublicKey() != null)
        {
            ephemPubKey = (ECPublicKeyParameters)
                ECUtil.generatePublicKeyParameter(mqvPrivKey.getEphemeralPublicKey());
        }

        MQVPrivateParameters localParams = new MQVPrivateParameters(staticPrivKey, ephemPrivKey, ephemPubKey);
        this.parameters = staticPrivKey.getParameters();

        // TODO Validate that all the keys are using the same parameters?

        agreement.init(localParams);
    }
    else
    {
        if (!(key instanceof ECPrivateKey))
        {
            throw new InvalidKeyException(kaAlgorithm + " key agreement requires "
                + getSimpleName(ECPrivateKey.class) + " for initialisation");
        }

        ECPrivateKeyParameters privKey = (ECPrivateKeyParameters)ECUtil.generatePrivateKeyParameter((PrivateKey)key);
        this.parameters = privKey.getParameters();

        agreement.init(privKey);
    }
}
项目:bc-java    文件:KeyAgreementSpi.java   
public MQV()
{
    super("ECMQV", new ECMQVBasicAgreement(), null);
}
项目:bc-java    文件:KeyAgreementSpi.java   
public MQVwithSHA1KDF()
{
    super("ECMQVwithSHA1KDF", new ECMQVBasicAgreement(), new ECDHKEKGenerator(new SHA1Digest()));
}