Reorder security providers in application class, document functionality

This commit is contained in:
Dominik Schürmann 2013-09-15 22:19:15 +02:00
parent 4b8c5c8134
commit c90e776055
2 changed files with 29 additions and 10 deletions

View File

@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain; package org.sufficientlysecure.keychain;
import java.io.File; import java.io.File;
import java.security.Provider;
import java.security.Security; import java.security.Security;
import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.jce.provider.BouncyCastleProvider;
@ -29,18 +30,37 @@ import android.os.Environment;
public class KeychainApplication extends Application { public class KeychainApplication extends Application {
static { /**
// Define Java Security Provider to be Bouncy Castle * Called when the application is starting, before any activity, service, or receiver objects
Security.insertProviderAt(new BouncyCastleProvider(), 1); * (excluding content providers) have been created.
} */
@Override @Override
public void onCreate() { public void onCreate() {
super.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(); 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 // Create APG directory on sdcard if not existing
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
@ -51,5 +71,4 @@ public class KeychainApplication extends Application {
} }
} }
} }
} }

View File

@ -1,5 +1,3 @@
package org.sufficientlysecure.keychain.util;
/* /*
* This software is provided 'as-is', without any express or implied * This software is provided 'as-is', without any express or implied
* warranty. In no event will Google be held liable for any damages * 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. * freely, as long as the origin is not misrepresented.
*/ */
package org.sufficientlysecure.keychain.util;
import android.os.Build; import android.os.Build;
import android.os.Process; import android.os.Process;