Fix for some devices that behave strangely with native code.

Sometimes, for whatever reason, native code fails to get installed
on some small percentage of Android devices.  In contrast to every
other device, on LG devices, the call to System.loadLibrary
 *succeeds*, and then the individual native calls throw exceptions.

This change allows the degredation path to work correctly on LG.
This commit is contained in:
Moxie Marlinspike 2015-02-09 12:32:52 -08:00
parent 003a4c0f95
commit fc5af285f5
6 changed files with 14 additions and 0 deletions

View File

@ -107,3 +107,9 @@ JNIEXPORT jboolean JNICALL Java_org_whispersystems_curve25519_NativeCurve25519Pr
return result;
}
JNIEXPORT jboolean JNICALL Java_org_whispersystems_curve25519_NativeCurve25519Provider_smokeCheck
(JNIEnv *env, jobject obj, jint dummy)
{
return 1;
}

Binary file not shown.

Binary file not shown.

View File

@ -35,6 +35,12 @@ class NativeCurve25519Provider implements Curve25519Provider {
NativeCurve25519Provider() throws NoSuchProviderException {
if (!libraryPresent) throw new NoSuchProviderException(libraryFailedException);
try {
smokeCheck(31337);
} catch (UnsatisfiedLinkError ule) {
throw new NoSuchProviderException(ule);
}
}
@Override
@ -76,4 +82,6 @@ class NativeCurve25519Provider implements Curve25519Provider {
@Override
public native boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature);
private native boolean smokeCheck(int dummy);
}