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
diff --git a/crypto/src/tls/TlsFatalAlertReceived.cs b/crypto/src/tls/TlsFatalAlertReceived.cs
index adf71d5b9..4e1a62481 100644
--- a/crypto/src/tls/TlsFatalAlertReceived.cs
+++ b/crypto/src/tls/TlsFatalAlertReceived.cs
@@ -7,17 +7,27 @@ namespace Org.BouncyCastle.Tls
public class TlsFatalAlertReceived
: TlsException
{
- protected readonly short m_alertDescription;
+ protected readonly byte m_alertDescription;
public TlsFatalAlertReceived(short alertDescription)
: base(Tls.AlertDescription.GetText(alertDescription))
{
- this.m_alertDescription = alertDescription;
+ if (!TlsUtilities.IsValidUint8(alertDescription))
+ throw new ArgumentOutOfRangeException(nameof(alertDescription));
+
+ m_alertDescription = (byte)alertDescription;
}
protected TlsFatalAlertReceived(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
|