summary refs log tree commit diff
path: root/crypto/src/pqc
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-24 00:02:41 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-24 00:02:41 +0700
commit0102c19ed6d0e0a2ce630b3118c40e1f4e9ffe97 (patch)
tree019bcceff8c0426593c44df7066d595f19fb3691 /crypto/src/pqc
parentAdd Gost2012 algorithms to registries (diff)
downloadBouncyCastle.NET-ed25519-0102c19ed6d0e0a2ce630b3118c40e1f4e9ffe97.tar.xz
Refactor intrinsics code
Diffstat (limited to 'crypto/src/pqc')
-rw-r--r--crypto/src/pqc/crypto/sphincsplus/HarakaS_X86.cs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypto/src/pqc/crypto/sphincsplus/HarakaS_X86.cs b/crypto/src/pqc/crypto/sphincsplus/HarakaS_X86.cs
index 3975f02ff..87681c484 100644
--- a/crypto/src/pqc/crypto/sphincsplus/HarakaS_X86.cs
+++ b/crypto/src/pqc/crypto/sphincsplus/HarakaS_X86.cs
@@ -1,7 +1,9 @@
 #if NETCOREAPP3_0_OR_GREATER
 using System;
+using System.Buffers.Binary;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 using System.Runtime.Intrinsics;
 
 using Org.BouncyCastle.Crypto;
@@ -185,15 +187,13 @@ namespace Org.BouncyCastle.Pqc.Crypto.SphincsPlus
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
         private static Vector128<byte> Load128(ReadOnlySpan<byte> t)
         {
-#if NET7_0_OR_GREATER
-            return Vector128.Create<byte>(t);
-#else
             if (BitConverter.IsLittleEndian && Unsafe.SizeOf<Vector128<byte>>() == 16)
-                return Unsafe.ReadUnaligned<Vector128<byte>>(ref Unsafe.AsRef(t[0]));
+                return MemoryMarshal.Read<Vector128<byte>>(t);
 
-            return Vector128.Create(t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12],
-                t[13], t[14], t[15]);
-#endif
+            return Vector128.Create(
+                BinaryPrimitives.ReadUInt64LittleEndian(t[..8]),
+                BinaryPrimitives.ReadUInt64LittleEndian(t[8..])
+            ).AsByte();
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]