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)");

    BigInteger q1 = ((GnuDHPublicKey) kp.getPublic()).getQ();
    BigInteger q2 = ((GnuDHPrivateKey) kp.getPrivate()).getQ();
    harness.check(q1.equals(q2), "q1.equals(q2)");

    BigInteger g1 = ((GnuDHPublicKey) kp.getPublic()).getParams().getG();
    BigInteger g2 = ((GnuDHPrivateKey) kp.getPrivate()).getParams().getG();
    harness.check(g1.equals(g2), "g1.equals(g2)");

    harness.check(Prime.isProbablePrime(p1), "p is probable prime");
  }
  public void test(final TestHarness harness) {
    harness.checkPoint("TestOfPrivateKeyring");
    final GnuPrivateKeyring kr = new GnuPrivateKeyring();
    try {
      final Map attributes = new HashMap();
      attributes.put(IKeyring.KEYRING_DATA_IN, new ByteArrayInputStream(keyring));
      attributes.put(IKeyring.KEYRING_PASSWORD, "password".toCharArray());

      // IMPORTANT:
      // the following relies on an X509 cert provider; which we're not.
      // GNU Classpath (gLibj.zip) is; you need to add it to the java
      // launcher classpath, and include the GNU provider ("GNU") before
      // exercising this code; eg:
      //
      //    Security.addProvider(new gnu.java.security.provider.Gnu());
      //
      //         kr.load(attributes);
      //         harness.check(true, "load(...)");
      //
      //         harness.check(kr.containsPrivateKey(ALIAS), "containsCertificate(...)");
      //
      //         final List list = kr.get(ALIAS);
      ////         System.out.println("list.size()="+list.size());
      //         harness.check(list.size() == 2, "get(...).size() == 2");
      //
      ////         for (java.util.Iterator it = list.listIterator(); it.hasNext(); ) {
      ////            System.out.println("*** "+it.next());
      ////         }
      //
      ////         final Key key = kr.getPrivateKey(ALIAS, "password".toCharArray());
      ////         harness.check(key != null, "getPrivateKey(...) != null");
      ////
      ////         System.out.println("key="+key);
      ////
      ////         final Certificate[] cp = kr.getCertPath(ALIAS);
      ////         harness.check(cp != null, "getCertPath(...) != null");
      ////         harness.check(cp.length != 0, "getCertPath(...).length != 0");

    } catch (Exception x) {
      harness.debug(x);
      harness.fail("TestOfPrivateKeyring");
    }
  }