Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Expand() [2/3]

static void System.Security.Cryptography.HKDF.Expand ( HashAlgorithmName hashAlgorithmName,
int hashLength,
ReadOnlySpan< byte > prk,
Span< byte > output,
ReadOnlySpan< byte > info )
inlinestaticprivate

Definition at line 76 of file HKDF.cs.

77 {
78 if (prk.Length < hashLength)
79 {
81 }
82 Span<byte> span = stackalloc byte[1];
83 ref byte reference = ref span[0];
84 Span<byte> span2 = Span<byte>.Empty;
85 Span<byte> destination = output;
86 Span<byte> span3 = stackalloc byte[64];
87 ReadOnlySpan<byte> readOnlySpan = default(Span<byte>);
88 byte[] array = null;
89 if (output.Overlaps(info))
90 {
91 if (info.Length > 64)
92 {
94 span3 = array;
95 }
96 span3 = span3.Slice(0, info.Length);
97 info.CopyTo(span3);
98 readOnlySpan = span3;
99 }
100 else
101 {
102 readOnlySpan = info;
103 }
104 using (IncrementalHash incrementalHash = IncrementalHash.CreateHMAC(hashAlgorithmName, prk))
105 {
106 int num = 1;
107 while (true)
108 {
109 incrementalHash.AppendData(span2);
110 incrementalHash.AppendData(readOnlySpan);
111 reference = (byte)num;
112 incrementalHash.AppendData(span);
113 if (destination.Length < hashLength)
114 {
115 break;
116 }
117 span2 = destination.Slice(0, hashLength);
118 destination = destination.Slice(hashLength);
119 GetHashAndReset(incrementalHash, span2);
120 num++;
121 }
122 if (destination.Length > 0)
123 {
124 Span<byte> output2 = stackalloc byte[hashLength];
125 GetHashAndReset(incrementalHash, output2);
126 output2.Slice(0, destination.Length).CopyTo(destination);
127 }
128 }
129 if (array != null)
130 {
132 }
133 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Cryptography_Prk_TooSmall
Definition SR.cs:170
Definition SR.cs:7
static void Return(byte[] array, int clearSize=-1)
Definition CryptoPool.cs:12
static byte[] Rent(int minimumLength)
Definition CryptoPool.cs:7
static void GetHashAndReset(IncrementalHash hmac, Span< byte > output)
Definition HKDF.cs:175

References System.Security.Cryptography.IncrementalHash.AppendData(), System.array, System.Security.Cryptography.IncrementalHash.CreateHMAC(), System.SR.Cryptography_Prk_TooSmall, System.destination, System.Span< T >.Empty, System.SR.Format(), System.Security.Cryptography.HKDF.GetHashAndReset(), System.info, System.ReadOnlySpan< T >.Length, System.Security.Cryptography.CryptoPool.Rent(), System.Security.Cryptography.CryptoPool.Return(), and System.Span< T >.Slice().