Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 package org.mozilla.gecko.background.nativecode;
7 import java.security.GeneralSecurityException;
9 import org.mozilla.gecko.AppConstants;
10 import org.mozilla.gecko.mozglue.RobocopTarget;
12 import android.util.Log;
14 @RobocopTarget
15 public class NativeCrypto {
16 static {
17 try {
18 System.loadLibrary("mozglue");
19 } catch (UnsatisfiedLinkError e) {
20 Log.wtf("NativeCrypto", "Couldn't load mozglue. Trying /data/app-lib path.");
21 try {
22 System.load("/data/app-lib/" + AppConstants.ANDROID_PACKAGE_NAME + "/libmozglue.so");
23 } catch (Throwable ee) {
24 try {
25 Log.wtf("NativeCrypto", "Couldn't load mozglue: " + ee + ". Trying /data/data path.");
26 System.load("/data/data/" + AppConstants.ANDROID_PACKAGE_NAME + "/lib/libmozglue.so");
27 } catch (UnsatisfiedLinkError eee) {
28 Log.wtf("NativeCrypto", "Failed every attempt to load mozglue. Giving up.");
29 throw new RuntimeException("Unable to load mozglue", eee);
30 }
31 }
32 }
33 }
35 /**
36 * Wrapper to perform PBKDF2-HMAC-SHA-256 in native code.
37 */
38 public native static byte[] pbkdf2SHA256(byte[] password, byte[] salt, int c, int dkLen)
39 throws GeneralSecurityException;
41 /**
42 * Wrapper to perform SHA-1 in native code.
43 */
44 public native static byte[] sha1(byte[] str);
45 }