mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 11:35:07 -05:00
Merge trunk into apg_service
This commit is contained in:
parent
e8d29c01c2
commit
6634f40bc2
@ -141,6 +141,7 @@
|
|||||||
<string name="expired">scaduto</string>
|
<string name="expired">scaduto</string>
|
||||||
<string name="notValid">non valido</string>
|
<string name="notValid">non valido</string>
|
||||||
<string name="nKeyServers">%s key server(s)</string>
|
<string name="nKeyServers">%s key server(s)</string>
|
||||||
|
<string name="fingerprint">fingerprint</string>
|
||||||
|
|
||||||
<!-- choice_lowerCase: capitalized firwst word, no punctuation -->
|
<!-- choice_lowerCase: capitalized firwst word, no punctuation -->
|
||||||
<string name="choice_none">Nessuno</string>
|
<string name="choice_none">Nessuno</string>
|
||||||
@ -154,6 +155,10 @@
|
|||||||
<string name="choice_10mins">10 min</string>
|
<string name="choice_10mins">10 min</string>
|
||||||
<string name="choice_20mins">20 min</string>
|
<string name="choice_20mins">20 min</string>
|
||||||
<string name="choice_40mins">40 min</string>
|
<string name="choice_40mins">40 min</string>
|
||||||
|
<string name="choice_1hour">1 ora</string>
|
||||||
|
<string name="choice_2hours">2 ore</string>
|
||||||
|
<string name="choice_4hours">4 ore</string>
|
||||||
|
<string name="choice_8hours">8 ore</string>
|
||||||
<string name="choice_untilQuit">tutta la sessione</string>
|
<string name="choice_untilQuit">tutta la sessione</string>
|
||||||
<string name="choice_language_system">Default di sistema</string>
|
<string name="choice_language_system">Default di sistema</string>
|
||||||
|
|
||||||
@ -223,6 +228,7 @@
|
|||||||
<string name="error_noKnownEncryptionFound">non è stato trovato nessun tipo di crittazione valido</string>
|
<string name="error_noKnownEncryptionFound">non è stato trovato nessun tipo di crittazione valido</string>
|
||||||
<string name="error_externalStorageNotReady">la scheda di memoria non è pronta o non è utilizzabile</string>
|
<string name="error_externalStorageNotReady">la scheda di memoria non è pronta o non è utilizzabile</string>
|
||||||
<string name="error_accountNotFound">acconto \'%s\' non trovato</string>
|
<string name="error_accountNotFound">acconto \'%s\' non trovato</string>
|
||||||
|
<string name="error_accountReadingNotAllowed">accesso in lettura all'\account negato</string>
|
||||||
<string name="error_addingAccountFailed">non è stato possibile aggiungere l\'acconto \'%s\'</string>
|
<string name="error_addingAccountFailed">non è stato possibile aggiungere l\'acconto \'%s\'</string>
|
||||||
<string name="error_invalidEmail">mail non valida \'%s\'</string>
|
<string name="error_invalidEmail">mail non valida \'%s\'</string>
|
||||||
<string name="error_keySizeMinimum512bit">la dimensione della chiave deve essere almeno di 512bit</string>
|
<string name="error_keySizeMinimum512bit">la dimensione della chiave deve essere almeno di 512bit</string>
|
||||||
|
@ -400,7 +400,8 @@ public class Apg {
|
|||||||
throws Apg.GeneralException, NoSuchProviderException, PGPException,
|
throws Apg.GeneralException, NoSuchProviderException, PGPException,
|
||||||
NoSuchAlgorithmException, SignatureException, IOException, Database.GeneralException {
|
NoSuchAlgorithmException, SignatureException, IOException, Database.GeneralException {
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_buildingKey, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_buildingKey, 0, 100);
|
||||||
|
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
|
||||||
@ -461,7 +462,8 @@ public class Apg {
|
|||||||
keys.add(editor.getValue());
|
keys.add(editor.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_preparingMasterKey, 10, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingMasterKey, 10, 100);
|
||||||
KeyEditor keyEditor = (KeyEditor) keyEditors.getChildAt(0);
|
KeyEditor keyEditor = (KeyEditor) keyEditors.getChildAt(0);
|
||||||
int usageId = keyEditor.getUsage();
|
int usageId = keyEditor.getUsage();
|
||||||
boolean canSign = (usageId == Id.choice.usage.sign_only ||
|
boolean canSign = (usageId == Id.choice.usage.sign_only ||
|
||||||
@ -481,7 +483,8 @@ public class Apg {
|
|||||||
masterKey.extractPrivateKey(oldPassPhrase.toCharArray(),
|
masterKey.extractPrivateKey(oldPassPhrase.toCharArray(),
|
||||||
new BouncyCastleProvider());
|
new BouncyCastleProvider());
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_certifyingMasterKey, 20, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_certifyingMasterKey, 20, 100);
|
||||||
for (int i = 0; i < userIds.size(); ++i) {
|
for (int i = 0; i < userIds.size(); ++i) {
|
||||||
String userId = userIds.get(i);
|
String userId = userIds.get(i);
|
||||||
|
|
||||||
@ -525,7 +528,8 @@ public class Apg {
|
|||||||
hashedPacketsGen.setKeyExpirationTime(true, numDays * 86400);
|
hashedPacketsGen.setKeyExpirationTime(true, numDays * 86400);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_buildingMasterKeyRing, 30, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_buildingMasterKeyRing, 30, 100);
|
||||||
PGPKeyRingGenerator keyGen =
|
PGPKeyRingGenerator keyGen =
|
||||||
new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION,
|
new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION,
|
||||||
masterKeyPair, mainUserId,
|
masterKeyPair, mainUserId,
|
||||||
@ -533,9 +537,11 @@ public class Apg {
|
|||||||
hashedPacketsGen.generate(), unhashedPacketsGen.generate(),
|
hashedPacketsGen.generate(), unhashedPacketsGen.generate(),
|
||||||
new SecureRandom(), new BouncyCastleProvider().getName());
|
new SecureRandom(), new BouncyCastleProvider().getName());
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_addingSubKeys, 40, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_addingSubKeys, 40, 100);
|
||||||
for (int i = 1; i < keys.size(); ++i) {
|
for (int i = 1; i < keys.size(); ++i) {
|
||||||
progress.setProgress(40 + 50 * (i - 1)/ (keys.size() - 1), 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(40 + 50 * (i - 1)/ (keys.size() - 1), 100);
|
||||||
PGPSecretKey subKey = keys.get(i);
|
PGPSecretKey subKey = keys.get(i);
|
||||||
keyEditor = (KeyEditor) keyEditors.getChildAt(i);
|
keyEditor = (KeyEditor) keyEditors.getChildAt(i);
|
||||||
PGPPublicKey subPublicKey = subKey.getPublicKey();
|
PGPPublicKey subPublicKey = subKey.getPublicKey();
|
||||||
@ -584,11 +590,13 @@ public class Apg {
|
|||||||
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
|
PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing();
|
||||||
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
|
PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing();
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_savingKeyRing, 90, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_savingKeyRing, 90, 100);
|
||||||
mDatabase.saveKeyRing(secretKeyRing);
|
mDatabase.saveKeyRing(secretKeyRing);
|
||||||
mDatabase.saveKeyRing(publicKeyRing);
|
mDatabase.saveKeyRing(publicKeyRing);
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bundle importKeyRings(Activity context, int type,
|
public static Bundle importKeyRings(Activity context, int type,
|
||||||
@ -598,9 +606,11 @@ public class Apg {
|
|||||||
Bundle returnData = new Bundle();
|
Bundle returnData = new Bundle();
|
||||||
|
|
||||||
if (type == Id.type.secret_key) {
|
if (type == Id.type.secret_key) {
|
||||||
progress.setProgress(R.string.progress_importingSecretKeys, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_importingSecretKeys, 0, 100);
|
||||||
} else {
|
} else {
|
||||||
progress.setProgress(R.string.progress_importingPublicKeys, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_importingPublicKeys, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||||
@ -671,7 +681,8 @@ public class Apg {
|
|||||||
} else if (retValue == Id.return_value.bad) {
|
} else if (retValue == Id.return_value.bad) {
|
||||||
++badKeys;
|
++badKeys;
|
||||||
}
|
}
|
||||||
progress.setProgress((int)(100 * progressIn.position() / data.getSize()), 100);
|
if( progress != null )
|
||||||
|
progress.setProgress((int)(100 * progressIn.position() / data.getSize()), 100);
|
||||||
obj = objectFactory.nextObject();
|
obj = objectFactory.nextObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -683,7 +694,8 @@ public class Apg {
|
|||||||
returnData.putInt("updated", oldKeys);
|
returnData.putInt("updated", oldKeys);
|
||||||
returnData.putInt("bad", badKeys);
|
returnData.putInt("bad", badKeys);
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
@ -695,9 +707,11 @@ public class Apg {
|
|||||||
Bundle returnData = new Bundle();
|
Bundle returnData = new Bundle();
|
||||||
|
|
||||||
if (keyRingIds.size() == 1) {
|
if (keyRingIds.size() == 1) {
|
||||||
progress.setProgress(R.string.progress_exportingKey, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_exportingKey, 0, 100);
|
||||||
} else {
|
} else {
|
||||||
progress.setProgress(R.string.progress_exportingKeys, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_exportingKeys, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||||
@ -707,7 +721,8 @@ public class Apg {
|
|||||||
|
|
||||||
int numKeys = 0;
|
int numKeys = 0;
|
||||||
for (int i = 0; i < keyRingIds.size(); ++i) {
|
for (int i = 0; i < keyRingIds.size(); ++i) {
|
||||||
progress.setProgress(i * 100 / keyRingIds.size(), 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(i * 100 / keyRingIds.size(), 100);
|
||||||
Object obj = mDatabase.getKeyRing(keyRingIds.get(i));
|
Object obj = mDatabase.getKeyRing(keyRingIds.get(i));
|
||||||
PGPPublicKeyRing publicKeyRing;
|
PGPPublicKeyRing publicKeyRing;
|
||||||
PGPSecretKeyRing secretKeyRing;
|
PGPSecretKeyRing secretKeyRing;
|
||||||
@ -726,7 +741,8 @@ public class Apg {
|
|||||||
out.close();
|
out.close();
|
||||||
returnData.putInt("exported", numKeys);
|
returnData.putInt("exported", numKeys);
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
|
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
@ -1236,15 +1252,16 @@ public class Apg {
|
|||||||
if (signaturePassPhrase == null) {
|
if (signaturePassPhrase == null) {
|
||||||
throw new GeneralException(context.getString(R.string.error_noSignaturePassPhrase));
|
throw new GeneralException(context.getString(R.string.error_noSignaturePassPhrase));
|
||||||
}
|
}
|
||||||
progress.setProgress(R.string.progress_extractingSignatureKey, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_extractingSignatureKey, 0, 100);
|
||||||
signaturePrivateKey = signingKey.extractPrivateKey(signaturePassPhrase.toCharArray(),
|
signaturePrivateKey = signingKey.extractPrivateKey(signaturePassPhrase.toCharArray(),
|
||||||
new BouncyCastleProvider());
|
new BouncyCastleProvider());
|
||||||
if (signaturePrivateKey == null) {
|
if (signaturePrivateKey == null) {
|
||||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if( progress != null )
|
||||||
progress.setProgress(R.string.progress_preparingStreams, 5, 100);
|
progress.setProgress(R.string.progress_preparingStreams, 5, 100);
|
||||||
// encrypt and compress input file content
|
// encrypt and compress input file content
|
||||||
PGPEncryptedDataGenerator cPk =
|
PGPEncryptedDataGenerator cPk =
|
||||||
new PGPEncryptedDataGenerator(symmetricAlgorithm, true, new SecureRandom(),
|
new PGPEncryptedDataGenerator(symmetricAlgorithm, true, new SecureRandom(),
|
||||||
@ -1266,7 +1283,8 @@ public class Apg {
|
|||||||
PGPV3SignatureGenerator signatureV3Generator = null;
|
PGPV3SignatureGenerator signatureV3Generator = null;
|
||||||
|
|
||||||
if (signatureKeyId != 0) {
|
if (signatureKeyId != 0) {
|
||||||
progress.setProgress(R.string.progress_preparingSignature, 10, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingSignature, 10, 100);
|
||||||
if (forceV3Signature) {
|
if (forceV3Signature) {
|
||||||
signatureV3Generator =
|
signatureV3Generator =
|
||||||
new PGPV3SignatureGenerator(signingKey.getPublicKey().getAlgorithm(),
|
new PGPV3SignatureGenerator(signingKey.getPublicKey().getAlgorithm(),
|
||||||
@ -1307,8 +1325,8 @@ public class Apg {
|
|||||||
// file name not needed, so empty string
|
// file name not needed, so empty string
|
||||||
OutputStream pOut = literalGen.open(bcpgOut, PGPLiteralData.BINARY, "",
|
OutputStream pOut = literalGen.open(bcpgOut, PGPLiteralData.BINARY, "",
|
||||||
new Date(), new byte[1 << 16]);
|
new Date(), new byte[1 << 16]);
|
||||||
|
if( progress != null )
|
||||||
progress.setProgress(R.string.progress_encrypting, 20, 100);
|
progress.setProgress(R.string.progress_encrypting, 20, 100);
|
||||||
long done = 0;
|
long done = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
byte[] buffer = new byte[1 << 16];
|
byte[] buffer = new byte[1 << 16];
|
||||||
@ -1324,14 +1342,16 @@ public class Apg {
|
|||||||
}
|
}
|
||||||
done += n;
|
done += n;
|
||||||
if (data.getSize() != 0) {
|
if (data.getSize() != 0) {
|
||||||
progress.setProgress((int) (20 + (95 - 20) * done / data.getSize()), 100);
|
if( progress != null )
|
||||||
|
progress.setProgress((int) (20 + (95 - 20) * done / data.getSize()), 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
literalGen.close();
|
literalGen.close();
|
||||||
|
|
||||||
if (signatureKeyId != 0) {
|
if (signatureKeyId != 0) {
|
||||||
progress.setProgress(R.string.progress_generatingSignature, 95, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_generatingSignature, 95, 100);
|
||||||
if (forceV3Signature) {
|
if (forceV3Signature) {
|
||||||
signatureV3Generator.generate().encode(pOut);
|
signatureV3Generator.generate().encode(pOut);
|
||||||
} else {
|
} else {
|
||||||
@ -1346,7 +1366,8 @@ public class Apg {
|
|||||||
armorOut.close();
|
armorOut.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void signText(Context context,
|
public static void signText(Context context,
|
||||||
@ -1385,9 +1406,11 @@ public class Apg {
|
|||||||
if (signaturePrivateKey == null) {
|
if (signaturePrivateKey == null) {
|
||||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||||
}
|
}
|
||||||
progress.setProgress(R.string.progress_preparingStreams, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingStreams, 0, 100);
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_preparingSignature, 30, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingSignature, 30, 100);
|
||||||
|
|
||||||
PGPSignatureGenerator signatureGenerator = null;
|
PGPSignatureGenerator signatureGenerator = null;
|
||||||
PGPV3SignatureGenerator signatureV3Generator = null;
|
PGPV3SignatureGenerator signatureV3Generator = null;
|
||||||
@ -1411,7 +1434,8 @@ public class Apg {
|
|||||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_signing, 40, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_signing, 40, 100);
|
||||||
|
|
||||||
armorOut.beginClearText(hashAlgorithm);
|
armorOut.beginClearText(hashAlgorithm);
|
||||||
|
|
||||||
@ -1454,7 +1478,8 @@ public class Apg {
|
|||||||
}
|
}
|
||||||
armorOut.close();
|
armorOut.close();
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generateSignature(Context context,
|
public static void generateSignature(Context context,
|
||||||
@ -1501,9 +1526,11 @@ public class Apg {
|
|||||||
if (signaturePrivateKey == null) {
|
if (signaturePrivateKey == null) {
|
||||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||||
}
|
}
|
||||||
progress.setProgress(R.string.progress_preparingStreams, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingStreams, 0, 100);
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_preparingSignature, 30, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingSignature, 30, 100);
|
||||||
|
|
||||||
PGPSignatureGenerator signatureGenerator = null;
|
PGPSignatureGenerator signatureGenerator = null;
|
||||||
PGPV3SignatureGenerator signatureV3Generator = null;
|
PGPV3SignatureGenerator signatureV3Generator = null;
|
||||||
@ -1532,7 +1559,8 @@ public class Apg {
|
|||||||
signatureGenerator.setHashedSubpackets(spGen.generate());
|
signatureGenerator.setHashedSubpackets(spGen.generate());
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_signing, 40, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_signing, 40, 100);
|
||||||
|
|
||||||
InputStream inStream = data.getInputStream();
|
InputStream inStream = data.getInputStream();
|
||||||
if (binary) {
|
if (binary) {
|
||||||
@ -1575,7 +1603,8 @@ public class Apg {
|
|||||||
out.close();
|
out.close();
|
||||||
outStream.close();
|
outStream.close();
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getDecryptionKeyId(Context context, InputData data)
|
public static long getDecryptionKeyId(Context context, InputData data)
|
||||||
@ -1669,7 +1698,8 @@ public class Apg {
|
|||||||
long signatureKeyId = 0;
|
long signatureKeyId = 0;
|
||||||
|
|
||||||
int currentProgress = 0;
|
int currentProgress = 0;
|
||||||
progress.setProgress(R.string.progress_readingData, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_readingData, currentProgress, 100);
|
||||||
|
|
||||||
if (o instanceof PGPEncryptedDataList) {
|
if (o instanceof PGPEncryptedDataList) {
|
||||||
enc = (PGPEncryptedDataList) o;
|
enc = (PGPEncryptedDataList) o;
|
||||||
@ -1704,12 +1734,14 @@ public class Apg {
|
|||||||
throw new GeneralException(context.getString(R.string.error_noSymmetricEncryptionPacket));
|
throw new GeneralException(context.getString(R.string.error_noSymmetricEncryptionPacket));
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_preparingStreams, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingStreams, currentProgress, 100);
|
||||||
clear = pbe.getDataStream(passPhrase.toCharArray(), new BouncyCastleProvider());
|
clear = pbe.getDataStream(passPhrase.toCharArray(), new BouncyCastleProvider());
|
||||||
encryptedData = pbe;
|
encryptedData = pbe;
|
||||||
currentProgress += 5;
|
currentProgress += 5;
|
||||||
} else {
|
} else {
|
||||||
progress.setProgress(R.string.progress_findingKey, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_findingKey, currentProgress, 100);
|
||||||
PGPPublicKeyEncryptedData pbe = null;
|
PGPPublicKeyEncryptedData pbe = null;
|
||||||
PGPSecretKey secretKey = null;
|
PGPSecretKey secretKey = null;
|
||||||
Iterator it = enc.getEncryptedDataObjects();
|
Iterator it = enc.getEncryptedDataObjects();
|
||||||
@ -1731,7 +1763,8 @@ public class Apg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentProgress += 5;
|
currentProgress += 5;
|
||||||
progress.setProgress(R.string.progress_extractingKey, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_extractingKey, currentProgress, 100);
|
||||||
PGPPrivateKey privateKey = null;
|
PGPPrivateKey privateKey = null;
|
||||||
try {
|
try {
|
||||||
privateKey = secretKey.extractPrivateKey(passPhrase.toCharArray(),
|
privateKey = secretKey.extractPrivateKey(passPhrase.toCharArray(),
|
||||||
@ -1743,7 +1776,8 @@ public class Apg {
|
|||||||
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
throw new GeneralException(context.getString(R.string.error_couldNotExtractPrivateKey));
|
||||||
}
|
}
|
||||||
currentProgress += 5;
|
currentProgress += 5;
|
||||||
progress.setProgress(R.string.progress_preparingStreams, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_preparingStreams, currentProgress, 100);
|
||||||
clear = pbe.getDataStream(privateKey, new BouncyCastleProvider());
|
clear = pbe.getDataStream(privateKey, new BouncyCastleProvider());
|
||||||
encryptedData = pbe;
|
encryptedData = pbe;
|
||||||
currentProgress += 5;
|
currentProgress += 5;
|
||||||
@ -1756,7 +1790,8 @@ public class Apg {
|
|||||||
int signatureIndex = -1;
|
int signatureIndex = -1;
|
||||||
|
|
||||||
if (dataChunk instanceof PGPCompressedData) {
|
if (dataChunk instanceof PGPCompressedData) {
|
||||||
progress.setProgress(R.string.progress_decompressingData, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_decompressingData, currentProgress, 100);
|
||||||
PGPObjectFactory fact =
|
PGPObjectFactory fact =
|
||||||
new PGPObjectFactory(((PGPCompressedData) dataChunk).getDataStream());
|
new PGPObjectFactory(((PGPCompressedData) dataChunk).getDataStream());
|
||||||
dataChunk = fact.nextObject();
|
dataChunk = fact.nextObject();
|
||||||
@ -1765,7 +1800,8 @@ public class Apg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dataChunk instanceof PGPOnePassSignatureList) {
|
if (dataChunk instanceof PGPOnePassSignatureList) {
|
||||||
progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_processingSignature, currentProgress, 100);
|
||||||
returnData.putBoolean(EXTRA_SIGNATURE, true);
|
returnData.putBoolean(EXTRA_SIGNATURE, true);
|
||||||
PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
|
PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
|
||||||
for (int i = 0; i < sigList.size(); ++i) {
|
for (int i = 0; i < sigList.size(); ++i) {
|
||||||
@ -1802,7 +1838,8 @@ public class Apg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dataChunk instanceof PGPLiteralData) {
|
if (dataChunk instanceof PGPLiteralData) {
|
||||||
progress.setProgress(R.string.progress_decrypting, currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_decrypting, currentProgress, 100);
|
||||||
PGPLiteralData literalData = (PGPLiteralData) dataChunk;
|
PGPLiteralData literalData = (PGPLiteralData) dataChunk;
|
||||||
OutputStream out = outStream;
|
OutputStream out = outStream;
|
||||||
|
|
||||||
@ -1838,11 +1875,13 @@ public class Apg {
|
|||||||
currentProgress = (int)(startProgress + (endProgress - startProgress) *
|
currentProgress = (int)(startProgress + (endProgress - startProgress) *
|
||||||
(data.getStreamPosition() - startPos) / (data.getSize() - startPos));
|
(data.getStreamPosition() - startPos) / (data.getSize() - startPos));
|
||||||
}
|
}
|
||||||
progress.setProgress(currentProgress, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(currentProgress, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signature != null) {
|
if (signature != null) {
|
||||||
progress.setProgress(R.string.progress_verifyingSignature, 90, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_verifyingSignature, 90, 100);
|
||||||
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
PGPSignatureList signatureList = (PGPSignatureList) plainFact.nextObject();
|
||||||
PGPSignature messageSignature = (PGPSignature) signatureList.get(signatureIndex);
|
PGPSignature messageSignature = (PGPSignature) signatureList.get(signatureIndex);
|
||||||
if (signature.verify(messageSignature)) {
|
if (signature.verify(messageSignature)) {
|
||||||
@ -1855,7 +1894,8 @@ public class Apg {
|
|||||||
|
|
||||||
// TODO: add integrity somewhere
|
// TODO: add integrity somewhere
|
||||||
if (encryptedData.isIntegrityProtected()) {
|
if (encryptedData.isIntegrityProtected()) {
|
||||||
progress.setProgress(R.string.progress_verifyingIntegrity, 95, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_verifyingIntegrity, 95, 100);
|
||||||
if (encryptedData.verify()) {
|
if (encryptedData.verify()) {
|
||||||
// passed
|
// passed
|
||||||
} else {
|
} else {
|
||||||
@ -1865,7 +1905,8 @@ public class Apg {
|
|||||||
// no integrity check
|
// no integrity check
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1878,7 +1919,8 @@ public class Apg {
|
|||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
ArmoredInputStream aIn = new ArmoredInputStream(data.getInputStream());
|
ArmoredInputStream aIn = new ArmoredInputStream(data.getInputStream());
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 0, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 0, 100);
|
||||||
|
|
||||||
// mostly taken from ClearSignedFileProcessor
|
// mostly taken from ClearSignedFileProcessor
|
||||||
ByteArrayOutputStream lineOut = new ByteArrayOutputStream();
|
ByteArrayOutputStream lineOut = new ByteArrayOutputStream();
|
||||||
@ -1903,7 +1945,8 @@ public class Apg {
|
|||||||
|
|
||||||
returnData.putBoolean(EXTRA_SIGNATURE, true);
|
returnData.putBoolean(EXTRA_SIGNATURE, true);
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_processingSignature, 60, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_processingSignature, 60, 100);
|
||||||
PGPObjectFactory pgpFact = new PGPObjectFactory(aIn);
|
PGPObjectFactory pgpFact = new PGPObjectFactory(aIn);
|
||||||
|
|
||||||
PGPSignatureList sigList = (PGPSignatureList) pgpFact.nextObject();
|
PGPSignatureList sigList = (PGPSignatureList) pgpFact.nextObject();
|
||||||
@ -1950,7 +1993,8 @@ public class Apg {
|
|||||||
|
|
||||||
if (signature == null) {
|
if (signature == null) {
|
||||||
returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true);
|
returnData.putBoolean(EXTRA_SIGNATURE_UNKNOWN, true);
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1976,7 +2020,8 @@ public class Apg {
|
|||||||
|
|
||||||
returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, signature.verify());
|
returnData.putBoolean(EXTRA_SIGNATURE_SUCCESS, signature.verify());
|
||||||
|
|
||||||
progress.setProgress(R.string.progress_done, 100, 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(R.string.progress_done, 100, 100);
|
||||||
return returnData;
|
return returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2234,7 +2279,8 @@ public class Apg {
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
String msg = context.getString(R.string.progress_deletingSecurely, file.getName());
|
String msg = context.getString(R.string.progress_deletingSecurely, file.getName());
|
||||||
while (pos < length) {
|
while (pos < length) {
|
||||||
progress.setProgress(msg, (int)(100 * pos / length), 100);
|
if( progress != null )
|
||||||
|
progress.setProgress(msg, (int)(100 * pos / length), 100);
|
||||||
random.nextBytes(data);
|
random.nextBytes(data);
|
||||||
raf.write(data);
|
raf.write(data);
|
||||||
pos += data.length;
|
pos += data.length;
|
||||||
|
Loading…
Reference in New Issue
Block a user