summary refs log tree commit diff
path: root/crypto/src/security/WrapperUtilities.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/security/WrapperUtilities.cs')
-rw-r--r--crypto/src/security/WrapperUtilities.cs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crypto/src/security/WrapperUtilities.cs b/crypto/src/security/WrapperUtilities.cs
index 782259d9c..a9bf9ce64 100644
--- a/crypto/src/security/WrapperUtilities.cs
+++ b/crypto/src/security/WrapperUtilities.cs
@@ -88,10 +88,8 @@ namespace Org.BouncyCastle.Security
         {
             string mechanism = CollectionUtilities.GetValueOrKey(Algorithms, algorithm).ToUpperInvariant();
 
-            try
+            if (Enums.TryGetEnumValue<WrapAlgorithm>(mechanism, out var wrapAlgorithm))
             {
-                WrapAlgorithm wrapAlgorithm = Enums.GetEnumValue<WrapAlgorithm>(mechanism);
-
                 switch (wrapAlgorithm)
                 {
                 case WrapAlgorithm.AESRFC3211WRAP:
@@ -120,11 +118,10 @@ namespace Org.BouncyCastle.Security
                     return new RC2WrapEngine();
                 case WrapAlgorithm.SEEDWRAP:
                     return new SeedWrapEngine();
+                default:
+                    throw new NotImplementedException();
                 }
             }
-            catch (ArgumentException)
-            {
-            }
 
             // Create an IBufferedCipher and use it as IWrapper (via BufferedCipherWrapper)
             IBufferedCipher blockCipher = CipherUtilities.GetCipher(algorithm);