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

项目:ipack    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey,
                                               DHPrivateKeyParameters privateKey)
{

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

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:ipack    文件:IESCipher.java   
public IESwithDESede()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new DESedeEngine())));
}
项目:ipack    文件:IESCipher.java   
public IESwithAES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new AESEngine())));
}
项目:ipack    文件:CipherSpi.java   
public IES()
{
    super(new IESEngine(
           new DHBasicAgreement(),
           new KDF2BytesGenerator(new SHA1Digest()),
           new HMac(new SHA1Digest())));
}
项目:gwt-crypto    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey)
{
    DHBasicAgreement basicAgreement = new DHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:gwt-crypto    文件:DHTest.java   
private void testSimpleWithRandom(
    DHBasicKeyPairGenerator kpGen)
{
    //
    // generate first pair
    //
    AsymmetricCipherKeyPair     pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu1 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv1 = (DHPrivateKeyParameters)pair.getPrivate();
    //
    // generate second pair
    //
    pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu2 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

    //
    // two way
    //
    DHBasicAgreement    e1 = new DHBasicAgreement();
    DHBasicAgreement    e2 = new DHBasicAgreement();

    e1.init(new ParametersWithRandom(pv1, new SecureRandom()));
    e2.init(new ParametersWithRandom(pv2, new SecureRandom()));

    BigInteger   k1 = e1.calculateAgreement(pu2);
    BigInteger   k2 = e2.calculateAgreement(pu1);

    if (!k1.equals(k2))
    {
        fail("basic with random 2-way test failed");
    }
}
项目:Aki-SSL    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey)
{
    DHBasicAgreement basicAgreement = new DHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:Aki-SSL    文件:IESCipher.java   
public IESwithDESede()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new DESedeEngine())));
}
项目:Aki-SSL    文件:IESCipher.java   
public IESwithAES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new AESEngine())));
}
项目:Aki-SSL    文件:IESCipher.java   
public OldIESwithCipher(BlockCipher baseCipher)
{
    super(new OldIESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(baseCipher)));
}
项目:TinyTravelTracker    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey)
{
    DHBasicAgreement basicAgreement = new DHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:CryptMeme    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey)
{
    DHBasicAgreement basicAgreement = new DHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:CryptMeme    文件:IESCipher.java   
public IESwithDESede()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new DESedeEngine())));
}
项目:CryptMeme    文件:IESCipher.java   
public IESwithAES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new AESEngine())));
}
项目:CryptMeme    文件:CipherSpi.java   
public IES()
{
    super(new IESEngine(
           new DHBasicAgreement(),
           new KDF2BytesGenerator(new SHA1Digest()),
           new HMac(new SHA1Digest())));
}
项目:irma_future_id    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey)
{
    DHBasicAgreement basicAgreement = new DHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:irma_future_id    文件:DHTest.java   
private void testSimpleWithRandom(
    DHBasicKeyPairGenerator kpGen)
{
    //
    // generate first pair
    //
    AsymmetricCipherKeyPair     pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu1 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv1 = (DHPrivateKeyParameters)pair.getPrivate();
    //
    // generate second pair
    //
    pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu2 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

    //
    // two way
    //
    DHBasicAgreement    e1 = new DHBasicAgreement();
    DHBasicAgreement    e2 = new DHBasicAgreement();

    e1.init(new ParametersWithRandom(pv1, new SecureRandom()));
    e2.init(new ParametersWithRandom(pv2, new SecureRandom()));

    BigInteger   k1 = e1.calculateAgreement(pu2);
    BigInteger   k2 = e2.calculateAgreement(pu1);

    if (!k1.equals(k2))
    {
        fail("basic with random 2-way test failed");
    }
}
项目:irma_future_id    文件:IESCipher.java   
public IESwithDESede()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new DESedeEngine())));
}
项目:irma_future_id    文件:IESCipher.java   
public IESwithAES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new AESEngine())));
}
项目:irma_future_id    文件:CipherSpi.java   
public IES()
{
    super(new IESEngine(
           new DHBasicAgreement(),
           new KDF2BytesGenerator(new SHA1Digest()),
           new HMac(new SHA1Digest())));
}
项目:bc-java    文件:TlsDHUtils.java   
public static byte[] calculateDHBasicAgreement(DHPublicKeyParameters publicKey, DHPrivateKeyParameters privateKey)
{
    DHBasicAgreement basicAgreement = new DHBasicAgreement();
    basicAgreement.init(privateKey);
    BigInteger agreementValue = basicAgreement.calculateAgreement(publicKey);

    /*
     * RFC 5246 8.1.2. Leading bytes of Z that contain all zero bits are stripped before it is
     * used as the pre_master_secret.
     */
    return BigIntegers.asUnsignedByteArray(agreementValue);
}
项目:bc-java    文件:DHTest.java   
private void testSimpleWithRandom(
    DHBasicKeyPairGenerator kpGen)
{
    //
    // generate first pair
    //
    AsymmetricCipherKeyPair     pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu1 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv1 = (DHPrivateKeyParameters)pair.getPrivate();
    //
    // generate second pair
    //
    pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu2 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

    //
    // two way
    //
    DHBasicAgreement    e1 = new DHBasicAgreement();
    DHBasicAgreement    e2 = new DHBasicAgreement();

    e1.init(new ParametersWithRandom(pv1, new SecureRandom()));
    e2.init(new ParametersWithRandom(pv2, new SecureRandom()));

    BigInteger   k1 = e1.calculateAgreement(pu2);
    BigInteger   k2 = e2.calculateAgreement(pu1);

    if (!k1.equals(k2))
    {
        fail("basic with random 2-way test failed");
    }
}
项目:bc-java    文件:IESCipher.java   
public IESwithDESede()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new DESedeEngine())));
}
项目:bc-java    文件:IESCipher.java   
public IESwithAES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest()),
        new PaddedBufferedBlockCipher(new AESEngine())));
}
项目:bc-java    文件:CipherSpi.java   
public IES()
{
    super(new IESEngine(
           new DHBasicAgreement(),
           new KDF2BytesGenerator(new SHA1Digest()),
           new HMac(new SHA1Digest())));
}
项目:jradius    文件:TlsDHKeyExchange.java   
public byte[] generatePremasterSecret() throws IOException
{
    /*
     * Diffie-Hellman basic key agreement
     */
    DHBasicAgreement dhAgree = new DHBasicAgreement();
    dhAgree.init(dhAgreeClientKeyPair.getPrivate());
    BigInteger agreement = dhAgree.calculateAgreement(dhAgreeServerPublicKey);
    return BigIntegers.asUnsignedByteArray(agreement);
}
项目:ipack    文件:IESCipher.java   
public IES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest())));
}
项目:gwt-crypto    文件:DHTest.java   
private void testDHBasic(
    int         size,
    int         privateValueSize,
    BigInteger  g,
    BigInteger  p)
{
    DHBasicKeyPairGenerator kpGen = getDHBasicKeyPairGenerator(g, p, privateValueSize);

    //
    // generate first pair
    //
    AsymmetricCipherKeyPair     pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu1 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv1 = (DHPrivateKeyParameters)pair.getPrivate();

    checkKeySize(privateValueSize, pv1);
    //
    // generate second pair
    //
    pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu2 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

    checkKeySize(privateValueSize, pv2);
    //
    // two way
    //
    DHBasicAgreement    e1 = new DHBasicAgreement();
    DHBasicAgreement    e2 = new DHBasicAgreement();

    e1.init(pv1);
    e2.init(pv2);

    BigInteger   k1 = e1.calculateAgreement(pu2);
    BigInteger   k2 = e2.calculateAgreement(pu1);

    if (!k1.equals(k2))
    {
        fail("basic " + size + " bit 2-way test failed");
    }
}
项目:Aki-SSL    文件:IESCipher.java   
public IES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest())));
}
项目:Aki-SSL    文件:IESCipher.java   
public OldIES()
{
    super(new OldIESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest())));
}
项目:CryptMeme    文件:IESCipher.java   
public IES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest())));
}
项目:irma_future_id    文件:DHTest.java   
private void testDHBasic(
    int         size,
    int         privateValueSize,
    BigInteger  g,
    BigInteger  p)
{
    DHBasicKeyPairGenerator kpGen = getDHBasicKeyPairGenerator(g, p, privateValueSize);

    //
    // generate first pair
    //
    AsymmetricCipherKeyPair     pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu1 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv1 = (DHPrivateKeyParameters)pair.getPrivate();

    checkKeySize(privateValueSize, pv1);
    //
    // generate second pair
    //
    pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu2 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

    checkKeySize(privateValueSize, pv2);
    //
    // two way
    //
    DHBasicAgreement    e1 = new DHBasicAgreement();
    DHBasicAgreement    e2 = new DHBasicAgreement();

    e1.init(pv1);
    e2.init(pv2);

    BigInteger   k1 = e1.calculateAgreement(pu2);
    BigInteger   k2 = e2.calculateAgreement(pu1);

    if (!k1.equals(k2))
    {
        fail("basic " + size + " bit 2-way test failed");
    }
}
项目:irma_future_id    文件:IESCipher.java   
public IES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest())));
}
项目:bc-java    文件:DHTest.java   
private void testDHBasic(
    int         size,
    int         privateValueSize,
    BigInteger  g,
    BigInteger  p)
{
    DHBasicKeyPairGenerator kpGen = getDHBasicKeyPairGenerator(g, p, privateValueSize);

    //
    // generate first pair
    //
    AsymmetricCipherKeyPair     pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu1 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv1 = (DHPrivateKeyParameters)pair.getPrivate();

    checkKeySize(privateValueSize, pv1);
    //
    // generate second pair
    //
    pair = kpGen.generateKeyPair();

    DHPublicKeyParameters       pu2 = (DHPublicKeyParameters)pair.getPublic();
    DHPrivateKeyParameters      pv2 = (DHPrivateKeyParameters)pair.getPrivate();

    checkKeySize(privateValueSize, pv2);
    //
    // two way
    //
    DHBasicAgreement    e1 = new DHBasicAgreement();
    DHBasicAgreement    e2 = new DHBasicAgreement();

    e1.init(pv1);
    e2.init(pv2);

    BigInteger   k1 = e1.calculateAgreement(pu2);
    BigInteger   k2 = e2.calculateAgreement(pu1);

    if (!k1.equals(k2))
    {
        fail("basic " + size + " bit 2-way test failed");
    }
}
项目:bc-java    文件:IESCipher.java   
public IES()
{
    super(new IESEngine(new DHBasicAgreement(),
        new KDF2BytesGenerator(new SHA1Digest()),
        new HMac(new SHA1Digest())));
}