summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-24 15:07:29 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-24 15:07:29 +0700
commitb72579c4b1200459f959bcd6a25364e239420573 (patch)
tree5e566cc2b7972cd8ccebece92d879bddc800393d
parentRemove certpath from PkixCertPathValidatorException (diff)
downloadBouncyCastle.NET-ed25519-b72579c4b1200459f959bcd6a25364e239420573.tar.xz
Cleanup Exception classes
-rw-r--r--crypto/src/asn1/Asn1Exception.cs17
-rw-r--r--crypto/src/asn1/Asn1ParsingException.cs17
-rw-r--r--crypto/src/bcpg/UnsupportedPacketVersionException.cs25
-rw-r--r--crypto/src/cmp/CmpException.cs8
-rw-r--r--crypto/src/cms/CMSAttributeTableGenerationException.cs34
-rw-r--r--crypto/src/cms/CMSException.cs20
-rw-r--r--crypto/src/cms/CMSStreamException.cs30
-rw-r--r--crypto/src/crmf/CrmfException.cs34
-rw-r--r--crypto/src/crypto/CryptoException.cs34
-rw-r--r--crypto/src/crypto/DataLengthException.cs51
-rw-r--r--crypto/src/crypto/InvalidCipherTextException.cs47
-rw-r--r--crypto/src/crypto/MaxBytesExceededException.cs23
-rw-r--r--crypto/src/crypto/OutputLengthException.cs36
-rw-r--r--crypto/src/ocsp/OCSPException.cs18
-rw-r--r--crypto/src/openpgp/PgpDataValidationException.cs29
-rw-r--r--crypto/src/openpgp/PgpException.cs27
-rw-r--r--crypto/src/openpgp/PgpKeyValidationException.cs29
-rw-r--r--crypto/src/openssl/EncryptionException.cs22
-rw-r--r--crypto/src/openssl/PEMException.cs22
-rw-r--r--crypto/src/openssl/PasswordException.cs22
-rw-r--r--crypto/src/pkcs/PkcsException.cs36
-rw-r--r--crypto/src/pkcs/PkcsIOException.cs35
-rw-r--r--crypto/src/pkix/PkixCertPathBuilderException.cs32
-rw-r--r--crypto/src/pkix/PkixCertPathValidatorException.cs10
-rw-r--r--crypto/src/pkix/PkixNameConstraintValidatorException.cs26
-rw-r--r--crypto/src/pqc/crypto/lms/LMSException.cs34
-rw-r--r--crypto/src/security/GeneralSecurityException.cs4
-rw-r--r--crypto/src/security/InvalidKeyException.cs28
-rw-r--r--crypto/src/security/InvalidParameterException.cs28
-rw-r--r--crypto/src/security/KeyException.cs28
-rw-r--r--crypto/src/security/SecurityUtilityException.cs42
-rw-r--r--crypto/src/security/SignatureException.cs28
-rw-r--r--crypto/src/security/cert/CertificateEncodingException.cs28
-rw-r--r--crypto/src/security/cert/CertificateException.cs28
-rw-r--r--crypto/src/security/cert/CertificateExpiredException.cs28
-rw-r--r--crypto/src/security/cert/CertificateNotYetValidException.cs28
-rw-r--r--crypto/src/security/cert/CertificateParsingException.cs28
-rw-r--r--crypto/src/security/cert/CrlException.cs28
-rw-r--r--crypto/src/tls/TlsException.cs35
-rw-r--r--crypto/src/tls/TlsFatalAlert.cs7
-rw-r--r--crypto/src/tls/TlsFatalAlertReceived.cs7
-rw-r--r--crypto/src/tls/TlsNoCloseNotifyException.cs9
-rw-r--r--crypto/src/tls/TlsTimeoutException.cs35
-rw-r--r--crypto/src/tls/crypto/TlsCryptoException.cs34
-rw-r--r--crypto/src/tsp/TSPException.cs18
-rw-r--r--crypto/src/tsp/TSPValidationException.cs21
-rw-r--r--crypto/src/util/MemoableResetException.cs35
-rw-r--r--crypto/src/util/io/StreamOverflowException.cs17
-rw-r--r--crypto/src/util/io/pem/PemGenerationException.cs17
-rw-r--r--crypto/src/x509/store/NoSuchStoreException.cs18
-rw-r--r--crypto/src/x509/store/X509StoreException.cs18
-rw-r--r--crypto/test/src/util/test/SimpleTest.cs2
-rw-r--r--crypto/test/src/util/test/TestFailedException.cs15
53 files changed, 846 insertions, 486 deletions
diff --git a/crypto/src/asn1/Asn1Exception.cs b/crypto/src/asn1/Asn1Exception.cs
index 9e4afb49f..ae89bbcdc 100644
--- a/crypto/src/asn1/Asn1Exception.cs
+++ b/crypto/src/asn1/Asn1Exception.cs
@@ -1,11 +1,10 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Asn1
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class Asn1Exception
 		: IOException
 	{
@@ -14,16 +13,18 @@ namespace Org.BouncyCastle.Asn1
 		{
 		}
 
-		public Asn1Exception(
-			string message)
+		public Asn1Exception(string message)
 			: base(message)
 		{
 		}
 
-		public Asn1Exception(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public Asn1Exception(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected Asn1Exception(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/asn1/Asn1ParsingException.cs b/crypto/src/asn1/Asn1ParsingException.cs
index 294e4c2c9..2b54ae0a1 100644
--- a/crypto/src/asn1/Asn1ParsingException.cs
+++ b/crypto/src/asn1/Asn1ParsingException.cs
@@ -1,10 +1,9 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Asn1
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class Asn1ParsingException
 		: InvalidOperationException
 	{
@@ -13,16 +12,18 @@ namespace Org.BouncyCastle.Asn1
 		{
 		}
 
-		public Asn1ParsingException(
-			string message)
+		public Asn1ParsingException(string message)
 			: base(message)
 		{
 		}
 
-		public Asn1ParsingException(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public Asn1ParsingException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected Asn1ParsingException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/bcpg/UnsupportedPacketVersionException.cs b/crypto/src/bcpg/UnsupportedPacketVersionException.cs
index 447d75286..d59404f7a 100644
--- a/crypto/src/bcpg/UnsupportedPacketVersionException.cs
+++ b/crypto/src/bcpg/UnsupportedPacketVersionException.cs
@@ -1,13 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Bcpg
 {
+    [Serializable]
     public class UnsupportedPacketVersionException
         : Exception
     {
-        public UnsupportedPacketVersionException(string msg)
-            : base(msg)
-        {
-        }
+		public UnsupportedPacketVersionException()
+			: base()
+		{
+		}
+
+		public UnsupportedPacketVersionException(string message)
+			: base(message)
+		{
+		}
+
+		public UnsupportedPacketVersionException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected UnsupportedPacketVersionException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
     }
 }
diff --git a/crypto/src/cmp/CmpException.cs b/crypto/src/cmp/CmpException.cs
index 6594e8f2a..6d3271a20 100644
--- a/crypto/src/cmp/CmpException.cs
+++ b/crypto/src/cmp/CmpException.cs
@@ -1,11 +1,14 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Cmp
 {
+    [Serializable]
     public class CmpException
         : Exception
     {
         public CmpException()
+            : base()
         {
         }
 
@@ -18,5 +21,10 @@ namespace Org.BouncyCastle.Cmp
             : base(message, innerException)
         {
         }
+
+        protected CmpException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+        }
     }
 }
diff --git a/crypto/src/cms/CMSAttributeTableGenerationException.cs b/crypto/src/cms/CMSAttributeTableGenerationException.cs
index 692be2804..977d60e5c 100644
--- a/crypto/src/cms/CMSAttributeTableGenerationException.cs
+++ b/crypto/src/cms/CMSAttributeTableGenerationException.cs
@@ -1,28 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Cms
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class CmsAttributeTableGenerationException
 		: CmsException
 	{
-		public CmsAttributeTableGenerationException()
-		{
-		}
+        public CmsAttributeTableGenerationException()
+            : base()
+        {
+        }
 
-		public CmsAttributeTableGenerationException(
-			string name)
-			: base(name)
-		{
-		}
+        public CmsAttributeTableGenerationException(string message)
+            : base(message)
+        {
+        }
 
-		public CmsAttributeTableGenerationException(
-			string		name,
-			Exception	e)
-			: base(name, e)
-		{
-		}
+        public CmsAttributeTableGenerationException(string message, Exception innerException)
+            : base(message, innerException)
+        {
+        }
+
+        protected CmsAttributeTableGenerationException(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+        }
 	}
 }
diff --git a/crypto/src/cms/CMSException.cs b/crypto/src/cms/CMSException.cs
index 83de3f00e..eab32f916 100644
--- a/crypto/src/cms/CMSException.cs
+++ b/crypto/src/cms/CMSException.cs
@@ -1,27 +1,29 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Cms
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class CmsException
 		: Exception
 	{
 		public CmsException()
+			: base()
 		{
 		}
 
-		public CmsException(
-			string msg)
-			: base(msg)
+		public CmsException(string message)
+			: base(message)
 		{
 		}
 
-		public CmsException(
-			string		msg,
-			Exception	e)
-			: base(msg, e)
+		public CmsException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CmsException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/cms/CMSStreamException.cs b/crypto/src/cms/CMSStreamException.cs
index c3b0f9621..42ae409f7 100644
--- a/crypto/src/cms/CMSStreamException.cs
+++ b/crypto/src/cms/CMSStreamException.cs
@@ -1,29 +1,31 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Cms
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class CmsStreamException
         : IOException
     {
 		public CmsStreamException()
+			: base()
 		{
 		}
 
-		public CmsStreamException(
-			string name)
-			: base(name)
-        {
-        }
+		public CmsStreamException(string message)
+			: base(message)
+		{
+		}
 
-		public CmsStreamException(
-			string		name,
-			Exception	e)
-			: base(name, e)
-        {
-        }
-    }
+		public CmsStreamException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CmsStreamException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/crmf/CrmfException.cs b/crypto/src/crmf/CrmfException.cs
index 5ae13a0eb..9b1597400 100644
--- a/crypto/src/crmf/CrmfException.cs
+++ b/crypto/src/crmf/CrmfException.cs
@@ -1,22 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Crmf
 {
-    public class CrmfException
+	[Serializable]
+	public class CrmfException
         : Exception
     {
-        public CrmfException()
-        {
-        }
+		public CrmfException()
+			: base()
+		{
+		}
 
-        public CrmfException(string message)
-            : base(message)
-        {
-        }
+		public CrmfException(string message)
+			: base(message)
+		{
+		}
 
-        public CrmfException(string message, Exception innerException)
-            : base(message, innerException)
-        {
-        }
-    }
+		public CrmfException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CrmfException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/crypto/CryptoException.cs b/crypto/src/crypto/CryptoException.cs
index c5ee938c7..e40cfbc04 100644
--- a/crypto/src/crypto/CryptoException.cs
+++ b/crypto/src/crypto/CryptoException.cs
@@ -1,28 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Crypto
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class CryptoException
 		: Exception
     {
-        public CryptoException()
-        {
-        }
+		public CryptoException()
+			: base()
+		{
+		}
 
-		public CryptoException(
-            string message)
+		public CryptoException(string message)
 			: base(message)
-        {
-        }
+		{
+		}
 
-		public CryptoException(
-            string		message,
-            Exception	exception)
-			: base(message, exception)
-        {
-        }
-    }
+		public CryptoException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CryptoException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/crypto/DataLengthException.cs b/crypto/src/crypto/DataLengthException.cs
index 5dde879d1..909639144 100644
--- a/crypto/src/crypto/DataLengthException.cs
+++ b/crypto/src/crypto/DataLengthException.cs
@@ -1,42 +1,35 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Crypto
 {
-    /**
-     * this exception is thrown if a buffer that is meant to have output
-     * copied into it turns out to be too short, or if we've been given
-     * insufficient input. In general this exception will Get thrown rather
-     * than an ArrayOutOfBounds exception.
-     */
-#if !PORTABLE
-    [Serializable]
-#endif
+	/// <summary>This exception is thrown if a buffer that is meant to have output copied into it turns out to be too
+	/// short, or if we've been given insufficient input.</summary>
+	/// <remarks>
+	/// In general this exception will get thrown rather than an <see cref="IndexOutOfRangeException"/>.
+	/// </remarks>
+	[Serializable]
     public class DataLengthException
 		: CryptoException
 	{
-        /**
-        * base constructor.
-		*/
-        public DataLengthException()
-        {
-        }
+		public DataLengthException()
+			: base()
+		{
+		}
 
-		/**
-         * create a DataLengthException with the given message.
-         *
-         * @param message the message to be carried with the exception.
-         */
-        public DataLengthException(
-            string message)
+		public DataLengthException(string message)
 			: base(message)
-        {
+		{
+		}
+
+		public DataLengthException(string message, Exception innerException)
+			: base(message, innerException)
+		{
 		}
 
-		public DataLengthException(
-            string		message,
-            Exception	exception)
-			: base(message, exception)
-        {
-        }
+		protected DataLengthException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/crypto/InvalidCipherTextException.cs b/crypto/src/crypto/InvalidCipherTextException.cs
index 760ef3206..13ac86763 100644
--- a/crypto/src/crypto/InvalidCipherTextException.cs
+++ b/crypto/src/crypto/InvalidCipherTextException.cs
@@ -1,40 +1,31 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Crypto
 {
-    /**
-     * this exception is thrown whenever we find something we don't expect in a
-     * message.
-     */
-#if !PORTABLE
+	 /// <summary>This exception is thrown whenever we find something we don't expect in a message.</summary>
     [Serializable]
-#endif
     public class InvalidCipherTextException
 		: CryptoException
     {
-		/**
-		* base constructor.
-		*/
-        public InvalidCipherTextException()
-        {
-        }
+		public InvalidCipherTextException()
+			: base()
+		{
+		}
 
-		/**
-         * create a InvalidCipherTextException with the given message.
-         *
-         * @param message the message to be carried with the exception.
-         */
-        public InvalidCipherTextException(
-            string message)
+		public InvalidCipherTextException(string message)
 			: base(message)
-        {
-        }
+		{
+		}
 
-		public InvalidCipherTextException(
-            string		message,
-            Exception	exception)
-			: base(message, exception)
-        {
-        }
-    }
+		public InvalidCipherTextException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected InvalidCipherTextException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/crypto/MaxBytesExceededException.cs b/crypto/src/crypto/MaxBytesExceededException.cs
index 032901c1d..b83b16fd4 100644
--- a/crypto/src/crypto/MaxBytesExceededException.cs
+++ b/crypto/src/crypto/MaxBytesExceededException.cs
@@ -1,31 +1,32 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Crypto
 {
-	/// <summary>
-	/// This exception is thrown whenever a cipher requires a change of key, iv
-	/// or similar after x amount of bytes enciphered
+	/// <summary>This exception is thrown whenever a cipher requires a change of key, IV or similar after x amount of
+	/// bytes enciphered.
 	/// </summary>
-#if !PORTABLE
     [Serializable]
-#endif
     public class MaxBytesExceededException
 		: CryptoException
 	{
 		public MaxBytesExceededException()
+			: base()
 		{
 		}
 
-		public MaxBytesExceededException(
-			string message)
+		public MaxBytesExceededException(string message)
 			: base(message)
 		{
 		}
 
-		public MaxBytesExceededException(
-			string		message,
-			Exception	e)
-			: base(message, e)
+		public MaxBytesExceededException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected MaxBytesExceededException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/crypto/OutputLengthException.cs b/crypto/src/crypto/OutputLengthException.cs
index 5f091f2ec..c8b2718f2 100644
--- a/crypto/src/crypto/OutputLengthException.cs
+++ b/crypto/src/crypto/OutputLengthException.cs
@@ -1,28 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Crypto
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class OutputLengthException
         : DataLengthException
     {
-        public OutputLengthException()
-        {
-        }
+		public OutputLengthException()
+			: base()
+		{
+		}
 
-        public OutputLengthException(
-            string message)
-            : base(message)
-        {
-        }
+		public OutputLengthException(string message)
+			: base(message)
+		{
+		}
 
-        public OutputLengthException(
-            string message,
-            Exception exception)
-            : base(message, exception)
-        {
-        }
-    }
+		public OutputLengthException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected OutputLengthException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/ocsp/OCSPException.cs b/crypto/src/ocsp/OCSPException.cs
index 5ec11fbf7..c575660c5 100644
--- a/crypto/src/ocsp/OCSPException.cs
+++ b/crypto/src/ocsp/OCSPException.cs
@@ -1,27 +1,29 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Ocsp
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class OcspException
 		: Exception
 	{
 		public OcspException()
+			: base()
 		{
 		}
 
-		public OcspException(
-			string message)
+		public OcspException(string message)
 			: base(message)
 		{
 		}
 
-		public OcspException(
-			string		message,
-			Exception	e)
-			: base(message, e)
+		public OcspException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected OcspException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/openpgp/PgpDataValidationException.cs b/crypto/src/openpgp/PgpDataValidationException.cs
index cec5c9b68..7718ab26c 100644
--- a/crypto/src/openpgp/PgpDataValidationException.cs
+++ b/crypto/src/openpgp/PgpDataValidationException.cs
@@ -1,18 +1,31 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Bcpg.OpenPgp
 {
-	/// <remarks>
-	/// Thrown if the IV at the start of a data stream indicates the wrong key is being used.
-	/// </remarks>
-#if !PORTABLE
+	/// <summary>Thrown if the IV at the start of a data stream indicates the wrong key is being used.</summary>
     [Serializable]
-#endif
     public class PgpDataValidationException
         : PgpException
 	{
-		public PgpDataValidationException() : base() {}
-		public PgpDataValidationException(string message) : base(message) {}
-		public PgpDataValidationException(string message, Exception exception) : base(message, exception) {}
+		public PgpDataValidationException()
+			: base()
+		{
+		}
+
+		public PgpDataValidationException(string message)
+			: base(message)
+		{
+		}
+
+		public PgpDataValidationException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PgpDataValidationException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/openpgp/PgpException.cs b/crypto/src/openpgp/PgpException.cs
index dc0f3482b..cb5ea3569 100644
--- a/crypto/src/openpgp/PgpException.cs
+++ b/crypto/src/openpgp/PgpException.cs
@@ -1,16 +1,31 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Bcpg.OpenPgp
 {
-	/// <remarks>Generic exception class for PGP encoding/decoding problems.</remarks>
-#if !PORTABLE
+	/// <summary>Generic exception class for PGP encoding/decoding problems.</summary>
     [Serializable]
-#endif
     public class PgpException
 		: Exception
 	{
-		public PgpException() : base() {}
-		public PgpException(string message) : base(message) {}
-		public PgpException(string message, Exception exception) : base(message, exception) {}
+		public PgpException()
+			: base()
+		{
+		}
+
+		public PgpException(string message)
+			: base(message)
+		{
+		}
+
+		public PgpException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PgpException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/openpgp/PgpKeyValidationException.cs b/crypto/src/openpgp/PgpKeyValidationException.cs
index df6abefe8..655c0a766 100644
--- a/crypto/src/openpgp/PgpKeyValidationException.cs
+++ b/crypto/src/openpgp/PgpKeyValidationException.cs
@@ -1,18 +1,31 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Bcpg.OpenPgp
 {
-	/// <remarks>
-	/// Thrown if the key checksum is invalid.
-	/// </remarks>
-#if !PORTABLE
+	/// <summary>Thrown if the key checksum is invalid.</summary>
     [Serializable]
-#endif
     public class PgpKeyValidationException
 		: PgpException
 	{
-		public PgpKeyValidationException() : base() {}
-		public PgpKeyValidationException(string message) : base(message) {}
-		public PgpKeyValidationException(string message, Exception exception) : base(message, exception) {}
+		public PgpKeyValidationException()
+			: base()
+		{
+		}
+
+		public PgpKeyValidationException(string message)
+			: base(message)
+		{
+		}
+
+		public PgpKeyValidationException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PgpKeyValidationException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/openssl/EncryptionException.cs b/crypto/src/openssl/EncryptionException.cs
index c17eb99c4..414f8f68b 100644
--- a/crypto/src/openssl/EncryptionException.cs
+++ b/crypto/src/openssl/EncryptionException.cs
@@ -1,24 +1,30 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class EncryptionException
 		: IOException
 	{
-		public EncryptionException(
-			string message)
+		public EncryptionException()
+			: base()
+		{
+		}
+
+		public EncryptionException(string message)
 			: base(message)
 		{
 		}
 
-		public EncryptionException(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public EncryptionException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected EncryptionException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/openssl/PEMException.cs b/crypto/src/openssl/PEMException.cs
index 3d51d799e..c4314b498 100644
--- a/crypto/src/openssl/PEMException.cs
+++ b/crypto/src/openssl/PEMException.cs
@@ -1,24 +1,30 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.OpenSsl
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class PemException
 		: IOException
 	{
-		public PemException(
-			string message)
+		public PemException()
+			: base()
+		{
+		}
+
+		public PemException(string message)
 			: base(message)
 		{
 		}
 
-		public PemException(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public PemException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PemException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/openssl/PasswordException.cs b/crypto/src/openssl/PasswordException.cs
index c920cc7a8..d056bb9b0 100644
--- a/crypto/src/openssl/PasswordException.cs
+++ b/crypto/src/openssl/PasswordException.cs
@@ -1,24 +1,30 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class PasswordException
 		: IOException
 	{
-		public PasswordException(
-			string message)
+		public PasswordException()
+			: base()
+		{
+		}
+
+		public PasswordException(string message)
 			: base(message)
 		{
 		}
 
-		public PasswordException(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public PasswordException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PasswordException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/pkcs/PkcsException.cs b/crypto/src/pkcs/PkcsException.cs
index 7a69ff736..ba296882c 100644
--- a/crypto/src/pkcs/PkcsException.cs
+++ b/crypto/src/pkcs/PkcsException.cs
@@ -1,21 +1,31 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Pkcs
 {
-    /// <summary>
-    /// Base exception for PKCS related issues.
-    /// </summary>
-    public class PkcsException
+	/// <summary>Base exception for PKCS related issues.</summary>
+	[Serializable]
+	public class PkcsException
         : Exception
     {
-        public PkcsException(string message)
-            : base(message)
-        {
-        }
+		public PkcsException()
+			: base()
+		{
+		}
 
-        public PkcsException(string message, Exception underlying)
-            : base(message, underlying)
-        {
-        }
-    }
+		public PkcsException(string message)
+			: base(message)
+		{
+		}
+
+		public PkcsException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PkcsException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/pkcs/PkcsIOException.cs b/crypto/src/pkcs/PkcsIOException.cs
index 889b0fcb0..4523ac286 100644
--- a/crypto/src/pkcs/PkcsIOException.cs
+++ b/crypto/src/pkcs/PkcsIOException.cs
@@ -1,19 +1,32 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Pkcs
 {
-    /// <summary>
-    /// Base exception for parsing related issues in the PKCS namespace.
-    /// </summary>
-    public class PkcsIOException: IOException
+	/// <summary>Base exception for parsing related issues in the PKCS namespace.</summary>
+	[Serializable]
+	public class PkcsIOException
+		: IOException
     {
-        public PkcsIOException(string message) : base(message)
-        {
-        }
+		public PkcsIOException()
+			: base()
+		{
+		}
 
-        public PkcsIOException(string message, Exception underlying) : base(message, underlying)
-        {
-        }
-    }
+		public PkcsIOException(string message)
+			: base(message)
+		{
+		}
+
+		public PkcsIOException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PkcsIOException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/pkix/PkixCertPathBuilderException.cs b/crypto/src/pkix/PkixCertPathBuilderException.cs
index 46845d287..81c833459 100644
--- a/crypto/src/pkix/PkixCertPathBuilderException.cs
+++ b/crypto/src/pkix/PkixCertPathBuilderException.cs
@@ -1,22 +1,32 @@
 using System;
+using System.Runtime.Serialization;
 
 using Org.BouncyCastle.Security;
 
 namespace Org.BouncyCastle.Pkix
 {
-	/// <summary>
-	/// Summary description for PkixCertPathBuilderException.
-	/// </summary>
-#if !PORTABLE
     [Serializable]
-#endif
-    public class PkixCertPathBuilderException : GeneralSecurityException
+    public class PkixCertPathBuilderException
+		: GeneralSecurityException
 	{
-		public PkixCertPathBuilderException() : base() { }
-		
-		public PkixCertPathBuilderException(string message) : base(message)	{ }  
+		public PkixCertPathBuilderException()
+			: base()
+		{
+		}
 
-		public PkixCertPathBuilderException(string message, Exception exception) : base(message, exception) { }
-		
+		public PkixCertPathBuilderException(string message)
+			: base(message)
+		{
+		}
+
+		public PkixCertPathBuilderException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PkixCertPathBuilderException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/pkix/PkixCertPathValidatorException.cs b/crypto/src/pkix/PkixCertPathValidatorException.cs
index f2152bcd3..effb60569 100644
--- a/crypto/src/pkix/PkixCertPathValidatorException.cs
+++ b/crypto/src/pkix/PkixCertPathValidatorException.cs
@@ -45,8 +45,8 @@ namespace Org.BouncyCastle.Pkix
 		{
 		}
 
-		public PkixCertPathValidatorException(string message, Exception exception)
-			: base(message, exception)
+		public PkixCertPathValidatorException(string message, Exception innerException)
+			: base(message, innerException)
 		{
 		}
 
@@ -55,10 +55,10 @@ namespace Org.BouncyCastle.Pkix
 		/// detail message, cause, certification path, and index.
 		/// </summary>
 		/// <param name="message">the detail message (or <code>null</code> if none)</param>
-		/// <param name="exception">the cause (or <code>null</code> if none)</param>
+		/// <param name="innerException">the cause (or <code>null</code> if none)</param>
 		/// <param name="index">the index of the certificate in the certification path that</param>																																																																																   * 
-		public PkixCertPathValidatorException(string message, Exception exception, int index)
-			: base(message, exception)
+		public PkixCertPathValidatorException(string message, Exception innerException, int index)
+			: base(message, innerException)
 		{
 			if (index < -1)
 				throw new ArgumentException("cannot be < -1", nameof(index));
diff --git a/crypto/src/pkix/PkixNameConstraintValidatorException.cs b/crypto/src/pkix/PkixNameConstraintValidatorException.cs
index d0882ca96..c67123506 100644
--- a/crypto/src/pkix/PkixNameConstraintValidatorException.cs
+++ b/crypto/src/pkix/PkixNameConstraintValidatorException.cs
@@ -1,16 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Pkix
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class PkixNameConstraintValidatorException
         : Exception
     {
-        public PkixNameConstraintValidatorException(string msg)
-            : base(msg)
-        {
-        }
+		public PkixNameConstraintValidatorException()
+			: base()
+		{
+		}
+
+		public PkixNameConstraintValidatorException(string message)
+			: base(message)
+		{
+		}
+
+		public PkixNameConstraintValidatorException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PkixNameConstraintValidatorException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
     }
 }
diff --git a/crypto/src/pqc/crypto/lms/LMSException.cs b/crypto/src/pqc/crypto/lms/LMSException.cs
index 5f8f7b9d9..c9c286b7f 100644
--- a/crypto/src/pqc/crypto/lms/LMSException.cs
+++ b/crypto/src/pqc/crypto/lms/LMSException.cs
@@ -1,22 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Pqc.Crypto.Lms
 {
+    [Serializable]
     public class LMSException
         : Exception
     {
-        public LMSException()
-        {
-        }
+		public LMSException()
+			: base()
+		{
+		}
 
-        public LMSException(string message)
-            : base(message)
-        {
-        }
+		public LMSException(string message)
+			: base(message)
+		{
+		}
 
-        public LMSException(string message, Exception cause)
-            : base(message, cause)
-        {
-        }
-    }
-}
\ No newline at end of file
+		public LMSException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected LMSException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
+}
diff --git a/crypto/src/security/GeneralSecurityException.cs b/crypto/src/security/GeneralSecurityException.cs
index 33fd2e543..02b1f6c57 100644
--- a/crypto/src/security/GeneralSecurityException.cs
+++ b/crypto/src/security/GeneralSecurityException.cs
@@ -17,8 +17,8 @@ namespace Org.BouncyCastle.Security
 		{
 		}
 
-		public GeneralSecurityException(string message, Exception exception)
-			: base(message, exception)
+		public GeneralSecurityException(string message, Exception innerException)
+			: base(message, innerException)
 		{
 		}
 
diff --git a/crypto/src/security/InvalidKeyException.cs b/crypto/src/security/InvalidKeyException.cs
index e9cfa75fd..73a59fbb8 100644
--- a/crypto/src/security/InvalidKeyException.cs
+++ b/crypto/src/security/InvalidKeyException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class InvalidKeyException : KeyException
+    public class InvalidKeyException
+		: KeyException
 	{
-		public InvalidKeyException() : base() { }
-		public InvalidKeyException(string message) : base(message) { }
-		public InvalidKeyException(string message, Exception exception) : base(message, exception) { }
+		public InvalidKeyException()
+			: base()
+		{
+		}
+
+		public InvalidKeyException(string message)
+			: base(message)
+		{
+		}
+
+		public InvalidKeyException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected InvalidKeyException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/InvalidParameterException.cs b/crypto/src/security/InvalidParameterException.cs
index 27b2ea411..fb27a3688 100644
--- a/crypto/src/security/InvalidParameterException.cs
+++ b/crypto/src/security/InvalidParameterException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class InvalidParameterException : KeyException
+    public class InvalidParameterException
+		: KeyException
 	{
-		public InvalidParameterException() : base() { }
-		public InvalidParameterException(string message) : base(message) { }
-		public InvalidParameterException(string message, Exception exception) : base(message, exception) { }
+		public InvalidParameterException()
+			: base()
+		{
+		}
+
+		public InvalidParameterException(string message)
+			: base(message)
+		{
+		}
+
+		public InvalidParameterException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected InvalidParameterException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/KeyException.cs b/crypto/src/security/KeyException.cs
index 57ce6862b..1ad1b0c49 100644
--- a/crypto/src/security/KeyException.cs
+++ b/crypto/src/security/KeyException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class KeyException : GeneralSecurityException
+    public class KeyException
+		: GeneralSecurityException
 	{
-		public KeyException() : base() { }
-		public KeyException(string message) : base(message) { }
-		public KeyException(string message, Exception exception) : base(message, exception) { }
+		public KeyException()
+			: base()
+		{
+		}
+
+		public KeyException(string message)
+			: base(message)
+		{
+		}
+
+		public KeyException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected KeyException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/SecurityUtilityException.cs b/crypto/src/security/SecurityUtilityException.cs
index d3f97c1a3..f10a7fbc5 100644
--- a/crypto/src/security/SecurityUtilityException.cs
+++ b/crypto/src/security/SecurityUtilityException.cs
@@ -1,36 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class SecurityUtilityException
 		: Exception
     {
-        /**
-        * base constructor.
-        */
-        public SecurityUtilityException()
-        {
-        }
+		public SecurityUtilityException()
+			: base()
+		{
+		}
 
-		/**
-         * create a SecurityUtilityException with the given message.
-         *
-         * @param message the message to be carried with the exception.
-         */
-        public SecurityUtilityException(
-            string message)
+		public SecurityUtilityException(string message)
 			: base(message)
-        {
-        }
+		{
+		}
 
-		public SecurityUtilityException(
-            string		message,
-            Exception	exception)
-			: base(message, exception)
-        {
-        }
-    }
+		public SecurityUtilityException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected SecurityUtilityException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/security/SignatureException.cs b/crypto/src/security/SignatureException.cs
index deaa23432..4bddc3d51 100644
--- a/crypto/src/security/SignatureException.cs
+++ b/crypto/src/security/SignatureException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class SignatureException : GeneralSecurityException
+    public class SignatureException
+		: GeneralSecurityException
 	{
-		public SignatureException() : base() { }
-		public SignatureException(string message) : base(message) { }
-		public SignatureException(string message, Exception exception) : base(message, exception) { }
+		public SignatureException()
+			: base()
+		{
+		}
+
+		public SignatureException(string message)
+			: base(message)
+		{
+		}
+
+		public SignatureException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected SignatureException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/cert/CertificateEncodingException.cs b/crypto/src/security/cert/CertificateEncodingException.cs
index 20c965630..5c902dfd1 100644
--- a/crypto/src/security/cert/CertificateEncodingException.cs
+++ b/crypto/src/security/cert/CertificateEncodingException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security.Certificates
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class CertificateEncodingException : CertificateException
+    public class CertificateEncodingException
+		: CertificateException
 	{
-		public CertificateEncodingException() : base() { }
-		public CertificateEncodingException(string msg) : base(msg) { }
-		public CertificateEncodingException(string msg, Exception e) : base(msg, e) { }
+		public CertificateEncodingException()
+			: base()
+		{
+		}
+
+		public CertificateEncodingException(string message)
+			: base(message)
+		{
+		}
+
+		public CertificateEncodingException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CertificateEncodingException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/cert/CertificateException.cs b/crypto/src/security/cert/CertificateException.cs
index c8819b710..5214675ab 100644
--- a/crypto/src/security/cert/CertificateException.cs
+++ b/crypto/src/security/cert/CertificateException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security.Certificates
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class CertificateException : GeneralSecurityException
+    public class CertificateException
+		: GeneralSecurityException
 	{
-		public CertificateException() : base() { }
-		public CertificateException(string message) : base(message) { }
-		public CertificateException(string message, Exception exception) : base(message, exception) { }
+		public CertificateException()
+			: base()
+		{
+		}
+
+		public CertificateException(string message)
+			: base(message)
+		{
+		}
+
+		public CertificateException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CertificateException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/cert/CertificateExpiredException.cs b/crypto/src/security/cert/CertificateExpiredException.cs
index 1d12ba7e9..25cb054bf 100644
--- a/crypto/src/security/cert/CertificateExpiredException.cs
+++ b/crypto/src/security/cert/CertificateExpiredException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security.Certificates
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class CertificateExpiredException : CertificateException
+    public class CertificateExpiredException
+		: CertificateException
 	{
-		public CertificateExpiredException() : base() { }
-		public CertificateExpiredException(string message) : base(message) { }
-		public CertificateExpiredException(string message, Exception exception) : base(message, exception) { }
+		public CertificateExpiredException()
+			: base()
+		{
+		}
+
+		public CertificateExpiredException(string message)
+			: base(message)
+		{
+		}
+
+		public CertificateExpiredException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CertificateExpiredException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/cert/CertificateNotYetValidException.cs b/crypto/src/security/cert/CertificateNotYetValidException.cs
index 8de806673..1ea3d0b97 100644
--- a/crypto/src/security/cert/CertificateNotYetValidException.cs
+++ b/crypto/src/security/cert/CertificateNotYetValidException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security.Certificates
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class CertificateNotYetValidException : CertificateException
+    public class CertificateNotYetValidException
+		: CertificateException
 	{
-		public CertificateNotYetValidException() : base() { }
-		public CertificateNotYetValidException(string message) : base(message) { }
-		public CertificateNotYetValidException(string message, Exception exception) : base(message, exception) { }
+		public CertificateNotYetValidException()
+			: base()
+		{
+		}
+
+		public CertificateNotYetValidException(string message)
+			: base(message)
+		{
+		}
+
+		public CertificateNotYetValidException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CertificateNotYetValidException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/cert/CertificateParsingException.cs b/crypto/src/security/cert/CertificateParsingException.cs
index 1e0a3f47a..244f3b614 100644
--- a/crypto/src/security/cert/CertificateParsingException.cs
+++ b/crypto/src/security/cert/CertificateParsingException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security.Certificates
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class CertificateParsingException : CertificateException
+    public class CertificateParsingException
+		: CertificateException
 	{
-		public CertificateParsingException() : base() { }
-		public CertificateParsingException(string message) : base(message) { }
-		public CertificateParsingException(string message, Exception exception) : base(message, exception) { }
+		public CertificateParsingException()
+			: base()
+		{
+		}
+
+		public CertificateParsingException(string message)
+			: base(message)
+		{
+		}
+
+		public CertificateParsingException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CertificateParsingException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/security/cert/CrlException.cs b/crypto/src/security/cert/CrlException.cs
index 4f71bea5f..9475f74de 100644
--- a/crypto/src/security/cert/CrlException.cs
+++ b/crypto/src/security/cert/CrlException.cs
@@ -1,14 +1,30 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Security.Certificates
 {
-#if !PORTABLE
     [Serializable]
-#endif
-    public class CrlException : GeneralSecurityException
+    public class CrlException
+		: GeneralSecurityException
 	{
-		public CrlException() : base() { }
-		public CrlException(string msg) : base(msg) {}
-		public CrlException(string msg, Exception e) : base(msg, e) {}
+		public CrlException()
+			: base()
+		{
+		}
+
+		public CrlException(string message)
+			: base(message)
+		{
+		}
+
+		public CrlException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected CrlException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
 	}
 }
diff --git a/crypto/src/tls/TlsException.cs b/crypto/src/tls/TlsException.cs
index c6d7a1916..9c6d74bf4 100644
--- a/crypto/src/tls/TlsException.cs
+++ b/crypto/src/tls/TlsException.cs
@@ -1,24 +1,31 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tls
 {
-    public class TlsException
+	[Serializable]
+	public class TlsException
         : IOException
     {
-        public TlsException()
-            : base()
-        {
-        }
+		public TlsException()
+			: base()
+		{
+		}
 
-        public TlsException(string message)
-            : base(message)
-        {
-        }
+		public TlsException(string message)
+			: base(message)
+		{
+		}
 
-        public TlsException(string message, Exception cause)
-            : base(message, cause)
-        {
-        }
-    }
+		public TlsException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected TlsException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/tls/TlsFatalAlert.cs b/crypto/src/tls/TlsFatalAlert.cs
index 9f0ea8f30..511fa9fb1 100644
--- a/crypto/src/tls/TlsFatalAlert.cs
+++ b/crypto/src/tls/TlsFatalAlert.cs
@@ -1,7 +1,9 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tls
 {
+    [Serializable]
     public class TlsFatalAlert
         : TlsException
     {
@@ -38,6 +40,11 @@ namespace Org.BouncyCastle.Tls
             this.m_alertDescription = alertDescription;
         }
 
+        protected TlsFatalAlert(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+        }
+
         public virtual short AlertDescription
         {
             get { return m_alertDescription; }
diff --git a/crypto/src/tls/TlsFatalAlertReceived.cs b/crypto/src/tls/TlsFatalAlertReceived.cs
index 0bf6cff38..adf71d5b9 100644
--- a/crypto/src/tls/TlsFatalAlertReceived.cs
+++ b/crypto/src/tls/TlsFatalAlertReceived.cs
@@ -1,7 +1,9 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tls
 {
+    [Serializable]
     public class TlsFatalAlertReceived
         : TlsException
     {
@@ -13,6 +15,11 @@ namespace Org.BouncyCastle.Tls
             this.m_alertDescription = alertDescription;
         }
 
+        protected TlsFatalAlertReceived(SerializationInfo info, StreamingContext context)
+            : base(info, context)
+        {
+        }
+
         public virtual short AlertDescription
         {
             get { return m_alertDescription; }
diff --git a/crypto/src/tls/TlsNoCloseNotifyException.cs b/crypto/src/tls/TlsNoCloseNotifyException.cs
index 8fdfbbfc4..b0314a406 100644
--- a/crypto/src/tls/TlsNoCloseNotifyException.cs
+++ b/crypto/src/tls/TlsNoCloseNotifyException.cs
@@ -1,5 +1,6 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tls
 {
@@ -10,6 +11,7 @@ namespace Org.BouncyCastle.Tls
     /// malicious). It may be possible to check for truncation via some property of a higher level protocol
     /// built upon TLS, e.g.the Content-Length header for HTTPS.
     /// </remarks>
+    [Serializable]
     public class TlsNoCloseNotifyException
         : EndOfStreamException
     {
@@ -17,5 +19,10 @@ namespace Org.BouncyCastle.Tls
             : base("No close_notify alert received before connection closed")
         {
         }
-    }
+
+		protected TlsNoCloseNotifyException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/tls/TlsTimeoutException.cs b/crypto/src/tls/TlsTimeoutException.cs
index ce2e1ac63..669352f54 100644
--- a/crypto/src/tls/TlsTimeoutException.cs
+++ b/crypto/src/tls/TlsTimeoutException.cs
@@ -1,24 +1,31 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tls
 {
-    public class TlsTimeoutException
+	[Serializable]
+	public class TlsTimeoutException
         : IOException
     {
-        public TlsTimeoutException()
-            : base()
-        {
-        }
+		public TlsTimeoutException()
+			: base()
+		{
+		}
 
-        public TlsTimeoutException(string message)
-            : base(message)
-        {
-        }
+		public TlsTimeoutException(string message)
+			: base(message)
+		{
+		}
 
-        public TlsTimeoutException(string message, Exception cause)
-            : base(message, cause)
-        {
-        }
-    }
+		public TlsTimeoutException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected TlsTimeoutException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/tls/crypto/TlsCryptoException.cs b/crypto/src/tls/crypto/TlsCryptoException.cs
index 83c3ef791..9498ddf3a 100644
--- a/crypto/src/tls/crypto/TlsCryptoException.cs
+++ b/crypto/src/tls/crypto/TlsCryptoException.cs
@@ -1,19 +1,31 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tls.Crypto
 {
-    /// <summary>Basic exception class for crypto services to pass back a cause.</summary>
-    public class TlsCryptoException
+	/// <summary>Basic exception class for crypto services to pass back a cause.</summary>
+	[Serializable]
+	public class TlsCryptoException
         : TlsException
     {
-        public TlsCryptoException(string msg)
-            : base(msg)
-        {
-        }
+		public TlsCryptoException()
+			: base()
+		{
+		}
 
-        public TlsCryptoException(string msg, Exception cause)
-            : base(msg, cause)
-        {
-        }
-    }
+		public TlsCryptoException(string message)
+			: base(message)
+		{
+		}
+
+		public TlsCryptoException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected TlsCryptoException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
diff --git a/crypto/src/tsp/TSPException.cs b/crypto/src/tsp/TSPException.cs
index 0213490d9..2fe7fdc90 100644
--- a/crypto/src/tsp/TSPException.cs
+++ b/crypto/src/tsp/TSPException.cs
@@ -1,27 +1,29 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tsp
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class TspException
 		: Exception
 	{
 		public TspException()
+			: base()
 		{
 		}
 
-		public TspException(
-			string message)
+		public TspException(string message)
 			: base(message)
 		{
 		}
 
-		public TspException(
-			string		message,
-			Exception	e)
-			: base(message, e)
+		public TspException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected TspException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/tsp/TSPValidationException.cs b/crypto/src/tsp/TSPValidationException.cs
index 066a398e4..eb5181f2e 100644
--- a/crypto/src/tsp/TSPValidationException.cs
+++ b/crypto/src/tsp/TSPValidationException.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Tsp
 {
@@ -8,34 +9,30 @@ namespace Org.BouncyCastle.Tsp
 	 * If a failure code is associated with the exception it can be retrieved using
 	 * the getFailureCode() method.</p>
 	 */
-#if !PORTABLE
     [Serializable]
-#endif
     public class TspValidationException
 		: TspException
 	{
 		private int failureCode;
 
-		public TspValidationException(
-			string message)
+		public TspValidationException(string message)
 			: base(message)
 		{
 			this.failureCode = -1;
 		}
 
-		public TspValidationException(
-			string	message,
-			int		failureCode)
+		public TspValidationException(string message, int failureCode)
 			: base(message)
 		{
 			this.failureCode = failureCode;
 		}
 
-		/**
-		 * Return the failure code associated with this exception - if one is set.
-		 *
-		 * @return the failure code if set, -1 otherwise.
-		 */
+		protected TspValidationException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+
+		/// <returns>The failure code associated with this exception, if one is set.</returns>
 		public int FailureCode
 		{
 			get { return failureCode; }
diff --git a/crypto/src/util/MemoableResetException.cs b/crypto/src/util/MemoableResetException.cs
index 99554f6c2..8a4deb142 100644
--- a/crypto/src/util/MemoableResetException.cs
+++ b/crypto/src/util/MemoableResetException.cs
@@ -1,27 +1,38 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Utilities
 {
-    /**
+	/**
      * Exception to be thrown on a failure to reset an object implementing Memoable.
      * <p>
      * The exception extends InvalidCastException to enable users to have a single handling case,
      * only introducing specific handling of this one if required.
      * </p>
      */
-    public class MemoableResetException
+	[Serializable]
+	public class MemoableResetException
         : InvalidCastException
     {
-        /**
-         * Basic Constructor.
-         *
-         * @param msg message to be associated with this exception.
-         */
-        public MemoableResetException(string msg)
-            : base(msg)
-        {
-        }
-    }
+		public MemoableResetException()
+			: base()
+		{
+		}
 
+		public MemoableResetException(string message)
+			: base(message)
+		{
+		}
+
+		public MemoableResetException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected MemoableResetException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
+		{
+		}
+	}
 }
 
diff --git a/crypto/src/util/io/StreamOverflowException.cs b/crypto/src/util/io/StreamOverflowException.cs
index 7e100e7b5..a36919780 100644
--- a/crypto/src/util/io/StreamOverflowException.cs
+++ b/crypto/src/util/io/StreamOverflowException.cs
@@ -1,11 +1,10 @@
 using System;
 using System.IO;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Utilities.IO
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class StreamOverflowException
 		: IOException
 	{
@@ -14,16 +13,18 @@ namespace Org.BouncyCastle.Utilities.IO
 		{
 		}
 
-		public StreamOverflowException(
-			string message)
+		public StreamOverflowException(string message)
 			: base(message)
 		{
 		}
 
-		public StreamOverflowException(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public StreamOverflowException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected StreamOverflowException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/util/io/pem/PemGenerationException.cs b/crypto/src/util/io/pem/PemGenerationException.cs
index a49dda0e7..b7f30672e 100644
--- a/crypto/src/util/io/pem/PemGenerationException.cs
+++ b/crypto/src/util/io/pem/PemGenerationException.cs
@@ -1,10 +1,9 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.Utilities.IO.Pem
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class PemGenerationException
 		: Exception
 	{
@@ -13,16 +12,18 @@ namespace Org.BouncyCastle.Utilities.IO.Pem
 		{
 		}
 
-		public PemGenerationException(
-			string message)
+		public PemGenerationException(string message)
 			: base(message)
 		{
 		}
 
-		public PemGenerationException(
-			string		message,
-			Exception	exception)
-			: base(message, exception)
+		public PemGenerationException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected PemGenerationException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/x509/store/NoSuchStoreException.cs b/crypto/src/x509/store/NoSuchStoreException.cs
index bf6bdf76c..3acac536f 100644
--- a/crypto/src/x509/store/NoSuchStoreException.cs
+++ b/crypto/src/x509/store/NoSuchStoreException.cs
@@ -1,27 +1,29 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.X509.Store
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class NoSuchStoreException
 		: X509StoreException
 	{
 		public NoSuchStoreException()
+			: base()
 		{
 		}
 
-		public NoSuchStoreException(
-			string message)
+		public NoSuchStoreException(string message)
 			: base(message)
 		{
 		}
 
-		public NoSuchStoreException(
-			string		message,
-			Exception	e)
-			: base(message, e)
+		public NoSuchStoreException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected NoSuchStoreException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/src/x509/store/X509StoreException.cs b/crypto/src/x509/store/X509StoreException.cs
index f697c116a..0ad32c2ef 100644
--- a/crypto/src/x509/store/X509StoreException.cs
+++ b/crypto/src/x509/store/X509StoreException.cs
@@ -1,27 +1,29 @@
 using System;
+using System.Runtime.Serialization;
 
 namespace Org.BouncyCastle.X509.Store
 {
-#if !PORTABLE
     [Serializable]
-#endif
     public class X509StoreException
 		: Exception
 	{
 		public X509StoreException()
+			: base()
 		{
 		}
 
-		public X509StoreException(
-			string message)
+		public X509StoreException(string message)
 			: base(message)
 		{
 		}
 
-		public X509StoreException(
-			string		message,
-			Exception	e)
-			: base(message, e)
+		public X509StoreException(string message, Exception innerException)
+			: base(message, innerException)
+		{
+		}
+
+		protected X509StoreException(SerializationInfo info, StreamingContext context)
+			: base(info, context)
 		{
 		}
 	}
diff --git a/crypto/test/src/util/test/SimpleTest.cs b/crypto/test/src/util/test/SimpleTest.cs
index fc88be103..1695164e5 100644
--- a/crypto/test/src/util/test/SimpleTest.cs
+++ b/crypto/test/src/util/test/SimpleTest.cs
@@ -108,7 +108,7 @@ namespace Org.BouncyCastle.Utilities.Test
             }
             catch (TestFailedException e)
             {
-                return e.GetResult();
+                return e.Result;
             }
             catch (Exception e)
             {
diff --git a/crypto/test/src/util/test/TestFailedException.cs b/crypto/test/src/util/test/TestFailedException.cs
index 215e1fd20..2ea66087d 100644
--- a/crypto/test/src/util/test/TestFailedException.cs
+++ b/crypto/test/src/util/test/TestFailedException.cs
@@ -2,23 +2,20 @@ using System;
 
 namespace Org.BouncyCastle.Utilities.Test
 {
-#if !PORTABLE
-    [Serializable]
-#endif
     public class TestFailedException
         : Exception
     {
-        private ITestResult _result;
+        private readonly ITestResult m_result;
 
-        public TestFailedException(
-            ITestResult result)
+        public TestFailedException(ITestResult result)
+            : base()
         {
-            _result = result;
+            m_result = result;
         }
 
-        public ITestResult GetResult()
+        public ITestResult Result
         {
-            return _result;
+            get { return m_result; }
         }
     }
 }