diff --git a/build.gradle-template b/build.gradle-template index 8af1b54..14cb9dd 100644 --- a/build.gradle-template +++ b/build.gradle-template @@ -57,6 +57,15 @@ dependencies { /*==== You probably don't have to edit below this line =======*/ +// The run task added by the application plugin +// is also of type JavaExec. +tasks.withType(JavaExec) { + // Assign all Java system properties from + // the command line to the JavaExec task. + systemProperties System.properties +} + + protobuf { // Configure the protoc executable protoc { diff --git a/meerkat-common/build.gradle b/meerkat-common/build.gradle index b744fcd..236bd82 100644 --- a/meerkat-common/build.gradle +++ b/meerkat-common/build.gradle @@ -57,6 +57,16 @@ dependencies { /*==== You probably don't have to edit below this line =======*/ + +// The run task added by the application plugin +// is also of type JavaExec. +tasks.withType(JavaExec) { + // Assign all Java system properties from + // the command line to the JavaExec task. + systemProperties System.properties +} + + protobuf { // Configure the protoc executable protoc { @@ -91,33 +101,6 @@ idea { * "Fat" Build targets *===================================*/ -task fatjar(type: Jar) { - description = "Generate a single jar containing everything. Use -Pfatmain=... to override main class" - - destinationDir = buildDir - - def fatMain = hasProperty('fatmain') ? fatmain : mainClassName - def testJar = hasProperty('test') - - appendix = "${fatMain}-fat" - - if (testJar) { - from sourceSets.test.output - from configurations.testRuntime.collect { it.isDirectory() ? it : zipTree(it) } - } - - from sourceSets.main.output // that's it - from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } - - exclude 'META-INF/MANIFEST.MF' - exclude 'META-INF/*.SF' - exclude 'META-INF/*.DSA' - exclude 'META-INF/*.RSA' - - - manifest { attributes 'Main-Class': fatMain } -} - task mavenCapsule(type: MavenCapsule){ description = "Generate a capsule jar that automatically downloads and caches dependencies when run." diff --git a/meerkat-common/src/main/java/meerkat/crypto/Digest.java b/meerkat-common/src/main/java/meerkat/crypto/Digest.java index a715b26..06b012c 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/Digest.java +++ b/meerkat-common/src/main/java/meerkat/crypto/Digest.java @@ -8,13 +8,6 @@ import java.security.MessageDigest; * Created by talm on 11/9/15. */ public interface Digest { - - /** - * Marker between messages - */ - public static final byte[] CONCAT_MARKER = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef, - (byte) 0xba, (byte) 0x1d, (byte) 0xfa, (byte) 0xce}; - /** * Completes the hash computation by performing final operations such as padding. * (copied from {@link MessageDigest#digest()}) @@ -25,9 +18,7 @@ public interface Digest { /** * Updates the digest using the specified message (in serialized wire form) * - * Includes a special message concatenation marker (the 64 bit message {@link #CONCAT_MARKER}) in the digest (digesting a single message - * will give a different result than the same message split into two messages). - * Messages must not contain the {@link #CONCAT_MARKER}) marker. + * Each message is (automatically) prepended with its length as a 32-bit big-endian unsigned integer. * @param msg * @return */ diff --git a/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java b/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java index eda41a2..1abad8f 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java +++ b/meerkat-common/src/main/java/meerkat/crypto/DigitalSignature.java @@ -41,8 +41,8 @@ public interface DigitalSignature { /** - * Add msg to the content stream to be verified / signed. Each message is always (automatically) - * prepended with its length as a 32-bit unsigned integer in network byte order. + * Add msg to the content stream to be verified / signed. Each message is (automatically) + * prepended with its length as a 32-bit big-endian unsigned integer. * * @param msg * @throws SignatureException diff --git a/meerkat-common/src/main/java/meerkat/crypto/concrete/ECDSASignature.java b/meerkat-common/src/main/java/meerkat/crypto/concrete/ECDSASignature.java index 4fb8de5..1a5683f 100644 --- a/meerkat-common/src/main/java/meerkat/crypto/concrete/ECDSASignature.java +++ b/meerkat-common/src/main/java/meerkat/crypto/concrete/ECDSASignature.java @@ -2,13 +2,13 @@ package meerkat.crypto.concrete; import java.io.IOException; import java.io.InputStream; +import java.nio.ByteBuffer; import java.security.*; import java.security.cert.*; import java.security.cert.Certificate; import java.util.*; import com.google.protobuf.ByteString; -import meerkat.crypto.Digest; import meerkat.protobuf.Crypto; import meerkat.util.Hex; import org.slf4j.Logger; @@ -27,7 +27,7 @@ import javax.security.auth.callback.UnsupportedCallbackException; /** * Sign and verify digital signatures. - *
+ * * This class is not thread-safe (each thread should have its own instance). */ public class ECDSASignature extends GlobalCryptoSetup implements DigitalSignature { @@ -38,6 +38,12 @@ public class ECDSASignature extends GlobalCryptoSetup implements DigitalSignatur SHA256Digest digest = new SHA256Digest(); + /** + * Buffer used to hold length in for hash update + */ + ByteBuffer lenBuf = ByteBuffer.allocate(4); + + Map