File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/libraries/System.IO.Hashing/src/System/IO/Hashing Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -713,8 +713,8 @@ private static void DeriveSecretFromSeed(byte* destinationSecret, ulong seed)
713713 {
714714 for ( int i = 0 ; i < SecretLengthBytes ; i += sizeof ( ulong ) * 2 )
715715 {
716- Unsafe . WriteUnaligned ( destinationSecret + i , Unsafe . ReadUnaligned < ulong > ( defaultSecret + i ) + seed ) ;
717- Unsafe . WriteUnaligned ( destinationSecret + i + 8 , Unsafe . ReadUnaligned < ulong > ( defaultSecret + i + 8 ) - seed ) ;
716+ WriteUInt64LE ( destinationSecret + i , ReadUInt64LE ( defaultSecret + i ) + seed ) ;
717+ WriteUInt64LE ( destinationSecret + i + 8 , ReadUInt64LE ( defaultSecret + i + 8 ) - seed ) ;
718718 }
719719 }
720720 }
@@ -1003,6 +1003,16 @@ private static ulong ReadUInt64LE(byte* data) =>
10031003 Unsafe . ReadUnaligned < ulong > ( data ) :
10041004 BinaryPrimitives . ReverseEndianness ( Unsafe . ReadUnaligned < ulong > ( data ) ) ;
10051005
1006+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
1007+ private static void WriteUInt64LE ( byte * data , ulong value )
1008+ {
1009+ if ( ! BitConverter . IsLittleEndian )
1010+ {
1011+ value = BinaryPrimitives . ReverseEndianness ( value ) ;
1012+ }
1013+ Unsafe . WriteUnaligned ( data , value ) ;
1014+ }
1015+
10061016 [ StructLayout ( LayoutKind . Auto ) ]
10071017 private struct State
10081018 {
You can’t perform that action at this time.
0 commit comments