summary refs log tree commit diff
path: root/crypto/src/tls/TlsFatalAlert.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-07-01 16:04:26 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-07-01 16:04:26 +0700
commit7667960b24e63b23518408337c69d5f36c5dfd94 (patch)
tree5a4d0d42d37cd2413b3ec7b68eccfb16f3d4a858 /crypto/src/tls/TlsFatalAlert.cs
parentRework EdDSA precomputations (diff)
downloadBouncyCastle.NET-ed25519-7667960b24e63b23518408337c69d5f36c5dfd94.tar.xz
Custom serialization
Diffstat (limited to 'crypto/src/tls/TlsFatalAlert.cs')
-rw-r--r--crypto/src/tls/TlsFatalAlert.cs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crypto/src/tls/TlsFatalAlert.cs b/crypto/src/tls/TlsFatalAlert.cs
index 511fa9fb1..feca84820 100644
--- a/crypto/src/tls/TlsFatalAlert.cs
+++ b/crypto/src/tls/TlsFatalAlert.cs
@@ -17,10 +17,10 @@ namespace Org.BouncyCastle.Tls
             return msg;
         }
 
-        protected readonly short m_alertDescription;
+        protected readonly byte m_alertDescription;
 
         public TlsFatalAlert(short alertDescription)
-            : this(alertDescription, (string)null)
+            : this(alertDescription, null, null)
         {
         }
 
@@ -37,12 +37,22 @@ namespace Org.BouncyCastle.Tls
         public TlsFatalAlert(short alertDescription, string detailMessage, Exception alertCause)
             : base(GetMessage(alertDescription, detailMessage), alertCause)
         {
-            this.m_alertDescription = alertDescription;
+            if (!TlsUtilities.IsValidUint8(alertDescription))
+                throw new ArgumentOutOfRangeException(nameof(alertDescription));
+
+            m_alertDescription = (byte)alertDescription;
         }
 
         protected TlsFatalAlert(SerializationInfo info, StreamingContext context)
             : base(info, context)
         {
+            m_alertDescription = info.GetByte("alertDescription");
+        }
+
+        public override void GetObjectData(SerializationInfo info, StreamingContext context)
+        {
+            base.GetObjectData(info, context);
+            info.AddValue("alertDescription", m_alertDescription);
         }
 
         public virtual short AlertDescription