From: Carlos Guzmán Álvarez Date: Mon, 20 Oct 2003 21:32:34 +0000 (-0000) Subject: Sync file X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=0af29dbb264e3e410f985c4584fce3cca8335b42;p=mono.git Sync file svn path=/trunk/mcs/; revision=19231 --- diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs index f88298b18bf..9a96aca52e7 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs @@ -1,199 +1,199 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; -using Mono.Security.Protocol.Tls; - -namespace Mono.Security.Protocol.Tls.Alerts -{ - #region ENUMS - - public enum TlsAlertLevel : byte - { - Warning = 1, - Fatal = 2 - } - - public enum TlsAlertDescription : byte - { - CloseNotify = 0, - UnexpectedMessage = 10, - BadRecordMAC = 20, - DecryptionFailed = 21, - RecordOverflow = 22, - DecompressionFailiure = 30, - HandshakeFailiure = 40, - BadCertificate = 42, - UnsupportedCertificate = 43, - CertificateRevoked = 44, - CertificateExpired = 45, - CertificateUnknown = 46, - IlegalParameter = 47, - UnknownCA = 48, - AccessDenied = 49, - DecodeError = 50, - DecryptError = 51, - ExportRestriction = 60, - ProtocolVersion = 70, - InsuficientSecurity = 71, - InternalError = 80, - UserCancelled = 90, - NoRenegotiation = 100 - } - - #endregion - - internal abstract class TlsAlert : TlsStream - { - #region FIELDS - - private TlsSession session; - private TlsAlertLevel level; - private TlsAlertDescription description; - - #endregion - - #region PROPERTIES - - public TlsSession Session - { - get { return session; } - } - - #endregion - - #region CONSTRUCTORS - - public TlsAlert(TlsSession session, - TlsAlertLevel level, - TlsAlertDescription description) : base() - { - this.session = session; - this.level = level; - this.description = description; - - this.fill(); - } - - #endregion - - #region ABSTRACT_METHODS - - public abstract void UpdateSession(); - - #endregion - - #region CONSTRUCTORS - - private void fill() - { - Write((byte)level); - Write((byte)description); - } - - #endregion - - #region STATIC_METHODS - - internal static string GetAlertMessage(TlsAlertDescription description) - { - switch (description) - { - case TlsAlertDescription.AccessDenied: - return "An inappropriate message was received."; - - case TlsAlertDescription.BadCertificate: - return "TLSCiphertext decrypted in an invalid way."; - - case TlsAlertDescription.BadRecordMAC: - return "Record with an incorrect MAC."; - - case TlsAlertDescription.CertificateExpired: - return "Certificate has expired or is not currently valid"; - - case TlsAlertDescription.CertificateRevoked: - return "Certificate was revoked by its signer."; - - case TlsAlertDescription.CertificateUnknown: - return "Certificate Unknown."; - - case TlsAlertDescription.CloseNotify: - return "Connection closed"; - - case TlsAlertDescription.DecodeError: - return "A message could not be decoded because some field was out of the specified range or the length of the message was incorrect."; - - case TlsAlertDescription.DecompressionFailiure: - return "The decompression function received improper input (e.g. data that would expand to excessive length)."; - - case TlsAlertDescription.DecryptError: - return "TLSCiphertext decrypted in an invalid way: either it wasn`t an even multiple of the block length or its padding values, when checked, weren`t correct."; - - case TlsAlertDescription.DecryptionFailed: - return "Handshake cryptographic operation failed, including being unable to correctly verify a signature, decrypt a key exchange, or validate finished message."; - - case TlsAlertDescription.ExportRestriction: - return "Negotiation not in compliance with export restrictions was detected."; - - case TlsAlertDescription.HandshakeFailiure: - return "Unable to negotiate an acceptable set of security parameters given the options available."; - - case TlsAlertDescription.IlegalParameter: - return "A field in the handshake was out of range or inconsistent with other fields."; - - case TlsAlertDescription.InsuficientSecurity: - return "Negotiation has failed specifically because the server requires ciphers more secure than those supported by the client."; - - case TlsAlertDescription.InternalError: - return "Internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue."; - - case TlsAlertDescription.NoRenegotiation: - return "Invalid renegotiation."; - - case TlsAlertDescription.ProtocolVersion: - return "Unsupported protocol version."; - - case TlsAlertDescription.RecordOverflow: - return "Invalid length on TLSCiphertext record or TLSCompressed record."; - - case TlsAlertDescription.UnexpectedMessage: - return "Invalid message receive."; - - case TlsAlertDescription.UnknownCA: - return "CA can't be identified as a trusted CA."; - - case TlsAlertDescription.UnsupportedCertificate: - return "Certificate was of an unsupported type."; - - case TlsAlertDescription.UserCancelled: - return "Handshake cancelled by user."; - - default: - return ""; - } - } - - #endregion - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; +using Mono.Security.Protocol.Tls; + +namespace Mono.Security.Protocol.Tls.Alerts +{ + #region ENUMS + + public enum TlsAlertLevel : byte + { + Warning = 1, + Fatal = 2 + } + + public enum TlsAlertDescription : byte + { + CloseNotify = 0, + UnexpectedMessage = 10, + BadRecordMAC = 20, + DecryptionFailed = 21, + RecordOverflow = 22, + DecompressionFailiure = 30, + HandshakeFailiure = 40, + BadCertificate = 42, + UnsupportedCertificate = 43, + CertificateRevoked = 44, + CertificateExpired = 45, + CertificateUnknown = 46, + IlegalParameter = 47, + UnknownCA = 48, + AccessDenied = 49, + DecodeError = 50, + DecryptError = 51, + ExportRestriction = 60, + ProtocolVersion = 70, + InsuficientSecurity = 71, + InternalError = 80, + UserCancelled = 90, + NoRenegotiation = 100 + } + + #endregion + + internal abstract class TlsAlert : TlsStream + { + #region FIELDS + + private TlsSession session; + private TlsAlertLevel level; + private TlsAlertDescription description; + + #endregion + + #region PROPERTIES + + public TlsSession Session + { + get { return session; } + } + + #endregion + + #region CONSTRUCTORS + + public TlsAlert(TlsSession session, + TlsAlertLevel level, + TlsAlertDescription description) : base() + { + this.session = session; + this.level = level; + this.description = description; + + this.fill(); + } + + #endregion + + #region ABSTRACT_METHODS + + public abstract void UpdateSession(); + + #endregion + + #region CONSTRUCTORS + + private void fill() + { + Write((byte)level); + Write((byte)description); + } + + #endregion + + #region STATIC_METHODS + + internal static string GetAlertMessage(TlsAlertDescription description) + { + switch (description) + { + case TlsAlertDescription.AccessDenied: + return "An inappropriate message was received."; + + case TlsAlertDescription.BadCertificate: + return "TLSCiphertext decrypted in an invalid way."; + + case TlsAlertDescription.BadRecordMAC: + return "Record with an incorrect MAC."; + + case TlsAlertDescription.CertificateExpired: + return "Certificate has expired or is not currently valid"; + + case TlsAlertDescription.CertificateRevoked: + return "Certificate was revoked by its signer."; + + case TlsAlertDescription.CertificateUnknown: + return "Certificate Unknown."; + + case TlsAlertDescription.CloseNotify: + return "Connection closed"; + + case TlsAlertDescription.DecodeError: + return "A message could not be decoded because some field was out of the specified range or the length of the message was incorrect."; + + case TlsAlertDescription.DecompressionFailiure: + return "The decompression function received improper input (e.g. data that would expand to excessive length)."; + + case TlsAlertDescription.DecryptError: + return "TLSCiphertext decrypted in an invalid way: either it wasn`t an even multiple of the block length or its padding values, when checked, weren`t correct."; + + case TlsAlertDescription.DecryptionFailed: + return "Handshake cryptographic operation failed, including being unable to correctly verify a signature, decrypt a key exchange, or validate finished message."; + + case TlsAlertDescription.ExportRestriction: + return "Negotiation not in compliance with export restrictions was detected."; + + case TlsAlertDescription.HandshakeFailiure: + return "Unable to negotiate an acceptable set of security parameters given the options available."; + + case TlsAlertDescription.IlegalParameter: + return "A field in the handshake was out of range or inconsistent with other fields."; + + case TlsAlertDescription.InsuficientSecurity: + return "Negotiation has failed specifically because the server requires ciphers more secure than those supported by the client."; + + case TlsAlertDescription.InternalError: + return "Internal error unrelated to the peer or the correctness of the protocol makes it impossible to continue."; + + case TlsAlertDescription.NoRenegotiation: + return "Invalid renegotiation."; + + case TlsAlertDescription.ProtocolVersion: + return "Unsupported protocol version."; + + case TlsAlertDescription.RecordOverflow: + return "Invalid length on TLSCiphertext record or TLSCompressed record."; + + case TlsAlertDescription.UnexpectedMessage: + return "Invalid message receive."; + + case TlsAlertDescription.UnknownCA: + return "CA can't be identified as a trusted CA."; + + case TlsAlertDescription.UnsupportedCertificate: + return "Certificate was of an unsupported type."; + + case TlsAlertDescription.UserCancelled: + return "Handshake cancelled by user."; + + default: + return ""; + } + } + + #endregion + } +} diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs index fd5083e672e..2e573a2924a 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsCloseNotifyAlert.cs @@ -1,44 +1,44 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; -using Mono.Security.Protocol.Tls; - -namespace Mono.Security.Protocol.Tls.Alerts -{ - internal class TlsCloseNotifyAlert : TlsAlert - { - public TlsCloseNotifyAlert(TlsSession session) - : base(session, - TlsAlertLevel.Warning, - TlsAlertDescription.CloseNotify) - { - } - - public override void UpdateSession() - { - this.Session.Context.ConnectionEnd = true; - } - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; +using Mono.Security.Protocol.Tls; + +namespace Mono.Security.Protocol.Tls.Alerts +{ + internal class TlsCloseNotifyAlert : TlsAlert + { + public TlsCloseNotifyAlert(TlsSession session) + : base(session, + TlsAlertLevel.Warning, + TlsAlertDescription.CloseNotify) + { + } + + public override void UpdateSession() + { + this.Session.Context.ConnectionEnd = true; + } + } +} diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsWarningAlertEventArgs.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsWarningAlertEventArgs.cs index 6ca3534d712..3486e43609c 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsWarningAlertEventArgs.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Alerts/TlsWarningAlertEventArgs.cs @@ -1,71 +1,71 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; - -namespace Mono.Security.Protocol.Tls.Alerts -{ - public delegate void TlsWarningAlertEventHandler(object sender, TlsWarningAlertEventArgs e); - - public sealed class TlsWarningAlertEventArgs - { - #region FIELDS - - private TlsAlertLevel level; - private TlsAlertDescription description; - private string message; - - #endregion - - #region PROPERTIES - - public TlsAlertLevel Level - { - get { return level; } - } - - public TlsAlertDescription Description - { - get { return description; } - } - - public string Message - { - get { return message; } - } - - #endregion - - #region CONSTRUCTORS - - internal TlsWarningAlertEventArgs(TlsAlertLevel level, TlsAlertDescription description) - { - this.level = level; - this.description = description; - this.message = TlsAlert.GetAlertMessage(description); - } - - #endregion - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; + +namespace Mono.Security.Protocol.Tls.Alerts +{ + public delegate void TlsWarningAlertEventHandler(object sender, TlsWarningAlertEventArgs e); + + public sealed class TlsWarningAlertEventArgs + { + #region FIELDS + + private TlsAlertLevel level; + private TlsAlertDescription description; + private string message; + + #endregion + + #region PROPERTIES + + public TlsAlertLevel Level + { + get { return level; } + } + + public TlsAlertDescription Description + { + get { return description; } + } + + public string Message + { + get { return message; } + } + + #endregion + + #region CONSTRUCTORS + + internal TlsWarningAlertEventArgs(TlsAlertLevel level, TlsAlertDescription description) + { + this.level = level; + this.description = description; + this.message = TlsAlert.GetAlertMessage(description); + } + + #endregion + } +} diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsClientCertificateType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsClientCertificateType.cs index 8a2848c2702..94900630ab7 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsClientCertificateType.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsClientCertificateType.cs @@ -1,37 +1,37 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; - -namespace Mono.Security.Protocol.Tls.Handshake -{ - internal enum TlsClientCertificateType - { - RSA = 1, - DSS = 2, - RSAFixed = 3, - DSSFixed = 4, - Unknown = 255 - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; + +namespace Mono.Security.Protocol.Tls.Handshake +{ + internal enum TlsClientCertificateType + { + RSA = 1, + DSS = 2, + RSAFixed = 3, + DSSFixed = 4, + Unknown = 255 + } +} diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeHashes.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeHashes.cs index a7f7428441b..adf66115b07 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeHashes.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeHashes.cs @@ -1,98 +1,98 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; -using System.Security.Cryptography; - -namespace Mono.Security.Protocol.Tls.Handshake -{ - internal class TlsHandshakeHashes - { - #region FIELDS - - private MD5CryptoServiceProvider md5; - private SHA1CryptoServiceProvider sha; - private TlsStream messages; - - #endregion - - #region CONSTRUCTORS - - public TlsHandshakeHashes() - { - this.messages = new TlsStream(); - this.md5 = new MD5CryptoServiceProvider(); - this.sha = new SHA1CryptoServiceProvider(); - } - - #endregion - - #region METHODS - - public void Update(byte[] message) - { - byte[] tmp = new byte[message.Length]; - - md5.TransformBlock(message, 0, message.Length, tmp, 0); - sha.TransformBlock(message, 0, message.Length, tmp, 0); - - this.messages.Write(message); - } - - public byte[] GetMD5Hash() - { - md5.TransformFinalBlock(new byte[0], 0, 0); - - return md5.Hash; - } - - public byte[] GetSHAHash() - { - sha.TransformFinalBlock(new byte[0], 0, 0); - - return sha.Hash; - } - - public void Reset() - { - md5.Initialize(); - sha.Initialize(); - - byte[] tmp = new byte[messages.Length]; - - md5.TransformBlock(messages.ToArray(), 0, tmp.Length, tmp, 0); - sha.TransformBlock(messages.ToArray(), 0, tmp.Length, tmp, 0); - } - - public void Clear() - { - md5.Initialize(); - sha.Initialize(); - - messages.Reset(); - } - - #endregion - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; +using System.Security.Cryptography; + +namespace Mono.Security.Protocol.Tls.Handshake +{ + internal class TlsHandshakeHashes + { + #region FIELDS + + private MD5CryptoServiceProvider md5; + private SHA1CryptoServiceProvider sha; + private TlsStream messages; + + #endregion + + #region CONSTRUCTORS + + public TlsHandshakeHashes() + { + this.messages = new TlsStream(); + this.md5 = new MD5CryptoServiceProvider(); + this.sha = new SHA1CryptoServiceProvider(); + } + + #endregion + + #region METHODS + + public void Update(byte[] message) + { + byte[] tmp = new byte[message.Length]; + + md5.TransformBlock(message, 0, message.Length, tmp, 0); + sha.TransformBlock(message, 0, message.Length, tmp, 0); + + this.messages.Write(message); + } + + public byte[] GetMD5Hash() + { + md5.TransformFinalBlock(new byte[0], 0, 0); + + return md5.Hash; + } + + public byte[] GetSHAHash() + { + sha.TransformFinalBlock(new byte[0], 0, 0); + + return sha.Hash; + } + + public void Reset() + { + md5.Initialize(); + sha.Initialize(); + + byte[] tmp = new byte[messages.Length]; + + md5.TransformBlock(messages.ToArray(), 0, tmp.Length, tmp, 0); + sha.TransformBlock(messages.ToArray(), 0, tmp.Length, tmp, 0); + } + + public void Clear() + { + md5.Initialize(); + sha.Initialize(); + + messages.Reset(); + } + + #endregion + } +} diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeType.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeType.cs index ce341840b61..6dbbe045d1e 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeType.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeType.cs @@ -1,43 +1,43 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; - -namespace Mono.Security.Protocol.Tls.Handshake -{ - internal enum TlsHandshakeType : byte - { - HelloRequest = 0, - ClientHello = 1, - ServerHello = 2, - Certificate = 11, - ServerKeyExchange = 12, - CertificateRequest = 13, - ServerHelloDone = 14, - CertificateVerify = 15, - ClientKeyExchange = 16, - Finished = 20, - Unknown = 255 - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; + +namespace Mono.Security.Protocol.Tls.Handshake +{ + internal enum TlsHandshakeType : byte + { + HelloRequest = 0, + ClientHello = 1, + ServerHello = 2, + Certificate = 11, + ServerKeyExchange = 12, + CertificateRequest = 13, + ServerHelloDone = 14, + CertificateVerify = 15, + ClientKeyExchange = 16, + Finished = 20, + Unknown = 255 + } +} diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSessionState.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSessionState.cs index efcd0746572..6856cd9bdd6 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSessionState.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/TlsSessionState.cs @@ -1,39 +1,39 @@ -/* Transport Security Layer (TLS) - * Copyright (c) 2003 Carlos Guzmán Álvarez - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, - * publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -using System; - -namespace Mono.Security.Protocol.Tls -{ - public enum TlsSessionState - { - Broken, - Open, - Closed, - OpenSecure, - OpeningSecure, - Opening, - Closing - } -} +/* Transport Security Layer (TLS) + * Copyright (c) 2003 Carlos Guzmán Álvarez + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +using System; + +namespace Mono.Security.Protocol.Tls +{ + public enum TlsSessionState + { + Broken, + Open, + Closed, + OpenSecure, + OpeningSecure, + Opening, + Closing + } +}