diff options
author | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-01-08 13:48:49 -0800 |
---|---|---|
committer | Moxie Marlinspike <moxie@thoughtcrime.org> | 2015-01-08 14:09:01 -0800 |
commit | 6445ea5f13850f42c3952bd06a2369317683ed88 (patch) | |
tree | f2bb37c8cf4710ff6a6a37a3e7e702c5a21ca504 /android/src | |
parent | a4d8f7f6a4c4e9e89db35f299e558dceee2362a1 (diff) |
Break project up into Java and Android build/test.
Diffstat (limited to 'android/src')
3 files changed, 53 insertions, 0 deletions
diff --git a/android/src/androidTest/java/org/whispersystems/libaxolotl/CurveTest.java b/android/src/androidTest/java/org/whispersystems/libaxolotl/CurveTest.java new file mode 100644 index 00000000..bb539d49 --- /dev/null +++ b/android/src/androidTest/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() { + assertTrue(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 (AssertionError e) { + // Success! + } + } + +} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 00000000..85f0fe6b --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.whispersystems.libaxolotl"> +</manifest> diff --git a/android/src/main/java/org/whispersystems/libaxolotl/util/AndroidAxolotlLogger.java b/android/src/main/java/org/whispersystems/libaxolotl/util/AndroidAxolotlLogger.java new file mode 100644 index 00000000..302c08a4 --- /dev/null +++ b/android/src/main/java/org/whispersystems/libaxolotl/util/AndroidAxolotlLogger.java @@ -0,0 +1,24 @@ +package org.whispersystems.libaxolotl.util; + +import android.util.Log; +import android.util.SparseIntArray; + +import org.whispersystems.libaxolotl.logging.AxolotlLogger; + +public class AndroidAxolotlLogger implements AxolotlLogger { + + private static final SparseIntArray PRIORITY_MAP = new SparseIntArray(5) {{ + put(AxolotlLogger.INFO, Log.INFO); + put(AxolotlLogger.ASSERT, Log.ASSERT); + put(AxolotlLogger.DEBUG, Log.DEBUG); + put(AxolotlLogger.VERBOSE, Log.VERBOSE); + put(AxolotlLogger.WARN, Log.WARN); + + }}; + + @Override + public void log(int priority, String tag, String message) { + int androidPriority = PRIORITY_MAP.get(priority, Log.WARN); + Log.println(androidPriority, tag, message); + } +} |