• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DHBasicKeyPairGenerator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testBounds

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入依赖的package包/类
private void testBounds()
{
     BigInteger p1 = new BigInteger("00C8028E9151C6B51BCDB35C1F6B2527986A72D8546AE7A4BF41DC4289FF9837EE01592D36C324A0F066149B8B940C86C87D194206A39038AE3396F8E12435BB74449B70222D117B8A2BB77CB0D67A5D664DDE7B75E0FEC13CE0CAF258DAF3ADA0773F6FF0F2051D1859929AAA53B07809E496B582A89C3D7DA8B6E38305626621", 16);
     BigInteger g1 = new BigInteger("1F869713181464577FE4026B47102FA0D7675503A4FCDA810881FAEC3524E6DBAEA9B96561EF7F8BEA76466DF11C2F3EB1A90CC5851735BF860606481257EECE6418C0204E61004E85D7131CE54BCBC7AD67E53C79DCB715E7C8D083DCD85D728283EC8F96839B4C9FA7C0727C472BEB94E4613CAFA8D580119C0AF4BF8AF252", 16);
     int l1 = 1023;

     BigInteger p2 = new BigInteger("00B333C98720220CC3946F494E25231B3E19F9AD5F6B19F4E7ABF80D8826C491C3224D4F7415A14A7C11D1BE584405FED12C3554F103E56A72D986CA5E325BB9DE07AC37D1EAE5E5AC724D32EF638F0E4462D4C1FC7A45B9FD3A5DF5EC36A1FA4DAA3FBB66AA42B1B71DF416AB547E987513426C7BB8634F5F4D37705514FDC1E1", 16);
     BigInteger g2 = new BigInteger("2592F5A99FE46313650CCE66C94C15DBED9F4A45BD05C329986CF5D3E12139F0405A47C6385FEA27BFFEDC4CBABC5BB151F3BEE7CC3D51567F1E2B12A975AA9F48A70BDAAE7F5B87E70ADCF902490A3CBEFEDA41EBA8E12E02B56120B5FDEFBED07F5EAD3AE020DF3C8233216F8F0D35E13A7AE4DA5CBCC0D91EADBF20C281C6", 16);
     int l2 = 1024;

    DHKeyGenerationParameters   params1 = new DHKeyGenerationParameters(new SecureRandom(), new DHParameters(p1, g1, null, l1));
    DHKeyGenerationParameters   params2 = new DHKeyGenerationParameters(new SecureRandom(), new DHParameters(p2, g2, null, l2));

    DHBasicKeyPairGenerator     kpGen = new DHBasicKeyPairGenerator();

    kpGen.init(params1);
    kpGen.init(params2);
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:19,代码来源:DHTest.java


示例2: 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


示例3: 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


示例4: 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


示例5: getDHBasicKeyPairGenerator

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入依赖的package包/类
private DHBasicKeyPairGenerator getDHBasicKeyPairGenerator(
    BigInteger g,
    BigInteger p,
    int        privateValueSize)
{
    DHParameters                dhParams = new DHParameters(p, g, null, privateValueSize);
    DHKeyGenerationParameters   params = new DHKeyGenerationParameters(new SecureRandom(), dhParams);
    DHBasicKeyPairGenerator     kpGen = new DHBasicKeyPairGenerator();

    kpGen.init(params);
    
    return kpGen;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:14,代码来源:DHTest.java


示例6: createAsymmetricCipherKeyPairGenerator

import org.bouncycastle.crypto.generators.DHBasicKeyPairGenerator; //导入依赖的package包/类
@Override
	public AsymmetricCipherKeyPairGenerator createAsymmetricCipherKeyPairGenerator(final boolean initWithDefaults)
	{
		final DHBasicKeyPairGenerator generator = new DHBasicKeyPairGenerator();

		// TODO implement meaningful and secure defaults!
		if (initWithDefaults)
			throw new UnsupportedOperationException("NYI: initWithDefaults");
//		if (initWithDefaults)
//			generator.init(new DHKeyGenerationParameters(new SecureRandom(), new DHParameters(p, g, q)));

		return generator;
	}
 
开发者ID:subshare,项目名称:subshare,代码行数:14,代码来源:DHBasicKeyPairGeneratorFactory.java


示例7: 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


示例8: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AvaticaUtils类代码示例发布时间:2022-05-22
下一篇:
Java OWLModelManagerListener类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap