Package gnu.javax.crypto.key.dh

Examples of gnu.javax.crypto.key.dh.GnuDHKeyPairGenerator


  {
    map = new HashMap();
    map.put(GnuDHKeyPairGenerator.PRIME_SIZE, new Integer(512));
    map.put(GnuDHKeyPairGenerator.EXPONENT_SIZE, new Integer(160));

    kpg = new GnuDHKeyPairGenerator();
    kpg.setup(map);
  }
View Full Code Here


public class TestOfDHKeyGeneration implements Testlet
{
  public void test(TestHarness harness)
  {
    harness.checkPoint("TestOfDHKeyGeneration");
    GnuDHKeyPairGenerator kpg = new GnuDHKeyPairGenerator();
    HashMap map = new HashMap();
    map.put(GnuDHKeyPairGenerator.PRIME_SIZE, new Integer(530));

    try
      {
        kpg.setup(map);
        harness.fail("L should be <= 1024 and of the form 512 + 64n");
      }
    catch (IllegalArgumentException x)
      {
        harness.check(true, "L should be <= 1024 and of the form 512 + 64n");
      }

    map.put(GnuDHKeyPairGenerator.PRIME_SIZE, new Integer(512));
    map.put(GnuDHKeyPairGenerator.EXPONENT_SIZE, new Integer(160));
    kpg.setup(map);
    KeyPair kp = kpg.generate();

    BigInteger p1 = ((GnuDHPublicKey) kp.getPublic()).getParams().getP();
    BigInteger p2 = ((GnuDHPrivateKey) kp.getPrivate()).getParams().getP();
    harness.check(p1.equals(p2), "p1.equals(p2)");
View Full Code Here

TOP

Related Classes of gnu.javax.crypto.key.dh.GnuDHKeyPairGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.