extend canonicalize to strip local certificates on export
This commit is contained in:
@@ -31,6 +31,7 @@ import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.Keyserver.AddKeyException;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.operations.results.ExportResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
@@ -399,7 +400,7 @@ public class ImportExportOperation extends BaseOperation {
|
||||
|
||||
}
|
||||
|
||||
private ExportResult exportKeyRings(OperationLog log, long[] masterKeyIds, boolean exportSecret,
|
||||
ExportResult exportKeyRings(OperationLog log, long[] masterKeyIds, boolean exportSecret,
|
||||
OutputStream outStream) {
|
||||
|
||||
/* TODO isn't this checked above, with the isStorageMounted call?
|
||||
@@ -469,12 +470,16 @@ public class ImportExportOperation extends BaseOperation {
|
||||
|
||||
log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
|
||||
|
||||
{ // export public key part
|
||||
byte[] data = cursor.getBlob(1);
|
||||
arOutStream.write(data);
|
||||
byte[] data = cursor.getBlob(1);
|
||||
CanonicalizedKeyRing ring =
|
||||
UncachedKeyRing.decodeFromData(data).canonicalize(log, 2, true);
|
||||
ring.encode(arOutStream);
|
||||
|
||||
okPublic += 1;
|
||||
}
|
||||
okPublic += 1;
|
||||
} catch (PgpGeneralException e) {
|
||||
log.add(LogType.MSG_EXPORT_ERROR_KEY, 2);
|
||||
updateProgress(progress++, numKeys);
|
||||
continue;
|
||||
} finally {
|
||||
// make sure this is closed
|
||||
if (arOutStream != null) {
|
||||
@@ -491,12 +496,18 @@ public class ImportExportOperation extends BaseOperation {
|
||||
arOutStream.setHeader("Version", version);
|
||||
}
|
||||
|
||||
// export secret key part
|
||||
// export secret key part
|
||||
log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
|
||||
byte[] data = cursor.getBlob(2);
|
||||
arOutStream.write(data);
|
||||
CanonicalizedKeyRing ring =
|
||||
UncachedKeyRing.decodeFromData(data).canonicalize(log, 2, true);
|
||||
ring.encode(arOutStream);
|
||||
|
||||
okSecret += 1;
|
||||
} catch (PgpGeneralException e) {
|
||||
log.add(LogType.MSG_EXPORT_ERROR_KEY, 2);
|
||||
updateProgress(progress++, numKeys);
|
||||
continue;
|
||||
} finally {
|
||||
// make sure this is closed
|
||||
if (arOutStream != null) {
|
||||
|
||||
@@ -371,12 +371,13 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_KC_ERROR_MASTER_ALGO (LogLevel.ERROR, R.string.msg_kc_error_master_algo),
|
||||
MSG_KC_ERROR_DUP_KEY (LogLevel.ERROR, R.string.msg_kc_error_dup_key),
|
||||
MSG_KC_MASTER (LogLevel.DEBUG, R.string.msg_kc_master),
|
||||
MSG_KC_BAD_TYPE(LogLevel.WARN, R.string.msg_kc_bad_type),
|
||||
MSG_KC_REVOKE_BAD_ERR (LogLevel.WARN, R.string.msg_kc_revoke_bad_err),
|
||||
MSG_KC_REVOKE_BAD_LOCAL (LogLevel.WARN, R.string.msg_kc_revoke_bad_local),
|
||||
MSG_KC_REVOKE_BAD_TIME (LogLevel.WARN, R.string.msg_kc_revoke_bad_time),
|
||||
MSG_KC_REVOKE_BAD_TYPE_UID (LogLevel.WARN, R.string.msg_kc_revoke_bad_type_uid),
|
||||
MSG_KC_REVOKE_BAD (LogLevel.WARN, R.string.msg_kc_revoke_bad),
|
||||
MSG_KC_MASTER_BAD_TYPE(LogLevel.WARN, R.string.msg_kc_master_bad_type),
|
||||
MSG_KC_MASTER_BAD_LOCAL(LogLevel.WARN, R.string.msg_kc_master_bad_local),
|
||||
MSG_KC_MASTER_BAD_ERR(LogLevel.WARN, R.string.msg_kc_master_bad_err),
|
||||
MSG_KC_MASTER_BAD_TIME(LogLevel.WARN, R.string.msg_kc_master_bad_time),
|
||||
MSG_KC_MASTER_BAD_TYPE_UID(LogLevel.WARN, R.string.msg_kc_master_bad_type_uid),
|
||||
MSG_KC_MASTER_BAD(LogLevel.WARN, R.string.msg_kc_master_bad),
|
||||
MSG_KC_MASTER_LOCAL(LogLevel.WARN, R.string.msg_kc_master_local),
|
||||
MSG_KC_REVOKE_DUP (LogLevel.DEBUG, R.string.msg_kc_revoke_dup),
|
||||
MSG_KC_NOTATION_DUP (LogLevel.DEBUG, R.string.msg_kc_notation_dup),
|
||||
MSG_KC_NOTATION_EMPTY (LogLevel.DEBUG, R.string.msg_kc_notation_empty),
|
||||
@@ -618,6 +619,7 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_EXPORT_ERROR_STORAGE (LogLevel.ERROR, R.string.msg_export_error_storage),
|
||||
MSG_EXPORT_ERROR_DB (LogLevel.ERROR, R.string.msg_export_error_db),
|
||||
MSG_EXPORT_ERROR_IO (LogLevel.ERROR, R.string.msg_export_error_io),
|
||||
MSG_EXPORT_ERROR_KEY (LogLevel.ERROR, R.string.msg_export_error_key),
|
||||
MSG_EXPORT_SUCCESS (LogLevel.OK, R.string.msg_export_success),
|
||||
|
||||
MSG_CRT_UPLOAD_SUCCESS (LogLevel.OK, R.string.msg_crt_upload_success),
|
||||
|
||||
Reference in New Issue
Block a user