Skip to content

Commit 21bbcec

Browse files
authored
Update Endianness usage
Signed-off-by: Xen <lordofxen@deskasoft.com>
1 parent 299cfdd commit 21bbcec

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

HashifyNet/Algorithms/Blake2/Blake2B_Implementation.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,11 @@ public BlockTransformer(int hashSizeInBits, uint originalKeyLength, byte[] salt,
179179
((uint)hashSizeInBits / 8) |
180180
(originalKeyLength << 8);
181181

182-
_e ^= BitConverter.ToUInt64(salt, 0);
183-
_f ^= BitConverter.ToUInt64(salt, 8);
182+
_e ^= Endianness.ToUInt64LittleEndian(salt, 0);
183+
_f ^= Endianness.ToUInt64LittleEndian(salt, 8);
184184

185-
_g ^= BitConverter.ToUInt64(personalization, 0);
186-
_h ^= BitConverter.ToUInt64(personalization, 8);
185+
_g ^= Endianness.ToUInt64LittleEndian(personalization, 0);
186+
_h ^= Endianness.ToUInt64LittleEndian(personalization, 8);
187187
}
188188
protected override void CopyStateTo(BlockTransformer other)
189189
{
@@ -320,14 +320,14 @@ protected override IHashValue FinalizeHashValueInternal(CancellationToken cancel
320320
true);
321321
}
322322

323-
var hashValueBytes = BitConverter.GetBytes(tempA)
324-
.Concat(BitConverter.GetBytes(tempB))
325-
.Concat(BitConverter.GetBytes(tempC))
326-
.Concat(BitConverter.GetBytes(tempD))
327-
.Concat(BitConverter.GetBytes(tempE))
328-
.Concat(BitConverter.GetBytes(tempF))
329-
.Concat(BitConverter.GetBytes(tempG))
330-
.Concat(BitConverter.GetBytes(tempH))
323+
var hashValueBytes = Endianness.GetBytesLittleEndian(tempA)
324+
.Concat(Endianness.GetBytesLittleEndian(tempB))
325+
.Concat(Endianness.GetBytesLittleEndian(tempC))
326+
.Concat(Endianness.GetBytesLittleEndian(tempD))
327+
.Concat(Endianness.GetBytesLittleEndian(tempE))
328+
.Concat(Endianness.GetBytesLittleEndian(tempF))
329+
.Concat(Endianness.GetBytesLittleEndian(tempG))
330+
.Concat(Endianness.GetBytesLittleEndian(tempH))
331331
.Take(_hashSizeInBits / 8)
332332
.ToArray();
333333

@@ -370,4 +370,5 @@ private static void Compress(
370370
}
371371
}
372372
}
373-
}
373+
374+
}

0 commit comments

Comments
 (0)