Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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\u003eSome important text that is signed\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": "denbond7@flowcrypt.test"
}
],
"fromAddress": "denbond7@flowcrypt.test",
"hasAttachments": false,
"id": 327,
"isEncrypted": false,
"isNew": false,
"isSeen": true,
"msgState": "NONE",
"receivedDate": 1634138754000,
"replyTo": "denbond7@flowcrypt.test",
"replyToAddress": [
{
"address": "denbond7@flowcrypt.test"
}
],
"sentDate": 1634138751000,
"subject": "SIGNED_MESSAGE. --clearsign",
"to": [
{
"address": "default@flowcrypt.test"
}
],
"toAddress": "default@flowcrypt.test",
"uid": 28,
"uidAsHEX": "1c"
},
"text": "Some important text that is signed"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"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\u003c/body\u003e\n\u003c/html\u003e",
"type": "plainHtml"
},
{
"complete": true,
"content": "-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: SHA512\r\n\r\nSome important text that is signed\r\n-----BEGIN PGP SIGNATURE-----\r\nVersion: PGPainless\r\n\r\niHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW\r\nVMWbrRaCiEghT5b3tpYn6jzVDenjxwg\u003d\r\n\u003dvdIK\r\n-----END PGP SIGNATURE-----",
"error": {
"errorMsg": "[IOException]: crc check failed in armored message."
},
"signedType": "SIGNED_MSG",
"type": "signedMsg"
}
],
"msgEntity": {
"cc": [],
"email": "default@flowcrypt.test",
"flags": "\\SEEN",
"folder": "INBOX",
"from": [
{
"address": "denbond7@flowcrypt.test"
}
],
"fromAddress": "denbond7@flowcrypt.test",
"hasAttachments": false,
"id": 326,
"isEncrypted": false,
"isNew": false,
"isSeen": true,
"msgState": "NONE",
"receivedDate": 1634138720000,
"replyTo": "denbond7@flowcrypt.test",
"replyToAddress": [
{
"address": "denbond7@flowcrypt.test"
}
],
"sentDate": 1634138717000,
"subject": "SIGNED_MESSAGE. --clearsign. Broken",
"to": [
{
"address": "default@flowcrypt.test"
}
],
"toAddress": "default@flowcrypt.test",
"uid": 27,
"uidAsHEX": "1b"
},
"text": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Return-Path: <denbond7@flowcrypt.test>
Delivered-To: default@flowcrypt.test
Received: from mail.flowcrypt.test
by mail.flowcrypt.test with LMTP
id sM02GYL6ZmG+BAAAc/RpdQ
(envelope-from <denbond7@flowcrypt.test>)
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:54 +0000
Received: from localhost (localhost [127.0.0.1])
by mail.flowcrypt.test (Postfix) with ESMTP id 6625D1C2104
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:54 +0000 (UTC)
Date: Wed, 13 Oct 2021 18:25:51 +0300 (GMT+03:00)
From: denbond7@flowcrypt.test
To: default@flowcrypt.test
Message-ID: <116269160.1.1634138751584@flowcrypt.test>
Subject: SIGNED_MESSAGE. --clearsign
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_129401711.1634138751570"

------=_Part_0_129401711.1634138751570
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Some important text that is signed
-----BEGIN PGP SIGNATURE-----
Version: PGPainless

iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW
zr6UAQCd8RYlxeawHRJui2T6tl+uKe2jeaQ08rfFaMzPQoumWgD/Q3KqJhL+6IkC
VMWbrRaCiEghT5b3tpYn6jzVDenjxwg=
=vdIK
-----END PGP SIGNATURE-----

------=_Part_0_129401711.1634138751570--
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Return-Path: <denbond7@flowcrypt.test>
Delivered-To: default@flowcrypt.test
Received: from mail.flowcrypt.test
by mail.flowcrypt.test with LMTP
id y3fSEmD6ZmG+BAAAc/RpdQ
(envelope-from <denbond7@flowcrypt.test>)
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:20 +0000
Received: from localhost (localhost [127.0.0.1])
by mail.flowcrypt.test (Postfix) with ESMTP id 49C011C2101
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:20 +0000 (UTC)
Date: Wed, 13 Oct 2021 18:25:17 +0300 (GMT+03:00)
From: denbond7@flowcrypt.test
To: default@flowcrypt.test
Message-ID: <231862942.5.1634138717382@flowcrypt.test>
Subject: SIGNED_MESSAGE. --clearsign. Broken
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_4_36792537.1634138717374"

------=_Part_4_36792537.1634138717374
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Some important text that is signed
-----BEGIN PGP SIGNATURE-----
Version: PGPainless

iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW
VMWbrRaCiEghT5b3tpYn6jzVDenjxwg=
=vdIK
-----END PGP SIGNATURE-----

------=_Part_4_36792537.1634138717374--
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.flowcrypt.email.api.email.EmailUtil
import com.flowcrypt.email.api.email.model.AttachmentInfo
import com.flowcrypt.email.api.email.model.IncomingMessageInfo
import com.flowcrypt.email.api.retrofit.response.model.DecryptErrorMsgBlock
import com.flowcrypt.email.api.retrofit.response.model.GenericMsgBlock
import com.flowcrypt.email.api.retrofit.response.model.PublicKeyMsgBlock
import com.flowcrypt.email.database.entity.MessageEntity
import com.flowcrypt.email.junit.annotations.NotReadyForCI
Expand Down Expand Up @@ -578,6 +579,40 @@ class MessageDetailsActivityTest : BaseMessageDetailsActivityTest() {
baseCheck(msgInfo)
}

@Test
fun testSignedMsgClearSign() {
val msgInfo = getMsgInfo(
"messages/info/signed_msg_clearsign.json",
"messages/mime/signed_msg_clearsign.txt"
)
baseCheck(msgInfo)
}

@Test
fun testSignedMsgClearSignBroken() {
val msgInfo = getMsgInfo(
"messages/info/signed_msg_clearsign_broken.json",
"messages/mime/signed_msg_clearsign_broken.txt"
) ?: throw NullPointerException()

assertThat(msgInfo, notNullValue())

val details = msgInfo.msgEntity

launchActivity(details)
matchHeader(msgInfo)

val block = msgInfo.msgBlocks?.get(1) as GenericMsgBlock
val errorMsg = getResString(
R.string.msg_contains_not_valid_block,
block.type.toString(),
requireNotNull(block.error?.errorMsg)
)
onView(withId(R.id.textViewErrorMessage))
.check(matches(withText(errorMsg)))
matchReplyButtons(details)
}

private fun testMissingKey(incomingMsgInfo: IncomingMessageInfo?) {
assertThat(incomingMsgInfo, notNullValue())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,11 @@ object PgpMsg {
}

block.type.isContentBlockType() || MimeUtils.isPlainImgAtt(block) -> {
contentBlocks.add(block)
if (block.error != null) {
resultBlocks.add(block)
} else {
contentBlocks.add(block)
}
}

block.type != MsgBlock.Type.PLAIN_ATT -> {
Expand Down Expand Up @@ -1012,8 +1016,12 @@ object PgpMsg {
}

msgBlock.type == MsgBlock.Type.SIGNED_MSG -> {
val cleartext = PgpSignature.extractClearText(msgBlock.content)
return msgBlock.copy(content = cleartext)
return try {
val cleartext = PgpSignature.extractClearText(msgBlock.content, false)
msgBlock.copy(content = cleartext)
} catch (e: Exception) {
msgBlock.copy(error = MsgBlockError("[" + e.javaClass.simpleName + "]: " + e.message))
}
}

else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import java.io.InputStream
* E-mail: DenBond7@gmail.com
*/
object PgpSignature {
fun extractClearText(source: String?): String? {
return extractClearText(ByteArrayInputStream(source?.toByteArray()))
fun extractClearText(source: String?, isSilent: Boolean = true): String? {
return extractClearText(ByteArrayInputStream(source?.toByteArray()), isSilent)
}

@Suppress("MemberVisibilityCanBePrivate")
fun extractClearText(srcInputStream: InputStream): String? {
fun extractClearText(srcInputStream: InputStream, isSilent: Boolean = true): String? {
srcInputStream.use { srcStream ->
return try {
val multiPassStrategy = MultiPassStrategy.keepMessageInMemory()
Expand All @@ -33,8 +33,10 @@ object PgpSignature {
)
String(multiPassStrategy.bytes)
} catch (e: Exception) {
e.printStackTrace()
null
if (isSilent) {
e.printStackTrace()
null
} else throw e
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docker-mailserver/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
mail:
image: flowcrypt/flowcrypt-email-server:0.0.11
image: flowcrypt/flowcrypt-email-server:0.0.12
hostname: ${HOSTNAME}
domainname: ${DOMAINNAME}
container_name: ${CONTAINER_NAME}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
2 M1e C6166fa60
N 00000000000004A0
Return-Path: <denbond7@flowcrypt.test>
Delivered-To: default@flowcrypt.test
Received: from mail.flowcrypt.test
by mail.flowcrypt.test with LMTP
id y3fSEmD6ZmG+BAAAc/RpdQ
(envelope-from <denbond7@flowcrypt.test>)
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:20 +0000
Received: from localhost (localhost [127.0.0.1])
by mail.flowcrypt.test (Postfix) with ESMTP id 49C011C2101
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:20 +0000 (UTC)
Date: Wed, 13 Oct 2021 18:25:17 +0300 (GMT+03:00)
From: denbond7@flowcrypt.test
To: default@flowcrypt.test
Message-ID: <231862942.5.1634138717382@flowcrypt.test>
Subject: SIGNED_MESSAGE. --clearsign. Broken
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_4_36792537.1634138717374"

------=_Part_4_36792537.1634138717374
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Some important text that is signed
-----BEGIN PGP SIGNATURE-----
Version: PGPainless

iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW
VMWbrRaCiEghT5b3tpYn6jzVDenjxwg=
=vdIK
-----END PGP SIGNATURE-----

------=_Part_4_36792537.1634138717374--


R6166fa60
V4c4
Ge19be41260fa6661be04000073f46975

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
2 M1e C6166fa82
N 00000000000004DC
Return-Path: <denbond7@flowcrypt.test>
Delivered-To: default@flowcrypt.test
Received: from mail.flowcrypt.test
by mail.flowcrypt.test with LMTP
id sM02GYL6ZmG+BAAAc/RpdQ
(envelope-from <denbond7@flowcrypt.test>)
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:54 +0000
Received: from localhost (localhost [127.0.0.1])
by mail.flowcrypt.test (Postfix) with ESMTP id 6625D1C2104
for <default@flowcrypt.test>; Wed, 13 Oct 2021 15:25:54 +0000 (UTC)
Date: Wed, 13 Oct 2021 18:25:51 +0300 (GMT+03:00)
From: denbond7@flowcrypt.test
To: default@flowcrypt.test
Message-ID: <116269160.1.1634138751584@flowcrypt.test>
Subject: SIGNED_MESSAGE. --clearsign
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_129401711.1634138751570"

------=_Part_0_129401711.1634138751570
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Some important text that is signed
-----BEGIN PGP SIGNATURE-----
Version: PGPainless

iHUEARYKAAYFAmFm9GEAIQkQwyCJzWr41s4WIQTBZCjWAcs5N4nPYdTDIInNavjW
zr6UAQCd8RYlxeawHRJui2T6tl+uKe2jeaQ08rfFaMzPQoumWgD/Q3KqJhL+6IkC
VMWbrRaCiEghT5b3tpYn6jzVDenjxwg=
=vdIK
-----END PGP SIGNATURE-----

------=_Part_0_129401711.1634138751570--


R6166fa82
V501
Ga1763e1982fa6661be04000073f46975

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading