summary refs log tree commit diff
path: root/crypto
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-16 12:41:05 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-16 12:41:05 +0700
commitfdeafa10e2dcfee734d050f2f11ab50a350f69cc (patch)
treeb839357e0bea77bf7c192671b77539b9051162a0 /crypto
parentFix non-8-aligned IPv4 netmask parsing (diff)
downloadBouncyCastle.NET-ed25519-fdeafa10e2dcfee734d050f2f11ab50a350f69cc.tar.xz
Fix rethrow syntax
- see https://github.com/bcgit/bc-csharp/issues/425
Diffstat (limited to 'crypto')
-rw-r--r--crypto/src/cms/CMSSignedHelper.cs4
-rw-r--r--crypto/src/cms/SignerInformation.cs4
-rw-r--r--crypto/src/crypto/engines/IesEngine.cs2
-rw-r--r--crypto/src/openpgp/PgpPbeEncryptedData.cs4
-rw-r--r--crypto/src/openpgp/PgpPublicKey.cs4
-rw-r--r--crypto/src/openpgp/PgpPublicKeyEncryptedData.cs12
-rw-r--r--crypto/src/openpgp/PgpSecretKey.cs16
-rw-r--r--crypto/src/openpgp/PgpUtilities.cs4
-rw-r--r--crypto/src/openssl/PEMReader.cs4
-rw-r--r--crypto/src/openssl/PEMWriter.cs2
-rw-r--r--crypto/src/tls/ClientHello.cs4
-rw-r--r--crypto/src/tls/DtlsClientProtocol.cs6
-rw-r--r--crypto/src/tls/DtlsRecordLayer.cs6
-rw-r--r--crypto/src/tls/DtlsServerProtocol.cs4
-rw-r--r--crypto/src/tls/DtlsTransport.cs64
-rw-r--r--crypto/src/tls/RecordStream.cs10
-rw-r--r--crypto/src/tls/TlsProtocol.cs24
-rw-r--r--crypto/src/tls/TlsUtilities.cs8
-rw-r--r--crypto/src/tls/crypto/impl/TlsAeadCipher.cs14
-rw-r--r--crypto/src/tls/crypto/impl/bc/BcTlsECDomain.cs4
-rw-r--r--crypto/src/x509/X509AttrCertParser.cs4
-rw-r--r--crypto/src/x509/X509CertPairParser.cs4
-rw-r--r--crypto/src/x509/X509CertificateParser.cs4
-rw-r--r--crypto/src/x509/X509CrlParser.cs4
-rw-r--r--crypto/src/x509/X509V2AttributeCertificate.cs4
-rw-r--r--crypto/test/src/math/test/PrimesTest.cs2
-rw-r--r--crypto/test/src/test/BaseBlockCipherTest.cs4
-rw-r--r--crypto/test/src/test/PkixPolicyMappingTest.cs4
28 files changed, 121 insertions, 109 deletions
diff --git a/crypto/src/cms/CMSSignedHelper.cs b/crypto/src/cms/CMSSignedHelper.cs
index 37fefe140..8f2a92147 100644
--- a/crypto/src/cms/CMSSignedHelper.cs
+++ b/crypto/src/cms/CMSSignedHelper.cs
@@ -187,7 +187,7 @@ namespace Org.BouncyCastle.Cms
 			{
 				return DigestUtilities.GetDigest(algorithm);
 			}
-			catch (SecurityUtilityException e)
+			catch (SecurityUtilityException)
 			{
 				// This is probably superfluous on C#, since no provider infrastructure,
 				// assuming DigestUtilities already knows all the aliases
@@ -196,7 +196,7 @@ namespace Org.BouncyCastle.Cms
 					try { return DigestUtilities.GetDigest(alias); }
 					catch (SecurityUtilityException) {}
 				}
-				throw e;
+				throw;
 			}
 		}
 
diff --git a/crypto/src/cms/SignerInformation.cs b/crypto/src/cms/SignerInformation.cs
index 2e32a3ae6..116e349f0 100644
--- a/crypto/src/cms/SignerInformation.cs
+++ b/crypto/src/cms/SignerInformation.cs
@@ -612,9 +612,9 @@ namespace Org.BouncyCastle.Cms
 					throw new CmsException("algorithm: " + algorithm + " not supported in base signatures.");
 				}
 			}
-			catch (SecurityUtilityException e)
+			catch (SecurityUtilityException)
 			{
-				throw e;
+				throw;
 			}
 			catch (GeneralSecurityException e)
 			{
diff --git a/crypto/src/crypto/engines/IesEngine.cs b/crypto/src/crypto/engines/IesEngine.cs
index 33fc4141b..2581aac2c 100644
--- a/crypto/src/crypto/engines/IesEngine.cs
+++ b/crypto/src/crypto/engines/IesEngine.cs
@@ -140,7 +140,7 @@ namespace Org.BouncyCastle.Crypto.Engines
             byte[] T1 = Arrays.CopyOfRange(in_enc, inOff, inOff + macBuf.Length);
 
             if (!Arrays.FixedTimeEquals(T1, macBuf))
-                throw (new InvalidCipherTextException("Invalid MAC."));
+                throw new InvalidCipherTextException("Invalid MAC.");
 
             return M;
         }
diff --git a/crypto/src/openpgp/PgpPbeEncryptedData.cs b/crypto/src/openpgp/PgpPbeEncryptedData.cs
index 7920f54ea..1c3432d89 100644
--- a/crypto/src/openpgp/PgpPbeEncryptedData.cs
+++ b/crypto/src/openpgp/PgpPbeEncryptedData.cs
@@ -133,9 +133,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
 				return encStream;
 			}
-			catch (PgpException e)
+			catch (PgpException)
 			{
-				throw e;
+				throw;
 			}
 			catch (Exception e)
 			{
diff --git a/crypto/src/openpgp/PgpPublicKey.cs b/crypto/src/openpgp/PgpPublicKey.cs
index 3ebfc6256..1fadcff64 100644
--- a/crypto/src/openpgp/PgpPublicKey.cs
+++ b/crypto/src/openpgp/PgpPublicKey.cs
@@ -635,9 +635,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
                     throw new PgpException("unknown public key algorithm encountered");
                 }
             }
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/openpgp/PgpPublicKeyEncryptedData.cs b/crypto/src/openpgp/PgpPublicKeyEncryptedData.cs
index 8c6fcda53..645973215 100644
--- a/crypto/src/openpgp/PgpPublicKeyEncryptedData.cs
+++ b/crypto/src/openpgp/PgpPublicKeyEncryptedData.cs
@@ -45,9 +45,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
                         throw new PgpException("unknown asymmetric algorithm: " + algorithm);
                 }
             }
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -116,9 +116,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
                 cipher = CipherUtilities.GetCipher(cName);
 			}
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -175,9 +175,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
 				return encStream;
             }
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/openpgp/PgpSecretKey.cs b/crypto/src/openpgp/PgpSecretKey.cs
index a120f97d8..f6e36715f 100644
--- a/crypto/src/openpgp/PgpSecretKey.cs
+++ b/crypto/src/openpgp/PgpSecretKey.cs
@@ -154,9 +154,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
                     }
                 }
             }
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -605,9 +605,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
                 return data;
             }
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -771,9 +771,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
                 return new PgpPrivateKey(KeyId, pubPk, privateKey);
             }
-            catch (PgpException e)
+            catch (PgpException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -1000,9 +1000,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
                         keyData = EncryptKeyDataV3(rawKeyData, newEncAlgorithm, rawNewPassPhrase, clearPassPhrase, rand, out s2k, out iv);
                     }
                 }
-                catch (PgpException e)
+                catch (PgpException)
                 {
-                    throw e;
+                    throw;
                 }
                 catch (Exception e)
                 {
diff --git a/crypto/src/openpgp/PgpUtilities.cs b/crypto/src/openpgp/PgpUtilities.cs
index 17e100bff..82f65bd08 100644
--- a/crypto/src/openpgp/PgpUtilities.cs
+++ b/crypto/src/openpgp/PgpUtilities.cs
@@ -526,9 +526,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
                 return new ArmoredInputStream(inputStream, hasHeaders);
             }
-            catch (IOException e)
+            catch (IOException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/openssl/PEMReader.cs b/crypto/src/openssl/PEMReader.cs
index a2c4fd1d6..cb6950c47 100644
--- a/crypto/src/openssl/PEMReader.cs
+++ b/crypto/src/openssl/PEMReader.cs
@@ -356,9 +356,9 @@ namespace Org.BouncyCastle.OpenSsl
 
                 return new AsymmetricCipherKeyPair(pubSpec, privSpec);
             }
-            catch (IOException e)
+            catch (IOException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/openssl/PEMWriter.cs b/crypto/src/openssl/PEMWriter.cs
index 58b6156d5..504ea9e4b 100644
--- a/crypto/src/openssl/PEMWriter.cs
+++ b/crypto/src/openssl/PEMWriter.cs
@@ -31,7 +31,7 @@ namespace Org.BouncyCastle.OpenSsl
                 if (e.InnerException is IOException inner)
                     throw inner;
 
-                throw e;
+                throw;
             }
 		}
 	}
diff --git a/crypto/src/tls/ClientHello.cs b/crypto/src/tls/ClientHello.cs
index 574264491..ab0125b55 100644
--- a/crypto/src/tls/ClientHello.cs
+++ b/crypto/src/tls/ClientHello.cs
@@ -103,9 +103,9 @@ namespace Org.BouncyCastle.Tls
             {
                 return ImplParse(messageInput, dtlsOutput);
             }
-            catch (TlsFatalAlert e)
+            catch (TlsFatalAlert)
             {
-                throw e;
+                throw;
             }
             catch (IOException e)
             {
diff --git a/crypto/src/tls/DtlsClientProtocol.cs b/crypto/src/tls/DtlsClientProtocol.cs
index 92478dc46..3b32c044e 100644
--- a/crypto/src/tls/DtlsClientProtocol.cs
+++ b/crypto/src/tls/DtlsClientProtocol.cs
@@ -69,12 +69,12 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert fatalAlert)
             {
                 AbortClientHandshake(state, recordLayer, fatalAlert.AlertDescription);
-                throw fatalAlert;
+                throw;
             }
-            catch (IOException e)
+            catch (IOException)
             {
                 AbortClientHandshake(state, recordLayer, AlertDescription.internal_error);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/tls/DtlsRecordLayer.cs b/crypto/src/tls/DtlsRecordLayer.cs
index bab6892b7..3cf04b8ac 100644
--- a/crypto/src/tls/DtlsRecordLayer.cs
+++ b/crypto/src/tls/DtlsRecordLayer.cs
@@ -78,7 +78,7 @@ namespace Org.BouncyCastle.Tls
             //catch (InterruptedIOException e)
             //{
             //    e.bytesTransferred = 0;
-            //    throw e;
+            //    throw;
             //}
 
             sender.Send(buf, off, len);
@@ -578,13 +578,13 @@ namespace Org.BouncyCastle.Tls
                 if (TlsUtilities.IsTimeout(e))
                     return -1;
 
-                throw e;
+                throw;
             }
             // TODO[tls-port] Can we support interrupted IO on .NET?
             //catch (InterruptedIOException e)
             //{
             //    e.bytesTransferred = 0;
-            //    throw e;
+            //    throw;
             //}
         }
 
diff --git a/crypto/src/tls/DtlsServerProtocol.cs b/crypto/src/tls/DtlsServerProtocol.cs
index 43d4e5539..3bf92395b 100644
--- a/crypto/src/tls/DtlsServerProtocol.cs
+++ b/crypto/src/tls/DtlsServerProtocol.cs
@@ -57,12 +57,12 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert fatalAlert)
             {
                 AbortServerHandshake(state, recordLayer, fatalAlert.AlertDescription);
-                throw fatalAlert;
+                throw;
             }
             catch (IOException e)
             {
                 AbortServerHandshake(state, recordLayer, AlertDescription.internal_error);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/tls/DtlsTransport.cs b/crypto/src/tls/DtlsTransport.cs
index 033e0af0b..2d950ede0 100644
--- a/crypto/src/tls/DtlsTransport.cs
+++ b/crypto/src/tls/DtlsTransport.cs
@@ -54,29 +54,29 @@ namespace Org.BouncyCastle.Tls
                     return -1;
 
                 m_recordLayer.Fail(fatalAlert.AlertDescription);
-                throw fatalAlert;
+                throw;
             }
-            catch (TlsTimeoutException e)
+            catch (TlsTimeoutException)
             {
-                throw e;
+                throw;
             }
             catch (SocketException e)
             {
                 if (TlsUtilities.IsTimeout(e))
-                    throw e;
+                    throw;
 
                 m_recordLayer.Fail(AlertDescription.internal_error);
                 throw new TlsFatalAlert(AlertDescription.internal_error, e);
             }
             // TODO[tls-port] Can we support interrupted IO on .NET?
-            //catch (InterruptedIOException e)
+            //catch (InterruptedIOException)
             //{
-            //    throw e;
+            //    throw;
             //}
-            catch (IOException e)
+            catch (IOException)
             {
                 m_recordLayer.Fail(AlertDescription.internal_error);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -103,29 +103,29 @@ namespace Org.BouncyCastle.Tls
                     return -1;
 
                 m_recordLayer.Fail(fatalAlert.AlertDescription);
-                throw fatalAlert;
+                throw;
             }
-            catch (TlsTimeoutException e)
+            catch (TlsTimeoutException)
             {
-                throw e;
+                throw;
             }
             catch (SocketException e)
             {
                 if (TlsUtilities.IsTimeout(e))
-                    throw e;
+                    throw;
 
                 m_recordLayer.Fail(AlertDescription.internal_error);
                 throw new TlsFatalAlert(AlertDescription.internal_error, e);
             }
             // TODO[tls-port] Can we support interrupted IO on .NET?
-            //catch (InterruptedIOException e)
+            //catch (InterruptedIOException)
             //{
-            //    throw e;
+            //    throw;
             //}
-            catch (IOException e)
+            catch (IOException)
             {
                 m_recordLayer.Fail(AlertDescription.internal_error);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -155,29 +155,29 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert fatalAlert)
             {
                 m_recordLayer.Fail(fatalAlert.AlertDescription);
-                throw fatalAlert;
+                throw;
             }
-            catch (TlsTimeoutException e)
+            catch (TlsTimeoutException)
             {
-                throw e;
+                throw;
             }
             catch (SocketException e)
             {
                 if (TlsUtilities.IsTimeout(e))
-                    throw e;
+                    throw;
 
                 m_recordLayer.Fail(AlertDescription.internal_error);
                 throw new TlsFatalAlert(AlertDescription.internal_error, e);
             }
             // TODO[tls-port] Can we support interrupted IO on .NET?
-            //catch (InterruptedIOException e)
+            //catch (InterruptedIOException)
             //{
-            //    throw e;
+            //    throw;
             //}
-            catch (IOException e)
+            catch (IOException)
             {
                 m_recordLayer.Fail(AlertDescription.internal_error);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -197,29 +197,29 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert fatalAlert)
             {
                 m_recordLayer.Fail(fatalAlert.AlertDescription);
-                throw fatalAlert;
+                throw;
             }
-            catch (TlsTimeoutException e)
+            catch (TlsTimeoutException)
             {
-                throw e;
+                throw;
             }
             catch (SocketException e)
             {
                 if (TlsUtilities.IsTimeout(e))
-                    throw e;
+                    throw;
 
                 m_recordLayer.Fail(AlertDescription.internal_error);
                 throw new TlsFatalAlert(AlertDescription.internal_error, e);
             }
             // TODO[tls-port] Can we support interrupted IO on .NET?
-            //catch (InterruptedIOException e)
+            //catch (InterruptedIOException)
             //{
-            //    throw e;
+            //    throw;
             //}
-            catch (IOException e)
+            catch (IOException)
             {
                 m_recordLayer.Fail(AlertDescription.internal_error);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/tls/RecordStream.cs b/crypto/src/tls/RecordStream.cs
index 8dc2a30ce..ed1c8d871 100644
--- a/crypto/src/tls/RecordStream.cs
+++ b/crypto/src/tls/RecordStream.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Diagnostics;
 using System.IO;
+using System.Runtime.ExceptionServices;
 
 using Org.BouncyCastle.Tls.Crypto;
 using Org.BouncyCastle.Utilities;
@@ -356,14 +357,14 @@ namespace Org.BouncyCastle.Tls
         {
             m_inputRecord.Reset();
 
-            IOException io = null;
+            ExceptionDispatchInfo io = null;
             try
             {
                 m_input.Dispose();
             }
             catch (IOException e)
             {
-                io = e;
+                io = ExceptionDispatchInfo.Capture(e);
             }
 
             try
@@ -374,7 +375,7 @@ namespace Org.BouncyCastle.Tls
             {
                 if (io == null)
                 {
-                    io = e;
+                    io = ExceptionDispatchInfo.Capture(e);
                 }
                 else
                 {
@@ -383,8 +384,7 @@ namespace Org.BouncyCastle.Tls
                 }
             }
 
-            if (io != null)
-                throw io;
+            io?.Throw();
         }
 
         /// <exception cref="IOException"/>
diff --git a/crypto/src/tls/TlsProtocol.cs b/crypto/src/tls/TlsProtocol.cs
index 92322e949..55fb9f745 100644
--- a/crypto/src/tls/TlsProtocol.cs
+++ b/crypto/src/tls/TlsProtocol.cs
@@ -782,12 +782,12 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert e)
             {
                 HandleException(e.AlertDescription, "Failed to read record", e);
-                throw e;
+                throw;
             }
             catch (IOException e)
             {
                 HandleException(AlertDescription.internal_error, "Failed to read record", e);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -813,20 +813,20 @@ namespace Org.BouncyCastle.Tls
                     return;
                 }
             }
-            catch (TlsFatalAlertReceived e)
+            catch (TlsFatalAlertReceived)
             {
                 // Connection failure already handled at source
-                throw e;
+                throw;
             }
             catch (TlsFatalAlert e)
             {
                 HandleException(e.AlertDescription, "Failed to read record", e);
-                throw e;
+                throw;
             }
             catch (IOException e)
             {
                 HandleException(AlertDescription.internal_error, "Failed to read record", e);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -849,12 +849,12 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert e)
             {
                 HandleException(e.AlertDescription, "Failed to process record", e);
-                throw e;
+                throw;
             }
             catch (IOException e)
             {
                 HandleException(AlertDescription.internal_error, "Failed to process record", e);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -873,12 +873,12 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert e)
             {
                 HandleException(e.AlertDescription, "Failed to write record", e);
-                throw e;
+                throw;
             }
             catch (IOException e)
             {
                 HandleException(AlertDescription.internal_error, "Failed to write record", e);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -898,12 +898,12 @@ namespace Org.BouncyCastle.Tls
             catch (TlsFatalAlert e)
             {
                 HandleException(e.AlertDescription, "Failed to write record", e);
-                throw e;
+                throw;
             }
             catch (IOException e)
             {
                 HandleException(AlertDescription.internal_error, "Failed to write record", e);
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/tls/TlsUtilities.cs b/crypto/src/tls/TlsUtilities.cs
index 0d2a971a0..a2ee82f9e 100644
--- a/crypto/src/tls/TlsUtilities.cs
+++ b/crypto/src/tls/TlsUtilities.cs
@@ -2288,9 +2288,9 @@ namespace Org.BouncyCastle.Tls
                     verified = verifier.VerifyRawSignature(certificateVerify, hash);
                 }
             }
-            catch (TlsFatalAlert e)
+            catch (TlsFatalAlert )
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -2353,9 +2353,9 @@ namespace Org.BouncyCastle.Tls
                 output.Write(prfHash, 0, prfHash.Length);
                 verified = verifier.VerifySignature(certificateVerify.Signature);
             }
-            catch (TlsFatalAlert e)
+            catch (TlsFatalAlert)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/tls/crypto/impl/TlsAeadCipher.cs b/crypto/src/tls/crypto/impl/TlsAeadCipher.cs
index 594981210..8525c2fe9 100644
--- a/crypto/src/tls/crypto/impl/TlsAeadCipher.cs
+++ b/crypto/src/tls/crypto/impl/TlsAeadCipher.cs
@@ -217,9 +217,9 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl
                 outputPos += m_encryptCipher.DoFinal(output, outputPos, plaintextLength + extraLength, output,
                     outputPos);
             }
-            catch (IOException e)
+            catch (IOException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -292,9 +292,9 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl
                 outputPos += m_encryptCipher.DoFinal(output, outputPos, plaintext.Length + extraLength, output,
                     outputPos);
             }
-            catch (IOException e)
+            catch (IOException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
@@ -357,11 +357,11 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl
                 {
                     m_decryptCipher.Reset();
                 }
-                throw fatalAlert;
+                throw;
             }
-            catch (IOException e)
+            catch (IOException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/tls/crypto/impl/bc/BcTlsECDomain.cs b/crypto/src/tls/crypto/impl/bc/BcTlsECDomain.cs
index ab3481924..89607b35a 100644
--- a/crypto/src/tls/crypto/impl/bc/BcTlsECDomain.cs
+++ b/crypto/src/tls/crypto/impl/bc/BcTlsECDomain.cs
@@ -91,9 +91,9 @@ namespace Org.BouncyCastle.Tls.Crypto.Impl.BC
 
                 return new ECPublicKeyParameters(point, m_domainParameters);
             }
-            catch (IOException e)
+            catch (IOException)
             {
-                throw e;
+                throw;
             }
             catch (Exception e)
             {
diff --git a/crypto/src/x509/X509AttrCertParser.cs b/crypto/src/x509/X509AttrCertParser.cs
index 0019a48eb..39727a0e2 100644
--- a/crypto/src/x509/X509AttrCertParser.cs
+++ b/crypto/src/x509/X509AttrCertParser.cs
@@ -141,6 +141,10 @@ namespace Org.BouncyCastle.X509
 
 				return ReadDerCertificate(new Asn1InputStream(inStream));
 			}
+			catch (CertificateException)
+			{
+				throw;
+			}
 			catch (Exception e)
 			{
 				throw new CertificateException(e.ToString());
diff --git a/crypto/src/x509/X509CertPairParser.cs b/crypto/src/x509/X509CertPairParser.cs
index 95ba522c8..d8ecd9ddf 100644
--- a/crypto/src/x509/X509CertPairParser.cs
+++ b/crypto/src/x509/X509CertPairParser.cs
@@ -74,6 +74,10 @@ namespace Org.BouncyCastle.X509
 
                 return ReadDerCrossCertificatePair(inStream);
 			}
+			catch (CertificateException)
+			{
+				throw;
+			}
 			catch (Exception e)
 			{
 				throw new CertificateException(e.ToString());
diff --git a/crypto/src/x509/X509CertificateParser.cs b/crypto/src/x509/X509CertificateParser.cs
index 6fc1b3ff4..2d6da0f23 100644
--- a/crypto/src/x509/X509CertificateParser.cs
+++ b/crypto/src/x509/X509CertificateParser.cs
@@ -143,6 +143,10 @@ namespace Org.BouncyCastle.X509
 					return ReadDerCertificate(asn1In);
 				}
 			}
+			catch (CertificateException)
+			{
+				throw;
+			}
 			catch (Exception e)
 			{
 				throw new CertificateException("Failed to read certificate", e);
diff --git a/crypto/src/x509/X509CrlParser.cs b/crypto/src/x509/X509CrlParser.cs
index 53a02393b..040943104 100644
--- a/crypto/src/x509/X509CrlParser.cs
+++ b/crypto/src/x509/X509CrlParser.cs
@@ -138,9 +138,9 @@ namespace Org.BouncyCastle.X509
                     return ReadDerCrl(asn1);
                 }
             }
-			catch (CrlException e)
+			catch (CrlException)
 			{
-				throw e;
+				throw;
 			}
 			catch (Exception e)
 			{
diff --git a/crypto/src/x509/X509V2AttributeCertificate.cs b/crypto/src/x509/X509V2AttributeCertificate.cs
index b5a316d76..836213fdc 100644
--- a/crypto/src/x509/X509V2AttributeCertificate.cs
+++ b/crypto/src/x509/X509V2AttributeCertificate.cs
@@ -27,9 +27,9 @@ namespace Org.BouncyCastle.X509
 			{
 				return AttributeCertificate.GetInstance(Asn1Object.FromStream(input));
 			}
-			catch (IOException e)
+			catch (IOException)
 			{
-				throw e;
+				throw;
 			}
 			catch (Exception e)
 			{
diff --git a/crypto/test/src/math/test/PrimesTest.cs b/crypto/test/src/math/test/PrimesTest.cs
index 4456ef2c1..6854e160b 100644
--- a/crypto/test/src/math/test/PrimesTest.cs
+++ b/crypto/test/src/math/test/PrimesTest.cs
@@ -142,7 +142,7 @@ namespace Org.BouncyCastle.Math.Tests
                             continue;
                         }
 
-                        throw e;
+                        throw;
                     }
                 }
 
diff --git a/crypto/test/src/test/BaseBlockCipherTest.cs b/crypto/test/src/test/BaseBlockCipherTest.cs
index 87fb01056..aca912131 100644
--- a/crypto/test/src/test/BaseBlockCipherTest.cs
+++ b/crypto/test/src/test/BaseBlockCipherTest.cs
@@ -115,9 +115,9 @@ namespace Org.BouncyCastle.Tests
 						+ Hex.ToHexString(cText));
 				}
 			}
-			catch (TestFailedException e)
+			catch (TestFailedException)
 			{
-				throw e;
+				throw;
 			}
 			catch (Exception e)
 			{
diff --git a/crypto/test/src/test/PkixPolicyMappingTest.cs b/crypto/test/src/test/PkixPolicyMappingTest.cs
index 4dbfe0ad5..66e09309c 100644
--- a/crypto/test/src/test/PkixPolicyMappingTest.cs
+++ b/crypto/test/src/test/PkixPolicyMappingTest.cs
@@ -144,9 +144,9 @@ namespace Org.BouncyCastle.Tests
 
 				return "";
 			}
-			catch (TestFailedException e)
+			catch (TestFailedException)
 			{
-				throw e;
+				throw;
 			}
 			catch (Exception e)
 			{