pgsqlclient-checkins Mailing List for PostgreSqlClient (Page 29)
Status: Inactive
Brought to you by:
carlosga_fb
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(120) |
Aug
(95) |
Sep
(95) |
Oct
(213) |
Nov
(114) |
Dec
(64) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(6) |
Feb
(134) |
Mar
(88) |
Apr
(28) |
May
(22) |
Jun
(15) |
Jul
(23) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(6) |
Dec
|
2005 |
Jan
(8) |
Feb
(6) |
Mar
|
Apr
(42) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(84) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
(84) |
Apr
(46) |
May
(40) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <car...@us...> - 2003-12-14 15:06:24
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography In directory sc8-pr-cvs1:/tmp/cvs-serv15535 Modified Files: MD5SHA1.cs Log Message: 2003-12-14 Carlos Guzmán Álvarez <car...@te...> * Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs: * Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs: - Added new classes for implement in the future RSA-SSL signatures. Index: MD5SHA1.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MD5SHA1.cs 14 Dec 2003 14:59:55 -0000 1.3 --- MD5SHA1.cs 14 Dec 2003 15:06:18 -0000 1.4 *************** *** 100,104 **** } ! RSASSLSignatureFormatter f = new RSASSLSignatureFormatter(rsa); f.SetHashAlgorithm("MD5SHA1"); --- 100,104 ---- } ! RSASslSignatureFormatter f = new RSASslSignatureFormatter(rsa); f.SetHashAlgorithm("MD5SHA1"); *************** *** 117,124 **** } ! RSAManaged rsam = new RSAManaged(); ! rsam.ImportParameters(rsa.ExportParameters(false)); ! ! RSASSLSignatureDeformatter d = new RSASSLSignatureDeformatter(rsam); d.SetHashAlgorithm("MD5SHA1"); --- 117,121 ---- } ! RSASslSignatureDeformatter d = new RSASslSignatureDeformatter(rsa); d.SetHashAlgorithm("MD5SHA1"); |
From: <car...@us...> - 2003-12-14 15:06:11
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv15467 Added Files: RSASslSignatureDeformatter.cs RSASslSignatureFormatter.cs Log Message: 2003-12-14 Carlos Guzmán Álvarez <car...@te...> * Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs: * Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs: - Added new classes for implement in the future RSA-SSL signatures. --- NEW FILE: RSASslSignatureDeformatter.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: RSASslSignatureFormatter.cs --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server In directory sc8-pr-cvs1:/tmp/cvs-serv14774 Modified Files: TlsClientCertificate.cs TlsClientCertificateVerify.cs TlsClientFinished.cs TlsClientHello.cs TlsClientKeyExchange.cs TlsServerCertificate.cs TlsServerCertificateRequest.cs TlsServerFinished.cs TlsServerHello.cs TlsServerHelloDone.cs TlsServerKeyExchange.cs Log Message: 2003-12-14 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: TlsClientCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificate.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsClientCertificate.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsClientCertificate.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,65 **** ! /* 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; ! using System.Security.Cryptography.X509Certificates; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientCertificate : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientCertificate(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Certificate, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,65 ---- ! /* 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; ! using System.Security.Cryptography.X509Certificates; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientCertificate : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientCertificate(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Certificate, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsClientCertificateVerify.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientCertificateVerify.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsClientCertificateVerify.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsClientCertificateVerify.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,67 **** ! /* 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.X509Certificates; ! ! using System.Security.Cryptography; ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientCertificateVerify : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientCertificateVerify(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Finished, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,67 ---- ! /* 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.X509Certificates; ! ! using System.Security.Cryptography; ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientCertificateVerify : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientCertificateVerify(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Finished, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsClientFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientFinished.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsClientFinished.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsClientFinished.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,66 **** ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientFinished : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientFinished(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Finished, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,66 ---- ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientFinished : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientFinished(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Finished, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsClientHello.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientHello.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsClientHello.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsClientHello.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,64 **** ! /* 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.Server ! { ! internal class TlsClientHello : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientHello(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ClientHello, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } } --- 1,64 ---- ! /* 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.Server ! { ! internal class TlsClientHello : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientHello(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ClientHello, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } } Index: TlsClientKeyExchange.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsClientKeyExchange.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsClientKeyExchange.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsClientKeyExchange.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,58 **** ! /* 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.IO; ! using System.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientKeyExchange : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientKeyExchange (TlsContext context, byte[] buffer) : ! base(context, ! TlsHandshakeType.ClientKeyExchange, ! buffer) ! { ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,58 ---- ! /* 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.IO; ! using System.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsClientKeyExchange : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientKeyExchange (TlsContext context, byte[] buffer) : ! base(context, ! TlsHandshakeType.ClientKeyExchange, ! buffer) ! { ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsServerCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificate.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerCertificate.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsServerCertificate.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,70 **** ! /* 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.Collections; ! using System.Text.RegularExpressions; ! using System.Security.Cryptography; ! using X509Cert = System.Security.Cryptography.X509Certificates; ! ! using Mono.Security.Protocol.Tls.Alerts; ! using Mono.Security.X509; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerCertificate : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerCertificate(TlsContext context) ! : base(context, TlsHandshakeType.Certificate) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,70 ---- ! /* 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.Collections; ! using System.Text.RegularExpressions; ! using System.Security.Cryptography; ! using X509Cert = System.Security.Cryptography.X509Certificates; ! ! using Mono.Security.Protocol.Tls.Alerts; ! using Mono.Security.X509; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerCertificate : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerCertificate(TlsContext context) ! : base(context, TlsHandshakeType.Certificate) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsServerCertificateRequest.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerCertificateRequest.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerCertificateRequest.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsServerCertificateRequest.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,65 **** ! /* 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.Text; ! using Mono.Security; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerCertificateRequest : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerCertificateRequest(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,65 ---- ! /* 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.Text; ! using Mono.Security; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerCertificateRequest : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerCertificateRequest(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsServerFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerFinished.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerFinished.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsServerFinished.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,66 **** ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerFinished : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerFinished(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,66 ---- ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerFinished : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerFinished(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsServerHello.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHello.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerHello.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsServerHello.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,63 **** ! /* 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.Server ! { ! internal class TlsServerHello : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerHello(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } } --- 1,63 ---- ! /* 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.Server ! { ! internal class TlsServerHello : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerHello(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } } Index: TlsServerHelloDone.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerHelloDone.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerHelloDone.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsServerHelloDone.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,63 **** ! /* 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.Server ! { ! internal class TlsServerHelloDone : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerHelloDone(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,63 ---- ! /* 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.Server ! { ! internal class TlsServerHelloDone : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerHelloDone(TlsContext context) ! : base(context, TlsHandshakeType.ServerHello) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsServerKeyExchange.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Server/TlsServerKeyExchange.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsServerKeyExchange.cs 23 Nov 2003 12:51:18 -0000 1.1 --- TlsServerKeyExchange.cs 14 Dec 2003 15:02:18 -0000 1.2 *************** *** 1,67 **** ! /* 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; ! ! using Mono.Security.Cryptography; ! using Mono.Security.X509; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerKeyExchange : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerKeyExchange(TlsContext context) ! : base(context, TlsHandshakeType.ServerKeyExchange) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,67 ---- ! /* 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; ! ! using Mono.Security.Cryptography; ! using Mono.Security.X509; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Server ! { ! internal class TlsServerKeyExchange : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerKeyExchange(TlsContext context) ! : base(context, TlsHandshakeType.ServerKeyExchange) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client In directory sc8-pr-cvs1:/tmp/cvs-serv14683 Modified Files: TlsClientCertificate.cs TlsClientCertificateVerify.cs TlsClientFinished.cs TlsClientHello.cs TlsClientKeyExchange.cs TlsServerCertificate.cs TlsServerCertificateRequest.cs TlsServerFinished.cs TlsServerHello.cs TlsServerHelloDone.cs TlsServerKeyExchange.cs Log Message: 2003-12-14 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: TlsClientCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificate.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TlsClientCertificate.cs 25 Nov 2003 12:36:06 -0000 1.11 --- TlsClientCertificate.cs 14 Dec 2003 15:01:54 -0000 1.12 *************** *** 1,82 **** ! /* 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; ! using System.Security.Cryptography.X509Certificates; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientCertificate : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientCertificate(TlsContext context) ! : base(context, TlsHandshakeType.Certificate) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! this.Reset(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! if (this.Context.ClientSettings.Certificates == null || ! this.Context.ClientSettings.Certificates.Count == 0) ! { ! throw this.Context.CreateException("Client certificate requested by the server and no client certificate specified."); ! } ! ! // Write client certificates information to a stream ! TlsStream stream = new TlsStream(); ! foreach (X509Certificate cert in this.Context.ClientSettings.Certificates) ! { ! stream.WriteInt24(cert.GetRawCertData().Length); ! stream.Write(cert.GetRawCertData()); ! } ! ! // Compose the message ! this.WriteInt24((int)stream.Length); ! this.Write(stream.ToArray()); ! } ! ! #endregion ! } ! } --- 1,82 ---- ! /* 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; ! using System.Security.Cryptography.X509Certificates; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientCertificate : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientCertificate(TlsContext context) ! : base(context, TlsHandshakeType.Certificate) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! this.Reset(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! if (this.Context.ClientSettings.Certificates == null || ! this.Context.ClientSettings.Certificates.Count == 0) ! { ! throw this.Context.CreateException("Client certificate requested by the server and no client certificate specified."); ! } ! ! // Write client certificates information to a stream ! TlsStream stream = new TlsStream(); ! foreach (X509Certificate cert in this.Context.ClientSettings.Certificates) ! { ! stream.WriteInt24(cert.GetRawCertData().Length); ! stream.Write(cert.GetRawCertData()); ! } ! ! // Compose the message ! this.WriteInt24((int)stream.Length); ! this.Write(stream.ToArray()); ! } ! ! #endregion ! } ! } Index: TlsClientCertificateVerify.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** TlsClientCertificateVerify.cs 9 Dec 2003 19:24:44 -0000 1.15 --- TlsClientCertificateVerify.cs 14 Dec 2003 15:01:54 -0000 1.16 *************** *** 1,76 **** ! /* 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.X509Certificates; ! ! using System.Security.Cryptography; ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientCertificateVerify : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientCertificateVerify(TlsContext context) ! : base(context, TlsHandshakeType.Finished) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! this.Reset(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Compute handshake messages hash ! MD5SHA1 hash = new MD5SHA1(); ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! ! // Write message ! Write(hash.CreateSignature(this.Context.Cipher.CreateRSA())); ! } ! ! #endregion ! } ! } --- 1,76 ---- ! /* 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.X509Certificates; ! ! using System.Security.Cryptography; ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientCertificateVerify : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientCertificateVerify(TlsContext context) ! : base(context, TlsHandshakeType.Finished) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! this.Reset(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Compute handshake messages hash ! MD5SHA1 hash = new MD5SHA1(); ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! ! // Write message ! Write(hash.CreateSignature(this.Context.Cipher.CertificateRSA())); ! } ! ! #endregion ! } ! } Index: TlsClientFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TlsClientFinished.cs 25 Nov 2003 12:36:06 -0000 1.13 --- TlsClientFinished.cs 14 Dec 2003 15:01:54 -0000 1.14 *************** *** 1,86 **** ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientFinished : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientFinished(TlsContext context) ! : base(context, TlsHandshakeType.Finished) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! this.Reset(); ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! // Compute handshake messages hashes ! HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret); ! ! TlsStream data = new TlsStream(); ! data.Write(this.Context.HandshakeMessages.ToArray()); ! data.Write((int)0x434C4E54); ! ! hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length); ! ! this.Write(hash.Hash); ! ! data.Reset(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Compute handshake messages hash ! HashAlgorithm hash = new MD5SHA1(); ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! ! // Write message ! Write(this.Context.Cipher.PRF(this.Context.MasterSecret, "client finished", hash.Hash, 12)); ! } ! ! #endregion ! } ! } --- 1,86 ---- ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientFinished : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientFinished(TlsContext context) ! : base(context, TlsHandshakeType.Finished) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! this.Reset(); ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! // Compute handshake messages hashes ! HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret); ! ! TlsStream data = new TlsStream(); ! data.Write(this.Context.HandshakeMessages.ToArray()); ! data.Write((int)0x434C4E54); ! ! hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length); ! ! this.Write(hash.Hash); ! ! data.Reset(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Compute handshake messages hash ! HashAlgorithm hash = new MD5SHA1(); ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! ! // Write message ! Write(this.Context.Cipher.PRF(this.Context.MasterSecret, "client finished", hash.Hash, 12)); ! } ! ! #endregion ! } ! } Index: TlsClientHello.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientHello.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TlsClientHello.cs 25 Nov 2003 12:36:06 -0000 1.11 --- TlsClientHello.cs 14 Dec 2003 15:01:54 -0000 1.12 *************** *** 1,114 **** ! /* 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.Client ! { ! internal class TlsClientHello : TlsHandshakeMessage ! { ! #region FIELDS ! ! private byte[] random; ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsClientHello(TlsContext context) ! : base(context, TlsHandshakeType.ClientHello) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! ! this.Context.ClientRandom = random; ! ! random = null; ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Client Version ! this.Write((short)this.Context.Protocol); ! ! // Random bytes - Unix time + Radom bytes [28] ! TlsStream clientRandom = new TlsStream(); ! clientRandom.Write(this.Context.GetUnixTime()); ! clientRandom.Write(this.Context.GetSecureRandomBytes(28)); ! this.random = clientRandom.ToArray(); ! clientRandom.Reset(); ! ! this.Write(this.random); ! ! // Session id ! // Send the session ID empty ! if (this.Context.SessionId != null) ! { ! this.Write((byte)this.Context.SessionId.Length); ! if (this.Context.SessionId.Length > 0) ! { ! this.Write(this.Context.SessionId); ! } ! } ! else ! { ! this.Write((byte)0); ! } ! ! // Write length of Cipher suites ! this.Write((short)(this.Context.SupportedCiphers.Count*2)); ! ! // Write Supported Cipher suites ! for (int i = 0; i < this.Context.SupportedCiphers.Count; i++) ! { ! this.Write((short)this.Context.SupportedCiphers[i].Code); ! } ! ! // Compression methods length ! this.Write((byte)1); ! ! // Compression methods ( 0 = none ) ! this.Write((byte)this.Context.CompressionMethod); ! } ! ! #endregion ! } } --- 1,114 ---- ! /* 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.Client ! { ! internal class TlsClientHello : TlsHandshakeMessage ! { ! #region Fields ! ! private byte[] random; ! ! #endregion ! ! #region Constructors ! ! public TlsClientHello(TlsContext context) ! : base(context, TlsHandshakeType.ClientHello) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! ! this.Context.ClientRandom = random; ! ! random = null; ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Client Version ! this.Write((short)this.Context.Protocol); ! ! // Random bytes - Unix time + Radom bytes [28] ! TlsStream clientRandom = new TlsStream(); ! clientRandom.Write(this.Context.GetUnixTime()); ! clientRandom.Write(this.Context.GetSecureRandomBytes(28)); ! this.random = clientRandom.ToArray(); ! clientRandom.Reset(); ! ! this.Write(this.random); ! ! // Session id ! // Send the session ID empty ! if (this.Context.SessionId != null) ! { ! this.Write((byte)this.Context.SessionId.Length); ! if (this.Context.SessionId.Length > 0) ! { ! this.Write(this.Context.SessionId); ! } ! } ! else ! { ! this.Write((byte)0); ! } ! ! // Write length of Cipher suites ! this.Write((short)(this.Context.SupportedCiphers.Count*2)); ! ! // Write Supported Cipher suites ! for (int i = 0; i < this.Context.SupportedCiphers.Count; i++) ! { ! this.Write((short)this.Context.SupportedCiphers[i].Code); ! } ! ! // Compression methods length ! this.Write((byte)1); ! ! // Compression methods ( 0 = none ) ! this.Write((byte)this.Context.CompressionMethod); ! } ! ! #endregion ! } } Index: TlsClientKeyExchange.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TlsClientKeyExchange.cs 25 Nov 2003 12:36:06 -0000 1.11 --- TlsClientKeyExchange.cs 14 Dec 2003 15:01:54 -0000 1.12 *************** *** 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.IO; ! using System.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientKeyExchange : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsClientKeyExchange (TlsContext context) : ! base(context, ! TlsHandshakeType.ClientKeyExchange) ! { ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! // Compute pre master secret ! byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret(); ! ! // Create a new RSA key ! RSA rsa = this.Context.Cipher.CreateRSA(); ! ! // Encrypt premaster_sercret ! RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa); ! ! // Write the preMasterSecret encrypted ! byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! this.Write(buffer); ! ! // Create master secret ! this.Context.Cipher.ComputeMasterSecret(preMasterSecret); ! ! // Create keys ! this.Context.Cipher.ComputeKeys(); ! ! // Clear resources ! rsa.Clear(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Compute pre master secret ! byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret(); ! ! // Create a new RSA key ! RSA rsa = this.Context.Cipher.CreateRSA(); ! ! // Encrypt premaster_sercret ! RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa); ! ! // Write the preMasterSecret encrypted ! byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! this.Write((short)buffer.Length); ! this.Write(buffer); ! ! // Create master secret ! this.Context.Cipher.ComputeMasterSecret(preMasterSecret); ! ! // Create keys ! this.Context.Cipher.ComputeKeys(); ! ! // Clear resources ! rsa.Clear(); ! } ! ! #endregion ! } ! } --- 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.IO; ! using System.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsClientKeyExchange : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsClientKeyExchange (TlsContext context) : ! base(context, ! TlsHandshakeType.ClientKeyExchange) ! { ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! // Compute pre master secret ! byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret(); ! ! // Create a new RSA key ! RSA rsa = this.Context.Cipher.CertificateRSA(); ! ! // Encrypt premaster_sercret ! RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa); ! ! // Write the preMasterSecret encrypted ! byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! this.Write(buffer); ! ! // Create master secret ! this.Context.Cipher.ComputeMasterSecret(preMasterSecret); ! ! // Create keys ! this.Context.Cipher.ComputeKeys(); ! ! // Clear resources ! rsa.Clear(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Compute pre master secret ! byte[] preMasterSecret = this.Context.Cipher.CreatePremasterSecret(); ! ! // Create a new RSA key ! RSA rsa = this.Context.Cipher.CertificateRSA(); ! ! // Encrypt premaster_sercret ! RSAPKCS1KeyExchangeFormatter formatter = new RSAPKCS1KeyExchangeFormatter(rsa); ! ! // Write the preMasterSecret encrypted ! byte[] buffer = formatter.CreateKeyExchange(preMasterSecret); ! this.Write((short)buffer.Length); ! this.Write(buffer); ! ! // Create master secret ! this.Context.Cipher.ComputeMasterSecret(preMasterSecret); ! ! // Create keys ! this.Context.Cipher.ComputeKeys(); ! ! // Clear resources ! rsa.Clear(); ! } ! ! #endregion ! } ! } Index: TlsServerCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TlsServerCertificate.cs 9 Dec 2003 19:21:33 -0000 1.14 --- TlsServerCertificate.cs 14 Dec 2003 15:01:54 -0000 1.15 *************** *** 1,186 **** ! /* 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.Net; ! using System.Collections; ! using System.Text.RegularExpressions; ! using System.Security.Cryptography; ! using X509Cert = System.Security.Cryptography.X509Certificates; ! ! using Mono.Security.Protocol.Tls.Alerts; ! using Mono.Security.X509; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsServerCertificate : TlsHandshakeMessage ! { ! #region FIELDS ! ! private X509CertificateCollection certificates; ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsServerCertificate(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Certificate, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! this.Context.ServerSettings.Certificates = certificates; ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! this.certificates = new X509CertificateCollection(); ! ! int readed = 0; ! int length = this.ReadInt24(); ! ! while (readed < length) ! { ! // Read certificate length ! int certLength = ReadInt24(); ! ! // Increment readed ! readed += 3; ! ! if (certLength > 0) ! { ! // Read certificate ! X509Certificate certificate = new X509Certificate(this.ReadBytes(certLength)); ! certificates.Add(certificate); ! ! readed += certLength; ! } ! } ! ! #warning Correct validation needs to be made using a certificate chain ! ! // Restrict validation to the first certificate ! this.validateCertificate(certificates[0]); ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private void validateCertificate(X509Certificate certificate) ! { ! ArrayList errors = new ArrayList(); ! ! // 1 step : Validate dates ! if (!certificate.IsCurrent) ! { ! errors.Add(0x800B0101); ! } ! ! // 2 step: Validate CA ! ! ! // 3 step: Validate digital sign ! /* ! if (!certificate.VerifySignature(certificate.RSA)) ! { ! throw this.Context.CreateException("Certificate received from the server has invalid signature."); ! } ! */ ! ! // 4 step: Validate domain name ! if (!this.checkDomainName(certificate.SubjectName)) ! { ! errors.Add(0x800B010F); ! } ! ! if (errors.Count > 0) ! { ! int[] certificateErrors = new int[errors.Count]; ! ! for (int i = 0; i < certificateErrors.Length; i++) ! { ! certificateErrors[i] = Convert.ToInt32(errors[i]); ! } ! ! if (!this.Context.SslStream.RaiseServerCertificateValidation( ! new X509Cert.X509Certificate(certificate.RawData), ! new int[]{})) ! { ! throw this.Context.CreateException("Invalid certificate received form server."); ! } ! } ! } ! ! private bool checkDomainName(string subjectName) ! { ! string domainName = String.Empty; ! Regex search = new Regex(@"([\w\s\d]*)\s*=\s*([^,]*)"); ! ! MatchCollection elements = search.Matches(subjectName); ! ! foreach (Match element in elements) ! { ! switch (element.Groups[1].Value.Trim().ToUpper()) ! { ! case "CN": ! domainName = element.Groups[2].Value; ! break; ! } ! } ! ! if (domainName == String.Empty) ! { ! return false; ! } ! else ! { ! string targetHost = this.Context.ClientSettings.TargetHost; ! ! // Check that the IP is correct ! IPAddress ipHost = Dns.Resolve(targetHost).AddressList[0]; ! IPAddress ipDomain = Dns.Resolve(domainName).AddressList[0]; ! ! return (ipHost.Address == ipDomain.Address); ! } ! } ! ! #endregion ! } ! } --- 1,225 ---- ! /* 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.Net; ! using System.Collections; ! using System.Text.RegularExpressions; ! using System.Security.Cryptography; ! using X509Cert = System.Security.Cryptography.X509Certificates; ! ! using Mono.Security.Protocol.Tls.Alerts; ! using Mono.Security.X509; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsServerCertificate : TlsHandshakeMessage ! { ! #region Fields ! ! private X509CertificateCollection certificates; ! ! #endregion ! ! #region Constructors ! ! public TlsServerCertificate(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.Certificate, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! this.Context.ServerSettings.Certificates = certificates; ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! this.ProcessAsTls1(); ! } ! ! protected override void ProcessAsTls1() ! { ! this.certificates = new X509CertificateCollection(); ! ! int readed = 0; ! int length = this.ReadInt24(); ! ! while (readed < length) ! { ! // Read certificate length ! int certLength = ReadInt24(); ! ! // Increment readed ! readed += 3; ! ! if (certLength > 0) ! { ! // Read certificate data ! byte[] buffer = this.ReadBytes(certLength); ! ! // Create a new X509 Certificate ! X509Certificate certificate = new X509Certificate(buffer); ! certificates.Add(certificate); ! ! /* ! System.Text.StringBuilder b = new System.Text.StringBuilder(); ! ! b.AppendFormat( ! "\r\nCertificate {0} | Issuer name {1} | Self signed {2} ({3} bytes) \r\n", ! certificates.Count, ! certificate.IssuerName, ! certificate.IsSelfSigned, ! buffer.Length); ! ! b.Append("Contents: \r\n"); ! ! int byteCount = 0; ! for (int i = 0; i < buffer.Length; i++) ! { ! if (byteCount == 25) ! { ! byteCount = 0; ! b.Append("\r\n"); ! } ! ! b.AppendFormat("{0} ", buffer[i].ToString("x2")); ! ! byteCount++; ! } ! ! System.Diagnostics.Trace.Write(b.ToString()); ! */ ! ! readed += certLength; ! } ! } ! ! #warning Correct validation needs to be made using a certificate chain ! ! // Restrict validation to the first certificate ! this.validateCertificate(certificates[0]); ! } ! ! #endregion ! ! #region Private Methods ! ! private void validateCertificate(X509Certificate certificate) ! { ! ArrayList errors = new ArrayList(); ! ! // 1 step : Validate dates ! if (!certificate.IsCurrent) ! { ! errors.Add(0x800B0101); ! } ! ! // 2 step: Validate CA ! ! ! // 3 step: Validate digital sign ! /* ! if (!certificate.VerifySignature(certificate.RSA)) ! { ! throw this.Context.CreateException("Certificate received from the server has invalid signature."); ! } ! */ ! ! // 4 step: Validate domain name ! if (!this.checkDomainName(certificate.SubjectName)) ! { ! errors.Add(0x800B010F); ! } ! ! if (errors.Count > 0) ! { ! int[] certificateErrors = new int[errors.Count]; ! ! for (int i = 0; i < certificateErrors.Length; i++) ! { ! certificateErrors[i] = Convert.ToInt32(errors[i]); ! } ! ! if (!this.Context.SslStream.RaiseServerCertificateValidation( ! new X509Cert.X509Certificate(certificate.RawData), ! new int[]{})) ! { ! throw this.Context.CreateException("Invalid certificate received form server."); ! } ! } ! } ! ! private bool checkDomainName(string subjectName) ! { ! string domainName = String.Empty; ! Regex search = new Regex(@"([\w\s\d]*)\s*=\s*([^,]*)"); ! ! MatchCollection elements = search.Matches(subjectName); ! ! foreach (Match element in elements) ! { ! switch (element.Groups[1].Value.Trim().ToUpper()) ! { ! case "CN": ! domainName = element.Groups[2].Value; ! break; ! } ! } ! ! if (domainName == String.Empty) ! { ! return false; ! } ! else ! { ! string targetHost = this.Context.ClientSettings.TargetHost; ! ! // Check that the IP is correct ! try ! { ! IPAddress ipHost = Dns.Resolve(targetHost).AddressList[0]; ! IPAddress ipDomain = Dns.Resolve(domainName).AddressList[0]; ! ! return (ipHost.Address == ipDomain.Address); ! } ! catch (Exception) ! { ! return false; ! } ! } ! } ! ! #endregion ! } ! } Index: TlsServerCertificateRequest.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificateRequest.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TlsServerCertificateRequest.cs 25 Nov 2003 12:36:06 -0000 1.8 --- TlsServerCertificateRequest.cs 14 Dec 2003 15:01:54 -0000 1.9 *************** *** 1,112 **** ! /* 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.Text; ! using Mono.Security; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsServerCertificateRequest : TlsHandshakeMessage ! { ! #region FIELDS ! ! private TlsClientCertificateType[] certificateTypes; ! private string[] distinguisedNames; ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsServerCertificateRequest(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ServerHello, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! ! this.Context.ServerSettings.CertificateTypes = this.certificateTypes; ! this.Context.ServerSettings.DistinguisedNames = this.distinguisedNames; ! this.Context.ServerSettings.CertificateRequest = true; ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Read requested certificate types ! int typesCount = this.ReadByte(); ! ! this.certificateTypes = new TlsClientCertificateType[typesCount]; ! ! for (int i = 0; i < typesCount; i++) ! { ! this.certificateTypes[i] = (TlsClientCertificateType)this.ReadByte(); ! } ! ! /* ! * Read requested certificate authorities (Distinguised Names) ! * ! * Name ::= SEQUENCE OF RelativeDistinguishedName ! * ! * RelativeDistinguishedName ::= SET OF AttributeValueAssertion ! * ! * AttributeValueAssertion ::= SEQUENCE { ! * attributeType OBJECT IDENTIFIER ! * attributeValue ANY } ! */ ! if (this.ReadInt16() != 0) ! { ! ASN1 rdn = new ASN1(this.ReadBytes(this.ReadInt16())); ! ! distinguisedNames = new string[rdn.Count]; ! ! #warning "needs testing" ! for (int i = 0; i < rdn.Count; i++) ! { ! // element[0] = attributeType ! // element[1] = attributeValue ! ASN1 element = new ASN1(rdn[i].Value); ! ! distinguisedNames[i] = Encoding.UTF8.GetString(element[1].Value); ! } ! } ! } ! ! #endregion ! } ! } --- 1,112 ---- ! /* 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.Text; ! using Mono.Security; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsServerCertificateRequest : TlsHandshakeMessage ! { ! #region Fields ! ! private TlsClientCertificateType[] certificateTypes; ! private string[] distinguisedNames; ! ! #endregion ! ! #region Constructors ! ! public TlsServerCertificateRequest(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ServerHello, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! ! this.Context.ServerSettings.CertificateTypes = this.certificateTypes; ! this.Context.ServerSettings.DistinguisedNames = this.distinguisedNames; ! this.Context.ServerSettings.CertificateRequest = true; ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! throw new NotSupportedException(); ! } ! ! protected override void ProcessAsTls1() ! { ! // Read requested certificate types ! int typesCount = this.ReadByte(); ! ! this.certificateTypes = new TlsClientCertificateType[typesCount]; ! ! for (int i = 0; i < typesCount; i++) ! { ! this.certificateTypes[i] = (TlsClientCertificateType)this.ReadByte(); ! } ! ! /* ! * Read requested certificate authorities (Distinguised Names) ! * ! * Name ::= SEQUENCE OF RelativeDistinguishedName ! * ! * RelativeDistinguishedName ::= SET OF AttributeValueAssertion ! * ! * AttributeValueAssertion ::= SEQUENCE { ! * attributeType OBJECT IDENTIFIER ! * attributeValue ANY } ! */ ! if (this.ReadInt16() != 0) ! { ! ASN1 rdn = new ASN1(this.ReadBytes(this.ReadInt16())); ! ! distinguisedNames = new string[rdn.Count]; ! ! #warning "needs testing" ! for (int i = 0; i < rdn.Count; i++) ! { ! // element[0] = attributeType ! // element[1] = attributeValue ! ASN1 element = new ASN1(rdn[i].Value); ! ! distinguisedNames[i] = Encoding.UTF8.GetString(element[1].Value); ! } ! } ! } ! ! #endregion ! } ! } Index: TlsServerFinished.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TlsServerFinished.cs 25 Nov 2003 12:36:06 -0000 1.13 --- TlsServerFinished.cs 14 Dec 2003 15:01:54 -0000 1.14 *************** *** 1,118 **** ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsServerFinished : TlsHandshakeMessage ! { ! #region CONSTRUCTORS ! ! public TlsServerFinished(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ServerHello, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! ! // Reset Hahdshake messages information ! this.Context.HandshakeMessages.Reset(); ! ! // Hahdshake is finished ! this.Context.HandshakeFinished = true; ! } ! ! #endregion ! ! #region PROTECTED_METHODS ! ! protected override void ProcessAsSsl3() ! { ! // Compute handshake messages hashes ! HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret); ! ! TlsStream data = new TlsStream(); ! data.Write(this.Context.HandshakeMessages.ToArray()); ! data.Write((int)0x53525652); ! ! hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length); ! ! data.Reset(); ! ! byte[] serverHash = this.ReadBytes((int)Length); ! byte[] clientHash = hash.Hash; ! ! // Check server prf against client prf ! if (clientHash.Length != serverHash.Length) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! for (int i = 0; i < serverHash.Length; i++) ! { ! if (clientHash[i] != serverHash[i]) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! } ! } ! ! protected override void ProcessAsTls1() ! { ! byte[] serverPRF = this.ReadBytes((int)Length); ! HashAlgorithm hash = new MD5SHA1(); ! ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! ! byte[] clientPRF = this.Context.Cipher.PRF(this.Context.MasterSecret, "server finished", hash.Hash, 12); ! ! // Check server prf against client prf ! if (clientPRF.Length != serverPRF.Length) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! for (int i = 0; i < serverPRF.Length; i++) ! { ! if (clientPRF[i] != serverPRF[i]) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! } ! } ! ! #endregion ! } ! } --- 1,118 ---- ! /* 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; ! ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls.Handshake.Client ! { ! internal class TlsServerFinished : TlsHandshakeMessage ! { ! #region Constructors ! ! public TlsServerFinished(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ServerHello, buffer) ! { ! } ! ! #endregion ! ! #region Methods ! ! public override void Update() ! { ! base.Update(); ! ! // Reset Hahdshake messages information ! this.Context.HandshakeMessages.Reset(); ! ! // Hahdshake is finished ! this.Context.HandshakeFinished = true; ! } ! ! #endregion ! ! #region Protected Methods ! ! protected override void ProcessAsSsl3() ! { ! // Compute handshake messages hashes ! HashAlgorithm hash = new TlsSslHandshakeHash(this.Context.MasterSecret); ! ! TlsStream data = new TlsStream(); ! data.Write(this.Context.HandshakeMessages.ToArray()); ! data.Write((int)0x53525652); ! ! hash.TransformFinalBlock(data.ToArray(), 0, (int)data.Length); ! ! data.Reset(); ! ! byte[] serverHash = this.ReadBytes((int)Length); ! byte[] clientHash = hash.Hash; ! ! // Check server prf against client prf ! if (clientHash.Length != serverHash.Length) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! for (int i = 0; i < serverHash.Length; i++) ! { ! if (clientHash[i] != serverHash[i]) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! } ! } ! ! protected override void ProcessAsTls1() ! { ! byte[] serverPRF = this.ReadBytes((int)Length); ! HashAlgorithm hash = new MD5SHA1(); ! ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! ! byte[] clientPRF = this.Context.Cipher.PRF(this.Context.MasterSecret, "server finished", hash.Hash, 12); ! ! // Check server prf against client prf ! if (clientPRF.Length != serverPRF.Length) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! for (int i = 0; i < serverPRF.Length; i++) ! { ! if (clientPRF[i] != serverPRF[i]) ! { ! throw new TlsException("Invalid ServerFinished message received."); ! } ! } ! } ! ! #endregion ! } ! } Index: TlsServerHello.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerHello.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TlsServerHello.cs 25 Nov 2003 12:36:06 -0000 1.14 --- TlsServerHello.cs 14 Dec 2003 15:01:54 -0000 1.15 *************** *** 1,139 **** ! /* 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.Client ! { ! internal class TlsServerHello : TlsHandshakeMessage ! { ! #region FIELDS ! ! private SecurityProtocolType protocol; ! private SecurityCompressionType compressionMethod; ! private byte[] random; ! private byte[] sessionId; ! private CipherSuite cipherSuite; ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsServerHello(TlsContext context, byte[] buffer) ! : base(context, TlsHandshakeType.ServerHello, buffer) ! { ! } ! ! #endregion ! ! #region METHODS ! ! public override void Update() ! { ! base.Update(); ! ! this.Context.SessionId = this.sessionId; ! this.Context.ServerRandom = this.random; ! this.Context.Cipher = this.cipherSuite; ! this.Context.CompressionMethod = this.compressionMethod; ! this.Context.Cipher.Context = this.Context; ! ! // Compute ClientRandom + ServerRandom ! TlsStream random = new TlsStream(); ! random.Write(this.Context.ClientRandom); ! random.Write(this.Context.ServerRandom); ! this.Context.RandomCS = random.ToArray(); ! ! // Server R... [truncated message content] |
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 ! } ! } |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Alerts In directory sc8-pr-cvs1:/tmp/cvs-serv14593 Modified Files: TlsAlert.cs TlsWarningAlertEventArgs.cs Log Message: 2003-12-15 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: TlsAlert.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsAlert.cs 23 Nov 2003 12:51:54 -0000 1.6 --- TlsAlert.cs 14 Dec 2003 15:01:27 -0000 1.7 *************** *** 1,276 **** ! /* 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 TlsContext context; ! private TlsAlertLevel level; ! private TlsAlertDescription description; ! ! #endregion ! ! #region PROPERTIES ! ! public TlsContext Context ! { ! get { return this.context; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsAlert(TlsContext context, ! TlsAlertLevel level, ! TlsAlertDescription description) : base() ! { ! this.context = context; ! this.level = level; ! this.description = description; ! ! this.fill(); ! } ! ! #endregion ! ! #region ABSTRACT_METHODS ! ! public abstract void Update(); ! ! #endregion ! ! #region CONSTRUCTORS ! ! private void fill() ! { ! Write((byte)level); ! Write((byte)description); ! } ! ! #endregion ! ! #region STATIC_METHODS ! ! internal static string GetAlertMessage(TlsAlertDescription description) ! { ! #if (DEBUG) ! 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 received."; ! ! 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 ""; ! } ! #else ! switch (description) ! { ! case TlsAlertDescription.AccessDenied: ! return "Invalid message."; ! ! case TlsAlertDescription.BadCertificate: ! return "Handshake failiure."; ! ! case TlsAlertDescription.BadRecordMAC: ! return "Cryptographic failiure."; ! ! case TlsAlertDescription.CertificateExpired: ! return "Handshake failiure."; ! ! case TlsAlertDescription.CertificateRevoked: ! return "Handshake failiure."; ! ! case TlsAlertDescription.CertificateUnknown: ! return "Handshake failiure."; ! ! case TlsAlertDescription.CloseNotify: ! return "Connection closed."; ! ! case TlsAlertDescription.DecodeError: ! return "Invalid message."; ! ! case TlsAlertDescription.DecompressionFailiure: ! return "Compression error."; ! ! case TlsAlertDescription.DecryptError: ! return "Cryptographic failiure."; ! ! case TlsAlertDescription.DecryptionFailed: ! return "Cryptographic failiure."; ! ! case TlsAlertDescription.ExportRestriction: ! return "Handshake failiure."; ! ! case TlsAlertDescription.HandshakeFailiure: ! return "Handshake failiure."; ! ! case TlsAlertDescription.IlegalParameter: ! return "Handshake failiure."; ! ! case TlsAlertDescription.InsuficientSecurity: ! return "Handshake failiure."; ! ! case TlsAlertDescription.InternalError: ! return "Fatal failiure."; ! ! case TlsAlertDescription.NoRenegotiation: ! return "Handshake failiure."; ! ! case TlsAlertDescription.ProtocolVersion: ! return "Handshake failiure."; ! ! case TlsAlertDescription.RecordOverflow: ! return "Incorrect message."; ! ! case TlsAlertDescription.UnexpectedMessage: ! return "Incorrect message."; ! ! case TlsAlertDescription.UnknownCA: ! return "Handshake failiure."; ! ! case TlsAlertDescription.UnsupportedCertificate: ! return "Handshake failiure."; ! ! case TlsAlertDescription.UserCancelled: ! return "Handshake cancelled by user."; ! ! default: ! return ""; ! } ! #endif ! } ! ! #endregion ! } ! } --- 1,276 ---- ! /* 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 Enumerations ! ! 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 TlsContext context; ! private TlsAlertLevel level; ! private TlsAlertDescription description; ! ! #endregion ! ! #region Properties ! ! public TlsContext Context ! { ! get { return this.context; } ! } ! ! #endregion ! ! #region Constructors ! ! public TlsAlert(TlsContext context, ! TlsAlertLevel level, ! TlsAlertDescription description) : base() ! { ! this.context = context; ! this.level = level; ! this.description = description; ! ! this.fill(); ! } ! ! #endregion ! ! #region Abstract Methods ! ! public abstract void Update(); ! ! #endregion ! ! #region Constructors ! ! private void fill() ! { ! Write((byte)level); ! Write((byte)description); ! } ! ! #endregion ! ! #region Static Methods ! ! internal static string GetAlertMessage(TlsAlertDescription description) ! { ! #if (DEBUG) ! 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 received."; ! ! 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 ""; ! } ! #else ! switch (description) ! { ! case TlsAlertDescription.AccessDenied: ! return "Invalid message."; ! ! case TlsAlertDescription.BadCertificate: ! return "Handshake failiure."; ! ! case TlsAlertDescription.BadRecordMAC: ! return "Cryptographic failiure."; ! ! case TlsAlertDescription.CertificateExpired: ! return "Handshake failiure."; ! ! case TlsAlertDescription.CertificateRevoked: ! return "Handshake failiure."; ! ! case TlsAlertDescription.CertificateUnknown: ! return "Handshake failiure."; ! ! case TlsAlertDescription.CloseNotify: ! return "Connection closed."; ! ! case TlsAlertDescription.DecodeError: ! return "Invalid message."; ! ! case TlsAlertDescription.DecompressionFailiure: ! return "Compression error."; ! ! case TlsAlertDescription.DecryptError: ! return "Cryptographic failiure."; ! ! case TlsAlertDescription.DecryptionFailed: ! return "Cryptographic failiure."; ! ! case TlsAlertDescription.ExportRestriction: ! return "Handshake failiure."; ! ! case TlsAlertDescription.HandshakeFailiure: ! return "Handshake failiure."; ! ! case TlsAlertDescription.IlegalParameter: ! return "Handshake failiure."; ! ! case TlsAlertDescription.InsuficientSecurity: ! return "Handshake failiure."; ! ! case TlsAlertDescription.InternalError: ! return "Fatal failiure."; ! ! case TlsAlertDescription.NoRenegotiation: ! return "Handshake failiure."; ! ! case TlsAlertDescription.ProtocolVersion: ! return "Handshake failiure."; ! ! case TlsAlertDescription.RecordOverflow: ! return "Incorrect message."; ! ! case TlsAlertDescription.UnexpectedMessage: ! return "Incorrect message."; ! ! case TlsAlertDescription.UnknownCA: ! return "Handshake failiure."; ! ! case TlsAlertDescription.UnsupportedCertificate: ! return "Handshake failiure."; ! ! case TlsAlertDescription.UserCancelled: ! return "Handshake cancelled by user."; ! ! default: ! return ""; ! } ! #endif ! } ! ! #endregion ! } ! } Index: TlsWarningAlertEventArgs.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Alerts/TlsWarningAlertEventArgs.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TlsWarningAlertEventArgs.cs 11 Oct 2003 10:08:17 -0000 1.1 --- TlsWarningAlertEventArgs.cs 14 Dec 2003 15:01:27 -0000 1.2 *************** *** 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 ! } ! } --- 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 ! } ! } |
From: <car...@us...> - 2003-12-14 15:01:11
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography In directory sc8-pr-cvs1:/tmp/cvs-serv14522 Added Files: PKCS1.cs Log Message: New class from mono project --- NEW FILE: PKCS1.cs --- // // PKCS1.cs - Implements PKCS#1 primitives. // // Author: // Sebastien Pouliot (spo...@mo...) // // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com) // using System; using System.Security.Cryptography; namespace Mono.Security.Cryptography { // References: // a. PKCS#1: RSA Cryptography Standard // http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/index.html internal class PKCS1 { private static bool Compare (byte[] array1, byte[] array2) { bool result = (array1.Length == array2.Length); if (result) { for (int i=0; i < array1.Length; i++) if (array1[i] != array2[i]) return false; } return result; } private static byte[] xor (byte[] array1, byte[] array2) { byte[] result = new byte [array1.Length]; for (int i=0; i < result.Length; i++) result[i] = (byte) (array1[i] ^ array2[i]); return result; } private static byte[] emptySHA1 = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }; private static byte[] emptySHA256 = { 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 }; private static byte[] emptySHA384 = { 0x38, 0xb0, 0x60, 0xa7, 0x51, 0xac, 0x96, 0x38, 0x4c, 0xd9, 0x32, 0x7e, 0xb1, 0xb1, 0xe3, 0x6a, 0x21, 0xfd, 0xb7, 0x11, 0x14, 0xbe, 0x07, 0x43, 0x4c, 0x0c, 0xc7, 0xbf, 0x63, 0xf6, 0xe1, 0xda, 0x27, 0x4e, 0xde, 0xbf, 0xe7, 0x6f, 0x65, 0xfb, 0xd5, 0x1a, 0xd2, 0xf1, 0x48, 0x98, 0xb9, 0x5b }; private static byte[] emptySHA512 = { 0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd, 0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07, 0xd6, 0x20, 0xe4, 0x05, 0x0b, 0x57, 0x15, 0xdc, 0x83, 0xf4, 0xa9, 0x21, 0xd3, 0x6c, 0xe9, 0xce, 0x47, 0xd0, 0xd1, 0x3c, 0x5d, 0x85, 0xf2, 0xb0, 0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f, 0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81, 0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e }; private static byte[] GetEmptyHash (HashAlgorithm hash) { if (hash is SHA1) return emptySHA1; else if (hash is SHA256) return emptySHA256; else if (hash is SHA384) return emptySHA384; else if (hash is SHA512) return emptySHA512; else return hash.ComputeHash ((byte[])null); } // PKCS #1 v.2.1, Section 4.1 // I2OSP converts a non-negative integer to an octet string of a specified length. public static byte[] I2OSP (int x, int size) { byte[] array = BitConverter.GetBytes (x); Array.Reverse (array, 0, array.Length); return I2OSP (array, size); } public static byte[] I2OSP (byte[] x, int size) { byte[] result = new byte [size]; Array.Copy (x, 0, result, (result.Length - x.Length), x.Length); return result; } // PKCS #1 v.2.1, Section 4.2 // OS2IP converts an octet string to a nonnegative integer. public static byte[] OS2IP (byte[] x) { int i = 0; while ((x [i++] == 0x00) && (i < x.Length)); i--; if (i > 0) { byte[] result = new byte [x.Length - i]; Array.Copy (x, i, result, 0, result.Length); return result; } else return x; } // PKCS #1 v.2.1, Section 5.1.1 public static byte[] RSAEP (RSA rsa, byte[] m) { // c = m^e mod n return rsa.EncryptValue (m); } // PKCS #1 v.2.1, Section 5.1.2 public static byte[] RSADP (RSA rsa, byte[] c) { // m = c^d mod n // Decrypt value may apply CRT optimizations return rsa.DecryptValue (c); } // PKCS #1 v.2.1, Section 5.2.1 public static byte[] RSASP1 (RSA rsa, byte[] m) { // first form: s = m^d mod n // Decrypt value may apply CRT optimizations return rsa.DecryptValue (m); } // PKCS #1 v.2.1, Section 5.2.2 public static byte[] RSAVP1 (RSA rsa, byte[] s) { // m = s^e mod n return rsa.EncryptValue (s); } // PKCS #1 v.2.1, Section 7.1.1 // RSAES-OAEP-ENCRYPT ((n, e), M, L) public static byte[] Encrypt_OAEP (RSA rsa, HashAlgorithm hash, RandomNumberGenerator rng, byte[] M) { int size = rsa.KeySize / 8; int hLen = hash.HashSize / 8; if (M.Length > size - 2 * hLen - 2) throw new CryptographicException ("message too long"); // empty label L SHA1 hash byte[] lHash = GetEmptyHash (hash); int PSLength = (size - M.Length - 2 * hLen - 2); // DB = lHash || PS || 0x01 || M byte[] DB = new byte [lHash.Length + PSLength + 1 + M.Length]; Array.Copy (lHash, 0, DB, 0, lHash.Length); DB [(lHash.Length + PSLength)] = 0x01; Array.Copy (M, 0, DB, (DB.Length - M.Length), M.Length); byte[] seed = new byte [hLen]; rng.GetBytes (seed); byte[] dbMask = MGF1 (hash, seed, size - hLen - 1); byte[] maskedDB = xor (DB, dbMask); byte[] seedMask = MGF1 (hash, maskedDB, hLen); byte[] maskedSeed = xor (seed, seedMask); // EM = 0x00 || maskedSeed || maskedDB byte[] EM = new byte [maskedSeed.Length + maskedDB.Length + 1]; Array.Copy (maskedSeed, 0, EM, 1, maskedSeed.Length); Array.Copy (maskedDB, 0, EM, maskedSeed.Length + 1, maskedDB.Length); byte[] m = OS2IP (EM); byte[] c = RSAEP (rsa, m); return I2OSP (c, size); } // PKCS #1 v.2.1, Section 7.1.2 // RSAES-OAEP-DECRYPT (K, C, L) public static byte[] Decrypt_OAEP (RSA rsa, HashAlgorithm hash, byte[] C) { int size = rsa.KeySize / 8; int hLen = hash.HashSize / 8; if ((size < (2 * hLen + 2)) || (C.Length != size)) throw new CryptographicException ("decryption error"); byte[] c = OS2IP (C); byte[] m = RSADP (rsa, c); byte[] EM = I2OSP (m, size); // split EM = Y || maskedSeed || maskedDB byte[] maskedSeed = new byte [hLen]; Array.Copy (EM, 1, maskedSeed, 0, maskedSeed.Length); byte[] maskedDB = new byte [size - hLen - 1]; Array.Copy (EM, (EM.Length - maskedDB.Length), maskedDB, 0, maskedDB.Length); byte[] seedMask = MGF1 (hash, maskedDB, hLen); byte[] seed = xor (maskedSeed, seedMask); byte[] dbMask = MGF1 (hash, seed, size - hLen - 1); byte[] DB = xor (maskedDB, dbMask); byte[] lHash = GetEmptyHash (hash); // split DB = lHash' || PS || 0x01 || M byte[] dbHash = new byte [lHash.Length]; Array.Copy (DB, 0, dbHash, 0, dbHash.Length); bool h = Compare (lHash, dbHash); // find separator 0x01 int nPos = lHash.Length; while (DB[nPos] == 0) nPos++; int Msize = DB.Length - nPos - 1; byte[] M = new byte [Msize]; Array.Copy (DB, (nPos + 1), M, 0, Msize); // we could have returned EM[0] sooner but would be helping a timing attack if ((EM[0] != 0) || (!h) || (DB[nPos] != 0x01)) return null; return M; } // PKCS #1 v.2.1, Section 7.2.1 // RSAES-PKCS1-V1_5-ENCRYPT ((n, e), M) public static byte[] Encrypt_v15 (RSA rsa, RandomNumberGenerator rng, byte[] M) { int size = rsa.KeySize / 8; if (M.Length > size - 11) throw new CryptographicException ("message too long"); int PSLength = System.Math.Max (8, (size - M.Length - 3)); byte[] PS = new byte [PSLength]; rng.GetNonZeroBytes (PS); byte[] EM = new byte [size]; EM [1] = 0x02; Array.Copy (PS, 0, EM, 2, PSLength); Array.Copy (M, 0, EM, (size - M.Length), M.Length); byte[] m = OS2IP (EM); byte[] c = RSAEP (rsa, m); byte[] C = I2OSP (c, size); return C; } // PKCS #1 v.2.1, Section 7.2.2 // RSAES-PKCS1-V1_5-DECRYPT (K, C) public static byte[] Decrypt_v15 (RSA rsa, byte[] C) { int size = rsa.KeySize / 8; if ((size < 11) || (C.Length != size)) throw new CryptographicException ("decryption error"); byte[] c = OS2IP (C); byte[] m = RSADP (rsa, c); byte[] EM = I2OSP (m, size); if ((EM [0] != 0x00) || (EM [1] != 0x02)) return null; int mPos = 10; // PS is a minimum of 8 bytes + 2 bytes for header while ((EM [mPos] != 0x00) && (mPos < EM.Length)) mPos++; if (EM [mPos] != 0x00) return null; mPos++; byte[] M = new byte [EM.Length - mPos]; Array.Copy (EM, mPos, M, 0, M.Length); return M; } // PKCS #1 v.2.1, Section 8.2.1 // RSASSA-PKCS1-V1_5-SIGN (K, M) public static byte[] Sign_v15 (RSA rsa, HashAlgorithm hash, byte[] hashValue) { int size = (rsa.KeySize >> 3); // div 8 byte[] EM = Encode_v15 (hash, hashValue, size); byte[] m = OS2IP (EM); byte[] s = RSASP1 (rsa, m); byte[] S = I2OSP (s, size); return S; } // PKCS #1 v.2.1, Section 8.2.2 // RSASSA-PKCS1-V1_5-VERIFY ((n, e), M, S) public static bool Verify_v15 (RSA rsa, HashAlgorithm hash, byte[] hashValue, byte[] signature) { int size = (rsa.KeySize >> 3); // div 8 byte[] s = OS2IP (signature); byte[] m = RSAVP1 (rsa, s); byte[] EM2 = I2OSP (m, size); byte[] EM = Encode_v15 (hash, hashValue, size); bool result = Compare (EM, EM2); if (!result) { // NOTE: some signatures don't include the hash OID (pretty lame but real) // and compatible with MS implementation if ((EM2 [0] != 0x00) || (EM2 [0] != 0x01)) return false; // TODO: add more validation byte[] decryptedHash = new byte [hashValue.Length]; Array.Copy (EM2, EM2.Length - hashValue.Length, decryptedHash, 0, decryptedHash.Length); result = Compare (decryptedHash, hashValue); } return result; } // PKCS #1 v.2.1, Section 9.2 // EMSA-PKCS1-v1_5-Encode public static byte[] Encode_v15 (HashAlgorithm hash, byte[] hashValue, int emLength) { if (hashValue.Length != (hash.HashSize >> 3)) throw new CryptographicException ("bad hash length for " + hash.ToString ()); // DigestInfo ::= SEQUENCE { // digestAlgorithm AlgorithmIdentifier, // digest OCTET STRING // } /* string oid = CryptoConfig.MapNameToOID (hash.ToString ()); ASN1 digestAlgorithm = new ASN1 (0x30); digestAlgorithm.Add (new ASN1 (CryptoConfig.EncodeOID (oid))); digestAlgorithm.Add (new ASN1 (0x05)); // NULL ASN1 digest = new ASN1 (0x04, hashValue); ASN1 digestInfo = new ASN1 (0x30); digestInfo.Add (digestAlgorithm); digestInfo.Add (digest); byte[] t = digestInfo.GetBytes (); */ ASN1 digestInfo = new ASN1 (0x30); digestInfo.Add (new ASN1 (0x04, hashValue)); byte[] t = digestInfo.GetBytes(); Array.Copy (hashValue, 0, t, t.Length - hashValue.Length, hashValue.Length); int PSLength = System.Math.Max (8, emLength - t.Length - 3); // PS = PSLength of 0xff // EM = 0x00 | 0x01 | PS | 0x00 | T byte[] EM = new byte [PSLength + t.Length + 3]; EM [1] = 0x01; for (int i=2; i < PSLength + 2; i++) EM[i] = 0xff; Array.Copy (t, 0, EM, PSLength + 3, t.Length); return EM; } // PKCS #1 v.2.1, Section B.2.1 public static byte[] MGF1 (HashAlgorithm hash, byte[] mgfSeed, int maskLen) { // 1. If maskLen > 2^32 hLen, output "mask too long" and stop. // easy - this is impossible by using a int (31bits) as parameter ;-) // BUT with a signed int we do have to check for negative values! if (maskLen < 0) throw new OverflowException(); int mgfSeedLength = mgfSeed.Length; int hLen = (hash.HashSize >> 3); // from bits to bytes int iterations = (maskLen / hLen); if (maskLen % hLen != 0) iterations++; // 2. Let T be the empty octet string. byte[] T = new byte [iterations * hLen]; byte[] toBeHashed = new byte [mgfSeedLength + 4]; int pos = 0; // 3. For counter from 0 to \ceil (maskLen / hLen) - 1, do the following: for (int counter = 0; counter < iterations; counter++) { // a. Convert counter to an octet string C of length 4 octets byte[] C = I2OSP (counter, 4); // b. Concatenate the hash of the seed mgfSeed and C to the octet string T: // T = T || Hash (mgfSeed || C) Array.Copy (mgfSeed, 0, toBeHashed, 0, mgfSeedLength); Array.Copy (C, 0, toBeHashed, mgfSeedLength, 4); byte[] output = hash.ComputeHash (toBeHashed); Array.Copy (output, 0, T, pos, hLen); pos += mgfSeedLength; } // 4. Output the leading maskLen octets of T as the octet string mask. byte[] mask = new byte [maskLen]; Array.Copy (T, 0, mask, 0, maskLen); return mask; } } } |
From: <car...@us...> - 2003-12-14 14:59:59
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography In directory sc8-pr-cvs1:/tmp/cvs-serv14116 Modified Files: HMAC.cs MD5SHA1.cs Log Message: 2003-12-15 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: HMAC.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography/HMAC.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HMAC.cs 10 Nov 2003 12:16:03 -0000 1.3 --- HMAC.cs 14 Dec 2003 14:59:55 -0000 1.4 *************** *** 1,191 **** ! /* 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.Cryptography ! { ! /* ! * References: ! * RFC 2104 (http://www.ietf.org/rfc/rfc2104.txt) ! * RFC 2202 (http://www.ietf.org/rfc/rfc2202.txt) ! * MSDN: ! * ! * Extending the KeyedHashAlgorithm Class (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconextendingkeyedhashalgorithmclass.asp) ! */ ! internal class HMAC : System.Security.Cryptography.KeyedHashAlgorithm ! { ! #region FIELDS ! ! private HashAlgorithm hash; ! private bool hashing; ! ! private byte[] innerPad; ! private byte[] outerPad; ! ! #endregion ! ! #region PROPERTIES ! ! public override byte[] Key ! { ! get { return (byte[])KeyValue.Clone(); } ! set ! { ! if (hashing) ! { ! throw new Exception("Cannot change key during hash operation."); ! } ! ! /* if key is longer than 64 bytes reset it to rgbKey = Hash(rgbKey) */ ! if (value.Length > 64) ! { ! KeyValue = hash.ComputeHash(value); ! } ! else ! { ! KeyValue = (byte[])value.Clone(); ! } ! ! initializePad(); ! } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public HMAC() ! { ! // Create the hash ! hash = MD5.Create(); ! // Set HashSizeValue ! HashSizeValue = hash.HashSize; ! ! // Generate a radom key ! byte[] rgbKey = new byte[64]; ! RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); ! rng.GetNonZeroBytes(rgbKey); ! ! KeyValue = (byte[])rgbKey.Clone(); ! ! this.Initialize(); ! } ! ! public HMAC(string hashName, byte[] rgbKey) ! { ! // Create the hash ! if (hashName == null || hashName.Length == 0) ! { ! hashName = "MD5"; ! } ! hash = HashAlgorithm.Create(hashName); ! // Set HashSizeValue ! HashSizeValue = hash.HashSize; ! ! /* if key is longer than 64 bytes reset it to rgbKey = Hash(rgbKey) */ ! if (rgbKey.Length > 64) ! { ! KeyValue = hash.ComputeHash(rgbKey); ! } ! else ! { ! KeyValue = (byte[])rgbKey.Clone(); ! } ! ! this.Initialize(); ! } ! ! #endregion ! ! #region METHODS ! ! public override void Initialize() ! { ! hash.Initialize(); ! initializePad(); ! hashing = false; ! } ! ! protected override byte[] HashFinal() ! { ! if (!hashing) ! { ! hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0); ! hashing = true; ! } ! // Finalize the original hash ! hash.TransformFinalBlock(new byte[0], 0, 0); ! ! byte[] firstResult = hash.Hash; ! ! hash.Initialize(); ! hash.TransformBlock(outerPad, 0, outerPad.Length, outerPad, 0); ! hash.TransformFinalBlock(firstResult, 0, firstResult.Length); ! ! Initialize(); ! ! return hash.Hash; ! } ! ! protected override void HashCore( ! byte[] array, ! int ibStart, ! int cbSize) ! { ! if (!hashing) ! { ! hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0); ! hashing = true; ! } ! hash.TransformBlock(array, ibStart, cbSize, array, ibStart); ! } ! ! #endregion ! ! #region PRIVATE_METHODS ! ! private void initializePad() ! { ! // Fill pad arrays ! innerPad = new byte[64]; ! outerPad = new byte[64]; ! ! /* Pad the key for inner and outer digest */ ! for (int i = 0 ; i < KeyValue.Length; ++i) ! { ! innerPad[i] = (byte)(KeyValue[i] ^ 0x36); ! outerPad[i] = (byte)(KeyValue[i] ^ 0x5C); ! } ! for (int i = KeyValue.Length; i < 64; ++i) ! { ! innerPad[i] = 0x36; ! outerPad[i] = 0x5C; ! } ! } ! ! #endregion ! } ! } --- 1,191 ---- ! /* 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.Cryptography ! { ! /* ! * References: ! * RFC 2104 (http://www.ietf.org/rfc/rfc2104.txt) ! * RFC 2202 (http://www.ietf.org/rfc/rfc2202.txt) ! * MSDN: ! * ! * Extending the KeyedHashAlgorithm Class (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconextendingkeyedhashalgorithmclass.asp) ! */ ! internal class HMAC : System.Security.Cryptography.KeyedHashAlgorithm ! { ! #region Fields ! ! private HashAlgorithm hash; ! private bool hashing; ! ! private byte[] innerPad; ! private byte[] outerPad; ! ! #endregion ! ! #region Properties ! ! public override byte[] Key ! { ! get { return (byte[])KeyValue.Clone(); } ! set ! { ! if (hashing) ! { ! throw new Exception("Cannot change key during hash operation."); ! } ! ! /* if key is longer than 64 bytes reset it to rgbKey = Hash(rgbKey) */ ! if (value.Length > 64) ! { ! KeyValue = hash.ComputeHash(value); ! } ! else ! { ! KeyValue = (byte[])value.Clone(); ! } ! ! initializePad(); ! } ! } ! ! #endregion ! ! #region Constructors ! ! public HMAC() ! { ! // Create the hash ! hash = MD5.Create(); ! // Set HashSizeValue ! HashSizeValue = hash.HashSize; ! ! // Generate a radom key ! byte[] rgbKey = new byte[64]; ! RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); ! rng.GetNonZeroBytes(rgbKey); ! ! KeyValue = (byte[])rgbKey.Clone(); ! ! this.Initialize(); ! } ! ! public HMAC(string hashName, byte[] rgbKey) ! { ! // Create the hash ! if (hashName == null || hashName.Length == 0) ! { ! hashName = "MD5"; ! } ! hash = HashAlgorithm.Create(hashName); ! // Set HashSizeValue ! HashSizeValue = hash.HashSize; ! ! /* if key is longer than 64 bytes reset it to rgbKey = Hash(rgbKey) */ ! if (rgbKey.Length > 64) ! { ! KeyValue = hash.ComputeHash(rgbKey); ! } ! else ! { ! KeyValue = (byte[])rgbKey.Clone(); ! } ! ! this.Initialize(); ! } ! ! #endregion ! ! #region Methods ! ! public override void Initialize() ! { ! hash.Initialize(); ! initializePad(); ! hashing = false; ! } ! ! protected override byte[] HashFinal() ! { ! if (!hashing) ! { ! hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0); ! hashing = true; ! } ! // Finalize the original hash ! hash.TransformFinalBlock(new byte[0], 0, 0); ! ! byte[] firstResult = hash.Hash; ! ! hash.Initialize(); ! hash.TransformBlock(outerPad, 0, outerPad.Length, outerPad, 0); ! hash.TransformFinalBlock(firstResult, 0, firstResult.Length); ! ! Initialize(); ! ! return hash.Hash; ! } ! ! protected override void HashCore( ! byte[] array, ! int ibStart, ! int cbSize) ! { ! if (!hashing) ! { ! hash.TransformBlock(innerPad, 0, innerPad.Length, innerPad, 0); ! hashing = true; ! } ! hash.TransformBlock(array, ibStart, cbSize, array, ibStart); ! } ! ! #endregion ! ! #region Private Methods ! ! private void initializePad() ! { ! // Fill pad arrays ! innerPad = new byte[64]; ! outerPad = new byte[64]; ! ! /* Pad the key for inner and outer digest */ ! for (int i = 0 ; i < KeyValue.Length; ++i) ! { ! innerPad[i] = (byte)(KeyValue[i] ^ 0x36); ! outerPad[i] = (byte)(KeyValue[i] ^ 0x5C); ! } ! for (int i = KeyValue.Length; i < 64; ++i) ! { ! innerPad[i] = 0x36; ! outerPad[i] = 0x5C; ! } ! } ! ! #endregion ! } ! } Index: MD5SHA1.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MD5SHA1.cs 7 Dec 2003 14:59:24 -0000 1.2 --- MD5SHA1.cs 14 Dec 2003 14:59:55 -0000 1.3 *************** *** 1,125 **** ! /* 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.Cryptography ! { ! internal class MD5SHA1 : HashAlgorithm ! { ! #region FIELDS ! ! private HashAlgorithm md5; ! private HashAlgorithm sha; ! private bool hashing; ! ! #endregion ! ! #region CONSTRUCTORS ! ! public MD5SHA1() : base() ! { ! this.md5 = MD5.Create(); ! this.sha = SHA1.Create(); ! ! // Set HashSizeValue ! this.HashSizeValue = this.md5.HashSize + this.sha.HashSize; ! } ! ! #endregion ! ! #region METHODS ! ! public override void Initialize() ! { ! this.md5.Initialize(); ! this.sha.Initialize(); ! this.hashing = false; ! } ! ! protected override byte[] HashFinal() ! { ! if (!hashing) ! { ! this.hashing = true; ! } ! // Finalize the original hash ! this.md5.TransformFinalBlock(new byte[0], 0, 0); ! this.sha.TransformFinalBlock(new byte[0], 0, 0); ! ! byte[] hash = new byte[36]; ! ! System.Array.Copy(this.md5.Hash, 0, hash, 0, 16); ! System.Array.Copy(this.sha.Hash, 0, hash, 16, 20); ! ! return hash; ! } ! ! protected override void HashCore( ! byte[] array, ! int ibStart, ! int cbSize) ! { ! if (!hashing) ! { ! hashing = true; ! } ! this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart); ! this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart); ! } ! ! public byte[] CreateSignature(RSA rsa) ! { ! if (rsa == null) ! { ! throw new CryptographicUnexpectedOperationException ("missing key"); ! } ! ! RSAPKCS1SignatureFormatter f = new RSAPKCS1SignatureFormatter(rsa); ! f.SetHashAlgorithm("MD5SHA1"); ! ! return f.CreateSignature(this.Hash); ! } ! ! public bool VerifySignature(RSA rsa, byte[] rgbSignature) ! { ! if (rsa == null) ! { ! throw new CryptographicUnexpectedOperationException ("missing key"); ! } ! if (rgbSignature == null) ! { ! throw new ArgumentNullException ("rgbSignature"); ! } ! ! RSAPKCS1SignatureDeformatter d = new RSAPKCS1SignatureDeformatter(rsa); ! d.SetHashAlgorithm("MD5SHA1"); ! ! return d.VerifySignature(this.Hash, rgbSignature); ! } ! ! #endregion ! } ! } --- 1,130 ---- ! /* 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; ! ! using Mono.Security.Protocol.Tls; ! ! namespace Mono.Security.Cryptography ! { ! internal class MD5SHA1 : HashAlgorithm ! { ! #region Fields ! ! private HashAlgorithm md5; ! private HashAlgorithm sha; ! private bool hashing; ! ! #endregion ! ! #region Constructors ! ! public MD5SHA1() : base() ! { ! this.md5 = MD5.Create(); ! this.sha = SHA1.Create(); ! ! // Set HashSizeValue ! this.HashSizeValue = this.md5.HashSize + this.sha.HashSize; ! } ! ! #endregion ! ! #region Methods ! ! public override void Initialize() ! { ! this.md5.Initialize(); ! this.sha.Initialize(); ! this.hashing = false; ! } ! ! protected override byte[] HashFinal() ! { ! if (!hashing) ! { ! this.hashing = true; ! } ! // Finalize the original hash ! this.md5.TransformFinalBlock(new byte[0], 0, 0); ! this.sha.TransformFinalBlock(new byte[0], 0, 0); ! ! byte[] hash = new byte[36]; ! ! System.Array.Copy(this.md5.Hash, 0, hash, 0, 16); ! System.Array.Copy(this.sha.Hash, 0, hash, 16, 20); ! ! return hash; ! } ! ! protected override void HashCore( ! byte[] array, ! int ibStart, ! int cbSize) ! { ! if (!hashing) ! { ! hashing = true; ! } ! this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart); ! this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart); ! } ! ! public byte[] CreateSignature(RSA rsa) ! { ! if (rsa == null) ! { ! throw new CryptographicUnexpectedOperationException ("missing key"); ! } ! ! RSASSLSignatureFormatter f = new RSASSLSignatureFormatter(rsa); ! f.SetHashAlgorithm("MD5SHA1"); ! ! return f.CreateSignature(this.Hash); ! } ! ! public bool VerifySignature(RSA rsa, byte[] rgbSignature) ! { ! if (rsa == null) ! { ! throw new CryptographicUnexpectedOperationException ("missing key"); ! } ! if (rgbSignature == null) ! { ! throw new ArgumentNullException ("rgbSignature"); ! } ! ! RSAManaged rsam = new RSAManaged(); ! rsam.ImportParameters(rsa.ExportParameters(false)); ! ! RSASSLSignatureDeformatter d = new RSASSLSignatureDeformatter(rsam); ! d.SetHashAlgorithm("MD5SHA1"); ! ! return d.VerifySignature(this.Hash, rgbSignature); ! } ! ! #endregion ! } ! } |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv14073 Modified Files: CipherSuite.cs SslClientStream.cs SslServerStream.cs TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsCipherSuiteFactory.cs TlsClientSettings.cs TlsContext.cs TlsException.cs TlsServerSettings.cs TlsSslCipherSuite.cs TlsSslHandshakeHash.cs TlsStream.cs Log Message: 2003-12-15 Carlos Guzmán Álvarez <car...@te...> * Changed #region names in all source files. Index: CipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/CipherSuite.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CipherSuite.cs 22 Nov 2003 14:43:51 -0000 1.10 --- CipherSuite.cs 14 Dec 2003 14:59:39 -0000 1.11 *************** *** 1,547 **** ! /* 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: [...1054 lines suppressed...] ! this.decryptionAlgorithm.KeySize = this.keyMaterialSize * 8; ! this.decryptionAlgorithm.BlockSize = this.blockSize * 8; ! } ! ! // Set the key and IV for the algorithm ! this.decryptionAlgorithm.Key = this.context.ServerWriteKey; ! this.decryptionAlgorithm.IV = this.context.ServerWriteIV; ! ! // Create decryption cipher ! this.decryptionCipher = this.decryptionAlgorithm.CreateDecryptor(); ! ! // Create the HMAC algorithm for the server ! this.serverHMAC = new M.HMAC( ! this.HashAlgorithmName, ! this.context.ServerWriteMAC); ! } ! ! #endregion ! } } Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SslClientStream.cs 9 Dec 2003 19:19:04 -0000 1.9 --- SslClientStream.cs 14 Dec 2003 14:59:39 -0000 1.10 *************** *** 1,1108 **** ! /* 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: [...2187 lines suppressed...] ! X509CertificateCollection clientCertificates, ! X509Certificate serverCertificate, ! string targetHost, ! X509CertificateCollection serverRequestedCertificates) ! { ! if (this.ClientCertSelection != null) ! { ! return this.ClientCertSelection( ! clientCertificates, ! serverCertificate, ! targetHost, ! serverRequestedCertificates); ! } ! ! return null; ! } ! ! #endregion ! } ! } Index: SslServerStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SslServerStream.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SslServerStream.cs 23 Nov 2003 12:50:08 -0000 1.1 --- SslServerStream.cs 14 Dec 2003 14:59:39 -0000 1.2 *************** *** 1,281 **** ! /* 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.IO; ! using System.Security.Cryptography.X509Certificates; ! ! namespace Mono.Security.Protocol.Tls ! { ! public class SslServerStream : Stream, IDisposable ! { ! #region FIELDS ! ! private Stream innerStream; ! private bool disposed; ! private bool ownsStream; ! ! #endregion ! ! #region PROPERTIES ! ! public override bool CanRead ! { ! get { return this.innerStream.CanRead; } ! } ! ! public override bool CanWrite ! { ! get { return this.innerStream.CanWrite; } ! } ! ! public override bool CanSeek ! { ! get { return this.innerStream.CanSeek; } ! } ! ! public override long Length ! { ! get { throw new NotSupportedException(); } ! } ! ! public override long Position ! { ! get { throw new NotSupportedException(); } ! set { throw new NotSupportedException(); } ! } ! ! #endregion ! ! #region SECURITY_PROPERTIES ! ! public bool CheckCertRevocationStatus ! { ! get { throw new NotSupportedException(); } ! set { throw new NotSupportedException(); } ! } ! ! public CipherAlgorithmType CipherAlgorithm ! { ! get { throw new NotSupportedException(); } ! } ! ! public int CipherStrength ! { ! get { throw new NotSupportedException(); } ! } ! ! public X509Certificate ClientCertificate ! { ! get { throw new NotSupportedException(); } ! } ! ! public CertificateValidationCallback ClientCertValidationDelegate ! { ! get { throw new NotSupportedException(); } ! set { throw new NotSupportedException(); } ! } ! ! public HashAlgorithmType HashAlgorithm ! { ! get { throw new NotSupportedException(); } ! } ! ! public int HashStrength ! { ! get { throw new NotSupportedException(); } ! } ! ! public int KeyExchangeStrength ! { ! get { throw new NotSupportedException(); } ! } ! ! public ExchangeAlgorithmType KeyExchangeAlgorithm ! { ! get { throw new NotSupportedException(); } ! } ! ! public SecurityProtocolType SecurityProtocol ! { ! get { throw new NotSupportedException(); } ! } ! ! public X509Certificate ServerCertificate ! { ! get { throw new NotSupportedException(); } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public SslServerStream(Stream stream, X509Certificate serverCertificate) ! { ! } ! ! public SslServerStream( ! Stream stream, ! X509Certificate serverCertificate, ! bool clientCertificateRequired, ! bool ownsStream) ! { ! } ! ! public SslServerStream( ! Stream stream, ! X509Certificate serverCertificate, ! bool clientCertificateRequired, ! bool ownsStream, ! SecurityProtocolType securityProtocolType) ! { ! } ! ! #endregion ! ! #region DESTRUCTOR ! ! ~SslServerStream() ! { ! this.Dispose(false); ! } ! ! #endregion ! ! #region IDISPOSABLE ! ! void IDisposable.Dispose() ! { ! this.Dispose(true); ! GC.SuppressFinalize(this); ! } ! ! protected virtual void Dispose(bool disposing) ! { ! if (!this.disposed) ! { ! if (disposing) ! { ! if (this.innerStream != null) ! { ! if (this.ownsStream) ! { ! // Close inner stream ! this.innerStream.Close(); ! } ! } ! this.ownsStream = false; ! this.innerStream = null; ! } ! ! this.disposed = true; ! } ! } ! ! #endregion ! ! #region METHODS ! ! public override IAsyncResult BeginRead( ! byte[] buffer, ! int offset, ! int count, ! AsyncCallback asyncCallback, ! object asyncState) ! { ! throw new NotSupportedException(); ! } ! ! public override IAsyncResult BeginWrite( ! byte[] buffer, ! int offset, ! int count, ! AsyncCallback asyncCallback, ! object asyncState) ! { ! throw new NotSupportedException(); ! } ! ! public override void Close() ! { ! throw new NotSupportedException(); ! } ! ! public override int EndRead(IAsyncResult asyncResult) ! { ! throw new NotSupportedException(); ! } ! ! public override void EndWrite(IAsyncResult asyncResult) ! { ! throw new NotSupportedException(); ! } ! ! public override void Flush() ! { ! if (this.disposed) ! { ! throw new ObjectDisposedException("The NetworkStream is closed."); ! } ! } ! ! public int Read(byte[] buffer) ! { ! throw new NotSupportedException(); ! } ! ! public override int Read( ! byte[] buffer, ! int offset, ! int count) ! { ! throw new NotSupportedException(); ! } ! ! public override long Seek(long offset, SeekOrigin origin) ! { ! throw new NotSupportedException(); ! } ! ! public override void SetLength(long value) ! { ! throw new NotSupportedException(); ! } ! ! public void Write(byte[] buffer) ! { ! throw new NotSupportedException(); ! } ! ! public override void Write( ! byte[] buffer, ! int offset, ! int count) ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } --- 1,281 ---- ! /* 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.IO; ! using System.Security.Cryptography.X509Certificates; ! ! namespace Mono.Security.Protocol.Tls ! { ! public class SslServerStream : Stream, IDisposable ! { ! #region Fields ! ! private Stream innerStream; ! private bool disposed; ! private bool ownsStream; ! ! #endregion ! ! #region Properties ! ! public override bool CanRead ! { ! get { return this.innerStream.CanRead; } ! } ! ! public override bool CanWrite ! { ! get { return this.innerStream.CanWrite; } ! } ! ! public override bool CanSeek ! { ! get { return this.innerStream.CanSeek; } ! } ! ! public override long Length ! { ! get { throw new NotSupportedException(); } ! } ! ! public override long Position ! { ! get { throw new NotSupportedException(); } ! set { throw new NotSupportedException(); } ! } ! ! #endregion ! ! #region Security Properties ! ! public bool CheckCertRevocationStatus ! { ! get { throw new NotSupportedException(); } ! set { throw new NotSupportedException(); } ! } ! ! public CipherAlgorithmType CipherAlgorithm ! { ! get { throw new NotSupportedException(); } ! } ! ! public int CipherStrength ! { ! get { throw new NotSupportedException(); } ! } ! ! public X509Certificate ClientCertificate ! { ! get { throw new NotSupportedException(); } ! } ! ! public CertificateValidationCallback ClientCertValidationDelegate ! { ! get { throw new NotSupportedException(); } ! set { throw new NotSupportedException(); } ! } ! ! public HashAlgorithmType HashAlgorithm ! { ! get { throw new NotSupportedException(); } ! } ! ! public int HashStrength ! { ! get { throw new NotSupportedException(); } ! } ! ! public int KeyExchangeStrength ! { ! get { throw new NotSupportedException(); } ! } ! ! public ExchangeAlgorithmType KeyExchangeAlgorithm ! { ! get { throw new NotSupportedException(); } ! } ! ! public SecurityProtocolType SecurityProtocol ! { ! get { throw new NotSupportedException(); } ! } ! ! public X509Certificate ServerCertificate ! { ! get { throw new NotSupportedException(); } ! } ! ! #endregion ! ! #region Constructors ! ! public SslServerStream(Stream stream, X509Certificate serverCertificate) ! { ! } ! ! public SslServerStream( ! Stream stream, ! X509Certificate serverCertificate, ! bool clientCertificateRequired, ! bool ownsStream) ! { ! } ! ! public SslServerStream( ! Stream stream, ! X509Certificate serverCertificate, ! bool clientCertificateRequired, ! bool ownsStream, ! SecurityProtocolType securityProtocolType) ! { ! } ! ! #endregion ! ! #region Finalizer ! ! ~SslServerStream() ! { ! this.Dispose(false); ! } ! ! #endregion ! ! #region IDisposable Methods ! ! void IDisposable.Dispose() ! { ! this.Dispose(true); ! GC.SuppressFinalize(this); ! } ! ! protected virtual void Dispose(bool disposing) ! { ! if (!this.disposed) ! { ! if (disposing) ! { ! if (this.innerStream != null) ! { ! if (this.ownsStream) ! { ! // Close inner stream ! this.innerStream.Close(); ! } ! } ! this.ownsStream = false; ! this.innerStream = null; ! } ! ! this.disposed = true; ! } ! } ! ! #endregion ! ! #region Methods ! ! public override IAsyncResult BeginRead( ! byte[] buffer, ! int offset, ! int count, ! AsyncCallback asyncCallback, ! object asyncState) ! { ! throw new NotSupportedException(); ! } ! ! public override IAsyncResult BeginWrite( ! byte[] buffer, ! int offset, ! int count, ! AsyncCallback asyncCallback, ! object asyncState) ! { ! throw new NotSupportedException(); ! } ! ! public override void Close() ! { ! throw new NotSupportedException(); ! } ! ! public override int EndRead(IAsyncResult asyncResult) ! { ! throw new NotSupportedException(); ! } ! ! public override void EndWrite(IAsyncResult asyncResult) ! { ! throw new NotSupportedException(); ! } ! ! public override void Flush() ! { ! if (this.disposed) ! { ! throw new ObjectDisposedException("The NetworkStream is closed."); ! } ! } ! ! public int Read(byte[] buffer) ! { ! throw new NotSupportedException(); ! } ! ! public override int Read( ! byte[] buffer, ! int offset, ! int count) ! { ! throw new NotSupportedException(); ! } ! ! public override long Seek(long offset, SeekOrigin origin) ! { ! throw new NotSupportedException(); ! } ! ! public override void SetLength(long value) ! { ! throw new NotSupportedException(); ! } ! ! public void Write(byte[] buffer) ! { ! throw new NotSupportedException(); ! } ! ! public override void Write( ! byte[] buffer, ! int offset, ! int count) ! { ! throw new NotSupportedException(); ! } ! ! #endregion ! } ! } Index: TlsCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuite.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TlsCipherSuite.cs 13 Nov 2003 09:21:52 -0000 1.9 --- TlsCipherSuite.cs 14 Dec 2003 14:59:39 -0000 1.10 *************** *** 1,158 **** ! /* 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.IO; ! using System.Text; ! using System.Security.Cryptography; ! using System.Security.Cryptography.X509Certificates; ! ! using Mono.Security; ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls ! { ! internal class TlsCipherSuite : CipherSuite ! { ! #region CONSTRUCTORS ! ! public TlsCipherSuite( ! short code, string name, CipherAlgorithmType cipherAlgorithmType, ! HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType, ! bool exportable, bool blockMode, byte keyMaterialSize, ! byte expandedKeyMaterialSize, short effectiveKeyBytes, ! byte ivSize, byte blockSize) : ! base(code, name, cipherAlgorithmType, hashAlgorithmType, ! exchangeAlgorithmType, exportable, blockMode, keyMaterialSize, ! expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize) ! { ! } ! ! #endregion ! ! #region MAC_GENERATION_METHOD ! ! public override byte[] ComputeServerRecordMAC(TlsContentType contentType, byte[] fragment) ! { ! TlsStream data = new TlsStream(); ! byte[] result = null; ! ! data.Write(this.Context.ReadSequenceNumber); ! data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); ! data.Write((short)fragment.Length); ! data.Write(fragment); ! ! result = this.ServerHMAC.ComputeHash(data.ToArray()); ! ! data.Reset(); ! ! return result; ! } ! ! public override byte[] ComputeClientRecordMAC(TlsContentType contentType, byte[] fragment) ! { ! TlsStream data = new TlsStream(); ! byte[] result = null; ! ! data.Write(this.Context.WriteSequenceNumber); ! data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); ! data.Write((short)fragment.Length); ! data.Write(fragment); ! ! result = this.ClientHMAC.ComputeHash(data.ToArray()); ! ! data.Reset(); ! ! return result; ! } ! ! #endregion ! ! #region KEY_GENERATION_METODS ! ! public override void ComputeMasterSecret(byte[] preMasterSecret) ! { ! // Create master secret ! this.Context.MasterSecret = new byte[preMasterSecret.Length]; ! this.Context.MasterSecret = this.PRF( ! preMasterSecret, "master secret", this.Context.RandomCS, 48); ! } ! ! public override void ComputeKeys() ! { ! // Create keyblock ! TlsStream keyBlock = new TlsStream( ! this.PRF( ! this.Context.MasterSecret, ! "key expansion", ! this.Context.RandomSC, ! this.KeyBlockSize)); ! ! this.Context.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ClientWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! this.Context.ServerWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! ! if (!this.IsExportable) ! { ! if (this.IvSize != 0) ! { ! this.Context.ClientWriteIV = keyBlock.ReadBytes(this.IvSize); ! this.Context.ServerWriteIV = keyBlock.ReadBytes(this.IvSize); ! } ! else ! { ! this.Context.ClientWriteIV = new byte[0]; ! this.Context.ServerWriteIV = new byte[0]; ! } ! } ! else ! { ! // Generate final write keys ! byte[] finalClientWriteKey = PRF(this.Context.ClientWriteKey, "client write key", this.Context.RandomCS, this.KeyMaterialSize); ! byte[] finalServerWriteKey = PRF(this.Context.ServerWriteKey, "server write key", this.Context.RandomCS, this.KeyMaterialSize); ! ! this.Context.ClientWriteKey = finalClientWriteKey; ! this.Context.ServerWriteKey = finalServerWriteKey; ! ! // Generate IV block ! byte[] ivBlock = PRF(new byte[]{}, "IV block", this.Context.RandomCS, this.IvSize*2); ! ! // Generate IV keys ! this.Context.ClientWriteIV = new byte[this.IvSize]; ! System.Array.Copy(ivBlock, 0, this.Context.ClientWriteIV, 0, this.Context.ClientWriteIV.Length); ! ! this.Context.ServerWriteIV = new byte[this.IvSize]; ! System.Array.Copy(ivBlock, this.IvSize, this.Context.ServerWriteIV, 0, this.Context.ServerWriteIV.Length); ! } ! ! // Clear no more needed data ! keyBlock.Reset(); ! } ! ! #endregion ! } } --- 1,158 ---- ! /* 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.IO; ! using System.Text; ! using System.Security.Cryptography; ! using System.Security.Cryptography.X509Certificates; ! ! using Mono.Security; ! using Mono.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls ! { ! internal class TlsCipherSuite : CipherSuite ! { ! #region Constructors ! ! public TlsCipherSuite( ! short code, string name, CipherAlgorithmType cipherAlgorithmType, ! HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType, ! bool exportable, bool blockMode, byte keyMaterialSize, ! byte expandedKeyMaterialSize, short effectiveKeyBytes, ! byte ivSize, byte blockSize) : ! base(code, name, cipherAlgorithmType, hashAlgorithmType, ! exchangeAlgorithmType, exportable, blockMode, keyMaterialSize, ! expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize) ! { ! } ! ! #endregion ! ! #region MAC Generation Methods ! ! public override byte[] ComputeServerRecordMAC(TlsContentType contentType, byte[] fragment) ! { ! TlsStream data = new TlsStream(); ! byte[] result = null; ! ! data.Write(this.Context.ReadSequenceNumber); ! data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); ! data.Write((short)fragment.Length); ! data.Write(fragment); ! ! result = this.ServerHMAC.ComputeHash(data.ToArray()); ! ! data.Reset(); ! ! return result; ! } ! ! public override byte[] ComputeClientRecordMAC(TlsContentType contentType, byte[] fragment) ! { ! TlsStream data = new TlsStream(); ! byte[] result = null; ! ! data.Write(this.Context.WriteSequenceNumber); ! data.Write((byte)contentType); ! data.Write((short)this.Context.Protocol); ! data.Write((short)fragment.Length); ! data.Write(fragment); ! ! result = this.ClientHMAC.ComputeHash(data.ToArray()); ! ! data.Reset(); ! ! return result; ! } ! ! #endregion ! ! #region Key Generation Methods ! ! public override void ComputeMasterSecret(byte[] preMasterSecret) ! { ! // Create master secret ! this.Context.MasterSecret = new byte[preMasterSecret.Length]; ! this.Context.MasterSecret = this.PRF( ! preMasterSecret, "master secret", this.Context.RandomCS, 48); ! } ! ! public override void ComputeKeys() ! { ! // Create keyblock ! TlsStream keyBlock = new TlsStream( ! this.PRF( ! this.Context.MasterSecret, ! "key expansion", ! this.Context.RandomSC, ! this.KeyBlockSize)); ! ! this.Context.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize); ! this.Context.ClientWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! this.Context.ServerWriteKey = keyBlock.ReadBytes(this.KeyMaterialSize); ! ! if (!this.IsExportable) ! { ! if (this.IvSize != 0) ! { ! this.Context.ClientWriteIV = keyBlock.ReadBytes(this.IvSize); ! this.Context.ServerWriteIV = keyBlock.ReadBytes(this.IvSize); ! } ! else ! { ! this.Context.ClientWriteIV = new byte[0]; ! this.Context.ServerWriteIV = new byte[0]; ! } ! } ! else ! { ! // Generate final write keys ! byte[] finalClientWriteKey = PRF(this.Context.ClientWriteKey, "client write key", this.Context.RandomCS, this.KeyMaterialSize); ! byte[] finalServerWriteKey = PRF(this.Context.ServerWriteKey, "server write key", this.Context.RandomCS, this.KeyMaterialSize); ! ! this.Context.ClientWriteKey = finalClientWriteKey; ! this.Context.ServerWriteKey = finalServerWriteKey; ! ! // Generate IV block ! byte[] ivBlock = PRF(new byte[]{}, "IV block", this.Context.RandomCS, this.IvSize*2); ! ! // Generate IV keys ! this.Context.ClientWriteIV = new byte[this.IvSize]; ! System.Array.Copy(ivBlock, 0, this.Context.ClientWriteIV, 0, this.Context.ClientWriteIV.Length); ! ! this.Context.ServerWriteIV = new byte[this.IvSize]; ! System.Array.Copy(ivBlock, this.IvSize, this.Context.ServerWriteIV, 0, this.Context.ServerWriteIV.Length); ! } ! ! // Clear no more needed data ! keyBlock.Reset(); ! } ! ! #endregion ! } } Index: TlsCipherSuiteCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TlsCipherSuiteCollection.cs 14 Nov 2003 13:40:40 -0000 1.6 --- TlsCipherSuiteCollection.cs 14 Dec 2003 14:59:39 -0000 1.7 *************** *** 1,167 **** ! /* 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.Collections; ! using System.Globalization; ! using System.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls ! { ! internal sealed class TlsCipherSuiteCollection : ArrayList ! { ! #region FIELDS ! ! private SecurityProtocolType protocol; ! ! #endregion ! ! #region PROPERTIES ! ! public CipherSuite this[string name] ! { ! get { return (CipherSuite)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (CipherSuite)value; } ! } ! ! public CipherSuite this[short code] ! { ! get { return (CipherSuite)base[IndexOf(code)]; } ! set { base[IndexOf(code)] = (CipherSuite)value; } ! } ! ! public new CipherSuite this[int code] ! { ! get { return (CipherSuite)base[code]; } ! set { base[code] = (CipherSuite)value; } ! } ! ! #endregion ! ! #region CONSTRUCTORS ! ! public TlsCipherSuiteCollection(SecurityProtocolType protocol) : base() ! { ! this.protocol = protocol; ! } ! ! #endregion ! ! #region METHODS ! ! public bool Contains(string name) ! { ! return(-1 != IndexOf(name)); ! } ! ! public int IndexOf(string name) ! { ! int index = 0; ! foreach (CipherSuite suite in this) ! { ! if (cultureAwareCompare(suite.Name, name)) ! { ! return index; ! } ! index++; ! } ! return -1; ! } ! ! public int IndexOf(short code) ! { ! int index = 0; ! foreach (CipherSuite suite in this) ! { ! if (suite.Code == code) ! { ! return index; ! } ! index++; ! } ! return -1; ! } ! ! public void RemoveAt(string errorMessage) ! { ! RemoveAt(IndexOf(errorMessage)); ! } ! ! public CipherSuite Add( ! short code, string name, CipherAlgorithmType cipherType, ! HashAlgorithmType hashType, ExchangeAlgorithmType exchangeType, ! bool exportable, bool blockMode, byte keyMaterialSize, ! byte expandedKeyMaterialSize, short effectiveKeyBytes, ! byte ivSize, byte blockSize) ! { ! switch (this.protocol) ! { ! case SecurityProtocolType.Ssl3: ! return this.add( ! new TlsSslCipherSuite( ! code, name, cipherType, hashType, exchangeType, exportable, ! blockMode, keyMaterialSize, expandedKeyMaterialSize, ! effectiveKeyBytes, ivSize, blockSize)); ! ! case SecurityProtocolType.Tls: ! return this.add( ! new TlsCipherSuite( ! code, name, cipherType, hashType, exchangeType, exportable, ! blockMode, keyMaterialSize, expandedKeyMaterialSize, ! effectiveKeyBytes, ivSize, blockSize)); ! ! default: ! throw new NotSupportedException(); ! } ! } ! ! private TlsCipherSuite add(TlsCipherSuite cipherSuite) ! { ! base.Add(cipherSuite); ! ! return cipherSuite; ! } ! ! private TlsSslCipherSuite add(TlsSslCipherSuite cipherSuite) ! { ! base.Add(cipherSuite); ! ! return cipherSuite; ! } ! ! private bool cultureAwareCompare(string strA, string strB) ! { ! try ! { ! return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false; ! } ! catch (NotSupportedException) ! { ! return strA.ToUpper() == strB.ToUpper() ? true : false; ! } ! } ! ! #endregion ! } ! } --- 1,167 ---- ! /* 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.Collections; ! using System.Globalization; ! using System.Security.Cryptography; ! ! namespace Mono.Security.Protocol.Tls ! { ! internal sealed class TlsCipherSuiteCollection : ArrayList ! { ! #region Fields ! ! private SecurityProtocolType protocol; ! ! #endregion ! ! #region Properties ! ! public CipherSuite this[string name] ! { ! get { return (CipherSuite)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (CipherSuite)value; } ! } ! ! public CipherSuite this[short code] ! { ! get { return (CipherSuite)base[IndexOf(code)]; } ! set { base[IndexOf(code)] = (CipherSuite)value; } ! } ! ! public new CipherSuite this[int code] ! { ! get { return (CipherSuite)base[code]; } ! set { base[code] = (CipherSuite)value; } ! } ! ! #endregion ! ! #region Constructors ! ! public TlsCipherSuiteCollection(SecurityProtocolType protocol) : base() ! { ! this.protocol = protocol; ! } ! ! #endregion ! ! #region Methods ! ! public bool Contains(string name) ! { ! return(-1 != IndexOf(name)); ! } ! ! public int IndexOf(string name) ! { ! int index = 0; ! foreach (CipherSuite suite in this) ! { ! if (cultureAwareCompare(suite.Name, name)) ! { ! return index; ! } ! index++; ! } ! return -1; ! } ! ! public int IndexOf(short code) ! { ! int index = 0; ! foreach (CipherSuite suite in this) ! { ! if (suite.Code == code) ! { ! return index; ! } ! index++; ! } ! return -1; ! } ! ! public void RemoveAt(string errorMessage) ! { ! RemoveAt(IndexOf(errorMessage)); ! } ! ! public CipherSuite Add( ! short code, string name, CipherAlgorithmType cipherType, ! HashAlgorithmType hashType, ExchangeAlgorithmType exchangeType, ! bool exportable, bool blockMode, byte keyMaterialSize, ! byte expandedKeyMaterialSize, short effectiveKeyBytes, ! byte ivSize, byte blockSize) ! { ! switch (this.protocol) ! { ! case SecurityProtocolType.Ssl3: ! return this.add( ! new TlsSslCipherSuite( ! code, name, cipherType, hashType, exchangeType, exportable, ! blockMode, keyMaterialSize, expandedKeyMaterialSize, ! effectiveKeyBytes, ivSize, blockSize)); ! ! case SecurityProtocolType.Tls: ! return this.add( ! new TlsCipherSuite( ! code, name, cipherType, hashType, exchangeType, exportable, ! blockMode, keyMaterialSize, expandedKeyMaterialSize, ! effectiveKeyBytes, ivSize, blockSize)); ! ! default: ! throw new NotSupportedException(); ! } ! } ! ! private TlsCipherSuite add(TlsCipherSuite cipherSuite) ! { ! base.Add(cipherSuite); ! ! return cipherSuite; ! } ! ! private TlsSslCipherSuite add(TlsSslCipherSuite cipherSuite) ! { ! base.Add(cipherSuite); ! ! return cipherSuite; ! } ! ! private bool cultureAwareCompare(string strA, string strB) ! { ! try ! { ! return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0 ? true : false; ! } ! catch (NotSupportedException) ! { ! return strA.ToUpper() == strB.ToUpper() ? true : false; ! } ! } ! ! #endregion ! } ! } Index: TlsCipherSuiteFactory.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteFactory.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TlsCipherSuiteFactory.cs 22 Nov 2003 14:43:51 -0000 1.12 --- TlsCipherSuiteFactory.cs 14 Dec 2003 14:59:39 -0000 1.13 *************** *** 1,168 **** ! /* 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 ! { ! internal class TlsCipherSuiteFactory ! { ! public static TlsCipherSuiteCollection GetSupportedCiphers(SecurityProtocolType protocol) ! { ! switch (protocol) ! { ! case SecurityProtocolType.Ssl3: ! return TlsCipherSuiteFactory.GetSsl3SupportedCiphers(); ! ! case SecurityProtocolType.Tls: ! return TlsCipherSuiteFactory.GetTls1SupportedCiphers(); ! ! default: ! throw new NotSupportedException(); ! } ! } ! ! #region PRIVATE_STATIC_METHODS ! ! private static TlsCipherSuiteCollection GetTls1SupportedCiphers() ! { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(SecurityProtocolType.Tls); ! ! // Supported ciphers ! scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16); ! scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 16, 16); ! scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); ! scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! ! // Default CipherSuite ! // scs.Add(0, "TLS_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! ! // RSA Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSignKeyX, true, false, 5, 16, 40, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! ! // Diffie-Hellman Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0C, "TLS_DH_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0D, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0E, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0F, "TLS_DH_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x10, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x11, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x12, "TLS_DHE_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x13, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x14, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x15, "TLS_DHE_RSA_WITH_DES_CBC_SHA", HashAlgorithmType.Sha1, CipherAlgorithmType.Des, false, ExchangeAlgorithmType.DiffieHellman, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x16, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! ! // Anonymous Diffie-Hellman Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x17, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.DiffieHellman, true, false, 5, 16, 40, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x18, "TLS_DH_anon_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, false, ExchangeAlgorithmType.DiffieHellman, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x19, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x1A, "TLS_DH_anon_WITH_DES_CBC_SHA", "DES4", HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x1B, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! ! // AES CipherSuites ! // ! // Ref: RFC3268 - (http://www.ietf.org/rfc/rfc3268.txt) ! ! // scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 16, 16); ! // scs.Add((0x00 << 0x08) | 0x30, "TLS_DH_DSS_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x31, "TLS_DH_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x32, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x33, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x34, "TLS_DH_anon_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 16, 16, 128, 8, 8); ! ! // scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16); ! // scs.Add((0x00 << 0x08) | 0x36, "TLS_DH_DSS_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16); ! // scs.Add((0x00 << 0x08) | 0x37, "TLS_DH_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16); ! // scs.Add((0x00 << 0x08) | 0x38, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16); ! // scs.Add((0x00 << 0x08) | 0x39, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16); ! // scs.Add((0x00 << 0x08) | 0x3A, "TLS_DH_anon_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 32, 32, 256, 16, 16); ! ! return scs; ! } ! ! private static TlsCipherSuiteCollection GetSsl3SupportedCiphers() ! { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(SecurityProtocolType.Ssl3); ! ! // Supported ciphers ! scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); ! scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! ! // Default CipherSuite ! // scs.Add(0, "SSL_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! ! // RSA Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x01, "SSL_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x02, "SSL_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, true, ExchangeAlgorithmType.None, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x03, "SSL_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, false, 5, 16, 40, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x05, "SSL_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x04, "SSL_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x06, "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x07, "SSL_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x08, "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyEx, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x09, "SSL_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0A, "SSL_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! ! // Diffie-Hellman Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x0B, "SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0C, "SSL_DH_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0D, "SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0E, "SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0F, "SSL_DH_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x10, "SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x11, "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x12, "SSL_DHE_DSS_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x13, "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x14, "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x15, "SSL_DHE_RSA_WITH_DES_CBC_SHA", HashAlgorithmType.Sha1, CipherAlgorithmType.Des, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x16, "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! ! // Anonymous Diffie-Hellman Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x17, "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.DiffieHellman, true, false, 5, 16, 40, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x18, "SSL_DH_anon_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, false, ExchangeAlgorithmType.DiffieHellman, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x19, "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x1A, "SSL_DH_anon_WITH_DES_CBC_SHA", "DES4", HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x1B, "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.DiffieHellman, false, true, 24, 24, 168, 8, 8); ! ! return scs; ! } ! ! #endregion ! } } --- 1,171 ---- ! /* 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 ! { ! internal class TlsCipherSuiteFactory ! { ! public static TlsCipherSuiteCollection GetSupportedCiphers(SecurityProtocolType protocol) ! { ! switch (protocol) ! { ! case SecurityProtocolType.Ssl3: ! return TlsCipherSuiteFactory.GetSsl3SupportedCiphers(); ! ! case SecurityProtocolType.Tls: ! return TlsCipherSuiteFactory.GetTls1SupportedCiphers(); ! ! default: ! throw new NotSupportedException(); ! } ! } ! ! #region PRIVATE_STATIC_METHODS ! ! private static TlsCipherSuiteCollection GetTls1SupportedCiphers() ! { ! TlsCipherSuiteCollection scs = new TlsCipherSuiteCollection(SecurityProtocolType.Tls); ! ! // Supported ciphers ! scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8); ! /* ! scs.Add((0x00 << 0x08) | 0x35, "TLS_RSA_WITH_AES_256_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 32, 32, 256, 16, 16); ! scs.Add((0x00 << 0x08) | 0x2F, "TLS_RSA_WITH_AES_128_CBC_SHA", CipherAlgorithmType.Rijndael, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 16, 16); ! scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); ! scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! */ ! ! // Default CipherSuite ! // scs.Add(0, "TLS_NULL_WITH_NULL_NULL", CipherAlgorithmType.None, HashAlgorithmType.None, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! ! // RSA Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x01, "TLS_RSA_WITH_NULL_MD5", CipherAlgorithmType.None, HashAlgorithmType.Md5, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x02, "TLS_RSA_WITH_NULL_SHA", CipherAlgorithmType.None, HashAlgorithmType.Sha1, ExchangeAlgorithmType.None, true, false, 0, 0, 0, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x03, "TLS_RSA_EXPORT_WITH_RC4_40_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSignKeyX, true, false, 5, 16, 40, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x05, "TLS_RSA_WITH_RC4_128_SHA", CipherAlgorithmType.Rc4, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x04, "TLS_RSA_WITH_RC4_128_MD5", CipherAlgorithmType.Rc4, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaSign, false, false, 16, 16, 128, 0, 0); ! // scs.Add((0x00 << 0x08) | 0x06, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5", CipherAlgorithmType.Rc2, HashAlgorithmType.Md5, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 16, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x07, "TLS_RSA_WITH_IDEA_CBC_SHA", "IDEA", HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 16, 16, 128, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x08, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaKeyX, true, true, 5, 8, 40, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x09, "TLS_RSA_WITH_DES_CBC_SHA", CipherAlgorithmType.Des, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 8, 8, 56, 8, 8); ! // scs.Add((0x00 << 0x08) | 0x0A, "TLS_RSA_WITH_3DES_EDE_CBC_SHA", CipherAlgorithmType.TripleDes, HashAlgorithmType.Sha1, ExchangeAlgorithmType.RsaSign, false, true, 24, 24, 168, 8, 8); ! ! // Diffie-Hellman Cipher Suites ! // scs.Add((0x00 << 0x08) | 0x0B, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_S... [truncated message content] |
From: <car...@us...> - 2003-12-09 21:01:00
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv18363 Added Files: TlsStream.cs Log Message: Rollback latest change |
From: <car...@us...> - 2003-12-09 19:56:38
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv5961 Removed Files: TlsStream.cs Log Message: Removed file (this was pending of deletetion) --- TlsStream.cs DELETED --- |
From: <car...@us...> - 2003-12-09 19:25:10
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv32260 Modified Files: changelog.txt Log Message: 2003-12-09 Carlos Guzmán Álvarez <car...@te...> * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: - Fixed message (but not working yet - we need RSA signing capabilitites with MD5SHA1 hash). * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: - Retrict certificate validation to the first validation. ( real validation needs to be made using a chain ) - Improved domain validation by making a IP checking between the target host IP and the certificate domain IP. - Fixed error list handling on certificate validation. Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/changelog.txt,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** changelog.txt 23 Nov 2003 12:52:24 -0000 1.15 --- changelog.txt 9 Dec 2003 19:25:04 -0000 1.16 *************** *** 2,5 **** --- 2,28 ---- --------------- ----------- ----------------------------------------- + 2003-12-09 Carlos Guzmán Álvarez <car...@te...> + + * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: + + - Fixed message (but not working yet - we need RSA signing + capabilitites with MD5SHA1 hash). + + * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: + + - Retrict certificate validation to the first validation. + ( real validation needs to be made using a chain ) + + - Improved domain validation by making a IP checking between + the target host IP and the certificate domain IP. + + - Fixed error list handling on certificate validation. + + 2003-11-28 Carlos Guzmán Álvarez <car...@te...> + + * Mono.Security.Protocol.Tls/SslClientStream.cs: + + - Added new exceptions. + 2003-11-23 Carlos Guzmán Álvarez <car...@te...> |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client In directory sc8-pr-cvs1:/tmp/cvs-serv32160 Modified Files: TlsClientCertificateVerify.cs Log Message: 2003-12-09 Carlos Guzmán Álvarez <car...@te...> * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: - Fixed message (but not working yet - we need RSA signing capabilitites with MD5SHA1 hash). * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: - Retrict certificate validation to the first validation. ( real validation needs to be made using a chain ) - Improved domain validation by making a IP checking between the target host IP and the certificate domain IP. - Fixed error list handling on certificate validation. Index: TlsClientCertificateVerify.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TlsClientCertificateVerify.cs 7 Dec 2003 15:00:57 -0000 1.14 --- TlsClientCertificateVerify.cs 9 Dec 2003 19:24:44 -0000 1.15 *************** *** 62,66 **** { // Compute handshake messages hash ! HashAlgorithm hash = new MD5SHA1(); hash.ComputeHash( this.Context.HandshakeMessages.ToArray(), --- 62,66 ---- { // Compute handshake messages hash ! MD5SHA1 hash = new MD5SHA1(); hash.ComputeHash( this.Context.HandshakeMessages.ToArray(), *************** *** 69,73 **** // Write message ! Write(hash.Hash); } --- 69,73 ---- // Write message ! Write(hash.CreateSignature(this.Context.Cipher.CreateRSA())); } |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client In directory sc8-pr-cvs1:/tmp/cvs-serv31455 Modified Files: TlsServerCertificate.cs Log Message: 2003-12-09 Carlos Guzmán Álvarez <car...@te...> * Mono.Security.Protocol.Handshake.Client/TlsServerCertificate.cs: - Retrict certificate validation to the first validation. ( real validation needs to be made using a chain ) - Improved domain validation by making a IP checking between the target host IP and the certificate domain IP. - Fixed error list handling on certificate validation. Index: TlsServerCertificate.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TlsServerCertificate.cs 25 Nov 2003 12:36:06 -0000 1.13 --- TlsServerCertificate.cs 9 Dec 2003 19:21:33 -0000 1.14 *************** *** 24,27 **** --- 24,28 ---- using System; + using System.Net; using System.Collections; using System.Text.RegularExpressions; *************** *** 90,97 **** readed += certLength; - - this.validateCertificate(certificate); } } } --- 91,101 ---- readed += certLength; } } + + #warning Correct validation needs to be made using a certificate chain + + // Restrict validation to the first certificate + this.validateCertificate(certificates[0]); } *************** *** 102,111 **** private void validateCertificate(X509Certificate certificate) { ! int[] certificateErrors = new int[0]; // 1 step : Validate dates if (!certificate.IsCurrent) { ! #warning "Add error to the list" } --- 106,115 ---- private void validateCertificate(X509Certificate certificate) { ! ArrayList errors = new ArrayList(); // 1 step : Validate dates if (!certificate.IsCurrent) { ! errors.Add(0x800B0101); } *************** *** 124,132 **** if (!this.checkDomainName(certificate.SubjectName)) { ! #warning "Add error to the list" } ! if (certificateErrors.Length > 0) { if (!this.Context.SslStream.RaiseServerCertificateValidation( new X509Cert.X509Certificate(certificate.RawData), --- 128,143 ---- if (!this.checkDomainName(certificate.SubjectName)) { ! errors.Add(0x800B010F); } ! if (errors.Count > 0) { + int[] certificateErrors = new int[errors.Count]; + + for (int i = 0; i < certificateErrors.Length; i++) + { + certificateErrors[i] = Convert.ToInt32(errors[i]); + } + if (!this.Context.SslStream.RaiseServerCertificateValidation( new X509Cert.X509Certificate(certificate.RawData), *************** *** 155,159 **** } ! return (this.Context.ClientSettings.TargetHost == domainName); } --- 166,183 ---- } ! if (domainName == String.Empty) ! { ! return false; ! } ! else ! { ! string targetHost = this.Context.ClientSettings.TargetHost; ! ! // Check that the IP is correct ! IPAddress ipHost = Dns.Resolve(targetHost).AddressList[0]; ! IPAddress ipDomain = Dns.Resolve(domainName).AddressList[0]; ! ! return (ipHost.Address == ipDomain.Address); ! } } |
From: <car...@us...> - 2003-12-09 19:19:10
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv31064 Modified Files: SslClientStream.cs Log Message: Minor changes in code regions Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SslClientStream.cs 7 Dec 2003 14:58:09 -0000 1.8 --- SslClientStream.cs 9 Dec 2003 19:19:04 -0000 1.9 *************** *** 605,609 **** #endregion ! #region TLS_RECORD_METHODS private byte[] receiveRecord() --- 605,609 ---- #endregion ! #region TLS_RECEIVE_METHODS private byte[] receiveRecord() |
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client In directory sc8-pr-cvs1:/tmp/cvs-serv16987 Modified Files: TlsClientCertificateVerify.cs Log Message: Fixed message Index: TlsClientCertificateVerify.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls.Handshake/Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TlsClientCertificateVerify.cs 25 Nov 2003 12:36:06 -0000 1.13 --- TlsClientCertificateVerify.cs 7 Dec 2003 15:00:57 -0000 1.14 *************** *** 61,85 **** protected override void ProcessAsTls1() { ! foreach (X509Certificate cert in this.Context.ClientSettings.Certificates) ! { ! MD5SHA1 hash = new MD5SHA1(); ! X509.X509Certificate c = new X509.X509Certificate(cert.GetRawCertData()); ! RSA rsa = c.RSA; ! RSAParameters p = rsa.ExportParameters(false); ! TlsStream data = new TlsStream(); ! ! data.Write(this.Context.RandomCS); ! data.Write((short)p.Modulus.Length); ! data.Write(p.Modulus); ! data.Write((short)p.Exponent.Length); ! data.Write(p.Exponent); ! ! hash.ComputeHash(data.ToArray(), 0, (int)data.Length); ! ! data.Reset(); ! // Write the signature ! Write(hash.CreateSignature(rsa)); ! } } --- 61,73 ---- protected override void ProcessAsTls1() { ! // Compute handshake messages hash ! HashAlgorithm hash = new MD5SHA1(); ! hash.ComputeHash( ! this.Context.HandshakeMessages.ToArray(), ! 0, ! (int)this.Context.HandshakeMessages.Length); ! // Write message ! Write(hash.Hash); } |
From: <car...@us...> - 2003-12-07 14:59:32
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography In directory sc8-pr-cvs1:/tmp/cvs-serv16618 Modified Files: MD5SHA1.cs Log Message: Minor change Index: MD5SHA1.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/Mono.Security/Mono.Security.Cryptography/MD5SHA1.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MD5SHA1.cs 13 Nov 2003 09:23:00 -0000 1.1 --- MD5SHA1.cs 7 Dec 2003 14:59:24 -0000 1.2 *************** *** 40,44 **** #region CONSTRUCTORS ! public MD5SHA1() { this.md5 = MD5.Create(); --- 40,44 ---- #region CONSTRUCTORS ! public MD5SHA1() : base() { this.md5 = MD5.Create(); *************** *** 98,102 **** } - #warning "MD5SHA1 hash is not supported by .NET" RSAPKCS1SignatureFormatter f = new RSAPKCS1SignatureFormatter(rsa); f.SetHashAlgorithm("MD5SHA1"); --- 98,101 ---- *************** *** 116,120 **** } - #warning "MD5SHA1 hash is not supported by .NET" RSAPKCS1SignatureDeformatter d = new RSAPKCS1SignatureDeformatter(rsa); d.SetHashAlgorithm("MD5SHA1"); --- 115,118 ---- |
From: <car...@us...> - 2003-12-07 14:58:13
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1:/tmp/cvs-serv16419 Modified Files: SslClientStream.cs Log Message: Minor change Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SslClientStream.cs 28 Nov 2003 17:24:07 -0000 1.7 --- SslClientStream.cs 7 Dec 2003 14:58:09 -0000 1.8 *************** *** 199,204 **** #region CONSTRUCTORS ! public SslClientStream(Stream stream, string targetHost, bool ownsStream) : ! this(stream, targetHost, ownsStream, SecurityProtocolType.Default, null) { --- 199,207 ---- #region CONSTRUCTORS ! public SslClientStream( ! Stream stream, ! string targetHost, ! bool ownsStream) ! : this(stream, targetHost, ownsStream, SecurityProtocolType.Default, null) { |
From: <car...@us...> - 2003-12-06 12:01:48
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv23912 Modified Files: PgStatement.cs Log Message: Fixed typo Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PgStatement.cs 5 Dec 2003 18:15:56 -0000 1.17 --- PgStatement.cs 6 Dec 2003 12:01:45 -0000 1.18 *************** *** 242,245 **** --- 242,248 ---- db.SendData(packet.GetPacketBytes(PgFrontEndCodes.DESCRIBE)); + // Flush pending messages + db.Flush(); + // Receive Describe response PgResponsePacket response = new PgResponsePacket(); |
From: <car...@us...> - 2003-12-06 12:01:19
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1:/tmp/cvs-serv23858 Modified Files: PgCommand.cs Log Message: Fixed typo Index: PgCommand.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommand.cs,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PgCommand.cs 5 Dec 2003 18:15:31 -0000 1.21 --- PgCommand.cs 6 Dec 2003 12:01:14 -0000 1.22 *************** *** 451,455 **** // Describe statement ! this.statement.Parse(); } else --- 451,455 ---- // Describe statement ! this.statement.Describe(); } else |
From: <car...@us...> - 2003-12-05 18:15:59
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv31311 Modified Files: PgStatement.cs Log Message: Minor change for try to improve statement execution. Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PgStatement.cs 5 Dec 2003 10:35:45 -0000 1.16 --- PgStatement.cs 5 Dec 2003 18:15:56 -0000 1.17 *************** *** 180,212 **** #region METHODS - public void Prepare() - { - lock (db) - { - this.Parse(); - this.Describe(); - - // Flush pending messages - db.Flush(); - - // Receive Parse response - PgResponsePacket response = new PgResponsePacket(); - while (response.Message != PgBackendCodes.PARSE_COMPLETE) - { - response = db.ReceiveResponsePacket(); - processSqlPacket(response); - } - - // Receive Describe response - response = new PgResponsePacket(); - while ((response.Message != PgBackendCodes.ROW_DESCRIPTION && - response.Message != PgBackendCodes.NODATA)) - { - response = db.ReceiveResponsePacket(); - processSqlPacket(response); - } - } - } - public void Parse() { --- 180,183 ---- *************** *** 270,273 **** --- 241,253 ---- // Send packet to the server db.SendData(packet.GetPacketBytes(PgFrontEndCodes.DESCRIBE)); + + // Receive Describe response + PgResponsePacket response = new PgResponsePacket(); + while ((response.Message != PgBackendCodes.ROW_DESCRIPTION && + response.Message != PgBackendCodes.NODATA)) + { + response = db.ReceiveResponsePacket(); + processSqlPacket(response); + } // Update status |
From: <car...@us...> - 2003-12-05 18:15:34
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1:/tmp/cvs-serv31266 Modified Files: PgCommand.cs Log Message: Minor change for try to improve statement execution. Index: PgCommand.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommand.cs,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PgCommand.cs 2 Dec 2003 11:38:27 -0000 1.20 --- PgCommand.cs 5 Dec 2003 18:15:31 -0000 1.21 *************** *** 447,452 **** parseParameterNames()); ! // Prepare the statment ! this.statement.Prepare(); } else --- 447,455 ---- parseParameterNames()); ! // Parse statement ! this.statement.Parse(); ! ! // Describe statement ! this.statement.Parse(); } else |
From: <car...@us...> - 2003-12-05 10:36:16
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10 In directory sc8-pr-cvs1:/tmp/cvs-serv19836 Modified Files: changelog.txt Log Message: Updated changelog.txt Index: changelog.txt =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/changelog.txt,v retrieving revision 1.84 retrieving revision 1.85 diff -C2 -d -r1.84 -r1.85 *** changelog.txt 26 Nov 2003 14:59:29 -0000 1.84 --- changelog.txt 5 Dec 2003 10:36:12 -0000 1.85 *************** *** 2,5 **** --- 2,14 ---- ------------------------------------------------------- + + 2003-12-02 Carlos Guzmán Álvarez <car...@te...> + + * source/PgCommand.cs: + * source/NPgClient/PgStatement.cs: + + - Minor uimprovement to prepare process. + + 2003-11-26 Carlos Guzmán Álvarez <car...@te...> |
From: <car...@us...> - 2003-12-05 10:35:48
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv19560 Modified Files: PgStatement.cs Log Message: Minor change for try to improve statement execution. Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PgStatement.cs 2 Dec 2003 11:38:44 -0000 1.15 --- PgStatement.cs 5 Dec 2003 10:35:45 -0000 1.16 *************** *** 320,334 **** // Send packet to the server db.SendData(packet.GetPacketBytes(PgFrontEndCodes.BIND)); - - // Flush pending messages - db.Flush(); - - // Read until BIND COMPLETE message is received - PgResponsePacket response = new PgResponsePacket(); - while (response.Message != PgBackendCodes.BIND_COMPLETE) - { - response = db.ReceiveResponsePacket(); - processSqlPacket(response); - } // Update status --- 320,323 ---- |
From: <car...@us...> - 2003-12-02 11:38:48
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1:/tmp/cvs-serv27985 Modified Files: PgStatement.cs Log Message: 2003-12-02 Carlos Guzmán Álvarez <car...@te...> * source/PgCommand.cs: * source/NPgClient/PgStatement.cs: - Minor uimprovement to prepare process. Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PgStatement.cs 26 Nov 2003 14:59:12 -0000 1.14 --- PgStatement.cs 2 Dec 2003 11:38:44 -0000 1.15 *************** *** 180,183 **** --- 180,212 ---- #region METHODS + public void Prepare() + { + lock (db) + { + this.Parse(); + this.Describe(); + + // Flush pending messages + db.Flush(); + + // Receive Parse response + PgResponsePacket response = new PgResponsePacket(); + while (response.Message != PgBackendCodes.PARSE_COMPLETE) + { + response = db.ReceiveResponsePacket(); + processSqlPacket(response); + } + + // Receive Describe response + response = new PgResponsePacket(); + while ((response.Message != PgBackendCodes.ROW_DESCRIPTION && + response.Message != PgBackendCodes.NODATA)) + { + response = db.ReceiveResponsePacket(); + processSqlPacket(response); + } + } + } + public void Parse() { *************** *** 186,189 **** --- 215,226 ---- try { + // Clear actual row list + rows = null; + rowIndex = 0; + + // Initialize RowDescriptor and Parameters + rowDescriptor = new PgRowDescriptor(0); + parameters = new PgParameter[0]; + PgOutputPacket packet = new PgOutputPacket(db.Settings.Encoding); *************** *** 194,219 **** // Send packet to the server db.SendData(packet.GetPacketBytes(PgFrontEndCodes.PARSE)); - - // Flush pending messages - db.Flush(); - - // Read until PARSE COMPLETE message is received - PgResponsePacket response = new PgResponsePacket(); - while (response.Message != PgBackendCodes.PARSE_COMPLETE) - { - response = db.ReceiveResponsePacket(); - processSqlPacket(response); - } - - // Clear actual row list - rows = null; - rowIndex = 0; // Update status this.status = PgStatementStatus.Parsed; - - // Initialize RowDescriptor and Parameters - rowDescriptor = new PgRowDescriptor(0); - parameters = new PgParameter[0]; } catch (PgClientException ex) --- 231,237 ---- *************** *** 252,275 **** // Send packet to the server db.SendData(packet.GetPacketBytes(PgFrontEndCodes.DESCRIBE)); - - // Flush pending messages - db.Flush(); - - // Receive response - PgResponsePacket response = new PgResponsePacket(); - while (response.Message != PgBackendCodes.ROW_DESCRIPTION && - response.Message != PgBackendCodes.NODATA) - { - response = db.ReceiveResponsePacket(); - processSqlPacket(response); - } - - /* - // Set a default row descriptor for NODATA query result - if (response.Message == PgBackendCodes.NODATA) - { - rowDescriptor = new PgRowDescriptor(0); - } - */ // Update status --- 270,273 ---- *************** *** 660,668 **** case PgBackendCodes.BIND_COMPLETE: - break; - case PgBackendCodes.PARSE_COMPLETE: - break; - case PgBackendCodes.CLOSE_COMPLETE: break; --- 658,662 ---- |