Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HMACSHA512.cs
Go to the documentation of this file.
3
5
6[UnsupportedOSPlatform("browser")]
7public class HMACSHA512 : HMAC
8{
10
11 [Obsolete("ProduceLegacyHmacValues is obsolete. Producing legacy HMAC values is not supported.", DiagnosticId = "SYSLIB0029", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
13 {
14 get
15 {
16 return false;
17 }
18 set
19 {
20 if (value)
21 {
23 }
24 }
25 }
26
27 public override byte[] Key
28 {
29 get
30 {
31 return base.Key;
32 }
33 set
34 {
35 if (value == null)
36 {
37 throw new ArgumentNullException("value");
38 }
40 base.Key = _hMacCommon.ActualKey;
41 }
42 }
43
44 public HMACSHA512()
45 : this(RandomNumberGenerator.GetBytes(128))
46 {
47 }
48
49 public HMACSHA512(byte[] key)
50 {
51 if (key == null)
52 {
53 throw new ArgumentNullException("key");
54 }
55 base.HashName = "SHA512";
56 _hMacCommon = new HMACCommon("SHA512", key, 128);
57 base.Key = _hMacCommon.ActualKey;
58 base.BlockSizeValue = 128;
60 }
61
62 protected override void HashCore(byte[] rgb, int ib, int cb)
63 {
64 _hMacCommon.AppendHashData(rgb, ib, cb);
65 }
66
67 protected override void HashCore(ReadOnlySpan<byte> source)
68 {
70 }
71
72 protected override byte[] HashFinal()
73 {
75 }
76
77 protected override bool TryHashFinal(Span<byte> destination, out int bytesWritten)
78 {
79 return _hMacCommon.TryFinalizeHashAndReset(destination, out bytesWritten);
80 }
81
82 public override void Initialize()
83 {
85 }
86
87 public static byte[] HashData(byte[] key, byte[] source)
88 {
89 if (key == null)
90 {
91 throw new ArgumentNullException("key");
92 }
93 if (source == null)
94 {
95 throw new ArgumentNullException("source");
96 }
98 }
99
101 {
102 byte[] array = new byte[64];
103 int num = HashData(key, source, array.AsSpan());
104 return array;
105 }
106
108 {
109 if (!TryHashData(key, source, destination, out var bytesWritten))
110 {
112 }
113 return bytesWritten;
114 }
115
117 {
118 if (destination.Length < 64)
119 {
120 bytesWritten = 0;
121 return false;
122 }
124 return true;
125 }
126
127 protected override void Dispose(bool disposing)
128 {
129 if (disposing)
130 {
131 HMACCommon hMacCommon = _hMacCommon;
132 if (hMacCommon != null)
133 {
134 _hMacCommon = null;
135 hMacCommon.Dispose(disposing);
136 }
137 }
138 base.Dispose(disposing);
139 }
140}
void Dispose(bool disposing)
Definition HMACCommon.cs:98
bool TryFinalizeHashAndReset(Span< byte > destination, out int bytesWritten)
Definition HMACCommon.cs:83
void AppendHashData(byte[] data, int offset, int count)
Definition HMACCommon.cs:63
static int MacData(string hashAlgorithmId, ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination)
static string Argument_DestinationTooShort
Definition SR.cs:14
Definition SR.cs:7
override void HashCore(byte[] rgb, int ib, int cb)
Definition HMACSHA512.cs:62
override void Dispose(bool disposing)
static byte[] HashData(byte[] key, byte[] source)
Definition HMACSHA512.cs:87
override void HashCore(ReadOnlySpan< byte > source)
Definition HMACSHA512.cs:67
static int HashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination)
override bool TryHashFinal(Span< byte > destination, out int bytesWritten)
Definition HMACSHA512.cs:77
static byte[] HashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source)
static bool TryHashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)