15 private uint counter = 0;
31 this.defaultSymmetricCipher?.Dispose();
32 this.defaultSymmetricCipher =
null;
49 set => this.prev = value;
109 foreach (XmlAttribute Attr
in Xml.Attributes)
114 return this.
CreatePublic(Convert.FromBase64String(Attr.Value));
117 return this.
CreatePrivate(Convert.FromBase64String(Attr.Value));
129 public void ToXml(StringBuilder Xml,
string ParentNamespace)
133 Xml.Append(
" pub=\"");
137 if (ns != ParentNamespace)
139 Xml.Append(
"\" xmlns=\"");
158 throw new NotSupportedException(
"Encrypting secrets not supported.");
168 throw new NotSupportedException(
"Decrypting secrets not supported.");
188 public abstract byte[]
Sign(
byte[] Data);
195 public abstract byte[]
Sign(Stream Data);
203 public abstract bool Verify(
byte[] Data,
byte[] Signature);
211 public abstract bool Verify(Stream Data,
byte[] Signature);
216 public virtual bool Safe =>
true;
221 public virtual bool Slow =>
false;
226 StringBuilder Xml =
new StringBuilder();
227 this.
ToXml(Xml,
string.Empty);
228 return Xml.ToString();
232 public override abstract bool Equals(
object obj);
246 if (this.SupportsSharedSecrets)
249 if (this.SupportsSignatures)
273 return ++this.counter;
Abstract base class for End-to-End encryption schemes.
abstract byte[] Sign(Stream Data)
Signs binary data using the local private key.
virtual bool Slow
If implementation is slow, compared to other options.
virtual bool SupportsSignatures
If signatures are supported.
abstract byte[] Sign(byte[] Data)
Signs binary data using the local private key.
virtual IE2eSymmetricCipher DefaultSymmetricCipher
Default symmetric cipher.
abstract IE2eEndpoint Create(int SecurityStrength)
Creates a new key.
uint GetNextCounter()
Gets the next counter value.
abstract bool Verify(Stream Data, byte[] Signature)
Verifies a signature.
virtual bool Safe
If endpoint is considered safe (i.e. there are no suspected backdoors)
virtual byte[] EncryptSecret(byte[] Secret)
Encrypts a secret. Used if shared secrets cannot be calculated.
virtual void Dispose()
IDisposable.Dispose
abstract IE2eEndpoint CreatePublic(byte[] PublicKey)
Creates a new endpoint given a public key.
abstract IE2eEndpoint CreatePrivate(byte[] Secret)
Creates a new endpoint given a private key.
override string ToString()
abstract override bool Equals(object obj)
abstract bool Verify(byte[] Data, byte[] Signature)
Verifies a signature.
void ToXml(StringBuilder Xml, string ParentNamespace)
Exports the public key information to XML.
IE2eEndpoint Parse(XmlElement Xml)
Parses endpoint information from an XML element.
E2eEndpoint(IE2eSymmetricCipher DefaultSymmetricCipher)
Abstract base class for End-to-End encryption schemes.
virtual bool SupportsSharedSecrets
If shared secrets can be calculated from the endpoints keys.
virtual string Namespace
Namespace of the E2E encryption scheme
abstract override int GetHashCode()
int Score
Provides a score for the endpoint. More features, higher score.
abstract string PublicKeyBase64
Remote public key, as a Base64 string.
virtual byte[] DecryptSecret(byte[] Secret)
Decrypts a secret. Used if shared secrets cannot be calculated.
abstract int SecurityStrength
Security strength of End-to-End encryption scheme.
abstract byte[] GetSharedSecret(IE2eEndpoint RemoteEndpoint)
Gets a shared secret
IE2eEndpoint Previous
Previous keys.
abstract string LocalName
Local name of the E2E encryption scheme
abstract byte[] PublicKey
Remote public key.
Class managing end-to-end encryption.
const string IoTHarmonizationE2ECurrent
Current namespace for End-to-End encryption.
Abstract base class for End-to-End encryption schemes.
Interface for symmetric ciphers.