scripts
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.X509;
|
||||
using Mono.Security.X509.Extensions;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B2 RID: 178
|
||||
internal class TlsClientCertificate : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000699 RID: 1689 RVA: 0x00024D90 File Offset: 0x00022F90
|
||||
public TlsClientCertificate(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.Certificate, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600069A RID: 1690 RVA: 0x00024D9C File Offset: 0x00022F9C
|
||||
public override void Update()
|
||||
{
|
||||
foreach (Mono.Security.X509.X509Certificate x509Certificate in this.clientCertificates)
|
||||
{
|
||||
base.Context.ClientSettings.Certificates.Add(new global::System.Security.Cryptography.X509Certificates.X509Certificate(x509Certificate.RawData));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600069B RID: 1691 RVA: 0x00024E20 File Offset: 0x00023020
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x0600069C RID: 1692 RVA: 0x00024E28 File Offset: 0x00023028
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
int num = 0;
|
||||
int i = base.ReadInt24();
|
||||
this.clientCertificates = new Mono.Security.X509.X509CertificateCollection();
|
||||
while (i > num)
|
||||
{
|
||||
int num2 = base.ReadInt24();
|
||||
num += num2 + 3;
|
||||
byte[] array = base.ReadBytes(num2);
|
||||
this.clientCertificates.Add(new Mono.Security.X509.X509Certificate(array));
|
||||
}
|
||||
if (this.clientCertificates.Count > 0)
|
||||
{
|
||||
this.validateCertificates(this.clientCertificates);
|
||||
}
|
||||
else if ((base.Context as ServerContext).ClientCertificateRequired)
|
||||
{
|
||||
throw new TlsException(AlertDescription.NoCertificate);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600069D RID: 1693 RVA: 0x00024EBC File Offset: 0x000230BC
|
||||
private bool checkCertificateUsage(Mono.Security.X509.X509Certificate cert)
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
if (cert.Version < 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
KeyUsages keyUsages = KeyUsages.none;
|
||||
switch (serverContext.Negotiating.Cipher.ExchangeAlgorithmType)
|
||||
{
|
||||
case ExchangeAlgorithmType.DiffieHellman:
|
||||
keyUsages = KeyUsages.keyAgreement;
|
||||
break;
|
||||
case ExchangeAlgorithmType.Fortezza:
|
||||
return false;
|
||||
case ExchangeAlgorithmType.RsaKeyX:
|
||||
case ExchangeAlgorithmType.RsaSign:
|
||||
keyUsages = KeyUsages.digitalSignature;
|
||||
break;
|
||||
}
|
||||
KeyUsageExtension keyUsageExtension = null;
|
||||
ExtendedKeyUsageExtension extendedKeyUsageExtension = null;
|
||||
Mono.Security.X509.X509Extension x509Extension = cert.Extensions["2.5.29.15"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
keyUsageExtension = new KeyUsageExtension(x509Extension);
|
||||
}
|
||||
x509Extension = cert.Extensions["2.5.29.37"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
extendedKeyUsageExtension = new ExtendedKeyUsageExtension(x509Extension);
|
||||
}
|
||||
if (keyUsageExtension != null && extendedKeyUsageExtension != null)
|
||||
{
|
||||
return keyUsageExtension.Support(keyUsages) && extendedKeyUsageExtension.KeyPurpose.Contains("1.3.6.1.5.5.7.3.2");
|
||||
}
|
||||
if (keyUsageExtension != null)
|
||||
{
|
||||
return keyUsageExtension.Support(keyUsages);
|
||||
}
|
||||
if (extendedKeyUsageExtension != null)
|
||||
{
|
||||
return extendedKeyUsageExtension.KeyPurpose.Contains("1.3.6.1.5.5.7.3.2");
|
||||
}
|
||||
x509Extension = cert.Extensions["2.16.840.1.113730.1.1"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
NetscapeCertTypeExtension netscapeCertTypeExtension = new NetscapeCertTypeExtension(x509Extension);
|
||||
return netscapeCertTypeExtension.Support(NetscapeCertTypeExtension.CertTypes.SslClient);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Token: 0x0600069E RID: 1694 RVA: 0x00024FF4 File Offset: 0x000231F4
|
||||
private void validateCertificates(Mono.Security.X509.X509CertificateCollection certificates)
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
AlertDescription alertDescription = AlertDescription.BadCertificate;
|
||||
global::System.Security.Cryptography.X509Certificates.X509Certificate x509Certificate = null;
|
||||
int[] array = null;
|
||||
if (certificates.Count > 0)
|
||||
{
|
||||
Mono.Security.X509.X509Certificate x509Certificate2 = certificates[0];
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (!this.checkCertificateUsage(x509Certificate2))
|
||||
{
|
||||
arrayList.Add(-2146762490);
|
||||
}
|
||||
Mono.Security.X509.X509Chain x509Chain;
|
||||
if (certificates.Count > 1)
|
||||
{
|
||||
Mono.Security.X509.X509CertificateCollection x509CertificateCollection = new Mono.Security.X509.X509CertificateCollection(certificates);
|
||||
x509CertificateCollection.Remove(x509Certificate2);
|
||||
x509Chain = new Mono.Security.X509.X509Chain(x509CertificateCollection);
|
||||
}
|
||||
else
|
||||
{
|
||||
x509Chain = new Mono.Security.X509.X509Chain();
|
||||
}
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
flag = x509Chain.Build(x509Certificate2);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
Mono.Security.X509.X509ChainStatusFlags status = x509Chain.Status;
|
||||
if (status != Mono.Security.X509.X509ChainStatusFlags.NotTimeValid)
|
||||
{
|
||||
if (status != Mono.Security.X509.X509ChainStatusFlags.NotTimeNested)
|
||||
{
|
||||
if (status != Mono.Security.X509.X509ChainStatusFlags.NotSignatureValid)
|
||||
{
|
||||
if (status != Mono.Security.X509.X509ChainStatusFlags.UntrustedRoot)
|
||||
{
|
||||
if (status != Mono.Security.X509.X509ChainStatusFlags.InvalidBasicConstraints)
|
||||
{
|
||||
if (status != Mono.Security.X509.X509ChainStatusFlags.PartialChain)
|
||||
{
|
||||
alertDescription = AlertDescription.CertificateUnknown;
|
||||
arrayList.Add((int)x509Chain.Status);
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDescription = AlertDescription.UnknownCA;
|
||||
arrayList.Add(-2146762486);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayList.Add(-2146869223);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDescription = AlertDescription.UnknownCA;
|
||||
arrayList.Add(-2146762487);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayList.Add(-2146869232);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
arrayList.Add(-2146762494);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDescription = AlertDescription.CertificateExpired;
|
||||
arrayList.Add(-2146762495);
|
||||
}
|
||||
}
|
||||
x509Certificate = new global::System.Security.Cryptography.X509Certificates.X509Certificate(x509Certificate2.RawData);
|
||||
array = (int[])arrayList.ToArray(typeof(int));
|
||||
}
|
||||
else
|
||||
{
|
||||
array = new int[0];
|
||||
}
|
||||
global::System.Security.Cryptography.X509Certificates.X509CertificateCollection x509CertificateCollection2 = new global::System.Security.Cryptography.X509Certificates.X509CertificateCollection();
|
||||
foreach (Mono.Security.X509.X509Certificate x509Certificate3 in certificates)
|
||||
{
|
||||
x509CertificateCollection2.Add(new global::System.Security.Cryptography.X509Certificates.X509Certificate(x509Certificate3.RawData));
|
||||
}
|
||||
if (!serverContext.SslStream.RaiseClientCertificateValidation(x509Certificate, array))
|
||||
{
|
||||
throw new TlsException(alertDescription, "Invalid certificate received from client.");
|
||||
}
|
||||
base.Context.ClientSettings.ClientCertificate = x509Certificate;
|
||||
}
|
||||
|
||||
// Token: 0x04000329 RID: 809
|
||||
private Mono.Security.X509.X509CertificateCollection clientCertificates;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B3 RID: 179
|
||||
internal class TlsClientCertificateVerify : HandshakeMessage
|
||||
{
|
||||
// Token: 0x0600069F RID: 1695 RVA: 0x00025288 File Offset: 0x00023488
|
||||
public TlsClientCertificateVerify(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.CertificateVerify, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006A0 RID: 1696 RVA: 0x00025294 File Offset: 0x00023494
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
int num = (int)base.ReadInt16();
|
||||
byte[] array = base.ReadBytes(num);
|
||||
SslHandshakeHash sslHandshakeHash = new SslHandshakeHash(serverContext.MasterSecret);
|
||||
sslHandshakeHash.TransformFinalBlock(serverContext.HandshakeMessages.ToArray(), 0, (int)serverContext.HandshakeMessages.Length);
|
||||
if (!sslHandshakeHash.VerifySignature(serverContext.ClientSettings.CertificateRSA, array))
|
||||
{
|
||||
throw new TlsException(AlertDescription.HandshakeFailiure, "Handshake Failure.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060006A1 RID: 1697 RVA: 0x0002530C File Offset: 0x0002350C
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
int num = (int)base.ReadInt16();
|
||||
byte[] array = base.ReadBytes(num);
|
||||
MD5SHA1 md5SHA = new MD5SHA1();
|
||||
md5SHA.ComputeHash(serverContext.HandshakeMessages.ToArray(), 0, (int)serverContext.HandshakeMessages.Length);
|
||||
if (!md5SHA.VerifySignature(serverContext.ClientSettings.CertificateRSA, array))
|
||||
{
|
||||
throw new TlsException(AlertDescription.HandshakeFailiure, "Handshake Failure.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B4 RID: 180
|
||||
internal class TlsClientFinished : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006A2 RID: 1698 RVA: 0x00025380 File Offset: 0x00023580
|
||||
public TlsClientFinished(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.Finished, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006A3 RID: 1699 RVA: 0x0002538C File Offset: 0x0002358C
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = new SslHandshakeHash(base.Context.MasterSecret);
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(base.Context.HandshakeMessages.ToArray());
|
||||
tlsStream.Write(1129074260);
|
||||
hashAlgorithm.TransformFinalBlock(tlsStream.ToArray(), 0, (int)tlsStream.Length);
|
||||
tlsStream.Reset();
|
||||
byte[] array = base.ReadBytes((int)this.Length);
|
||||
byte[] hash = hashAlgorithm.Hash;
|
||||
if (!HandshakeMessage.Compare(array, hash))
|
||||
{
|
||||
throw new TlsException(AlertDescription.DecryptError, "Decrypt error.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060006A4 RID: 1700 RVA: 0x0002541C File Offset: 0x0002361C
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
byte[] array = base.ReadBytes((int)this.Length);
|
||||
HashAlgorithm hashAlgorithm = new MD5SHA1();
|
||||
byte[] array2 = base.Context.HandshakeMessages.ToArray();
|
||||
byte[] array3 = hashAlgorithm.ComputeHash(array2, 0, array2.Length);
|
||||
byte[] array4 = base.Context.Current.Cipher.PRF(base.Context.MasterSecret, "client finished", array3, 12);
|
||||
if (!HandshakeMessage.Compare(array, array4))
|
||||
{
|
||||
throw new TlsException(AlertDescription.DecryptError, "Decrypt error.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B5 RID: 181
|
||||
internal class TlsClientHello : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006A5 RID: 1701 RVA: 0x000254A0 File Offset: 0x000236A0
|
||||
public TlsClientHello(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.ClientHello, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006A6 RID: 1702 RVA: 0x000254AC File Offset: 0x000236AC
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
this.selectCipherSuite();
|
||||
this.selectCompressionMethod();
|
||||
base.Context.SessionId = this.sessionId;
|
||||
base.Context.ClientRandom = this.random;
|
||||
base.Context.ProtocolNegotiated = true;
|
||||
}
|
||||
|
||||
// Token: 0x060006A7 RID: 1703 RVA: 0x000254FC File Offset: 0x000236FC
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x060006A8 RID: 1704 RVA: 0x00025504 File Offset: 0x00023704
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
this.processProtocol(base.ReadInt16());
|
||||
this.random = base.ReadBytes(32);
|
||||
this.sessionId = base.ReadBytes((int)base.ReadByte());
|
||||
this.cipherSuites = new short[(int)(base.ReadInt16() / 2)];
|
||||
for (int i = 0; i < this.cipherSuites.Length; i++)
|
||||
{
|
||||
this.cipherSuites[i] = base.ReadInt16();
|
||||
}
|
||||
this.compressionMethods = new byte[(int)base.ReadByte()];
|
||||
for (int j = 0; j < this.compressionMethods.Length; j++)
|
||||
{
|
||||
this.compressionMethods[j] = base.ReadByte();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060006A9 RID: 1705 RVA: 0x000255B0 File Offset: 0x000237B0
|
||||
private void processProtocol(short protocol)
|
||||
{
|
||||
SecurityProtocolType securityProtocolType = base.Context.DecodeProtocolCode(protocol);
|
||||
if ((securityProtocolType & base.Context.SecurityProtocolFlags) == securityProtocolType || (base.Context.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default)
|
||||
{
|
||||
base.Context.SecurityProtocol = securityProtocolType;
|
||||
base.Context.SupportedCiphers.Clear();
|
||||
base.Context.SupportedCiphers = null;
|
||||
base.Context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(securityProtocolType);
|
||||
return;
|
||||
}
|
||||
throw new TlsException(AlertDescription.ProtocolVersion, "Incorrect protocol version received from server");
|
||||
}
|
||||
|
||||
// Token: 0x060006AA RID: 1706 RVA: 0x00025644 File Offset: 0x00023844
|
||||
private void selectCipherSuite()
|
||||
{
|
||||
for (int i = 0; i < this.cipherSuites.Length; i++)
|
||||
{
|
||||
int num;
|
||||
if ((num = base.Context.SupportedCiphers.IndexOf(this.cipherSuites[i])) != -1)
|
||||
{
|
||||
base.Context.Negotiating.Cipher = base.Context.SupportedCiphers[num];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (base.Context.Negotiating.Cipher == null)
|
||||
{
|
||||
throw new TlsException(AlertDescription.InsuficientSecurity, "Insuficient Security");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060006AB RID: 1707 RVA: 0x000256D4 File Offset: 0x000238D4
|
||||
private void selectCompressionMethod()
|
||||
{
|
||||
base.Context.CompressionMethod = SecurityCompressionType.None;
|
||||
}
|
||||
|
||||
// Token: 0x0400032A RID: 810
|
||||
private byte[] random;
|
||||
|
||||
// Token: 0x0400032B RID: 811
|
||||
private byte[] sessionId;
|
||||
|
||||
// Token: 0x0400032C RID: 812
|
||||
private short[] cipherSuites;
|
||||
|
||||
// Token: 0x0400032D RID: 813
|
||||
private byte[] compressionMethods;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B6 RID: 182
|
||||
internal class TlsClientKeyExchange : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006AC RID: 1708 RVA: 0x000256E4 File Offset: 0x000238E4
|
||||
public TlsClientKeyExchange(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.ClientKeyExchange, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006AD RID: 1709 RVA: 0x000256F0 File Offset: 0x000238F0
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
AsymmetricAlgorithm asymmetricAlgorithm = serverContext.SslStream.RaisePrivateKeySelection(new X509Certificate(serverContext.ServerSettings.Certificates[0].RawData), null);
|
||||
if (asymmetricAlgorithm == null)
|
||||
{
|
||||
throw new TlsException(AlertDescription.UserCancelled, "Server certificate Private Key unavailable.");
|
||||
}
|
||||
byte[] array = base.ReadBytes((int)this.Length);
|
||||
RSAPKCS1KeyExchangeDeformatter rsapkcs1KeyExchangeDeformatter = new RSAPKCS1KeyExchangeDeformatter(asymmetricAlgorithm);
|
||||
byte[] array2 = rsapkcs1KeyExchangeDeformatter.DecryptKeyExchange(array);
|
||||
base.Context.Negotiating.Cipher.ComputeMasterSecret(array2);
|
||||
base.Context.Negotiating.Cipher.ComputeKeys();
|
||||
base.Context.Negotiating.Cipher.InitializeCipher();
|
||||
}
|
||||
|
||||
// Token: 0x060006AE RID: 1710 RVA: 0x000257A8 File Offset: 0x000239A8
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
AsymmetricAlgorithm asymmetricAlgorithm = serverContext.SslStream.RaisePrivateKeySelection(new X509Certificate(serverContext.ServerSettings.Certificates[0].RawData), null);
|
||||
if (asymmetricAlgorithm == null)
|
||||
{
|
||||
throw new TlsException(AlertDescription.UserCancelled, "Server certificate Private Key unavailable.");
|
||||
}
|
||||
byte[] array = base.ReadBytes((int)base.ReadInt16());
|
||||
RSAPKCS1KeyExchangeDeformatter rsapkcs1KeyExchangeDeformatter = new RSAPKCS1KeyExchangeDeformatter(asymmetricAlgorithm);
|
||||
byte[] array2 = rsapkcs1KeyExchangeDeformatter.DecryptKeyExchange(array);
|
||||
base.Context.Negotiating.Cipher.ComputeMasterSecret(array2);
|
||||
base.Context.Negotiating.Cipher.ComputeKeys();
|
||||
base.Context.Negotiating.Cipher.InitializeCipher();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B7 RID: 183
|
||||
internal class TlsServerCertificate : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006AF RID: 1711 RVA: 0x0002585C File Offset: 0x00023A5C
|
||||
public TlsServerCertificate(Context context)
|
||||
: base(context, HandshakeType.Certificate)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006B0 RID: 1712 RVA: 0x00025868 File Offset: 0x00023A68
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x060006B1 RID: 1713 RVA: 0x00025870 File Offset: 0x00023A70
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
foreach (X509Certificate x509Certificate in base.Context.ServerSettings.Certificates)
|
||||
{
|
||||
tlsStream.WriteInt24(x509Certificate.RawData.Length);
|
||||
tlsStream.Write(x509Certificate.RawData);
|
||||
}
|
||||
base.WriteInt24(Convert.ToInt32(tlsStream.Length));
|
||||
base.Write(tlsStream.ToArray());
|
||||
tlsStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B8 RID: 184
|
||||
internal class TlsServerCertificateRequest : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006B2 RID: 1714 RVA: 0x00025920 File Offset: 0x00023B20
|
||||
public TlsServerCertificateRequest(Context context)
|
||||
: base(context, HandshakeType.CertificateRequest)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006B3 RID: 1715 RVA: 0x0002592C File Offset: 0x00023B2C
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x060006B4 RID: 1716 RVA: 0x00025934 File Offset: 0x00023B34
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
int num = serverContext.ServerSettings.CertificateTypes.Length;
|
||||
this.WriteByte(Convert.ToByte(num));
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
this.WriteByte((byte)serverContext.ServerSettings.CertificateTypes[i]);
|
||||
}
|
||||
if (serverContext.ServerSettings.DistinguisedNames.Length > 0)
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
foreach (string text in serverContext.ServerSettings.DistinguisedNames)
|
||||
{
|
||||
byte[] bytes = X501.FromString(text).GetBytes();
|
||||
tlsStream.Write((short)bytes.Length);
|
||||
tlsStream.Write(bytes);
|
||||
}
|
||||
base.Write((short)tlsStream.Length);
|
||||
base.Write(tlsStream.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Write(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000B9 RID: 185
|
||||
internal class TlsServerFinished : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006B5 RID: 1717 RVA: 0x00025A1C File Offset: 0x00023C1C
|
||||
public TlsServerFinished(Context context)
|
||||
: base(context, HandshakeType.Finished)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006B7 RID: 1719 RVA: 0x00025A40 File Offset: 0x00023C40
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = new SslHandshakeHash(base.Context.MasterSecret);
|
||||
byte[] array = base.Context.HandshakeMessages.ToArray();
|
||||
hashAlgorithm.TransformBlock(array, 0, array.Length, array, 0);
|
||||
hashAlgorithm.TransformBlock(TlsServerFinished.Ssl3Marker, 0, TlsServerFinished.Ssl3Marker.Length, TlsServerFinished.Ssl3Marker, 0);
|
||||
hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
base.Write(hashAlgorithm.Hash);
|
||||
}
|
||||
|
||||
// Token: 0x060006B8 RID: 1720 RVA: 0x00025AB4 File Offset: 0x00023CB4
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = new MD5SHA1();
|
||||
byte[] array = base.Context.HandshakeMessages.ToArray();
|
||||
byte[] array2 = hashAlgorithm.ComputeHash(array, 0, array.Length);
|
||||
base.Write(base.Context.Current.Cipher.PRF(base.Context.MasterSecret, "server finished", array2, 12));
|
||||
}
|
||||
|
||||
// Token: 0x0400032E RID: 814
|
||||
private static byte[] Ssl3Marker = new byte[] { 83, 82, 86, 82 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000BA RID: 186
|
||||
internal class TlsServerHello : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006B9 RID: 1721 RVA: 0x00025B14 File Offset: 0x00023D14
|
||||
public TlsServerHello(Context context)
|
||||
: base(context, HandshakeType.ServerHello)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006BA RID: 1722 RVA: 0x00025B20 File Offset: 0x00023D20
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(this.unixTime);
|
||||
tlsStream.Write(this.random);
|
||||
base.Context.ServerRandom = tlsStream.ToArray();
|
||||
tlsStream.Reset();
|
||||
tlsStream.Write(base.Context.ClientRandom);
|
||||
tlsStream.Write(base.Context.ServerRandom);
|
||||
base.Context.RandomCS = tlsStream.ToArray();
|
||||
tlsStream.Reset();
|
||||
tlsStream.Write(base.Context.ServerRandom);
|
||||
tlsStream.Write(base.Context.ClientRandom);
|
||||
base.Context.RandomSC = tlsStream.ToArray();
|
||||
tlsStream.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x060006BB RID: 1723 RVA: 0x00025BDC File Offset: 0x00023DDC
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x060006BC RID: 1724 RVA: 0x00025BE4 File Offset: 0x00023DE4
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
base.Write(base.Context.Protocol);
|
||||
this.unixTime = base.Context.GetUnixTime();
|
||||
base.Write(this.unixTime);
|
||||
this.random = base.Context.GetSecureRandomBytes(28);
|
||||
base.Write(this.random);
|
||||
if (base.Context.SessionId == null)
|
||||
{
|
||||
this.WriteByte(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteByte((byte)base.Context.SessionId.Length);
|
||||
base.Write(base.Context.SessionId);
|
||||
}
|
||||
base.Write(base.Context.Negotiating.Cipher.Code);
|
||||
this.WriteByte((byte)base.Context.CompressionMethod);
|
||||
}
|
||||
|
||||
// Token: 0x0400032F RID: 815
|
||||
private int unixTime;
|
||||
|
||||
// Token: 0x04000330 RID: 816
|
||||
private byte[] random;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000BB RID: 187
|
||||
internal class TlsServerHelloDone : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006BD RID: 1725 RVA: 0x00025CAC File Offset: 0x00023EAC
|
||||
public TlsServerHelloDone(Context context)
|
||||
: base(context, HandshakeType.ServerHelloDone)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006BE RID: 1726 RVA: 0x00025CB8 File Offset: 0x00023EB8
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006BF RID: 1727 RVA: 0x00025CBC File Offset: 0x00023EBC
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Server
|
||||
{
|
||||
// Token: 0x020000BC RID: 188
|
||||
internal class TlsServerKeyExchange : HandshakeMessage
|
||||
{
|
||||
// Token: 0x060006C0 RID: 1728 RVA: 0x00025CC0 File Offset: 0x00023EC0
|
||||
public TlsServerKeyExchange(Context context)
|
||||
: base(context, HandshakeType.ServerKeyExchange)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060006C1 RID: 1729 RVA: 0x00025CCC File Offset: 0x00023ECC
|
||||
public override void Update()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
// Token: 0x060006C2 RID: 1730 RVA: 0x00025CD4 File Offset: 0x00023ED4
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x060006C3 RID: 1731 RVA: 0x00025CDC File Offset: 0x00023EDC
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
ServerContext serverContext = (ServerContext)base.Context;
|
||||
RSA rsa = (RSA)serverContext.SslStream.PrivateKeyCertSelectionDelegate(new X509Certificate(serverContext.ServerSettings.Certificates[0].RawData), null);
|
||||
RSAParameters rsaparameters = rsa.ExportParameters(false);
|
||||
base.WriteInt24(rsaparameters.Modulus.Length);
|
||||
this.Write(rsaparameters.Modulus, 0, rsaparameters.Modulus.Length);
|
||||
base.WriteInt24(rsaparameters.Exponent.Length);
|
||||
this.Write(rsaparameters.Exponent, 0, rsaparameters.Exponent.Length);
|
||||
byte[] array = this.createSignature(rsa, base.ToArray());
|
||||
base.WriteInt24(array.Length);
|
||||
base.Write(array);
|
||||
}
|
||||
|
||||
// Token: 0x060006C4 RID: 1732 RVA: 0x00025D9C File Offset: 0x00023F9C
|
||||
private byte[] createSignature(RSA rsa, byte[] buffer)
|
||||
{
|
||||
MD5SHA1 md5SHA = new MD5SHA1();
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(base.Context.RandomCS);
|
||||
tlsStream.Write(buffer, 0, buffer.Length);
|
||||
md5SHA.ComputeHash(tlsStream.ToArray());
|
||||
tlsStream.Reset();
|
||||
return md5SHA.CreateSignature(rsa);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user