mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 16:38:50 -05:00
Always use insertProvider instead of addProvider
This commit is contained in:
parent
9611236bf1
commit
a186686109
@ -127,8 +127,8 @@ import java.util.regex.Pattern;
|
|||||||
public class PgpMain {
|
public class PgpMain {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// register spongy castle provider
|
// Define Java Security Provider to be Bouncy Castle
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.insertProviderAt(new BouncyCastleProvider(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not BC due to the use of Spongy Castle for Android
|
// Not BC due to the use of Spongy Castle for Android
|
||||||
@ -310,10 +310,9 @@ public class PgpMain {
|
|||||||
return secKeyRing;
|
return secKeyRing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void changeSecretKeyPassphrase(Context context,
|
public static void changeSecretKeyPassphrase(Context context, PGPSecretKeyRing keyRing,
|
||||||
PGPSecretKeyRing keyRing, String oldPassPhrase, String newPassPhrase,
|
String oldPassPhrase, String newPassPhrase, ProgressDialogUpdater progress)
|
||||||
ProgressDialogUpdater progress) throws IOException, PGPException, PGPException,
|
throws IOException, PGPException, PGPException, NoSuchProviderException {
|
||||||
NoSuchProviderException {
|
|
||||||
|
|
||||||
updateProgress(progress, R.string.progress_buildingKey, 0, 100);
|
updateProgress(progress, R.string.progress_buildingKey, 0, 100);
|
||||||
if (oldPassPhrase == null) {
|
if (oldPassPhrase == null) {
|
||||||
@ -323,10 +322,13 @@ public class PgpMain {
|
|||||||
newPassPhrase = "";
|
newPassPhrase = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.copyWithNewPassword(keyRing,
|
PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.copyWithNewPassword(
|
||||||
new JcePBESecretKeyDecryptorBuilder(
|
keyRing,
|
||||||
new JcaPGPDigestCalculatorProviderBuilder().setProvider(BOUNCY_CASTLE_PROVIDER_NAME).build()).setProvider(BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()),
|
new JcePBESecretKeyDecryptorBuilder(new JcaPGPDigestCalculatorProviderBuilder()
|
||||||
new JcePBESecretKeyEncryptorBuilder(keyRing.getSecretKey().getKeyEncryptionAlgorithm()).build(newPassPhrase.toCharArray()));
|
.setProvider(BOUNCY_CASTLE_PROVIDER_NAME).build()).setProvider(
|
||||||
|
BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()),
|
||||||
|
new JcePBESecretKeyEncryptorBuilder(keyRing.getSecretKey()
|
||||||
|
.getKeyEncryptionAlgorithm()).build(newPassPhrase.toCharArray()));
|
||||||
|
|
||||||
updateProgress(progress, R.string.progress_savingKeyRing, 50, 100);
|
updateProgress(progress, R.string.progress_savingKeyRing, 50, 100);
|
||||||
|
|
||||||
@ -334,7 +336,7 @@ public class PgpMain {
|
|||||||
|
|
||||||
updateProgress(progress, R.string.progress_done, 100, 100);
|
updateProgress(progress, R.string.progress_done, 100, 100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void buildSecretKey(Context context, ArrayList<String> userIds,
|
public static void buildSecretKey(Context context, ArrayList<String> userIds,
|
||||||
ArrayList<PGPSecretKey> keys, ArrayList<Integer> keysUsages, long masterKeyId,
|
ArrayList<PGPSecretKey> keys, ArrayList<Integer> keysUsages, long masterKeyId,
|
||||||
@ -519,7 +521,8 @@ public class PgpMain {
|
|||||||
PGPSecretKeyRing secretKeyRing = (PGPSecretKeyRing) keyring;
|
PGPSecretKeyRing secretKeyRing = (PGPSecretKeyRing) keyring;
|
||||||
boolean save = true;
|
boolean save = true;
|
||||||
|
|
||||||
for (PGPSecretKey testSecretKey : new IterableIterator<PGPSecretKey>(secretKeyRing.getSecretKeys())) {
|
for (PGPSecretKey testSecretKey : new IterableIterator<PGPSecretKey>(
|
||||||
|
secretKeyRing.getSecretKeys())) {
|
||||||
if (!testSecretKey.isMasterKey()) {
|
if (!testSecretKey.isMasterKey()) {
|
||||||
if (PgpHelper.isSecretKeyPrivateEmpty(testSecretKey)) {
|
if (PgpHelper.isSecretKeyPrivateEmpty(testSecretKey)) {
|
||||||
// this is bad, something is very wrong...
|
// this is bad, something is very wrong...
|
||||||
|
Loading…
Reference in New Issue
Block a user