diff --git a/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_armored.json b/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_armored.json new file mode 100644 index 0000000000..a81e2f9b76 --- /dev/null +++ b/FlowCrypt/src/androidTest/assets/messages/info/signed_msg_armored.json @@ -0,0 +1,46 @@ +{ + "encryptionType": "STANDARD", + "msgBlocks": [ + { + "complete": true, + "content": " \u003c!DOCTYPE html\u003e\n \u003chtml\u003e\n \u003chead\u003e\n \u003cmeta name\u003d\"viewport\" content\u003d\"width\u003ddevice-width\"/\u003e\n \u003cstyle\u003e\n body { word-wrap: break-word; word-break: break-word; hyphens: auto; margin-left: 0px; padding-left: 0px; }\n body img { display: inline !important; height: auto !important; max-width: 95% !important; }\n body pre { white-space: pre-wrap !important; }\n body \u003e div.MsgBlock \u003e table { zoom: 75% } /* table layouts tend to overflow - eg emails from fb */\n \u003c/style\u003e\n \u003c/head\u003e\n \u003cbody\u003e\u003cdiv class\u003d\"MsgBlock GRAY\" style\u003d\"background: white;padding-left: 8px;min-height: 50px;padding-top: 4px;padding-bottom: 4px;width: 100%;border: 1px solid #f0f0f0;border-left: 8px solid #989898;border-right: none;\"\u003e\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003eSigned text for default@flowcrypt.test\u003cbr\u003e\u003c/body\u003e\u003c/html\u003e\u003c/div\u003e\u003c!-- next MsgBlock --\u003e\n\u003c/body\u003e\n \u003c/html\u003e", + "type": "plainHtml" + } + ], + "msgEntity": { + "cc": [], + "email": "default@flowcrypt.test", + "flags": "\\SEEN", + "folder": "INBOX", + "from": [ + { + "address": "default@flowcrypt.test" + } + ], + "fromAddress": "default@flowcrypt.test", + "hasAttachments": false, + "id": 70, + "isNew": false, + "isSeen": true, + "msgState": "NONE", + "receivedDate": 1633967967000, + "replyTo": "default@flowcrypt.test", + "replyToAddress": [ + { + "address": "default@flowcrypt.test" + } + ], + "sentDate": 1633967964000, + "state": -1, + "subject": "SIGNED message. \"gpg --sign --armor\"", + "to": [ + { + "address": "default@flowcrypt.test" + } + ], + "toAddress": "default@flowcrypt.test", + "uid": 26, + "uidAsHEX": "1a" + }, + "text": "Signed text for default@flowcrypt.test" +} diff --git a/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_armored.txt b/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_armored.txt new file mode 100644 index 0000000000..93c6500434 --- /dev/null +++ b/FlowCrypt/src/androidTest/assets/messages/mime/signed_msg_armored.txt @@ -0,0 +1,33 @@ +Return-Path: +Delivered-To: default@flowcrypt.test +Received: from mail.flowcrypt.test + by mail.flowcrypt.test with LMTP + id 4eX1NV9fZGEKBQAAc/RpdQ + (envelope-from ) + for ; Mon, 11 Oct 2021 15:59:27 +0000 +Received: from localhost (localhost [127.0.0.1]) + by mail.flowcrypt.test (Postfix) with ESMTP id D93A51C2074 + for ; Mon, 11 Oct 2021 15:59:27 +0000 (UTC) +Date: Mon, 11 Oct 2021 18:59:24 +0300 (GMT+03:00) +From: default@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <163818563.5.1633967964807@flowcrypt.test> +Subject: SIGNED message. "gpg --sign --armor" +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_4_204938738.1633967964803" + +------=_Part_4_204938738.1633967964803 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP MESSAGE----- + +owGbwMvMwCGmFN+gfIiXM5zxtG4SQ2Iw74rgzPS81BSFktSKEoW0/CKFlNS0xNKc +Eoe0nPzy5KLKghK9ktTiEq6OXhYGMQ4GUzFFFtvXL7+VX9252+LpIheYcaxMQLMO +iMtg183AxSkAUynizshwbBMnx4e4tn6NgJYtG/od3HL1y26GvpgqUtr2o37HpC+v +GRmudmly/g+Osdt3t6Rb+8t8i8Y94ZJ3P/zNlk015FihXM0JAA== +=A8uF +-----END PGP MESSAGE----- + +------=_Part_4_204938738.1633967964803-- diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt index 43bc70e63e..2dbbc90e0a 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/activity/MessageDetailsActivityTest.kt @@ -568,6 +568,15 @@ class MessageDetailsActivityTest : BaseMessageDetailsActivityTest() { matchReplyButtons(details) } + @Test + fun testSignedArmoredMsg() { + val msgInfo = getMsgInfo( + "messages/info/signed_msg_armored.json", + "messages/mime/signed_msg_armored.txt" + ) + baseCheck(msgInfo) + } + private fun testMissingKey(incomingMsgInfo: IncomingMessageInfo?) { assertThat(incomingMsgInfo, notNullValue()) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt index 1c4308b52f..eec2a07ee8 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/security/pgp/PgpDecrypt.kt @@ -82,8 +82,10 @@ object PgpDecrypt { ) decryptionStream.use { it.copyTo(outStream) } - return DecryptionResult.withDecrypted( + return DecryptionResult( content = destOutputStream, + isEncrypted = decryptionStream.result.isEncrypted, + isSigned = decryptionStream.result.isSigned, filename = decryptionStream.result.fileName ) } catch (e: Exception) { @@ -171,6 +173,8 @@ object PgpDecrypt { // also false when error happens. val isEncrypted: Boolean = false, + val isSigned: Boolean = false, + // pgp messages may include original filename in them val filename: String? = null, @@ -184,10 +188,6 @@ object PgpDecrypt { fun withError(exception: DecryptionException): DecryptionResult { return DecryptionResult(exception = exception) } - - fun withDecrypted(content: ByteArrayOutputStream, filename: String?): DecryptionResult { - return DecryptionResult(content = content, isEncrypted = true, filename = filename) - } } } diff --git a/docker-mailserver/docker-compose.yml b/docker-mailserver/docker-compose.yml index 5c81843000..cba6d4c63d 100644 --- a/docker-mailserver/docker-compose.yml +++ b/docker-mailserver/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: mail: - image: flowcrypt/flowcrypt-email-server:0.0.10 + image: flowcrypt/flowcrypt-email-server:0.0.11 hostname: ${HOSTNAME} domainname: ${DOMAINNAME} container_name: ${CONTAINER_NAME} diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index new file mode 100644 index 0000000000..0d21b5eed1 Binary files /dev/null and b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log index 2f30af6e94..b42552513a 100644 Binary files a/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log and b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log.2 b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log.2 new file mode 100644 index 0000000000..3f2eec0089 Binary files /dev/null and b/docker-mailserver/maildata_source/flowcrypt.test/default/dovecot.list.index.log.2 differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.cache b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.cache index 2bf317b31f..042d8c0801 100644 Binary files a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.cache and b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.cache differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.log index 44f1f7a6c0..c6d3ba6d39 100644 Binary files a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.log and b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/dovecot.index.log differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.26 b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.26 new file mode 100644 index 0000000000..97c4466402 --- /dev/null +++ b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/INBOX/dbox-Mails/u.26 @@ -0,0 +1,41 @@ +2 M1e C61645f5f +N 00000000000004CB +Return-Path: +Delivered-To: default@flowcrypt.test +Received: from mail.flowcrypt.test + by mail.flowcrypt.test with LMTP + id 4eX1NV9fZGEKBQAAc/RpdQ + (envelope-from ) + for ; Mon, 11 Oct 2021 15:59:27 +0000 +Received: from localhost (localhost [127.0.0.1]) + by mail.flowcrypt.test (Postfix) with ESMTP id D93A51C2074 + for ; Mon, 11 Oct 2021 15:59:27 +0000 (UTC) +Date: Mon, 11 Oct 2021 18:59:24 +0300 (GMT+03:00) +From: default@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <163818563.5.1633967964807@flowcrypt.test> +Subject: SIGNED message. "gpg --sign --armor" +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_4_204938738.1633967964803" + +------=_Part_4_204938738.1633967964803 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP MESSAGE----- + +owGbwMvMwCGmFN+gfIiXM5zxtG4SQ2Iw74rgzPS81BSFktSKEoW0/CKFlNS0xNKc +Eoe0nPzy5KLKghK9ktTiEq6OXhYGMQ4GUzFFFtvXL7+VX9252+LpIheYcaxMQLMO +iMtg183AxSkAUynizshwbBMnx4e4tn6NgJYtG/od3HL1y26GvpgqUtr2o37HpC+v +GRmudmly/g+Osdt3t6Rb+8t8i8Y94ZJ3P/zNlk015FihXM0JAA== +=A8uF +-----END PGP MESSAGE----- + +------=_Part_4_204938738.1633967964803-- + + +R61645f5f +V4ec +Ga19408365f5f64610a05000073f46975 + diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.cache b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.cache new file mode 100644 index 0000000000..9dd608bea1 Binary files /dev/null and b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.cache differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.log index b46203ec4a..429a1d84b0 100644 Binary files a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.log and b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/dovecot.index.log differ diff --git a/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/u.1 b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/u.1 new file mode 100644 index 0000000000..3151729eab --- /dev/null +++ b/docker-mailserver/maildata_source/flowcrypt.test/default/mailboxes/Sent/dbox-Mails/u.1 @@ -0,0 +1,32 @@ +2 M1e C61645f5f +N 000000000000033D +Date: Mon, 11 Oct 2021 18:59:24 +0300 (GMT+03:00) +From: default@flowcrypt.test +To: default@flowcrypt.test +Message-ID: <163818563.5.1633967964807@flowcrypt.test> +Subject: SIGNED message. "gpg --sign --armor" +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_4_204938738.1633967964803" +User-Agent: FlowCrypt_Android_1.2.3_dev_123__2021_10_11 + +------=_Part_4_204938738.1633967964803 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP MESSAGE----- + +owGbwMvMwCGmFN+gfIiXM5zxtG4SQ2Iw74rgzPS81BSFktSKEoW0/CKFlNS0xNKc +Eoe0nPzy5KLKghK9ktTiEq6OXhYGMQ4GUzFFFtvXL7+VX9252+LpIheYcaxMQLMO +iMtg183AxSkAUynizshwbBMnx4e4tn6NgJYtG/od3HL1y26GvpgqUtr2o37HpC+v +GRmudmly/g+Osdt3t6Rb+8t8i8Y94ZJ3P/zNlk015FihXM0JAA== +=A8uF +-----END PGP MESSAGE----- + +------=_Part_4_204938738.1633967964803-- + + +R61645f5c +V355 +Ge010cd325f5f6461f204000073f46975 + diff --git a/docker-mailserver/maildata_source/flowcrypt.test/has_msgs_no_backups/mailboxes/INBOX/dbox-Mails/dovecot.index.log b/docker-mailserver/maildata_source/flowcrypt.test/has_msgs_no_backups/mailboxes/INBOX/dbox-Mails/dovecot.index.log index c2cb7fafd3..eecf140e3a 100644 Binary files a/docker-mailserver/maildata_source/flowcrypt.test/has_msgs_no_backups/mailboxes/INBOX/dbox-Mails/dovecot.index.log and b/docker-mailserver/maildata_source/flowcrypt.test/has_msgs_no_backups/mailboxes/INBOX/dbox-Mails/dovecot.index.log differ