当前位置: 首页>>代码示例>>Java>>正文


Java DHBasicKeyPairGenerator.generateKeyPair方法代码示例

本文整理汇总了Java中org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator.generateKeyPair方法的典型用法代码示例。如果您正苦于以下问题:Java DHBasicKeyPairGenerator.generateKeyPair方法的具体用法?Java DHBasicKeyPairGenerator.generateKeyPair怎么用?Java DHBasicKeyPairGenerator.generateKeyPair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator的用法示例。


在下文中一共展示了DHBasicKeyPairGenerator.generateKeyPair方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateClientKeyExchange

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入方法依赖的package包/类
public byte[] generateClientKeyExchange() throws IOException
    {
        // TODO RFC 2246 7.4.72
        /*
         * If the client certificate already contains a suitable Diffie-Hellman key, then
         * Yc is implicit and does not need to be sent again. In this case, the Client Key
         * Exchange message will be sent, but will be empty.
         */
//        return new byte[0];

        /*
         * Generate a keypair (using parameters from server key) and send the public value
         * to the server.
         */
        DHBasicKeyPairGenerator dhGen = new DHBasicKeyPairGenerator();
        dhGen.init(new DHKeyGenerationParameters(handler.getRandom(),
            dhAgreeServerPublicKey.getParameters()));
        this.dhAgreeClientKeyPair = dhGen.generateKeyPair();
        BigInteger Yc = ((DHPublicKeyParameters)dhAgreeClientKeyPair.getPublic()).getY();
        return BigIntegers.asUnsignedByteArray(Yc);
    }
 
开发者ID:coova,项目名称:jradius,代码行数:22,代码来源:TlsDHKeyExchange.java

示例2: generateDHKeyPair

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入方法依赖的package包/类
public static AsymmetricCipherKeyPair generateDHKeyPair(SecureRandom random,
                                                        DHParameters dhParams)
{
    DHBasicKeyPairGenerator dhGen = new DHBasicKeyPairGenerator();
    dhGen.init(new DHKeyGenerationParameters(random, dhParams));
    return dhGen.generateKeyPair();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:8,代码来源:TlsDHUtils.java

示例3: testSimpleWithRandom

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:36,代码来源:DHTest.java

示例4: generateDHKeyPair

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入方法依赖的package包/类
public static AsymmetricCipherKeyPair generateDHKeyPair(SecureRandom random, DHParameters dhParams)
{
    DHBasicKeyPairGenerator dhGen = new DHBasicKeyPairGenerator();
    dhGen.init(new DHKeyGenerationParameters(random, dhParams));
    return dhGen.generateKeyPair();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:7,代码来源:TlsDHUtils.java

示例5: testDHBasic

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入方法依赖的package包/类
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");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:44,代码来源:DHTest.java


注:本文中的org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator.generateKeyPair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。