[pgsqlclient-checkins] pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls Alert.c
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos Guzm?n ?l. <car...@us...> - 2004-04-10 21:57:35
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26556 Modified Files: Alert.cs CipherSuiteCollection.cs ClientContext.cs Context.cs RSASslSignatureDeformatter.cs RSASslSignatureFormatter.cs SslCipherSuite.cs SslHandshakeHash.cs TlsException.cs TlsStream.cs Log Message: 2004-04-10 Carlos Guzman Alvarez <car...@te...> * Started cleanup and unification of this keyword usage tasks. Index: TlsException.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsException.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TlsException.cs 10 Apr 2004 11:16:24 -0000 1.3 --- TlsException.cs 10 Apr 2004 21:44:02 -0000 1.4 *************** *** 32,36 **** internal sealed class TlsException : Exception { ! #region Private fields private Alert alert; --- 32,36 ---- internal sealed class TlsException : Exception { ! #region Fields private Alert alert; Index: ClientContext.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/ClientContext.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ClientContext.cs 3 Mar 2004 16:22:36 -0000 1.3 --- ClientContext.cs 10 Apr 2004 21:44:02 -0000 1.4 *************** *** 74,79 **** public override void Clear() { ! this.clientHelloProtocol = 0; ! base.Clear(); } --- 74,78 ---- public override void Clear() { ! this.clientHelloProtocol = 0; base.Clear(); } Index: RSASslSignatureFormatter.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureFormatter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RSASslSignatureFormatter.cs 10 Feb 2004 09:43:42 -0000 1.1 --- RSASslSignatureFormatter.cs 10 Apr 2004 21:44:02 -0000 1.2 *************** *** 54,58 **** public override byte[] CreateSignature(byte[] rgbHash) { ! if (key == null) { throw new CryptographicUnexpectedOperationException("The key is a null reference"); --- 54,58 ---- public override byte[] CreateSignature(byte[] rgbHash) { ! if (this.key == null) { throw new CryptographicUnexpectedOperationException("The key is a null reference"); Index: RSASslSignatureDeformatter.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/RSASslSignatureDeformatter.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RSASslSignatureDeformatter.cs 10 Feb 2004 09:43:42 -0000 1.1 --- RSASslSignatureDeformatter.cs 10 Apr 2004 21:44:02 -0000 1.2 *************** *** 56,60 **** byte[] rgbSignature) { ! if (key == null) { throw new CryptographicUnexpectedOperationException("The key is a null reference"); --- 56,60 ---- byte[] rgbSignature) { ! if (this.key == null) { throw new CryptographicUnexpectedOperationException("The key is a null reference"); Index: TlsStream.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/TlsStream.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TlsStream.cs 15 Mar 2004 13:18:30 -0000 1.2 --- TlsStream.cs 10 Apr 2004 21:44:02 -0000 1.3 *************** *** 62,87 **** public override bool CanWrite { ! get { return canWrite; } } public override bool CanRead { ! get { return canRead; } } public override bool CanSeek { ! get { return buffer.CanSeek; } } public override long Position { ! get { return buffer.Position; } ! set { buffer.Position = value; } } public override long Length { ! get { return buffer.Length; } } --- 62,87 ---- public override bool CanWrite { ! get { return this.canWrite; } } public override bool CanRead { ! get { return this.canRead; } } public override bool CanSeek { ! get { return this.buffer.CanSeek; } } public override long Position { ! get { return this.buffer.Position; } ! set { this.buffer.Position = value; } } public override long Length { ! get { return this.buffer.Length; } } *************** *** 155,159 **** public void Write(byte value) { ! WriteByte(value); } --- 155,159 ---- public void Write(byte value) { ! this.WriteByte(value); } *************** *** 161,165 **** { byte[] bytes = BitConverter.GetBytes((short)IPAddress.HostToNetworkOrder(value)); ! Write(bytes); } --- 161,165 ---- { byte[] bytes = BitConverter.GetBytes((short)IPAddress.HostToNetworkOrder(value)); ! this.Write(bytes); } *************** *** 171,175 **** Buffer.BlockCopy(BitConverter.GetBytes(int24), 1, content, 0, 3); ! Write(content); } --- 171,175 ---- Buffer.BlockCopy(BitConverter.GetBytes(int24), 1, content, 0, 3); ! this.Write(content); } *************** *** 177,181 **** { byte[] bytes = BitConverter.GetBytes((int)IPAddress.HostToNetworkOrder(value)); ! Write(bytes); } --- 177,181 ---- { byte[] bytes = BitConverter.GetBytes((int)IPAddress.HostToNetworkOrder(value)); ! this.Write(bytes); } *************** *** 183,192 **** { byte[] bytes = BitConverter.GetBytes((long)IPAddress.HostToNetworkOrder(value)); ! Write(bytes); } public void Write(byte[] buffer) { ! Write(buffer, 0, buffer.Length); } --- 183,192 ---- { byte[] bytes = BitConverter.GetBytes((long)IPAddress.HostToNetworkOrder(value)); ! this.Write(bytes); } public void Write(byte[] buffer) { ! this.Write(buffer, 0, buffer.Length); } *************** *** 197,207 **** public void Reset() { ! buffer.SetLength(0); ! buffer.Position = 0; } public byte[] ToArray() { ! return buffer.ToArray(); } --- 197,207 ---- public void Reset() { ! this.buffer.SetLength(0); ! this.buffer.Position = 0; } public byte[] ToArray() { ! return this.buffer.ToArray(); } *************** *** 212,231 **** public override void Flush() { ! buffer.Flush(); } public override void SetLength(long length) { ! buffer.SetLength(length); } public override long Seek(long offset, System.IO.SeekOrigin loc) { ! return buffer.Seek(offset, loc); } public override int Read(byte[] buffer, int offset, int count) { ! if (canRead) { return this.buffer.Read(buffer, offset, count); --- 212,231 ---- public override void Flush() { ! this.buffer.Flush(); } public override void SetLength(long length) { ! this.buffer.SetLength(length); } public override long Seek(long offset, System.IO.SeekOrigin loc) { ! return this.buffer.Seek(offset, loc); } public override int Read(byte[] buffer, int offset, int count) { ! if (this.canRead) { return this.buffer.Read(buffer, offset, count); *************** *** 236,240 **** public override void Write(byte[] buffer, int offset, int count) { ! if (canWrite) { this.buffer.Write(buffer, offset, count); --- 236,240 ---- public override void Write(byte[] buffer, int offset, int count) { ! if (this.canWrite) { this.buffer.Write(buffer, offset, count); Index: SslHandshakeHash.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslHandshakeHash.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SslHandshakeHash.cs 9 Apr 2004 08:42:21 -0000 1.3 --- SslHandshakeHash.cs 10 Apr 2004 21:44:02 -0000 1.4 *************** *** 66,103 **** public override void Initialize() { ! md5.Initialize(); ! sha.Initialize(); ! initializePad(); ! hashing = false; } protected override byte[] HashFinal() { ! if (!hashing) { ! hashing = true; } // Finalize the md5 hash ! md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! md5.TransformFinalBlock(this.innerPadMD5, 0, this.innerPadMD5.Length); ! byte[] firstResultMD5 = md5.Hash; ! md5.Initialize(); ! md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! md5.TransformBlock(this.outerPadMD5, 0, this.outerPadMD5.Length, this.outerPadMD5, 0); ! md5.TransformFinalBlock(firstResultMD5, 0, firstResultMD5.Length); // Finalize the sha1 hash ! sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! sha.TransformFinalBlock(this.innerPadSHA, 0, this.innerPadSHA.Length); ! byte[] firstResultSHA = sha.Hash; ! sha.Initialize(); ! sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! sha.TransformBlock(this.outerPadSHA, 0, this.outerPadSHA.Length, this.outerPadSHA, 0); ! sha.TransformFinalBlock(firstResultSHA, 0, firstResultSHA.Length); this.Initialize(); --- 66,103 ---- public override void Initialize() { ! this.md5.Initialize(); ! this.sha.Initialize(); ! this.initializePad(); ! this.hashing = false; } protected override byte[] HashFinal() { ! if (!this.hashing) { ! this.hashing = true; } // Finalize the md5 hash ! this.md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! this.md5.TransformFinalBlock(this.innerPadMD5, 0, this.innerPadMD5.Length); ! byte[] firstResultMD5 = this.md5.Hash; ! this.md5.Initialize(); ! this.md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! this.md5.TransformBlock(this.outerPadMD5, 0, this.outerPadMD5.Length, this.outerPadMD5, 0); ! this.md5.TransformFinalBlock(firstResultMD5, 0, firstResultMD5.Length); // Finalize the sha1 hash ! this.sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! this.sha.TransformFinalBlock(this.innerPadSHA, 0, this.innerPadSHA.Length); ! byte[] firstResultSHA = this.sha.Hash; ! this.sha.Initialize(); ! this.sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0); ! this.sha.TransformBlock(this.outerPadSHA, 0, this.outerPadSHA.Length, this.outerPadSHA, 0); ! this.sha.TransformFinalBlock(firstResultSHA, 0, firstResultSHA.Length); this.Initialize(); *************** *** 105,125 **** byte[] result = new byte[36]; ! Buffer.BlockCopy(md5.Hash, 0, result, 0, 16); ! Buffer.BlockCopy(sha.Hash, 0, result, 16, 20); return result; } ! protected override void HashCore( ! byte[] array, ! int ibStart, ! int cbSize) { ! if (!hashing) { ! hashing = true; } ! md5.TransformBlock(array, ibStart, cbSize, array, ibStart); ! sha.TransformBlock(array, ibStart, cbSize, array, ibStart); } --- 105,123 ---- byte[] result = new byte[36]; ! Buffer.BlockCopy(this.md5.Hash, 0, result, 0, 16); ! Buffer.BlockCopy(this.sha.Hash, 0, result, 16, 20); return result; } ! protected override void HashCore(byte[] array, int ibStart, int cbSize) { ! if (!this.hashing) { ! this.hashing = true; } ! ! this.md5.TransformBlock(array, ibStart, cbSize, array, ibStart); ! this.sha.TransformBlock(array, ibStart, cbSize, array, ibStart); } Index: SslCipherSuite.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/SslCipherSuite.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SslCipherSuite.cs 18 Mar 2004 14:06:31 -0000 1.3 --- SslCipherSuite.cs 10 Apr 2004 21:44:02 -0000 1.4 *************** *** 65,70 **** for (int i = 0; i < padLength; ++i) { ! pad1[i] = 0x36; ! pad2[i] = 0x5C; } } --- 65,70 ---- for (int i = 0; i < padLength; ++i) { ! this.pad1[i] = 0x36; ! this.pad2[i] = 0x5C; } } *************** *** 168,171 **** --- 168,172 ---- char labelChar = 'A'; int count = 1; + while (tmp.Length < this.KeyBlockSize) { *************** *** 188,193 **** // Create keyblock ! TlsStream keyBlock = new TlsStream(tmp.ToArray()); ! this.Context.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize); this.Context.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize); --- 189,194 ---- // Create keyblock ! TlsStream keyBlock = new TlsStream(tmp.ToArray()); ! this.Context.ClientWriteMAC = keyBlock.ReadBytes(this.HashSize); this.Context.ServerWriteMAC = keyBlock.ReadBytes(this.HashSize); Index: Alert.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/Alert.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Alert.cs 10 Apr 2004 11:16:24 -0000 1.2 --- Alert.cs 10 Apr 2004 21:44:02 -0000 1.3 *************** *** 95,110 **** public bool IsWarning { ! get ! { ! return this.level == AlertLevel.Warning ? true : false; ! } } public bool IsFatal { ! get ! { ! return this.level == AlertLevel.Fatal ? true : false; ! } } --- 95,104 ---- public bool IsWarning { ! get { return this.level == AlertLevel.Warning ? true : false; } } public bool IsFatal { ! get { return this.level == AlertLevel.Fatal ? true : false; } } Index: CipherSuiteCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/CipherSuiteCollection.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CipherSuiteCollection.cs 6 Mar 2004 14:53:13 -0000 1.2 --- CipherSuiteCollection.cs 10 Apr 2004 21:44:02 -0000 1.3 *************** *** 73,77 **** public bool Contains(string name) { ! return(-1 != IndexOf(name)); } --- 73,77 ---- public bool Contains(string name) { ! return (-1 != this.IndexOf(name)); } *************** *** 79,85 **** { int index = 0; foreach (CipherSuite suite in this) { ! if (cultureAwareCompare(suite.Name, name)) { return index; --- 79,86 ---- { int index = 0; + foreach (CipherSuite suite in this) { ! if (this.cultureAwareCompare(suite.Name, name)) { return index; *************** *** 87,90 **** --- 88,92 ---- index++; } + return -1; } *************** *** 93,96 **** --- 95,99 ---- { int index = 0; + foreach (CipherSuite suite in this) { *************** *** 101,104 **** --- 104,108 ---- index++; } + return -1; } *************** *** 106,110 **** public void RemoveAt(string errorMessage) { ! RemoveAt(IndexOf(errorMessage)); } --- 110,114 ---- public void RemoveAt(string errorMessage) { ! this.RemoveAt(this.IndexOf(errorMessage)); } Index: Context.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/Mono.Security/Mono.Security/Mono.Security.Protocol.Tls/Context.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Context.cs 10 Apr 2004 11:16:24 -0000 1.7 --- Context.cs 10 Apr 2004 21:44:02 -0000 1.8 *************** *** 420,449 **** #endregion - - /* - #region Exception Methods - - public TlsException CreateException( - AlertLevel alertLevel, - AlertDescription alertDesc) - { - return CreateException(Alert.GetAlertMessage(alertDesc)); - } - - public TlsException CreateException(string format, params object[] args) - { - StringBuilder message = new StringBuilder(); - message.AppendFormat(format, args); - - return CreateException(message.ToString()); - } - - public TlsException CreateException(string message) - { - return new TlsException(message); - } - - #endregion - */ } } --- 420,423 ---- |