Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,205 @@
2006-09-11 Sebastien Pouliot <sebastien@ximian.com>
* HandshakeMessage.cs: EncodeMessage is called very often so we avoid
many allocations by not creating a TlsStream and by not calling
WriteInt24 (IPAddress.HostToNetworkOrder and BitConverter.GetBytes).
We also cache the encoded result to avoid computing/allocating the
encoded message twice (in most cases) for the handshake. Added a
Compare static method to compare byte arrays (easier to step out when
debugging).
2004-07-14 Carlos Guzman Alvarez <carlosga@telefonica.net>
* Updated license head in c# source files for use
always the same format.
2003-11-17 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls/SslClientStream.cs:
Removed ReadByte method, use innerStream.ReadByte() method instead.
2003-11-13 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Added implementation of an SslClientStream class similar to the MS .NET Framework 1.2 documentation.
The next files are no more needed:
- TlsSession.cs
- TlsNetworkStream.cs
- TlsSocket.cs
- TlsSessionState.cs
The next files are renamed:
- TlsSessionSettings.cs -> TlsClientSettings.cs
- TlsSessionContext.cs -> TlsContext.cs
The next files are new:
- SslClientStream.cs ( the name is non definitive yet )
The next files where changed to reflect the new canges:
- TlsHandshakeMessage.cs
- TlsClientCertificate.cs
- TlsClientCertificateVerify.cs
- TlsClientFinished.cs
- TlsClientHello.cs
- TlsClientKeyExchange.cs
- TlsServerCertificate.cs
- TlsServerCertificateRequest.cs
- TlsServerFinished.cs
- TlsServerHello.cs
- TlsServerHelloDone.cs
- TlsServerKeyExchange.cs
- TlsAlert.cs
- TlsCloseNotifyAlert.cs
2003-11-12 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
- Changes for give full error message only in debug mode ( Thanks to Sebastién Pouliot. )
* Mono.Security.Protocol.Tls/TlsProtocol.cs:
- Renamed to SecurityProtocolType.cs ( for match .NET 1.2 )
* Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
- Renamed to MD5SHA1.cs ( Thanks to Sebastién Pouliot. )
* Mono.Security.Cryptography/TlsCompressionMethod.cs:
- Renamed to SecurityCompressionType.
* Mono.Security.Protocol.Tls/CipherAlgorithmType.cs:
* Mono.Security.Protocol.Tls/HashAlgorithmType.cs:
* Mono.Security.Protocol.Tls/ExchangeAlgorithmType.cs:
- New enumerations that matches .NET 1.2 definitions with some minor differences.
* Mono.Security.Protocol.Tls/CipherSuite.cs:
* Mono.Security.Protocol.Tls/TlsCipherSuite.cs:
* Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
* Mono.Security.Protocol.Tls/TlsSessionContext.cs:
- Added changes for make use of new enumerations.
* Mono.Security.Protocol.Tls/TlsClientStream.cs:
- Added new informative properties that matches .NET 1.2 SslClientStream
( Not all the properties are implemented yet ).
2003-11-10 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls.Alerts/TlsAlert.cs:
- Fixed invalid alert message.
* Mono.Security.Protocol.Tls/CipherSuite.cs:
* Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
* Mono.Security.Cryptography/HMAC.cs:
* Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
- Changed ( Thanks to Sebastién Pouliot for his feedback )
SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();
MD5CryptoServiceProvider sha = new MD5CryptoServiceProvider();
to
HashAlgorithm sha = SHA1.Create();
HashAlgorithm md5 = MD5.Create();
2003-11-04 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls/CipherSuite.cs:
- Added custom padding for record encryption.
2003-11-03 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls.Handshake/TlsHandshakeMessages.cs:
- Removed file.
* Mono.Security.Protocol.Tls/TlsSslHandshakeHash.cs:
- New class for handshake hashes calculation on SSL3 protocol.
* Mono.Security.Protocol.Tls/TlsSessionContext.cs:
- Fixed mac keys clearing for SSL3 protocol.
* Mono.Security.Protocol.Tls/TlsSslCipherSuite.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
- Added changes for make use of new TlsSslHandshakeHash class.
* Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
- Added initial implementation for SSL3 protocol.
* Mono.Security.Cryptography/MD5SHA1CryptoServiceProvider.cs:
- New class for md5-sha hash calculation.
* Mono.Security.Protocol.Tls.Handshake.Client/TlsClientFinished.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsServerFinished.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsHandshakeMessage.cs:
- Make use of new MD5SHA1CryptoServiceProvider class.
* Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
- Added initial implementation (not finished).
* Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
- Minor change to message processing.
- Changed verify method name to verifySignature.
* Mono.Security.Protocol.Tls/TlsSessionContext.cs:
- Changed handshakeHashes member to be an TlsStream.
2003-10-28 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Mono.Security.Protocol.Tls/CipherSuite.cs:
* Mono.Security.Protocol.Tls/TlsSessionSettings.cs:
* Mono.Security.Protocol.Tls/TlsServerSettings.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsClientCertificateVerify.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsClientKeyExchange.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsServerCertificate.cs:
* Mono.Security.Protocol.Tls.Handshake.Client/TlsServerKeyExchange.cs:
- Added changes for make use of X509 classes from mono.
2003-10-23 Carlos Guzmán Álvarez <carlosga@telefonica.net>
* Added partial implementation of SSL3 protocol ( not finished yet ).

View File

@@ -0,0 +1,38 @@
// 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;
namespace Mono.Security.Protocol.Tls.Handshake
{
[Serializable]
internal enum ClientCertificateType
{
RSA = 1,
DSS = 2,
RSAFixed = 3,
DSSFixed = 4,
Unknown = 255
}
}

View File

@@ -0,0 +1,170 @@
// Transport Security Layer (TLS)
// Copyright (c) 2003-2004 Carlos Guzman Alvarez
// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Mono.Security.Protocol.Tls.Handshake
{
internal abstract class HandshakeMessage : TlsStream
{
#region Fields
private Context context;
private HandshakeType handshakeType;
private ContentType contentType;
private byte[] cache;
#endregion
#region Properties
public Context Context
{
get { return this.context; }
}
public HandshakeType HandshakeType
{
get { return this.handshakeType; }
}
public ContentType ContentType
{
get { return this.contentType; }
}
#endregion
#region Constructors
public HandshakeMessage(
Context context,
HandshakeType handshakeType)
: this(context, handshakeType, ContentType.Handshake)
{
}
public HandshakeMessage(
Context context,
HandshakeType handshakeType,
ContentType contentType) : base()
{
this.context = context;
this.handshakeType = handshakeType;
this.contentType = contentType;
}
public HandshakeMessage(
Context context,
HandshakeType handshakeType,
byte[] data) : base(data)
{
this.context = context;
this.handshakeType = handshakeType;
}
#endregion
#region Abstract Methods
protected abstract void ProcessAsTls1();
protected abstract void ProcessAsSsl3();
#endregion
#region Methods
public void Process()
{
switch (this.Context.SecurityProtocol)
{
case SecurityProtocolType.Tls:
case SecurityProtocolType.Default:
this.ProcessAsTls1();
break;
case SecurityProtocolType.Ssl3:
this.ProcessAsSsl3();
break;
case SecurityProtocolType.Ssl2:
default:
throw new NotSupportedException("Unsupported security protocol type");
}
}
public virtual void Update()
{
if (this.CanWrite)
{
// result may (should) be available from a previous call to EncodeMessage
if (cache == null)
cache = this.EncodeMessage ();
this.context.HandshakeMessages.Write (cache);
this.Reset();
cache = null;
}
}
public virtual byte[] EncodeMessage()
{
cache = null;
if (CanWrite)
{
byte[] hs = this.ToArray ();
int len = hs.Length;
cache = new byte[4 + len];
cache[0] = (byte) HandshakeType;
// Length as an Int24 in Network Order
cache[1] = (byte) (len >> 16);
cache[2] = (byte) (len >> 8);
cache[3] = (byte) len;
Buffer.BlockCopy (hs, 0, cache, 4, len);
}
return cache;
}
static public bool Compare (byte[] buffer1, byte[] buffer2)
{
// in our case both null can't exist (or be valid)
if ((buffer1 == null) || (buffer2 == null))
return false;
if (buffer1.Length != buffer2.Length)
return false;
for (int i = 0; i < buffer1.Length; i++) {
if (buffer1[i] != buffer2[i])
return false;
}
return true;
}
#endregion
}
}

View File

@@ -0,0 +1,44 @@
// 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;
namespace Mono.Security.Protocol.Tls.Handshake
{
[Serializable]
internal enum HandshakeType : byte
{
HelloRequest = 0,
ClientHello = 1,
ServerHello = 2,
Certificate = 11,
ServerKeyExchange = 12,
CertificateRequest = 13,
ServerHelloDone = 14,
CertificateVerify = 15,
ClientKeyExchange = 16,
Finished = 20,
None = 255
}
}