aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-15 22:19:15 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-15 22:19:15 +0200
commitc90e776055f2bbf860b7d961dde3ca3271407131 (patch)
treeafe2fef07a517d38879d6733fa314a727cabcbe4 /OpenPGP-Keychain/src/org/sufficientlysecure
parent4b8c5c8134dc6ebec6758b595861dab446341a92 (diff)
downloadopen-keychain-c90e776055f2bbf860b7d961dde3ca3271407131.tar.gz
open-keychain-c90e776055f2bbf860b7d961dde3ca3271407131.tar.bz2
open-keychain-c90e776055f2bbf860b7d961dde3ca3271407131.zip
Reorder security providers in application class, document functionality
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java35
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/util/PRNGFixes.java4
2 files changed, 29 insertions, 10 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java
index 654eca5b8..4a25f2df1 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/KeychainApplication.java
@@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain;
import java.io.File;
+import java.security.Provider;
import java.security.Security;
import org.spongycastle.jce.provider.BouncyCastleProvider;
@@ -29,18 +30,37 @@ import android.os.Environment;
public class KeychainApplication extends Application {
- static {
- // Define Java Security Provider to be Bouncy Castle
- Security.insertProviderAt(new BouncyCastleProvider(), 1);
- }
-
+ /**
+ * Called when the application is starting, before any activity, service, or receiver objects
+ * (excluding content providers) have been created.
+ */
@Override
public void onCreate() {
super.onCreate();
- // apply RNG fixes
+ /*
+ * Sets Bouncy (Spongy) Castle as preferred security provider
+ *
+ * insertProviderAt() position starts from 1
+ */
+ Security.insertProviderAt(new BouncyCastleProvider(), 1);
+
+ /*
+ * apply RNG fixes
+ *
+ * among other things, executes Security.insertProviderAt(new
+ * LinuxPRNGSecureRandomProvider(), 1) for Android <= SDK 17
+ */
PRNGFixes.apply();
- Log.d(Constants.TAG, "PRNG Fixes applied!");
+ Log.d(Constants.TAG, "Bouncy Castle set and PRNG Fixes applied!");
+
+ if (Constants.DEBUG) {
+ Provider[] providers = Security.getProviders();
+ Log.d(Constants.TAG, "Installed Security Providers:");
+ for (Provider p : providers) {
+ Log.d(Constants.TAG, "provider class: " + p.getClass().getName());
+ }
+ }
// Create APG directory on sdcard if not existing
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
@@ -51,5 +71,4 @@ public class KeychainApplication extends Application {
}
}
}
-
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/util/PRNGFixes.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/util/PRNGFixes.java
index 9346ca878..9736bb4b8 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/util/PRNGFixes.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/util/PRNGFixes.java
@@ -1,5 +1,3 @@
-package org.sufficientlysecure.keychain.util;
-
/*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will Google be held liable for any damages
@@ -10,6 +8,8 @@ package org.sufficientlysecure.keychain.util;
* freely, as long as the origin is not misrepresented.
*/
+package org.sufficientlysecure.keychain.util;
+
import android.os.Build;
import android.os.Process;