michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko; michael@0: michael@0: import org.mozilla.gecko.mozglue.GeckoLoader; michael@0: michael@0: import android.content.Context; michael@0: import org.mozilla.gecko.mozglue.RobocopTarget; michael@0: michael@0: public class NSSBridge { michael@0: private static final String LOGTAG = "NSSBridge"; michael@0: michael@0: private static native String nativeEncrypt(String aDb, String aValue); michael@0: private static native String nativeDecrypt(String aDb, String aValue); michael@0: michael@0: @RobocopTarget michael@0: static public String encrypt(Context context, String aValue) michael@0: throws Exception { michael@0: String resourcePath = context.getPackageResourcePath(); michael@0: GeckoLoader.loadNSSLibs(context, resourcePath); michael@0: michael@0: String path = GeckoProfile.get(context).getDir().toString(); michael@0: return nativeEncrypt(path, aValue); michael@0: } michael@0: michael@0: @RobocopTarget michael@0: static public String encrypt(Context context, String profilePath, String aValue) michael@0: throws Exception { michael@0: String resourcePath = context.getPackageResourcePath(); michael@0: GeckoLoader.loadNSSLibs(context, resourcePath); michael@0: michael@0: return nativeEncrypt(profilePath, aValue); michael@0: } michael@0: michael@0: @RobocopTarget michael@0: static public String decrypt(Context context, String aValue) michael@0: throws Exception { michael@0: String resourcePath = context.getPackageResourcePath(); michael@0: GeckoLoader.loadNSSLibs(context, resourcePath); michael@0: michael@0: String path = GeckoProfile.get(context).getDir().toString(); michael@0: return nativeDecrypt(path, aValue); michael@0: } michael@0: michael@0: @RobocopTarget michael@0: static public String decrypt(Context context, String profilePath, String aValue) michael@0: throws Exception { michael@0: String resourcePath = context.getPackageResourcePath(); michael@0: GeckoLoader.loadNSSLibs(context, resourcePath); michael@0: michael@0: return nativeDecrypt(profilePath, aValue); michael@0: } michael@0: }