autocrypt operations class

This commit is contained in:
Vincent Breitmoser 2017-04-18 17:09:26 +02:00
parent 6acc2a17bb
commit 42bd8683dd
11 changed files with 543 additions and 1 deletions

View file

@ -4,7 +4,9 @@ package com.fsck.k9.mail.internet;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
import android.support.annotation.NonNull;
@ -15,7 +17,6 @@ import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import org.apache.james.mime4j.codec.Base64InputStream;
import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
import org.apache.james.mime4j.util.MimeUtil;
@ -953,6 +954,23 @@ public class MimeUtility {
return null;
}
public static Map<String,String> getAllHeaderParameters(String headerValue) {
Map<String,String> result = new HashMap<>();
headerValue = headerValue.replaceAll("\r|\n", "");
String[] parts = headerValue.split(";");
for (String part : parts) {
String[] partParts = part.split("=", 2);
if (partParts.length == 2) {
String parameterName = partParts[0].trim().toLowerCase(Locale.US);
String parameterValue = partParts[1].trim();
result.put(parameterName, parameterValue);
}
}
return result;
}
public static Part findFirstPartByMimeType(Part part, String mimeType) {
if (part.getBody() instanceof Multipart) {
Multipart multipart = (Multipart)part.getBody();

View file

@ -0,0 +1,145 @@
package com.fsck.k9.crypto;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.internet.MimeUtility;
import okio.ByteString;
import org.openintents.openpgp.AutocryptPeerUpdate;
import org.openintents.openpgp.util.OpenPgpApi;
import timber.log.Timber;
public class AutocryptOperations {
private static final String AUTOCRYPT_PARAM_KEY_DATA = "key";
private static final String AUTOCRYPT_PARAM_TO = "to";
private static final String AUTOCRYPT_HEADER = "Autocrypt";
private static final String AUTOCRYPT_PARAM_TYPE = "type";
public AutocryptOperations() {
}
private boolean addAutocryptPeerUpdateToIntentIfPresent(MimeMessage currentMessage, Intent intent) {
AutocryptHeader autocryptHeader = getValidAutocryptHeader(currentMessage);
if (autocryptHeader == null) {
return false;
}
String messageFromAddress = currentMessage.getFrom()[0].getAddress();
if (!autocryptHeader.to.equalsIgnoreCase(messageFromAddress)) {
return false;
}
Date messageDate = currentMessage.getSentDate();
Date internalDate = currentMessage.getInternalDate();
Date effectiveDate = messageDate.before(internalDate) ? messageDate : internalDate;
AutocryptPeerUpdate data = AutocryptPeerUpdate.createAutocryptPeerUpdate(autocryptHeader.keyData, effectiveDate);
intent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, messageFromAddress);
intent.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_UPDATE, data);
return true;
}
public void processCleartextMessage(OpenPgpApi openPgpApi, MimeMessage currentMessage) {
Intent intent = new Intent(OpenPgpApi.ACTION_UPDATE_AUTOCRYPT_PEER);
boolean hasInlineKeyData = addAutocryptPeerUpdateToIntentIfPresent(currentMessage, intent);
if (hasInlineKeyData) {
openPgpApi.executeApi(intent, (InputStream) null, null);
}
}
@Nullable
@VisibleForTesting
AutocryptHeader getValidAutocryptHeader(MimeMessage currentMessage) {
String[] headers = currentMessage.getHeader(AUTOCRYPT_HEADER);
ArrayList<AutocryptHeader> autocryptHeaders = parseAllAutocryptHeaders(headers);
boolean isSingleValidHeader = autocryptHeaders.size() == 1;
return isSingleValidHeader ? autocryptHeaders.get(0) : null;
}
@NonNull
private ArrayList<AutocryptHeader> parseAllAutocryptHeaders(String[] headers) {
ArrayList<AutocryptHeader> autocryptHeaders = new ArrayList<>();
for (String header : headers) {
AutocryptHeader autocryptHeader = parseAutocryptHeader(header);
if (autocryptHeader != null) {
autocryptHeaders.add(autocryptHeader);
}
}
return autocryptHeaders;
}
@Nullable
private AutocryptHeader parseAutocryptHeader(String headerValue) {
Map<String,String> parameters = MimeUtility.getAllHeaderParameters(headerValue);
String type = parameters.remove(AUTOCRYPT_PARAM_TYPE);
if (type != null && !type.equals("p")) {
Timber.e("autocrypt: unsupported type parameter %s", type);
return null;
}
String base64KeyData = parameters.remove(AUTOCRYPT_PARAM_KEY_DATA);
if (base64KeyData == null) {
Timber.e("autocrypt: missing key parameter");
return null;
}
ByteString byteString = ByteString.decodeBase64(base64KeyData);
if (byteString == null) {
Timber.e("autocrypt: error parsing base64 data");
return null;
}
String to = parameters.remove(AUTOCRYPT_PARAM_TO);
if (to == null) {
Timber.e("autocrypt: no to header!");
return null;
}
if (hasCriticalParameters(parameters)) {
return null;
}
return new AutocryptHeader(parameters, to, byteString.toByteArray());
}
private boolean hasCriticalParameters(Map<String, String> parameters) {
for (String parameterName : parameters.keySet()) {
if (parameterName != null && !parameterName.startsWith("_")) {
return true;
}
}
return false;
}
public boolean hasAutocryptHeader(MimeMessage currentMessage) {
return currentMessage.getHeader(AUTOCRYPT_HEADER).length > 0;
}
@VisibleForTesting
class AutocryptHeader {
final byte[] keyData;
final String to;
final Map<String,String> parameters;
private AutocryptHeader(Map<String, String> parameters, String to, byte[] keyData) {
this.parameters = parameters;
this.to = to;
this.keyData = keyData;
}
}
}

View file

@ -0,0 +1,118 @@
package com.fsck.k9.crypto;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import com.fsck.k9.crypto.AutocryptOperations.AutocryptHeader;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.internet.BinaryTempFileBody;
import com.fsck.k9.mail.internet.MimeMessage;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
public class AutocryptOperationsTest {
AutocryptOperations autocryptOperations = new AutocryptOperations();
@Before
public void setUp() throws Exception {
BinaryTempFileBody.setTempDirectory(RuntimeEnvironment.application.getCacheDir());
}
// Test cases taken from: https://github.com/mailencrypt/autocrypt/tree/master/src/tests/data
@Test
public void getValidAutocryptHeader__withNoHeader__shouldReturnNull() throws Exception {
MimeMessage message = parseFromResource("autocrypt/no_autocrypt.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNull(autocryptHeader);
}
@Test
public void getValidAutocryptHeader__withBrokenBase64__shouldReturnNull() throws Exception {
MimeMessage message = parseFromResource("autocrypt/rsa2048-broken-base64.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNull(autocryptHeader);
}
@Test
public void getValidAutocryptHeader__withSimpleAutocrypt() throws Exception {
MimeMessage message = parseFromResource("autocrypt/rsa2048-simple.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNotNull(autocryptHeader);
assertEquals("alice@testsuite.autocrypt.org", autocryptHeader.to);
assertEquals(0, autocryptHeader.parameters.size());
assertEquals(1225, autocryptHeader.keyData.length);
}
@Test
public void getValidAutocryptHeader__withExplicitType() throws Exception {
MimeMessage message = parseFromResource("autocrypt/rsa2048-explicit-type.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNotNull(autocryptHeader);
assertEquals("alice@testsuite.autocrypt.org", autocryptHeader.to);
assertEquals(0, autocryptHeader.parameters.size());
}
@Test
public void getValidAutocryptHeader__withUnknownType__shouldReturnNull() throws Exception {
MimeMessage message = parseFromResource("autocrypt/unknown-type.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNull(autocryptHeader);
}
@Test
public void getValidAutocryptHeader__withUnknownCriticalHeader__shouldReturnNull() throws Exception {
MimeMessage message = parseFromResource("autocrypt/rsa2048-unknown-critical.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNull(autocryptHeader);
}
@Test
public void getValidAutocryptHeader__withUnknownNonCriticalHeader() throws Exception {
MimeMessage message = parseFromResource("autocrypt/rsa2048-unknown-non-critical.eml");
AutocryptHeader autocryptHeader = autocryptOperations.getValidAutocryptHeader(message);
assertNotNull(autocryptHeader);
assertEquals("alice@testsuite.autocrypt.org", autocryptHeader.to);
assertEquals(1, autocryptHeader.parameters.size());
assertEquals("ignore", autocryptHeader.parameters.get("_monkey"));
}
private MimeMessage parseFromResource(String resourceName) throws IOException, MessagingException {
InputStream inputStream = readFromResourceFile(resourceName);
return MimeMessage.parseMimeMessage(inputStream, false);
}
private InputStream readFromResourceFile(String name) throws FileNotFoundException {
return new FileInputStream(RuntimeEnvironment.application.getPackageResourcePath() + "/src/test/resources/" + name);
}
}

View file

@ -0,0 +1,11 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Bob <bob@testsuite.autocrypt.org>
Subject: INBOME with invalid type attribute
Date: Sat, 17 Dec 2016 10:51:48 +0100
Message-ID: <unknown-type@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This message contains no INBOME header
An agent capable of INBOME level 0 should not try to parse it as a header and crash.

View file

@ -0,0 +1,35 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Bob <bob@testsuite.autocrypt.org>
Subject: an INBOME RSA test
INBOME: to=alice@testsuite.autocrypt.org; key=
m!@#$%hVF+ABCADu17FBUgA3mCemeKbNaBTyWe3VGxjbu7fUyHgdLK7i3tnd7IRtxQy/AEN2t6Vq
0/xeZEAKYRInsHI/HjvmhqPeWFzipk71jRQ02WUY1pZytFjYNIrTdMk4eLYdC1N0go83PU33V4R8
fc2fWHD8N5JPsDH2xOB6WNWkMPxgMbtGIa0QTx7TINhDif4/1/VcrX3wz1gZ6xYI+sujbC54iBZo
qbEfu4SFVvp53d+a1plxBzuZ/X6nqJqcysiS7ORMieBvU6W/mVeiAxwN4qcAI5s+rGmRnP8ltONK
/P1ScH6lmELgqm8Z/M0wdiYgywme/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ASastuFDFkGANLmGZVGQQ2iTYFG1aejjtGb01vcaPrgE9WDueMB+Pn6/QbDc
5SWCrVWrRFZKrwbAGw35GySoFYpxXyCNsk6q6Db56plllPZjrYj7axF0yN536D1ntEVFDOdKZq8x
Tb9P/4Tq9NKRLE4+aO6qCqEOz+V1OeOvYLw58BfnzXY8rXF93D/86YLyilv6p5WGaS/cRhIzr+Xq
+qBLD/vW+dh72e8MvcduX3tXV3Vkg0mkGekdOw==
Date: Sat, 17 Dec 2016 10:07:48 +0100
Message-ID: <rsa2048-simple@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This contains an INBOME header with invalid characters in the base64 key
data.
This header should be ignored by all user agents.

View file

@ -0,0 +1,40 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Bob <bob@testsuite.autocrypt.org>
Subject: inbome rsa2048 with correct type
INBOME: to=alice@testsuite.autocrypt.org; type=p; key=
mQENBFhVF+ABCADu17FBUgA3mCemeKbNaBTyWe3VGxjbu7fUyHgdLK7i3tnd7IRtxQy/AEN2t6Vq
0/xeZEAKYRInsHI/HjvmhqPeWFzipk71jRQ02WUY1pZytFjYNIrTdMk4eLYdC1N0go83PU33V4R8
fc2fWHD8N5JPsDH2xOB6WNWkMPxgMbtGIa0QTx7TINhDif4/1/VcrX3wz1gZ6xYI+sujbC54iBZo
qbEfu4SFVvp53d+a1plxBzuZ/X6nqJqcysiS7ORMieBvU6W/mVeiAxwN4qcAI5s+rGmRnP8ltONK
/P1ScH6lmELgqm8Z/M0wdiYgywme/bdEQOg3s0S/8nCIFmwUchN7ABEBAAG0HWFsaWNlQHRlc3Rz
dWl0ZS5hdXRvY3J5cHQub3JniQFOBBMBCAA4FiEEfi47NkGai9tG9hBruvxTPNmTvX8FAlhVF+AC
GwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQuvxTPNmTvX/k4wf+JJZ0M0rZeAXbnxdR6HDU
ZYL734Z8x/HRpz3vzK4VQQJ4oIbUQPwydZmAlTlgl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w==
Date: Sat, 17 Dec 2016 10:49:02 +0100
Message-ID: <rsa2048-explicit-type@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This message contains the standard INBOME header, but includes an
explicit "type=p" attribute. This is the default value of type, so it
should not be necessary to include this attribute.
"p" signifies that the key value is a specialized subset of OpenPGP.
This should be accepted by any agent capable of INBOME level 0.
--dkg

View file

@ -0,0 +1,34 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Autocrypt-Bot <bot@autocrypt.org>
Subject: an INBOME RSA test
INBOME: to=alice@testsuite.autocrypt.org; key=
mQENBFhVF+ABCADu17FBUgA3mCemeKbNaBTyWe3VGxjbu7fUyHgdLK7i3tnd7IRtxQy/AEN2t6Vq
0/xeZEAKYRInsHI/HjvmhqPeWFzipk71jRQ02WUY1pZytFjYNIrTdMk4eLYdC1N0go83PU33V4R8
fc2fWHD8N5JPsDH2xOB6WNWkMPxgMbtGIa0QTx7TINhDif4/1/VcrX3wz1gZ6xYI+sujbC54iBZo
qbEfu4SFVvp53d+a1plxBzuZ/X6nqJqcysiS7ORMieBvU6W/mVeiAxwN4qcAI5s+rGmRnP8ltONK
/P1ScH6lmELgqm8Z/M0wdiYgywme/bdEQOg3s0S/8nCIFmwUchN7ABEBAAG0HWFsaWNlQHRlc3Rz
dWl0ZS5hdXRvY3J5cHQub3JniQFOBBMBCAA4FiEEfi47NkGai9tG9hBruvxTPNmTvX8FAlhVF+AC
GwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQuvxTPNmTvX/k4wf+JJZ0M0rZeAXbnxdR6HDU
ZYL734Z8x/HRpz3vzK4VQQJ4oIbUQPwydZmAlTlglQY48IWWOdJnYvn2pIhlTM/T8q9ZfmOyp6i1
jxFCPT+2ma4DjNOqYFhfnULE/MYc6xeVaBcwGj7yvAW7YY7156/wDo6+9TCd/a9mzOFCGS0yQoRa
K3uDajA+G/SmbC8t/3X8+5sapvi9Ru0HNkIzaj1jhH+kW6628E7nkf9aN9LodXHfs1UtfuLqM8VG
Ysk9474x9QxbsrJ4YvXeFwM9zAs+Pvj4lnpH/0WOU8jJc3uarluGH58kTHM5/5+p0TeMpOHX7OEw
JndsBOV9gFc6FMx4hLkBDQRYVRfiAQgA3ad+Aat4UY8xvQQutLYb8e417XZN1zVmKypyReB0l0Zf
HA6Qc7uxnJQ7dzIEZAxdnjvTYJaCFrOCBXAyPHpShVMpKqQP+kBBY/WiC3BSUALR3xqp7k5/sjLD
+K4dAacXEc7nyXP5o5+oqBXEH8Ls5X440c9A3EdsvVlncvSW5ILLItlFHmQd6f1ynnjK+FQwYJRJ
ypDuqJpYkA1vn7+XxeQShpX105rM3C8tJUxRAP3QFimenn4Zm2BDhQpCneuBt239rkXOAXsR0PnJ
fV8eNAEsE8IIqnPoSlBme5DZAri69+joYmTeSKGuj4aoxzDlx1AQigwpMISLciTXLnJypwARAQAB
iQE2BBgBCAAgFiEEfi47NkGai9tG9hBruvxTPNmTvX8FAlhVF+ICGwwACgkQuvxTPNmTvX8dOwf9
H72BGoYJkuuFrbQ6F/mH7gG9z3ytQHRD2Z0ja+3O7YnJBpotHFFjF7yHGj0FtmQR0Q7KnhkJ/3mv
fkvuaH3Gcjli/E7VASastuFDFkGANLmGZVGQQ2iTYFG1aejjtGb01vcaPrgE9WDueMB+Pn6/QbDc
5SWCrVWrRFZKrwbAGw35GySoFYpxXyCNsk6q6Db56plllPZjrYj7axF0yN536D1ntEVFDOdKZq8x
Tb9P/4Tq9NKRLE4+aO6qCqEOz+V1OeOvYLw58BfnzXY8rXF93D/86YLyilv6p5WGaS/cRhIzr+Xq
+qBLD/vW+dh72e8MvcduX3tXV3Vkg0mkGekdOw==
Date: Sat, 17 Dec 2016 10:07:48 +0100
Message-ID: <rsa2048-simple-to-bot@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This contains a default, minimal INBOME header using an RSA 2048 key.
This should be importable and valid by any agent supporting INBOME level 0.

View file

@ -0,0 +1,34 @@
From: Alice <alice@testsuite.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7k5/sjLD
+K4dAacXEc7nyXP5o5+oqBXEH8Ls5X440c9A3EdsvVlncvSW5ILLItlFHmQd6f1ynnjK+FQwYJRJ
ypDuqJpYkA1vn7+XxeQShpX105rM3C8tJUxRAP3QFimenn4Zm2BDhQpCneuBt239rkXOAXsR0PnJ
fV8eNAEsE8IIqnPoSlBme5DZAri69+joYmTeSKGuj4aoxzDlx1AQigwpMISLciTXLnJypwARAQAB
iQE2BBgBCAAgFiEEfi47NkGai9tG9hBruvxTPNmTvX8FAlhVF+ICGwwACgkQuvxTPNmTvX8dOwf9
H72BGoYJkuuFrbQ6F/mH7gG9z3ytQHRD2Z0ja+3O7YnJBpotHFFjF7yHGj0FtmQR0Q7KnhkJ/3mv
fkvuaH3Gcjli/E7VASastuFDFkGANLmGZVGQQ2iTYFG1aejjtGb01vcaPrgE9WDueMB+Pn6/QbDc
5SWCrVWrRFZKrwbAGw35GySoFYpxXyCNsk6q6Db56plllPZjrYj7axF0yN536D1ntEVFDOdKZq8x
Tb9P/4Tq9NKRLE4+aO6qCqEOz+V1OeOvYLw58BfnzXY8rXF93D/86YLyilv6p5WGaS/cRhIzr+Xq
+qBLD/vW+dh72e8MvcduX3tXV3Vkg0mkGekdOw==
Date: Sat, 17 Dec 2016 10:07:48 +0100
Message-ID: <rsa2048-simple@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This contains a default, minimal INBOME header using an RSA 2048 key.
This should be importable and valid by any agent supporting INBOME level 0.

View file

@ -0,0 +1,35 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Bob <bob@testsuite.autocrypt.org>
Subject: another inbome with rsa2048 but with an unknown critical attribute
INBOME: to=alice@testsuite.autocrypt.org; danger=do-not-use; key=
mQENBFhVGA8BCADK+qTRkAfax0LtJ6RiyxzuAFyIohBTwvtcOM2sd/tRmWq1eyNif5AGDnc1+b6X
zJ6l3BXiYM/8qXU/F04UA5BP05SgIqXjqT5I13blrydjKtUbZFchK7lJU7cyDbar+TH70DZURS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AQAB
iQE2BBgBCAAgFiEE0uuMX0KSMgVBfC/25MZusLe5gWMFAlhVGBECGwwACgkQ5MZusLe5gWOn/Qf/
aeV7CqZW/YN4/LhXjJG7i+iDJYv/9Lr12dvgjO/sOlmDPHkEzXPMLKalm0biMPN7E1woQzcKt7Qy
eF/CRcVKK1TM6wdClOj2jErnWyx85/uZfnG9QRD41rhInk891A8LGebPZ6DJeJR/uwzMniEgNnKN
AMuGy95ckwlM3AfwzsKPTUUFnBAmSwWfMLRxjZPNefeo1Ic8mMRAT3d5sfDUx/4wm8tyiNLuOSkm
Ej6ONYpESD2sJGMo3ZY96pkzir7ZH++4mH6PwZg1ZT2nO+0PtaB9DHRGfBrzH85d4aLFZD9txx3p
ewabrNpYI/cJu9hUTaTM7wZaG5kmfStwihKYUg==
Date: Sat, 17 Dec 2016 10:32:49 +0100
Message-ID: <rsa2048-unknown-critical@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This message contains an INBOME header with RSA 2048, but with an
unknown critical attribute. Agents that are compatible with INBOME
level 0 should ignore this header because of the unknown critical
attribute.

View file

@ -0,0 +1,36 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Bob <bob@testsuite.autocrypt.org>
Subject: inbome: rsa 2048 with unknown non-critical attribute
INBOME: to=alice@testsuite.autocrypt.org; _monkey=ignore; key=
mQENBFhVF+ABCADu17FBUgA3mCemeKbNaBTyWe3VGxjbu7fUyHgdLK7i3tnd7IRtxQy/AEN2t6Vq
0/xeZEAKYRInsHI/HjvmhqPeWFzipk71jRQ02WUY1pZytFjYNIrTdMk4eLYdC1N0go83PU33V4R8
fc2fWHD8N5JPsDH2xOB6WNWkMPxgMbtGIa0QTx7TINhDif4/1/VcrX3wz1gZ6xYI+sujbC54iBZo
qbEfu4SFVvp53d+a1plxBzuZ/X6nqJqcysiS7ORMieBvU6W/mVeiAxwN4qcAI5s+rGmRnP8ltONK
/P1ScH6lmELgqm8Z/M0wdiYgywme/bdEQOg3s0S/8nCIF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Q2iTYFG1aejjtGb01vcaPrgE9WDueMB+Pn6/QbDc
5SWCrVWrRFZKrwbAGw35GySoFYpxXyCNsk6q6Db56plllPZjrYj7axF0yN536D1ntEVFDOdKZq8x
Tb9P/4Tq9NKRLE4+aO6qCqEOz+V1OeOvYLw58BfnzXY8rXF93D/86YLyilv6p5WGaS/cRhIzr+Xq
+qBLD/vW+dh72e8MvcduX3tXV3Vkg0mkGekdOw==
Date: Sat, 17 Dec 2016 10:34:30 +0100
Message-ID: <rsa2048-unknown-non-critical@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This message contains an INBOME header with RSA 2048, but with an
unknown non-critical attribute. Agents that are compatible with
INBOME level 0 should accept this header while ignoring the unknown
attribute.

View file

@ -0,0 +1,36 @@
From: Alice <alice@testsuite.autocrypt.org>
To: Bob <bob@testsuite.autocrypt.org>
Subject: INBOME with invalid type attribute
INBOME: to=alice@testsuite.autocrypt.org; type=x; key=
mQENBFhVGA8BCADK+qTRkAfax0LtJ6RiyxzuAFyIohBTwvtcOM2sd/tRmWq1eyNif5AGDnc1+b6X
zJ6l3BXiYM/8qXU/F04UA5BP05SgIqXjqT5I13blrydjKtUbZFchK7lJU7cyDbar+TH70DZURSQm
MusCj0+fdx6hx8y4LSOM68rjwVeq7JXAPU78QQsYgMrbtkf5mZWUquDdb7tEoxU+PcNifvtvuHF2
ILv09a4Fi8thJG4i/3LxMFtmMLIiZWLfk5KpXAKrOy436e1LCm3vesALcihPNppb803dgBqpvvEE
9W7sg5NUy3P8+fTEuvI8HYYd+lEvYe2ojm4HVTts4YFHmzaGVzHLABEBAAG0HVRoaXMgc2hvdWxk
IG5ldmVyIGJlIGltcG9ydGVkiQFOBBMBCAA4FiEE0uuMX0KSMgVBfC/25MZusLe5gWMFAlhVGA8C
GwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQ5MZusLe5gWN9Hwf+PpLCCV7TiGc1nqIxLMTs
O84PVLSQZB642/QhLoMYXQ5iqty5H2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wZaG5kmfStwihKYUg==
Date: Sat, 17 Dec 2016 10:51:48 +0100
Message-ID: <unknown-type@testsuite.autocrypt.org>
MIME-Version: 1.0
Content-Type: text/plain
This message contains an INBOME header that claims to be of type "x",
which is not a specified type.
An agent capable of INBOME level 0 should reject this inbome header
because of this type. (it should not try to parse it as a header).