DHParameterSpec getG - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DHParameterSpec getG method.

This code example shows how to use the following methods:getG, getL, getP
        } 
        else 
        { 
            DHParameterSpec dhParams = (DHParameterSpec)params;
 
            param = new ElGamalKeyGenerationParameters(random, new ElGamalParameters(dhParams.getP(), dhParams.getG(), dhParams.getL()));
        } 
 
        engine.init(param);
        initialised = true;
    } 
 
    public KeyPair generateKeyPair()
    { 
        if (!initialised)
        { 
            DHParameterSpec dhParams = BouncyCastleProvider.CONFIGURATION.getDHDefaultParameters(strength);
 
            if (dhParams != null)
            { 
7
CodeRank
This code example shows how to use the following methods:getG, getL, getP
    private void writeObject( 
        ObjectOutputStream  out)
        throws IOException 
    { 
        out.writeObject(this.getY());
        out.writeObject(dhSpec.getP());
        out.writeObject(dhSpec.getG());
        out.writeInt(dhSpec.getL());
    } 
} 
7
CodeRank
This code example shows how to use the following methods:getG, getL, getP
    private void writeObject( 
        ObjectOutputStream  out)
        throws IOException 
    { 
        out.writeObject(this.getX());
        out.writeObject(dhSpec.getP());
        out.writeObject(dhSpec.getG());
        out.writeInt(dhSpec.getL());
    } 
 
    public void setBagAttribute( 
        ASN1ObjectIdentifier oid,
        ASN1Encodable attribute)
    { 
        attrCarrier.setBagAttribute(oid, attribute);
    } 
 
    public ASN1Encodable getBagAttribute( 
        ASN1ObjectIdentifier oid)
    { 
7
CodeRank
This code example shows how to use the following methods:getG, getP
        } 
        else 
        { 
            DHParameterSpec s = (DHParameterSpec)paramSpec;
 
            this.currentSpec = new ElGamalParameterSpec(s.getP(), s.getG());
        } 
    } 
 
    protected void engineInit( 
        byte[] params)
        throws IOException 
    { 
        try 
        { 
            ElGamalParameter elP = new ElGamalParameter((ASN1Sequence)ASN1Primitive.fromByteArray(params));
 
            currentSpec = new ElGamalParameterSpec(elP.getP(), elP.getG());
        } 
        catch (ClassCastException e)
6
CodeRank
This code example shows how to use the following methods:getG, getL, getP
        { 
            throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec");
        } 
        DHParameterSpec dhParams = (DHParameterSpec)params;
 
        param = new DHKeyGenerationParameters(random, new DHParameters(dhParams.getP(), dhParams.getG(), null, dhParams.getL()));
 
        engine.init(param);
        initialised = true;
    } 
 
    public KeyPair generateKeyPair()
    { 
        if (!initialised)
        { 
            Integer paramStrength = Integers.valueOf(strength);
 
            if (params.containsKey(paramStrength))
            { 
                param = (DHKeyGenerationParameters)params.get(paramStrength);
6
CodeRank
This code example shows how to use the following methods:getG
        int         privateValueSize,
        BigInteger  g,
        BigInteger  p)
        throws Exception 
    { 
        DHParameterSpec  elParams = new DHParameterSpec(p, g, privateValueSize);
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("ElGamal", "BC");
        byte[]           in = "This is a test".getBytes();
 
        keyGen.initialize(elParams);
         
        KeyPair         keyPair = keyGen.generateKeyPair();
        SecureRandom    rand = new SecureRandom();
 
        checkKeySize(privateValueSize, keyPair);
 
        Cipher  cipher = Cipher.getInstance("ElGamal", "BC");
         
        cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic(), rand);
         

5
CodeRank
This code example shows how to use the following methods:getG, getL, getP
        { 
            throw new InvalidAlgorithmParameterException("parameter object not a DHParameterSpec");
        } 
        DHParameterSpec dhParams = (DHParameterSpec)params;
 
        param = new DHKeyGenerationParameters(random, new DHParameters(dhParams.getP(), dhParams.getG(), null, dhParams.getL()));
 
        engine.init(param);
        initialised = true;
    } 
 
    public KeyPair generateKeyPair()
    { 
        if (!initialised)
        { 
            Integer paramStrength = Integers.valueOf(strength);
 
            if (params.containsKey(paramStrength))
            { 
                param = (DHKeyGenerationParameters)params.get(paramStrength);
7
CodeRank
This code example shows how to use the following methods:getG, getP
        int         privateValueSize,
        BigInteger  g,
        BigInteger  p)
        throws Exception 
    { 
        DHParameterSpec             dhParams = new DHParameterSpec(p, g, privateValueSize);
 
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algName, "BC");
 
        keyGen.initialize(dhParams);
 
        testTwoParty(algName, size, privateValueSize, keyGen);
 
        KeyPair aKeyPair = keyGen.generateKeyPair();
 
        // 
        // public key encoding test 
        // 
        byte[]              pubEnc = aKeyPair.getPublic().getEncoded();
        KeyFactory          keyFac = KeyFactory.getInstance(algName, "BC");

5
CodeRank
This code example shows how to use the following methods:getG, getP
DHParameterSpec parameterSpec = DiffieHellmanSession.getDefaultParameter();
 
        assertNotNull(parameterSpec);
 
        assertEquals(2, parameterSpec.getG().intValue());
        assertEquals(DiffieHellmanSession.DEFAULT_MODULUS_HEX.length() * 4, parameterSpec.getP().bitLength());
    } 
 
    public void testGetDefaultParameterSha256() throws Exception 
    { 
        DHParameterSpec parameterSpec = DiffieHellmanSession.getDefaultParameter();
 
        assertNotNull(parameterSpec);
 
        assertEquals(2, parameterSpec.getG().intValue());
        assertEquals(DiffieHellmanSession.DEFAULT_MODULUS_HEX.length() * 4, parameterSpec.getP().bitLength());
    } 
 
    public void testGenerateRandomParameterSha1() throws Exception 

5
CodeRank
This code example shows how to use the following methods:getG, getL, getP
  { 
    if (! (spec instanceof DHParameterSpec))
      throw new InvalidParameterSpecException("Wrong AlgorithmParameterSpec type: "
                                              + spec.getClass().getName());
    DHParameterSpec dhSpec = (DHParameterSpec) spec;
    p = dhSpec.getP();
    g = dhSpec.getG();
    l = dhSpec.getL();
  } 
 
  /** 
   * Decodes the set of DH parameters as per RFC-2459; i.e. the DER-encoded 
   * form of the following ASN.1 construct: 
   * 
   * <pre> 
   *   DhParams ::= SEQUENCE { 
   *     p  INTEGER, -- odd prime, p=jq +1 
   *     g  INTEGER, -- generator, g 
   *     q  INTEGER  -- factor of p-1 
   *   } 
6
CodeRank
getG Method Overview
Returns the base generator of this parameter specification.
See Code Examples for other Java 8 DHParameterSpec Methods: