Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HMACSHA1.cs
Go to the documentation of this file.
4
6
7[UnsupportedOSPlatform("browser")]
8public class HMACSHA1 : HMAC
9{
11
12 public override byte[] Key
13 {
14 get
15 {
16 return base.Key;
17 }
18 set
19 {
20 if (value == null)
21 {
22 throw new ArgumentNullException("value");
23 }
25 base.Key = _hMacCommon.ActualKey;
26 }
27 }
28
29 public HMACSHA1()
30 : this(RandomNumberGenerator.GetBytes(64))
31 {
32 }
33
34 public HMACSHA1(byte[] key)
35 {
36 if (key == null)
37 {
38 throw new ArgumentNullException("key");
39 }
40 base.HashName = "SHA1";
41 _hMacCommon = new HMACCommon("SHA1", key, 64);
42 base.Key = _hMacCommon.ActualKey;
43 base.BlockSizeValue = 64;
45 }
46
47 [EditorBrowsable(EditorBrowsableState.Never)]
48 [Obsolete("HMACSHA1 always uses the algorithm implementation provided by the platform. Use a constructor without the useManagedSha1 parameter.", DiagnosticId = "SYSLIB0030", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
49 public HMACSHA1(byte[] key, bool useManagedSha1)
50 : this(key)
51 {
52 }
53
54 protected override void HashCore(byte[] rgb, int ib, int cb)
55 {
56 _hMacCommon.AppendHashData(rgb, ib, cb);
57 }
58
59 protected override void HashCore(ReadOnlySpan<byte> source)
60 {
62 }
63
64 protected override byte[] HashFinal()
65 {
67 }
68
69 protected override bool TryHashFinal(Span<byte> destination, out int bytesWritten)
70 {
71 return _hMacCommon.TryFinalizeHashAndReset(destination, out bytesWritten);
72 }
73
74 public override void Initialize()
75 {
77 }
78
79 public static byte[] HashData(byte[] key, byte[] source)
80 {
81 if (key == null)
82 {
83 throw new ArgumentNullException("key");
84 }
85 if (source == null)
86 {
87 throw new ArgumentNullException("source");
88 }
90 }
91
93 {
94 byte[] array = new byte[20];
95 int num = HashData(key, source, array.AsSpan());
96 return array;
97 }
98
100 {
101 if (!TryHashData(key, source, destination, out var bytesWritten))
102 {
104 }
105 return bytesWritten;
106 }
107
109 {
110 if (destination.Length < 20)
111 {
112 bytesWritten = 0;
113 return false;
114 }
116 return true;
117 }
118
119 protected override void Dispose(bool disposing)
120 {
121 if (disposing)
122 {
123 HMACCommon hMacCommon = _hMacCommon;
124 if (hMacCommon != null)
125 {
126 _hMacCommon = null;
127 hMacCommon.Dispose(disposing);
128 }
129 }
130 base.Dispose(disposing);
131 }
132}
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
HMACSHA1(byte[] key, bool useManagedSha1)
Definition HMACSHA1.cs:49
static int HashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination)
Definition HMACSHA1.cs:99
override void HashCore(ReadOnlySpan< byte > source)
Definition HMACSHA1.cs:59
static bool TryHashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source, Span< byte > destination, out int bytesWritten)
Definition HMACSHA1.cs:108
override void Dispose(bool disposing)
Definition HMACSHA1.cs:119
static byte[] HashData(byte[] key, byte[] source)
Definition HMACSHA1.cs:79
static byte[] HashData(ReadOnlySpan< byte > key, ReadOnlySpan< byte > source)
Definition HMACSHA1.cs:92
override void HashCore(byte[] rgb, int ib, int cb)
Definition HMACSHA1.cs:54
override bool TryHashFinal(Span< byte > destination, out int bytesWritten)
Definition HMACSHA1.cs:69