diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-10-31 18:18:09 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-10-31 18:18:09 +0100 |
commit | 1886dd1790536e07a0c2e6eac3006e93cb5611e1 (patch) | |
tree | fc7099135b90eb1241f9dcdad759b9e562552e81 /OpenKeychain/src/main | |
parent | 8720a211067a5cd0a82311603865c283ca3ba4ac (diff) | |
download | open-keychain-1886dd1790536e07a0c2e6eac3006e93cb5611e1.tar.gz open-keychain-1886dd1790536e07a0c2e6eac3006e93cb5611e1.tar.bz2 open-keychain-1886dd1790536e07a0c2e6eac3006e93cb5611e1.zip |
export secret and public keys in separate armored blocks
Diffstat (limited to 'OpenKeychain/src/main')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java index 9b9c5043d..da532d2dc 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java @@ -456,16 +456,17 @@ public class ImportExportOperation extends BaseOperation { // For each public masterKey id while (!cursor.isAfterLast()) { + long keyId = cursor.getLong(0); + ArmoredOutputStream arOutStream = null; + // Create an output stream - ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); try { + arOutStream = new ArmoredOutputStream(outStream); String version = PgpHelper.getVersionForHeader(mContext); if (version != null) { arOutStream.setHeader("Version", version); } - long keyId = cursor.getLong(0); - log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId)); { // export public key part @@ -474,19 +475,33 @@ public class ImportExportOperation extends BaseOperation { okPublic += 1; } + } finally { + // make sure this is closed + if (arOutStream != null) { + arOutStream.close(); + } + arOutStream = null; + } + + if (exportSecret && cursor.getInt(3) > 0) { + try { + arOutStream = new ArmoredOutputStream(outStream); + String version = PgpHelper.getVersionForHeader(mContext); + if (version != null) { + arOutStream.setHeader("Version", version); + } // export secret key part - if (exportSecret && cursor.getInt(3) > 0) { log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId)); byte[] data = cursor.getBlob(2); arOutStream.write(data); okSecret += 1; - } - } finally { - // make sure this is closed - if (arOutStream != null) { - arOutStream.close(); + } finally { + // make sure this is closed + if (arOutStream != null) { + arOutStream.close(); + } } } |