summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/crypto/modes/GCMBlockCipher.cs7
-rw-r--r--crypto/src/crypto/modes/gcm/BasicGcmMultiplier.cs9
2 files changed, 10 insertions, 6 deletions
diff --git a/crypto/src/crypto/modes/GCMBlockCipher.cs b/crypto/src/crypto/modes/GCMBlockCipher.cs
index 16e9e4597..f41214c5d 100644
--- a/crypto/src/crypto/modes/GCMBlockCipher.cs
+++ b/crypto/src/crypto/modes/GCMBlockCipher.cs
@@ -35,13 +35,8 @@ namespace Org.BouncyCastle.Crypto.Modes
 
         internal static IGcmMultiplier CreateGcmMultiplier()
         {
-#if NETCOREAPP3_0_OR_GREATER
-            // TODO Prefer more tightly coupled test
-            if (Pclmulqdq.IsSupported)
-            {
+            if (BasicGcmMultiplier.IsHardwareAccelerated)
                 return new BasicGcmMultiplier();
-            }
-#endif
 
             return new Tables4kGcmMultiplier();
         }
diff --git a/crypto/src/crypto/modes/gcm/BasicGcmMultiplier.cs b/crypto/src/crypto/modes/gcm/BasicGcmMultiplier.cs
index abae4f3fa..7fa275449 100644
--- a/crypto/src/crypto/modes/gcm/BasicGcmMultiplier.cs
+++ b/crypto/src/crypto/modes/gcm/BasicGcmMultiplier.cs
@@ -1,4 +1,7 @@
 using System;
+#if NETCOREAPP3_0_OR_GREATER
+using System.Runtime.Intrinsics.X86;
+#endif
 
 namespace Org.BouncyCastle.Crypto.Modes.Gcm
 {
@@ -6,6 +9,12 @@ namespace Org.BouncyCastle.Crypto.Modes.Gcm
     public class BasicGcmMultiplier
         : IGcmMultiplier
     {
+#if NETCOREAPP3_0_OR_GREATER
+        internal static bool IsHardwareAccelerated => Pclmulqdq.IsSupported;
+#else
+        internal static bool IsHardwareAccelerated => false;
+#endif
+
         private GcmUtilities.FieldElement H;
 
         public void Init(byte[] H)