Thread: [pgsqlclient-checkins] pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Sec
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-12-14 15:01:42
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake In directory sc8-pr-cvs1:/tmp/cvs-serv14637 Modified Files: TlsHandshakeMessage.cs Log Message: 2003-12-15 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: TlsHandshakeMessage.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessage.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TlsHandshakeMessage.cs 23 Nov 2003 12:50:26 -0000 1.13 --- TlsHandshakeMessage.cs 14 Dec 2003 15:01:39 -0000 1.14 *************** *** 1,148 **** ! /* 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.Handshake ! { ! internal abstract class TlsHandshakeMessage : TlsStream ! { ! #region FIELDS ! ! private TlsContext context; ! private TlsHandshakeType handshakeType; ! private TlsContentType contentType; ! ! #endregion ! ! #region PROPERTIES ! ! public TlsContext Context ! { ! get { return this.context; } ! } ! ! public TlsHandshakeType HandshakeType ! { ! get { return this.handshakeType; } ! } ! ! public TlsContentType ContentType ! { ! get { return this.contentType; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsHandshakeMessage( ! TlsContext context, ! TlsHandshakeType handshakeType) ! : this(context, handshakeType, TlsContentType.Handshake) ! { ! } ! ! public TlsHandshakeMessage( ! TlsContext context, ! TlsHandshakeType handshakeType, ! TlsContentType contentType) : base() ! { ! this.context = context; ! this.handshakeType = handshakeType; ! this.contentType = contentType; ! ! // Process message ! this.process(); ! } ! ! public TlsHandshakeMessage( ! TlsContext context, ! TlsHandshakeType handshakeType, ! byte[] data) : base(data) ! { ! this.context = context; ! this.handshakeType = handshakeType; ! ! // Process message ! this.process(); ! } ! ! #endregion ! ! #region ABSTRACT_METHODS ! ! protected abstract void ProcessAsTls1(); ! ! protected abstract void ProcessAsSsl3(); ! ! #endregion ! ! #region METHODS ! ! private void process() ! { ! switch (this.Context.Protocol) ! { ! case SecurityProtocolType.Ssl3: ! this.ProcessAsSsl3(); ! break; ! ! case SecurityProtocolType.Tls: ! this.ProcessAsTls1(); ! break; ! } ! } ! ! public virtual void Update() ! { ! if (CanWrite) ! { ! this.context.HandshakeMessages.Write(this.EncodeMessage()); ! this.Reset(); ! } ! } ! ! public virtual byte[] EncodeMessage() ! { ! byte[] result = null; ! ! if (CanWrite) ! { ! TlsStream c = new TlsStream(); ! ! c.Write((byte)HandshakeType); ! c.WriteInt24((int)this.Length); ! c.Write(this.ToArray()); ! ! result = c.ToArray(); ! } ! ! return result; ! } ! ! #endregion ! } ! } --- 1,148 ---- ! /* 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.Handshake ! { ! internal abstract class TlsHandshakeMessage : TlsStream ! { ! #region Fields ! ! private TlsContext context; ! private TlsHandshakeType handshakeType; ! private TlsContentType contentType; ! ! #endregion ! ! #region Properties ! ! public TlsContext Context ! { ! get { return this.context; } ! } ! ! public TlsHandshakeType HandshakeType ! { ! get { return this.handshakeType; } ! } ! ! public TlsContentType ContentType ! { ! get { return this.contentType; } ! } ! ! #endregion ! ! #region Constructors ! ! public TlsHandshakeMessage( ! TlsContext context, ! TlsHandshakeType handshakeType) ! : this(context, handshakeType, TlsContentType.Handshake) ! { ! } ! ! public TlsHandshakeMessage( ! TlsContext context, ! TlsHandshakeType handshakeType, ! TlsContentType contentType) : base() ! { ! this.context = context; ! this.handshakeType = handshakeType; ! this.contentType = contentType; ! ! // Process message ! this.process(); ! } ! ! public TlsHandshakeMessage( ! TlsContext context, ! TlsHandshakeType handshakeType, ! byte[] data) : base(data) ! { ! this.context = context; ! this.handshakeType = handshakeType; ! ! // Process message ! this.process(); ! } ! ! #endregion ! ! #region Abstract Methods ! ! protected abstract void ProcessAsTls1(); ! ! protected abstract void ProcessAsSsl3(); ! ! #endregion ! ! #region Methods ! ! private void process() ! { ! switch (this.Context.Protocol) ! { ! case SecurityProtocolType.Ssl3: ! this.ProcessAsSsl3(); ! break; ! ! case SecurityProtocolType.Tls: ! this.ProcessAsTls1(); ! break; ! } ! } ! ! public virtual void Update() ! { ! if (CanWrite) ! { ! this.context.HandshakeMessages.Write(this.EncodeMessage()); ! this.Reset(); ! } ! } ! ! public virtual byte[] EncodeMessage() ! { ! byte[] result = null; ! ! if (CanWrite) ! { ! TlsStream c = new TlsStream(); ! ! c.Write((byte)HandshakeType); ! c.WriteInt24((int)this.Length); ! c.Write(this.ToArray()); ! ! result = c.ToArray(); ! } ! ! return result; ! } ! ! #endregion ! } ! } |