mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-21 05:11:45 -05:00
export secret and public keys in separate armored blocks
This commit is contained in:
parent
8720a21106
commit
1886dd1790
@ -456,16 +456,17 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
// For each public masterKey id
|
// For each public masterKey id
|
||||||
while (!cursor.isAfterLast()) {
|
while (!cursor.isAfterLast()) {
|
||||||
|
|
||||||
|
long keyId = cursor.getLong(0);
|
||||||
|
ArmoredOutputStream arOutStream = null;
|
||||||
|
|
||||||
// Create an output stream
|
// Create an output stream
|
||||||
ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream);
|
|
||||||
try {
|
try {
|
||||||
|
arOutStream = new ArmoredOutputStream(outStream);
|
||||||
String version = PgpHelper.getVersionForHeader(mContext);
|
String version = PgpHelper.getVersionForHeader(mContext);
|
||||||
if (version != null) {
|
if (version != null) {
|
||||||
arOutStream.setHeader("Version", version);
|
arOutStream.setHeader("Version", version);
|
||||||
}
|
}
|
||||||
|
|
||||||
long keyId = cursor.getLong(0);
|
|
||||||
|
|
||||||
log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
|
log.add(LogType.MSG_EXPORT_PUBLIC, 1, KeyFormattingUtils.beautifyKeyId(keyId));
|
||||||
|
|
||||||
{ // export public key part
|
{ // export public key part
|
||||||
@ -474,19 +475,33 @@ public class ImportExportOperation extends BaseOperation {
|
|||||||
|
|
||||||
okPublic += 1;
|
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
|
// export secret key part
|
||||||
if (exportSecret && cursor.getInt(3) > 0) {
|
|
||||||
log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
|
log.add(LogType.MSG_EXPORT_SECRET, 2, KeyFormattingUtils.beautifyKeyId(keyId));
|
||||||
byte[] data = cursor.getBlob(2);
|
byte[] data = cursor.getBlob(2);
|
||||||
arOutStream.write(data);
|
arOutStream.write(data);
|
||||||
|
|
||||||
okSecret += 1;
|
okSecret += 1;
|
||||||
}
|
} finally {
|
||||||
} finally {
|
// make sure this is closed
|
||||||
// make sure this is closed
|
if (arOutStream != null) {
|
||||||
if (arOutStream != null) {
|
arOutStream.close();
|
||||||
arOutStream.close();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user