From b67b6b7f874c2f448f8636f7c0d465b381b9ea65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 13 Sep 2014 21:59:47 +0200 Subject: [PATCH 1/2] Set literal data format tag to UTF8 when encrypting text --- .../sufficientlysecure/keychain/pgp/PgpSignEncrypt.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java index d82c68316..070239a80 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java @@ -434,7 +434,13 @@ public class PgpSignEncrypt { } PGPLiteralDataGenerator literalGen = new PGPLiteralDataGenerator(); - pOut = literalGen.open(bcpgOut, PGPLiteralData.BINARY, mOriginalFilename, new Date(), + char literalDataFormatTag; + if (mCleartextInput) { + literalDataFormatTag = PGPLiteralData.UTF8; + } else { + literalDataFormatTag = PGPLiteralData.BINARY; + } + pOut = literalGen.open(bcpgOut, literalDataFormatTag, mOriginalFilename, new Date(), new byte[1 << 16]); long alreadyWritten = 0; From be199b844c106fd5247e511fdf9bc0a9e0b67839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sat, 13 Sep 2014 22:02:01 +0200 Subject: [PATCH 2/2] Cleanup tests --- .../keychain/provider/ProviderHelperSaveTest.java | 11 +++-------- settings.gradle | 3 +-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java index c431dff1b..2d6b1b127 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/provider/ProviderHelperSaveTest.java @@ -76,8 +76,7 @@ public class ProviderHelperSaveTest { @Test public void testImportNoFlagKey() throws Exception { - UncachedKeyRing pub = - readRingFromResource("/test-keys/mailvelope_07_no_key_flags.asc"); + UncachedKeyRing pub = readRingFromResource("/test-keys/mailvelope_07_no_key_flags.asc"); long keyId = pub.getMasterKeyId(); Assert.assertNull("key flags should be null", pub.getPublicKey().getKeyUsage()); @@ -100,8 +99,7 @@ public class ProviderHelperSaveTest { @Test public void testImportDivertToCard() throws Exception { - UncachedKeyRing sec = - readRingFromResource("/test-keys/divert_to_card_sec.asc"); + UncachedKeyRing sec = readRingFromResource("/test-keys/divert_to_card_sec.asc"); long keyId = sec.getMasterKeyId(); SaveKeyringResult result; @@ -124,8 +122,7 @@ public class ProviderHelperSaveTest { @Test public void testImportBadEncodedUserId() throws Exception { - UncachedKeyRing key = - readRingFromResource("/test-keys/bad_user_id_encoding.asc"); + UncachedKeyRing key = readRingFromResource("/test-keys/bad_user_id_encoding.asc"); long keyId = key.getMasterKeyId(); SaveKeyringResult result; @@ -133,8 +130,6 @@ public class ProviderHelperSaveTest { result = mProviderHelper.savePublicKeyRing(key, new ProgressScaler()); Assert.assertTrue("import of keyring should succeed", result.success()); - // make sure both the CanonicalizedSecretKeyRing as well as the CachedPublicKeyRing correctly - // indicate the secret key type CanonicalizedPublicKeyRing ring = mProviderHelper.getCanonicalizedPublicKeyRing(keyId); boolean found = false; byte[] badUserId = Hex.decode("436c61757320467261656e6b656c203c436c6175732e4672e46e6b656c4068616c696661782e727774682d61616368656e2e64653e"); diff --git a/settings.gradle b/settings.gradle index 997dcc838..3e232d229 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,5 +14,4 @@ include ':extern:minidns' include ':extern:KeybaseLib:Lib' include ':extern:TokenAutoComplete:library' include ':extern:openpgp-card-nfc-lib:library' -include ':extern:safeslinger-exchange' -include ':OpenKeychain-Test' +include ':extern:safeslinger-exchange' \ No newline at end of file