summary refs log tree commit diff
path: root/crypto/src/tls
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/src/tls
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/src/tls')
-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
10 files changed, 72 insertions, 72 deletions
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)
             {