summary refs log tree commit diff
path: root/crypto/src/tls/BasicTlsPskIdentity.cs
blob: 4ed385a6b0296a7efe79f24eeb8d5adf43f6f571 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
        }
    }
}