diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-07 11:01:19 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-07 11:01:19 +0700 |
commit | 67a5d0f5805539c0a05a5f7204d5f2cbd0a74f1a (patch) | |
tree | 9a958f92e73e831e89810aa61a401cb4bbf4b36c /crypto/src | |
parent | Formatting (diff) | |
download | BouncyCastle.NET-ed25519-67a5d0f5805539c0a05a5f7204d5f2cbd0a74f1a.tar.xz |
Add BasicGcmMultiplier.IsHardwareAccelerated
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/crypto/modes/GCMBlockCipher.cs | 7 | ||||
-rw-r--r-- | crypto/src/crypto/modes/gcm/BasicGcmMultiplier.cs | 9 |
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) |