2using System.Collections.Generic;
4using System.Reflection;
6using System.Threading.Tasks;
72 private static Dictionary<string, IE2eEndpoint> endpointTypes =
new Dictionary<string, IE2eEndpoint>();
73 private static bool initialized =
false;
74 private static Type[] e2eTypes =
null;
75 private static bool e2eTypesLocked =
false;
77 private readonly Dictionary<string, IE2eEndpoint[]> contacts;
82 private readonly UTF8Encoding encoding =
new UTF8Encoding(
false,
false);
83 private readonly
object synchObject =
new object();
84 private readonly
int securityStrength;
85 private readonly
bool ephemeralKeys;
96 : this(Client, null, SecurityStrength)
107 : this(Client, ServerlessMessaging, SecurityStrength, null)
118 : this(Client, null, SecurityStrength, LocalEndpoints)
133 this.securityStrength = SecurityStrength;
134 this.client = Client;
135 this.serverlessMessaging = ServerlessMessaging;
136 this.contacts =
new Dictionary<string, IE2eEndpoint[]>(StringComparer.CurrentCultureIgnoreCase);
138 if (!(LocalEndpoints is
null))
140 this.keys = LocalEndpoints;
141 this.ephemeralKeys =
false;
146 this.ephemeralKeys =
true;
149 if (!(this.client is
null))
153 this.client.OnStateChanged += this.Client_OnStateChanged;
154 this.client.OnPresence += this.Client_OnPresence;
155 this.client.CustomPresenceXml += this.Client_CustomPresenceXml;
162 this.serverlessMessaging?.AppendP2pInfo(e.
Stanza);
164 return Task.CompletedTask;
176 return CreateEndpoints(DesiredSecurityStrength, MinSecurityStrength, MaxSecurityStrength,
null);
188 Type OnlyIfDerivedFrom)
190 return CreateEndpoints(DesiredSecurityStrength, MinSecurityStrength, MaxSecurityStrength, OnlyIfDerivedFrom,
null);
211 List<IE2eEndpoint> Result =
new List<IE2eEndpoint>();
212 TypeInfo OnlyIfDerivedFromType = OnlyIfDerivedFrom?.GetTypeInfo();
213 IEnumerable<IE2eEndpoint> Templates;
214 bool CheckHeritance =
true;
219 Templates = endpointTypes.Values;
222 Dictionary<string, IE2eEndpoint> E2eTypes =
new Dictionary<string, IE2eEndpoint>();
223 Dictionary<string, bool> TypeNames =
new Dictionary<string, bool>();
224 TypeInfo E2eTypeInfo = typeof(
IE2eEndpoint).GetTypeInfo();
226 foreach (KeyValuePair<string, IE2eEndpoint> P
in endpointTypes)
228 E2eTypes[P.Key] = P.Value;
229 TypeNames[P.Value.GetType().FullName] =
true;
234 if (TypeNames.ContainsKey(T.FullName))
237 TypeInfo TI = T.GetTypeInfo();
238 if (!(e2eTypes is
null) && !E2eTypeInfo.IsAssignableFrom(TI))
241 if (!(OnlyIfDerivedFromType?.IsAssignableFrom(TI) ??
true))
251 E2eTypes[Endpoint.Namespace +
"#" + Endpoint.
LocalName] = Endpoint;
260 endpointTypes = E2eTypes;
261 Templates = E2eTypes.Values;
263 if (OnlyIfDerivedFromType is
null)
266 CheckHeritance =
false;
272 if (CheckHeritance && !(OnlyIfDerivedFromType?.IsAssignableFrom(Endpoint.GetType().GetTypeInfo()) ??
true))
279 if (i >= MinSecurityStrength && i <= MaxSecurityStrength)
280 Result.Add(Endpoint2);
285 return Result.ToArray();
301 throw new InvalidOperationException(
"Ciphers locked.");
303 e2eTypes = CipherTypes;
304 e2eTypesLocked = Lock;
316 if (Namespace.StartsWith(
"urn:ieee:"))
317 Namespace = Namespace.Replace(
"urn:ieee:",
"urn:nf:");
319 string Key = Namespace +
"#" + LocalName;
321 if (endpointTypes.TryGetValue(Key, out Endpoint))
323 else if (initialized || endpointTypes.Count > 0)
328 return endpointTypes.TryGetValue(Key, out Endpoint);
342 Endpoint = Endpoint.Create(Endpoint.SecurityStrength);
354 if (!(this.client is
null))
356 this.client.OnStateChanged -= this.Client_OnStateChanged;
357 this.client.OnPresence -= this.Client_OnPresence;
358 this.client.CustomPresenceXml -= this.Client_CustomPresenceXml;
364 if (!(this.oldKeys is
null))
370 if (!(this.keys is
null))
379 foreach (
IE2eEndpoint[] Endpoints
in this.contacts.Values)
385 this.contacts.Clear();
398 private Task Client_OnStateChanged(
object Sender,
XmppState NewState)
400 if (NewState ==
XmppState.RequestingSession &&
this.ephemeralKeys)
403 return Task.CompletedTask;
411 lock (this.synchObject)
415 this.oldKeys = this.keys;
423 int i, c = this.keys.Length;
426 for (i = 0; i < c; i++)
428 Keys[i] = this.keys[i].
Create(this.securityStrength);
443 #region Neuro-Foundation V1
480 #region Neuro-Foundation V1
518 List<IE2eEndpoint> Endpoints =
null;
520 foreach (XmlNode N
in E2E.ChildNodes)
522 if (N is XmlElement E)
526 if (!(Endpoint is
null))
528 if (Endpoints is
null)
529 Endpoints =
new List<IE2eEndpoint>();
531 Endpoints.Add(Endpoint);
547 return Endpoint.
Parse(E);
562 List<IE2eEndpoint> Endpoints =
null;
569 if (Endpoints is
null)
575 Endpoints.Sort((e1, e2) =>
577 int Diff = e2.SecurityStrength - e1.SecurityStrength;
581 return e1.Score - e2.Score;
585 int j, c = Endpoints.Count;
587 for (j = 1; j < c; j++)
589 if (Endpoints[j].SecurityStrength >= this.securityStrength)
596 Endpoints.RemoveAt(i);
597 Endpoints.Insert(0, Temp);
602 if (!this.contacts.TryGetValue(FullJID, out OldEndpoints))
605 this.contacts[FullJID] = Endpoints.ToArray();
608 if (!(OldEndpoints is
null))
634 if (!this.contacts.TryGetValue(FullJID, out List))
637 this.contacts.Remove(FullJID);
655 return this.contacts.ContainsKey(FullJid);
668 if (this.contacts.TryGetValue(FullJid, out
IE2eEndpoint[] Endpoints))
672 if (
string.Compare(FullJid, this.client.
BareJID) == 0)
674 StringBuilder Xml =
new StringBuilder();
678 XmlDocument Doc =
new XmlDocument()
680 PreserveWhitespace =
true
682 Doc.LoadXml(Xml.ToString());
700 public virtual Task<byte[]>
Encrypt(
string Id,
string Type,
string From,
string To,
byte[] Data, out
IE2eEndpoint EndpointReference)
702 IE2eEndpoint RemoteEndpoint = this.FindRemoteEndpoint(To,
null);
703 if (RemoteEndpoint is
null)
705 EndpointReference =
null;
709 EndpointReference = this.FindLocalEndpoint(RemoteEndpoint);
710 if (EndpointReference is
null)
713 uint Counter = EndpointReference.GetNextCounter();
714 byte[] Encrypted = EndpointReference.DefaultSymmetricCipher.Encrypt(Id, Type, From, To, Counter, Data, EndpointReference, RemoteEndpoint);
716 return Task.FromResult(Encrypted);
730 public virtual Task<byte[]>
Decrypt(
string EndpointReference,
string Id,
string Type,
string From,
string To,
byte[] Data,
733 IE2eEndpoint RemoteEndpoint = this.FindRemoteEndpoint(From, EndpointReference);
734 if (RemoteEndpoint is
null)
737 IE2eEndpoint LocalEndpoint = this.FindLocalEndpoint(RemoteEndpoint);
738 if (LocalEndpoint is
null)
742 if (!(SymmetricCipher is
null) && Cipher.GetType() != SymmetricCipher.GetType())
743 Cipher = SymmetricCipher;
745 byte[] Decrypted = Cipher.
Decrypt(Id, Type, From, To, Data, RemoteEndpoint, LocalEndpoint);
747 return Task.FromResult(Decrypted);
750 private IE2eEndpoint FindRemoteEndpoint(
string RemoteJid,
string EndpointReference)
756 if (!this.contacts.TryGetValue(RemoteJid, out Endpoints))
760 if (EndpointReference is
null)
767 i = EndpointReference.IndexOf(
'#');
770 LocalName = EndpointReference;
775 Namespace = EndpointReference.Substring(0, i).Replace(
"urn:ieee:",
"urn:nf:");
776 LocalName = EndpointReference.Substring(i + 1);
798 public virtual async Task<IE2eEndpoint>
Encrypt(
string Id,
string Type,
string From,
string To, Stream Data, Stream Encrypted)
800 IE2eEndpoint RemoteEndpoint = this.FindRemoteEndpoint(To,
null);
801 if (RemoteEndpoint is
null)
804 IE2eEndpoint LocalEndpoint = this.FindLocalEndpoint(RemoteEndpoint);
805 if (LocalEndpoint is
null)
811 return LocalEndpoint;
825 public virtual async Task<Stream>
Decrypt(
string EndpointReference,
string Id,
string Type,
string From,
string To, Stream Data,
828 IE2eEndpoint RemoteEndpoint = this.FindRemoteEndpoint(From, EndpointReference);
829 if (RemoteEndpoint is
null)
832 IE2eEndpoint LocalEndpoint = this.FindLocalEndpoint(RemoteEndpoint);
833 if (LocalEndpoint is
null)
837 if (!(SymmetricCipher is
null) && Cipher.GetType() != SymmetricCipher.GetType())
838 Cipher = SymmetricCipher;
840 return await Cipher.
Decrypt(Id, Type, From, To, Data, RemoteEndpoint, LocalEndpoint);
854 public virtual async Task<bool>
Encrypt(
XmppClient Client,
string Id,
string Type,
string From,
string To,
string DataXml, StringBuilder Xml)
856 bool SniffE2eInfo = Client.HasSniffers && Client.
TryGetTag(
"ShowE2E", out
object Obj) && Obj is
bool b && b;
857 IE2eEndpoint RemoteEndpoint = this.FindRemoteEndpoint(To,
null);
858 if (RemoteEndpoint is
null)
861 await Client.
Warning(
"Remote E2E endpoint not found. Unable to encrypt message.");
866 IE2eEndpoint LocalEndpoint = this.FindLocalEndpoint(RemoteEndpoint);
867 if (LocalEndpoint is
null)
870 await Client.
Warning(
"Local E2E endpoint matching remote endpoint not found. Unable to encrypt message.");
875 byte[] Data = this.encoding.GetBytes(DataXml);
888 int c = Endpoints.Length;
890 Type T = RemoteEndpoint.GetType();
892 for (i = 0; i < c; i++)
894 if (Endpoints[i].GetType() == T)
908 return this.FindLocalEndpoint(KeyName,
string.Empty);
920 int c = Endpoints.Length;
923 for (i = 0; i < c; i++)
925 if (Endpoints[i].LocalName == KeyName &&
926 (Endpoints[i].Namespace == KeyNamespace ||
string.IsNullOrEmpty(KeyNamespace)))
946 public virtual async Task<Tuple<string, string>>
Decrypt(
XmppClient Client,
string Id,
string Type,
string From,
string To, XmlElement E2eElement,
949 bool SniffE2eInfo = Client.HasSniffers && Client.
TryGetTag(
"ShowE2E", out
object Obj) && Obj is
bool b && b;
950 string EndpointReference =
XML.
Attribute(E2eElement,
"r");
951 IE2eEndpoint RemoteEndpoint = this.FindRemoteEndpoint(From, EndpointReference);
952 if (RemoteEndpoint is
null)
955 await Client.Error(
"Remote E2E endpoint not found. Unable to decrypt message.");
960 IE2eEndpoint LocalEndpoint = this.FindLocalEndpoint(RemoteEndpoint);
961 if (LocalEndpoint is
null)
964 await Client.Error(
"Local E2E endpoint matching remote endpoint not found. Unable to decrypt message.");
970 if (!(SymmetricCipher is
null) && Cipher.GetType() != SymmetricCipher.GetType())
971 Cipher = SymmetricCipher;
973 string Xml = Cipher.
Decrypt(Id, Type, From, To, E2eElement, RemoteEndpoint, LocalEndpoint);
977 await Client.Error(
"Unable to decrypt message.");
985 return new Tuple<string, string>(Xml, EndpointReference);
990 return this.E2eMessageHandler(Sender, e, this.aes);
995 return this.E2eMessageHandler(Sender, e, this.acp);
1000 return this.E2eMessageHandler(Sender, e, this.cha);
1009 await Client.Error(
"Unable to decrypt or verify message.");
1013 string Xml = T.Item1;
1014 string EndpointReference = T.Item2;
1016 XmlDocument Doc =
new XmlDocument()
1018 PreserveWhitespace =
true
1027 E2eEncryption =
this,
1028 E2eReference = EndpointReference
1045 case "aes": Cipher = this.aes;
return true;
1046 case "acp": Cipher = this.acp;
return true;
1047 case "cha": Cipher = this.cha;
return true;
1063 object[] P = (
object[])e.
State;
1064 EventHandlerAsync<IqResultEventArgs> Callback = (EventHandlerAsync<IqResultEventArgs>)P[0];
1065 object State = P[1];
1070 if (!(Cipher is
null))
1072 Tuple<string, string> T = await this.
Decrypt(Client, e.
Id, e.
Response.GetAttribute(
"type"), e.
From, e.
To, E, Cipher);
1075 await Client.Error(
"Unable to decrypt or verify response.");
1079 string Content = T.Item1;
1080 string EndpointReference = T.Item2;
1081 StringBuilder Xml =
new StringBuilder();
1083 Xml.Append(
"<iq xmlns=\"jabber:client\" id=\"");
1085 Xml.Append(
"\" from=\"");
1087 Xml.Append(
"\" to=\"");
1091 Xml.Append(
"\" type=\"result\">");
1093 Xml.Append(
"\" type=\"error\">");
1095 Xml.Append(Content);
1096 Xml.Append(
"</iq>");
1098 XmlDocument Doc =
new XmlDocument()
1100 PreserveWhitespace =
true
1102 Doc.LoadXml(Xml.ToString());
1105 Doc.DocumentElement, e.
Id, e.
To, e.
From, e.
Ok, State);
1106 await Callback.Raise(Sender, e2);
1111 string Id = (string)P[3];
1112 string To = (string)P[4];
1113 string Xml = (string)P[5];
1114 string Type = (string)P[6];
1115 int RetryTimeout = (int)P[7];
1116 int NrRetries = (int)P[8];
1117 bool DropOff = (bool)P[9];
1118 int MaxRetryTimeout = (int)P[10];
1119 bool PkiSynchronized = (bool)P[11];
1121 if (PkiSynchronized)
1124 await Callback.Raise(Sender, e);
1132 await this.SendIq(Client, E2ETransmission, Id, To, Xml, Type, Callback, State,
1133 RetryTimeout, NrRetries, DropOff, MaxRetryTimeout, true);
1138 await Callback.Raise(Sender, e);
1146 await Callback.Raise(Sender, e);
1150 private bool IsForbidden(XmlElement E)
1157 foreach (XmlNode N
in E.ChildNodes)
1159 E2 = N as XmlElement;
1170 private string EmbedIq(
IqEventArgs e,
string Type,
string Content)
1172 StringBuilder Xml =
new StringBuilder();
1174 Xml.Append(
"<iq xmlns=\"jabber:client\" id=\"");
1176 Xml.Append(
"\" from=\"");
1178 Xml.Append(
"\" to=\"");
1180 Xml.Append(
"\" type=\"");
1183 Xml.Append(Content);
1184 Xml.Append(
"</iq>");
1186 return Xml.ToString();
1189 private Task AesIqGetHandler(
object Sender,
IqEventArgs e)
1191 return this.E2eIqGetHandler(Sender, e, this.aes);
1194 private Task AcpIqGetHandler(
object Sender,
IqEventArgs e)
1196 return this.E2eIqGetHandler(Sender, e, this.acp);
1199 private Task ChaIqGetHandler(
object Sender,
IqEventArgs e)
1201 return this.E2eIqGetHandler(Sender, e, this.cha);
1207 Tuple<string, string> T = await this.
Decrypt(Client, e.
Id, e.
IQ.GetAttribute(
"type"), e.
From, e.
To, e.
Query, Cipher);
1210 await Client.Error(
"Unable to decrypt or verify request.");
1215 string Content = T.Item1;
1216 string EndpointReference = T.Item2;
1218 XmlDocument Doc =
new XmlDocument()
1220 PreserveWhitespace =
true
1222 Doc.LoadXml(this.EmbedIq(e,
"get", Content));
1228 private Task AesIqSetHandler(
object Sender,
IqEventArgs e)
1230 return this.E2eIqSetHandler(Sender, e, this.aes);
1233 private Task AcpIqSetHandler(
object Sender,
IqEventArgs e)
1235 return this.E2eIqSetHandler(Sender, e, this.acp);
1238 private Task ChaIqSetHandler(
object Sender,
IqEventArgs e)
1240 return this.E2eIqSetHandler(Sender, e, this.cha);
1246 Tuple<string, string> T = await this.
Decrypt(Client, e.
Id, e.
IQ.GetAttribute(
"type"), e.
From, e.
To, e.
Query, Cipher);
1249 await Client.Error(
"Unable to decrypt or verify request.");
1254 string Content = T.Item1;
1255 string EndpointReference = T.Item2;
1257 XmlDocument Doc =
new XmlDocument()
1259 PreserveWhitespace =
true
1261 Doc.LoadXml(this.EmbedIq(e,
"set", Content));
1285 MessageType Type,
string Id,
string To,
string CustomXml,
string Body,
string Subject,
1286 string Language,
string ThreadId,
string ParentThreadId, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback,
1290 Language, ThreadId, ParentThreadId, DeliveryCallback, State,
false);
1312 MessageType Type,
string Id,
string To,
string CustomXml,
string Body,
string Subject,
1313 string Language,
string ThreadId,
string ParentThreadId, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback,
1314 object State,
bool PkiSynchronized)
1316 if (this.client is
null)
1317 throw new ObjectDisposedException(
"Endpoint security object disposed.");
1319 if (
string.IsNullOrEmpty(Id))
1322 StringBuilder Xml =
new StringBuilder();
1324 Xml.Append(
"<message");
1329 Xml.Append(
" type=\"chat\"");
1333 Xml.Append(
" type=\"error\"");
1337 Xml.Append(
" type=\"groupchat\"");
1341 Xml.Append(
" type=\"headline\"");
1345 if (!
string.IsNullOrEmpty(Language))
1347 Xml.Append(
" xml:lang=\"");
1354 if (!
string.IsNullOrEmpty(Subject))
1356 Xml.Append(
"<subject>");
1358 Xml.Append(
"</subject>");
1361 Xml.Append(
"<body>");
1363 Xml.Append(
"</body>");
1365 if (!
string.IsNullOrEmpty(ThreadId))
1367 Xml.Append(
"<thread");
1369 if (!
string.IsNullOrEmpty(ParentThreadId))
1371 Xml.Append(
" parent=\"");
1378 Xml.Append(
"</thread>");
1381 if (!
string.IsNullOrEmpty(CustomXml))
1382 Xml.Append(CustomXml);
1384 Xml.Append(
"</message>");
1386 string MessageXml = Xml.ToString();
1387 StringBuilder Encrypted =
new StringBuilder();
1389 if (await this.
Encrypt(Client, Id,
string.Empty, this.client.
FullJID, To, MessageXml, Encrypted))
1391 MessageXml = Encrypted.ToString();
1394 string.Empty,
string.Empty,
string.Empty,
string.Empty, DeliveryCallback, State);
1403 if (!(Item is
null))
1409 if (await this.
Encrypt(Client, Id,
string.Empty, this.client.
FullJID, e.
From, MessageXml, Encrypted))
1412 string.Empty,
string.Empty,
string.Empty,
string.Empty, DeliveryCallback, State);
1426 if (!PkiSynchronized)
1432 await this.SendMessage(Client, E2ETransmission, QoS, Type, Id, To, CustomXml, Body, Subject,
1433 Language, ThreadId, ParentThreadId, DeliveryCallback, State, true);
1437 await Client.SendMessage(QoS, Type, Id, To, CustomXml, Body, Subject, Language,
1438 ThreadId, ParentThreadId, DeliveryCallback, State);
1440 else if (!(DeliveryCallback is
null))
1447 await Client.
SendMessage(QoS, Type, Id, To, CustomXml, Body, Subject, Language,
1448 ThreadId, ParentThreadId, DeliveryCallback, State);
1451 throw new InvalidOperationException(
"End-to-End Encryption not available between " + Client.
FullJID +
" and " + To +
".");
1465 EventHandlerAsync<IqResultEventArgs> Callback,
object State)
1484 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries)
1486 return this.
SendIq(Client,
E2ETransmission,
null, To, Xml,
"get", Callback, State, RetryTimeout, NrRetries,
false,
1487 RetryTimeout,
false);
1506 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
bool DropOff,
1507 int MaxRetryTimeout)
1510 NrRetries, DropOff, MaxRetryTimeout,
false);
1524 EventHandlerAsync<IqResultEventArgs> Callback,
object State)
1544 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries)
1547 NrRetries,
false, RetryTimeout,
false);
1566 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
bool DropOff,
1567 int MaxRetryTimeout)
1570 NrRetries, DropOff, MaxRetryTimeout,
false);
1585 EventHandlerAsync<IqResultEventArgs> Callback,
object State, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1605 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
1606 EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1608 return this.
SendIq(Client,
E2ETransmission,
null, To, Xml,
"get", Callback, State, RetryTimeout, NrRetries,
false,
1609 RetryTimeout,
false, DeliveryCallback);
1629 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
bool DropOff,
1630 int MaxRetryTimeout, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1633 NrRetries, DropOff, MaxRetryTimeout,
false, DeliveryCallback);
1648 EventHandlerAsync<IqResultEventArgs> Callback,
object State, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1669 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
1670 EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1673 NrRetries,
false, RetryTimeout,
false, DeliveryCallback);
1693 EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
bool DropOff,
1694 int MaxRetryTimeout, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1697 NrRetries, DropOff, MaxRetryTimeout,
false, DeliveryCallback);
1710 return this.
SendIq(Client,
E2ETransmission, Id, To, Xml,
"result",
null,
null, 0, 0,
false, 0,
false);
1723 return this.
SendIq(Client,
E2ETransmission, Id, To, Xml,
"error",
null,
null, 0, 0,
false, 0,
false);
1762 string Type, EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
bool DropOff,
1763 int MaxRetryTimeout,
bool PkiSynchronized)
1765 return this.
SendIq(Client,
E2ETransmission, Id, To, Xml, Type, Callback, State, RetryTimeout, NrRetries, DropOff,
1766 MaxRetryTimeout, PkiSynchronized,
null);
1792 string Type, EventHandlerAsync<IqResultEventArgs> Callback,
object State,
int RetryTimeout,
int NrRetries,
bool DropOff,
1793 int MaxRetryTimeout,
bool PkiSynchronized, EventHandlerAsync<DeliveryEventArgs> DeliveryCallback)
1795 if (this.client is
null)
1796 throw new ObjectDisposedException(
"Endpoint security object disposed.");
1798 if (
string.IsNullOrEmpty(Id))
1801 StringBuilder Encrypted =
new StringBuilder();
1803 if (await this.
Encrypt(Client, Id, Type, this.client.
FullJID, To, Xml, Encrypted))
1805 string XmlEnc = Encrypted.ToString();
1808 new object[] { Callback, State,
E2ETransmission, Id, To, Xml, Type, RetryTimeout, NrRetries, DropOff, MaxRetryTimeout, PkiSynchronized },
1809 RetryTimeout, NrRetries, DropOff, MaxRetryTimeout, DeliveryCallback);
1814 if (uint.TryParse(Id, out uint SeqNr))
1820 if (!PkiSynchronized)
1822 if (!uint.TryParse(Id, out uint SeqNr))
1825 SeqNr = uint.Parse(Id);
1832 await this.SendIq(Client, E2ETransmission, Id, To, Xml, Type, Callback, State,
1833 RetryTimeout, NrRetries, DropOff, MaxRetryTimeout, true, DeliveryCallback);
1837 await Client.SendIq(Id, To, Xml, Type, Callback, State, RetryTimeout,
1838 NrRetries, DropOff, MaxRetryTimeout, DeliveryCallback);
1842 if (!(DeliveryCallback is null))
1843 await DeliveryCallback.Raise(Sender, new DeliveryEventArgs(Sender, true));
1845 await Callback.Raise(Sender, e);
1853 return await Client.
SendIq(Id, To, Xml, Type, Callback, State, RetryTimeout,
1854 NrRetries, DropOff, MaxRetryTimeout, DeliveryCallback);
1857 throw new InvalidOperationException(
"End-to-End Encryption not available between " + Client.
FullJID +
" and " + To +
".");
1875 if (!Result.Wait(Timeout))
1876 throw new TimeoutException();
1878 return Result.Result;
1893 TaskCompletionSource<XmlElement> Result =
new TaskCompletionSource<XmlElement>();
1898 Result.TrySetResult(e.Response);
1902 return Task.CompletedTask;
1906 return await Result.Task;
1924 if (!Result.Wait(Timeout))
1925 throw new TimeoutException();
1927 return Result.Result;
1942 TaskCompletionSource<XmlElement> Result =
new TaskCompletionSource<XmlElement>();
1947 Result.TrySetResult(e.Response);
1951 return Task.CompletedTask;
1955 return await Result.Task;
1964 Xml.Append(
"<e2e xmlns=\"");
1971 Xml.Append(
"</e2e>");
1979 public Task
SynchronizeE2e(
string FullJID, EventHandlerAsync<IqResultEventArgs> Callback)
1990 public async Task
SynchronizeE2e(
string FullJID, EventHandlerAsync<IqResultEventArgs> Callback,
object State)
1992 LinkedList<SynchRec> CallbackList;
1994 lock (this.synchronizationTasks)
1996 SynchRec Rec =
new SynchRec()
1998 Callback = Callback,
2002 if (this.synchronizationTasks.TryGetValue(FullJID, out CallbackList))
2004 CallbackList.AddLast(Rec);
2008 CallbackList =
new LinkedList<SynchRec>();
2009 CallbackList.AddLast(Rec);
2011 this.synchronizationTasks[FullJID] = CallbackList;
2014 await this.client.
SendIqSet(FullJID, this.GetE2eXml(), async (Sender, e) =>
2016 lock (this.synchronizationTasks)
2018 if (!this.synchronizationTasks.TryGetValue(FullJID, out CallbackList))
2021 this.synchronizationTasks.Remove(FullJID);
2024 if (e.
Ok && !(e.FirstElement is
null))
2025 await this.ParseE2e(e.FirstElement, FullJID);
2027 foreach (SynchRec Rec
in CallbackList)
2029 e.State = Rec.State;
2030 await Rec.Callback.Raise(Sender, e);
2035 private readonly Dictionary<string, LinkedList<SynchRec>> synchronizationTasks =
new Dictionary<string, LinkedList<SynchRec>>();
2037 private class SynchRec
2039 public EventHandlerAsync<IqResultEventArgs> Callback;
2040 public object State;
2043 private string GetE2eXml()
2045 StringBuilder Xml =
new StringBuilder();
2047 Xml.Append(
"<synchE2e xmlns=\"");
2052 this.serverlessMessaging?.AppendP2pInfo(Xml);
2054 Xml.Append(
"</synchE2e>");
2056 return Xml.ToString();
2059 private async Task ParseE2e(XmlElement E,
string RemoteFullJID)
2061 XmlElement E2E =
null;
2062 XmlElement P2P =
null;
2064 if (!(E is
null) && E.LocalName ==
"synchE2e")
2066 foreach (XmlNode N
in E.ChildNodes)
2068 if (N is XmlElement E2)
2070 switch (E2.LocalName)
2087 bool HasP2P = !(this.serverlessMessaging is
null) && await this.serverlessMessaging.AddPeerAddressInfo(RemoteFullJID, P2P);
2092 private async Task SynchE2eHandler(
object Sender,
IqEventArgs e)
2097 ((Item =
this.client.GetRosterItem(e.
FromBareJid)) is
null ||
2106 await e.
IqResult(this.GetE2eXml());
2114 XmlElement E2E =
null;
2115 XmlElement P2P =
null;
2117 foreach (XmlNode N
in e.
Presence.ChildNodes)
2119 if (N is XmlElement E)
2121 switch (E.LocalName)
2137 bool HasP2P = !(this.serverlessMessaging is
null) && await this.serverlessMessaging.AddPeerAddressInfo(e.
From, P2P);
2161 public event EventHandlerAsync<PeerSynchronizedEventArgs>
PeerUpdated =
null;
2182 if (Endpoint.GetType() == KeyType)
2186 if (!typeof(
IE2eEndpoint).GetTypeInfo().IsAssignableFrom(KeyType.GetTypeInfo()))
2187 throw new ArgumentException(
"Not assignable from " + typeof(
IE2eEndpoint).FullName, nameof(KeyType));
2199 if (PublicKey is
null)
2202 string s = Convert.ToBase64String(PublicKey);
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Task Information(string Comment)
Called to inform the viewer of something.
Task Warning(string Warning)
Called to inform the viewer of a warning state.
Event arguments for delivery events.
Event Argument for custom presence XML events.
StringBuilder Stanza
Stanza being built.
Event arguments for IQ queries.
async Task IqError(string Xml)
Returns an error response to the current request.
async Task IqResult(string Xml)
Returns a response to the current request.
XmlElement Query
Query element, if found, null otherwise.
string From
From address attribute
string To
To address attribute
string Id
ID of the request.
string FromBareJid
Bare version of the "from" JID.
Event arguments for responses to IQ queries.
string Id
ID of the request.
string From
From address attribute
XmlElement ErrorElement
Error element.
bool Ok
If the response is an OK result response (true), or an error response (false).
object State
State object passed to the original request.
XmlElement Response
IQ Response element.
XmlElement FirstElement
First child element of the Response element.
string To
To address attribute
Event arguments for message events.
string Id
ID attribute of message stanza.
string From
From where the message was received.
XmlElement Message
The message stanza.
bool Ok
If the response is an OK result response (true), or an error response (false).
string To
To whom the message was sent.
XmlElement Content
Content of the message. For messages that are processed by registered message handlers,...
Event arguments for presence events.
bool Ok
If the response is an OK result response (true), or an error response (false).
XmppException StanzaError
Any stanza error returned.
string From
From where the presence was received.
XmlElement Presence
Presence element.
PresenceType Type
Type of presence received.
Event arguments for Availability events.
Abstract base class for End-to-End encryption schemes.
Class managing end-to-end encryption.
EventHandlerAsync< AvailableEventArgs > PeerAvailable
Event raised whenever a peer has become available.
Task< uint > SendIqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, bool DropOff, int MaxRetryTimeout)
Sends an IQ Set stanza
EndpointSecurity(XmppClient Client, XmppServerlessMessaging ServerlessMessaging, int SecurityStrength, params IE2eEndpoint[] LocalEndpoints)
Class managing end-to-end encryption.
Task< uint > SendIqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, bool DropOff, int MaxRetryTimeout, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ Set stanza
async Task SendIqError(XmppClient Client, E2ETransmission E2ETransmission, string Id, string To, Exception ex)
Sends an IQ Error stanza
virtual bool TryGetSymmetricCipher(string LocalName, string Namespace, out IE2eSymmetricCipher Cipher)
Tries to get a symmetric cipher from a reference.
const string IoTHarmonizationE2ENeuroFoundationV1
urn:nf:iot:e2e:1.0
IE2eEndpoint[] GetE2eEndpoints(string FullJid)
Gets available E2E options for a given endpoint.
XmlElement IqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, int Timeout)
Sends an IQ Get stanza
const string IoTHarmonizationP2PIeeeV1
urn:ieee:iot:p2p:1.0
Task< uint > SendIqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ Get stanza
static readonly string[] NamespacesIoTHarmonizationE2E
Namespaces supported for End-to-end encryption.
virtual void RegisterHandlers(XmppClient Client)
Registers XMPP stanza handlers
virtual async Task< Stream > Decrypt(string EndpointReference, string Id, string Type, string From, string To, Stream Data, IE2eSymmetricCipher SymmetricCipher)
Decrypts binary data received from an XMPP client out of band.
Task< uint > SendIqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ Get stanza
static List< IE2eEndpoint > ParseE2eKeys(XmlElement E2E)
Parses a set of E2E keys from XML.
static bool TryCreateEndpoint(string LocalName, string Namespace, out IE2eEndpoint Endpoint)
Tries to create a new endpoint, given its qualified name.
IE2eEndpoint GetLocalKey(IE2eEndpoint Key)
Gets the local key of a given type.
virtual Task< byte[]> Decrypt(string EndpointReference, string Id, string Type, string From, string To, byte[] Data, IE2eSymmetricCipher SymmetricCipher)
Decrypts binary data from an endpoint.
Task< uint > SendIqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, bool DropOff, int MaxRetryTimeout)
Sends an IQ Get stanza
virtual Task< byte[]> Encrypt(string Id, string Type, string From, string To, byte[] Data, out IE2eEndpoint EndpointReference)
Encrypts binary data for transmission to an endpoint.
const string IoTHarmonizationP2PCurrent
Current namespace for peer-to-peer communication
IE2eEndpoint GetLocalKey(Type KeyType)
Gets the local key of a given type.
IE2eEndpoint GetLocalKey(byte[] PublicKey)
Gets the local key with a given public key.
Task< uint > SendIqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ Set stanza
static IE2eEndpoint[] CreateEndpoints(int DesiredSecurityStrength, int MinSecurityStrength, int MaxSecurityStrength, Type OnlyIfDerivedFrom)
Creates a set of endpoints within a range of security strengths.
static IE2eEndpoint ParseE2eKey(XmlElement E)
Parses a single E2E key from XML.
Task< uint > SendIqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, bool DropOff, int MaxRetryTimeout, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ Get stanza
Task< uint > SendIqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries)
Sends an IQ Get stanza
virtual void UnregisterHandlers(XmppClient Client)
Unregisters XMPP stanza handlers
Task< uint > SendIqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ Set stanza
EndpointSecurity(XmppClient Client, int SecurityStrength, params IE2eEndpoint[] LocalEndpoints)
Class managing end-to-end encryption.
async Task SynchronizeE2e(string FullJID, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Synchronizes End-to-End Encryption and Peer-to-Peer connectivity parameters with a remote entity.
EndpointSecurity(XmppClient Client, XmppServerlessMessaging ServerlessMessaging, int SecurityStrength)
Class managing end-to-end encryption.
Task< uint > SendIq(XmppClient Client, E2ETransmission E2ETransmission, string Id, string To, string Xml, string Type, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, bool DropOff, int MaxRetryTimeout, bool PkiSynchronized)
Sends an IQ stanza
virtual async Task IqResult(object Sender, IqResultEventArgs e)
Response handler for E2E encrypted iq stanzas
void AppendE2eInfo(StringBuilder Xml)
Appends E2E information to XML.
static bool TryGetEndpoint(string LocalName, string Namespace, out IE2eEndpoint Endpoint)
Tries to get an existing endpoint, given its qualified name.
Task< uint > SendIqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries)
Sends an IQ Set stanza
static readonly string[] NamespacesIoTHarmonizationP2P
Namespaces supported for Peer-to-peer communication.
async Task< XmlElement > IqSetAsync(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml)
Sends an IQ Set stanza
Task SendIqResult(XmppClient Client, E2ETransmission E2ETransmission, string Id, string To, string Xml)
Sends an IQ Result stanza
EndpointSecurity(XmppClient Client, int SecurityStrength)
Class managing end-to-end encryption.
const string IoTHarmonizationP2PNeuroFoundationV1
urn:nf:iot:p2p:1.0
IE2eEndpoint FindLocalEndpoint(string KeyName)
Returns the local endpoint that matches a given key name.
IE2eEndpoint FindLocalEndpoint(string KeyName, string KeyNamespace)
Returns the local endpoint that matches a given key name and namespace.
Task< uint > SendIqGet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ Get stanza
EventHandlerAsync< PeerSynchronizedEventArgs > PeerUpdated
Event raised whenever information about a peer has been updated.
virtual async Task< IE2eEndpoint > Encrypt(string Id, string Type, string From, string To, Stream Data, Stream Encrypted)
Encrypts binary data that can be sent to an XMPP client out of band.
Task SynchronizeE2e(string FullJID, EventHandlerAsync< IqResultEventArgs > Callback)
Synchronizes End-to-End Encryption and Peer-to-Peer connectivity parameters with a remote entity.
static void SetCiphers(Type[] CipherTypes, bool Lock)
Sets allowed cipers in endpoint security.
static IE2eEndpoint[] CreateEndpoints(int DesiredSecurityStrength, int MinSecurityStrength, int MaxSecurityStrength, Type OnlyIfDerivedFrom, ProfilerThread Thread)
Creates a set of endpoints within a range of security strengths.
static IE2eEndpoint[] CreateEndpoints(int DesiredSecurityStrength, int MinSecurityStrength, int MaxSecurityStrength)
Creates a set of endpoints within a range of security strengths.
virtual async Task< Tuple< string, string > > Decrypt(XmppClient Client, string Id, string Type, string From, string To, XmlElement E2eElement, IE2eSymmetricCipher SymmetricCipher)
Decrypts XML data from an endpoint.
async Task< uint > SendIq(XmppClient Client, E2ETransmission E2ETransmission, string Id, string To, string Xml, string Type, EventHandlerAsync< IqResultEventArgs > Callback, object State, int RetryTimeout, int NrRetries, bool DropOff, int MaxRetryTimeout, bool PkiSynchronized, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ stanza
XmlElement IqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, int Timeout)
Sends an IQ Set stanza
virtual async Task< bool > Encrypt(XmppClient Client, string Id, string Type, string From, string To, string DataXml, StringBuilder Xml)
Encrypts XML data for transmission to an endpoint.
bool AddPeerPkiInfo(string FullJID, XmlElement E2E)
Adds E2E information about a peer.
const string IoTHarmonizationE2ECurrent
Current namespace for End-to-End encryption.
const string IoTHarmonizationE2EIeeeV1
urn:ieee:iot:e2e:1.0
bool ContainsKey(string FullJid)
If infomation is available for a given endpoint.
Task SendMessage(XmppClient Client, E2ETransmission E2ETransmission, QoSLevel QoS, MessageType Type, string Id, string To, string CustomXml, string Body, string Subject, string Language, string ThreadId, string ParentThreadId, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback, object State)
Sends an XMPP message to an endpoint.
bool RemovePeerPkiInfo(string FullJID)
Removes E2E information about a peer.
Task< uint > SendIqSet(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State, EventHandlerAsync< DeliveryEventArgs > DeliveryCallback)
Sends an IQ Set stanza
void GenerateNewKey()
Generates new local keys.
Task SendIqError(XmppClient Client, E2ETransmission E2ETransmission, string Id, string To, string Xml)
Sends an IQ Error stanza
EventHandlerAsync< PresenceEventArgs > PeerUnavailable
Event raised whenever a peer has become unavailable.
async Task< XmlElement > IqGetAsync(XmppClient Client, E2ETransmission E2ETransmission, string To, string Xml)
Sends an IQ Get stanza
virtual void Dispose()
IDisposable.Dispose
Event arguments for peer synchronization events.
Implements support for the AEAD-ChaCha20-Poly1305 cipher in hybrid End-to-End encryption schemes.
Implements support for the AES-256 cipher in hybrid End-to-End encryption schemes.
override void Dispose()
IDisposable.Dispose
Implements support for the ChaCha20 cipher in hybrid End-to-End encryption schemes.
virtual void Dispose()
IDisposable.Dispose
Class managing peer-to-peer serveless XMPP communication.
Maintains information about an item in the roster.
SubscriptionState State
roup Current subscription state.
PresenceEventArgs[] Resources
Active resources utilized by contact.
The requesting entity does not possess the necessary permissions to perform an action that only certa...
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
async void ProcessMessage(MessageEventArgs e)
Processes an incoming message.
bool UnregisterMessageHandler(string LocalName, string Namespace, EventHandlerAsync< MessageEventArgs > Handler, bool RemoveNamespaceAsClientFeature)
Unregisters a Message handler.
bool UnregisterIqGetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool RemoveNamespaceAsClientFeature)
Unregisters an IQ-Get handler.
int DefaultRetryTimeout
Default retry timeout, in milliseconds. This value is used when sending IQ requests wihtout specifyin...
Task SendMessage(MessageType Type, string To, string CustomXml, string Body, string Subject, string Language, string ThreadId, string ParentThreadId)
Sends a simple chat message
bool DefaultDropOff
Default Drop-off value. If drop-off is used, the retry timeout is doubled for each retry,...
int DefaultNrRetries
Default number of retries if results or errors are not returned. This value is used when sending IQ r...
static string GetBareJID(string JID)
Gets the Bare JID from a JID, which may be a Full JID.
void RegisterIqSetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool PublishNamespaceAsClientFeature)
Registers an IQ-Set handler.
int DefaultMaxRetryTimeout
Default maximum retry timeout, in milliseconds. This value is used when sending IQ requests wihtout s...
void RegisterIqGetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool PublishNamespaceAsClientFeature)
Registers an IQ-Get handler.
Task ProcessIqSet(IqEventArgs e)
Processes an incoming IQ SET stanza.
Task ProcessIqGet(IqEventArgs e)
Processes an incoming IQ GET stanza.
const string NamespaceXmppStanzas
urn:ietf:params:xml:ns:xmpp-stanzas
void RegisterMessageHandler(string LocalName, string Namespace, EventHandlerAsync< MessageEventArgs > Handler, bool PublishNamespaceAsClientFeature)
Registers a Message handler.
bool UnregisterIqSetHandler(string LocalName, string Namespace, EventHandlerAsync< IqEventArgs > Handler, bool RemoveNamespaceAsClientFeature)
Unregisters an IQ-Set handler.
Task< uint > SendIq(string Id, string To, string Xml, string Type, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ stanza.
Task< uint > SendIqSet(string To, string Xml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ Set request.
bool TryGetTag(string TagName, out object Tag)
Tries to get a tag from the client. Tags can be used to attached application specific objects to the ...
async Task< string > ExceptionToXmppXml(Exception ex)
Converts an exception object to an XMPP XML error element.
string NextId()
Generates a new id attribute value.
RosterItem GetRosterItem(string BareJID)
Gets a roster item.
Base class of XMPP exceptions
Static class that dynamically manages types and interfaces available in the runtime environment.
static object[] NoParameters
Contains an empty array of parameter values.
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
Class that keeps track of events and timing for one thread.
ProfilerThread CreateSubThread(string Name, ProfilerThreadType Type)
Creates a new profiler thread.
void Start()
Processing starts.
void Stop()
Processing starts.
void NewState(string State)
Thread changes state.
Abstract base class for End-to-End encryption schemes.
void ToXml(StringBuilder Xml, string ParentNamespace)
Exports the public key information to XML.
int SecurityStrength
Security strength of End-to-End encryption scheme.
IE2eEndpoint Create(int SecurityStrength)
Creates a new key.
uint GetNextCounter()
Gets the next counter value.
IE2eEndpoint Parse(XmlElement Xml)
Parses endpoint information from an XML element.
string PublicKeyBase64
Remote public key, as a Base64 string.
string Namespace
Namespace of the E2E endpoint
IE2eSymmetricCipher DefaultSymmetricCipher
Default symmetric cipher.
string LocalName
Local name of the E2E endpoint
IE2eEndpoint Previous
Previous keys.
Interface for symmetric ciphers.
byte[] Encrypt(string Id, string Type, string From, string To, uint Counter, byte[] Data, IE2eEndpoint Sender, IE2eEndpoint Receiver)
Encrypts binary data
byte[] Decrypt(string Id, string Type, string From, string To, byte[] Data, IE2eEndpoint Sender, IE2eEndpoint Receiver)
Decrypts binary data
End-to-end encryption interface.
PresenceType
Type of presence received.
QoSLevel
Quality of Service Level for asynchronous messages. Support for QoS Levels must be supported by the r...
SubscriptionState
State of a presence subscription.
MessageType
Type of message received.
XmppState
State of XMPP connection.
E2ETransmission
End-to-end encryption mode.
ProfilerThreadType
Type of profiler thread.