[pgsqlclient-checkins] pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls Assembly
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12059 Modified Files: AssemblyInfo.cs CipherAlgorithmType.cs CipherSuite.cs ExchangeAlgorithmType.cs HashAlgorithmType.cs RSASslSignatureDeformatter.cs RSASslSignatureFormatter.cs SecurityCompressionType.cs SecurityProtocolType.cs SslClientStream.cs SslServerStream.cs TlsCipherSuite.cs TlsCipherSuiteCollection.cs TlsCipherSuiteFactory.cs TlsClientSettings.cs TlsContentType.cs TlsContext.cs TlsException.cs TlsServerSettings.cs TlsSslCipherSuite.cs TlsSslHandshakeHash.cs TlsStream.cs Log Message: Updated license headers Index: AssemblyInfo.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/AssemblyInfo.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AssemblyInfo.cs 11 Oct 2003 10:04:20 -0000 1.1 --- AssemblyInfo.cs 9 Feb 2004 14:16:56 -0000 1.2 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: CipherAlgorithmType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/CipherAlgorithmType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CipherAlgorithmType.cs 13 Nov 2003 09:21:51 -0000 1.1 --- CipherAlgorithmType.cs 9 Feb 2004 14:16:57 -0000 1.2 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: CipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/CipherSuite.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CipherSuite.cs 21 Dec 2003 14:39:54 -0000 1.12 --- CipherSuite.cs 9 Feb 2004 14:16:57 -0000 1.13 *************** *** 1,541 **** ! /* 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: [...1055 lines suppressed...] ! 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 ! } } \ No newline at end of file Index: ExchangeAlgorithmType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExchangeAlgorithmType.cs 13 Nov 2003 09:21:51 -0000 1.1 --- ExchangeAlgorithmType.cs 9 Feb 2004 14:17:02 -0000 1.2 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: HashAlgorithmType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/HashAlgorithmType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HashAlgorithmType.cs 13 Nov 2003 09:21:51 -0000 1.1 --- HashAlgorithmType.cs 9 Feb 2004 14:17:02 -0000 1.2 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: RSASslSignatureDeformatter.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RSASslSignatureDeformatter.cs 23 Dec 2003 18:24:23 -0000 1.3 --- RSASslSignatureDeformatter.cs 9 Feb 2004 14:17:02 -0000 1.4 *************** *** 1,104 **** ! /* 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 ! { ! internal class RSASslSignatureDeformatter : AsymmetricSignatureDeformatter ! { ! #region Fields ! ! private RSA key; ! private HashAlgorithm hash; ! ! #endregion ! ! #region Constructors ! ! public RSASslSignatureDeformatter() ! { ! } ! ! public RSASslSignatureDeformatter(AsymmetricAlgorithm key) ! { ! this.SetKey(key); ! } ! ! #endregion ! ! #region Methods ! ! public override bool VerifySignature( ! byte[] rgbHash, ! byte[] rgbSignature) ! { ! if (key == null) ! { ! throw new CryptographicUnexpectedOperationException("The key is a null reference"); ! } ! if (hash == null) ! { ! throw new CryptographicUnexpectedOperationException("The hash algorithm is a null reference."); ! } ! if (rgbHash == null) ! { ! throw new ArgumentNullException("The rgbHash parameter is a null reference."); ! } ! ! return Mono.Security.Cryptography.PKCS1.Verify_v15( ! this.key, ! this.hash, ! rgbHash, ! rgbSignature); ! } ! ! public override void SetHashAlgorithm(string strName) ! { ! switch (strName) ! { ! case "MD5SHA1": ! this.hash = new Mono.Security.Cryptography.MD5SHA1(); ! break; ! ! default: ! this.hash = HashAlgorithm.Create(strName); ! break; ! } ! } ! ! public override void SetKey(AsymmetricAlgorithm key) ! { ! if (!(key is RSA)) ! { ! throw new ArgumentException("Specfied key is not an RSA key"); ! } ! ! this.key = key as RSA; ! } ! ! #endregion ! } ! } --- 1,104 ---- ! /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez ! * ! * 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 ! { ! internal class RSASslSignatureDeformatter : AsymmetricSignatureDeformatter ! { ! #region Fields ! ! private RSA key; ! private HashAlgorithm hash; ! ! #endregion ! ! #region Constructors ! ! public RSASslSignatureDeformatter() ! { ! } ! ! public RSASslSignatureDeformatter(AsymmetricAlgorithm key) ! { ! this.SetKey(key); ! } ! ! #endregion ! ! #region Methods ! ! public override bool VerifySignature( ! byte[] rgbHash, ! byte[] rgbSignature) ! { ! if (key == null) ! { ! throw new CryptographicUnexpectedOperationException("The key is a null reference"); ! } ! if (hash == null) ! { ! throw new CryptographicUnexpectedOperationException("The hash algorithm is a null reference."); ! } ! if (rgbHash == null) ! { ! throw new ArgumentNullException("The rgbHash parameter is a null reference."); ! } ! ! return Mono.Security.Cryptography.PKCS1.Verify_v15( ! this.key, ! this.hash, ! rgbHash, ! rgbSignature); ! } ! ! public override void SetHashAlgorithm(string strName) ! { ! switch (strName) ! { ! case "MD5SHA1": ! this.hash = new Mono.Security.Cryptography.MD5SHA1(); ! break; ! ! default: ! this.hash = HashAlgorithm.Create(strName); ! break; ! } ! } ! ! public override void SetKey(AsymmetricAlgorithm key) ! { ! if (!(key is RSA)) ! { ! throw new ArgumentException("Specfied key is not an RSA key"); ! } ! ! this.key = key as RSA; ! } ! ! #endregion ! } ! } Index: RSASslSignatureFormatter.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RSASslSignatureFormatter.cs 23 Dec 2003 18:24:23 -0000 1.3 --- RSASslSignatureFormatter.cs 9 Feb 2004 14:17:02 -0000 1.4 *************** *** 1,101 **** ! /* 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 ! { ! internal class RSASslSignatureFormatter : AsymmetricSignatureFormatter ! { ! #region Fields ! ! private RSA key; ! private HashAlgorithm hash; ! ! #endregion ! ! #region Constructors ! ! public RSASslSignatureFormatter() ! { ! } ! ! public RSASslSignatureFormatter(AsymmetricAlgorithm key) ! { ! this.SetKey(key); ! } ! ! #endregion ! ! #region Methods ! ! public override byte[] CreateSignature(byte[] rgbHash) ! { ! if (key == null) ! { ! throw new CryptographicUnexpectedOperationException("The key is a null reference"); ! } ! if (hash == null) ! { ! throw new CryptographicUnexpectedOperationException("The hash algorithm is a null reference."); ! } ! if (rgbHash == null) ! { ! throw new ArgumentNullException("The rgbHash parameter is a null reference."); ! } ! ! return Mono.Security.Cryptography.PKCS1.Sign_v15( ! this.key, ! this.hash, ! rgbHash); ! } ! ! public override void SetHashAlgorithm(string strName) ! { ! switch (strName) ! { ! case "MD5SHA1": ! this.hash = new Mono.Security.Cryptography.MD5SHA1(); ! break; ! ! default: ! this.hash = HashAlgorithm.Create(strName); ! break; ! } ! } ! ! public override void SetKey(AsymmetricAlgorithm key) ! { ! if (!(key is RSA)) ! { ! throw new ArgumentException("Specfied key is not an RSA key"); ! } ! ! this.key = key as RSA; ! } ! ! #endregion ! } ! } --- 1,101 ---- ! /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez ! * ! * 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 ! { ! internal class RSASslSignatureFormatter : AsymmetricSignatureFormatter ! { ! #region Fields ! ! private RSA key; ! private HashAlgorithm hash; ! ! #endregion ! ! #region Constructors ! ! public RSASslSignatureFormatter() ! { ! } ! ! public RSASslSignatureFormatter(AsymmetricAlgorithm key) ! { ! this.SetKey(key); ! } ! ! #endregion ! ! #region Methods ! ! public override byte[] CreateSignature(byte[] rgbHash) ! { ! if (key == null) ! { ! throw new CryptographicUnexpectedOperationException("The key is a null reference"); ! } ! if (hash == null) ! { ! throw new CryptographicUnexpectedOperationException("The hash algorithm is a null reference."); ! } ! if (rgbHash == null) ! { ! throw new ArgumentNullException("The rgbHash parameter is a null reference."); ! } ! ! return Mono.Security.Cryptography.PKCS1.Sign_v15( ! this.key, ! this.hash, ! rgbHash); ! } ! ! public override void SetHashAlgorithm(string strName) ! { ! switch (strName) ! { ! case "MD5SHA1": ! this.hash = new Mono.Security.Cryptography.MD5SHA1(); ! break; ! ! default: ! this.hash = HashAlgorithm.Create(strName); ! break; ! } ! } ! ! public override void SetKey(AsymmetricAlgorithm key) ! { ! if (!(key is RSA)) ! { ! throw new ArgumentException("Specfied key is not an RSA key"); ! } ! ! this.key = key as RSA; ! } ! ! #endregion ! } ! } Index: SecurityCompressionType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SecurityCompressionType.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SecurityCompressionType.cs 13 Nov 2003 09:21:51 -0000 1.1 --- SecurityCompressionType.cs 9 Feb 2004 14:17:02 -0000 1.2 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: SecurityProtocolType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SecurityProtocolType.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SecurityProtocolType.cs 14 Nov 2003 13:40:40 -0000 1.2 --- SecurityProtocolType.cs 9 Feb 2004 14:17:02 -0000 1.3 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: SslClientStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SslClientStream.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SslClientStream.cs 8 Feb 2004 22:25:24 -0000 1.13 --- SslClientStream.cs 9 Feb 2004 14:17:02 -0000 1.14 *************** *** 1,4 **** /* Transport Security Layer (TLS) ! * Copyright (c) 2003 Carlos Guzmán Álvarez * * Permission is hereby granted, free of charge, to any person --- 1,4 ---- /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez * * Permission is hereby granted, free of charge, to any person Index: SslServerStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/SslServerStream.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SslServerStream.cs 14 Dec 2003 14:59:39 -0000 1.2 --- SslServerStream.cs 9 Feb 2004 14:17:02 -0000 1.3 *************** *** 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 ! } ! } --- 1,281 ---- ! /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez ! * ! * 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.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TlsCipherSuite.cs 14 Dec 2003 14:59:39 -0000 1.10 --- TlsCipherSuite.cs 9 Feb 2004 14:17:02 -0000 1.11 *************** *** 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 ! } } \ No newline at end of file --- 1,158 ---- ! /* Transport Security Layer (TLS) ! * Copyright (c) 2003-2004 Carlos Guzman Alvarez ! * ! * 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 ! } } \ No newline at end of file Index: TlsCipherSuiteCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security.Protocol.Tls/Mono.Security.Protocol.Tls/TlsCipherSuiteCollection.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TlsCipherSuiteCollection.cs 14 Dec 2003 14:59:39 -0000 1.7 --- TlsCipherSuiteCollection.cs 9 Feb 2004 14:17:02 -0000 1.8 *************** *** 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-2004 Carlos Guzman Alvarez ! * ! * 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.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** TlsCipherSuiteFactory.cs 26 Dec 2003 11:14:26 -0000 1.16 --- TlsCipherSuiteFactory.cs 9 Feb 2004 14:17:02 -0000 1.17 *************** *** 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, tru... [truncated message content] |