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


Java DHParameters.getG方法代码示例

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


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

示例1: validateDHPublicKey

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public static DHPublicKeyParameters validateDHPublicKey(DHPublicKeyParameters key)
    throws IOException
{
    BigInteger Y = key.getY();
    DHParameters params = key.getParameters();
    BigInteger p = params.getP();
    BigInteger g = params.getG();

    if (!p.isProbablePrime(2))
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (g.compareTo(TWO) < 0 || g.compareTo(p.subtract(TWO)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (Y.compareTo(TWO) < 0 || Y.compareTo(p.subtract(ONE)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    // TODO See RFC 2631 for more discussion of Diffie-Hellman validation

    return key;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:26,代码来源:TlsDHUtils.java

示例2: generateKeyPair

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
  {
      BigInteger      p, g, x, y;
      int             qLength = param.getStrength() - 1;
      DHParameters    dhParams = param.getParameters();

      p = dhParams.getP();
      g = dhParams.getG();
  
      //
      // calculate the private key
      //
x = new BigInteger(qLength, param.getRandom());

      //
      // calculate the public key.
      //
      y = g.modPow(x, p);

      return new AsymmetricCipherKeyPair(
              new DHPublicKeyParameters(y, dhParams),
              new DHPrivateKeyParameters(x, dhParams));
  }
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:24,代码来源:DHKeyPairGenerator.java

示例3: generateKeyPair

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public AsymmetricCipherKeyPair generateKeyPair()
  {
      BigInteger      p, g, x, y;
      int             qLength = param.getStrength() - 1;
      DHParameters    dhParams = param.getParameters();

      p = dhParams.getP();
      g = dhParams.getG();
 
      //
      // calculate the private key
      //
x = new BigInteger(qLength, param.getRandom());

      //
      // calculate the public key.
      //
      y = g.modPow(x, p);

      return new AsymmetricCipherKeyPair(
              new DHPublicKeyParameters(y, dhParams),
              new DHPrivateKeyParameters(x, dhParams));
  }
 
开发者ID:thangbn,项目名称:Direct-File-Downloader,代码行数:24,代码来源:DHBasicKeyPairGenerator.java

示例4: validateDHParameters

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public static DHParameters validateDHParameters(DHParameters params) throws IOException
{
    BigInteger p = params.getP();
    BigInteger g = params.getG();

    if (!p.isProbablePrime(2))
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (g.compareTo(TWO) < 0 || g.compareTo(p.subtract(TWO)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    return params;
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:17,代码来源:TlsDHUtils.java

示例5: validateDHPublicKey

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public static DHPublicKeyParameters validateDHPublicKey(DHPublicKeyParameters key) throws IOException
{
    BigInteger Y = key.getY();
    DHParameters params = key.getParameters();
    BigInteger p = params.getP();
    BigInteger g = params.getG();

    if (!p.isProbablePrime(2))
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (g.compareTo(TWO) < 0 || g.compareTo(p.subtract(TWO)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (Y.compareTo(TWO) < 0 || Y.compareTo(p.subtract(TWO)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    // TODO See RFC 2631 for more discussion of Diffie-Hellman validation

    return key;
}
 
开发者ID:redfish64,项目名称:TinyTravelTracker,代码行数:25,代码来源:TlsDHUtils.java

示例6: validateDHPublicKey

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public static DHPublicKeyParameters validateDHPublicKey(DHPublicKeyParameters key) throws IOException
{
    BigInteger Y = key.getY();
    DHParameters params = key.getParameters();
    BigInteger p = params.getP();
    BigInteger g = params.getG();

    if (!p.isProbablePrime(2))
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (g.compareTo(TWO) < 0 || g.compareTo(p.subtract(TWO)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }
    if (Y.compareTo(TWO) < 0 || Y.compareTo(p.subtract(ONE)) > 0)
    {
        throw new TlsFatalAlert(AlertDescription.illegal_parameter);
    }

    // TODO See RFC 2631 for more discussion of Diffie-Hellman validation

    return key;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:25,代码来源:TlsDHUtils.java

示例7: generateParameters

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public CramerShoupParameters generateParameters(DHParameters dhParams)
{
    BigInteger p = dhParams.getP();
    BigInteger g1 = dhParams.getG();

    // now we just need a second generator
    BigInteger g2 = ParametersHelper.selectGenerator(p, random);
    while (g1.equals(g2))
    {
        g2 = ParametersHelper.selectGenerator(p, random);
    }

    return new CramerShoupParameters(p, g1, g2, new SHA256Digest());
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:15,代码来源:CramerShoupParametersGenerator.java

示例8: testWithRandomParams

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
private void testWithRandomParams(int bits) throws CryptoException
{
    DHParametersGenerator paramGen = new DHParametersGenerator();
    paramGen.init(bits, 25, random);
    DHParameters parameters = paramGen.generateParameters();

    BigInteger g = parameters.getG();
    BigInteger p = parameters.getP();

    testMutualVerification(p, g);
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:12,代码来源:SRP6Test.java

示例9: validateDHPublicKey

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
private DHPublicKeyParameters validateDHPublicKey(DHPublicKeyParameters key) throws IOException
{
    BigInteger Y = key.getY();
    DHParameters params = key.getParameters();
    BigInteger p = params.getP();
    BigInteger g = params.getG();

    if (!p.isProbablePrime(2))
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_illegal_parameter);
    }
    if (g.compareTo(TWO) < 0 || g.compareTo(p.subtract(TWO)) > 0)
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_illegal_parameter);
    }
    if (Y.compareTo(TWO) < 0 || Y.compareTo(p.subtract(ONE)) > 0)
    {
        handler.failWithError(TlsProtocolHandler.AL_fatal,
            TlsProtocolHandler.AP_illegal_parameter);
    }

    // TODO See RFC 2631 for more discussion of Diffie-Hellman validation

    return key;
}
 
开发者ID:coova,项目名称:jradius,代码行数:28,代码来源:TlsDHKeyExchange.java

示例10: PaceDH

import org.bouncycastle.crypto.params.DHParameters; //导入方法依赖的package包/类
public PaceDH(DHParameters dhParameters) {
	g = dhParameters.getG();
	p = dhParameters.getP();
	Random rnd = new Random();
	randomGenerator.setSeed(rnd.nextLong());
}
 
开发者ID:tsenger,项目名称:animamea,代码行数:7,代码来源:PaceDH.java


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