-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathPresharedKey.cs
More file actions
59 lines (52 loc) · 1.34 KB
/
PresharedKey.cs
File metadata and controls
59 lines (52 loc) · 1.34 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Text;
namespace Waher.Security.DTLS
{
/// <summary>
/// Pre-shared key.
/// </summary>
public class PresharedKey : IDtlsCredentials
{
private readonly byte[] identity;
private readonly byte[] key;
/// <summary>
/// Pre-shared key.
/// </summary>
/// <param name="Identity">Identity.</param>
/// <param name="Key">Secret key.</param>
public PresharedKey(string Identity, string Key)
: this(Encoding.UTF8.GetBytes(Identity), Encoding.UTF8.GetBytes(Key))
{
}
/// <summary>
/// Pre-shared key.
/// </summary>
/// <param name="Identity">Identity.</param>
/// <param name="Key">Secret binary key.</param>
public PresharedKey(string Identity, byte[] Key)
: this(Encoding.UTF8.GetBytes(Identity), Key)
{
}
/// <summary>
/// Pre-shared key.
/// </summary>
/// <param name="Identity">UTF-8 encoded Identity.</param>
/// <param name="Key">Secret binary key.</param>
public PresharedKey(byte[] Identity, byte[] Key)
{
this.identity = Identity;
this.key = Key;
}
/// <summary>
/// UTF-8 encoded Identity.
/// </summary>
public byte[] Identity => this.identity;
/// <summary>
/// Identity string.
/// </summary>
public string IdentityString => Encoding.UTF8.GetString(this.identity);
/// <summary>
/// Secret binary key.
/// </summary>
public byte[] Key => this.key;
}
}