aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorMoxie Marlinspike <moxie@thoughtcrime.org>2015-01-08 13:48:49 -0800
committerMoxie Marlinspike <moxie@thoughtcrime.org>2015-01-08 14:09:01 -0800
commit6445ea5f13850f42c3952bd06a2369317683ed88 (patch)
treef2bb37c8cf4710ff6a6a37a3e7e702c5a21ca504 /java
parenta4d8f7f6a4c4e9e89db35f299e558dceee2362a1 (diff)
Break project up into Java and Android build/test.
Diffstat (limited to '')
-rw-r--r--java/build.gradle83
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/DuplicateMessageException.java (renamed from src/main/java/org/whispersystems/libaxolotl/DuplicateMessageException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/IdentityKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/IdentityKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/IdentityKeyPair.java (renamed from src/main/java/org/whispersystems/libaxolotl/IdentityKeyPair.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/InvalidKeyException.java (renamed from src/main/java/org/whispersystems/libaxolotl/InvalidKeyException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/InvalidKeyIdException.java (renamed from src/main/java/org/whispersystems/libaxolotl/InvalidKeyIdException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/InvalidMacException.java (renamed from src/main/java/org/whispersystems/libaxolotl/InvalidMacException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/InvalidMessageException.java (renamed from src/main/java/org/whispersystems/libaxolotl/InvalidMessageException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/InvalidVersionException.java (renamed from src/main/java/org/whispersystems/libaxolotl/InvalidVersionException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/LegacyMessageException.java (renamed from src/main/java/org/whispersystems/libaxolotl/LegacyMessageException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/NoSessionException.java (renamed from src/main/java/org/whispersystems/libaxolotl/NoSessionException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/SessionBuilder.java (renamed from src/main/java/org/whispersystems/libaxolotl/SessionBuilder.java)2
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/SessionCipher.java (renamed from src/main/java/org/whispersystems/libaxolotl/SessionCipher.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/StaleKeyExchangeException.java (renamed from src/main/java/org/whispersystems/libaxolotl/StaleKeyExchangeException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/UntrustedIdentityException.java (renamed from src/main/java/org/whispersystems/libaxolotl/UntrustedIdentityException.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ecc/Curve.java (renamed from src/main/java/org/whispersystems/libaxolotl/ecc/Curve.java)43
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPrivateKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPrivateKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPublicKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPublicKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ecc/ECKeyPair.java (renamed from src/main/java/org/whispersystems/libaxolotl/ecc/ECKeyPair.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ecc/ECPrivateKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/ecc/ECPrivateKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ecc/ECPublicKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/ecc/ECPublicKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/GroupCipher.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/GroupCipher.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/GroupSessionBuilder.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/GroupSessionBuilder.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderMessageKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderMessageKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyRecord.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyRecord.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyState.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyState.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyStore.java (renamed from src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyStore.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedMessageSecrets.java (renamed from src/main/java/org/whispersystems/libaxolotl/kdf/DerivedMessageSecrets.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedRootSecrets.java (renamed from src/main/java/org/whispersystems/libaxolotl/kdf/DerivedRootSecrets.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDF.java (renamed from src/main/java/org/whispersystems/libaxolotl/kdf/HKDF.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv2.java (renamed from src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv2.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv3.java (renamed from src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv3.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLogger.java13
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLoggerProvider.java14
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/logging/Log.java86
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/CiphertextMessage.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/CiphertextMessage.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/KeyExchangeMessage.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/KeyExchangeMessage.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/PreKeyWhisperMessage.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/PreKeyWhisperMessage.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyMessage.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyMessage.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperMessage.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/WhisperMessage.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperProtos.java (renamed from src/main/java/org/whispersystems/libaxolotl/protocol/WhisperProtos.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/AliceAxolotlParameters.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/AliceAxolotlParameters.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/BobAxolotlParameters.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/BobAxolotlParameters.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/ChainKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/ChainKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/MessageKeys.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/MessageKeys.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/RatchetingSession.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/RatchetingSession.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/RootKey.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/RootKey.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/ratchet/SymmetricAxolotlParameters.java (renamed from src/main/java/org/whispersystems/libaxolotl/ratchet/SymmetricAxolotlParameters.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/AxolotlStore.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/AxolotlStore.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/IdentityKeyStore.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/IdentityKeyStore.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyBundle.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/PreKeyBundle.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyStore.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/PreKeyStore.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/SessionRecord.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/SessionRecord.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/SessionState.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/SessionState.java)2
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/SessionStore.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/SessionStore.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyRecord.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyRecord.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyStore.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyStore.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/state/StorageProtos.java (renamed from src/main/java/org/whispersystems/libaxolotl/state/StorageProtos.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/ByteUtil.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/ByteUtil.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/Hex.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/Hex.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/Medium.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/Medium.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/Pair.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/Pair.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/guava/Absent.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/guava/Absent.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/guava/Function.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/guava/Function.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/guava/Optional.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/guava/Optional.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/guava/Preconditions.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/guava/Preconditions.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/guava/Present.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/guava/Present.java)0
-rw-r--r--java/src/main/java/org/whispersystems/libaxolotl/util/guava/Supplier.java (renamed from src/main/java/org/whispersystems/libaxolotl/util/guava/Supplier.java)0
-rw-r--r--java/src/test/java/org/whispersystems/libaxolotl/CurveTest.java26
73 files changed, 258 insertions, 11 deletions
diff --git a/java/build.gradle b/java/build.gradle
new file mode 100644
index 00000000..11834e6b
--- /dev/null
+++ b/java/build.gradle
@@ -0,0 +1,83 @@
+apply plugin: 'java'
+apply plugin: 'maven'
+apply plugin: 'signing'
+
+sourceCompatibility = 1.7
+archivesBaseName = "axolotl-java"
+version = version_number
+group = group_info
+
+repositories {
+ mavenCentral()
+ mavenLocal()
+}
+
+sourceSets {
+ test {
+ java {
+ srcDirs = ['src/test/java/', project(':tests').file('src/main/java')]
+ }
+ }
+}
+
+dependencies {
+ compile "org.whispersystems:curve25519-java:${curve25519_version}"
+ compile 'com.google.protobuf:protobuf-java:2.5.0'
+
+ testCompile ('junit:junit:3.8.2')
+}
+
+
+test {
+ testLogging {
+ events 'passed'
+ showStandardStreams = true
+ }
+
+ include 'org/whispersystems/**'
+}
+
+signing {
+ required { has("release") && gradle.taskGraph.hasTask("uploadArchives") }
+ sign configurations.archives
+}
+
+uploadArchives {
+ configuration = configurations.archives
+ repositories.mavenDeployer {
+ beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
+
+ repository(url: sonatypeRepo) {
+ authentication(userName: whisperSonatypeUsername, password: whisperSonatypePassword)
+ }
+
+ pom.project {
+ name 'axolotl-java'
+ packaging 'jar'
+ description 'Axolotl library for Java'
+ url 'https://github.com/WhisperSystems/libaxolotl-android'
+
+ scm {
+ url 'scm:git@github.com:WhisperSystems/libaxolotl-android.git'
+ connection 'scm:git@github.com:WhisperSystems/libaxolotl-android.git'
+ developerConnection 'scm:git@github.com:WhisperSystems/libaxolotl-android.git'
+ }
+
+ developers {
+ developer {
+ name 'Moxie Marlinspike'
+ }
+ }
+ }
+ }
+}
+
+task installArchives(type: Upload) {
+ description "Installs the artifacts to the local Maven repository."
+ configuration = configurations['archives']
+ repositories {
+ mavenDeployer {
+ repository url: "file://${System.properties['user.home']}/.m2/repository"
+ }
+ }
+}
diff --git a/src/main/java/org/whispersystems/libaxolotl/DuplicateMessageException.java b/java/src/main/java/org/whispersystems/libaxolotl/DuplicateMessageException.java
index 913c0121..913c0121 100644
--- a/src/main/java/org/whispersystems/libaxolotl/DuplicateMessageException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/DuplicateMessageException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/IdentityKey.java b/java/src/main/java/org/whispersystems/libaxolotl/IdentityKey.java
index 35af3394..35af3394 100644
--- a/src/main/java/org/whispersystems/libaxolotl/IdentityKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/IdentityKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/IdentityKeyPair.java b/java/src/main/java/org/whispersystems/libaxolotl/IdentityKeyPair.java
index c47df4bc..c47df4bc 100644
--- a/src/main/java/org/whispersystems/libaxolotl/IdentityKeyPair.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/IdentityKeyPair.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/InvalidKeyException.java b/java/src/main/java/org/whispersystems/libaxolotl/InvalidKeyException.java
index bb70df16..bb70df16 100644
--- a/src/main/java/org/whispersystems/libaxolotl/InvalidKeyException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/InvalidKeyException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/InvalidKeyIdException.java b/java/src/main/java/org/whispersystems/libaxolotl/InvalidKeyIdException.java
index c7c6bc01..c7c6bc01 100644
--- a/src/main/java/org/whispersystems/libaxolotl/InvalidKeyIdException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/InvalidKeyIdException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/InvalidMacException.java b/java/src/main/java/org/whispersystems/libaxolotl/InvalidMacException.java
index 0afc6996..0afc6996 100644
--- a/src/main/java/org/whispersystems/libaxolotl/InvalidMacException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/InvalidMacException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/InvalidMessageException.java b/java/src/main/java/org/whispersystems/libaxolotl/InvalidMessageException.java
index 063eb594..063eb594 100644
--- a/src/main/java/org/whispersystems/libaxolotl/InvalidMessageException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/InvalidMessageException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/InvalidVersionException.java b/java/src/main/java/org/whispersystems/libaxolotl/InvalidVersionException.java
index a1324443..a1324443 100644
--- a/src/main/java/org/whispersystems/libaxolotl/InvalidVersionException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/InvalidVersionException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/LegacyMessageException.java b/java/src/main/java/org/whispersystems/libaxolotl/LegacyMessageException.java
index dadde754..dadde754 100644
--- a/src/main/java/org/whispersystems/libaxolotl/LegacyMessageException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/LegacyMessageException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/NoSessionException.java b/java/src/main/java/org/whispersystems/libaxolotl/NoSessionException.java
index 16203554..16203554 100644
--- a/src/main/java/org/whispersystems/libaxolotl/NoSessionException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/NoSessionException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/SessionBuilder.java b/java/src/main/java/org/whispersystems/libaxolotl/SessionBuilder.java
index 2d1c8969..736d9ab1 100644
--- a/src/main/java/org/whispersystems/libaxolotl/SessionBuilder.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/SessionBuilder.java
@@ -1,10 +1,10 @@
package org.whispersystems.libaxolotl;
-import android.util.Log;
import org.whispersystems.libaxolotl.ecc.Curve;
import org.whispersystems.libaxolotl.ecc.ECKeyPair;
import org.whispersystems.libaxolotl.ecc.ECPublicKey;
+import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.libaxolotl.protocol.CiphertextMessage;
import org.whispersystems.libaxolotl.protocol.KeyExchangeMessage;
import org.whispersystems.libaxolotl.protocol.PreKeyWhisperMessage;
diff --git a/src/main/java/org/whispersystems/libaxolotl/SessionCipher.java b/java/src/main/java/org/whispersystems/libaxolotl/SessionCipher.java
index 381dedb8..381dedb8 100644
--- a/src/main/java/org/whispersystems/libaxolotl/SessionCipher.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/SessionCipher.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/StaleKeyExchangeException.java b/java/src/main/java/org/whispersystems/libaxolotl/StaleKeyExchangeException.java
index f94a3008..f94a3008 100644
--- a/src/main/java/org/whispersystems/libaxolotl/StaleKeyExchangeException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/StaleKeyExchangeException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/UntrustedIdentityException.java b/java/src/main/java/org/whispersystems/libaxolotl/UntrustedIdentityException.java
index f434b923..f434b923 100644
--- a/src/main/java/org/whispersystems/libaxolotl/UntrustedIdentityException.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/UntrustedIdentityException.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ecc/Curve.java b/java/src/main/java/org/whispersystems/libaxolotl/ecc/Curve.java
index 66b8cc3a..5d47e3aa 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ecc/Curve.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ecc/Curve.java
@@ -16,25 +16,41 @@
*/
package org.whispersystems.libaxolotl.ecc;
+import org.whispersystems.curve25519.Curve25519KeyPair;
import org.whispersystems.libaxolotl.InvalidKeyException;
+import org.whispersystems.curve25519.Curve25519;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
public class Curve {
public static final int DJB_TYPE = 0x05;
+ public static boolean isNative() {
+ return Curve25519.isNative();
+ }
+
public static ECKeyPair generateKeyPair() {
- return Curve25519.generateKeyPair();
+ SecureRandom secureRandom = getSecureRandom();
+ Curve25519KeyPair keyPair = Curve25519.generateKeyPair(secureRandom);
+
+ return new ECKeyPair(new DjbECPublicKey(keyPair.getPublicKey()),
+ new DjbECPrivateKey(keyPair.getPrivateKey()));
}
public static ECPublicKey decodePoint(byte[] bytes, int offset)
throws InvalidKeyException
{
- int type = bytes[offset];
+ int type = bytes[offset] & 0xFF;
- if (type == DJB_TYPE) {
- return Curve25519.decodePoint(bytes, offset);
- } else {
- throw new InvalidKeyException("Unknown key type: " + type);
+ switch (type) {
+ case Curve.DJB_TYPE:
+ byte[] keyBytes = new byte[32];
+ System.arraycopy(bytes, offset+1, keyBytes, 0, keyBytes.length);
+ return new DjbECPublicKey(keyBytes);
+ default:
+ throw new InvalidKeyException("Bad key type: " + type);
}
}
@@ -50,7 +66,8 @@ public class Curve {
}
if (publicKey.getType() == DJB_TYPE) {
- return Curve25519.calculateAgreement(publicKey, privateKey);
+ return Curve25519.calculateAgreement(((DjbECPublicKey)publicKey).getPublicKey(),
+ ((DjbECPrivateKey)privateKey).getPrivateKey());
} else {
throw new InvalidKeyException("Unknown type: " + publicKey.getType());
}
@@ -60,7 +77,7 @@ public class Curve {
throws InvalidKeyException
{
if (signingKey.getType() == DJB_TYPE) {
- return Curve25519.verifySignature(signingKey, message, signature);
+ return Curve25519.verifySignature(((DjbECPublicKey)signingKey).getPublicKey(), message, signature);
} else {
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
}
@@ -70,9 +87,17 @@ public class Curve {
throws InvalidKeyException
{
if (signingKey.getType() == DJB_TYPE) {
- return Curve25519.calculateSignature(signingKey, message);
+ return Curve25519.calculateSignature(getSecureRandom(), ((DjbECPrivateKey)signingKey).getPrivateKey(), message);
} else {
throw new InvalidKeyException("Unknown type: " + signingKey.getType());
}
}
+
+ private static SecureRandom getSecureRandom() {
+ try {
+ return SecureRandom.getInstance("SHA1PRNG");
+ } catch (NoSuchAlgorithmException e) {
+ throw new AssertionError(e);
+ }
+ }
}
diff --git a/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPrivateKey.java b/java/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPrivateKey.java
index ecb55b4e..ecb55b4e 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPrivateKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPrivateKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPublicKey.java b/java/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPublicKey.java
index 9f66d439..9f66d439 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPublicKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ecc/DjbECPublicKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ecc/ECKeyPair.java b/java/src/main/java/org/whispersystems/libaxolotl/ecc/ECKeyPair.java
index bcaec927..bcaec927 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ecc/ECKeyPair.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ecc/ECKeyPair.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ecc/ECPrivateKey.java b/java/src/main/java/org/whispersystems/libaxolotl/ecc/ECPrivateKey.java
index 922057de..922057de 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ecc/ECPrivateKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ecc/ECPrivateKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ecc/ECPublicKey.java b/java/src/main/java/org/whispersystems/libaxolotl/ecc/ECPublicKey.java
index 12576807..12576807 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ecc/ECPublicKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ecc/ECPublicKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/GroupCipher.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/GroupCipher.java
index 43dac752..43dac752 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/GroupCipher.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/GroupCipher.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/GroupSessionBuilder.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/GroupSessionBuilder.java
index 8b73484b..8b73484b 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/GroupSessionBuilder.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/GroupSessionBuilder.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java
index 71375923..71375923 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderChainKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderMessageKey.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderMessageKey.java
index 8808a8e8..8808a8e8 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderMessageKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/ratchet/SenderMessageKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyRecord.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyRecord.java
index bb1ba952..bb1ba952 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyRecord.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyRecord.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyState.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyState.java
index 80498ce0..80498ce0 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyState.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyState.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyStore.java b/java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyStore.java
index da01b1f3..da01b1f3 100644
--- a/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyStore.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/groups/state/SenderKeyStore.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedMessageSecrets.java b/java/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedMessageSecrets.java
index b3f54fb8..b3f54fb8 100644
--- a/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedMessageSecrets.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedMessageSecrets.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedRootSecrets.java b/java/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedRootSecrets.java
index 82cc541d..82cc541d 100644
--- a/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedRootSecrets.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/kdf/DerivedRootSecrets.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/kdf/HKDF.java b/java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDF.java
index d190822d..d190822d 100644
--- a/src/main/java/org/whispersystems/libaxolotl/kdf/HKDF.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDF.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv2.java b/java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv2.java
index 86e4bf5f..86e4bf5f 100644
--- a/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv2.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv2.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv3.java b/java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv3.java
index a1934c90..a1934c90 100644
--- a/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv3.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/kdf/HKDFv3.java
diff --git a/java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLogger.java b/java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLogger.java
new file mode 100644
index 00000000..e8baf5e4
--- /dev/null
+++ b/java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLogger.java
@@ -0,0 +1,13 @@
+package org.whispersystems.libaxolotl.logging;
+
+public interface AxolotlLogger {
+
+ public static final int VERBOSE = 2;
+ public static final int DEBUG = 3;
+ public static final int INFO = 4;
+ public static final int WARN = 5;
+ public static final int ERROR = 6;
+ public static final int ASSERT = 7;
+
+ public void log(int priority, String tag, String message);
+}
diff --git a/java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLoggerProvider.java b/java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLoggerProvider.java
new file mode 100644
index 00000000..e385aa09
--- /dev/null
+++ b/java/src/main/java/org/whispersystems/libaxolotl/logging/AxolotlLoggerProvider.java
@@ -0,0 +1,14 @@
+package org.whispersystems.libaxolotl.logging;
+
+public class AxolotlLoggerProvider {
+
+ private static AxolotlLogger provider;
+
+ public static AxolotlLogger getProvider() {
+ return provider;
+ }
+
+ public static void setProvider(AxolotlLogger provider) {
+ AxolotlLoggerProvider.provider = provider;
+ }
+}
diff --git a/java/src/main/java/org/whispersystems/libaxolotl/logging/Log.java b/java/src/main/java/org/whispersystems/libaxolotl/logging/Log.java
new file mode 100644
index 00000000..22db9baf
--- /dev/null
+++ b/java/src/main/java/org/whispersystems/libaxolotl/logging/Log.java
@@ -0,0 +1,86 @@
+package org.whispersystems.libaxolotl.logging;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.UnknownHostException;
+
+public class Log {
+
+ private Log() {}
+
+ public static void v(String tag, String msg) {
+ log(AxolotlLogger.VERBOSE, tag, msg);
+ }
+
+ public static void v(String tag, String msg, Throwable tr) {
+ log(AxolotlLogger.VERBOSE, tag, msg + '\n' + getStackTraceString(tr));
+ }
+
+ public static void d(String tag, String msg) {
+ log(AxolotlLogger.DEBUG, tag, msg);
+ }
+
+ public static void d(String tag, String msg, Throwable tr) {
+ log(AxolotlLogger.DEBUG, tag, msg + '\n' + getStackTraceString(tr));
+ }
+
+ public static void i(String tag, String msg) {
+ log(AxolotlLogger.INFO, tag, msg);
+ }
+
+ public static void i(String tag, String msg, Throwable tr) {
+ log(AxolotlLogger.INFO, tag, msg + '\n' + getStackTraceString(tr));
+ }
+
+ public static void w(String tag, String msg) {
+ log(AxolotlLogger.WARN, tag, msg);
+ }
+
+ public static void w(String tag, String msg, Throwable tr) {
+ log(AxolotlLogger.WARN, tag, msg + '\n' + getStackTraceString(tr));
+ }
+
+ public static void w(String tag, Throwable tr) {
+ log(AxolotlLogger.WARN, tag, getStackTraceString(tr));
+ }
+
+ public static void e(String tag, String msg) {
+ log(AxolotlLogger.ERROR, tag, msg);
+ }
+
+ public static void e(String tag, String msg, Throwable tr) {
+ log(AxolotlLogger.ERROR, tag, msg + '\n' + getStackTraceString(tr));
+ }
+
+ private static String getStackTraceString(Throwable tr) {
+ if (tr == null) {
+ return "";
+ }
+
+ // This is to reduce the amount of log spew that apps do in the non-error
+ // condition of the network being unavailable.
+ Throwable t = tr;
+ while (t != null) {
+ if (t instanceof UnknownHostException) {
+ return "";
+ }
+ t = t.getCause();
+ }
+
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ tr.printStackTrace(pw);
+ pw.flush();
+ return sw.toString();
+ }
+
+ private static void log(int priority, String tag, String msg) {
+ AxolotlLogger logger = AxolotlLoggerProvider.getProvider();
+
+ if (logger != null) {
+ logger.log(priority, tag, msg);
+ }
+ }
+
+
+}
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/CiphertextMessage.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/CiphertextMessage.java
index cf4be756..cf4be756 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/CiphertextMessage.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/CiphertextMessage.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/KeyExchangeMessage.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/KeyExchangeMessage.java
index bec9208c..bec9208c 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/KeyExchangeMessage.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/KeyExchangeMessage.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/PreKeyWhisperMessage.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/PreKeyWhisperMessage.java
index fff6d02a..fff6d02a 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/PreKeyWhisperMessage.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/PreKeyWhisperMessage.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java
index 424dd87c..424dd87c 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyDistributionMessage.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyMessage.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyMessage.java
index b3a17456..b3a17456 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyMessage.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/SenderKeyMessage.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperMessage.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperMessage.java
index 980bec1f..980bec1f 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperMessage.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperMessage.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperProtos.java b/java/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperProtos.java
index 12ab0272..12ab0272 100644
--- a/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperProtos.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/protocol/WhisperProtos.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/AliceAxolotlParameters.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/AliceAxolotlParameters.java
index 13c995e9..13c995e9 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/AliceAxolotlParameters.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/AliceAxolotlParameters.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/BobAxolotlParameters.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/BobAxolotlParameters.java
index 27116a8b..27116a8b 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/BobAxolotlParameters.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/BobAxolotlParameters.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/ChainKey.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/ChainKey.java
index 9dd1dbee..9dd1dbee 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/ChainKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/ChainKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/MessageKeys.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/MessageKeys.java
index 95a8c7dc..95a8c7dc 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/MessageKeys.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/MessageKeys.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/RatchetingSession.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/RatchetingSession.java
index ec9af6d9..ec9af6d9 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/RatchetingSession.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/RatchetingSession.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/RootKey.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/RootKey.java
index 39f3a831..39f3a831 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/RootKey.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/RootKey.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/ratchet/SymmetricAxolotlParameters.java b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/SymmetricAxolotlParameters.java
index 7a63c45f..7a63c45f 100644
--- a/src/main/java/org/whispersystems/libaxolotl/ratchet/SymmetricAxolotlParameters.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/ratchet/SymmetricAxolotlParameters.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/AxolotlStore.java b/java/src/main/java/org/whispersystems/libaxolotl/state/AxolotlStore.java
index 2fda9a21..2fda9a21 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/AxolotlStore.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/AxolotlStore.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/IdentityKeyStore.java b/java/src/main/java/org/whispersystems/libaxolotl/state/IdentityKeyStore.java
index d2024f78..d2024f78 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/IdentityKeyStore.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/IdentityKeyStore.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyBundle.java b/java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyBundle.java
index 772bcc14..772bcc14 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyBundle.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyBundle.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java b/java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java
index 0ea905f4..0ea905f4 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyRecord.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyStore.java b/java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyStore.java
index 7dc5e626..7dc5e626 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/PreKeyStore.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/PreKeyStore.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/SessionRecord.java b/java/src/main/java/org/whispersystems/libaxolotl/state/SessionRecord.java
index 76c64922..76c64922 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/SessionRecord.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/SessionRecord.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/SessionState.java b/java/src/main/java/org/whispersystems/libaxolotl/state/SessionState.java
index 9b2b1e2a..e724e7df 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/SessionState.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/SessionState.java
@@ -17,7 +17,6 @@
package org.whispersystems.libaxolotl.state;
-import android.util.Log;
import com.google.protobuf.ByteString;
@@ -29,6 +28,7 @@ import org.whispersystems.libaxolotl.ecc.ECKeyPair;
import org.whispersystems.libaxolotl.ecc.ECPrivateKey;
import org.whispersystems.libaxolotl.ecc.ECPublicKey;
import org.whispersystems.libaxolotl.kdf.HKDF;
+import org.whispersystems.libaxolotl.logging.Log;
import org.whispersystems.libaxolotl.ratchet.ChainKey;
import org.whispersystems.libaxolotl.ratchet.MessageKeys;
import org.whispersystems.libaxolotl.ratchet.RootKey;
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/SessionStore.java b/java/src/main/java/org/whispersystems/libaxolotl/state/SessionStore.java
index c5ad00b0..c5ad00b0 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/SessionStore.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/SessionStore.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyRecord.java b/java/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyRecord.java
index f11f5cf1..f11f5cf1 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyRecord.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyRecord.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyStore.java b/java/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyStore.java
index c828bf23..c828bf23 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyStore.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/SignedPreKeyStore.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/state/StorageProtos.java b/java/src/main/java/org/whispersystems/libaxolotl/state/StorageProtos.java
index b3e3e0e6..b3e3e0e6 100644
--- a/src/main/java/org/whispersystems/libaxolotl/state/StorageProtos.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/state/StorageProtos.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/ByteUtil.java b/java/src/main/java/org/whispersystems/libaxolotl/util/ByteUtil.java
index c213ba0b..c213ba0b 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/ByteUtil.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/ByteUtil.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/Hex.java b/java/src/main/java/org/whispersystems/libaxolotl/util/Hex.java
index 19285464..19285464 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/Hex.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/Hex.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java b/java/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java
index 96ee6563..96ee6563 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/KeyHelper.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/Medium.java b/java/src/main/java/org/whispersystems/libaxolotl/util/Medium.java
index d18b2d66..d18b2d66 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/Medium.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/Medium.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/Pair.java b/java/src/main/java/org/whispersystems/libaxolotl/util/Pair.java
index 0476d932..0476d932 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/Pair.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/Pair.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/guava/Absent.java b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Absent.java
index bd06ded9..bd06ded9 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/guava/Absent.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Absent.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/guava/Function.java b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Function.java
index 1ad516c5..1ad516c5 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/guava/Function.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Function.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/guava/Optional.java b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Optional.java
index 4f2de832..4f2de832 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/guava/Optional.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Optional.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/guava/Preconditions.java b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Preconditions.java
index ce253c65..ce253c65 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/guava/Preconditions.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Preconditions.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/guava/Present.java b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Present.java
index 630570ff..630570ff 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/guava/Present.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Present.java
diff --git a/src/main/java/org/whispersystems/libaxolotl/util/guava/Supplier.java b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Supplier.java
index ba880707..ba880707 100644
--- a/src/main/java/org/whispersystems/libaxolotl/util/guava/Supplier.java
+++ b/java/src/main/java/org/whispersystems/libaxolotl/util/guava/Supplier.java
diff --git a/java/src/test/java/org/whispersystems/libaxolotl/CurveTest.java b/java/src/test/java/org/whispersystems/libaxolotl/CurveTest.java
new file mode 100644
index 00000000..734f6c86
--- /dev/null
+++ b/java/src/test/java/org/whispersystems/libaxolotl/CurveTest.java
@@ -0,0 +1,26 @@
+package org.whispersystems.libaxolotl;
+
+import junit.framework.TestCase;
+
+import org.whispersystems.libaxolotl.ecc.Curve;
+import org.whispersystems.libaxolotl.ecc.ECKeyPair;
+
+public class CurveTest extends TestCase {
+
+ public void testPureJava() {
+ assertFalse(Curve.isNative());
+ }
+
+ public void testSignatureOverflow() throws InvalidKeyException {
+ ECKeyPair keys = Curve.generateKeyPair();
+ byte[] message = new byte[4096];
+
+ try {
+ byte[] signature = Curve.calculateSignature(keys.getPrivateKey(), message);
+ throw new InvalidKeyException("Should have asserted!");
+ } catch (IllegalArgumentException e) {
+ // Success!
+ }
+ }
+
+}