mirror of https://github.com/M66B/FairEmail.git
Check Autocrypt peer address
This commit is contained in:
parent
7f0456ee65
commit
3d42e18764
|
@ -4380,6 +4380,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(data.getAction()))
|
OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(data.getAction()))
|
||||||
try {
|
try {
|
||||||
String peer = ((InternetAddress) message.from[0]).getAddress();
|
String peer = ((InternetAddress) message.from[0]).getAddress();
|
||||||
|
String addr = null;
|
||||||
boolean mutual = false;
|
boolean mutual = false;
|
||||||
byte[] keydata = null;
|
byte[] keydata = null;
|
||||||
|
|
||||||
|
@ -4393,6 +4394,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
Log.i("Autocrypt " + key + "=" + value);
|
Log.i("Autocrypt " + key + "=" + value);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "addr":
|
case "addr":
|
||||||
|
addr = value;
|
||||||
break;
|
break;
|
||||||
case "prefer-encrypt":
|
case "prefer-encrypt":
|
||||||
mutual = value.trim().toLowerCase().equals("mutual");
|
mutual = value.trim().toLowerCase().equals("mutual");
|
||||||
|
@ -4404,13 +4406,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addr == null)
|
||||||
|
throw new IllegalArgumentException("addr not found");
|
||||||
|
|
||||||
|
if (!addr.equalsIgnoreCase(peer))
|
||||||
|
throw new IllegalArgumentException("addr different from peer");
|
||||||
|
|
||||||
if (keydata == null)
|
if (keydata == null)
|
||||||
throw new IllegalArgumentException("keydata not found");
|
throw new IllegalArgumentException("keydata not found");
|
||||||
|
|
||||||
AutocryptPeerUpdate update = AutocryptPeerUpdate.create(
|
AutocryptPeerUpdate update = AutocryptPeerUpdate.create(
|
||||||
keydata, new Date(message.received), mutual);
|
keydata, new Date(message.received), mutual);
|
||||||
|
|
||||||
data.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, peer);
|
data.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_ID, addr);
|
||||||
data.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_UPDATE, update);
|
data.putExtra(OpenPgpApi.EXTRA_AUTOCRYPT_PEER_UPDATE, update);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.w(ex);
|
Log.w(ex);
|
||||||
|
|
Loading…
Reference in New Issue