gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28982 - in gnunet-java: . src/main/java/org/gnunet/constru


From: gnunet
Subject: [GNUnet-SVN] r28982 - in gnunet-java: . src/main/java/org/gnunet/construct src/main/java/org/gnunet/construct/parsers src/main/java/org/gnunet/core src/main/java/org/gnunet/mesh src/main/java/org/gnunet/mq src/main/java/org/gnunet/testbed src/main/java/org/gnunet/testing src/main/java/org/gnunet/transport src/main/java/org/gnunet/util src/main/resources/org/gnunet src/main/resources/org/gnunet/construct src/main/resources/org/gnunet/voting src/test/java/org/gnunet src/test/java/org/gnunet/construct src/test/java/org/gnunet/mesh src/test/java/org/gnunet/testbed src/test/java/org/gnunet/util
Date: Wed, 4 Sep 2013 13:20:04 +0200

Author: dold
Date: 2013-09-04 13:20:04 +0200 (Wed, 04 Sep 2013)
New Revision: 28982

Added:
   gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java
   gnunet-java/src/main/java/org/gnunet/transport/Blacklist.java
   gnunet-java/src/main/java/org/gnunet/transport/BlacklistQueryMessage.java
   gnunet-java/src/main/java/org/gnunet/transport/BlacklistReplyMessage.java
   gnunet-java/src/main/java/org/gnunet/util/CryptoECC.java
   gnunet-java/src/main/resources/org/gnunet/voting/
   gnunet-java/src/main/resources/org/gnunet/voting/template.espec
   gnunet-java/src/test/java/org/gnunet/testbed/
   gnunet-java/src/test/java/org/gnunet/testbed/TestbedTest.java
   gnunet-java/src/test/java/org/gnunet/util/CryptoECCTest.java
Removed:
   gnunet-java/src/main/java/org/gnunet/construct/MsgMap.txt
   gnunet-java/src/main/java/org/gnunet/transport/BlacklistCallback.java
Modified:
   gnunet-java/ISSUES
   gnunet-java/build.gradle
   gnunet-java/src/main/java/org/gnunet/construct/ReflectUtil.java
   gnunet-java/src/main/java/org/gnunet/construct/parsers/IntegerParser.java
   gnunet-java/src/main/java/org/gnunet/core/Core.java
   gnunet-java/src/main/java/org/gnunet/mesh/DataMessage.java
   gnunet-java/src/main/java/org/gnunet/mesh/LocalAckMessage.java
   gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java
   gnunet-java/src/main/java/org/gnunet/mesh/TunnelCreateMessage.java
   gnunet-java/src/main/java/org/gnunet/mesh/TunnelDestroyMessage.java
   gnunet-java/src/main/java/org/gnunet/mq/MessageQueue.java
   gnunet-java/src/main/java/org/gnunet/testbed/Controller.java
   gnunet-java/src/main/java/org/gnunet/testbed/ControllerProc.java
   gnunet-java/src/main/java/org/gnunet/testing/TestingSubsystem.java
   gnunet-java/src/main/java/org/gnunet/transport/AddressIterateMessage.java
   gnunet-java/src/main/java/org/gnunet/transport/Transport.java
   gnunet-java/src/main/java/org/gnunet/util/Client.java
   gnunet-java/src/main/java/org/gnunet/util/Connection.java
   gnunet-java/src/main/java/org/gnunet/util/Helper.java
   gnunet-java/src/main/java/org/gnunet/util/Scheduler.java
   gnunet-java/src/main/resources/org/gnunet/construct/MsgMap.txt
   gnunet-java/src/test/java/org/gnunet/construct/ConstructTest.java
   gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java
Log:
- blacklist is now has its own handle
- mesh fixed and tested
- voting template
- Ed25519+ecdh implemented and tested



Modified: gnunet-java/ISSUES
===================================================================
--- gnunet-java/ISSUES  2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/ISSUES  2013-09-04 11:20:04 UTC (rev 28982)
@@ -1,133 +1,97 @@
-* gnunet-testing-run-service merged into gnunet-testing
- * the whole program runs without scheduler ... shouldn't be a problem, right?
-* i'm getting a lot of warnings from the autotools (newer version)
+implementing the crypto stuff was more effort than I expected
+ * turns out I actually had to read the DJB paper
 
-* probably found a bug in (openjdk7's) warning suppression
+any 32-byte string is a valid key, right?
 
-* various issues with time unit change now fixed
- * test cases timed out ... exponential backoff unit mismatch was the cause
+should be implemented now (and has tests)
+ * awefully slow! (5sec for key generation, signing and verification)
+ * no optimizations from the paper implemented, should I look into this?
 
-* code coverage: 
- * cobertura has problems with JDK7
-  * not acceptable, even if gnunet-java uses java6
-  * newest cobertura version should work (2.x), not tried yet ...
- * what about JaCoCo?
-  * gradle has (will have) built-in support for it
-  * no instrumentation necessary (jvm agent)
-  * but: eclipse license (not gpl compatible), is this a block?
+Ed25519 implementation on github is somewhat bad
+ * substibuted recursive expmod(b,e,m) with b.modPow(e,m)
+ * Hint can be done with new BigInteger(1, h);
+ * I've added some documentation, but still don't understand most 
cryptographic details
+ * the comments used to say something about constant time comparison:
 
+      if (!ra[0].equals(rb[0]) || !ra[1].equals(rb[1])) // Constant time 
comparison
+              return false;
+      return true;
 
-* i found the "correct" way to handle junit4/scheduler: test teardown 
annotations (@After/@Before)
- * tests using the scheduler should inherit org.gnunet.testing.TestingFixture
- * other test cases are now unaffected
+   but this code does not execute in constant time! Is this detail important?
 
-* i experimented around with message / request queues
- * everything now uses an mq/envelope mechanism very similar to GNUNET_MQ
-  * difference: in gnunet-java, client, mesh tunnel, etc. _are_ message queues
- * there are request containers
-  * sequential (e.g. statistics set/get) and matching (stat. watch, core ntr)
+* the ecc crypto stuff is now implemented in java with the api similar to 
GNUNET_CRYPTO_ecc*, including
+  data structures (=org.gnunet.construct messages) etc.
 
+* what's "our" encoding of curve points?
+ * Bernstein et al. use point compression
+ * even if GNUnet does not *store* points compressed, the algorithm 
+   hashes a compressed point
+ * does GNUnet do this? do we use a different hash function?
+ok, my "best guess" / whats currently implemented:
+ * no point compression for public keys
+ * point compression for R and S in signatures
 
-* for testing org.gnunet.mesh.Mesh:
- * how should the peer's identity accessed from java?
-   GNUNET_CRYPTO_ecc_key_get_public in java?
- * => java mesh api currently can't be tested without using Core
-      (mesh _used_ to allow peerid=0, but does not anymore)
-See https://github.com/k3d3/ed25519-java/blob/master/ed25519.java
-But: https://bugs.g10code.com/gnupg/issue1469
-=> Tests: sign/verify/ECDH(E) with C/Java interactions => binary compatibility!
+* what is the reasoning behind the purpose field for signatures?
+ * i.e. why can't the user just add the field to messages if he wants to?
 
-* core:
- * the second test case seems to hang for a few seconds sometimes,
-   is this core's key generation?
- * i just increased the test timeout, works fine no, works fine now ...
+why is the key material derived from an s-expr?
+from GNUNET_CRYPTO_ecc_dh
+  /* finally, get a string of the resulting S-expression and hash it
+     to generate the key material */
+  GNUNET_CRYPTO_hash (sdata_buf, slen, key_material);
 
+ECDH neither works in my implementation, nor the python reference.
+what am I doing wrong with ECDH?
 
-* transport API:
- * discuss transport api strangeness
-  * hellos are passed around as message headers in the C API (for 
"copyability"?), what should java do?
-   * GnunetMessage or HelloMessage? Hello.
-  * I get my own hello (for get_hello) only after I send init => bad?!
-  * currently, a transport handle is required for blacklist/active address 
query
-   * should there be a seperate 
org.gnunet.transport.(Blacklist|ActiveAddressQuery)?
-     => separate blacklist handle/connection
- * testing the blacklist api? => good luck, have fun
+$ python
+>>> import ed25519 as ecc
+>>> import os
+>>> sk1 = os.urandom(32)
+>>> sk2 = os.urandom(32)
+>>> pk1 = ecc.publickey(sk1)
+>>> pk2 = ecc.publickey(sk2)
+>>> ecc.scalarmult(ecc.decodepoint(pk1), ecc.decodeint(sk2))
+[17839698087218818508188271506040749529597055621135915409627286085172612074737L,
 1568236133114249143202350357927861645459149141660189072712053603778341056893L]
+>>> ecc.scalarmult(ecc.decodepoint(pk2), ecc.decodeint(sk1))
+[49070523807924122052691980024493573448121871463721857488922928165668153903065L,
 11604814587173472450491572181106441638149561159961615227277125012932458010271L]
 
+OK, got it: see org.gnunet.util.CryptoECC.computePublicCoefficient
+One has to do this due to the non-standard key derivation
 
-statistics:
- * queing etc. now implemented with mq / new requests api
- * how do I test correct behavior on reconnect automatically?
-  * as statistics refuses to shut down when there's a (non-monitor) connection
 
-configuration:
-* what about newline in config options? they are written as "\\\n", right?
-  Tolerate \r\n.
+GNUNET_CRYPTO_hash_distance_u32 documentation is unclear (inconsistent in 
.c/.h)
+and I don't know enough about it to fix it!
 
-testbed:
+org.gnunet.mesh.Mesh is now actually tested and works after fixing some bugs
 
+starting the testbed helper (any libexec program acually):
+ * did I understand correctly, that if 'gnunet' is a substring of the binary 
name, we *only* look in libexec?
+ * logic to locate the thing is a bit complicated
 
-habitability check ... what's the best way to do this in java?
- * threads ....
+test case for testbed helper still fails, working on it
 
-* starting a controller on a host updates the host's config?
-* why do i have to send the controller hostname when connecting to a 
controller?
-* in what extent does controller_disconnect block? (see doxygen comment)
+currently, my test case somehow makes the gradle test runner fail:
 
+Unexpected exception thrown.
+org.gradle.messaging.remote.internal.MessageIOException: Could not read 
message from '/0:0:0:0:0:0:0:1:45612'.
+       at 
org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:88)
+       at 
org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionReceive.run(MessageHub.java:230)
+       at 
org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
+       at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
+       at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
+       at java.lang.Thread.run(Thread.java:724)
+Caused by: com.esotericsoftware.kryo.KryoException: Buffer underflow.
+       at com.esotericsoftware.kryo.io.Input.require(Input.java:162)
+       at com.esotericsoftware.kryo.io.Input.readByte(Input.java:255)
+       at 
org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:64)
+       at 
org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:53)
+       at 
org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:83)
+       ... 5 more
 
-GNUNET_TESTBED_HelperInit has a very "nice" format, but consensus can handle 
it ...
- * one string is zero terminated, the other not ...
- * currently the non-zero-terminated string is just implemented as 
@VariableSizeIntegerArray
-  * do we need a @VariableSizeString?
- * java's Deflater has the worst api imaginable ...
 
-* why is the host list an array?
- * creating a host with a large (e.g. random) id creates huge array
 
-  while (id >= new_size)
-    new_size += HOST_LIST_GROW_STEP;
-  if (new_size != host_list_size)
-    GNUNET_array_grow (host_list, host_list_size, new_size);
+is the election specification OK like this, or do you consider the authorities 
section abuse of syntax?
+ * how should deadlines be specified? at the moment, GNUnet seems to only 
support relative time
 
-* gnunet-java has now org.gnunet.util.Helper, which is needed for testbed
- * which is "simply" a message queue with some extra methods
- * java async process IO _requires_ threading (or using e.g. the bloated 
apache commons)
-  * Scheduler now is (or should be ;) thread safe
- * i'm not sure what to do about process stopping/killing in java
-  * only kill is implemented, i'm not sure stop() is possible in java
 
 
-* the latest version of cobertura is very large (~5MB)
-* discuss dependencies in general, discuss maven repositories and classpath 
with gradle repos
- * developer can specfiy custom repositories in the build config
-  * e.g. when the jar is probably available in the local system
- * see gradle showDeps for getting at the jar's locations
- * could have a gradle copyDeps/installDeps
- * make gradle create wrappers with correct classpath, either for development 
or
-   shipping
-
-* why not run multiple gnunet-java "applications" in one JVM?
- * would require changes the the scheduler (non-static)
- * handy for running larger testbeds and nice for command line tool startup 
times
- * nailgun nails (nailgun is apache2 licensed)
-
-* changed some paths to be more compliant with java (=intellij,gradle,maven) 
conventions
-* the gradle wrapper is checked into svn (as recommended by gradle docs)
-
-* should voting stay in the main gnunet-java tree, or be an extension?
- * being an extension would force me to maintain good compatibility of the
-   extension template
-
-
-voting
- * what should be used for signatures, voter IDs?
- * the voting ca could selectively deny voters their permission
-  * is this what we want to have "per default"?
- * review VotingTool/ElectionCallTool
-
-
-TODO:
-testbed
-review all existing gnj stuff (use request and mq)
-voting
-
-

Modified: gnunet-java/build.gradle
===================================================================
--- gnunet-java/build.gradle    2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/build.gradle    2013-09-04 11:20:04 UTC (rev 28982)
@@ -39,7 +39,7 @@
 project.ext.coverageData = "$projectDir/coverage.data"
 project.ext.coverageReportDir = "$projectDir/coverage-report"
 
-task instrument (dependsOn: 'compileJava', type: JavaExec) {
+task instrument (dependsOn: ['compileJava', 'compileTestJava'], type: 
JavaExec) {
   inputs.dir compileJava.destinationDir
   outputs.dir fileTree(dir: instrumentDir)
 
@@ -62,6 +62,7 @@
   classpath = files("$instrumentDir",
                     "$coberturaDir/cobertura.jar",
                     project.sourceSets.test.runtimeClasspath)
+  //testClassesDir = new File("$instrumentDir")
   systemProperties = ["net.sourceforge.cobertura.datafile":"$coverageData"]
 }
 

Deleted: gnunet-java/src/main/java/org/gnunet/construct/MsgMap.txt
===================================================================
--- gnunet-java/src/main/java/org/gnunet/construct/MsgMap.txt   2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/construct/MsgMap.txt   2013-09-04 
11:20:04 UTC (rev 28982)
@@ -1,46 +0,0 @@
-org.gnunet.util.Resolver$Address|0=org.gnunet.util.Resolver$TextualAddress
-org.gnunet.util.Resolver$Address|1=org.gnunet.util.Resolver$NumericAddress
-org.gnunet.util.GnunetMessage$Body|68=org.gnunet.core.DisconnectNotifyMessage
-org.gnunet.util.GnunetMessage$Body|274=org.gnunet.mesh.TunnelDestroyMessage
-org.gnunet.util.GnunetMessage$Body|1=org.gnunet.util.TestMessage
-org.gnunet.util.GnunetMessage$Body|70=org.gnunet.core.NotifyInboundTrafficMessage
-org.gnunet.util.GnunetMessage$Body|273=org.gnunet.mesh.TunnelCreateMessage
-org.gnunet.util.GnunetMessage$Body|71=org.gnunet.core.NotifyOutboundTrafficMessage
-org.gnunet.util.GnunetMessage$Body|272=org.gnunet.mesh.ClientConnectMessage
-org.gnunet.util.GnunetMessage$Body|64=org.gnunet.core.InitMessage
-org.gnunet.util.GnunetMessage$Body|4=org.gnunet.util.Resolver$GetMessage
-org.gnunet.util.GnunetMessage$Body|65=org.gnunet.core.InitReplyMessage
-org.gnunet.util.GnunetMessage$Body|5=org.gnunet.util.Resolver$ResolverResponse
-org.gnunet.util.GnunetMessage$Body|143=org.gnunet.dht.ClientGetMessage
-org.gnunet.util.GnunetMessage$Body|67=org.gnunet.core.ConnectNotifyMessage
-org.gnunet.util.GnunetMessage$Body|142=org.gnunet.dht.ClientPutMessage
-org.gnunet.util.GnunetMessage$Body|76=org.gnunet.core.SendMessage
-org.gnunet.util.GnunetMessage$Body|286=org.gnunet.mesh.LocalAckMessage
-org.gnunet.util.GnunetMessage$Body|74=org.gnunet.core.SendMessageRequest
-org.gnunet.util.GnunetMessage$Body|75=org.gnunet.core.SendMessageReady
-org.gnunet.util.GnunetMessage$Body|153=org.gnunet.dht.MonitorStartStop
-org.gnunet.util.GnunetMessage$Body|155=org.gnunet.dht.ClientPutConfirmationMessage
-org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage
-org.gnunet.util.GnunetMessage$Body|260=org.gnunet.mesh.DataMessage
-org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage
-org.gnunet.util.GnunetMessage$Body|144=org.gnunet.dht.ClientGetStopMessage
-org.gnunet.util.GnunetMessage$Body|145=org.gnunet.dht.ClientResultMessage
-org.gnunet.util.GnunetMessage$Body|332=org.gnunet.peerinfo.InfoMessage
-org.gnunet.util.GnunetMessage$Body|333=org.gnunet.peerinfo.InfoEnd
-org.gnunet.util.GnunetMessage$Body|149=org.gnunet.dht.MonitorGetMessage
-org.gnunet.util.GnunetMessage$Body|331=org.gnunet.peerinfo.ListAllPeersMessage
-org.gnunet.util.GnunetMessage$Body|150=org.gnunet.dht.MonitorGetRespMessage
-org.gnunet.util.GnunetMessage$Body|151=org.gnunet.dht.MonitorPutMessage
-org.gnunet.util.GnunetMessage$Body|171=org.gnunet.statistics.GetResponseEndMessage
-org.gnunet.util.GnunetMessage$Body|170=org.gnunet.statistics.GetResponseMessage
-org.gnunet.util.GnunetMessage$Body|169=org.gnunet.statistics.GetMessage
-org.gnunet.util.GnunetMessage$Body|168=org.gnunet.statistics.SetMessage
-org.gnunet.util.GnunetMessage$Body|374=org.gnunet.transport.RequestConnectMessage
-org.gnunet.util.GnunetMessage$Body|173=org.gnunet.statistics.WatchResponseMessage
-org.gnunet.util.GnunetMessage$Body|172=org.gnunet.statistics.WatchMessage
-org.gnunet.util.GnunetMessage$Body|524=org.gnunet.consensus.ConcludeMessage
-org.gnunet.util.GnunetMessage$Body|521=org.gnunet.consensus.InsertElementMessage
-org.gnunet.util.GnunetMessage$Body|523=org.gnunet.consensus.NewElementMessage
-org.gnunet.util.GnunetMessage$Body|360=org.gnunet.transport.StartMessage
-org.gnunet.construct.MessageUnion|525=org.gnunet.consensus.ConcludeDoneMessage
-# generated 2013/08/22 21:14:59

Modified: gnunet-java/src/main/java/org/gnunet/construct/ReflectUtil.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/construct/ReflectUtil.java     
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/construct/ReflectUtil.java     
2013-09-04 11:20:04 UTC (rev 28982)
@@ -78,7 +78,7 @@
      * An enumeration of all built-in type that can store integers.
      */
     public enum NumFieldType {
-        BIGNUM, BYTE_PRIM, SHORT_PRIM, INT_PRIM, LONG_PRIM, CHAR_PRIM
+        BIGNUM, BYTE_PRIM, SHORT_PRIM, INT_PRIM, LONG_PRIM, BOOLEAN, CHAR_PRIM
     }
 
     /**
@@ -107,6 +107,8 @@
                 targetType = NumFieldType.CHAR_PRIM;
             } else if (f.getType().equals(BigInteger.class)) {
                 targetType = NumFieldType.BIGNUM;
+            } else if (f.getType().equals(Boolean.TYPE)) {
+                targetType = NumFieldType.BOOLEAN;
             } else {
                 throw new AssertionError(
                         "expected numeric type, got: " + f.getType());
@@ -134,6 +136,9 @@
                     case BIGNUM:
                         targetField.set(obj, BigInteger.valueOf(val));
                         break;
+                    case BOOLEAN:
+                        targetField.setBoolean(obj, (val != 0));
+                        break;
                 }
             } catch (IllegalArgumentException e) {
                 throw new AssertionError("cannot access field");
@@ -163,8 +168,10 @@
                         return targetField.getByte(obj);
                     case CHAR_PRIM:
                         return targetField.getChar(obj);
+                    case BOOLEAN:
+                        return targetField.getBoolean(obj) ? 1 : 0;
                     case BIGNUM:
-                        throw new RuntimeException("get() called on NumField 
that is a BigInteger");
+                        throw new RuntimeException("get() called on NumField 
that is a BigInteger (getBig() must be used instead)");
                     default:
                         throw new AssertionError("unreachable");
                 }

Modified: 
gnunet-java/src/main/java/org/gnunet/construct/parsers/IntegerParser.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/construct/parsers/IntegerParser.java   
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/construct/parsers/IntegerParser.java   
2013-09-04 11:20:04 UTC (rev 28982)
@@ -21,9 +21,11 @@
 package org.gnunet.construct.parsers;
 
 import org.gnunet.construct.Message;
+import org.gnunet.construct.ProtocolViolationException;
 import org.gnunet.construct.ReflectUtil;
 
 import java.lang.reflect.Field;
+import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
 import java.util.List;
 
@@ -59,10 +61,14 @@
     @Override
     public int parse(final ByteBuffer srcBuf, int frameOffset, Message 
frameObj, final Message dstObj, List<Field>
             frameSizePath) {
-        if (targetField.isBig()) {
-            targetField.set(dstObj, IntegerUtil.readBigInteger(srcBuf, 
isSigned, byteSize));
-        } else {
-            targetField.set(dstObj, IntegerUtil.readLong(srcBuf, isSigned, 
byteSize));
+        try {
+            if (targetField.isBig()) {
+                targetField.set(dstObj, IntegerUtil.readBigInteger(srcBuf, 
isSigned, byteSize));
+            } else {
+                targetField.set(dstObj, IntegerUtil.readLong(srcBuf, isSigned, 
byteSize));
+            }
+        } catch (BufferUnderflowException e) {
+            throw new ProtocolViolationException("Underflow while parsing " + 
targetField);
         }
         return byteSize;
     }

Modified: gnunet-java/src/main/java/org/gnunet/core/Core.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/Core.java 2013-09-04 11:04:38 UTC 
(rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/core/Core.java 2013-09-04 11:20:04 UTC 
(rev 28982)
@@ -292,6 +292,24 @@
     }
 
     /**
+     * Helper function to retrieve the peer identity with the given 
configuration via CORE.
+     * Should <b>not</b> be used unless there is no other means to obtain the 
peer identity.
+     *
+     * @param cfg
+     * @param cont
+     */
+    public static void withPeerIdentity(Configuration cfg, final 
PeerIdentityContinuation cont) {
+        final Core core = new Core(cfg);
+        core.init(new InitCallback() {
+            @Override
+            public void onInit(PeerIdentity myIdentity) {
+                core.disconnect();
+                cont.cont(myIdentity);
+            }
+        });
+    }
+
+    /**
      * Observe outgoing message headers from core.
      * @param h callback
      */

Added: gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java     
                        (rev 0)
+++ gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java     
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,7 @@
+package org.gnunet.core;
+
+import org.gnunet.util.PeerIdentity;
+
+public interface PeerIdentityContinuation {
+    public void cont(PeerIdentity peerIdentity);
+}

Modified: gnunet-java/src/main/java/org/gnunet/mesh/DataMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/DataMessage.java  2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/mesh/DataMessage.java  2013-09-04 
11:20:04 UTC (rev 28982)
@@ -9,10 +9,10 @@
  *
  * @author Florian Dold
  */
address@hidden(260)
address@hidden(285)
 public class DataMessage implements GnunetMessage.Body {
     @UInt32
-    public int tid;
+    public long tid;
     @FillWith
     @UInt8
     public byte[] payload;

Modified: gnunet-java/src/main/java/org/gnunet/mesh/LocalAckMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/LocalAckMessage.java      
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/mesh/LocalAckMessage.java      
2013-09-04 11:20:04 UTC (rev 28982)
@@ -12,7 +12,5 @@
 @UnionCase(286)
 public class LocalAckMessage implements GnunetMessage.Body {
     @UInt32
-    public int tid;
-    @UInt32
-    public int maxPid;
+    public long tid;
 }

Modified: gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java 2013-09-04 11:04:38 UTC 
(rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java 2013-09-04 11:20:04 UTC 
(rev 28982)
@@ -47,13 +47,13 @@
      * For tunnels created by the client, the bit in this
      * mask is always set.
      */
-    private static final int TUNNEL_ID_CLI = 0x80000000;
+    private static final long TUNNEL_ID_CLI = 0x80000000L;
 
     /**
      * For tunnels created by the server, the bit in this
      * mask is always set.
      */
-    private static final int TUNNEL_ID_SERV = 0xB0000000;
+    private static final long TUNNEL_ID_SERV = 0xB0000000L;
 
     /**
      * Disable buffering on intermediate nodes (for minimum latency).
@@ -96,13 +96,13 @@
     /**
      * Mapping from the tunnel's ID to the tunnel object.
      */
-    private Map<Integer,Tunnel> tunnelMap = new HashMap<Integer,Tunnel>();
+    private Map<Long,Tunnel> tunnelMap = new HashMap<Long,Tunnel>();
 
     /**
      * Counter for generating fresh tunnel ID's
      * when creating new tunnels.
      */
-    private int next_tid = 1;
+    private long next_tid = 1;
 
     /**
      * A tunnel to a remote peer.
@@ -113,9 +113,9 @@
         private final int opt;
         public final PeerIdentity peer;
         public final int port;
-        protected int tunnelId;
+        protected long tunnelId;
         private boolean receive_done_expected = false;
-        int ack_count = 1;
+        int ack_count = 0;
 
         /**
          * Canceler for the currently submitted envelope.
@@ -153,19 +153,25 @@
          * @param nobuffer
          * @param reliable
          */
-        public Tunnel(PeerIdentity peer, int tunnelId, int port, boolean 
nobuffer, boolean reliable) {
+        public Tunnel(PeerIdentity peer, long tunnelId, int port, boolean 
nobuffer, boolean reliable) {
             int my_opt = 0;
             if (reliable)
                 my_opt |= OPTION_RELIABLE;
             if (nobuffer)
                 my_opt |= OPTION_NOBUFFER;
-            if (0 == tunnelId)
-                this.tunnelId = ((next_tid++) | TUNNEL_ID_CLI) & 
~TUNNEL_ID_SERV;
-            else
+            if (0 == tunnelId) {
+                this.tunnelId = next_tid++;
+                this.tunnelId &= ~TUNNEL_ID_SERV;
+                this.tunnelId |= TUNNEL_ID_CLI;
+            }
+            else {
                 this.tunnelId = tunnelId;
+            }
             this.peer = peer;
             this.port = port;
             this.opt = my_opt;
+            logger.debug("registering tunnel {}", this.tunnelId);
+            tunnelMap.put(this.tunnelId, this);
         }
 
         public void receiveDone() {
@@ -180,20 +186,24 @@
         public void destroy() {
             TunnelDestroyMessage m = new TunnelDestroyMessage();
             m.tunnel_id = tunnelId;
+            m.reserved = new byte[32];
             client.send(m);
+            tunnelMap.remove(m.tunnel_id);
         }
 
         @Override
         protected void submit(Envelope ev) {
+            logger.debug("submitting data message on tunnel {}", tunnelId);
             if (ack_count <= 0)
                 throw new AssertionError();
             DataMessage m = new DataMessage();
             m.payload = Construct.toBinary(GnunetMessage.fromBody(ev.message));
+            m.tid = tunnelId;
             Envelope mesh_ev = new Envelope(m);
             mesh_ev.notifySent(new NotifySentHandler() {
                 @Override
                 public void onSent() {
-                    envelopeCanceler = null;
+                    envelopeCanceler = null; reportMessageSent();
                 }
             });
             client.send(mesh_ev);
@@ -217,12 +227,20 @@
             context = newContext;
         }
 
+        public void handleAck() {
+            ack_count++;
+            logger.debug("got ack for tunnel id " + tunnelId);
+            if (ack_count == 1) {
+                reportReadyForSubmit();
+            }
+        }
     }
 
     private class MeshMessageReceiver extends RunaboutMessageReceiver {
         public void visit(TunnelCreateMessage m) {
             Tunnel t = new Tunnel(m.otherEnd, m.tunnel_id, m.port,
                     (m.opt & OPTION_NOBUFFER) != 0, (m.opt & OPTION_NOBUFFER) 
!= 0);
+            logger.debug("inbound tunnel {}", m.tunnel_id);
             if (inboundTunnelHandler != null) {
                 inboundTunnelHandler.onInboundTunnel(t, m.otherEnd);
             }
@@ -240,9 +258,13 @@
         }
 
         public void visit(LocalAckMessage m) {
+            logger.debug("got LocalAckMessage for {}", m.tid);
             Tunnel t = tunnelMap.get(m.tid);
-            if (t != null)
-                t.ack_count += 1;
+            if (t != null) {
+                t.handleAck();
+            } else {
+                logger.warn("tunnel id for local ack not found");
+            }
         }
 
         public void visit(TunnelDestroyMessage m) {
@@ -286,6 +308,8 @@
         this.ports = ports;
         this.inboundTunnelHandler = inboundTunnelHandler;
 
+        logger.debug("mesh handle created");
+
         client = new Client("mesh", cfg);
         client.installReceiver(new MeshMessageReceiver());
         ClientConnectMessage ccm = new ClientConnectMessage();

Modified: gnunet-java/src/main/java/org/gnunet/mesh/TunnelCreateMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/TunnelCreateMessage.java  
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/mesh/TunnelCreateMessage.java  
2013-09-04 11:20:04 UTC (rev 28982)
@@ -14,7 +14,7 @@
 @UnionCase(273)
 public class TunnelCreateMessage implements GnunetMessage.Body {
     @UInt32
-    public int tunnel_id;
+    public long tunnel_id;
 
     @NestedMessage(optional = false)
     public PeerIdentity otherEnd;

Modified: gnunet-java/src/main/java/org/gnunet/mesh/TunnelDestroyMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/TunnelDestroyMessage.java 
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/mesh/TunnelDestroyMessage.java 
2013-09-04 11:20:04 UTC (rev 28982)
@@ -1,8 +1,11 @@
 package org.gnunet.mesh;
 
+import org.gnunet.construct.FixedSizeIntegerArray;
+import org.gnunet.construct.NestedMessage;
 import org.gnunet.construct.UInt32;
 import org.gnunet.construct.UnionCase;
 import org.gnunet.util.GnunetMessage;
+import org.gnunet.util.PeerIdentity;
 
 /**
  * ...
@@ -12,5 +15,13 @@
 @UnionCase(274)
 public class TunnelDestroyMessage implements GnunetMessage.Body {
     @UInt32
-    public int tunnel_id;
+    public long tunnel_id;
+
+    @FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
+    public byte[] reserved;
+    @UInt32
+    public int port;
+
+    @UInt32
+    public int opt;
 }

Modified: gnunet-java/src/main/java/org/gnunet/mq/MessageQueue.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mq/MessageQueue.java   2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/mq/MessageQueue.java   2013-09-04 
11:20:04 UTC (rev 28982)
@@ -11,10 +11,19 @@
 public abstract class MessageQueue {
     private LinkedList<Envelope> queued_envelopes = new LinkedList<Envelope>();
     private LinkedList<Envelope> prefered_queued_envelopes = new 
LinkedList<Envelope>();
-    protected Envelope current_envelope;
+    protected Envelope currentEnvelope;
+    private boolean readyForSubmit;
 
+    /**
+     * Submit a message. Once the message can't be canceled,
+     * reportMessageSent must be called.
+     * @param ev envelope to submit
+     */
     protected abstract void submit(Envelope ev);
 
+    /**
+     * Cancel a message that already has been submitted.
+     */
     protected abstract void retract();
 
     public void send(GnunetMessage.Body body) {
@@ -25,6 +34,16 @@
         sendPrefered(new Envelope(body));
     }
 
+    public void send(Envelope ev) {
+        queued_envelopes.addLast(ev);
+        trySubmitNext();
+    }
+
+    public void sendPrefered(Envelope ev) {
+        prefered_queued_envelopes.addLast(ev);
+        trySubmitNext();
+    }
+
     private Envelope pollNextEnvelope() {
         if (!prefered_queued_envelopes.isEmpty())
             return prefered_queued_envelopes.removeFirst();
@@ -33,49 +52,46 @@
         return null;
     }
 
-    public void send(Envelope ev) {
-        if (null == current_envelope) {
-            current_envelope = ev;
-            submit(current_envelope);
-        } else {
-            queued_envelopes.addLast(ev);
+    protected void trySubmitNext() {
+        if (currentEnvelope != null || !readyForSubmit) {
+            return;
         }
+        Envelope ev = pollNextEnvelope();
+        if (ev == null) {
+            return;
+        }
+        currentEnvelope = ev;
+        readyForSubmit = false;
+        submit(currentEnvelope);
     }
 
-    public void sendPrefered(Envelope ev) {
-        if (null == current_envelope) {
-            current_envelope = ev;
-            submit(current_envelope);
-        } else {
-            prefered_queued_envelopes.addLast(ev);
+    protected void reportReadyForSubmit() {
+        if (readyForSubmit) {
+            throw new AssertionError("message queue reported 'ready for 
submit' twice");
         }
+        readyForSubmit = true;
+        trySubmitNext();
     }
 
     protected void reportMessageSent() {
-        if (null == current_envelope)
+        if (null == currentEnvelope)
             throw new AssertionError();
-        current_envelope.invokeSentNotification();
-        next();
+        currentEnvelope.invokeSentNotification();
+        currentEnvelope = null;
+        trySubmitNext();
     }
 
-    private void next() {
-        current_envelope = pollNextEnvelope();
-        if (current_envelope == null)
-            return;
-        submit(current_envelope);
-    }
-
     /**
      * Cancel sending an envelope. The envelope must be queued in this message 
queue.
      *
      * @param ev the envelope to cancel
      */
     /* pkg-private */ void cancelEnvelope(Envelope ev) {
-        if (null == current_envelope)
+        if (null == currentEnvelope)
             throw new AssertionError();
-        if (ev == current_envelope) {
+        if (ev == currentEnvelope) {
             retract();
-            next();
+            trySubmitNext();
         } else {
             queued_envelopes.remove(ev);
             prefered_queued_envelopes.remove(ev);

Modified: gnunet-java/src/main/java/org/gnunet/testbed/Controller.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/testbed/Controller.java        
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/testbed/Controller.java        
2013-09-04 11:20:04 UTC (rev 28982)
@@ -37,7 +37,6 @@
         client = new Client("testbed", host.cfg);
     }
 
-
     /**
      * Create the given peer at the specified host using the given
      * controller.  If the given controller is not running on the target
@@ -70,7 +69,6 @@
         return null;
     }
 
-
     /**
      * Stop the given controller (also will terminate all peers and
      * controllers dependent on this controller).  This function

Modified: gnunet-java/src/main/java/org/gnunet/testbed/ControllerProc.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/testbed/ControllerProc.java    
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/testbed/ControllerProc.java    
2013-09-04 11:20:04 UTC (rev 28982)
@@ -13,20 +13,29 @@
  * the testbed helper on a remote machine.
  */
 public class ControllerProc {
-    final Helper helper;
+    private Helper helper;
 
 
     public class ControllerProcReceiver extends RunaboutMessageReceiver {
         public void visit(HelperReplyMessage m) {
+            System.out.println("got controller proc message");
 
         }
+
         @Override
         public void handleError() {
-
+            throw new AssertionError();
         }
     }
 
     /**
+     * Create a controller proc. Nothing will hapen until ControllerProc.start 
is called.
+     */
+    public void ControllerProc() {
+
+    }
+
+    /**
      * Starts a controller process at the given host.  The given host's 
configration
      * is used as a Template configuration to use for the remote controller; 
the
      * remote controller will be started with a slightly modified configuration
@@ -47,15 +56,25 @@
      *          (synchronous errors will be signalled by returning NULL). This
      *          parameter cannot be NULL.
      */
-    public ControllerProc(String trustedIP, Host host, 
ControllerStatusCallback cb) {
+    public void start(String trustedIP, Host host, ControllerStatusCallback 
cb) {
         if (host.isLocal()) {
-            helper = new Helper(false, "gnunet-testbed-helper", null, new 
ControllerProcReceiver());
+            helper = new Helper(false, "gnunet-helper-testbed", null, new 
ControllerProcReceiver());
         } else {
             throw new AssertionError("not implemented yet");
         }
+        helper.send(makeHelperInitMessage(trustedIP, host));
     }
 
+    /**
+     * Stop the controller process (also will terminate all peers and 
controllers
+     * dependent on this controller).  This function blocks until the testbed 
has
+     * been fully terminated (!). The controller status cb will not be called.
+     */
+    public void stop() {
+        throw new AssertionError("not implemented");
+    }
 
+
     private HelperInitMessage makeHelperInitMessage(String trustedIP, Host 
host) {
         HelperInitMessage m = new HelperInitMessage();
         if (host.hostname == null) {

Modified: gnunet-java/src/main/java/org/gnunet/testing/TestingSubsystem.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/testing/TestingSubsystem.java  
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/testing/TestingSubsystem.java  
2013-09-04 11:20:04 UTC (rev 28982)
@@ -85,15 +85,8 @@
 
         cfg = new Configuration();
         cfg.parse(cfgFileName);
+    }
 
-        try {
-            if (p.getErrorStream().available() != 0) {
-                throw new TestingSetup.SetupException("error starting 
service");
-            }
-        } catch (IOException e) {
-            throw new TestingSetup.SetupException(e);
-        }
-    }
     public void destroy() {
         try {
             writer.write("q\n");

Modified: 
gnunet-java/src/main/java/org/gnunet/transport/AddressIterateMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/transport/AddressIterateMessage.java   
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/transport/AddressIterateMessage.java   
2013-09-04 11:20:04 UTC (rev 28982)
@@ -5,6 +5,7 @@
 import org.gnunet.construct.UInt32;
 import org.gnunet.construct.UnionCase;
 import org.gnunet.util.AbsoluteTime;
+import org.gnunet.util.GnunetMessage;
 import org.gnunet.util.PeerIdentity;
 
 
@@ -13,7 +14,7 @@
  * asking for binary addresses known for a peer.
  */
 @UnionCase(380)
-public class AddressIterateMessage {
+public class AddressIterateMessage implements GnunetMessage.Body {
     /**
      * One shot call or continous replies?
      */

Added: gnunet-java/src/main/java/org/gnunet/transport/Blacklist.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/transport/Blacklist.java               
                (rev 0)
+++ gnunet-java/src/main/java/org/gnunet/transport/Blacklist.java       
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,55 @@
+package org.gnunet.transport;
+
+import org.gnunet.util.Client;
+import org.gnunet.util.Configuration;
+import org.gnunet.util.PeerIdentity;
+import org.gnunet.util.RunaboutMessageReceiver;
+
+/**
+ * Transport blacklist.
+ */
+public abstract class Blacklist {
+    /**
+     * Client connecting to the transport service.
+     */
+    private Client client;
+
+    private final class TransportReceiver extends RunaboutMessageReceiver {
+        void visit(BlacklistQueryMessage m) {
+            boolean allowed = isAllowed(m.peer);
+            BlacklistReplyMessage mr = new BlacklistReplyMessage();
+            mr.is_allowed = allowed;
+            mr.peer = m.peer;
+            client.send(mr);
+        }
+
+        @Override
+        public void handleError() {
+            client.reconnect();
+            client.send(new BlacklistInitMessage());
+        }
+    }
+
+    /**
+     * Install a blacklist callback.  The service will be queried for all
+     * existing connections as well as any fresh connections to check if
+     * they are permitted.
+     * The blacklist is active until the Transport handle is destroyed.
+     * When the transport handle that installed the blacklist is destroyed,
+     * all hosts that were denied in the past will automatically be
+     * whitelisted again.  This is the only way to re-enable
+     * connections from peers that were previously blacklisted.
+     */
+    public Blacklist(Configuration cfg) {
+        client = new Client("transport", cfg);
+        client.send(new BlacklistInitMessage());
+        client.installReceiver(new TransportReceiver());
+    }
+
+    public void destroy() {
+        client.disconnect();
+        client = null;
+    }
+
+    protected abstract boolean isAllowed(PeerIdentity peer);
+}

Deleted: gnunet-java/src/main/java/org/gnunet/transport/BlacklistCallback.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/transport/BlacklistCallback.java       
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/transport/BlacklistCallback.java       
2013-09-04 11:20:04 UTC (rev 28982)
@@ -1,12 +0,0 @@
-package org.gnunet.transport;
-
-import org.gnunet.util.PeerIdentity;
-
-/**
- * ...
- *
- * @author Florian Dold
- */
-public interface BlacklistCallback {
-    boolean isAllowed(PeerIdentity peerIdentity);
-}

Added: gnunet-java/src/main/java/org/gnunet/transport/BlacklistQueryMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/transport/BlacklistQueryMessage.java   
                        (rev 0)
+++ gnunet-java/src/main/java/org/gnunet/transport/BlacklistQueryMessage.java   
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,16 @@
+package org.gnunet.transport;
+
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UInt32;
+import org.gnunet.construct.UnionCase;
+import org.gnunet.util.GnunetMessage;
+import org.gnunet.util.PeerIdentity;
+
address@hidden(370)
+public class BlacklistQueryMessage implements GnunetMessage.Body {
+    @UInt32
+    public byte reserved;
+
+    @NestedMessage
+    public PeerIdentity peer;
+}

Added: gnunet-java/src/main/java/org/gnunet/transport/BlacklistReplyMessage.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/transport/BlacklistReplyMessage.java   
                        (rev 0)
+++ gnunet-java/src/main/java/org/gnunet/transport/BlacklistReplyMessage.java   
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,16 @@
+package org.gnunet.transport;
+
+import org.gnunet.construct.NestedMessage;
+import org.gnunet.construct.UInt32;
+import org.gnunet.construct.UnionCase;
+import org.gnunet.util.GnunetMessage;
+import org.gnunet.util.PeerIdentity;
+
address@hidden(371)
+public class BlacklistReplyMessage implements GnunetMessage.Body {
+    @UInt32
+    public boolean is_allowed;
+
+    @NestedMessage
+    public PeerIdentity peer;
+}

Modified: gnunet-java/src/main/java/org/gnunet/transport/Transport.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/transport/Transport.java       
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/transport/Transport.java       
2013-09-04 11:20:04 UTC (rev 28982)
@@ -19,12 +19,6 @@
 
     boolean init_requested;
 
-    /**
-     * Blacklist callback, null if there is no active blacklist
-     * for this handle.
-     */
-    BlacklistCallback blacklistCallback;
-
     private final class TransportReceiver extends RunaboutMessageReceiver {
         @Override
         public void handleError() {
@@ -113,27 +107,6 @@
     }
 
     /**
-     * Install a blacklist callback.  The service will be queried for all
-     * existing connections as well as any fresh connections to check if
-     * they are permitted.
-     * The blacklist is active until the Transport handle is destroyed.
-     * When the transport handle that installed the blacklist is destroyed,
-     * all hosts that were denied in the past will automatically be
-     * whitelisted again.  This is the only way to re-enable
-     * connections from peers that were previously blacklisted.
-     *
-     * @param blacklistCallback  callback to invoke to check if connections 
are allowed
-     */
-    public void blacklist(BlacklistCallback blacklistCallback) {
-        if (this.blacklistCallback != null)
-            throw new AssertionError("there is already a blacklist");
-        if (blacklistCallback == null)
-            throw new AssertionError("blacklist callback may not be null");
-        this.blacklistCallback = blacklistCallback;
-        client.send(new BlacklistInitMessage());
-    }
-
-    /**
      * Return all the known addresses for a specific peer or all peers.
      * Returns continuously all address if one_shot is set to false
      * <p/>

Modified: gnunet-java/src/main/java/org/gnunet/util/Client.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/Client.java       2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/util/Client.java       2013-09-04 
11:20:04 UTC (rev 28982)
@@ -121,6 +121,8 @@
             throw new 
Configuration.ConfigurationException(String.format("hostname of service '%s' 
empty", serviceName));
         }
         reconnect();
+        // we don't have to wait for any acks, but can send right away!
+        reportReadyForSubmit();
     }
 
     /**
@@ -133,6 +135,8 @@
         this.hostname = hostname;
         this.port = port;
         reconnect();
+        // we don't have to wait for any acks, but can send right away!
+        reportReadyForSubmit();
     }
 
 
@@ -286,6 +290,7 @@
             public void cont(boolean success) {
                 currentSubmit = null;
                 reportMessageSent();
+                reportReadyForSubmit();
             }
         });
     }

Modified: gnunet-java/src/main/java/org/gnunet/util/Connection.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/Connection.java   2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/util/Connection.java   2013-09-04 
11:20:04 UTC (rev 28982)
@@ -214,7 +214,7 @@
                     int n = connectionChannel.read(recvBuffer);
                     if (n == -1) {
                         currentReceiveHelper = null;
-                        logger.warn("lost connection to service");
+                        logger.warn("lost connection to service, {}", 
connectionChannel.socket().toString());
                         connectionChannel.close();
                         connectionChannel = null;
                         if (Connection.this.currentTransmitHelper != null) {
@@ -384,7 +384,8 @@
                         String.format("tried to send message with binary size 
%s but size in header %s",
                                 b.length, gm.header.messageSize));
             }
-            logger.debug("sending message (size={},type={})", b.length, 
gm.header.messageType);
+            logger.debug("sending message (size={},type={}) over {}",
+                    new String[] {String.valueOf(b.length), 
String.valueOf(gm.header.messageType), connectionChannel.socket().toString()});
             if (transmitBuffer.remaining() < b.length) {
                 ByteBuffer buf = ByteBuffer.allocate(b.length + 
transmitBuffer.capacity());
                 transmitBuffer.flip();

Added: gnunet-java/src/main/java/org/gnunet/util/CryptoECC.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/CryptoECC.java                    
        (rev 0)
+++ gnunet-java/src/main/java/org/gnunet/util/CryptoECC.java    2013-09-04 
11:20:04 UTC (rev 28982)
@@ -0,0 +1,360 @@
+package org.gnunet.util;
+
+import org.gnunet.construct.FixedSizeIntegerArray;
+import org.gnunet.construct.Message;
+import org.gnunet.construct.ProtocolViolationException;
+import org.gnunet.construct.UInt32;
+
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Implementation of the Ed25519 public-key signature system.
+ * Original version written and placed into the public domain by k3d3 
(https://github.com/k3d3/ed25519-java).
+ * See also http://ed25519.cr.yp.to/.
+ */
+public class CryptoECC {
+
+    /**
+     * Private ECC key.
+     */
+    public static final class PrivateKey implements Message {
+        /**
+         * Value of the private key, represents a number modulo q.
+         * The number is stored as little endian.
+         */
+        @FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
+        public byte[] d;
+    }
+
+    /**
+     * Public ECC key.
+     */
+    public static final class PublicKey implements Message {
+        /**
+         * x-coordinate of the point on the curve.
+         * The number is stored as little endian.
+         */
+        @FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
+        public byte[] x;
+
+        /**
+         * y-coordinate of the point on the curve.
+         * The number is stored as little endian.
+         */
+        @FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
+        public byte[] y;
+
+    }
+
+    /**
+     * ECC Signature.
+     */
+    public static final class Signature implements Message {
+        /**
+         * R-value of the signature.
+         * The number is stored as little endian.
+         */
+        @FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
+        public byte[] r;
+
+        /**
+         * S-value of the signature.
+         * The number is stored as little endian.
+         */
+        @FixedSizeIntegerArray(bitSize = 8, signed = false, length = 32)
+        public byte[] s;
+    }
+
+    // curve parameter b
+    private static final int b = 256;
+    // curve parameter q
+    private static final BigInteger q = new 
BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564819949");
+    // q-3
+    private static final BigInteger qm2 = new 
BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564819947");
+    // q-3
+    private static final BigInteger qp3 = new 
BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564819952");
+    private static final BigInteger l = new 
BigInteger("7237005577332262213973186563042994240857116359379907606001950938285454250989");
+    private static final BigInteger d = new 
BigInteger("-4513249062541557337682894930092624173785641285191125241628941591882900924598840740");
+    private static final BigInteger I = new 
BigInteger("19681161376707505956807079304988542015446066515923890162744021073123829784752");
+    private static final BigInteger By = new 
BigInteger("46316835694926478169428394003475163141307993866256225615783033603165251855960");
+    private static final BigInteger Bx = new 
BigInteger("15112221349535400772501151409588531511454012693041857206046113283949847762202");
+    private static final BigInteger[] B = {Bx.mod(q),By.mod(q)};
+    // 2^255
+    private static final BigInteger un = new 
BigInteger("57896044618658097711785492504343953926634992332820282019728792003956564819967");
+
+    static final private MessageDigest sha512;
+    static {
+        try {
+            sha512 = MessageDigest.getInstance("SHA-512");
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException("SHA-512 not available");
+        }
+    }
+
+    /**
+     * Computes the multiplicative inverse of x modulo q using Euler's theorem.
+     *
+     * @param x the group element to invert
+     * @return the inverse of x modulo q
+     */
+    private static BigInteger inv(BigInteger x) {
+        return x.modPow(qm2, q);
+    }
+
+    /**
+     * Compute the x-component of a point on our curve from
+     * the y-coordinate.
+     *
+     * @param y the y-coordinate of a point
+     * @return the x-coordinate of the point (x,y) on the curve
+     */
+    private static BigInteger xrecover(BigInteger y) {
+        BigInteger y2 = y.multiply(y);
+        BigInteger xx = 
(y2.subtract(BigInteger.ONE)).multiply(inv(d.multiply(y2).add(BigInteger.ONE)));
+        BigInteger x = xx.modPow(qp3.divide(BigInteger.valueOf(8)), q);
+        if (!x.multiply(x).subtract(xx).mod(q).equals(BigInteger.ZERO)) x = 
(x.multiply(I).mod(q));
+        if (!x.mod(BigInteger.valueOf(2)).equals(BigInteger.ZERO)) x = 
q.subtract(x);
+        return x;
+    }
+
+    /**
+     * Implements the group operation (twisted Edwards addition) on our curve.
+     *
+     * @param P a point on the curve
+     * @param Q another point on the curve
+     * @return P+Q
+     */
+    private static BigInteger[] edwards(BigInteger[] P, BigInteger[] Q) {
+        BigInteger x1 = P[0];
+        BigInteger y1 = P[1];
+        BigInteger x2 = Q[0];
+        BigInteger y2 = Q[1];
+        BigInteger dtemp = 
d.multiply(x1).multiply(x2).multiply(y1).multiply(y2);
+        BigInteger x3 = 
((x1.multiply(y2)).add((x2.multiply(y1)))).multiply(inv(BigInteger.ONE.add(dtemp)));
+        BigInteger y3 = 
((y1.multiply(y2)).add((x1.multiply(x2)))).multiply(inv(BigInteger.ONE.subtract(dtemp)));
+        return new BigInteger[]{x3.mod(q), y3.mod(q)};
+    }
+
+    /**
+     * Multiply a point on the curve with a constant.
+     *
+     * @param P point on the curve
+     * @param e constant
+     * @return eP
+     */
+    private static BigInteger[] scalarmult(BigInteger[] P, BigInteger e) {
+        if (e.equals(BigInteger.ZERO)) {
+            return new BigInteger[]{BigInteger.ZERO, BigInteger.ONE};
+        }
+        BigInteger[] Q = scalarmult(P, e.shiftRight(1));
+        Q = edwards(Q, Q);
+        if (e.testBit(0)) Q = edwards(Q, P);
+        return Q;
+    }
+
+    /**
+     * Encode an integer to binary format.
+     *
+     * @param y integer to encode
+     * @return encoded integer as byte array
+     */
+    private static byte[] encodeint(BigInteger y) {
+        byte[] in = y.toByteArray();
+        // reverse the array
+        for (int i = 0; i < in.length / 2; i++) {
+            byte tmp = in[i];
+            in[i] = in[in.length - i - 1];
+            in[in.length - i - 1] = tmp;
+        }
+        return in;
+    }
+
+    /**
+     * Encode a point to binary format.
+     *
+     * @param P point to encode
+     * @return encoded point as byte array
+     */
+    private static byte[] encodepoint(BigInteger[] P) {
+        BigInteger x = P[0];
+        BigInteger y = P[1];
+        byte[] out = encodeint(y);
+        out[out.length-1] |= (x.testBit(0) ? 0x80 : 0);
+        return out;
+    }
+
+    /**
+     * Get return the i-th bit in the given array of bytes h.
+     *
+     * @param h array of bytes
+     * @param i bit index
+     * @return i-th bit in h
+     */
+    private static int bit(byte[] h, int i) {
+        return h[i/8] >> (i%8) & 1;
+    }
+
+    static private BigInteger computePublicKeyCoefficient(PrivateKey sk) {
+        byte[] h = sha512.digest(sk.d);
+        BigInteger a = BigInteger.valueOf(2).pow(b-2);
+        for (int i=3; i < (b - 2); i++) {
+            BigInteger apart = 
BigInteger.valueOf(2).pow(i).multiply(BigInteger.valueOf(bit(h,i)));
+            a = a.add(apart);
+        }
+        return a;
+    }
+
+    /**
+     * Derive the public key from the private key 'sk',
+     *
+     * @param sk private key
+     * @return public key derived from 'sk'
+     */
+    static public PublicKey computePublicKey(PrivateKey sk) {
+        BigInteger a = computePublicKeyCoefficient(sk);
+        BigInteger[] A = scalarmult(B, a);
+        PublicKey publicKey = new PublicKey();
+        publicKey.x = encodeint(A[0]);
+        publicKey.y = encodeint(A[1]);
+        return publicKey;
+    }
+
+    /**
+     * Hash the data in m and return 2^h(m)
+     *
+     * @param m data to hash
+     * @return 2^h(m)
+     */
+    static private BigInteger Hint(byte[] m) {
+        final byte[] h = sha512.digest(m);
+        for (int i = 0; i < 32; i++) {
+            byte tmp = h[i];
+            h[i] = h[63 - i];
+            h[63 - i] = tmp;
+        }
+        return new BigInteger(1, h);
+    }
+
+    /**
+     * Sign a message.
+     *
+     * @param m the message to sign
+     * @param sk the private (secret) key
+     * @param pk the public key, derived from 'sk', but passed as a
+     *           parameter for performance reasons
+     * @return a signature on m
+     */
+    public static Signature sign(byte[] m, PrivateKey sk, PublicKey pk) {
+        byte[] compressed_pk = encodepoint(new BigInteger[]{decodeint(pk.x), 
decodeint(pk.y)});
+        byte[] h = sha512.digest(sk.d);
+        BigInteger a = BigInteger.valueOf(2).pow(b-2);
+        for (int i = 3; i < (b - 2); i++) {
+            a = 
a.add(BigInteger.valueOf(2).pow(i).multiply(BigInteger.valueOf(bit(h,i))));
+        }
+        ByteBuffer rsub = ByteBuffer.allocate((b/8)+m.length);
+        rsub.put(h, b/8, b/4-b/8).put(m);
+        BigInteger r = Hint(rsub.array());
+        BigInteger[] R = scalarmult(B,r);
+
+        Signature sig = new Signature();
+        sig.r = encodepoint(R);
+
+        ByteBuffer buf = ByteBuffer.allocate(32 + compressed_pk.length + 
m.length);
+        buf.put(encodepoint(R)).put(compressed_pk).put(m);
+
+        BigInteger S = r.add(Hint(buf.array()).multiply(a)).mod(l);
+        sig.s = encodeint(S);
+
+        return sig;
+    }
+
+    /**
+     * Check if a point is on the curve.
+     *
+     * @param P point to check
+     * @return whether the point P is on the curve
+     */
+    private static boolean isoncurve(BigInteger[] P) {
+        BigInteger x = P[0];
+        BigInteger y = P[1];
+        BigInteger xx = x.multiply(x);
+        BigInteger yy = y.multiply(y);
+        BigInteger dxxyy = d.multiply(yy).multiply(xx);
+        return 
xx.negate().add(yy).subtract(BigInteger.ONE).subtract(dxxyy).mod(q).equals(BigInteger.ZERO);
+    }
+
+    /**
+     * Decode an integer from its binary form.
+     *
+     * @param s the binary form if the integer
+     * @return the decoded integer
+     */
+    private static BigInteger decodeint(byte[] s) {
+        byte[] out = new byte[s.length];
+        for (int i=0;i<s.length;i++) {
+            out[i] = s[s.length-1-i];
+        }
+        return new BigInteger(out).and(un);
+    }
+
+    /**
+     * Decode a curve point from its compressed form.
+     *
+     * @param s the compressed point data
+     * @return the uncompressed point, null if not a valid point
+     */
+    private static BigInteger[] decodepoint(byte[] s) {
+        byte[] ybyte = new byte[s.length];
+        for (int i=0;i<s.length;i++) {
+            ybyte[i] = s[s.length-1-i];
+        }
+        BigInteger y = new BigInteger(ybyte).and(un);
+        BigInteger x = xrecover(y);
+        if ((x.testBit(0)?1:0) != bit(s, b-1)) {
+            x = q.subtract(x);
+        }
+        BigInteger[] P = {x,y};
+        if (!isoncurve(P))
+            return null;
+        return P;
+    }
+
+    /**
+     * Verify the validity of a signature on a message.
+     *
+     * @param sig signature
+     * @param m message
+     * @param pk public key of the signature creator
+     * @return whether the signature is valid
+     */
+    public static boolean verify(Signature sig, byte[] m, PublicKey pk) {
+        BigInteger[] R = decodepoint(sig.r);
+        BigInteger[] A = new BigInteger[]{decodeint(pk.x), decodeint(pk.y)};
+        BigInteger S = decodeint(sig.s);
+        ByteBuffer Stemp = ByteBuffer.allocate(32 + 32 + m.length);
+        Stemp.put(encodepoint(R)).put(encodepoint(A)).put(m);
+        BigInteger h = Hint(Stemp.array());
+        BigInteger[] ra = scalarmult(B,S);
+        BigInteger[] rb = edwards(R,scalarmult(A,h));
+        return ra[0].equals(rb[0]) && ra[1].equals(rb[1]);
+    }
+
+    /**
+     * Derive key material from a public and a private ECC key.
+     *
+     * @param privateKey private key to use for the ECDH (x)
+     * @param publicKey public key to use for the ECDH (yG)
+     * @return key material (xyG)
+     */
+    public static HashCode ecdh(PrivateKey privateKey, PublicKey publicKey) {
+        BigInteger[] publicPoint = new BigInteger[]{decodeint(publicKey.x), 
decodeint(publicKey.y)};
+        BigInteger coeff = computePublicKeyCoefficient(privateKey);
+        BigInteger[] R = scalarmult(publicPoint, coeff);
+        // FIXME: this is *not* equivalent to the GNUnet C implementation, 
which hashes an s-expr
+        sha512.update(R[0].toByteArray());
+        return new HashCode(sha512.digest(R[1].toByteArray()));
+    }
+}

Modified: gnunet-java/src/main/java/org/gnunet/util/Helper.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/Helper.java       2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/util/Helper.java       2013-09-04 
11:20:04 UTC (rev 28982)
@@ -6,7 +6,10 @@
 import org.gnunet.construct.ProtocolViolationException;
 import org.gnunet.mq.Envelope;
 import org.gnunet.mq.MessageQueue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+import java.io.File;
 import java.io.IOError;
 import java.io.IOException;
 import java.nio.Buffer;
@@ -18,17 +21,20 @@
 import java.util.List;
 
 /**
- * Process that we can communicate with standard GNUnet messages over 
stdin/stdout.
+ * Process that we can communicate to with standard GNUnet messages over 
stdin/stdout.
  */
 public class Helper extends MessageQueue {
+    private static final Logger logger = LoggerFactory
+            .getLogger(Helper.class);
 
     private final ProcessBuilder processBuilder;
     private final RunaboutMessageReceiver receiver;
     private Process process;
-
     private volatile GnunetMessage.Body writeMessage;
+    private WriteThread writeThread;
+    private ReadThread readThread;
 
-    private final class WriteThread implements Runnable {
+    private final class WriteThread extends Thread {
         @Override
         public void run() {
             GnunetMessage.Body msg;
@@ -62,7 +68,7 @@
         }
     }
 
-    private final class ReadThread implements Runnable {
+    private final class ReadThread extends Thread {
         private ByteBuffer buffer;
         ReadableByteChannel channel;
 
@@ -133,6 +139,15 @@
         }
     }
 
+    private String getBinaryPath(String binaryName) {
+        if (!binaryName.contains("gnunet"))
+            return binaryName;
+        String prefix = System.getenv("GNUNET_PREFIX");
+        if (prefix == null || prefix.isEmpty())
+            return binaryName;
+        // FIXME: this is not portable at all
+        return prefix + "/lib/" + "gnunet/" + "libexec/" +  binaryName;
+    }
 
     public Helper(boolean withControlPipe, String binaryName, List<String> 
argv,
                   RunaboutMessageReceiver receiver) {
@@ -141,7 +156,7 @@
         if (binaryName == null) {
             throw new AssertionError();
         }
-        command.add(binaryName);
+        command.add(getBinaryPath(binaryName));
         if (argv != null)
             command.addAll(argv);
         processBuilder = new ProcessBuilder(command);
@@ -150,6 +165,14 @@
         } catch (IOException e) {
             throw new IOError(e);
         }
+
+        writeThread = new WriteThread();
+        readThread = new ReadThread();
+
+        writeThread.start();
+        readThread.start();
+
+        reportReadyForSubmit();
     }
 
     /**
@@ -191,12 +214,14 @@
 
     @Override
     protected void submit(Envelope ev) {
+        logger.debug("submitting envelope to helper thread");
         synchronized (this) {
             if (writeMessage != null)
                 throw new AssertionError("message queue not implemented 
correctly");
             writeMessage = ev.message;
             notifyAll();
         }
+        reportReadyForSubmit();
     }
 
     @Override

Modified: gnunet-java/src/main/java/org/gnunet/util/Scheduler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/Scheduler.java    2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/java/org/gnunet/util/Scheduler.java    2013-09-04 
11:20:04 UTC (rev 28982)
@@ -44,6 +44,16 @@
     // cumulative number of tasks in the ready lists
     private static volatile int readyCount = 0;
 
+    /**
+     * Priority for Tasks.
+     */
+    public enum Priority {
+        IDLE, BACKGROUND, DEFAULT, HIGH, UI, URGENT, SHUTDOWN;
+
+        // how many different priorities do we have?
+        private static final int numberOfPriorities = Priority.values().length;
+    }
+
     // for every priority, there is a list of tasks that is definitely ready 
to run
     @SuppressWarnings("unchecked")
     final private static LinkedList<TaskConfiguration>[] readyLists = new 
LinkedList[Priority.numberOfPriorities];
@@ -108,16 +118,6 @@
 
 
     /**
-     * Priority for Tasks.
-     */
-    public enum Priority {
-        IDLE, BACKGROUND, DEFAULT, HIGH, UI, URGENT, SHUTDOWN;
-
-        // how many different priorities do we have?
-        private static final int numberOfPriorities = Priority.values().length;
-    }
-
-    /**
      * Reasons for executing a task.
      */
     public enum Reason {

Modified: gnunet-java/src/main/resources/org/gnunet/construct/MsgMap.txt
===================================================================
--- gnunet-java/src/main/resources/org/gnunet/construct/MsgMap.txt      
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/main/resources/org/gnunet/construct/MsgMap.txt      
2013-09-04 11:20:04 UTC (rev 28982)
@@ -1,46 +1,53 @@
 org.gnunet.util.Resolver$Address|0=org.gnunet.util.Resolver$TextualAddress
 org.gnunet.util.Resolver$Address|1=org.gnunet.util.Resolver$NumericAddress
-org.gnunet.util.GnunetMessage$Body|68=org.gnunet.core.DisconnectNotifyMessage
+org.gnunet.util.GnunetMessage$Body|1=org.gnunet.util.TestMessage
 org.gnunet.util.GnunetMessage$Body|274=org.gnunet.mesh.TunnelDestroyMessage
-org.gnunet.util.GnunetMessage$Body|1=org.gnunet.util.TestMessage
-org.gnunet.util.GnunetMessage$Body|70=org.gnunet.core.NotifyInboundTrafficMessage
 org.gnunet.util.GnunetMessage$Body|273=org.gnunet.mesh.TunnelCreateMessage
-org.gnunet.util.GnunetMessage$Body|71=org.gnunet.core.NotifyOutboundTrafficMessage
 org.gnunet.util.GnunetMessage$Body|272=org.gnunet.mesh.ClientConnectMessage
-org.gnunet.util.GnunetMessage$Body|64=org.gnunet.core.InitMessage
 org.gnunet.util.GnunetMessage$Body|4=org.gnunet.util.Resolver$GetMessage
-org.gnunet.util.GnunetMessage$Body|65=org.gnunet.core.InitReplyMessage
 org.gnunet.util.GnunetMessage$Body|5=org.gnunet.util.Resolver$ResolverResponse
 org.gnunet.util.GnunetMessage$Body|143=org.gnunet.dht.ClientGetMessage
-org.gnunet.util.GnunetMessage$Body|67=org.gnunet.core.ConnectNotifyMessage
 org.gnunet.util.GnunetMessage$Body|142=org.gnunet.dht.ClientPutMessage
-org.gnunet.util.GnunetMessage$Body|76=org.gnunet.core.SendMessage
 org.gnunet.util.GnunetMessage$Body|286=org.gnunet.mesh.LocalAckMessage
-org.gnunet.util.GnunetMessage$Body|74=org.gnunet.core.SendMessageRequest
-org.gnunet.util.GnunetMessage$Body|75=org.gnunet.core.SendMessageReady
+org.gnunet.util.GnunetMessage$Body|285=org.gnunet.mesh.DataMessage
 org.gnunet.util.GnunetMessage$Body|153=org.gnunet.dht.MonitorStartStop
 
org.gnunet.util.GnunetMessage$Body|155=org.gnunet.dht.ClientPutConfirmationMessage
-org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage
-org.gnunet.util.GnunetMessage$Body|260=org.gnunet.mesh.DataMessage
-org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage
 org.gnunet.util.GnunetMessage$Body|144=org.gnunet.dht.ClientGetStopMessage
 org.gnunet.util.GnunetMessage$Body|145=org.gnunet.dht.ClientResultMessage
-org.gnunet.util.GnunetMessage$Body|332=org.gnunet.peerinfo.InfoMessage
-org.gnunet.util.GnunetMessage$Body|333=org.gnunet.peerinfo.InfoEnd
 org.gnunet.util.GnunetMessage$Body|149=org.gnunet.dht.MonitorGetMessage
-org.gnunet.util.GnunetMessage$Body|331=org.gnunet.peerinfo.ListAllPeersMessage
 org.gnunet.util.GnunetMessage$Body|150=org.gnunet.dht.MonitorGetRespMessage
 org.gnunet.util.GnunetMessage$Body|151=org.gnunet.dht.MonitorPutMessage
 
org.gnunet.util.GnunetMessage$Body|171=org.gnunet.statistics.GetResponseEndMessage
 org.gnunet.util.GnunetMessage$Body|170=org.gnunet.statistics.GetResponseMessage
 org.gnunet.util.GnunetMessage$Body|169=org.gnunet.statistics.GetMessage
 org.gnunet.util.GnunetMessage$Body|168=org.gnunet.statistics.SetMessage
-org.gnunet.util.GnunetMessage$Body|374=org.gnunet.transport.RequestConnectMessage
 
org.gnunet.util.GnunetMessage$Body|173=org.gnunet.statistics.WatchResponseMessage
 org.gnunet.util.GnunetMessage$Body|172=org.gnunet.statistics.WatchMessage
 org.gnunet.util.GnunetMessage$Body|524=org.gnunet.consensus.ConcludeMessage
 
org.gnunet.util.GnunetMessage$Body|521=org.gnunet.consensus.InsertElementMessage
 org.gnunet.util.GnunetMessage$Body|523=org.gnunet.consensus.NewElementMessage
+org.gnunet.util.GnunetMessage$Body|68=org.gnunet.core.DisconnectNotifyMessage
+org.gnunet.util.GnunetMessage$Body|70=org.gnunet.core.NotifyInboundTrafficMessage
+org.gnunet.util.GnunetMessage$Body|71=org.gnunet.core.NotifyOutboundTrafficMessage
+org.gnunet.util.GnunetMessage$Body|64=org.gnunet.core.InitMessage
+org.gnunet.util.GnunetMessage$Body|65=org.gnunet.core.InitReplyMessage
+org.gnunet.util.GnunetMessage$Body|67=org.gnunet.core.ConnectNotifyMessage
+org.gnunet.util.GnunetMessage$Body|76=org.gnunet.core.SendMessage
+org.gnunet.util.GnunetMessage$Body|74=org.gnunet.core.SendMessageRequest
+org.gnunet.util.GnunetMessage$Body|75=org.gnunet.core.SendMessageReady
+org.gnunet.util.GnunetMessage$Body|460=org.gnunet.testbed.ControllerInitMessage
+org.gnunet.util.GnunetMessage$Body|323=org.gnunet.nse.UpdateMessage
+org.gnunet.util.GnunetMessage$Body|321=org.gnunet.nse.StartMessage
+org.gnunet.util.GnunetMessage$Body|332=org.gnunet.peerinfo.InfoMessage
+org.gnunet.util.GnunetMessage$Body|333=org.gnunet.peerinfo.InfoEnd
+org.gnunet.util.GnunetMessage$Body|331=org.gnunet.peerinfo.ListAllPeersMessage
+org.gnunet.util.GnunetMessage$Body|374=org.gnunet.transport.RequestConnectMessage
+org.gnunet.util.GnunetMessage$Body|369=org.gnunet.transport.BlacklistInitMessage
+org.gnunet.util.GnunetMessage$Body|371=org.gnunet.transport.BlacklistReplyMessage
+org.gnunet.util.GnunetMessage$Body|370=org.gnunet.transport.BlacklistQueryMessage
+org.gnunet.util.GnunetMessage$Body|380=org.gnunet.transport.AddressIterateMessage
+org.gnunet.util.GnunetMessage$Body|496=org.gnunet.testbed.HelperReplyMessage
+org.gnunet.util.GnunetMessage$Body|495=org.gnunet.testbed.HelperInitMessage
 org.gnunet.util.GnunetMessage$Body|360=org.gnunet.transport.StartMessage
 org.gnunet.construct.MessageUnion|525=org.gnunet.consensus.ConcludeDoneMessage
-# generated 2013/08/22 21:29:40
+# generated 2013/09/04 11:05:50

Added: gnunet-java/src/main/resources/org/gnunet/voting/template.espec
===================================================================
--- gnunet-java/src/main/resources/org/gnunet/voting/template.espec             
                (rev 0)
+++ gnunet-java/src/main/resources/org/gnunet/voting/template.espec     
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,36 @@
+[election]
+
+# human-readable topic description of the election
+TOPIC =
+
+# choices for the voter, separated by a double slash
+CHOICES = yes//no
+
+# starting time of the election, yy/mm/dd hh:mm:ss UTC+x
+# authorities affirm that they are available for the election from this point 
in time
+ELECTION_START =
+
+# deadline for vote submission, yy/mm/dd hh:mm:ss UTC+x
+# must be later than ELECTION_START
+ELECTION_END =
+
+# peer identity of the certificate authority for voting eligibility
+CA =
+
+# public key of the election issuer
+ISSUER_PUB =
+
+# the signature of the issuer will be filled in by gnunet-vote-call
+# ISSUER_SIGNATURE =
+
+
+[authorities]
+# specified as <authority-alias> = <peer-identity>, one entry for each 
authority; e.g.
+# awesome_authority_one = 123abc
+
+
+[authority-affirmation]
+# will be filled in by gnunet-vote-call once
+# authorities agreed to participate, with one entry per authority
+# <authority-alias> = <signature>
+# where the signature is on the

Modified: gnunet-java/src/test/java/org/gnunet/construct/ConstructTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/construct/ConstructTest.java   
2013-09-04 11:04:38 UTC (rev 28981)
+++ gnunet-java/src/test/java/org/gnunet/construct/ConstructTest.java   
2013-09-04 11:20:04 UTC (rev 28982)
@@ -6,6 +6,8 @@
 import java.util.Random;
 
 /**
+ * Miscellaneous tests for org.gnunet.construct.
+ *
  * @author Florian Dold
  */
 public class ConstructTest {
@@ -17,7 +19,25 @@
         public byte[] bytes;
     }
 
+    public static class BoolTestMessage implements Message {
+        @UInt32
+        public boolean x1;
+        @Int16
+        public boolean x2;
+    }
+
     @Test
+    public void test_bool_conversion() {
+        BoolTestMessage m = new BoolTestMessage();
+        m.x1 = true;
+        m.x2 = true;
+        byte[] bin = Construct.toBinary(m);
+        BoolTestMessage m2 = Construct.parseAs(bin, BoolTestMessage.class);
+        Assert.assertEquals(m.x1, m2.x1);
+        Assert.assertEquals(m.x2, m2.x2);
+    }
+
+    @Test
     public void test_ByteFill() {
         ByteFillTestMessage msg = new ByteFillTestMessage();
         msg.bytes = new byte[]{0,1,2,3};

Modified: gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java     2013-09-04 
11:04:38 UTC (rev 28981)
+++ gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java     2013-09-04 
11:20:04 UTC (rev 28982)
@@ -1,5 +1,7 @@
 package org.gnunet.mesh;
 
+import org.gnunet.core.Core;
+import org.gnunet.core.PeerIdentityContinuation;
 import org.gnunet.testing.TestingFixture;
 import org.gnunet.testing.TestingSubsystem;
 import org.gnunet.util.*;
@@ -16,32 +18,42 @@
         public Mesh m1;
         public Mesh m2;
         public void visit(TestMessage m) {
+            System.out.println("got test message");
             m1.destroy();
             m2.destroy();
         }
     }
-    //@Test
+    @Test (timeout = 5000)
     public void test_mesh_send() {
         Program.configureLogging("DEBUG");
-        final TestingSubsystem ts = new TestingSubsystem("mesh");
-        Configuration cfg = ts.getConfiguration();
-        MessageHandler1 mh = new MessageHandler1();
-        final Mesh mesh1 = new Mesh(cfg, null, null, null);
-        final Mesh mesh2 = new Mesh(cfg, new InboundTunnelHandler() {
-            @Override
-            public void onInboundTunnel(Mesh.Tunnel tunnel, PeerIdentity 
initiator) {
+        // we want the full arm here (starts both mesh and core)
+        final TestingSubsystem ts = new TestingSubsystem("arm");
+        final Configuration cfg = ts.getConfiguration();
 
-            }
-        }, new TunnelEndHandler() {
+        final MessageHandler1 mh = new MessageHandler1();
+        // FIXME: use CryptoECC instead of Core once available and compatible
+        Core.withPeerIdentity(cfg, new PeerIdentityContinuation() {
             @Override
-            public void onTunnelEnd(Mesh.Tunnel tunnel) {
-
+            public void cont(PeerIdentity peerIdentity) {
+                System.out.println("got peer identity from core");
+                final Mesh mesh1 = new Mesh(cfg, null, null, null);
+                final Mesh mesh2 = new Mesh(cfg, new InboundTunnelHandler() {
+                    @Override
+                    public void onInboundTunnel(Mesh.Tunnel tunnel, 
PeerIdentity initiator) {
+                        System.out.println("got inbound tunnel " + initiator);
+                    }
+                }, new TunnelEndHandler() {
+                    @Override
+                    public void onTunnelEnd(Mesh.Tunnel tunnel) {
+                        System.out.println("tunnel end handler called");
+                    }
+                }, mh, 42);
+                mh.m1 = mesh1;
+                mh.m2 = mesh2;
+                Mesh.Tunnel<Void> tunnel = mesh1.createTunnel(peerIdentity, 
42, false, true, null);
+                tunnel.send(new TestMessage());
             }
-        }, mh, 42);
-        mh.m1 = mesh1;
-        mh.m2 = mesh2;
-        Mesh.Tunnel<Void> tunnel = mesh2.createTunnel(null, 42, false, true, 
null);
-        tunnel.send(new TestMessage());
+        });
         Scheduler.run();
     }
 }

Added: gnunet-java/src/test/java/org/gnunet/testbed/TestbedTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/testbed/TestbedTest.java               
                (rev 0)
+++ gnunet-java/src/test/java/org/gnunet/testbed/TestbedTest.java       
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,41 @@
+package org.gnunet.testbed;
+
+
+import org.gnunet.testing.TestingFixture;
+import org.gnunet.util.Configuration;
+import org.gnunet.util.Program;
+import org.gnunet.util.Scheduler;
+import org.gnunet.util.Wrapper;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestbedTest extends TestingFixture {
+
+
+    @Test
+    public void test_controller_proc() {
+        final Wrapper<Boolean> success = new Wrapper<Boolean>(false);
+        new Program() {
+
+            @Override
+            public void run() {
+                // use local peer's config, does that really make sense?
+                Host h = new Host(null, null, getConfiguration(), 0);
+                final ControllerProc cp = new ControllerProc();
+                cp.start("127.0.0.1", h, new ControllerStatusCallback() {
+                    @Override
+                    public void onStartupSuccess(Configuration cfg) {
+                        success.set(true);
+                        cp.stop();
+                    }
+                    @Override
+                    public void onStartupFailure() {
+                        Assert.fail();
+                        //To change body of implemented methods use File | 
Settings | File Templates.
+                    }
+                });
+            }
+        }.start();
+        Assert.assertTrue(success.get());
+    }
+}

Added: gnunet-java/src/test/java/org/gnunet/util/CryptoECCTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/util/CryptoECCTest.java                
                (rev 0)
+++ gnunet-java/src/test/java/org/gnunet/util/CryptoECCTest.java        
2013-09-04 11:20:04 UTC (rev 28982)
@@ -0,0 +1,82 @@
+package org.gnunet.util;
+
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Random;
+
+public class CryptoECCTest {
+    /**
+     * Check that signed messages can be verified correctly.
+     */
+    @Test
+    public void test_sign_success() {
+        Random r = new Random();
+        // the test uses random data, repeat it multiple times!
+        for (int i = 0; i < 10; i++) {
+            byte[] msg = new byte[16];
+            r.nextBytes(msg);
+
+            CryptoECC.PrivateKey privateKey = new CryptoECC.PrivateKey();
+            privateKey.d = new byte[32];
+            r.nextBytes(privateKey.d);
+            CryptoECC.PublicKey publicKey = 
CryptoECC.computePublicKey(privateKey);
+
+            CryptoECC.Signature sig = CryptoECC.sign(msg, privateKey, 
publicKey);
+
+            boolean valid = CryptoECC.verify(sig, msg, publicKey);
+
+            Assert.assertTrue(valid);
+        }
+    }
+
+    /**
+     * Check that signature verification fails for manipulated data.
+     */
+    @Test
+    public void test_sign_failure() {
+        Random r = new Random();
+        // the test uses random data, repeat it multiple times!
+        for (int i = 0; i < 10; i++) {
+            byte[] msg = new byte[16];
+            r.nextBytes(msg);
+
+            CryptoECC.PrivateKey privateKey = new CryptoECC.PrivateKey();
+            privateKey.d = new byte[32];
+            r.nextBytes(privateKey.d);
+            CryptoECC.PublicKey publicKey = 
CryptoECC.computePublicKey(privateKey);
+
+            CryptoECC.Signature sig = CryptoECC.sign(msg, privateKey, 
publicKey);
+
+            msg[0] = (byte) (msg[0] + 1);
+
+            boolean valid = CryptoECC.verify(sig, msg, publicKey);
+
+            Assert.assertFalse(valid);
+        }
+    }
+
+    /**
+     * Check whether ecdh key coincide
+     */
+    @Test
+    public void test_ecdh() {
+        Random r = new Random();
+
+        CryptoECC.PrivateKey privateAlice = new CryptoECC.PrivateKey();
+        privateAlice.d = new byte[32];
+        r.nextBytes(privateAlice.d);
+        CryptoECC.PublicKey publicAlice = 
CryptoECC.computePublicKey(privateAlice);
+
+        CryptoECC.PrivateKey privateBob = new CryptoECC.PrivateKey();
+        privateBob.d = new byte[32];
+        r.nextBytes(privateBob.d);
+        CryptoECC.PublicKey publicBob = CryptoECC.computePublicKey(privateBob);
+
+        HashCode ssAlice = CryptoECC.ecdh(privateAlice, publicBob);
+        HashCode ssBob = CryptoECC.ecdh(privateBob, publicAlice);
+
+        Assert.assertArrayEquals(ssAlice.data, ssBob.data);
+    }
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]