summary refs log tree commit diff
path: root/crypto/src/tls/BasicTlsPskIdentity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/tls/BasicTlsPskIdentity.cs')
-rw-r--r--crypto/src/tls/BasicTlsPskIdentity.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crypto/src/tls/BasicTlsPskIdentity.cs b/crypto/src/tls/BasicTlsPskIdentity.cs
new file mode 100644
index 000000000..4ed385a6b
--- /dev/null
+++ b/crypto/src/tls/BasicTlsPskIdentity.cs
@@ -0,0 +1,44 @@
+using System;
+
+using Org.BouncyCastle.Utilities;
+
+namespace Org.BouncyCastle.Tls
+{
+    /// <summary>A basic PSK Identity holder.</summary>
+    public class BasicTlsPskIdentity
+        : TlsPskIdentity
+    {
+        protected readonly byte[] m_identity;
+        protected readonly byte[] m_psk;
+
+        public BasicTlsPskIdentity(byte[] identity, byte[] psk)
+        {
+            this.m_identity = Arrays.Clone(identity);
+            this.m_psk = Arrays.Clone(psk);
+        }
+
+        public BasicTlsPskIdentity(string identity, byte[] psk)
+        {
+            this.m_identity = Strings.ToUtf8ByteArray(identity);
+            this.m_psk = Arrays.Clone(psk);
+        }
+
+        public virtual void SkipIdentityHint()
+        {
+        }
+
+        public virtual void NotifyIdentityHint(byte[] psk_identity_hint)
+        {
+        }
+
+        public virtual byte[] GetPskIdentity()
+        {
+            return m_identity;
+        }
+
+        public byte[] GetPsk()
+        {
+            return Arrays.Clone(m_psk);
+        }
+    }
+}