signalapp / curve25519-java

Pure Java and JNI backed Curve25519 implementation.
GNU General Public License v3.0
233 stars 96 forks source link

Signature failures cause NoSuchMethodException on Android Lollipop #17

Open dkonigsberg opened 7 years ago

dkonigsberg commented 7 years ago

Inside curve25519-jni.c, the following code is used to throw an AssertionError when certain signature functions fail: (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/AssertionError"), "Signature failed!");

This works on older versions of Android (e.g. KitKat), however it causes a NoSuchMethodException on newer versions of Android (e.g. Lollipop). This is because AssertionError does not actually have a constructor that takes a String. (Just one that takes an Object, which it internally converts to a string.)

A simple fix would be to pick a different exception that has a String-only constructor. A more complicated fix would be to construct the AssertionError object manually, prior to throwing it.