,
+# finally setting variable _ACJNI_FOLLOWED
+# --------------------
+AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[
+# find the include directory relative to the javac executable
+_cur="$1"
+while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do
+ AC_MSG_CHECKING(symlink for $_cur)
+ _slink=`ls -ld "$_cur" | sed 's/.* -> //'`
+ case "$_slink" in
+ /*) _cur="$_slink";;
+ # 'X' avoids triggering unwanted echo options.
+ *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";;
+ esac
+ AC_MSG_RESULT($_cur)
+done
+_ACJNI_FOLLOWED="$_cur"
+])# _ACJNI
diff --git a/src/bin/vmgj-info.src b/src/bin/vmgj-info.src
new file mode 100644
index 0000000..4110465
--- /dev/null
+++ b/src/bin/vmgj-info.src
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+if test x$1 = x"bin";
+then
+ printf "M4_BINDIR"
+elif test x$1 = x"lib";
+then
+ printf "M4_LIBDIR"
+elif test x$1 = x"jar";
+then
+ printf "M4_VMGJ_JAR"
+elif test x$1 = x"version";
+then
+ printf "M4_VERSION"
+elif test x$1 = x"complete";
+then
+ printf "vmgj-M4_VERSION`('gmpmee-M4_GMPMEE_VERSION`)'"
+else
+ printf "Illegal parameter! (%s)\n" $1
+fi
diff --git a/src/java/com/verificatum/vmgj/BenchVMG.java b/src/java/com/verificatum/vmgj/BenchVMG.java
new file mode 100644
index 0000000..01eb313
--- /dev/null
+++ b/src/java/com/verificatum/vmgj/BenchVMG.java
@@ -0,0 +1,280 @@
+
+/*
+ * Copyright 2008-2018 Douglas Wikstrom
+ *
+ * This file is part of Verificatum Multiplicative Groups library for
+ * Java (VMGJ).
+ *
+ * VMGJ is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * VMGJ is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with VMGJ. If not, see
+ * .
+ */
+
+package com.verificatum.vmgj;
+
+import java.math.BigInteger;
+import java.security.SecureRandom;
+
+// We use C style to name things in this file, since it should
+// correspond to the native code.
+
+//CHECKSTYLE.OFF: LocalVariableName
+//CHECKSTYLE.OFF: LocalFinalVariableName
+//CHECKSTYLE.OFF: MethodName
+//CHECKSTYLE.OFF: ParameterName
+
+/**
+ * Allows invoking the modular exponentiation, simultaneous modular
+ * exponentiation routines, primality tests, and related routines of
+ * the Gnu Multiprecision Library
+ * (GMP)and GMPMEE (a minor extension of GMP).
+ *
+ *
+ *
+ * @author Douglas Wikstrom
+ */
+@SuppressWarnings("PMD.MethodNamingConventions")
+public final class BenchVMG {
+
+ /**
+ * Avoid accidental instantiation.
+ */
+ private BenchVMG() {
+ }
+
+ /**
+ * Default number of seconds used for a timing.
+ */
+ static final int DEFAULT_SPEED_TIME = 2000;
+
+ /**
+ * Convenience method for bounding the execution time of a test.
+ *
+ * @param t Time when the test started.
+ * @param milliSecs Milliseconds the should proceed.
+ * @return True if the deadline has passed and false otherwise.
+ */
+ private static boolean done(final long t, final long milliSecs) {
+ return System.currentTimeMillis() > t + milliSecs;
+ }
+
+ /**
+ * Times exponentiation.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ * @return Number of exponentiations performed.
+ */
+ protected static long time_powm(final int bitLength, final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ final int len = 100;
+
+ // Generate random modulus.
+ BigInteger modulus = new BigInteger(bitLength, random);
+ modulus = modulus.setBit(bitLength - 1);
+
+ BigInteger basis = new BigInteger(bitLength, random);
+ basis = basis.setBit(bitLength - 1);
+
+ BigInteger[] exponents = new BigInteger[len];
+
+ for (int l = 0; l < len; l++) {
+ exponents[l] = new BigInteger(bitLength, random);
+ }
+
+ // Time optimized code.
+ final long t = System.currentTimeMillis();
+ long i = 0;
+ int l = 0;
+ while (!done(t, milliSecs)) {
+
+ VMG.powm(basis, exponents[l], modulus);
+
+ l = (l + 1) % len;
+
+ i++;
+ }
+ return i;
+ }
+
+ /**
+ * Times simultaneous exponentiation.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ * @return Number of simultaneous exponentiations performed.
+ */
+ protected static long time_spowm(final int bitLength,
+ final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ final int len = 100;
+
+ // Generate random modulus.
+ BigInteger modulus = new BigInteger(bitLength, random);
+ modulus = modulus.setBit(bitLength - 1);
+
+ final BigInteger[] bases = new BigInteger[len];
+ final BigInteger[] exponents = new BigInteger[len];
+
+ for (int l = 0; l < len; l++) {
+ bases[l] = new BigInteger(bitLength, random);
+ bases[l] = bases[l].setBit(bitLength - 1);
+
+ exponents[l] = new BigInteger(bitLength, random);
+ }
+
+ final long t = System.currentTimeMillis();
+
+ long i = 0;
+ while (!done(t, milliSecs)) {
+
+ VMG.spowm(bases, exponents, modulus);
+
+ i++;
+ }
+ return i * len;
+ }
+
+ /**
+ * Times fixed-basis exponentiation.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ * @return Number of fixed-basis exponentiations performed.
+ */
+ protected static long time_fpowm(final int bitLength,
+ final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ final int len = 100;
+
+ // Generate random modulus.
+ BigInteger modulus = new BigInteger(bitLength, random);
+ modulus = modulus.setBit(bitLength - 1);
+
+ BigInteger basis = new BigInteger(bitLength, random);
+ basis = basis.setBit(bitLength - 1);
+
+ final BigInteger[] exponents = new BigInteger[len];
+
+ for (int l = 0; l < len; l++) {
+ exponents[l] = new BigInteger(bitLength, random);
+ }
+
+ final FpowmTab tab = new FpowmTab(basis, modulus, bitLength);
+
+ // Time optimized code.
+ final long t = System.currentTimeMillis();
+ long i = 0;
+ int l = 0;
+ while (!done(t, milliSecs)) {
+
+ tab.fpowm(exponents[l]);
+
+ l = (l + 1) % len;
+
+ i++;
+ }
+ return i;
+ }
+
+ /**
+ * Times modular arithmetic and prints the results.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ public static void time_modulus(final int bitLength, final int milliSecs) {
+
+ final String f =
+ "%nTiming modular arithmetic: %d bitlength (%d ms/function)";
+
+ System.out.println(String.format(f, bitLength, milliSecs));
+ System.out.println(
+ "----------------------------------------------------------------");
+
+ System.out.println(String.format("%12d exponentiations",
+ time_powm(bitLength, milliSecs)));
+ System.out.println(String.format("%12d simultaneous exponentiations",
+ time_spowm(bitLength, milliSecs)));
+ System.out.println(String.format("%12d fixed-basis exponentiations",
+ time_fpowm(bitLength, milliSecs)));
+ }
+
+ /**
+ * Prints usage information.
+ */
+ protected static void usage() {
+ System.out.println("Usage: vmgj.VMG [bitLength]... ");
+ }
+
+ /**
+ * Executes the timing routines.
+ *
+ * @param args Command line arguments.
+ */
+ public static void main(final String[] args) {
+
+ int[] bitLengths = new int[4];
+ bitLengths[0] = 1024;
+ bitLengths[1] = 2048;
+ bitLengths[2] = 3072;
+ bitLengths[3] = 4096;
+
+ if (args.length > 0) {
+
+ bitLengths = new int[args.length];
+ for (int i = 0; i < args.length; i++) {
+
+ try {
+ bitLengths[i] = Integer.parseInt(args[i]);
+ } catch (NumberFormatException nfe) {
+ usage();
+ System.exit(1);
+ }
+ }
+ }
+
+ final String s =
+"\n================================================================\n"
++ "\n BENCHMARKS FOR com.verificatum.vmgj.VMG \n\n"
++ "You need to consult the code understand exactly what is \n"
++ "measured before drawing any conclusions, but the benchmarks \n"
++ "are fairly self explanatory.\n"
++ "\n"
++ "The code makes calls to the GNU Multiple Precision Arithmetic\n"
++ "library (GMP) and GMP Modular Exponentiation Extension (VMG).\n"
++ "================================================================";
+
+ System.out.println(s);
+
+ for (int i = 0; i < bitLengths.length; i++) {
+
+ time_modulus(bitLengths[i], DEFAULT_SPEED_TIME);
+ }
+ System.out.println("");
+ }
+}
+//CHECKSTYLE.ON: LocalVariableName
+//CHECKSTYLE.ON: LocalFinalVariableName
+//CHECKSTYLE.ON: MethodName
+//CHECKSTYLE.ON: ParameterName
diff --git a/src/java/com/verificatum/vmgj/FpowmTab.java b/src/java/com/verificatum/vmgj/FpowmTab.java
new file mode 100644
index 0000000..571110b
--- /dev/null
+++ b/src/java/com/verificatum/vmgj/FpowmTab.java
@@ -0,0 +1,110 @@
+
+/*
+ * Copyright 2008-2018 Douglas Wikstrom
+ *
+ * This file is part of Verificatum Multiplicative Groups library for
+ * Java (VMGJ).
+ *
+ * VMGJ is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * VMGJ is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with VMGJ. If not, see
+ * .
+ */
+
+package com.verificatum.vmgj;
+
+import java.math.BigInteger;
+
+/**
+ * Provides a Java wrapper for a pointer to a native pre-computed
+ * table used for fixed based modular exponentiation as implemented in
+ * {@link VMG}.
+ *
+ * @author Douglas Wikstrom
+ */
+public class FpowmTab {
+
+ /**
+ * Stores native pointer to a precomputed fixed base
+ * exponentiation table.
+ */
+ protected long tablePtr;
+
+ /**
+ * Creates a precomputed table for the given basis, modulus, and
+ * exponent bit length.
+ *
+ * @param basis Basis element.
+ * @param modulus Modulus used during modular exponentiations.
+ * @param exponentBitlen Expected bit length of exponents used when
+ * invoking the table.
+ */
+ public FpowmTab(final BigInteger basis,
+ final BigInteger modulus,
+ final int exponentBitlen) {
+ this(basis, modulus, 16, exponentBitlen);
+ }
+
+ /**
+ * Creates a precomputed table for the given basis, modulus, and
+ * exponent bit length.
+ *
+ * @param basis Basis element.
+ * @param modulus Modulus used during modular exponentiations.
+ * @param blockWidth Number of basis elements used during
+ * splitting.
+ * @param exponentBitlen Expected bit length of exponents used when
+ * invoking the table.
+ */
+ public FpowmTab(final BigInteger basis,
+ final BigInteger modulus,
+ final int blockWidth,
+ final int exponentBitlen) {
+ tablePtr = VMG.fpowm_precomp(basis.toByteArray(),
+ modulus.toByteArray(),
+ blockWidth,
+ exponentBitlen);
+ }
+
+ /**
+ * Computes a modular exponentiation using the given exponent and
+ * the basis and modulus previously used to construct this table.
+ *
+ * @param exponent Exponent used in modular exponentiation.
+ * @return Power of basis for which pre-computation took place.
+ */
+ public BigInteger fpowm(final BigInteger exponent) {
+ return new BigInteger(VMG.fpowm(tablePtr,
+ exponent.toByteArray()));
+ }
+
+ /**
+ * Release resources allocated by native code.
+ */
+ public void free() {
+ if (tablePtr != 0) {
+ VMG.fpowm_clear(tablePtr);
+ tablePtr = 0;
+ }
+ }
+
+ /**
+ * This is optimistic, but we only allocate a fixed amount of
+ * memory and do not rely on this.
+ *
+ * @throws Throwable If this instance can not be finalized.
+ */
+ protected void finalize() throws Throwable {
+ free();
+ super.finalize();
+ }
+}
diff --git a/src/java/com/verificatum/vmgj/MillerRabin.java b/src/java/com/verificatum/vmgj/MillerRabin.java
new file mode 100644
index 0000000..501ef16
--- /dev/null
+++ b/src/java/com/verificatum/vmgj/MillerRabin.java
@@ -0,0 +1,156 @@
+
+/*
+ * Copyright 2008-2018 Douglas Wikstrom
+ *
+ * This file is part of Verificatum Multiplicative Groups library for
+ * Java (VMGJ).
+ *
+ * VMGJ is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * VMGJ is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with VMGJ. If not, see
+ * .
+ */
+
+package com.verificatum.vmgj;
+
+import java.math.BigInteger;
+
+/**
+ * Implements primality tests and safe-primality tests such that the
+ * caller provides the randomness. This allows a theoretically sound
+ * primality test in contrast to builtin routines. Interlacing and
+ * trial division is used in the test of safe primes, which speeds up
+ * searching drastically. Consult the native code for more
+ * information.
+ *
+ * @author Douglas Wikstrom
+ */
+public class MillerRabin {
+
+ /**
+ * Stores native pointer to state.
+ */
+ protected long statePtr;
+
+ /**
+ * Decides if we are checking primality or safe primality.
+ */
+ protected boolean primality;
+
+ /**
+ * Initializes the Miller-Rabin test for the given
+ * integers. Please use the method {@link #trial()} and read the
+ * comment.
+ *
+ * @param n Integer to test.
+ * @param primality Decides if we are checking primality or safe
+ * primality.
+ * @param search Decides if we are searching for an integer or testing.
+ */
+ public MillerRabin(final BigInteger n, final boolean primality,
+ final boolean search) {
+ if (n.compareTo(BigInteger.ZERO) <= 0) {
+ throw new ArithmeticException("Primality check of non-positive "
+ + "integer!");
+ }
+ this.primality = primality;
+ if (primality) {
+ statePtr = VMG.millerrabin_init(n.toByteArray(), search);
+ } else {
+ statePtr = VMG.millerrabin_safe_init(n.toByteArray(), search);
+ }
+ }
+
+ /**
+ * Returns the result of the trial divisions. {@link
+ * #once(BigInteger)} or {@link #done()} must not be called if this
+ * function returns false. Note that if this instance is created
+ * for searching, this will always return true
, since
+ * the constructor in that case moves to the first candidate
+ * integer that passes trial divisions.
+ *
+ * @return Returns true
or false
+ * depending on if the integer is found not to be a candidate
+ * after trial divisions.
+ */
+ public boolean trial() {
+ return statePtr != 0;
+ }
+
+ /**
+ * Increases the integer to the next candidate prime, or safe
+ * prime, depending on how this instance was created a candidate
+ * prime passes all trial divisions.
+ */
+ public void nextCandidate() {
+ if (primality) {
+ VMG.millerrabin_next_cand(statePtr);
+ } else {
+ VMG.millerrabin_safe_next_cand(statePtr);
+ }
+ }
+
+ /**
+ * Returns the current candidate.
+ *
+ * @return Current candidate.
+ */
+ public BigInteger getCurrentCandidate() {
+ if (primality) {
+ return new BigInteger(VMG.millerrabin_current(statePtr));
+ } else {
+ return new BigInteger(VMG.millerrabin_current_safe(statePtr));
+ }
+ }
+
+ /**
+ * Perform one Miller-Rabin test using the given base.
+ *
+ * @param base Base used in testing.
+ * @return false
if the integer is not prime and
+ * true
otherwise.
+ */
+ public boolean once(final BigInteger base) {
+ return VMG.millerrabin_once(statePtr, base.toByteArray()) == 1;
+ }
+
+ /**
+ * Perform one Miller-Rabin test using the given base.
+ *
+ * @param base Base used in testing.
+ * @param index Determines if Miller-Rabin is executed on the
+ * tested integer n or (n-1)/2.
+ * @return false
if the integer is not prime and
+ * true
otherwise.
+ */
+ public boolean once(final BigInteger base, final int index) {
+ return VMG.millerrabin_safe_once(statePtr,
+ base.toByteArray(),
+ index) == 1;
+ }
+
+ /**
+ * Releases resources allocated for testing. This must be called
+ * after testing is completed, but it must not be called if {@link
+ * #trial()} returns 0.
+ */
+ public void done() {
+ if (statePtr != 0) {
+ if (primality) {
+ VMG.millerrabin_clear(statePtr);
+ } else {
+ VMG.millerrabin_safe_clear(statePtr);
+ }
+ statePtr = 0;
+ }
+ }
+}
diff --git a/src/java/com/verificatum/vmgj/TestVMG.java b/src/java/com/verificatum/vmgj/TestVMG.java
new file mode 100644
index 0000000..bf3f19c
--- /dev/null
+++ b/src/java/com/verificatum/vmgj/TestVMG.java
@@ -0,0 +1,437 @@
+
+/*
+ * Copyright 2008-2018 Douglas Wikstrom
+ *
+ * This file is part of Verificatum Multiplicative Groups library for
+ * Java (VMGJ).
+ *
+ * VMGJ is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * VMGJ is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with VMGJ. If not, see
+ * .
+ */
+
+package com.verificatum.vmgj;
+
+import java.math.BigInteger;
+import java.security.SecureRandom;
+
+// We use C style to name things in this file, since it should
+// correspond to the native code.
+
+//CHECKSTYLE.OFF: LocalVariableName
+//CHECKSTYLE.OFF: LocalFinalVariableName
+//CHECKSTYLE.OFF: MethodName
+//CHECKSTYLE.OFF: ParameterName
+
+/**
+ * Testing routines for VMG, FpowmTab, and MillerRabin. These tests
+ * are not meant to be a complete test of the arithmetic. This is
+ * handled by the more comprehensive tests in the underlying native
+ * code. Here we merely run basic sanity checks to make sure that the
+ * native code is called correctly from Java.
+ *
+ * @author Douglas Wikstrom
+ */
+@SuppressWarnings("PMD.MethodNamingConventions")
+public final class TestVMG {
+
+ /**
+ * Avoid accidental instantiation.
+ */
+ private TestVMG() {
+ }
+
+ /**
+ * Default number of milliseconds used for a single test during
+ * testing of a curve.
+ */
+ static final int DEFAULT_TEST_TIME = 2000;
+
+ /**
+ * Convenience method for bounding the execution time of a test.
+ *
+ * @param t Time when the test started.
+ * @param milliSecs Milliseconds the should proceed.
+ * @return True if the deadline has passed and false otherwise.
+ */
+ private static boolean done(final long t, final long milliSecs) {
+ return System.currentTimeMillis() > t + milliSecs;
+ }
+
+ /**
+ * Tests exponentiation.
+ *
+ * @param bitLength Number of bits of integers.
+ * @param milliSecs Duration of the timing.
+ */
+ protected static void test_powm(final int bitLength, final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ // Test optimized code.
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+
+ final BigInteger modulus = new BigInteger(bitLength, random);
+ final BigInteger basis = new BigInteger(bitLength, random);
+ final BigInteger exponent = new BigInteger(bitLength, random);
+
+ final BigInteger vmg = VMG.powm(basis, exponent, modulus);
+ final BigInteger java = basis.modPow(exponent, modulus);
+
+ assert vmg.equals(java) : "Fixed basis exponentiation failed!";
+ }
+ }
+
+ /**
+ * Test simultaneous exponentiation.
+ *
+ * @param bitLength Number of bits of integers.
+ * @param milliSecs Duration of the timing.
+ */
+ protected static void test_spowm(final int bitLength,
+ final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ final int len = 50;
+
+ // Generate random modulus.
+ final BigInteger modulus = new BigInteger(bitLength, random);
+
+ final BigInteger[] bases = new BigInteger[len];
+ final BigInteger[] exponents = new BigInteger[len];
+
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+ for (int l = 0; l < len; l++) {
+ bases[l] = new BigInteger(bitLength, random).mod(modulus);
+ exponents[l] = new BigInteger(bitLength, random);
+ }
+
+ final BigInteger vmg = VMG.spowm(bases, exponents, modulus);
+
+ BigInteger res = BigInteger.ONE;
+ for (int l = 0; l < len; l++) {
+ res = res.multiply(bases[l].modPow(exponents[l], modulus));
+ res = res.mod(modulus);
+ }
+
+ assert vmg.equals(res) : "Failed to simultanously exponentiate!";
+ }
+ }
+
+ /**
+ * Tests fixed-basis exponentiation.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ protected static void test_fpowm(final int bitLength,
+ final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ // Generate random modulus.
+ final BigInteger modulus = new BigInteger(bitLength, random);
+ final BigInteger basis = new BigInteger(bitLength, random);
+ final FpowmTab tab = new FpowmTab(basis, modulus, bitLength);
+
+ // Test optimized code.
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+
+ final BigInteger exponent = new BigInteger(bitLength, random);
+ final BigInteger vmg = tab.fpowm(exponent);
+ final BigInteger res = basis.modPow(exponent, modulus);
+
+ assert vmg.equals(res) : "Failed to fixed-basis exponentiate!";
+ }
+ }
+
+ /**
+ * Tests computation of Legendre symbols.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ protected static void test_legendre(final int bitLength,
+ final long milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ final BigInteger two = BigInteger.ONE.add(BigInteger.ONE);
+
+ // Test optimized code.
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+
+ // Make sure we have an odd prime modulus.
+ final BigInteger prime =
+ BigInteger.probablePrime(bitLength, random);
+ final BigInteger exponent =
+ prime.subtract(BigInteger.ONE).divide(two);
+
+ final BigInteger bi = new BigInteger(bitLength, random);
+
+ final int ivmg = VMG.legendre(bi, prime);
+ final BigInteger vmg =
+ new BigInteger(Integer.toString(ivmg)).mod(prime);
+ final BigInteger res = bi.modPow(exponent, prime);
+
+ assert vmg.equals(res) : "Failed to compute Legendre symbol!";
+ }
+ }
+
+ /**
+ * Generates random integer between 2 and modulus - 1.
+ *
+ * @param modulus Modulus.
+ * @param random Random source.
+ * @return Random integer between 2 and modulus - 1.
+ */
+ private static BigInteger getBasis(final BigInteger modulus,
+ final SecureRandom random) {
+ BigInteger basis;
+
+ // Pick a random base in [2,modulus - 1].
+ do {
+ basis = new BigInteger(modulus.bitLength(), random).mod(modulus);
+ } while (basis.equals(BigInteger.ZERO) || basis.equals(BigInteger.ONE));
+ return basis;
+ }
+
+ /**
+ * Tests primality testing.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ public static void test_millerrabin_prime(final int bitLength,
+ final int milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ // Test optimized code.
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+
+ // Make sure we have an odd prime modulus.
+ final BigInteger bi = new BigInteger(bitLength, random);
+
+ final MillerRabin mr = new MillerRabin(bi, true, false);
+ boolean vmg = mr.trial();
+ for (int i = 0; vmg && i < 30; i++) {
+ final BigInteger b = getBasis(bi, random);
+ vmg = mr.once(b);
+ }
+ mr.done();
+
+ final boolean res = bi.isProbablePrime(50);
+
+ assert vmg == res : "Failed to test for primality!";
+ }
+ }
+
+ /**
+ * Tests next prime.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ public static void test_millerrabin_nextprime(final int bitLength,
+ final int milliSecs) {
+
+ final SecureRandom random = new SecureRandom();
+
+ // Test optimized code.
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+
+ // Make sure we have an odd prime modulus.
+ final BigInteger bi = new BigInteger(bitLength, random);
+ final BigInteger primeA = bi.nextProbablePrime();
+
+ final MillerRabin mr = new MillerRabin(bi, true, true);
+ boolean vmg = false;
+ BigInteger primeB = null;
+ while (!vmg) {
+ primeB = mr.getCurrentCandidate();
+ vmg = true;
+ for (int i = 0; vmg && i < 30; i++) {
+ final BigInteger b = getBasis(primeB, random);
+ vmg = mr.once(b);
+ }
+ mr.nextCandidate();
+ }
+ mr.done();
+
+ assert primeA.equals(primeB) : "Failed get next prime!";
+ }
+ }
+
+ /**
+ * Tests next prime.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ public static void test_millerrabin_nextsafeprime(final int bitLength,
+ final int milliSecs) {
+
+ final BigInteger two = BigInteger.ONE.add(BigInteger.ONE);
+ final SecureRandom random = new SecureRandom();
+
+ // Test optimized code.
+ final long t = System.currentTimeMillis();
+ while (!done(t, milliSecs)) {
+
+ // Search for the next safe prime naively.
+ BigInteger bi;
+ BigInteger primeA;
+ BigInteger subA;
+ do {
+ bi = new BigInteger(bitLength, random);
+ primeA = bi.nextProbablePrime();
+ subA = primeA.subtract(BigInteger.ONE).divide(two);
+ } while (!subA.isProbablePrime(20));
+
+ // Search using our routines.
+ MillerRabin mr = new MillerRabin(bi, false, true);
+ boolean vmg = false;
+ BigInteger primeB = null;
+ BigInteger subB = null;
+ BigInteger b = null;
+ while (!vmg) {
+ primeB = mr.getCurrentCandidate();
+ subB = primeB.subtract(BigInteger.ONE).divide(two);
+ vmg = true;
+ for (int i = 0; vmg && i < 30; i++) {
+ if (i % 2 == 0) {
+ b = getBasis(primeB, random);
+ } else {
+ b = getBasis(subB, random);
+ }
+ vmg = mr.once(b, i % 2);
+ }
+ mr.nextCandidate();
+ }
+ mr.done();
+
+ assert primeA.equals(primeB) : "Failed get next prime!";
+
+ mr = new MillerRabin(primeA, false, false);
+ vmg = mr.trial();
+ for (int i = 0; vmg && i < 40; i++) {
+ if (i % 2 == 0) {
+ b = getBasis(primeA, random);
+ } else {
+ b = getBasis(subA, random);
+ }
+ vmg = mr.once(b, i % 2);
+ }
+ mr.done();
+
+ assert vmg && primeA.equals(primeB) : "Failed verify safe prime!";
+ }
+ }
+
+ /**
+ * Tests modular arithmetic and prints the results.
+ *
+ * @param bitLength Number of bits of integers in the operation
+ * timed.
+ * @param milliSecs Duration of the timing.
+ */
+ public static void test_vmg(final int bitLength, final int milliSecs) {
+
+ final String f =
+ "%nTesting modular arithmetic: %d bitlength (%d ms/function)";
+
+ System.out.println(String.format(f, bitLength, milliSecs));
+ System.out.println(
+ "----------------------------------------------------------------");
+
+ System.out.println("powm (plain modular exponentiation)");
+ test_powm(bitLength, milliSecs);
+ System.out.println("spowm (simultaneous modular exponentiation)");
+ test_spowm(bitLength, milliSecs);
+ System.out.println("fpowm (fixed-basis modular exponentiation)");
+ test_fpowm(bitLength, milliSecs);
+ System.out.println("legendre (Legendre symbol)");
+ test_legendre(bitLength, milliSecs);
+ System.out.println("prime (test random integers for primality)");
+ test_millerrabin_prime(bitLength, milliSecs);
+ System.out.println("nextprime (find next prime)");
+ test_millerrabin_nextprime(100, milliSecs);
+ System.out.println("nextsafeprime (find next and check safe prime "
+ + "100 bits)");
+ test_millerrabin_nextsafeprime(70, milliSecs);
+ }
+
+ /**
+ * Executes the testing routines.
+ *
+ * @param args Command line arguments.
+ */
+ public static void main(final String[] args) {
+
+ int[] bitLengths = new int[4];
+ bitLengths[0] = 1024;
+ bitLengths[1] = 2048;
+ bitLengths[2] = 3072;
+ bitLengths[3] = 4096;
+
+ if (args.length > 0) {
+
+ bitLengths = new int[args.length];
+ for (int i = 0; i < args.length; i++) {
+
+ try {
+ bitLengths[i] = Integer.parseInt(args[i]);
+ } catch (NumberFormatException nfe) {
+ System.err.println("Failed to parse a bit length! ("
+ + args[i] + ")");
+ System.exit(1);
+ }
+ }
+ }
+
+ final String s =
+"\n================================================================\n"
++ "\n TEST com.verificatum.vmgj.VMG \n\n"
++ " Although these tests technically give full coverage, they are\n"
++ " not sufficient to verify the correctness of the arithmetic.\n"
++ " The correctness of the arithmetic is guaranteed by the tests\n"
++ " of the native code. The tests run here merely verify that\n"
++ " native calls are handled correctly.\n\n"
++ "================================================================";
+
+ System.out.println(s);
+
+ for (int i = 0; i < bitLengths.length; i++) {
+
+ test_vmg(bitLengths[i], DEFAULT_TEST_TIME);
+ }
+ System.out.println("");
+ }
+}
+//CHECKSTYLE.ON: LocalVariableName
+//CHECKSTYLE.ON: LocalFinalVariableName
+//CHECKSTYLE.ON: MethodName
+//CHECKSTYLE.ON: ParameterName
diff --git a/src/java/com/verificatum/vmgj/VMG.magic b/src/java/com/verificatum/vmgj/VMG.magic
new file mode 100644
index 0000000..e57a7f4
--- /dev/null
+++ b/src/java/com/verificatum/vmgj/VMG.magic
@@ -0,0 +1,299 @@
+
+/*
+ * Copyright 2008-2018 Douglas Wikstrom
+ *
+ * This file is part of Verificatum Multiplicative Groups library for
+ * Java (VMGJ).
+ *
+ * VMGJ is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * VMGJ is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with VMGJ. If not, see
+ * .
+ */
+
+package com.verificatum.vmgj;
+
+import java.math.BigInteger;
+
+// We use C style to name things in this file, since it should
+// correspond to the native code.
+
+//CHECKSTYLE.OFF: LocalVariableName
+//CHECKSTYLE.OFF: LocalFinalVariableName
+//CHECKSTYLE.OFF: MethodName
+//CHECKSTYLE.OFF: ParameterName
+
+/**
+ * Allows invoking the modular exponentiation, simultaneous modular
+ * exponentiation routines, primality tests, and related routines of
+ * the Gnu Multiprecision Library
+ * (GMP)and GMPMEE (a minor extension of GMP).
+ *
+ *
+ *
+ * @author Douglas Wikstrom
+ */
+@SuppressWarnings("PMD.MethodNamingConventions")
+public final class VMG {
+
+ /**
+ * Avoid accidental instantiation.
+ */
+ private VMG() {
+ }
+
+ /**
+ * Load native code upon loading this class.
+ */
+ static {
+ System.loadLibrary("vmgj-M4_VERSION");
+ }
+
+ /**
+ * Converts an array of BigInteger
to an array of
+ * byte[]
representing the integers in two's
+ * complement representation.
+ *
+ * @param bis Integers to be converted.
+ * @return Array of converted integers.
+ */
+ static byte[][] convert(final BigInteger[] bis) {
+
+ final byte[][] native_bis = new byte[bis.length][];
+ for (int i = 0; i < native_bis.length; i++) {
+ native_bis[i] = bis[i].toByteArray();
+ }
+ return native_bis;
+ }
+
+ /**
+ * Computes a modular exponentiation.
+ *
+ * @param basis Basis integer.
+ * @param exponent Exponent used to compute power.
+ * @param modulus Modulus.
+ * @return This instance to the power of exponent
+ * modulo modulus
.
+ */
+ static native byte[] powm(final byte[] basis,
+ final byte[] exponent,
+ final byte[] modulus);
+
+ /**
+ * Computes a modular exponentiation.
+ *
+ * @param basis Basis integer.
+ * @param exponent Exponent used to compute power.
+ * @param modulus Modulus.
+ * @return This instance to the power of exponent
+ * modulo modulus
.
+ * @throws ArithmeticException If the result from the native code
+ * can not be interpreted as a BigInteger.
+ */
+ public static BigInteger powm(final BigInteger basis,
+ final BigInteger exponent,
+ final BigInteger modulus)
+ throws ArithmeticException {
+ return new BigInteger(powm(basis.toByteArray(),
+ exponent.toByteArray(),
+ modulus.toByteArray()));
+ }
+
+ /**
+ * Computes a simultaneous modular exponentiation.
+ *
+ * @param bases Basis integers.
+ * @param exponents Exponent used to compute power.
+ * @param modulus Modulus.
+ * @return Product of the bases to the powers of
+ * exponents
modulo modulus
.
+ */
+ static native byte[] spowm(final byte[][] bases,
+ final byte[][] exponents,
+ final byte[] modulus);
+
+ /**
+ * Computes a simultaneous modular exponentiation.
+ *
+ * @param bases Basis elements.
+ * @param exponents Exponent used to compute power.
+ * @param modulus Modulus.
+ * @return Product of the bases to the powers of
+ * exponents
modulo modulus
.
+ */
+ public static BigInteger spowm(final BigInteger[] bases,
+ final BigInteger[] exponents,
+ final BigInteger modulus) {
+ final byte[][] native_bases = convert(bases);
+ final byte[][] native_exponents = convert(exponents);
+ return new BigInteger(spowm(native_bases,
+ native_exponents,
+ modulus.toByteArray()));
+ }
+
+ /**
+ * Performs precomputation for the given basis and modulus
+ * assuming the given exponent bit length.
+ *
+ * @param basis Basis elements.
+ * @param modulus Modulus used during modular exponentiation.
+ * @param exponentBitlen Expected bit length of exponents.
+ * @param blockWidth Decides how many distinct generators are used
+ * when translating an exponentiation into a simultaneous
+ * exponentiation.
+ * @return Native pointer to a precomputed table.
+ */
+ static native long fpowm_precomp(byte[] basis,
+ byte[] modulus,
+ int blockWidth,
+ int exponentBitlen);
+
+ /**
+ * Performs precomputation for the given basis and modulus
+ * assuming the given exponent bit length.
+ *
+ * @param tablePtr Native pointer to a precomputed table output by
+ * {@link #fpowm_precomp(byte[], byte[], int, int)}.
+ * @param exponent Exponent given in two's complement.
+ * @return Result of modular exponentiation.
+ */
+ static native byte[] fpowm(long tablePtr, byte[] exponent);
+
+ /**
+ * Frees the resources allocated by the native object pointed to
+ * by the input.
+ *
+ * @param tablePtr Native pointer to a precomputed table output by
+ * {@link #fpowm_precomp(byte[], byte[], int, int)}.
+ */
+ static native void fpowm_clear(long tablePtr);
+
+ /**
+ * Returns the Legendre symbol of op
modulo
+ * odd_prime
.
+ *
+ * @param op An integer.
+ * @param odd_prime An odd prime modulus.
+ * @return Legendre symbol of op
modulo
+ * odd_prime
.
+ */
+ static native int legendre(final byte[] op, final byte[] odd_prime);
+
+ /**
+ * Returns the Legendre symbol of this instance modulo the
+ * input.
+ *
+ * @param odd_prime An odd prime modulus.
+ * @param value Integer to be tested.
+ * @return Legendre symbol of value
modulo
+ * odd_prime
.
+ */
+ public static int legendre(final BigInteger value,
+ final BigInteger odd_prime) {
+ return legendre(value.toByteArray(), odd_prime.toByteArray());
+ }
+
+ /**
+ * Allocate and initialize Miller-Rabin state using the given
+ * integer.
+ *
+ * @param n Integer to test.
+ * @param search Decides if we are searching for an integer or testing.
+ * @return Pointer to structure in native space.
+ */
+ static native long millerrabin_init(byte[] n, boolean search);
+
+ /**
+ * Increase the tested number to the next candidate integer.
+ *
+ * @param statePtr Native pointer to state for testing.
+ */
+ static native void millerrabin_next_cand(long statePtr);
+
+ /**
+ * Executes one round of the Miller-Rabin test and returns 0 or 1
+ * depending on if the tested integer is deemed to be composite or
+ * not.
+ *
+ * @param statePtr Native pointer to state for testing.
+ * @param base Base element used for testing. This must be
+ * non-zero and non-one modulo the tested integer.
+ * @return Result of the test as a 0/1 integer.
+ */
+ static native int millerrabin_once(long statePtr, byte[] base);
+
+ /**
+ * Free memory resources allocated for testing.
+ *
+ * @param statePtr Native pointer to state for testing.
+ */
+ static native void millerrabin_clear(long statePtr);
+
+ /**
+ * Returns the current candidate integer.
+ *
+ * @param statePtr Native pointer to state for testing.
+ * @return Current candidate integer.
+ */
+ static native byte[] millerrabin_current(long statePtr);
+
+ /**
+ * Allocate and initialize Miller-Rabin state using the given
+ * integer.
+ *
+ * @param n Integer to test.
+ * @param search Decides if we are searching for an integer or testing.
+ * @return Native pointer to state for testing.
+ */
+ static native long millerrabin_safe_init(byte[] n, boolean search);
+
+ /**
+ * Increase the tested number to the next candidate integer.
+ *
+ * @param statePtr Native pointer to state for testing.
+ */
+ static native void millerrabin_safe_next_cand(long statePtr);
+
+ /**
+ * Executes one round of the Miller-Rabin test and returns 0 or 1
+ * depending on if the tested integer is deemed to not be a safe
+ * prime, or a safe prime.
+ *
+ * @param statePtr Native pointer to state for testing.
+ * @param base Base element used for testing.
+ * @param index Must be zero for testing the integer and one for
+ * testing m, where n=2m+1.
+ * @return Result of test.
+ */
+ static native int millerrabin_safe_once(long statePtr,
+ byte[] base,
+ int index);
+
+ /**
+ * Free memory resources allocated for testing.
+ *
+ * @param statePtr Native pointer to state for testing.
+ */
+ static native void millerrabin_safe_clear(long statePtr);
+
+ /**
+ * Returns the current safe-prime candidate.
+ *
+ * @param statePtr Pointer to structure in native space.
+ * @return Current candidate safe-prime.
+ */
+ static native byte[] millerrabin_current_safe(long statePtr);
+}
+//CHECKSTYLE.ON: LocalVariableName
+//CHECKSTYLE.ON: LocalFinalVariableName
+//CHECKSTYLE.ON: MethodName
+//CHECKSTYLE.ON: ParameterName
diff --git a/src/java/com/verificatum/vmgj/package-info.java b/src/java/com/verificatum/vmgj/package-info.java
new file mode 100644
index 0000000..3ed9b1b
--- /dev/null
+++ b/src/java/com/verificatum/vmgj/package-info.java
@@ -0,0 +1,27 @@
+
+/*
+ * Copyright 2008-2018 Douglas Wikstrom
+ *
+ * This file is part of Verificatum Multiplicative Groups library for
+ * Java (VMGJ).
+ *
+ * VMGJ is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * VMGJ is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with VMGJ. If not, see
+ * .
+ */
+
+ /**
+ * This library allows calling GMP and GMPMEE from Java.
+ */
+
+package com.verificatum.vmgj;
diff --git a/src/m4/ac_check_class.m4 b/src/m4/ac_check_class.m4
new file mode 100644
index 0000000..dcc8197
--- /dev/null
+++ b/src/m4/ac_check_class.m4
@@ -0,0 +1,141 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_check_class.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CHECK_CLASS
+#
+# DESCRIPTION
+#
+# AC_CHECK_CLASS tests the existence of a given Java class, either in a
+# jar or in a '.class' file.
+#
+# *Warning*: its success or failure can depend on a proper setting of the
+# CLASSPATH env. variable.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Stephane Bortzmeyer
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_CHECK_CLASS],[
+AC_REQUIRE([AC_PROG_JAVA])
+ac_var_name=`echo $1 | sed 's/\./_/g'`
+dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is
+dnl dynamic I need an extra level of extraction
+AC_MSG_CHECKING([for $1 class])
+AC_CACHE_VAL(ac_cv_class_$ac_var_name, [
+if test x$ac_cv_prog_uudecode_base64 = xyes; then
+dnl /**
+dnl * Test.java: used to test dynamicaly if a class exists.
+dnl */
+dnl public class Test
+dnl {
+dnl
+dnl public static void
+dnl main( String[] argv )
+dnl {
+dnl Class lib;
+dnl if (argv.length < 1)
+dnl {
+dnl System.err.println ("Missing argument");
+dnl System.exit (77);
+dnl }
+dnl try
+dnl {
+dnl lib = Class.forName (argv[0]);
+dnl }
+dnl catch (ClassNotFoundException e)
+dnl {
+dnl System.exit (1);
+dnl }
+dnl lib = null;
+dnl System.exit (0);
+dnl }
+dnl
+dnl }
+cat << \EOF > Test.uue
+begin-base64 644 Test.class
+yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
+bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
+bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ
+AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt
+ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV
+ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp
+VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM
+amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi
+AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B
+AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA
+AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN
+uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK
+AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA
+JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA
+JwAAAAIAKA==
+====
+EOF
+ if uudecode$EXEEXT Test.uue; then
+ :
+ else
+ echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
+ echo "configure: failed file was:" >&AC_FD_CC
+ cat Test.uue >&AC_FD_CC
+ ac_cv_prog_uudecode_base64=no
+ fi
+ rm -f Test.uue
+ if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then
+ eval "ac_cv_class_$ac_var_name=yes"
+ else
+ eval "ac_cv_class_$ac_var_name=no"
+ fi
+ rm -f Test.class
+else
+ AC_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"],
+ [eval "ac_cv_class_$ac_var_name=no"])
+fi
+eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
+eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`"
+HAVE_LAST_CLASS=$ac_var_val
+if test x$ac_var_val = xyes; then
+ ifelse([$2], , :, [$2])
+else
+ ifelse([$3], , :, [$3])
+fi
+])
+dnl for some reason the above statment didn't fall though here?
+dnl do scripts have variable scoping?
+eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
+AC_MSG_RESULT($ac_var_val)
+])
diff --git a/src/m4/ac_check_classpath.m4 b/src/m4/ac_check_classpath.m4
new file mode 100644
index 0000000..ea3e779
--- /dev/null
+++ b/src/m4/ac_check_classpath.m4
@@ -0,0 +1,57 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_check_classpath.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CHECK_CLASSPATH
+#
+# DESCRIPTION
+#
+# AC_CHECK_CLASSPATH just displays the CLASSPATH, for the edification of
+# the user.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Stephane Bortzmeyer
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_CHECK_CLASSPATH],[
+if test "x$CLASSPATH" = x; then
+ echo "You have no CLASSPATH, I hope it is good"
+else
+ echo "You have CLASSPATH $CLASSPATH, hope it is correct"
+fi
+])
diff --git a/src/m4/ac_check_java_home.m4 b/src/m4/ac_check_java_home.m4
new file mode 100644
index 0000000..13b1e51
--- /dev/null
+++ b/src/m4/ac_check_java_home.m4
@@ -0,0 +1,56 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_check_java_home.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CHECK_JAVA_HOME
+#
+# DESCRIPTION
+#
+# Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in.
+# If found, set environment variable JAVA_HOME = Java installation home,
+# else left JAVA_HOME untouch, which in most case means JAVA_HOME is
+# empty.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Gleen Salmon
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_CHECK_JAVA_HOME],[
+AC_REQUIRE([AC_EXEEXT])dnl
+TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1`
+if test x$TRY_JAVA_HOME != x; then
+ PATH=$PATH:$TRY_JAVA_HOME/bin
+fi
+AC_PATH_PROG(JAVA_PATH_NAME, java$EXEEXT)
+if test x$JAVA_PATH_NAME != x; then
+ JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java$EXEEXT$/\1/"`
+fi;dnl
+])
diff --git a/src/m4/ac_check_rqrd_class.m4 b/src/m4/ac_check_rqrd_class.m4
new file mode 100644
index 0000000..62b130f
--- /dev/null
+++ b/src/m4/ac_check_rqrd_class.m4
@@ -0,0 +1,59 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_check_rqrd_class.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CHECK_RQRD_CLASS
+#
+# DESCRIPTION
+#
+# AC_CHECK_RQRD_CLASS tests the existence of a given Java class, either in
+# a jar or in a '.class' file and fails if it doesn't exist. Its success
+# or failure can depend on a proper setting of the CLASSPATH env.
+# variable.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Stephane Bortzmeyer
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_CHECK_RQRD_CLASS],[
+CLASS=`echo $1|sed 's/\./_/g'`
+AC_CHECK_CLASS($1)
+if test "$HAVE_LAST_CLASS" = "no"; then
+ AC_MSG_ERROR([Required class $1 missing, exiting.])
+fi
+])
diff --git a/src/m4/ac_java_options.m4 b/src/m4/ac_java_options.m4
new file mode 100644
index 0000000..c51aa7e
--- /dev/null
+++ b/src/m4/ac_java_options.m4
@@ -0,0 +1,44 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_java_options.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_JAVA_OPTIONS
+#
+# DESCRIPTION
+#
+# AC_JAVA_OPTIONS adds configure command line options used for Java m4
+# macros. This Macro is optional.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Devin Weaver
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_JAVA_OPTIONS],[
+AC_ARG_WITH(java-prefix,
+ [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)])
+AC_ARG_WITH(javac-flags,
+ [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)])
+AC_ARG_WITH(java-flags,
+ [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)])
+JAVAPREFIX=$with_java_prefix
+JAVACFLAGS=$with_javac_flags
+JAVAFLAGS=$with_java_flags
+AC_SUBST(JAVAPREFIX)dnl
+AC_SUBST(JAVACFLAGS)dnl
+AC_SUBST(JAVAFLAGS)dnl
+AC_SUBST(JAVA)dnl
+AC_SUBST(JAVAC)dnl
+])
diff --git a/src/m4/ac_prog_jar.m4 b/src/m4/ac_prog_jar.m4
new file mode 100644
index 0000000..2b0a595
--- /dev/null
+++ b/src/m4/ac_prog_jar.m4
@@ -0,0 +1,48 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_prog_jar.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_JAR
+#
+# DESCRIPTION
+#
+# AC_PROG_JAR tests for an existing jar program. It uses the environment
+# variable JAR then tests in sequence various common jar programs.
+#
+# If you want to force a specific compiler:
+#
+# - at the configure.in level, set JAR=yourcompiler before calling
+# AC_PROG_JAR
+#
+# - at the configure level, setenv JAR
+#
+# You can use the JAR variable in your Makefile.in, with @JAR@.
+#
+# Note: This macro depends on the autoconf M4 macros for Java programs. It
+# is VERY IMPORTANT that you download that whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission.
+#
+# The general documentation of those macros, as well as the sample
+# configure.in, is included in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Egon Willighagen
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_PROG_JAR],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test "x$JAVAPREFIX" = x; then
+ test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar$EXEEXT)
+else
+ test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar, $JAVAPREFIX)
+fi
+test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH])
+AC_PROVIDE([$0])dnl
+])
diff --git a/src/m4/ac_prog_java.m4 b/src/m4/ac_prog_java.m4
new file mode 100644
index 0000000..d28dc12
--- /dev/null
+++ b/src/m4/ac_prog_java.m4
@@ -0,0 +1,113 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_prog_java.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_JAVA
+#
+# DESCRIPTION
+#
+# Here is a summary of the main macros:
+#
+# AC_PROG_JAVAC: finds a Java compiler.
+#
+# AC_PROG_JAVA: finds a Java virtual machine.
+#
+# AC_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!).
+#
+# AC_CHECK_RQRD_CLASS: finds if we have the given class and stops
+# otherwise.
+#
+# AC_TRY_COMPILE_JAVA: attempt to compile user given source.
+#
+# AC_TRY_RUN_JAVA: attempt to compile and run user given source.
+#
+# AC_JAVA_OPTIONS: adds Java configure options.
+#
+# AC_PROG_JAVA tests an existing Java virtual machine. It uses the
+# environment variable JAVA then tests in sequence various common Java
+# virtual machines. For political reasons, it starts with the free ones.
+# You *must* call [AC_PROG_JAVAC] before.
+#
+# If you want to force a specific VM:
+#
+# - at the configure.in level, set JAVA=yourvm before calling AC_PROG_JAVA
+#
+# (but after AC_INIT)
+#
+# - at the configure level, setenv JAVA
+#
+# You can use the JAVA variable in your Makefile.in, with @JAVA@.
+#
+# *Warning*: its success or failure can depend on a proper setting of the
+# CLASSPATH env. variable.
+#
+# TODO: allow to exclude virtual machines (rationale: most Java programs
+# cannot run with some VM like kaffe).
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission.
+#
+# A Web page, with a link to the latest CVS snapshot is at
+# .
+#
+# This is a sample configure.in Process this file with autoconf to produce
+# a configure script.
+#
+# AC_INIT(UnTag.java)
+#
+# dnl Checks for programs.
+# AC_CHECK_CLASSPATH
+# AC_PROG_JAVAC
+# AC_PROG_JAVA
+#
+# dnl Checks for classes
+# AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
+# AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
+#
+# AC_OUTPUT(Makefile)
+#
+# LICENSE
+#
+# Copyright (c) 2008 Stephane Bortzmeyer
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_PROG_JAVA],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test x$JAVAPREFIX = x; then
+ test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT)
+else
+ test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT, $JAVAPREFIX)
+fi
+test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
+AC_PROG_JAVA_WORKS
+AC_PROVIDE([$0])dnl
+])
diff --git a/src/m4/ac_prog_java_works.m4 b/src/m4/ac_prog_java_works.m4
new file mode 100644
index 0000000..3a36319
--- /dev/null
+++ b/src/m4/ac_prog_java_works.m4
@@ -0,0 +1,131 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_prog_java_works.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_JAVA_WORKS
+#
+# DESCRIPTION
+#
+# Internal use ONLY.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Stephane Bortzmeyer
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_PROG_JAVA_WORKS], [
+AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
+if test x$uudecode = xyes; then
+AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
+dnl /**
+dnl * Test.java: used to test if java compiler works.
+dnl */
+dnl public class Test
+dnl {
+dnl
+dnl public static void
+dnl main( String[] argv )
+dnl {
+dnl System.exit (0);
+dnl }
+dnl
+dnl }
+cat << \EOF > Test.uue
+begin-base64 644 Test.class
+yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
+bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
+bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
+YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
+aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
+AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
+AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
+====
+EOF
+if uudecode$EXEEXT Test.uue; then
+ ac_cv_prog_uudecode_base64=yes
+else
+ echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
+ echo "configure: failed file was:" >&AC_FD_CC
+ cat Test.uue >&AC_FD_CC
+ ac_cv_prog_uudecode_base64=no
+fi
+rm -f Test.uue])
+fi
+if test x$ac_cv_prog_uudecode_base64 != xyes; then
+ rm -f Test.class
+ AC_MSG_WARN([I have to compile Test.class from scratch])
+ if test x$ac_cv_prog_javac_works = xno; then
+ AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
+ fi
+ if test x$ac_cv_prog_javac_works = x; then
+ AC_PROG_JAVAC
+ fi
+fi
+AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
+JAVA_TEST=Test.java
+CLASS_TEST=Test.class
+TEST=Test
+changequote(, )dnl
+cat << \EOF > $JAVA_TEST
+/* [#]line __oline__ "configure" */
+public class Test {
+public static void main (String args[]) {
+ System.exit (0);
+} }
+EOF
+changequote([, ])dnl
+if test x$ac_cv_prog_uudecode_base64 != xyes; then
+ if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
+ :
+ else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+ AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
+ fi
+fi
+if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
+ ac_cv_prog_java_works=yes
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+ AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
+fi
+rm -fr $JAVA_TEST $CLASS_TEST Test.uue
+])
+AC_PROVIDE([$0])dnl
+]
+)
diff --git a/src/m4/ac_prog_javac_works.m4 b/src/m4/ac_prog_javac_works.m4
new file mode 100644
index 0000000..36164a4
--- /dev/null
+++ b/src/m4/ac_prog_javac_works.m4
@@ -0,0 +1,69 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_prog_javac_works.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_JAVAC_WORKS
+#
+# DESCRIPTION
+#
+# Internal use ONLY.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Stephane Bortzmeyer
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([AC_PROG_JAVAC_WORKS],[
+AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
+JAVA_TEST=Test.java
+CLASS_TEST=Test.class
+cat << \EOF > $JAVA_TEST
+/* [#]line __oline__ "configure" */
+public class Test {
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
+ ac_cv_prog_javac_works=yes
+else
+ AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+fi
+rm -f $JAVA_TEST $CLASS_TEST
+])
+AC_PROVIDE([$0])dnl
+])
diff --git a/src/m4/ac_prog_javadoc.m4 b/src/m4/ac_prog_javadoc.m4
new file mode 100644
index 0000000..e689cbb
--- /dev/null
+++ b/src/m4/ac_prog_javadoc.m4
@@ -0,0 +1,49 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_prog_javadoc.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_JAVADOC
+#
+# DESCRIPTION
+#
+# AC_PROG_JAVADOC tests for an existing javadoc generator. It uses the
+# environment variable JAVADOC then tests in sequence various common
+# javadoc generator.
+#
+# If you want to force a specific compiler:
+#
+# - at the configure.in level, set JAVADOC=yourgenerator before calling
+# AC_PROG_JAVADOC
+#
+# - at the configure level, setenv JAVADOC
+#
+# You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@.
+#
+# Note: This macro depends on the autoconf M4 macros for Java programs. It
+# is VERY IMPORTANT that you download that whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission.
+#
+# The general documentation of those macros, as well as the sample
+# configure.in, is included in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Egon Willighagen
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_PROG_JAVADOC],[
+AC_REQUIRE([AC_EXEEXT])dnl
+if test "x$JAVAPREFIX" = x; then
+ test "x$JAVADOC" = x && AC_CHECK_PROGS(JAVADOC, javadoc$EXEEXT)
+else
+ test "x$JAVADOC" = x && AC_CHECK_PROGS(JAVADOC, javadoc, $JAVAPREFIX)
+fi
+test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH])
+AC_PROVIDE([$0])dnl
+])
diff --git a/src/m4/ac_prog_javah.m4 b/src/m4/ac_prog_javah.m4
new file mode 100644
index 0000000..ed0a5c3
--- /dev/null
+++ b/src/m4/ac_prog_javah.m4
@@ -0,0 +1,39 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_prog_javah.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_PROG_JAVAH
+#
+# DESCRIPTION
+#
+# AC_PROG_JAVAH tests the availability of the javah header generator and
+# looks for the jni.h header file. If available, JAVAH is set to the full
+# path of javah and CPPFLAGS is updated accordingly.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Luc Maisonobe
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_PROG_JAVAH],[
+AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
+AC_REQUIRE([AC_PROG_CPP])dnl
+AC_PATH_PROG(JAVAH,javah)
+if test x"`eval 'echo $ac_cv_path_JAVAH'`" != x ; then
+ AC_TRY_CPP([#include ],,[
+ ac_save_CPPFLAGS="$CPPFLAGS"
+changequote(, )dnl
+ ac_dir=`echo $ac_cv_path_JAVAH | sed 's,\(.*\)/[^/]*/[^/]*$,\1/include,'`
+ ac_machdep=`echo $build_os | sed 's,[-0-9].*,,' | sed 's,cygwin,win32,'`
+changequote([, ])dnl
+ CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep"
+ AC_TRY_CPP([#include ],
+ ac_save_CPPFLAGS="$CPPFLAGS",
+ AC_MSG_WARN([unable to include ]))
+ CPPFLAGS="$ac_save_CPPFLAGS"])
+fi])
diff --git a/src/m4/ac_try_compile_java.m4 b/src/m4/ac_try_compile_java.m4
new file mode 100644
index 0000000..8e776f8
--- /dev/null
+++ b/src/m4/ac_try_compile_java.m4
@@ -0,0 +1,51 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_try_compile_java.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_TRY_COMPILE_JAVA
+#
+# DESCRIPTION
+#
+# AC_TRY_COMPILE_JAVA attempt to compile user given source.
+#
+# *Warning*: its success or failure can depend on a proper setting of the
+# CLASSPATH env. variable.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Devin Weaver
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_TRY_COMPILE_JAVA],[
+AC_REQUIRE([AC_PROG_JAVAC])dnl
+cat << \EOF > Test.java
+/* [#]line __oline__ "configure" */
+ifelse([$1], , , [import $1;])
+public class Test {
+[$2]
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class
+then
+dnl Don't remove the temporary files here, so they can be examined.
+ ifelse([$3], , :, [$3])
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat Test.java >&AC_FD_CC
+ifelse([$4], , , [ rm -fr Test*
+ $4
+])dnl
+fi
+rm -fr Test*])
diff --git a/src/m4/ac_try_run_javac.m4 b/src/m4/ac_try_run_javac.m4
new file mode 100644
index 0000000..c7cf925
--- /dev/null
+++ b/src/m4/ac_try_run_javac.m4
@@ -0,0 +1,52 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ac_try_run_javac.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_TRY_RUN_JAVA
+#
+# DESCRIPTION
+#
+# AC_TRY_RUN_JAVA attempt to compile and run user given source.
+#
+# *Warning*: its success or failure can depend on a proper setting of the
+# CLASSPATH env. variable.
+#
+# Note: This is part of the set of autoconf M4 macros for Java programs.
+# It is VERY IMPORTANT that you download the whole set, some macros depend
+# on other. Unfortunately, the autoconf archive does not support the
+# concept of set of macros, so I had to break it for submission. The
+# general documentation, as well as the sample configure.in, is included
+# in the AC_PROG_JAVA macro.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Devin Weaver
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AC_TRY_RUN_JAVA],[
+AC_REQUIRE([AC_PROG_JAVAC])dnl
+AC_REQUIRE([AC_PROG_JAVA])dnl
+cat << \EOF > Test.java
+/* [#]line __oline__ "configure" */
+ifelse([$1], , , [include $1;])
+public class Test {
+[$2]
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null
+then
+dnl Don't remove the temporary files here, so they can be examined.
+ ifelse([$3], , :, [$3])
+else
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat Test.java >&AC_FD_CC
+ifelse([$4], , , [ rm -fr Test*
+ $4
+])dnl
+fi
+rm -fr Test*])
diff --git a/src/m4/ace_check_jvmg.m4 b/src/m4/ace_check_jvmg.m4
new file mode 100644
index 0000000..2e7ee77
--- /dev/null
+++ b/src/m4/ace_check_jvmg.m4
@@ -0,0 +1,32 @@
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+AC_DEFUN([ACE_CHECK_VMGJ],[
+AC_REQUIRE([ACE_PROG_JAVA])
+ace_res=$($JAVA $JAVAFLAGS -classpath $CLASSPATH TestLoadVMGJ)
+
+echo -n "checking for vmgj.jar... "
+if test "x$ace_res" = x
+then
+ echo "yes"
+else
+ echo "no"
+ AC_MSG_ERROR([$ace_res Please make sure that VMGJ is installed (found at www.verificatum.org) and that your \$CLASSPATH points to the proper location. You can check your VMGJ installation using \"java vmgj.Test\". This should give you a usage description.])
+fi
+])
diff --git a/src/m4/ace_prog_jar.m4 b/src/m4/ace_prog_jar.m4
new file mode 100644
index 0000000..7edddfd
--- /dev/null
+++ b/src/m4/ace_prog_jar.m4
@@ -0,0 +1,27 @@
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+AC_DEFUN([ACE_PROG_JAR],[
+AC_CHECK_PROG([JAR], [jar], [jar], [no])
+
+if test $JAR = no
+then
+ AC_MSG_ERROR([No jar found in \$PATH. Please install JDK 6!])
+fi
+])
diff --git a/src/m4/ace_prog_java.m4 b/src/m4/ace_prog_java.m4
new file mode 100644
index 0000000..653ac0d
--- /dev/null
+++ b/src/m4/ace_prog_java.m4
@@ -0,0 +1,27 @@
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+AC_DEFUN([ACE_PROG_JAVA],[
+AC_CHECK_PROG([JAVA], [java], [java], [no])
+
+if test $JAVA = no
+then
+ AC_MSG_ERROR([No java found in \$PATH. Please install JDK 6!])
+fi
+])
diff --git a/src/m4/ace_prog_javac.m4 b/src/m4/ace_prog_javac.m4
new file mode 100644
index 0000000..d287203
--- /dev/null
+++ b/src/m4/ace_prog_javac.m4
@@ -0,0 +1,27 @@
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+AC_DEFUN([ACE_PROG_JAVAC],[
+AC_CHECK_PROG([JAVAC], [javac], [javac], [no])
+
+if test $JAVAC = no
+then
+ AC_MSG_ERROR([No javac found in \$PATH. Please install JDK 6!])
+fi
+])
diff --git a/src/m4/ace_prog_javadoc.m4 b/src/m4/ace_prog_javadoc.m4
new file mode 100644
index 0000000..5dfe820
--- /dev/null
+++ b/src/m4/ace_prog_javadoc.m4
@@ -0,0 +1,27 @@
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+AC_DEFUN([ACE_PROG_JAVADOC],[
+AC_CHECK_PROG([JAVADOC], [javadoc], [javadoc], [no])
+
+if test $JAVADOC = no
+then
+ AC_MSG_ERROR([No javadoc found in \$PATH. Please install JDK 6!])
+fi
+])
diff --git a/src/m4/ace_prog_javah.m4 b/src/m4/ace_prog_javah.m4
new file mode 100644
index 0000000..f11add8
--- /dev/null
+++ b/src/m4/ace_prog_javah.m4
@@ -0,0 +1,27 @@
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+AC_DEFUN([ACE_PROG_JAVAH],[
+AC_CHECK_PROG([JAVAH], [javah], [javah], [no])
+
+if test $JAVAH = no
+then
+ AC_MSG_ERROR([No javah found in \$PATH. Please install JDK 6!])
+fi
+])
diff --git a/src/m4/dps_check_plugin.m4 b/src/m4/dps_check_plugin.m4
new file mode 100644
index 0000000..a06ad6a
--- /dev/null
+++ b/src/m4/dps_check_plugin.m4
@@ -0,0 +1,98 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/dps_check_plugin.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# DPS_CHECK_JAVA_PLUGIN()
+#
+# DESCRIPTION
+#
+# This macro sets to empty on failure and to a compatible
+# version of plugin.jar otherwise. Directories searched are /usr/java/*
+# and /usr/local/java/*, which are assumed to be j{dk,re} installations.
+# Apply the shell variable as you see fit. If sun changes things so
+# /lib/plugin.jar is not the magic file it will stop working.
+#
+# This macro assumes that unzip, zipinfo or pkzipc is avialable (and can
+# list the contents of the jar archive). The first two are assumed to work
+# similarly enough to the infozip versisonms. The pkzipc version is
+# assumed to work if I undertstand the documentation on pkware's site but
+# YMMV. I do not have access to pwkware's version to test it.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Duncan Simpson
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([DPS_CHECK_JAVA_PLUGIN],
+[AC_REQUIRE([AC_PROG_AWK])
+AC_REQUIRE([AC_PROG_FGREP])
+AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc])
+AC_MSG_CHECKING([for the java plugin])
+case "x$ZIPINFO" in
+[*/zipinfo)]
+ zipinf="zipinfo -1" ;;
+[*/unzip)]
+ zipinf="unzip -l";;
+[*/pkzipc)]
+ ziping="unzipc -view";;
+[x*)]
+ AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found])
+ AC_SUBST($1,[])
+ zipinf="";;
+esac
+if test "x$zipinf" != "x"; then
+jplugin=""
+for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do
+for jfile in lib/plugin.jar jre/lib/plugin.jar; do
+if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then
+eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null
+if test $? -eq 0; then
+dnl Some version of gcj (and javac) refuse to work with some files
+dnl that pass this test. To stop this problem make sure that the compiler
+dnl still works with this jar file in the classpath
+cat << \EOF > Test.java
+/* [#]line __oline__ "configure" */
+public class Test {
+}
+EOF
+if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then
+jplugin="$jhome/$jfile"
+fi
+rm -f Test.java Test.class
+fi; fi; done; done
+if test "x$jplugin" != "x"; then
+AC_SUBST($1,$jplugin)
+AC_MSG_RESULT($jplugin)
+else
+AC_MSG_RESULT([java plugin not found])
+AC_SUBST($1,[])
+fi
+fi
+])
diff --git a/src/m4/dps_java_check_class.m4 b/src/m4/dps_java_check_class.m4
new file mode 100644
index 0000000..1f521b6
--- /dev/null
+++ b/src/m4/dps_java_check_class.m4
@@ -0,0 +1,82 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/dps_java_check_class.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# DPS_JAVA_CHECK_CLASS(,,)
+#
+# DESCRIPTION
+#
+# Test if a Java class is available. Based on AC_PROG_JAVAC_WORKS. This
+# version uses a cache variable which is both compiler, options and
+# classpath dependent (so if you switch from javac to gcj it correctly
+# notices and redoes the test).
+#
+# The macro tries to compile a minimal program importing . Some
+# newer compilers moan about the failure to use this but fail or produce a
+# class file anyway. All moaing is sunk to /dev/null since I only wanted
+# to know if the class could be imported. This is a recommended followup
+# to DPS_CHECK_JAVA_PLUGIN with classpath appropriately adjusted.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Duncan Simpson
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see .
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+AC_DEFUN([DPS_JAVA_CHECK_CLASS],[
+m4_define([cache_val],[m4_translit(dps_cv_have_java_class_$1, " ." ,"__")])
+if test "x$CLASSPATH" != "x"; then
+xtra=" with classpath ${CLASSPATH}"
+xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'`
+xopts="-classpath $xopts"
+else xtra=""; xopts=""; fi
+cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}])
+AC_CACHE_CHECK([if the $1 class is avialable$xtra], [$cache_var], [
+JAVA_TEST=Test.java
+CLASS_TEST=Test.class
+cat << \EOF > $JAVA_TEST
+/* [#]xline __oline__ "configure" */
+import $1;
+public class Test {
+}
+EOF
+if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then
+ eval "${cache_var}=yes"
+else
+ eval "${cache_var}=no"
+ echo "configure: failed program was:" >&AC_FD_CC
+ cat $JAVA_TEST >&AC_FD_CC
+fi
+rm -f $JAVA_TEST $CLASS_TEST
+])
+if eval 'test "x$'${cache_var}'" = "xyes"'; then
+$2
+true; else
+$3
+false; fi])
diff --git a/src/mf/MANIFEST.MF.src b/src/mf/MANIFEST.MF.src
new file mode 100644
index 0000000..1f75dca
--- /dev/null
+++ b/src/mf/MANIFEST.MF.src
@@ -0,0 +1,7 @@
+Name: com/verificatum/vmgj/
+Specification-Title: VMGJ
+Specification-Version: VMGJ_VERSION_STRING
+Specification-Vendor: Verificatum Project
+Implementation-Title: com.verificatum.vmgj
+Implementation-Version: VMGJ_VERSION_STRING
+Implementation-Vendor: Verificatum Project
diff --git a/tools/staticanalysis/checkstyle/checkstyle_configure.xml b/tools/staticanalysis/checkstyle/checkstyle_configure.xml
new file mode 100644
index 0000000..a498fd8
--- /dev/null
+++ b/tools/staticanalysis/checkstyle/checkstyle_configure.xml
@@ -0,0 +1,212 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/staticanalysis/checkstyle/checkstyle_filter.sh b/tools/staticanalysis/checkstyle/checkstyle_filter.sh
new file mode 100755
index 0000000..bb5a302
--- /dev/null
+++ b/tools/staticanalysis/checkstyle/checkstyle_filter.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+RAW_REPORT_FILE=$1
+REPORT_FILE=$2
+
+cat $RAW_REPORT_FILE | grep -E -v "Starting audit|Audit done" | sed "s/.*verificatum\/\(verificatum.*\)/\1/p" > $REPORT_FILE
+
+return 0
diff --git a/tools/staticanalysis/checkstyle/checkstyle_ruleset.xml b/tools/staticanalysis/checkstyle/checkstyle_ruleset.xml
new file mode 100644
index 0000000..a238660
--- /dev/null
+++ b/tools/staticanalysis/checkstyle/checkstyle_ruleset.xml
@@ -0,0 +1,337 @@
+
+
+
+
+ Ruleset used by PDM to analyze Verificatum.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/staticanalysis/checkstyle/checkstyle_suppressions.xml b/tools/staticanalysis/checkstyle/checkstyle_suppressions.xml
new file mode 100644
index 0000000..a2013f1
--- /dev/null
+++ b/tools/staticanalysis/checkstyle/checkstyle_suppressions.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/staticanalysis/checkstyle/checkstyle_wrapper b/tools/staticanalysis/checkstyle/checkstyle_wrapper
new file mode 100755
index 0000000..6487803
--- /dev/null
+++ b/tools/staticanalysis/checkstyle/checkstyle_wrapper
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+# The authors of checkstyle report the total number of issues in the
+# exit code. This is an abuse of the exit codes.
+
+checkstyle -c $1 -o $2 $3
+
+exit 0
diff --git a/tools/staticanalysis/findbugs/findbugs_configure.xml b/tools/staticanalysis/findbugs/findbugs_configure.xml
new file mode 100644
index 0000000..551c055
--- /dev/null
+++ b/tools/staticanalysis/findbugs/findbugs_configure.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/tools/staticanalysis/findbugs/findbugs_wrapper b/tools/staticanalysis/findbugs/findbugs_wrapper
new file mode 100755
index 0000000..0a93535
--- /dev/null
+++ b/tools/staticanalysis/findbugs/findbugs_wrapper
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+findbugs $@
diff --git a/tools/staticanalysis/generate_analysis.sh b/tools/staticanalysis/generate_analysis.sh
new file mode 100755
index 0000000..cf61b5a
--- /dev/null
+++ b/tools/staticanalysis/generate_analysis.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+add_result() {
+
+ TOOLNAME=$1
+ CONTENTFILE=$2
+ OUTPUTFILE=$3
+
+ printf "\n#########################################################\n" \
+>> $OUTPUTFILE
+ printf "$TOOLNAME\n\n" >> $OUTPUTFILE
+
+ CONTENT=`cat $CONTENTFILE`
+
+ if test "x$CONTENT" = x;
+ then
+ printf "NO COMPLAINTS!\n" >> $OUTPUTFILE
+ else
+ printf "%s" "$CONTENT" >> $OUTPUTFILE
+ fi
+}
+
+printf "\nCODE ANALYSIS REPORTS\n" > analysis_report.txt
+add_result "Checkstyle (configured using checkstyle_ruleset.xml and checkstyle_suppressions.xml)" checkstyle/checkstyle_report.txt analysis_report.txt
+add_result "Findbugs (configured using findbugs_configure.xml)" findbugs/findbugs_report.txt analysis_report.txt
+add_result "PMD (configured using pmd_ruleset.xml and pmd_filter.sh)" pmd/pmd_report.txt analysis_report.txt
+
+printf "\n"
diff --git a/tools/staticanalysis/pmd/pmd_filter.sh b/tools/staticanalysis/pmd/pmd_filter.sh
new file mode 100755
index 0000000..959ac90
--- /dev/null
+++ b/tools/staticanalysis/pmd/pmd_filter.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+# No filtering so far.
+cp $1 $2
+
+return 0
diff --git a/tools/staticanalysis/pmd/pmd_ruleset.xml b/tools/staticanalysis/pmd/pmd_ruleset.xml
new file mode 100644
index 0000000..a9d5cd3
--- /dev/null
+++ b/tools/staticanalysis/pmd/pmd_ruleset.xml
@@ -0,0 +1,369 @@
+
+
+
+
+ Ruleset used by PDM to analyze VECJ. Please read the comments to
+ see what rules have been commented out and why.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tools/staticanalysis/pmd/pmd_wrapper b/tools/staticanalysis/pmd/pmd_wrapper
new file mode 100755
index 0000000..0e402b6
--- /dev/null
+++ b/tools/staticanalysis/pmd/pmd_wrapper
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+
+# Copyright 2008-2018 Douglas Wikstrom
+#
+# This file is part of Verificatum Multiplicative Groups library for
+# Java (VMGJ).
+#
+# VMGJ is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# VMGJ is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public
+# License along with VMGJ. If not, see .
+
+# The authors of PMD have not provided any installation program, so we
+# need this wrapper to give a clean Makefile.am. You can simply unpack
+# the pmd directory in your home directory.
+
+pmd_run_in_dir() {
+ RES=`ls -1 $2 | grep -v zip | grep -v tar.gz | sort | grep -E "pmd-bin-?\.?\.?" | tail -n 1`
+ eval "$1=\$2/\$RES/bin/run.sh"
+}
+
+
+pmd_run_in_dir PMD_RUN $PWD
+
+if test -f $PMD_RUN;
+then
+
+ $PMD_RUN pmd $@
+
+else
+
+ pmd_run_in_dir PMD_RUN $HOME
+
+ if test -f $PMD_RUN;
+ then
+
+ $PMD_RUN pmd $@
+
+ else
+
+ echo "Failed to find any pmd binary! Please consult Makefile.am for more information."
+
+ exit 1
+ fi
+fi
+
+exit 0