scripts
This commit is contained in:
@@ -0,0 +1,220 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Ntlm
|
||||
{
|
||||
// Token: 0x02000076 RID: 118
|
||||
public class ChallengeResponse : IDisposable
|
||||
{
|
||||
// Token: 0x06000437 RID: 1079 RVA: 0x0001B350 File Offset: 0x00019550
|
||||
public ChallengeResponse()
|
||||
{
|
||||
this._disposed = false;
|
||||
this._lmpwd = new byte[21];
|
||||
this._ntpwd = new byte[21];
|
||||
}
|
||||
|
||||
// Token: 0x06000438 RID: 1080 RVA: 0x0001B37C File Offset: 0x0001957C
|
||||
public ChallengeResponse(string password, byte[] challenge)
|
||||
: this()
|
||||
{
|
||||
this.Password = password;
|
||||
this.Challenge = challenge;
|
||||
}
|
||||
|
||||
// Token: 0x0600043A RID: 1082 RVA: 0x0001B3D0 File Offset: 0x000195D0
|
||||
~ChallengeResponse()
|
||||
{
|
||||
if (!this._disposed)
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F5 RID: 245
|
||||
// (get) Token: 0x0600043B RID: 1083 RVA: 0x0001B418 File Offset: 0x00019618
|
||||
// (set) Token: 0x0600043C RID: 1084 RVA: 0x0001B41C File Offset: 0x0001961C
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this._disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("too late");
|
||||
}
|
||||
DES des = DES.Create();
|
||||
des.Mode = CipherMode.ECB;
|
||||
if (value == null || value.Length < 1)
|
||||
{
|
||||
Buffer.BlockCopy(ChallengeResponse.nullEncMagic, 0, this._lmpwd, 0, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
des.Key = this.PasswordToKey(value, 0);
|
||||
ICryptoTransform cryptoTransform = des.CreateEncryptor();
|
||||
cryptoTransform.TransformBlock(ChallengeResponse.magic, 0, 8, this._lmpwd, 0);
|
||||
}
|
||||
if (value == null || value.Length < 8)
|
||||
{
|
||||
Buffer.BlockCopy(ChallengeResponse.nullEncMagic, 0, this._lmpwd, 8, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
des.Key = this.PasswordToKey(value, 7);
|
||||
ICryptoTransform cryptoTransform = des.CreateEncryptor();
|
||||
cryptoTransform.TransformBlock(ChallengeResponse.magic, 0, 8, this._lmpwd, 8);
|
||||
}
|
||||
MD4 md = MD4.Create();
|
||||
byte[] array = ((value != null) ? Encoding.Unicode.GetBytes(value) : new byte[0]);
|
||||
byte[] array2 = md.ComputeHash(array);
|
||||
Buffer.BlockCopy(array2, 0, this._ntpwd, 0, 16);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
Array.Clear(array2, 0, array2.Length);
|
||||
des.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F6 RID: 246
|
||||
// (get) Token: 0x0600043D RID: 1085 RVA: 0x0001B550 File Offset: 0x00019750
|
||||
// (set) Token: 0x0600043E RID: 1086 RVA: 0x0001B554 File Offset: 0x00019754
|
||||
public byte[] Challenge
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("Challenge");
|
||||
}
|
||||
if (this._disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("too late");
|
||||
}
|
||||
this._challenge = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F7 RID: 247
|
||||
// (get) Token: 0x0600043F RID: 1087 RVA: 0x0001B59C File Offset: 0x0001979C
|
||||
public byte[] LM
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("too late");
|
||||
}
|
||||
return this.GetResponse(this._lmpwd);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000F8 RID: 248
|
||||
// (get) Token: 0x06000440 RID: 1088 RVA: 0x0001B5CC File Offset: 0x000197CC
|
||||
public byte[] NT
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("too late");
|
||||
}
|
||||
return this.GetResponse(this._ntpwd);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000441 RID: 1089 RVA: 0x0001B5FC File Offset: 0x000197FC
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Token: 0x06000442 RID: 1090 RVA: 0x0001B60C File Offset: 0x0001980C
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!this._disposed)
|
||||
{
|
||||
Array.Clear(this._lmpwd, 0, this._lmpwd.Length);
|
||||
Array.Clear(this._ntpwd, 0, this._ntpwd.Length);
|
||||
if (this._challenge != null)
|
||||
{
|
||||
Array.Clear(this._challenge, 0, this._challenge.Length);
|
||||
}
|
||||
this._disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000443 RID: 1091 RVA: 0x0001B674 File Offset: 0x00019874
|
||||
private byte[] GetResponse(byte[] pwd)
|
||||
{
|
||||
byte[] array = new byte[24];
|
||||
DES des = DES.Create();
|
||||
des.Mode = CipherMode.ECB;
|
||||
des.Key = this.PrepareDESKey(pwd, 0);
|
||||
ICryptoTransform cryptoTransform = des.CreateEncryptor();
|
||||
cryptoTransform.TransformBlock(this._challenge, 0, 8, array, 0);
|
||||
des.Key = this.PrepareDESKey(pwd, 7);
|
||||
cryptoTransform = des.CreateEncryptor();
|
||||
cryptoTransform.TransformBlock(this._challenge, 0, 8, array, 8);
|
||||
des.Key = this.PrepareDESKey(pwd, 14);
|
||||
cryptoTransform = des.CreateEncryptor();
|
||||
cryptoTransform.TransformBlock(this._challenge, 0, 8, array, 16);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000444 RID: 1092 RVA: 0x0001B70C File Offset: 0x0001990C
|
||||
private byte[] PrepareDESKey(byte[] key56bits, int position)
|
||||
{
|
||||
return new byte[]
|
||||
{
|
||||
key56bits[position],
|
||||
(byte)(((int)key56bits[position] << 7) | (key56bits[position + 1] >> 1)),
|
||||
(byte)(((int)key56bits[position + 1] << 6) | (key56bits[position + 2] >> 2)),
|
||||
(byte)(((int)key56bits[position + 2] << 5) | (key56bits[position + 3] >> 3)),
|
||||
(byte)(((int)key56bits[position + 3] << 4) | (key56bits[position + 4] >> 4)),
|
||||
(byte)(((int)key56bits[position + 4] << 3) | (key56bits[position + 5] >> 5)),
|
||||
(byte)(((int)key56bits[position + 5] << 2) | (key56bits[position + 6] >> 6)),
|
||||
(byte)(key56bits[position + 6] << 1)
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x06000445 RID: 1093 RVA: 0x0001B7A4 File Offset: 0x000199A4
|
||||
private byte[] PasswordToKey(string password, int position)
|
||||
{
|
||||
byte[] array = new byte[7];
|
||||
int num = Math.Min(password.Length - position, 7);
|
||||
Encoding.ASCII.GetBytes(password.ToUpper(CultureInfo.CurrentCulture), position, num, array, 0);
|
||||
byte[] array2 = this.PrepareDESKey(array, 0);
|
||||
Array.Clear(array, 0, array.Length);
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x040001F8 RID: 504
|
||||
private static byte[] magic = new byte[] { 75, 71, 83, 33, 64, 35, 36, 37 };
|
||||
|
||||
// Token: 0x040001F9 RID: 505
|
||||
private static byte[] nullEncMagic = new byte[] { 170, 211, 180, 53, 181, 20, 4, 238 };
|
||||
|
||||
// Token: 0x040001FA RID: 506
|
||||
private bool _disposed;
|
||||
|
||||
// Token: 0x040001FB RID: 507
|
||||
private byte[] _challenge;
|
||||
|
||||
// Token: 0x040001FC RID: 508
|
||||
private byte[] _lmpwd;
|
||||
|
||||
// Token: 0x040001FD RID: 509
|
||||
private byte[] _ntpwd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Ntlm
|
||||
{
|
||||
// Token: 0x02000077 RID: 119
|
||||
public abstract class MessageBase
|
||||
{
|
||||
// Token: 0x06000446 RID: 1094 RVA: 0x0001B7F8 File Offset: 0x000199F8
|
||||
protected MessageBase(int messageType)
|
||||
{
|
||||
this._type = messageType;
|
||||
}
|
||||
|
||||
// Token: 0x170000F9 RID: 249
|
||||
// (get) Token: 0x06000448 RID: 1096 RVA: 0x0001B820 File Offset: 0x00019A20
|
||||
// (set) Token: 0x06000449 RID: 1097 RVA: 0x0001B828 File Offset: 0x00019A28
|
||||
public NtlmFlags Flags
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._flags;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._flags = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FA RID: 250
|
||||
// (get) Token: 0x0600044A RID: 1098 RVA: 0x0001B834 File Offset: 0x00019A34
|
||||
public int Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600044B RID: 1099 RVA: 0x0001B83C File Offset: 0x00019A3C
|
||||
protected byte[] PrepareMessage(int messageSize)
|
||||
{
|
||||
byte[] array = new byte[messageSize];
|
||||
Buffer.BlockCopy(MessageBase.header, 0, array, 0, 8);
|
||||
array[8] = (byte)this._type;
|
||||
array[9] = (byte)(this._type >> 8);
|
||||
array[10] = (byte)(this._type >> 16);
|
||||
array[11] = (byte)(this._type >> 24);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0600044C RID: 1100 RVA: 0x0001B894 File Offset: 0x00019A94
|
||||
protected virtual void Decode(byte[] message)
|
||||
{
|
||||
if (message == null)
|
||||
{
|
||||
throw new ArgumentNullException("message");
|
||||
}
|
||||
if (message.Length < 12)
|
||||
{
|
||||
string text = Locale.GetText("Minimum message length is 12 bytes.");
|
||||
throw new ArgumentOutOfRangeException("message", message.Length, text);
|
||||
}
|
||||
if (!this.CheckHeader(message))
|
||||
{
|
||||
string text2 = string.Format(Locale.GetText("Invalid Type{0} message."), this._type);
|
||||
throw new ArgumentException(text2, "message");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600044D RID: 1101 RVA: 0x0001B910 File Offset: 0x00019B10
|
||||
protected bool CheckHeader(byte[] message)
|
||||
{
|
||||
for (int i = 0; i < MessageBase.header.Length; i++)
|
||||
{
|
||||
if (message[i] != MessageBase.header[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (ulong)BitConverterLE.ToUInt32(message, 8) == (ulong)((long)this._type);
|
||||
}
|
||||
|
||||
// Token: 0x0600044E RID: 1102
|
||||
public abstract byte[] GetBytes();
|
||||
|
||||
// Token: 0x040001FE RID: 510
|
||||
private static byte[] header = new byte[] { 78, 84, 76, 77, 83, 83, 80, 0 };
|
||||
|
||||
// Token: 0x040001FF RID: 511
|
||||
private int _type;
|
||||
|
||||
// Token: 0x04000200 RID: 512
|
||||
private NtlmFlags _flags;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Ntlm
|
||||
{
|
||||
// Token: 0x02000078 RID: 120
|
||||
[Flags]
|
||||
public enum NtlmFlags
|
||||
{
|
||||
// Token: 0x04000202 RID: 514
|
||||
NegotiateUnicode = 1,
|
||||
// Token: 0x04000203 RID: 515
|
||||
NegotiateOem = 2,
|
||||
// Token: 0x04000204 RID: 516
|
||||
RequestTarget = 4,
|
||||
// Token: 0x04000205 RID: 517
|
||||
NegotiateNtlm = 512,
|
||||
// Token: 0x04000206 RID: 518
|
||||
NegotiateDomainSupplied = 4096,
|
||||
// Token: 0x04000207 RID: 519
|
||||
NegotiateWorkstationSupplied = 8192,
|
||||
// Token: 0x04000208 RID: 520
|
||||
NegotiateAlwaysSign = 32768,
|
||||
// Token: 0x04000209 RID: 521
|
||||
NegotiateNtlm2Key = 524288,
|
||||
// Token: 0x0400020A RID: 522
|
||||
Negotiate128 = 536870912,
|
||||
// Token: 0x0400020B RID: 523
|
||||
Negotiate56 = -2147483648
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.Protocol.Ntlm
|
||||
{
|
||||
// Token: 0x02000079 RID: 121
|
||||
public class Type1Message : MessageBase
|
||||
{
|
||||
// Token: 0x0600044F RID: 1103 RVA: 0x0001B958 File Offset: 0x00019B58
|
||||
public Type1Message()
|
||||
: base(1)
|
||||
{
|
||||
this._domain = Environment.UserDomainName;
|
||||
this._host = Environment.MachineName;
|
||||
base.Flags = NtlmFlags.NegotiateUnicode | NtlmFlags.NegotiateOem | NtlmFlags.NegotiateNtlm | NtlmFlags.NegotiateDomainSupplied | NtlmFlags.NegotiateWorkstationSupplied | NtlmFlags.NegotiateAlwaysSign;
|
||||
}
|
||||
|
||||
// Token: 0x06000450 RID: 1104 RVA: 0x0001B990 File Offset: 0x00019B90
|
||||
public Type1Message(byte[] message)
|
||||
: base(1)
|
||||
{
|
||||
this.Decode(message);
|
||||
}
|
||||
|
||||
// Token: 0x170000FB RID: 251
|
||||
// (get) Token: 0x06000451 RID: 1105 RVA: 0x0001B9A0 File Offset: 0x00019BA0
|
||||
// (set) Token: 0x06000452 RID: 1106 RVA: 0x0001B9A8 File Offset: 0x00019BA8
|
||||
public string Domain
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._domain;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._domain = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FC RID: 252
|
||||
// (get) Token: 0x06000453 RID: 1107 RVA: 0x0001B9B4 File Offset: 0x00019BB4
|
||||
// (set) Token: 0x06000454 RID: 1108 RVA: 0x0001B9BC File Offset: 0x00019BBC
|
||||
public string Host
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._host;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._host = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000455 RID: 1109 RVA: 0x0001B9C8 File Offset: 0x00019BC8
|
||||
protected override void Decode(byte[] message)
|
||||
{
|
||||
base.Decode(message);
|
||||
base.Flags = (NtlmFlags)BitConverterLE.ToUInt32(message, 12);
|
||||
int num = (int)BitConverterLE.ToUInt16(message, 16);
|
||||
int num2 = (int)BitConverterLE.ToUInt16(message, 20);
|
||||
this._domain = Encoding.ASCII.GetString(message, num2, num);
|
||||
int num3 = (int)BitConverterLE.ToUInt16(message, 24);
|
||||
this._host = Encoding.ASCII.GetString(message, 32, num3);
|
||||
}
|
||||
|
||||
// Token: 0x06000456 RID: 1110 RVA: 0x0001BA2C File Offset: 0x00019C2C
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
short num = (short)this._domain.Length;
|
||||
short num2 = (short)this._host.Length;
|
||||
byte[] array = base.PrepareMessage((int)(32 + num + num2));
|
||||
array[12] = (byte)base.Flags;
|
||||
array[13] = (byte)(base.Flags >> 8);
|
||||
array[14] = (byte)(base.Flags >> 16);
|
||||
array[15] = (byte)(base.Flags >> 24);
|
||||
short num3 = 32 + num2;
|
||||
array[16] = (byte)num;
|
||||
array[17] = (byte)(num >> 8);
|
||||
array[18] = array[16];
|
||||
array[19] = array[17];
|
||||
array[20] = (byte)num3;
|
||||
array[21] = (byte)(num3 >> 8);
|
||||
array[24] = (byte)num2;
|
||||
array[25] = (byte)(num2 >> 8);
|
||||
array[26] = array[24];
|
||||
array[27] = array[25];
|
||||
array[28] = 32;
|
||||
array[29] = 0;
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(this._host.ToUpper(CultureInfo.InvariantCulture));
|
||||
Buffer.BlockCopy(bytes, 0, array, 32, bytes.Length);
|
||||
byte[] bytes2 = Encoding.ASCII.GetBytes(this._domain.ToUpper(CultureInfo.InvariantCulture));
|
||||
Buffer.BlockCopy(bytes2, 0, array, (int)num3, bytes2.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0400020C RID: 524
|
||||
private string _host;
|
||||
|
||||
// Token: 0x0400020D RID: 525
|
||||
private string _domain;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Ntlm
|
||||
{
|
||||
// Token: 0x0200007A RID: 122
|
||||
public class Type2Message : MessageBase
|
||||
{
|
||||
// Token: 0x06000457 RID: 1111 RVA: 0x0001BB48 File Offset: 0x00019D48
|
||||
public Type2Message()
|
||||
: base(2)
|
||||
{
|
||||
this._nonce = new byte[8];
|
||||
RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();
|
||||
randomNumberGenerator.GetBytes(this._nonce);
|
||||
base.Flags = NtlmFlags.NegotiateUnicode | NtlmFlags.NegotiateNtlm | NtlmFlags.NegotiateAlwaysSign;
|
||||
}
|
||||
|
||||
// Token: 0x06000458 RID: 1112 RVA: 0x0001BB88 File Offset: 0x00019D88
|
||||
public Type2Message(byte[] message)
|
||||
: base(2)
|
||||
{
|
||||
this._nonce = new byte[8];
|
||||
this.Decode(message);
|
||||
}
|
||||
|
||||
// Token: 0x06000459 RID: 1113 RVA: 0x0001BBA4 File Offset: 0x00019DA4
|
||||
~Type2Message()
|
||||
{
|
||||
if (this._nonce != null)
|
||||
{
|
||||
Array.Clear(this._nonce, 0, this._nonce.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FD RID: 253
|
||||
// (get) Token: 0x0600045A RID: 1114 RVA: 0x0001BBF8 File Offset: 0x00019DF8
|
||||
// (set) Token: 0x0600045B RID: 1115 RVA: 0x0001BC0C File Offset: 0x00019E0C
|
||||
public byte[] Nonce
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this._nonce.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("Nonce");
|
||||
}
|
||||
if (value.Length != 8)
|
||||
{
|
||||
string text = Locale.GetText("Invalid Nonce Length (should be 8 bytes).");
|
||||
throw new ArgumentException(text, "Nonce");
|
||||
}
|
||||
this._nonce = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600045C RID: 1116 RVA: 0x0001BC5C File Offset: 0x00019E5C
|
||||
protected override void Decode(byte[] message)
|
||||
{
|
||||
base.Decode(message);
|
||||
base.Flags = (NtlmFlags)BitConverterLE.ToUInt32(message, 20);
|
||||
Buffer.BlockCopy(message, 24, this._nonce, 0, 8);
|
||||
}
|
||||
|
||||
// Token: 0x0600045D RID: 1117 RVA: 0x0001BC90 File Offset: 0x00019E90
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
byte[] array = base.PrepareMessage(40);
|
||||
short num = (short)array.Length;
|
||||
array[16] = (byte)num;
|
||||
array[17] = (byte)(num >> 8);
|
||||
array[20] = (byte)base.Flags;
|
||||
array[21] = (byte)(base.Flags >> 8);
|
||||
array[22] = (byte)(base.Flags >> 16);
|
||||
array[23] = (byte)(base.Flags >> 24);
|
||||
Buffer.BlockCopy(this._nonce, 0, array, 24, this._nonce.Length);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0400020E RID: 526
|
||||
private byte[] _nonce;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.Protocol.Ntlm
|
||||
{
|
||||
// Token: 0x0200007B RID: 123
|
||||
public class Type3Message : MessageBase
|
||||
{
|
||||
// Token: 0x0600045E RID: 1118 RVA: 0x0001BD08 File Offset: 0x00019F08
|
||||
public Type3Message()
|
||||
: base(3)
|
||||
{
|
||||
this._domain = Environment.UserDomainName;
|
||||
this._host = Environment.MachineName;
|
||||
this._username = Environment.UserName;
|
||||
base.Flags = NtlmFlags.NegotiateUnicode | NtlmFlags.NegotiateNtlm | NtlmFlags.NegotiateAlwaysSign;
|
||||
}
|
||||
|
||||
// Token: 0x0600045F RID: 1119 RVA: 0x0001BD40 File Offset: 0x00019F40
|
||||
public Type3Message(byte[] message)
|
||||
: base(3)
|
||||
{
|
||||
this.Decode(message);
|
||||
}
|
||||
|
||||
// Token: 0x06000460 RID: 1120 RVA: 0x0001BD50 File Offset: 0x00019F50
|
||||
~Type3Message()
|
||||
{
|
||||
if (this._challenge != null)
|
||||
{
|
||||
Array.Clear(this._challenge, 0, this._challenge.Length);
|
||||
}
|
||||
if (this._lm != null)
|
||||
{
|
||||
Array.Clear(this._lm, 0, this._lm.Length);
|
||||
}
|
||||
if (this._nt != null)
|
||||
{
|
||||
Array.Clear(this._nt, 0, this._nt.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FE RID: 254
|
||||
// (get) Token: 0x06000461 RID: 1121 RVA: 0x0001BDE4 File Offset: 0x00019FE4
|
||||
// (set) Token: 0x06000462 RID: 1122 RVA: 0x0001BE04 File Offset: 0x0001A004
|
||||
public byte[] Challenge
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._challenge == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this._challenge.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("Challenge");
|
||||
}
|
||||
if (value.Length != 8)
|
||||
{
|
||||
string text = Locale.GetText("Invalid Challenge Length (should be 8 bytes).");
|
||||
throw new ArgumentException(text, "Challenge");
|
||||
}
|
||||
this._challenge = (byte[])value.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000FF RID: 255
|
||||
// (get) Token: 0x06000463 RID: 1123 RVA: 0x0001BE54 File Offset: 0x0001A054
|
||||
// (set) Token: 0x06000464 RID: 1124 RVA: 0x0001BE5C File Offset: 0x0001A05C
|
||||
public string Domain
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._domain;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._domain = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000100 RID: 256
|
||||
// (get) Token: 0x06000465 RID: 1125 RVA: 0x0001BE68 File Offset: 0x0001A068
|
||||
// (set) Token: 0x06000466 RID: 1126 RVA: 0x0001BE70 File Offset: 0x0001A070
|
||||
public string Host
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._host;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._host = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000101 RID: 257
|
||||
// (get) Token: 0x06000467 RID: 1127 RVA: 0x0001BE7C File Offset: 0x0001A07C
|
||||
// (set) Token: 0x06000468 RID: 1128 RVA: 0x0001BE84 File Offset: 0x0001A084
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._password;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._password = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000102 RID: 258
|
||||
// (get) Token: 0x06000469 RID: 1129 RVA: 0x0001BE90 File Offset: 0x0001A090
|
||||
// (set) Token: 0x0600046A RID: 1130 RVA: 0x0001BE98 File Offset: 0x0001A098
|
||||
public string Username
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._username;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._username = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000103 RID: 259
|
||||
// (get) Token: 0x0600046B RID: 1131 RVA: 0x0001BEA4 File Offset: 0x0001A0A4
|
||||
public byte[] LM
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._lm;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000104 RID: 260
|
||||
// (get) Token: 0x0600046C RID: 1132 RVA: 0x0001BEAC File Offset: 0x0001A0AC
|
||||
public byte[] NT
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._nt;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600046D RID: 1133 RVA: 0x0001BEB4 File Offset: 0x0001A0B4
|
||||
protected override void Decode(byte[] message)
|
||||
{
|
||||
base.Decode(message);
|
||||
if ((int)BitConverterLE.ToUInt16(message, 56) != message.Length)
|
||||
{
|
||||
string text = Locale.GetText("Invalid Type3 message length.");
|
||||
throw new ArgumentException(text, "message");
|
||||
}
|
||||
this._password = null;
|
||||
int num = (int)BitConverterLE.ToUInt16(message, 28);
|
||||
int num2 = 64;
|
||||
this._domain = Encoding.Unicode.GetString(message, num2, num);
|
||||
int num3 = (int)BitConverterLE.ToUInt16(message, 44);
|
||||
int num4 = (int)BitConverterLE.ToUInt16(message, 48);
|
||||
this._host = Encoding.Unicode.GetString(message, num4, num3);
|
||||
int num5 = (int)BitConverterLE.ToUInt16(message, 36);
|
||||
int num6 = (int)BitConverterLE.ToUInt16(message, 40);
|
||||
this._username = Encoding.Unicode.GetString(message, num6, num5);
|
||||
this._lm = new byte[24];
|
||||
int num7 = (int)BitConverterLE.ToUInt16(message, 16);
|
||||
Buffer.BlockCopy(message, num7, this._lm, 0, 24);
|
||||
this._nt = new byte[24];
|
||||
int num8 = (int)BitConverterLE.ToUInt16(message, 24);
|
||||
Buffer.BlockCopy(message, num8, this._nt, 0, 24);
|
||||
if (message.Length >= 64)
|
||||
{
|
||||
base.Flags = (NtlmFlags)BitConverterLE.ToUInt32(message, 60);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600046E RID: 1134 RVA: 0x0001BFD0 File Offset: 0x0001A1D0
|
||||
public override byte[] GetBytes()
|
||||
{
|
||||
byte[] bytes = Encoding.Unicode.GetBytes(this._domain.ToUpper(CultureInfo.InvariantCulture));
|
||||
byte[] bytes2 = Encoding.Unicode.GetBytes(this._username);
|
||||
byte[] bytes3 = Encoding.Unicode.GetBytes(this._host.ToUpper(CultureInfo.InvariantCulture));
|
||||
byte[] array = base.PrepareMessage(64 + bytes.Length + bytes2.Length + bytes3.Length + 24 + 24);
|
||||
short num = (short)(64 + bytes.Length + bytes2.Length + bytes3.Length);
|
||||
array[12] = 24;
|
||||
array[13] = 0;
|
||||
array[14] = 24;
|
||||
array[15] = 0;
|
||||
array[16] = (byte)num;
|
||||
array[17] = (byte)(num >> 8);
|
||||
short num2 = num + 24;
|
||||
array[20] = 24;
|
||||
array[21] = 0;
|
||||
array[22] = 24;
|
||||
array[23] = 0;
|
||||
array[24] = (byte)num2;
|
||||
array[25] = (byte)(num2 >> 8);
|
||||
short num3 = (short)bytes.Length;
|
||||
short num4 = 64;
|
||||
array[28] = (byte)num3;
|
||||
array[29] = (byte)(num3 >> 8);
|
||||
array[30] = array[28];
|
||||
array[31] = array[29];
|
||||
array[32] = (byte)num4;
|
||||
array[33] = (byte)(num4 >> 8);
|
||||
short num5 = (short)bytes2.Length;
|
||||
short num6 = num4 + num3;
|
||||
array[36] = (byte)num5;
|
||||
array[37] = (byte)(num5 >> 8);
|
||||
array[38] = array[36];
|
||||
array[39] = array[37];
|
||||
array[40] = (byte)num6;
|
||||
array[41] = (byte)(num6 >> 8);
|
||||
short num7 = (short)bytes3.Length;
|
||||
short num8 = num6 + num5;
|
||||
array[44] = (byte)num7;
|
||||
array[45] = (byte)(num7 >> 8);
|
||||
array[46] = array[44];
|
||||
array[47] = array[45];
|
||||
array[48] = (byte)num8;
|
||||
array[49] = (byte)(num8 >> 8);
|
||||
short num9 = (short)array.Length;
|
||||
array[56] = (byte)num9;
|
||||
array[57] = (byte)(num9 >> 8);
|
||||
array[60] = (byte)base.Flags;
|
||||
array[61] = (byte)(base.Flags >> 8);
|
||||
array[62] = (byte)(base.Flags >> 16);
|
||||
array[63] = (byte)(base.Flags >> 24);
|
||||
Buffer.BlockCopy(bytes, 0, array, (int)num4, bytes.Length);
|
||||
Buffer.BlockCopy(bytes2, 0, array, (int)num6, bytes2.Length);
|
||||
Buffer.BlockCopy(bytes3, 0, array, (int)num8, bytes3.Length);
|
||||
using (ChallengeResponse challengeResponse = new ChallengeResponse(this._password, this._challenge))
|
||||
{
|
||||
Buffer.BlockCopy(challengeResponse.LM, 0, array, (int)num, 24);
|
||||
Buffer.BlockCopy(challengeResponse.NT, 0, array, (int)num2, 24);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0400020F RID: 527
|
||||
private byte[] _challenge;
|
||||
|
||||
// Token: 0x04000210 RID: 528
|
||||
private string _host;
|
||||
|
||||
// Token: 0x04000211 RID: 529
|
||||
private string _domain;
|
||||
|
||||
// Token: 0x04000212 RID: 530
|
||||
private string _username;
|
||||
|
||||
// Token: 0x04000213 RID: 531
|
||||
private string _password;
|
||||
|
||||
// Token: 0x04000214 RID: 532
|
||||
private byte[] _lm;
|
||||
|
||||
// Token: 0x04000215 RID: 533
|
||||
private byte[] _nt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200007E RID: 126
|
||||
internal class Alert
|
||||
{
|
||||
// Token: 0x0600046F RID: 1135 RVA: 0x0001C234 File Offset: 0x0001A434
|
||||
public Alert(AlertDescription description)
|
||||
{
|
||||
this.inferAlertLevel();
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
// Token: 0x06000470 RID: 1136 RVA: 0x0001C24C File Offset: 0x0001A44C
|
||||
public Alert(AlertLevel level, AlertDescription description)
|
||||
{
|
||||
this.level = level;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
// Token: 0x17000105 RID: 261
|
||||
// (get) Token: 0x06000471 RID: 1137 RVA: 0x0001C264 File Offset: 0x0001A464
|
||||
public AlertLevel Level
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000106 RID: 262
|
||||
// (get) Token: 0x06000472 RID: 1138 RVA: 0x0001C26C File Offset: 0x0001A46C
|
||||
public AlertDescription Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000107 RID: 263
|
||||
// (get) Token: 0x06000473 RID: 1139 RVA: 0x0001C274 File Offset: 0x0001A474
|
||||
public string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return Alert.GetAlertMessage(this.description);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000108 RID: 264
|
||||
// (get) Token: 0x06000474 RID: 1140 RVA: 0x0001C284 File Offset: 0x0001A484
|
||||
public bool IsWarning
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.level == AlertLevel.Warning;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000109 RID: 265
|
||||
// (get) Token: 0x06000475 RID: 1141 RVA: 0x0001C29C File Offset: 0x0001A49C
|
||||
public bool IsCloseNotify
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.IsWarning && this.description == AlertDescription.CloseNotify;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000476 RID: 1142 RVA: 0x0001C2B8 File Offset: 0x0001A4B8
|
||||
private void inferAlertLevel()
|
||||
{
|
||||
AlertDescription alertDescription = this.description;
|
||||
switch (alertDescription)
|
||||
{
|
||||
case AlertDescription.HandshakeFailiure:
|
||||
case AlertDescription.BadCertificate:
|
||||
case AlertDescription.UnsupportedCertificate:
|
||||
case AlertDescription.CertificateRevoked:
|
||||
case AlertDescription.CertificateExpired:
|
||||
case AlertDescription.CertificateUnknown:
|
||||
case AlertDescription.IlegalParameter:
|
||||
case AlertDescription.UnknownCA:
|
||||
case AlertDescription.AccessDenied:
|
||||
case AlertDescription.DecodeError:
|
||||
case AlertDescription.DecryptError:
|
||||
case AlertDescription.ExportRestriction:
|
||||
break;
|
||||
default:
|
||||
switch (alertDescription)
|
||||
{
|
||||
case AlertDescription.BadRecordMAC:
|
||||
case AlertDescription.DecryptionFailed:
|
||||
case AlertDescription.RecordOverflow:
|
||||
break;
|
||||
default:
|
||||
if (alertDescription != AlertDescription.ProtocolVersion && alertDescription != AlertDescription.InsuficientSecurity)
|
||||
{
|
||||
if (alertDescription != AlertDescription.CloseNotify)
|
||||
{
|
||||
if (alertDescription == AlertDescription.UnexpectedMessage || alertDescription == AlertDescription.DecompressionFailiure || alertDescription == AlertDescription.InternalError)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (alertDescription != AlertDescription.UserCancelled && alertDescription != AlertDescription.NoRenegotiation)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.level = AlertLevel.Warning;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.level = AlertLevel.Fatal;
|
||||
}
|
||||
|
||||
// Token: 0x06000477 RID: 1143 RVA: 0x0001C39C File Offset: 0x0001A59C
|
||||
public static string GetAlertMessage(AlertDescription description)
|
||||
{
|
||||
return "The authentication or decryption has failed.";
|
||||
}
|
||||
|
||||
// Token: 0x04000232 RID: 562
|
||||
private AlertLevel level;
|
||||
|
||||
// Token: 0x04000233 RID: 563
|
||||
private AlertDescription description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200007D RID: 125
|
||||
[Serializable]
|
||||
internal enum AlertDescription : byte
|
||||
{
|
||||
// Token: 0x0400021A RID: 538
|
||||
CloseNotify,
|
||||
// Token: 0x0400021B RID: 539
|
||||
UnexpectedMessage = 10,
|
||||
// Token: 0x0400021C RID: 540
|
||||
BadRecordMAC = 20,
|
||||
// Token: 0x0400021D RID: 541
|
||||
DecryptionFailed,
|
||||
// Token: 0x0400021E RID: 542
|
||||
RecordOverflow,
|
||||
// Token: 0x0400021F RID: 543
|
||||
DecompressionFailiure = 30,
|
||||
// Token: 0x04000220 RID: 544
|
||||
HandshakeFailiure = 40,
|
||||
// Token: 0x04000221 RID: 545
|
||||
NoCertificate,
|
||||
// Token: 0x04000222 RID: 546
|
||||
BadCertificate,
|
||||
// Token: 0x04000223 RID: 547
|
||||
UnsupportedCertificate,
|
||||
// Token: 0x04000224 RID: 548
|
||||
CertificateRevoked,
|
||||
// Token: 0x04000225 RID: 549
|
||||
CertificateExpired,
|
||||
// Token: 0x04000226 RID: 550
|
||||
CertificateUnknown,
|
||||
// Token: 0x04000227 RID: 551
|
||||
IlegalParameter,
|
||||
// Token: 0x04000228 RID: 552
|
||||
UnknownCA,
|
||||
// Token: 0x04000229 RID: 553
|
||||
AccessDenied,
|
||||
// Token: 0x0400022A RID: 554
|
||||
DecodeError,
|
||||
// Token: 0x0400022B RID: 555
|
||||
DecryptError,
|
||||
// Token: 0x0400022C RID: 556
|
||||
ExportRestriction = 60,
|
||||
// Token: 0x0400022D RID: 557
|
||||
ProtocolVersion = 70,
|
||||
// Token: 0x0400022E RID: 558
|
||||
InsuficientSecurity,
|
||||
// Token: 0x0400022F RID: 559
|
||||
InternalError = 80,
|
||||
// Token: 0x04000230 RID: 560
|
||||
UserCancelled = 90,
|
||||
// Token: 0x04000231 RID: 561
|
||||
NoRenegotiation = 100
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200007C RID: 124
|
||||
[Serializable]
|
||||
internal enum AlertLevel : byte
|
||||
{
|
||||
// Token: 0x04000217 RID: 535
|
||||
Warning = 1,
|
||||
// Token: 0x04000218 RID: 536
|
||||
Fatal
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000CD RID: 205
|
||||
// (Invoke) Token: 0x06000719 RID: 1817
|
||||
public delegate X509Certificate CertificateSelectionCallback(X509CertificateCollection clientCertificates, X509Certificate serverCertificate, string targetHost, X509CertificateCollection serverRequestedCertificates);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000CB RID: 203
|
||||
// (Invoke) Token: 0x06000711 RID: 1809
|
||||
public delegate bool CertificateValidationCallback(X509Certificate certificate, int[] certificateErrors);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000CC RID: 204
|
||||
// (Invoke) Token: 0x06000715 RID: 1813
|
||||
public delegate ValidationResult CertificateValidationCallback2(X509CertificateCollection collection);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200007F RID: 127
|
||||
[Serializable]
|
||||
public enum CipherAlgorithmType
|
||||
{
|
||||
// Token: 0x04000235 RID: 565
|
||||
Des,
|
||||
// Token: 0x04000236 RID: 566
|
||||
None,
|
||||
// Token: 0x04000237 RID: 567
|
||||
Rc2,
|
||||
// Token: 0x04000238 RID: 568
|
||||
Rc4,
|
||||
// Token: 0x04000239 RID: 569
|
||||
Rijndael,
|
||||
// Token: 0x0400023A RID: 570
|
||||
SkipJack,
|
||||
// Token: 0x0400023B RID: 571
|
||||
TripleDes
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000080 RID: 128
|
||||
internal abstract class CipherSuite
|
||||
{
|
||||
// Token: 0x06000478 RID: 1144 RVA: 0x0001C3A4 File Offset: 0x0001A5A4
|
||||
public CipherSuite(short code, string name, CipherAlgorithmType cipherAlgorithmType, HashAlgorithmType hashAlgorithmType, ExchangeAlgorithmType exchangeAlgorithmType, bool exportable, bool blockMode, byte keyMaterialSize, byte expandedKeyMaterialSize, short effectiveKeyBits, byte ivSize, byte blockSize)
|
||||
{
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.cipherAlgorithmType = cipherAlgorithmType;
|
||||
this.hashAlgorithmType = hashAlgorithmType;
|
||||
this.exchangeAlgorithmType = exchangeAlgorithmType;
|
||||
this.isExportable = exportable;
|
||||
if (blockMode)
|
||||
{
|
||||
this.cipherMode = CipherMode.CBC;
|
||||
}
|
||||
this.keyMaterialSize = keyMaterialSize;
|
||||
this.expandedKeyMaterialSize = expandedKeyMaterialSize;
|
||||
this.effectiveKeyBits = effectiveKeyBits;
|
||||
this.ivSize = ivSize;
|
||||
this.blockSize = blockSize;
|
||||
this.keyBlockSize = (int)this.keyMaterialSize + this.HashSize + (int)this.ivSize << 1;
|
||||
}
|
||||
|
||||
// Token: 0x1700010A RID: 266
|
||||
// (get) Token: 0x0600047A RID: 1146 RVA: 0x0001C448 File Offset: 0x0001A648
|
||||
protected ICryptoTransform EncryptionCipher
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.encryptionCipher;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010B RID: 267
|
||||
// (get) Token: 0x0600047B RID: 1147 RVA: 0x0001C450 File Offset: 0x0001A650
|
||||
protected ICryptoTransform DecryptionCipher
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.decryptionCipher;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010C RID: 268
|
||||
// (get) Token: 0x0600047C RID: 1148 RVA: 0x0001C458 File Offset: 0x0001A658
|
||||
protected KeyedHashAlgorithm ClientHMAC
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientHMAC;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010D RID: 269
|
||||
// (get) Token: 0x0600047D RID: 1149 RVA: 0x0001C460 File Offset: 0x0001A660
|
||||
protected KeyedHashAlgorithm ServerHMAC
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverHMAC;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010E RID: 270
|
||||
// (get) Token: 0x0600047E RID: 1150 RVA: 0x0001C468 File Offset: 0x0001A668
|
||||
public CipherAlgorithmType CipherAlgorithmType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherAlgorithmType;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700010F RID: 271
|
||||
// (get) Token: 0x0600047F RID: 1151 RVA: 0x0001C470 File Offset: 0x0001A670
|
||||
public string HashAlgorithmName
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (this.hashAlgorithmType)
|
||||
{
|
||||
case HashAlgorithmType.Md5:
|
||||
return "MD5";
|
||||
case HashAlgorithmType.Sha1:
|
||||
return "SHA1";
|
||||
}
|
||||
return "None";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000110 RID: 272
|
||||
// (get) Token: 0x06000480 RID: 1152 RVA: 0x0001C4AC File Offset: 0x0001A6AC
|
||||
public HashAlgorithmType HashAlgorithmType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.hashAlgorithmType;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000111 RID: 273
|
||||
// (get) Token: 0x06000481 RID: 1153 RVA: 0x0001C4B4 File Offset: 0x0001A6B4
|
||||
public int HashSize
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (this.hashAlgorithmType)
|
||||
{
|
||||
case HashAlgorithmType.Md5:
|
||||
return 16;
|
||||
case HashAlgorithmType.Sha1:
|
||||
return 20;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000112 RID: 274
|
||||
// (get) Token: 0x06000482 RID: 1154 RVA: 0x0001C4E8 File Offset: 0x0001A6E8
|
||||
public ExchangeAlgorithmType ExchangeAlgorithmType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.exchangeAlgorithmType;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000113 RID: 275
|
||||
// (get) Token: 0x06000483 RID: 1155 RVA: 0x0001C4F0 File Offset: 0x0001A6F0
|
||||
public CipherMode CipherMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherMode;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000114 RID: 276
|
||||
// (get) Token: 0x06000484 RID: 1156 RVA: 0x0001C4F8 File Offset: 0x0001A6F8
|
||||
public short Code
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.code;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000115 RID: 277
|
||||
// (get) Token: 0x06000485 RID: 1157 RVA: 0x0001C500 File Offset: 0x0001A700
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000116 RID: 278
|
||||
// (get) Token: 0x06000486 RID: 1158 RVA: 0x0001C508 File Offset: 0x0001A708
|
||||
public bool IsExportable
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isExportable;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000117 RID: 279
|
||||
// (get) Token: 0x06000487 RID: 1159 RVA: 0x0001C510 File Offset: 0x0001A710
|
||||
public byte KeyMaterialSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.keyMaterialSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000118 RID: 280
|
||||
// (get) Token: 0x06000488 RID: 1160 RVA: 0x0001C518 File Offset: 0x0001A718
|
||||
public int KeyBlockSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.keyBlockSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000119 RID: 281
|
||||
// (get) Token: 0x06000489 RID: 1161 RVA: 0x0001C520 File Offset: 0x0001A720
|
||||
public byte ExpandedKeyMaterialSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.expandedKeyMaterialSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011A RID: 282
|
||||
// (get) Token: 0x0600048A RID: 1162 RVA: 0x0001C528 File Offset: 0x0001A728
|
||||
public short EffectiveKeyBits
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.effectiveKeyBits;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011B RID: 283
|
||||
// (get) Token: 0x0600048B RID: 1163 RVA: 0x0001C530 File Offset: 0x0001A730
|
||||
public byte IvSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ivSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011C RID: 284
|
||||
// (get) Token: 0x0600048C RID: 1164 RVA: 0x0001C538 File Offset: 0x0001A738
|
||||
// (set) Token: 0x0600048D RID: 1165 RVA: 0x0001C540 File Offset: 0x0001A740
|
||||
public Context Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.context;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.context = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600048E RID: 1166 RVA: 0x0001C54C File Offset: 0x0001A74C
|
||||
internal void Write(byte[] array, int offset, short value)
|
||||
{
|
||||
if (offset > array.Length - 2)
|
||||
{
|
||||
throw new ArgumentException("offset");
|
||||
}
|
||||
array[offset] = (byte)(value >> 8);
|
||||
array[offset + 1] = (byte)value;
|
||||
}
|
||||
|
||||
// Token: 0x0600048F RID: 1167 RVA: 0x0001C580 File Offset: 0x0001A780
|
||||
internal void Write(byte[] array, int offset, ulong value)
|
||||
{
|
||||
if (offset > array.Length - 8)
|
||||
{
|
||||
throw new ArgumentException("offset");
|
||||
}
|
||||
array[offset] = (byte)(value >> 56);
|
||||
array[offset + 1] = (byte)(value >> 48);
|
||||
array[offset + 2] = (byte)(value >> 40);
|
||||
array[offset + 3] = (byte)(value >> 32);
|
||||
array[offset + 4] = (byte)(value >> 24);
|
||||
array[offset + 5] = (byte)(value >> 16);
|
||||
array[offset + 6] = (byte)(value >> 8);
|
||||
array[offset + 7] = (byte)value;
|
||||
}
|
||||
|
||||
// Token: 0x06000490 RID: 1168 RVA: 0x0001C5F0 File Offset: 0x0001A7F0
|
||||
public void InitializeCipher()
|
||||
{
|
||||
this.createEncryptionCipher();
|
||||
this.createDecryptionCipher();
|
||||
}
|
||||
|
||||
// Token: 0x06000491 RID: 1169 RVA: 0x0001C600 File Offset: 0x0001A800
|
||||
public byte[] EncryptRecord(byte[] fragment, byte[] mac)
|
||||
{
|
||||
int num = fragment.Length + mac.Length;
|
||||
int num2 = 0;
|
||||
if (this.CipherMode == CipherMode.CBC)
|
||||
{
|
||||
num++;
|
||||
num2 = (int)this.blockSize - num % (int)this.blockSize;
|
||||
if (num2 == (int)this.blockSize)
|
||||
{
|
||||
num2 = 0;
|
||||
}
|
||||
num += num2;
|
||||
}
|
||||
byte[] array = new byte[num];
|
||||
Buffer.BlockCopy(fragment, 0, array, 0, fragment.Length);
|
||||
Buffer.BlockCopy(mac, 0, array, fragment.Length, mac.Length);
|
||||
if (num2 > 0)
|
||||
{
|
||||
int num3 = fragment.Length + mac.Length;
|
||||
for (int i = num3; i < num3 + num2 + 1; i++)
|
||||
{
|
||||
array[i] = (byte)num2;
|
||||
}
|
||||
}
|
||||
this.EncryptionCipher.TransformBlock(array, 0, array.Length, array, 0);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000492 RID: 1170 RVA: 0x0001C6B0 File Offset: 0x0001A8B0
|
||||
public void DecryptRecord(byte[] fragment, out byte[] dcrFragment, out byte[] dcrMAC)
|
||||
{
|
||||
this.DecryptionCipher.TransformBlock(fragment, 0, fragment.Length, fragment, 0);
|
||||
int num2;
|
||||
if (this.CipherMode == CipherMode.CBC)
|
||||
{
|
||||
int num = (int)fragment[fragment.Length - 1];
|
||||
num2 = fragment.Length - (num + 1) - this.HashSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = fragment.Length - this.HashSize;
|
||||
}
|
||||
dcrFragment = new byte[num2];
|
||||
dcrMAC = new byte[this.HashSize];
|
||||
Buffer.BlockCopy(fragment, 0, dcrFragment, 0, dcrFragment.Length);
|
||||
Buffer.BlockCopy(fragment, dcrFragment.Length, dcrMAC, 0, dcrMAC.Length);
|
||||
}
|
||||
|
||||
// Token: 0x06000493 RID: 1171
|
||||
public abstract byte[] ComputeClientRecordMAC(ContentType contentType, byte[] fragment);
|
||||
|
||||
// Token: 0x06000494 RID: 1172
|
||||
public abstract byte[] ComputeServerRecordMAC(ContentType contentType, byte[] fragment);
|
||||
|
||||
// Token: 0x06000495 RID: 1173
|
||||
public abstract void ComputeMasterSecret(byte[] preMasterSecret);
|
||||
|
||||
// Token: 0x06000496 RID: 1174
|
||||
public abstract void ComputeKeys();
|
||||
|
||||
// Token: 0x06000497 RID: 1175 RVA: 0x0001C73C File Offset: 0x0001A93C
|
||||
public byte[] CreatePremasterSecret()
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)this.context;
|
||||
byte[] secureRandomBytes = this.context.GetSecureRandomBytes(48);
|
||||
secureRandomBytes[0] = (byte)(clientContext.ClientHelloProtocol >> 8);
|
||||
secureRandomBytes[1] = (byte)clientContext.ClientHelloProtocol;
|
||||
return secureRandomBytes;
|
||||
}
|
||||
|
||||
// Token: 0x06000498 RID: 1176 RVA: 0x0001C77C File Offset: 0x0001A97C
|
||||
public byte[] PRF(byte[] secret, string label, byte[] data, int length)
|
||||
{
|
||||
int num = secret.Length >> 1;
|
||||
if ((secret.Length & 1) == 1)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(Encoding.ASCII.GetBytes(label));
|
||||
tlsStream.Write(data);
|
||||
byte[] array = tlsStream.ToArray();
|
||||
tlsStream.Reset();
|
||||
byte[] array2 = new byte[num];
|
||||
Buffer.BlockCopy(secret, 0, array2, 0, num);
|
||||
byte[] array3 = new byte[num];
|
||||
Buffer.BlockCopy(secret, secret.Length - num, array3, 0, num);
|
||||
byte[] array4 = this.Expand("MD5", array2, array, length);
|
||||
byte[] array5 = this.Expand("SHA1", array3, array, length);
|
||||
byte[] array6 = new byte[length];
|
||||
for (int i = 0; i < array6.Length; i++)
|
||||
{
|
||||
array6[i] = array4[i] ^ array5[i];
|
||||
}
|
||||
return array6;
|
||||
}
|
||||
|
||||
// Token: 0x06000499 RID: 1177 RVA: 0x0001C84C File Offset: 0x0001AA4C
|
||||
public byte[] Expand(string hashName, byte[] secret, byte[] seed, int length)
|
||||
{
|
||||
int num = ((!(hashName == "MD5")) ? 20 : 16);
|
||||
int num2 = length / num;
|
||||
if (length % num > 0)
|
||||
{
|
||||
num2++;
|
||||
}
|
||||
Mono.Security.Cryptography.HMAC hmac = new Mono.Security.Cryptography.HMAC(hashName, secret);
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
byte[][] array = new byte[num2 + 1][];
|
||||
array[0] = seed;
|
||||
for (int i = 1; i <= num2; i++)
|
||||
{
|
||||
TlsStream tlsStream2 = new TlsStream();
|
||||
hmac.TransformFinalBlock(array[i - 1], 0, array[i - 1].Length);
|
||||
array[i] = hmac.Hash;
|
||||
tlsStream2.Write(array[i]);
|
||||
tlsStream2.Write(seed);
|
||||
hmac.TransformFinalBlock(tlsStream2.ToArray(), 0, (int)tlsStream2.Length);
|
||||
tlsStream.Write(hmac.Hash);
|
||||
tlsStream2.Reset();
|
||||
}
|
||||
byte[] array2 = new byte[length];
|
||||
Buffer.BlockCopy(tlsStream.ToArray(), 0, array2, 0, array2.Length);
|
||||
tlsStream.Reset();
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x0600049A RID: 1178 RVA: 0x0001C948 File Offset: 0x0001AB48
|
||||
private void createEncryptionCipher()
|
||||
{
|
||||
switch (this.cipherAlgorithmType)
|
||||
{
|
||||
case CipherAlgorithmType.Des:
|
||||
this.encryptionAlgorithm = DES.Create();
|
||||
break;
|
||||
case CipherAlgorithmType.Rc2:
|
||||
this.encryptionAlgorithm = RC2.Create();
|
||||
break;
|
||||
case CipherAlgorithmType.Rc4:
|
||||
this.encryptionAlgorithm = new ARC4Managed();
|
||||
break;
|
||||
case CipherAlgorithmType.Rijndael:
|
||||
this.encryptionAlgorithm = Rijndael.Create();
|
||||
break;
|
||||
case CipherAlgorithmType.TripleDes:
|
||||
this.encryptionAlgorithm = TripleDES.Create();
|
||||
break;
|
||||
}
|
||||
if (this.cipherMode == CipherMode.CBC)
|
||||
{
|
||||
this.encryptionAlgorithm.Mode = this.cipherMode;
|
||||
this.encryptionAlgorithm.Padding = PaddingMode.None;
|
||||
this.encryptionAlgorithm.KeySize = (int)(this.expandedKeyMaterialSize * 8);
|
||||
this.encryptionAlgorithm.BlockSize = (int)(this.blockSize * 8);
|
||||
}
|
||||
if (this.context is ClientContext)
|
||||
{
|
||||
this.encryptionAlgorithm.Key = this.context.ClientWriteKey;
|
||||
this.encryptionAlgorithm.IV = this.context.ClientWriteIV;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.encryptionAlgorithm.Key = this.context.ServerWriteKey;
|
||||
this.encryptionAlgorithm.IV = this.context.ServerWriteIV;
|
||||
}
|
||||
this.encryptionCipher = this.encryptionAlgorithm.CreateEncryptor();
|
||||
if (this.context is ClientContext)
|
||||
{
|
||||
this.clientHMAC = new Mono.Security.Cryptography.HMAC(this.HashAlgorithmName, this.context.Negotiating.ClientWriteMAC);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.serverHMAC = new Mono.Security.Cryptography.HMAC(this.HashAlgorithmName, this.context.Negotiating.ServerWriteMAC);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600049B RID: 1179 RVA: 0x0001CAF8 File Offset: 0x0001ACF8
|
||||
private void createDecryptionCipher()
|
||||
{
|
||||
switch (this.cipherAlgorithmType)
|
||||
{
|
||||
case CipherAlgorithmType.Des:
|
||||
this.decryptionAlgorithm = DES.Create();
|
||||
break;
|
||||
case CipherAlgorithmType.Rc2:
|
||||
this.decryptionAlgorithm = RC2.Create();
|
||||
break;
|
||||
case CipherAlgorithmType.Rc4:
|
||||
this.decryptionAlgorithm = new ARC4Managed();
|
||||
break;
|
||||
case CipherAlgorithmType.Rijndael:
|
||||
this.decryptionAlgorithm = Rijndael.Create();
|
||||
break;
|
||||
case CipherAlgorithmType.TripleDes:
|
||||
this.decryptionAlgorithm = TripleDES.Create();
|
||||
break;
|
||||
}
|
||||
if (this.cipherMode == CipherMode.CBC)
|
||||
{
|
||||
this.decryptionAlgorithm.Mode = this.cipherMode;
|
||||
this.decryptionAlgorithm.Padding = PaddingMode.None;
|
||||
this.decryptionAlgorithm.KeySize = (int)(this.expandedKeyMaterialSize * 8);
|
||||
this.decryptionAlgorithm.BlockSize = (int)(this.blockSize * 8);
|
||||
}
|
||||
if (this.context is ClientContext)
|
||||
{
|
||||
this.decryptionAlgorithm.Key = this.context.ServerWriteKey;
|
||||
this.decryptionAlgorithm.IV = this.context.ServerWriteIV;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.decryptionAlgorithm.Key = this.context.ClientWriteKey;
|
||||
this.decryptionAlgorithm.IV = this.context.ClientWriteIV;
|
||||
}
|
||||
this.decryptionCipher = this.decryptionAlgorithm.CreateDecryptor();
|
||||
if (this.context is ClientContext)
|
||||
{
|
||||
this.serverHMAC = new Mono.Security.Cryptography.HMAC(this.HashAlgorithmName, this.context.Negotiating.ServerWriteMAC);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clientHMAC = new Mono.Security.Cryptography.HMAC(this.HashAlgorithmName, this.context.Negotiating.ClientWriteMAC);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400023C RID: 572
|
||||
public static byte[] EmptyArray = new byte[0];
|
||||
|
||||
// Token: 0x0400023D RID: 573
|
||||
private short code;
|
||||
|
||||
// Token: 0x0400023E RID: 574
|
||||
private string name;
|
||||
|
||||
// Token: 0x0400023F RID: 575
|
||||
private CipherAlgorithmType cipherAlgorithmType;
|
||||
|
||||
// Token: 0x04000240 RID: 576
|
||||
private HashAlgorithmType hashAlgorithmType;
|
||||
|
||||
// Token: 0x04000241 RID: 577
|
||||
private ExchangeAlgorithmType exchangeAlgorithmType;
|
||||
|
||||
// Token: 0x04000242 RID: 578
|
||||
private bool isExportable;
|
||||
|
||||
// Token: 0x04000243 RID: 579
|
||||
private CipherMode cipherMode;
|
||||
|
||||
// Token: 0x04000244 RID: 580
|
||||
private byte keyMaterialSize;
|
||||
|
||||
// Token: 0x04000245 RID: 581
|
||||
private int keyBlockSize;
|
||||
|
||||
// Token: 0x04000246 RID: 582
|
||||
private byte expandedKeyMaterialSize;
|
||||
|
||||
// Token: 0x04000247 RID: 583
|
||||
private short effectiveKeyBits;
|
||||
|
||||
// Token: 0x04000248 RID: 584
|
||||
private byte ivSize;
|
||||
|
||||
// Token: 0x04000249 RID: 585
|
||||
private byte blockSize;
|
||||
|
||||
// Token: 0x0400024A RID: 586
|
||||
private Context context;
|
||||
|
||||
// Token: 0x0400024B RID: 587
|
||||
private SymmetricAlgorithm encryptionAlgorithm;
|
||||
|
||||
// Token: 0x0400024C RID: 588
|
||||
private ICryptoTransform encryptionCipher;
|
||||
|
||||
// Token: 0x0400024D RID: 589
|
||||
private SymmetricAlgorithm decryptionAlgorithm;
|
||||
|
||||
// Token: 0x0400024E RID: 590
|
||||
private ICryptoTransform decryptionCipher;
|
||||
|
||||
// Token: 0x0400024F RID: 591
|
||||
private KeyedHashAlgorithm clientHMAC;
|
||||
|
||||
// Token: 0x04000250 RID: 592
|
||||
private KeyedHashAlgorithm serverHMAC;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000081 RID: 129
|
||||
internal sealed class CipherSuiteCollection : IEnumerable, ICollection, IList
|
||||
{
|
||||
// Token: 0x0600049C RID: 1180 RVA: 0x0001CCA8 File Offset: 0x0001AEA8
|
||||
public CipherSuiteCollection(SecurityProtocolType protocol)
|
||||
{
|
||||
this.protocol = protocol;
|
||||
this.cipherSuites = new ArrayList();
|
||||
}
|
||||
|
||||
// Token: 0x1700011D RID: 285
|
||||
object IList.this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
this[index] = (CipherSuite)value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011E RID: 286
|
||||
// (get) Token: 0x0600049F RID: 1183 RVA: 0x0001CCE0 File Offset: 0x0001AEE0
|
||||
bool ICollection.IsSynchronized
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherSuites.IsSynchronized;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011F RID: 287
|
||||
// (get) Token: 0x060004A0 RID: 1184 RVA: 0x0001CCF0 File Offset: 0x0001AEF0
|
||||
object ICollection.SyncRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherSuites.SyncRoot;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004A1 RID: 1185 RVA: 0x0001CD00 File Offset: 0x0001AF00
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.cipherSuites.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x060004A2 RID: 1186 RVA: 0x0001CD10 File Offset: 0x0001AF10
|
||||
bool IList.Contains(object value)
|
||||
{
|
||||
return this.cipherSuites.Contains(value as CipherSuite);
|
||||
}
|
||||
|
||||
// Token: 0x060004A3 RID: 1187 RVA: 0x0001CD24 File Offset: 0x0001AF24
|
||||
int IList.IndexOf(object value)
|
||||
{
|
||||
return this.cipherSuites.IndexOf(value as CipherSuite);
|
||||
}
|
||||
|
||||
// Token: 0x060004A4 RID: 1188 RVA: 0x0001CD38 File Offset: 0x0001AF38
|
||||
void IList.Insert(int index, object value)
|
||||
{
|
||||
this.cipherSuites.Insert(index, value as CipherSuite);
|
||||
}
|
||||
|
||||
// Token: 0x060004A5 RID: 1189 RVA: 0x0001CD4C File Offset: 0x0001AF4C
|
||||
void IList.Remove(object value)
|
||||
{
|
||||
this.cipherSuites.Remove(value as CipherSuite);
|
||||
}
|
||||
|
||||
// Token: 0x060004A6 RID: 1190 RVA: 0x0001CD60 File Offset: 0x0001AF60
|
||||
void IList.RemoveAt(int index)
|
||||
{
|
||||
this.cipherSuites.RemoveAt(index);
|
||||
}
|
||||
|
||||
// Token: 0x060004A7 RID: 1191 RVA: 0x0001CD70 File Offset: 0x0001AF70
|
||||
int IList.Add(object value)
|
||||
{
|
||||
return this.cipherSuites.Add(value as CipherSuite);
|
||||
}
|
||||
|
||||
// Token: 0x17000120 RID: 288
|
||||
public CipherSuite this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CipherSuite)this.cipherSuites[this.IndexOf(name)];
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cipherSuites[this.IndexOf(name)] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000121 RID: 289
|
||||
public CipherSuite this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CipherSuite)this.cipherSuites[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cipherSuites[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000122 RID: 290
|
||||
public CipherSuite this[short code]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CipherSuite)this.cipherSuites[this.IndexOf(code)];
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cipherSuites[this.IndexOf(code)] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000123 RID: 291
|
||||
// (get) Token: 0x060004AE RID: 1198 RVA: 0x0001CE10 File Offset: 0x0001B010
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherSuites.Count;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000124 RID: 292
|
||||
// (get) Token: 0x060004AF RID: 1199 RVA: 0x0001CE20 File Offset: 0x0001B020
|
||||
public bool IsFixedSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherSuites.IsFixedSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000125 RID: 293
|
||||
// (get) Token: 0x060004B0 RID: 1200 RVA: 0x0001CE30 File Offset: 0x0001B030
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipherSuites.IsReadOnly;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004B1 RID: 1201 RVA: 0x0001CE40 File Offset: 0x0001B040
|
||||
public void CopyTo(Array array, int index)
|
||||
{
|
||||
this.cipherSuites.CopyTo(array, index);
|
||||
}
|
||||
|
||||
// Token: 0x060004B2 RID: 1202 RVA: 0x0001CE50 File Offset: 0x0001B050
|
||||
public void Clear()
|
||||
{
|
||||
this.cipherSuites.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x060004B3 RID: 1203 RVA: 0x0001CE60 File Offset: 0x0001B060
|
||||
public int IndexOf(string name)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (object obj in this.cipherSuites)
|
||||
{
|
||||
CipherSuite cipherSuite = (CipherSuite)obj;
|
||||
if (this.cultureAwareCompare(cipherSuite.Name, name))
|
||||
{
|
||||
return num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x060004B4 RID: 1204 RVA: 0x0001CEF0 File Offset: 0x0001B0F0
|
||||
public int IndexOf(short code)
|
||||
{
|
||||
int num = 0;
|
||||
foreach (object obj in this.cipherSuites)
|
||||
{
|
||||
CipherSuite cipherSuite = (CipherSuite)obj;
|
||||
if (cipherSuite.Code == code)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Token: 0x060004B5 RID: 1205 RVA: 0x0001CF78 File Offset: 0x0001B178
|
||||
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)
|
||||
{
|
||||
SecurityProtocolType securityProtocolType = this.protocol;
|
||||
if (securityProtocolType != SecurityProtocolType.Default)
|
||||
{
|
||||
if (securityProtocolType != SecurityProtocolType.Ssl2)
|
||||
{
|
||||
if (securityProtocolType == SecurityProtocolType.Ssl3)
|
||||
{
|
||||
return this.add(new SslCipherSuite(code, name, cipherType, hashType, exchangeType, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize));
|
||||
}
|
||||
if (securityProtocolType == SecurityProtocolType.Tls)
|
||||
{
|
||||
goto IL_32;
|
||||
}
|
||||
}
|
||||
throw new NotSupportedException("Unsupported security protocol type.");
|
||||
}
|
||||
IL_32:
|
||||
return this.add(new TlsCipherSuite(code, name, cipherType, hashType, exchangeType, exportable, blockMode, keyMaterialSize, expandedKeyMaterialSize, effectiveKeyBytes, ivSize, blockSize));
|
||||
}
|
||||
|
||||
// Token: 0x060004B6 RID: 1206 RVA: 0x0001D004 File Offset: 0x0001B204
|
||||
private TlsCipherSuite add(TlsCipherSuite cipherSuite)
|
||||
{
|
||||
this.cipherSuites.Add(cipherSuite);
|
||||
return cipherSuite;
|
||||
}
|
||||
|
||||
// Token: 0x060004B7 RID: 1207 RVA: 0x0001D014 File Offset: 0x0001B214
|
||||
private SslCipherSuite add(SslCipherSuite cipherSuite)
|
||||
{
|
||||
this.cipherSuites.Add(cipherSuite);
|
||||
return cipherSuite;
|
||||
}
|
||||
|
||||
// Token: 0x060004B8 RID: 1208 RVA: 0x0001D024 File Offset: 0x0001B224
|
||||
private bool cultureAwareCompare(string strA, string strB)
|
||||
{
|
||||
return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, strB, CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0;
|
||||
}
|
||||
|
||||
// Token: 0x04000251 RID: 593
|
||||
private ArrayList cipherSuites;
|
||||
|
||||
// Token: 0x04000252 RID: 594
|
||||
private SecurityProtocolType protocol;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000082 RID: 130
|
||||
internal class CipherSuiteFactory
|
||||
{
|
||||
// Token: 0x060004BA RID: 1210 RVA: 0x0001D050 File Offset: 0x0001B250
|
||||
public static CipherSuiteCollection GetSupportedCiphers(SecurityProtocolType protocol)
|
||||
{
|
||||
if (protocol != SecurityProtocolType.Default)
|
||||
{
|
||||
if (protocol != SecurityProtocolType.Ssl2)
|
||||
{
|
||||
if (protocol == SecurityProtocolType.Ssl3)
|
||||
{
|
||||
return CipherSuiteFactory.GetSsl3SupportedCiphers();
|
||||
}
|
||||
if (protocol == SecurityProtocolType.Tls)
|
||||
{
|
||||
goto IL_2D;
|
||||
}
|
||||
}
|
||||
throw new NotSupportedException("Unsupported security protocol type");
|
||||
}
|
||||
IL_2D:
|
||||
return CipherSuiteFactory.GetTls1SupportedCiphers();
|
||||
}
|
||||
|
||||
// Token: 0x060004BB RID: 1211 RVA: 0x0001D0A0 File Offset: 0x0001B2A0
|
||||
private static CipherSuiteCollection GetTls1SupportedCiphers()
|
||||
{
|
||||
return new CipherSuiteCollection(SecurityProtocolType.Tls)
|
||||
{
|
||||
{
|
||||
53,
|
||||
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
||||
CipherAlgorithmType.Rijndael,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
32,
|
||||
32,
|
||||
256,
|
||||
16,
|
||||
16
|
||||
},
|
||||
{
|
||||
47,
|
||||
"TLS_RSA_WITH_AES_128_CBC_SHA",
|
||||
CipherAlgorithmType.Rijndael,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
16,
|
||||
16,
|
||||
128,
|
||||
16,
|
||||
16
|
||||
},
|
||||
{
|
||||
10,
|
||||
"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
|
||||
CipherAlgorithmType.TripleDes,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
24,
|
||||
24,
|
||||
168,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
5,
|
||||
"TLS_RSA_WITH_RC4_128_SHA",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
false,
|
||||
16,
|
||||
16,
|
||||
128,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
4,
|
||||
"TLS_RSA_WITH_RC4_128_MD5",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
false,
|
||||
16,
|
||||
16,
|
||||
128,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
9,
|
||||
"TLS_RSA_WITH_DES_CBC_SHA",
|
||||
CipherAlgorithmType.Des,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
8,
|
||||
8,
|
||||
56,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
3,
|
||||
"TLS_RSA_EXPORT_WITH_RC4_40_MD5",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
false,
|
||||
5,
|
||||
16,
|
||||
40,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
6,
|
||||
"TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5",
|
||||
CipherAlgorithmType.Rc2,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
5,
|
||||
16,
|
||||
40,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
8,
|
||||
"TLS_RSA_EXPORT_WITH_DES40_CBC_SHA",
|
||||
CipherAlgorithmType.Des,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
5,
|
||||
8,
|
||||
40,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
96,
|
||||
"TLS_RSA_EXPORT_WITH_RC4_56_MD5",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
false,
|
||||
7,
|
||||
16,
|
||||
56,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
97,
|
||||
"TLS_RSA_EXPORT_WITH_RC2_CBC_56_MD5",
|
||||
CipherAlgorithmType.Rc2,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
7,
|
||||
16,
|
||||
56,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
98,
|
||||
"TLS_RSA_EXPORT_WITH_DES_CBC_56_SHA",
|
||||
CipherAlgorithmType.Des,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
8,
|
||||
8,
|
||||
64,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
100,
|
||||
"TLS_RSA_EXPORT_WITH_RC4_56_SHA",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
false,
|
||||
7,
|
||||
16,
|
||||
56,
|
||||
0,
|
||||
0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x060004BC RID: 1212 RVA: 0x0001D21C File Offset: 0x0001B41C
|
||||
private static CipherSuiteCollection GetSsl3SupportedCiphers()
|
||||
{
|
||||
return new CipherSuiteCollection(SecurityProtocolType.Ssl3)
|
||||
{
|
||||
{
|
||||
53,
|
||||
"SSL_RSA_WITH_AES_256_CBC_SHA",
|
||||
CipherAlgorithmType.Rijndael,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
32,
|
||||
32,
|
||||
256,
|
||||
16,
|
||||
16
|
||||
},
|
||||
{
|
||||
10,
|
||||
"SSL_RSA_WITH_3DES_EDE_CBC_SHA",
|
||||
CipherAlgorithmType.TripleDes,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
24,
|
||||
24,
|
||||
168,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
5,
|
||||
"SSL_RSA_WITH_RC4_128_SHA",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
false,
|
||||
16,
|
||||
16,
|
||||
128,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
4,
|
||||
"SSL_RSA_WITH_RC4_128_MD5",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
false,
|
||||
16,
|
||||
16,
|
||||
128,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
9,
|
||||
"SSL_RSA_WITH_DES_CBC_SHA",
|
||||
CipherAlgorithmType.Des,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
false,
|
||||
true,
|
||||
8,
|
||||
8,
|
||||
56,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
3,
|
||||
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
false,
|
||||
5,
|
||||
16,
|
||||
40,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
6,
|
||||
"SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5",
|
||||
CipherAlgorithmType.Rc2,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
5,
|
||||
16,
|
||||
40,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
8,
|
||||
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
|
||||
CipherAlgorithmType.Des,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
5,
|
||||
8,
|
||||
40,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
96,
|
||||
"SSL_RSA_EXPORT_WITH_RC4_56_MD5",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
false,
|
||||
7,
|
||||
16,
|
||||
56,
|
||||
0,
|
||||
0
|
||||
},
|
||||
{
|
||||
97,
|
||||
"SSL_RSA_EXPORT_WITH_RC2_CBC_56_MD5",
|
||||
CipherAlgorithmType.Rc2,
|
||||
HashAlgorithmType.Md5,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
7,
|
||||
16,
|
||||
56,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
98,
|
||||
"SSL_RSA_EXPORT_WITH_DES_CBC_56_SHA",
|
||||
CipherAlgorithmType.Des,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
true,
|
||||
8,
|
||||
8,
|
||||
64,
|
||||
8,
|
||||
8
|
||||
},
|
||||
{
|
||||
100,
|
||||
"SSL_RSA_EXPORT_WITH_RC4_56_SHA",
|
||||
CipherAlgorithmType.Rc4,
|
||||
HashAlgorithmType.Sha1,
|
||||
ExchangeAlgorithmType.RsaKeyX,
|
||||
true,
|
||||
false,
|
||||
7,
|
||||
16,
|
||||
56,
|
||||
0,
|
||||
0
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000083 RID: 131
|
||||
internal class ClientContext : Context
|
||||
{
|
||||
// Token: 0x060004BD RID: 1213 RVA: 0x0001D374 File Offset: 0x0001B574
|
||||
public ClientContext(SslClientStream stream, SecurityProtocolType securityProtocolType, string targetHost, X509CertificateCollection clientCertificates)
|
||||
: base(securityProtocolType)
|
||||
{
|
||||
this.sslStream = stream;
|
||||
base.ClientSettings.Certificates = clientCertificates;
|
||||
base.ClientSettings.TargetHost = targetHost;
|
||||
}
|
||||
|
||||
// Token: 0x17000126 RID: 294
|
||||
// (get) Token: 0x060004BE RID: 1214 RVA: 0x0001D3A8 File Offset: 0x0001B5A8
|
||||
public SslClientStream SslStream
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sslStream;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000127 RID: 295
|
||||
// (get) Token: 0x060004BF RID: 1215 RVA: 0x0001D3B0 File Offset: 0x0001B5B0
|
||||
// (set) Token: 0x060004C0 RID: 1216 RVA: 0x0001D3B8 File Offset: 0x0001B5B8
|
||||
public short ClientHelloProtocol
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientHelloProtocol;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.clientHelloProtocol = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004C1 RID: 1217 RVA: 0x0001D3C4 File Offset: 0x0001B5C4
|
||||
public override void Clear()
|
||||
{
|
||||
this.clientHelloProtocol = 0;
|
||||
base.Clear();
|
||||
}
|
||||
|
||||
// Token: 0x04000253 RID: 595
|
||||
private SslClientStream sslStream;
|
||||
|
||||
// Token: 0x04000254 RID: 596
|
||||
private short clientHelloProtocol;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.Protocol.Tls.Handshake.Client;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000084 RID: 132
|
||||
internal class ClientRecordProtocol : RecordProtocol
|
||||
{
|
||||
// Token: 0x060004C2 RID: 1218 RVA: 0x0001D3D4 File Offset: 0x0001B5D4
|
||||
public ClientRecordProtocol(Stream innerStream, ClientContext context)
|
||||
: base(innerStream, context)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060004C3 RID: 1219 RVA: 0x0001D3E0 File Offset: 0x0001B5E0
|
||||
public override HandshakeMessage GetMessage(HandshakeType type)
|
||||
{
|
||||
return this.createClientHandshakeMessage(type);
|
||||
}
|
||||
|
||||
// Token: 0x060004C4 RID: 1220 RVA: 0x0001D3F8 File Offset: 0x0001B5F8
|
||||
protected override void ProcessHandshakeMessage(TlsStream handMsg)
|
||||
{
|
||||
HandshakeType handshakeType = (HandshakeType)handMsg.ReadByte();
|
||||
int num = handMsg.ReadInt24();
|
||||
byte[] array = null;
|
||||
if (num > 0)
|
||||
{
|
||||
array = new byte[num];
|
||||
handMsg.Read(array, 0, num);
|
||||
}
|
||||
HandshakeMessage handshakeMessage = this.createServerHandshakeMessage(handshakeType, array);
|
||||
if (handshakeMessage != null)
|
||||
{
|
||||
handshakeMessage.Process();
|
||||
}
|
||||
base.Context.LastHandshakeMsg = handshakeType;
|
||||
if (handshakeMessage != null)
|
||||
{
|
||||
handshakeMessage.Update();
|
||||
base.Context.HandshakeMessages.WriteByte((byte)handshakeType);
|
||||
base.Context.HandshakeMessages.WriteInt24(num);
|
||||
if (num > 0)
|
||||
{
|
||||
base.Context.HandshakeMessages.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004C5 RID: 1221 RVA: 0x0001D49C File Offset: 0x0001B69C
|
||||
private HandshakeMessage createClientHandshakeMessage(HandshakeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HandshakeType.CertificateVerify:
|
||||
return new TlsClientCertificateVerify(this.context);
|
||||
case HandshakeType.ClientKeyExchange:
|
||||
return new TlsClientKeyExchange(this.context);
|
||||
default:
|
||||
if (type == HandshakeType.ClientHello)
|
||||
{
|
||||
return new TlsClientHello(this.context);
|
||||
}
|
||||
if (type != HandshakeType.Certificate)
|
||||
{
|
||||
throw new InvalidOperationException("Unknown client handshake message type: " + type.ToString());
|
||||
}
|
||||
return new TlsClientCertificate(this.context);
|
||||
case HandshakeType.Finished:
|
||||
return new TlsClientFinished(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004C6 RID: 1222 RVA: 0x0001D538 File Offset: 0x0001B738
|
||||
private HandshakeMessage createServerHandshakeMessage(HandshakeType type, byte[] buffer)
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)this.context;
|
||||
switch (type)
|
||||
{
|
||||
case HandshakeType.Certificate:
|
||||
return new TlsServerCertificate(this.context, buffer);
|
||||
case HandshakeType.ServerKeyExchange:
|
||||
return new TlsServerKeyExchange(this.context, buffer);
|
||||
case HandshakeType.CertificateRequest:
|
||||
return new TlsServerCertificateRequest(this.context, buffer);
|
||||
case HandshakeType.ServerHelloDone:
|
||||
return new TlsServerHelloDone(this.context, buffer);
|
||||
default:
|
||||
switch (type)
|
||||
{
|
||||
case HandshakeType.HelloRequest:
|
||||
if (clientContext.HandshakeState != HandshakeState.Started)
|
||||
{
|
||||
clientContext.HandshakeState = HandshakeState.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.SendAlert(AlertLevel.Warning, AlertDescription.NoRenegotiation);
|
||||
}
|
||||
return null;
|
||||
case HandshakeType.ServerHello:
|
||||
return new TlsServerHello(this.context, buffer);
|
||||
}
|
||||
throw new TlsException(AlertDescription.UnexpectedMessage, string.Format(CultureInfo.CurrentUICulture, "Unknown server handshake message received ({0})", new object[] { type.ToString() }));
|
||||
case HandshakeType.Finished:
|
||||
return new TlsServerFinished(this.context, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000086 RID: 134
|
||||
internal class ClientSessionCache
|
||||
{
|
||||
// Token: 0x060004D5 RID: 1237 RVA: 0x0001D874 File Offset: 0x0001BA74
|
||||
public static void Add(string host, byte[] id)
|
||||
{
|
||||
object obj = ClientSessionCache.locker;
|
||||
lock (obj)
|
||||
{
|
||||
string text = BitConverter.ToString(id);
|
||||
ClientSessionInfo clientSessionInfo = (ClientSessionInfo)ClientSessionCache.cache[text];
|
||||
if (clientSessionInfo == null)
|
||||
{
|
||||
ClientSessionCache.cache.Add(text, new ClientSessionInfo(host, id));
|
||||
}
|
||||
else if (clientSessionInfo.HostName == host)
|
||||
{
|
||||
clientSessionInfo.KeepAlive();
|
||||
}
|
||||
else
|
||||
{
|
||||
clientSessionInfo.Dispose();
|
||||
ClientSessionCache.cache.Remove(text);
|
||||
ClientSessionCache.cache.Add(text, new ClientSessionInfo(host, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004D6 RID: 1238 RVA: 0x0001D92C File Offset: 0x0001BB2C
|
||||
public static byte[] FromHost(string host)
|
||||
{
|
||||
object obj = ClientSessionCache.locker;
|
||||
byte[] array;
|
||||
lock (obj)
|
||||
{
|
||||
foreach (object obj2 in ClientSessionCache.cache.Values)
|
||||
{
|
||||
ClientSessionInfo clientSessionInfo = (ClientSessionInfo)obj2;
|
||||
if (clientSessionInfo.HostName == host && clientSessionInfo.Valid)
|
||||
{
|
||||
clientSessionInfo.KeepAlive();
|
||||
return clientSessionInfo.Id;
|
||||
}
|
||||
}
|
||||
array = null;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060004D7 RID: 1239 RVA: 0x0001DA04 File Offset: 0x0001BC04
|
||||
private static ClientSessionInfo FromContext(Context context, bool checkValidity)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] sessionId = context.SessionId;
|
||||
if (sessionId == null || sessionId.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string text = BitConverter.ToString(sessionId);
|
||||
ClientSessionInfo clientSessionInfo = (ClientSessionInfo)ClientSessionCache.cache[text];
|
||||
if (clientSessionInfo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (context.ClientSettings.TargetHost != clientSessionInfo.HostName)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (checkValidity && !clientSessionInfo.Valid)
|
||||
{
|
||||
clientSessionInfo.Dispose();
|
||||
ClientSessionCache.cache.Remove(text);
|
||||
return null;
|
||||
}
|
||||
return clientSessionInfo;
|
||||
}
|
||||
|
||||
// Token: 0x060004D8 RID: 1240 RVA: 0x0001DA94 File Offset: 0x0001BC94
|
||||
public static bool SetContextInCache(Context context)
|
||||
{
|
||||
object obj = ClientSessionCache.locker;
|
||||
bool flag;
|
||||
lock (obj)
|
||||
{
|
||||
ClientSessionInfo clientSessionInfo = ClientSessionCache.FromContext(context, false);
|
||||
if (clientSessionInfo == null)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clientSessionInfo.GetContext(context);
|
||||
clientSessionInfo.KeepAlive();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060004D9 RID: 1241 RVA: 0x0001DB00 File Offset: 0x0001BD00
|
||||
public static bool SetContextFromCache(Context context)
|
||||
{
|
||||
object obj = ClientSessionCache.locker;
|
||||
bool flag;
|
||||
lock (obj)
|
||||
{
|
||||
ClientSessionInfo clientSessionInfo = ClientSessionCache.FromContext(context, true);
|
||||
if (clientSessionInfo == null)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clientSessionInfo.SetContext(context);
|
||||
clientSessionInfo.KeepAlive();
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x0400025C RID: 604
|
||||
private static Hashtable cache = new Hashtable();
|
||||
|
||||
// Token: 0x0400025D RID: 605
|
||||
private static object locker = new object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000085 RID: 133
|
||||
internal class ClientSessionInfo : IDisposable
|
||||
{
|
||||
// Token: 0x060004C7 RID: 1223 RVA: 0x0001D638 File Offset: 0x0001B838
|
||||
public ClientSessionInfo(string hostname, byte[] id)
|
||||
{
|
||||
this.host = hostname;
|
||||
this.sid = id;
|
||||
this.KeepAlive();
|
||||
}
|
||||
|
||||
// Token: 0x060004C8 RID: 1224 RVA: 0x0001D654 File Offset: 0x0001B854
|
||||
static ClientSessionInfo()
|
||||
{
|
||||
string environmentVariable = Environment.GetEnvironmentVariable("MONO_TLS_SESSION_CACHE_TIMEOUT");
|
||||
if (environmentVariable == null)
|
||||
{
|
||||
ClientSessionInfo.ValidityInterval = 180;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ClientSessionInfo.ValidityInterval = int.Parse(environmentVariable);
|
||||
}
|
||||
catch
|
||||
{
|
||||
ClientSessionInfo.ValidityInterval = 180;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004C9 RID: 1225 RVA: 0x0001D6C0 File Offset: 0x0001B8C0
|
||||
~ClientSessionInfo()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x17000128 RID: 296
|
||||
// (get) Token: 0x060004CA RID: 1226 RVA: 0x0001D6FC File Offset: 0x0001B8FC
|
||||
public string HostName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.host;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000129 RID: 297
|
||||
// (get) Token: 0x060004CB RID: 1227 RVA: 0x0001D704 File Offset: 0x0001B904
|
||||
public byte[] Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sid;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012A RID: 298
|
||||
// (get) Token: 0x060004CC RID: 1228 RVA: 0x0001D70C File Offset: 0x0001B90C
|
||||
public bool Valid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.masterSecret != null && this.validuntil > DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004CD RID: 1229 RVA: 0x0001D72C File Offset: 0x0001B92C
|
||||
public void GetContext(Context context)
|
||||
{
|
||||
this.CheckDisposed();
|
||||
if (context.MasterSecret != null)
|
||||
{
|
||||
this.masterSecret = (byte[])context.MasterSecret.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004CE RID: 1230 RVA: 0x0001D760 File Offset: 0x0001B960
|
||||
public void SetContext(Context context)
|
||||
{
|
||||
this.CheckDisposed();
|
||||
if (this.masterSecret != null)
|
||||
{
|
||||
context.MasterSecret = (byte[])this.masterSecret.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004CF RID: 1231 RVA: 0x0001D78C File Offset: 0x0001B98C
|
||||
public void KeepAlive()
|
||||
{
|
||||
this.CheckDisposed();
|
||||
this.validuntil = DateTime.UtcNow.AddSeconds((double)ClientSessionInfo.ValidityInterval);
|
||||
}
|
||||
|
||||
// Token: 0x060004D0 RID: 1232 RVA: 0x0001D7B8 File Offset: 0x0001B9B8
|
||||
public void Dispose()
|
||||
{
|
||||
this.Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// Token: 0x060004D1 RID: 1233 RVA: 0x0001D7C8 File Offset: 0x0001B9C8
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.disposed)
|
||||
{
|
||||
this.validuntil = DateTime.MinValue;
|
||||
this.host = null;
|
||||
this.sid = null;
|
||||
if (this.masterSecret != null)
|
||||
{
|
||||
Array.Clear(this.masterSecret, 0, this.masterSecret.Length);
|
||||
this.masterSecret = null;
|
||||
}
|
||||
}
|
||||
this.disposed = true;
|
||||
}
|
||||
|
||||
// Token: 0x060004D2 RID: 1234 RVA: 0x0001D828 File Offset: 0x0001BA28
|
||||
private void CheckDisposed()
|
||||
{
|
||||
if (this.disposed)
|
||||
{
|
||||
string text = Locale.GetText("Cache session information were disposed.");
|
||||
throw new ObjectDisposedException(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000255 RID: 597
|
||||
private const int DefaultValidityInterval = 180;
|
||||
|
||||
// Token: 0x04000256 RID: 598
|
||||
private static readonly int ValidityInterval;
|
||||
|
||||
// Token: 0x04000257 RID: 599
|
||||
private bool disposed;
|
||||
|
||||
// Token: 0x04000258 RID: 600
|
||||
private DateTime validuntil;
|
||||
|
||||
// Token: 0x04000259 RID: 601
|
||||
private string host;
|
||||
|
||||
// Token: 0x0400025A RID: 602
|
||||
private byte[] sid;
|
||||
|
||||
// Token: 0x0400025B RID: 603
|
||||
private byte[] masterSecret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000087 RID: 135
|
||||
[Serializable]
|
||||
internal enum ContentType : byte
|
||||
{
|
||||
// Token: 0x0400025F RID: 607
|
||||
ChangeCipherSpec = 20,
|
||||
// Token: 0x04000260 RID: 608
|
||||
Alert,
|
||||
// Token: 0x04000261 RID: 609
|
||||
Handshake,
|
||||
// Token: 0x04000262 RID: 610
|
||||
ApplicationData
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,731 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000088 RID: 136
|
||||
internal abstract class Context
|
||||
{
|
||||
// Token: 0x060004DA RID: 1242 RVA: 0x0001DB6C File Offset: 0x0001BD6C
|
||||
public Context(SecurityProtocolType securityProtocolType)
|
||||
{
|
||||
this.SecurityProtocol = securityProtocolType;
|
||||
this.compressionMethod = SecurityCompressionType.None;
|
||||
this.serverSettings = new TlsServerSettings();
|
||||
this.clientSettings = new TlsClientSettings();
|
||||
this.handshakeMessages = new TlsStream();
|
||||
this.sessionId = null;
|
||||
this.handshakeState = HandshakeState.None;
|
||||
this.random = RandomNumberGenerator.Create();
|
||||
}
|
||||
|
||||
// Token: 0x1700012B RID: 299
|
||||
// (get) Token: 0x060004DB RID: 1243 RVA: 0x0001DBC8 File Offset: 0x0001BDC8
|
||||
// (set) Token: 0x060004DC RID: 1244 RVA: 0x0001DBD0 File Offset: 0x0001BDD0
|
||||
public bool AbbreviatedHandshake
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.abbreviatedHandshake;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.abbreviatedHandshake = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012C RID: 300
|
||||
// (get) Token: 0x060004DD RID: 1245 RVA: 0x0001DBDC File Offset: 0x0001BDDC
|
||||
// (set) Token: 0x060004DE RID: 1246 RVA: 0x0001DBE4 File Offset: 0x0001BDE4
|
||||
public bool ProtocolNegotiated
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.protocolNegotiated;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.protocolNegotiated = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012D RID: 301
|
||||
// (get) Token: 0x060004DF RID: 1247 RVA: 0x0001DBF0 File Offset: 0x0001BDF0
|
||||
// (set) Token: 0x060004E0 RID: 1248 RVA: 0x0001DC4C File Offset: 0x0001BE4C
|
||||
public SecurityProtocolType SecurityProtocol
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((this.securityProtocol & SecurityProtocolType.Tls) == SecurityProtocolType.Tls || (this.securityProtocol & SecurityProtocolType.Default) == SecurityProtocolType.Default)
|
||||
{
|
||||
return SecurityProtocolType.Tls;
|
||||
}
|
||||
if ((this.securityProtocol & SecurityProtocolType.Ssl3) == SecurityProtocolType.Ssl3)
|
||||
{
|
||||
return SecurityProtocolType.Ssl3;
|
||||
}
|
||||
throw new NotSupportedException("Unsupported security protocol type");
|
||||
}
|
||||
set
|
||||
{
|
||||
this.securityProtocol = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012E RID: 302
|
||||
// (get) Token: 0x060004E1 RID: 1249 RVA: 0x0001DC58 File Offset: 0x0001BE58
|
||||
public SecurityProtocolType SecurityProtocolFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.securityProtocol;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012F RID: 303
|
||||
// (get) Token: 0x060004E2 RID: 1250 RVA: 0x0001DC60 File Offset: 0x0001BE60
|
||||
public short Protocol
|
||||
{
|
||||
get
|
||||
{
|
||||
SecurityProtocolType securityProtocolType = this.SecurityProtocol;
|
||||
if (securityProtocolType != SecurityProtocolType.Default)
|
||||
{
|
||||
if (securityProtocolType != SecurityProtocolType.Ssl2)
|
||||
{
|
||||
if (securityProtocolType == SecurityProtocolType.Ssl3)
|
||||
{
|
||||
return 768;
|
||||
}
|
||||
if (securityProtocolType == SecurityProtocolType.Tls)
|
||||
{
|
||||
return 769;
|
||||
}
|
||||
}
|
||||
throw new NotSupportedException("Unsupported security protocol type");
|
||||
}
|
||||
return 769;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000130 RID: 304
|
||||
// (get) Token: 0x060004E3 RID: 1251 RVA: 0x0001DCB8 File Offset: 0x0001BEB8
|
||||
// (set) Token: 0x060004E4 RID: 1252 RVA: 0x0001DCC0 File Offset: 0x0001BEC0
|
||||
public byte[] SessionId
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sessionId;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.sessionId = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000131 RID: 305
|
||||
// (get) Token: 0x060004E5 RID: 1253 RVA: 0x0001DCCC File Offset: 0x0001BECC
|
||||
// (set) Token: 0x060004E6 RID: 1254 RVA: 0x0001DCD4 File Offset: 0x0001BED4
|
||||
public SecurityCompressionType CompressionMethod
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.compressionMethod;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.compressionMethod = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000132 RID: 306
|
||||
// (get) Token: 0x060004E7 RID: 1255 RVA: 0x0001DCE0 File Offset: 0x0001BEE0
|
||||
public TlsServerSettings ServerSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverSettings;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000133 RID: 307
|
||||
// (get) Token: 0x060004E8 RID: 1256 RVA: 0x0001DCE8 File Offset: 0x0001BEE8
|
||||
public TlsClientSettings ClientSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientSettings;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000134 RID: 308
|
||||
// (get) Token: 0x060004E9 RID: 1257 RVA: 0x0001DCF0 File Offset: 0x0001BEF0
|
||||
// (set) Token: 0x060004EA RID: 1258 RVA: 0x0001DCF8 File Offset: 0x0001BEF8
|
||||
public HandshakeType LastHandshakeMsg
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lastHandshakeMsg;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lastHandshakeMsg = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000135 RID: 309
|
||||
// (get) Token: 0x060004EB RID: 1259 RVA: 0x0001DD04 File Offset: 0x0001BF04
|
||||
// (set) Token: 0x060004EC RID: 1260 RVA: 0x0001DD0C File Offset: 0x0001BF0C
|
||||
public HandshakeState HandshakeState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handshakeState;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.handshakeState = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000136 RID: 310
|
||||
// (get) Token: 0x060004ED RID: 1261 RVA: 0x0001DD18 File Offset: 0x0001BF18
|
||||
// (set) Token: 0x060004EE RID: 1262 RVA: 0x0001DD20 File Offset: 0x0001BF20
|
||||
public bool ReceivedConnectionEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.receivedConnectionEnd;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.receivedConnectionEnd = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000137 RID: 311
|
||||
// (get) Token: 0x060004EF RID: 1263 RVA: 0x0001DD2C File Offset: 0x0001BF2C
|
||||
// (set) Token: 0x060004F0 RID: 1264 RVA: 0x0001DD34 File Offset: 0x0001BF34
|
||||
public bool SentConnectionEnd
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sentConnectionEnd;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.sentConnectionEnd = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000138 RID: 312
|
||||
// (get) Token: 0x060004F1 RID: 1265 RVA: 0x0001DD40 File Offset: 0x0001BF40
|
||||
// (set) Token: 0x060004F2 RID: 1266 RVA: 0x0001DD48 File Offset: 0x0001BF48
|
||||
public CipherSuiteCollection SupportedCiphers
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.supportedCiphers;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.supportedCiphers = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000139 RID: 313
|
||||
// (get) Token: 0x060004F3 RID: 1267 RVA: 0x0001DD54 File Offset: 0x0001BF54
|
||||
public TlsStream HandshakeMessages
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handshakeMessages;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013A RID: 314
|
||||
// (get) Token: 0x060004F4 RID: 1268 RVA: 0x0001DD5C File Offset: 0x0001BF5C
|
||||
// (set) Token: 0x060004F5 RID: 1269 RVA: 0x0001DD64 File Offset: 0x0001BF64
|
||||
public ulong WriteSequenceNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.writeSequenceNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.writeSequenceNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013B RID: 315
|
||||
// (get) Token: 0x060004F6 RID: 1270 RVA: 0x0001DD70 File Offset: 0x0001BF70
|
||||
// (set) Token: 0x060004F7 RID: 1271 RVA: 0x0001DD78 File Offset: 0x0001BF78
|
||||
public ulong ReadSequenceNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.readSequenceNumber;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.readSequenceNumber = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013C RID: 316
|
||||
// (get) Token: 0x060004F8 RID: 1272 RVA: 0x0001DD84 File Offset: 0x0001BF84
|
||||
// (set) Token: 0x060004F9 RID: 1273 RVA: 0x0001DD8C File Offset: 0x0001BF8C
|
||||
public byte[] ClientRandom
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientRandom;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.clientRandom = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013D RID: 317
|
||||
// (get) Token: 0x060004FA RID: 1274 RVA: 0x0001DD98 File Offset: 0x0001BF98
|
||||
// (set) Token: 0x060004FB RID: 1275 RVA: 0x0001DDA0 File Offset: 0x0001BFA0
|
||||
public byte[] ServerRandom
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverRandom;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.serverRandom = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013E RID: 318
|
||||
// (get) Token: 0x060004FC RID: 1276 RVA: 0x0001DDAC File Offset: 0x0001BFAC
|
||||
// (set) Token: 0x060004FD RID: 1277 RVA: 0x0001DDB4 File Offset: 0x0001BFB4
|
||||
public byte[] RandomCS
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.randomCS;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.randomCS = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013F RID: 319
|
||||
// (get) Token: 0x060004FE RID: 1278 RVA: 0x0001DDC0 File Offset: 0x0001BFC0
|
||||
// (set) Token: 0x060004FF RID: 1279 RVA: 0x0001DDC8 File Offset: 0x0001BFC8
|
||||
public byte[] RandomSC
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.randomSC;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.randomSC = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000140 RID: 320
|
||||
// (get) Token: 0x06000500 RID: 1280 RVA: 0x0001DDD4 File Offset: 0x0001BFD4
|
||||
// (set) Token: 0x06000501 RID: 1281 RVA: 0x0001DDDC File Offset: 0x0001BFDC
|
||||
public byte[] MasterSecret
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.masterSecret;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.masterSecret = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000141 RID: 321
|
||||
// (get) Token: 0x06000502 RID: 1282 RVA: 0x0001DDE8 File Offset: 0x0001BFE8
|
||||
// (set) Token: 0x06000503 RID: 1283 RVA: 0x0001DDF0 File Offset: 0x0001BFF0
|
||||
public byte[] ClientWriteKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientWriteKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.clientWriteKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000142 RID: 322
|
||||
// (get) Token: 0x06000504 RID: 1284 RVA: 0x0001DDFC File Offset: 0x0001BFFC
|
||||
// (set) Token: 0x06000505 RID: 1285 RVA: 0x0001DE04 File Offset: 0x0001C004
|
||||
public byte[] ServerWriteKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverWriteKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.serverWriteKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000143 RID: 323
|
||||
// (get) Token: 0x06000506 RID: 1286 RVA: 0x0001DE10 File Offset: 0x0001C010
|
||||
// (set) Token: 0x06000507 RID: 1287 RVA: 0x0001DE18 File Offset: 0x0001C018
|
||||
public byte[] ClientWriteIV
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientWriteIV;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.clientWriteIV = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000144 RID: 324
|
||||
// (get) Token: 0x06000508 RID: 1288 RVA: 0x0001DE24 File Offset: 0x0001C024
|
||||
// (set) Token: 0x06000509 RID: 1289 RVA: 0x0001DE2C File Offset: 0x0001C02C
|
||||
public byte[] ServerWriteIV
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverWriteIV;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.serverWriteIV = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000145 RID: 325
|
||||
// (get) Token: 0x0600050A RID: 1290 RVA: 0x0001DE38 File Offset: 0x0001C038
|
||||
// (set) Token: 0x0600050B RID: 1291 RVA: 0x0001DE40 File Offset: 0x0001C040
|
||||
public RecordProtocol RecordProtocol
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.recordProtocol;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.recordProtocol = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600050C RID: 1292 RVA: 0x0001DE4C File Offset: 0x0001C04C
|
||||
public int GetUnixTime()
|
||||
{
|
||||
return (int)((DateTime.UtcNow.Ticks - 621355968000000000L) / 10000000L);
|
||||
}
|
||||
|
||||
// Token: 0x0600050D RID: 1293 RVA: 0x0001DE78 File Offset: 0x0001C078
|
||||
public byte[] GetSecureRandomBytes(int count)
|
||||
{
|
||||
byte[] array = new byte[count];
|
||||
this.random.GetNonZeroBytes(array);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x0600050E RID: 1294 RVA: 0x0001DE9C File Offset: 0x0001C09C
|
||||
public virtual void Clear()
|
||||
{
|
||||
this.compressionMethod = SecurityCompressionType.None;
|
||||
this.serverSettings = new TlsServerSettings();
|
||||
this.clientSettings = new TlsClientSettings();
|
||||
this.handshakeMessages = new TlsStream();
|
||||
this.sessionId = null;
|
||||
this.handshakeState = HandshakeState.None;
|
||||
this.ClearKeyInfo();
|
||||
}
|
||||
|
||||
// Token: 0x0600050F RID: 1295 RVA: 0x0001DEE8 File Offset: 0x0001C0E8
|
||||
public virtual void ClearKeyInfo()
|
||||
{
|
||||
if (this.masterSecret != null)
|
||||
{
|
||||
Array.Clear(this.masterSecret, 0, this.masterSecret.Length);
|
||||
this.masterSecret = null;
|
||||
}
|
||||
if (this.clientRandom != null)
|
||||
{
|
||||
Array.Clear(this.clientRandom, 0, this.clientRandom.Length);
|
||||
this.clientRandom = null;
|
||||
}
|
||||
if (this.serverRandom != null)
|
||||
{
|
||||
Array.Clear(this.serverRandom, 0, this.serverRandom.Length);
|
||||
this.serverRandom = null;
|
||||
}
|
||||
if (this.randomCS != null)
|
||||
{
|
||||
Array.Clear(this.randomCS, 0, this.randomCS.Length);
|
||||
this.randomCS = null;
|
||||
}
|
||||
if (this.randomSC != null)
|
||||
{
|
||||
Array.Clear(this.randomSC, 0, this.randomSC.Length);
|
||||
this.randomSC = null;
|
||||
}
|
||||
if (this.clientWriteKey != null)
|
||||
{
|
||||
Array.Clear(this.clientWriteKey, 0, this.clientWriteKey.Length);
|
||||
this.clientWriteKey = null;
|
||||
}
|
||||
if (this.clientWriteIV != null)
|
||||
{
|
||||
Array.Clear(this.clientWriteIV, 0, this.clientWriteIV.Length);
|
||||
this.clientWriteIV = null;
|
||||
}
|
||||
if (this.serverWriteKey != null)
|
||||
{
|
||||
Array.Clear(this.serverWriteKey, 0, this.serverWriteKey.Length);
|
||||
this.serverWriteKey = null;
|
||||
}
|
||||
if (this.serverWriteIV != null)
|
||||
{
|
||||
Array.Clear(this.serverWriteIV, 0, this.serverWriteIV.Length);
|
||||
this.serverWriteIV = null;
|
||||
}
|
||||
this.handshakeMessages.Reset();
|
||||
if (this.securityProtocol != SecurityProtocolType.Ssl3)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000510 RID: 1296 RVA: 0x0001E064 File Offset: 0x0001C264
|
||||
public SecurityProtocolType DecodeProtocolCode(short code)
|
||||
{
|
||||
if (code == 768)
|
||||
{
|
||||
return SecurityProtocolType.Ssl3;
|
||||
}
|
||||
if (code != 769)
|
||||
{
|
||||
throw new NotSupportedException("Unsupported security protocol type");
|
||||
}
|
||||
return SecurityProtocolType.Tls;
|
||||
}
|
||||
|
||||
// Token: 0x06000511 RID: 1297 RVA: 0x0001E0A4 File Offset: 0x0001C2A4
|
||||
public void ChangeProtocol(short protocol)
|
||||
{
|
||||
SecurityProtocolType securityProtocolType = this.DecodeProtocolCode(protocol);
|
||||
if ((securityProtocolType & this.SecurityProtocolFlags) == securityProtocolType || (this.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default)
|
||||
{
|
||||
this.SecurityProtocol = securityProtocolType;
|
||||
this.SupportedCiphers.Clear();
|
||||
this.SupportedCiphers = null;
|
||||
this.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(securityProtocolType);
|
||||
return;
|
||||
}
|
||||
throw new TlsException(AlertDescription.ProtocolVersion, "Incorrect protocol version received from server");
|
||||
}
|
||||
|
||||
// Token: 0x17000146 RID: 326
|
||||
// (get) Token: 0x06000512 RID: 1298 RVA: 0x0001E114 File Offset: 0x0001C314
|
||||
public SecurityParameters Current
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.current == null)
|
||||
{
|
||||
this.current = new SecurityParameters();
|
||||
}
|
||||
if (this.current.Cipher != null)
|
||||
{
|
||||
this.current.Cipher.Context = this;
|
||||
}
|
||||
return this.current;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000147 RID: 327
|
||||
// (get) Token: 0x06000513 RID: 1299 RVA: 0x0001E154 File Offset: 0x0001C354
|
||||
public SecurityParameters Negotiating
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.negotiating == null)
|
||||
{
|
||||
this.negotiating = new SecurityParameters();
|
||||
}
|
||||
if (this.negotiating.Cipher != null)
|
||||
{
|
||||
this.negotiating.Cipher.Context = this;
|
||||
}
|
||||
return this.negotiating;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000148 RID: 328
|
||||
// (get) Token: 0x06000514 RID: 1300 RVA: 0x0001E194 File Offset: 0x0001C394
|
||||
public SecurityParameters Read
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.read;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000149 RID: 329
|
||||
// (get) Token: 0x06000515 RID: 1301 RVA: 0x0001E19C File Offset: 0x0001C39C
|
||||
public SecurityParameters Write
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.write;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000516 RID: 1302 RVA: 0x0001E1A4 File Offset: 0x0001C3A4
|
||||
public void StartSwitchingSecurityParameters(bool client)
|
||||
{
|
||||
if (client)
|
||||
{
|
||||
this.write = this.negotiating;
|
||||
this.read = this.current;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.read = this.negotiating;
|
||||
this.write = this.current;
|
||||
}
|
||||
this.current = this.negotiating;
|
||||
}
|
||||
|
||||
// Token: 0x06000517 RID: 1303 RVA: 0x0001E1F8 File Offset: 0x0001C3F8
|
||||
public void EndSwitchingSecurityParameters(bool client)
|
||||
{
|
||||
SecurityParameters securityParameters;
|
||||
if (client)
|
||||
{
|
||||
securityParameters = this.read;
|
||||
this.read = this.current;
|
||||
}
|
||||
else
|
||||
{
|
||||
securityParameters = this.write;
|
||||
this.write = this.current;
|
||||
}
|
||||
if (securityParameters != null)
|
||||
{
|
||||
securityParameters.Clear();
|
||||
}
|
||||
this.negotiating = securityParameters;
|
||||
}
|
||||
|
||||
// Token: 0x04000263 RID: 611
|
||||
internal const short MAX_FRAGMENT_SIZE = 16384;
|
||||
|
||||
// Token: 0x04000264 RID: 612
|
||||
internal const short TLS1_PROTOCOL_CODE = 769;
|
||||
|
||||
// Token: 0x04000265 RID: 613
|
||||
internal const short SSL3_PROTOCOL_CODE = 768;
|
||||
|
||||
// Token: 0x04000266 RID: 614
|
||||
internal const long UNIX_BASE_TICKS = 621355968000000000L;
|
||||
|
||||
// Token: 0x04000267 RID: 615
|
||||
private SecurityProtocolType securityProtocol;
|
||||
|
||||
// Token: 0x04000268 RID: 616
|
||||
private byte[] sessionId;
|
||||
|
||||
// Token: 0x04000269 RID: 617
|
||||
private SecurityCompressionType compressionMethod;
|
||||
|
||||
// Token: 0x0400026A RID: 618
|
||||
private TlsServerSettings serverSettings;
|
||||
|
||||
// Token: 0x0400026B RID: 619
|
||||
private TlsClientSettings clientSettings;
|
||||
|
||||
// Token: 0x0400026C RID: 620
|
||||
private SecurityParameters current;
|
||||
|
||||
// Token: 0x0400026D RID: 621
|
||||
private SecurityParameters negotiating;
|
||||
|
||||
// Token: 0x0400026E RID: 622
|
||||
private SecurityParameters read;
|
||||
|
||||
// Token: 0x0400026F RID: 623
|
||||
private SecurityParameters write;
|
||||
|
||||
// Token: 0x04000270 RID: 624
|
||||
private CipherSuiteCollection supportedCiphers;
|
||||
|
||||
// Token: 0x04000271 RID: 625
|
||||
private HandshakeType lastHandshakeMsg;
|
||||
|
||||
// Token: 0x04000272 RID: 626
|
||||
private HandshakeState handshakeState;
|
||||
|
||||
// Token: 0x04000273 RID: 627
|
||||
private bool abbreviatedHandshake;
|
||||
|
||||
// Token: 0x04000274 RID: 628
|
||||
private bool receivedConnectionEnd;
|
||||
|
||||
// Token: 0x04000275 RID: 629
|
||||
private bool sentConnectionEnd;
|
||||
|
||||
// Token: 0x04000276 RID: 630
|
||||
private bool protocolNegotiated;
|
||||
|
||||
// Token: 0x04000277 RID: 631
|
||||
private ulong writeSequenceNumber;
|
||||
|
||||
// Token: 0x04000278 RID: 632
|
||||
private ulong readSequenceNumber;
|
||||
|
||||
// Token: 0x04000279 RID: 633
|
||||
private byte[] clientRandom;
|
||||
|
||||
// Token: 0x0400027A RID: 634
|
||||
private byte[] serverRandom;
|
||||
|
||||
// Token: 0x0400027B RID: 635
|
||||
private byte[] randomCS;
|
||||
|
||||
// Token: 0x0400027C RID: 636
|
||||
private byte[] randomSC;
|
||||
|
||||
// Token: 0x0400027D RID: 637
|
||||
private byte[] masterSecret;
|
||||
|
||||
// Token: 0x0400027E RID: 638
|
||||
private byte[] clientWriteKey;
|
||||
|
||||
// Token: 0x0400027F RID: 639
|
||||
private byte[] serverWriteKey;
|
||||
|
||||
// Token: 0x04000280 RID: 640
|
||||
private byte[] clientWriteIV;
|
||||
|
||||
// Token: 0x04000281 RID: 641
|
||||
private byte[] serverWriteIV;
|
||||
|
||||
// Token: 0x04000282 RID: 642
|
||||
private TlsStream handshakeMessages;
|
||||
|
||||
// Token: 0x04000283 RID: 643
|
||||
private RandomNumberGenerator random;
|
||||
|
||||
// Token: 0x04000284 RID: 644
|
||||
private RecordProtocol recordProtocol;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000089 RID: 137
|
||||
internal class DebugHelper
|
||||
{
|
||||
// Token: 0x06000519 RID: 1305 RVA: 0x0001E254 File Offset: 0x0001C454
|
||||
[Conditional("DEBUG")]
|
||||
public static void Initialize()
|
||||
{
|
||||
if (!DebugHelper.isInitialized)
|
||||
{
|
||||
DebugHelper.isInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600051A RID: 1306 RVA: 0x0001E268 File Offset: 0x0001C468
|
||||
[Conditional("DEBUG")]
|
||||
public static void WriteLine(string format, params object[] args)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600051B RID: 1307 RVA: 0x0001E26C File Offset: 0x0001C46C
|
||||
[Conditional("DEBUG")]
|
||||
public static void WriteLine(string message)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600051C RID: 1308 RVA: 0x0001E270 File Offset: 0x0001C470
|
||||
[Conditional("DEBUG")]
|
||||
public static void WriteLine(string message, byte[] buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600051D RID: 1309 RVA: 0x0001E274 File Offset: 0x0001C474
|
||||
[Conditional("DEBUG")]
|
||||
public static void WriteBuffer(byte[] buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600051E RID: 1310 RVA: 0x0001E278 File Offset: 0x0001C478
|
||||
[Conditional("DEBUG")]
|
||||
public static void WriteBuffer(byte[] buffer, int index, int length)
|
||||
{
|
||||
for (int i = index; i < length; i += 16)
|
||||
{
|
||||
int num = ((length - i < 16) ? (length - i) : 16);
|
||||
string text = string.Empty;
|
||||
for (int j = 0; j < num; j++)
|
||||
{
|
||||
text = text + buffer[i + j].ToString("x2") + " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000285 RID: 645
|
||||
private static bool isInitialized;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200008A RID: 138
|
||||
[Serializable]
|
||||
public enum ExchangeAlgorithmType
|
||||
{
|
||||
// Token: 0x04000287 RID: 647
|
||||
DiffieHellman,
|
||||
// Token: 0x04000288 RID: 648
|
||||
Fortezza,
|
||||
// Token: 0x04000289 RID: 649
|
||||
None,
|
||||
// Token: 0x0400028A RID: 650
|
||||
RsaKeyX,
|
||||
// Token: 0x0400028B RID: 651
|
||||
RsaSign
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000A7 RID: 167
|
||||
internal class TlsClientCertificate : HandshakeMessage
|
||||
{
|
||||
// Token: 0x0600065E RID: 1630 RVA: 0x0002373C File Offset: 0x0002193C
|
||||
public TlsClientCertificate(Context context)
|
||||
: base(context, HandshakeType.Certificate)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x170001A3 RID: 419
|
||||
// (get) Token: 0x0600065F RID: 1631 RVA: 0x00023748 File Offset: 0x00021948
|
||||
public X509Certificate ClientCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!this.clientCertSelected)
|
||||
{
|
||||
this.GetClientCertificate();
|
||||
this.clientCertSelected = true;
|
||||
}
|
||||
return this.clientCert;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000660 RID: 1632 RVA: 0x00023768 File Offset: 0x00021968
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x06000661 RID: 1633 RVA: 0x00023778 File Offset: 0x00021978
|
||||
private void GetClientCertificate()
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
if (clientContext.ClientSettings.Certificates != null && clientContext.ClientSettings.Certificates.Count > 0)
|
||||
{
|
||||
this.clientCert = clientContext.SslStream.RaiseClientCertificateSelection(base.Context.ClientSettings.Certificates, new X509Certificate(base.Context.ServerSettings.Certificates[0].RawData), base.Context.ClientSettings.TargetHost, null);
|
||||
}
|
||||
clientContext.ClientSettings.ClientCertificate = this.clientCert;
|
||||
}
|
||||
|
||||
// Token: 0x06000662 RID: 1634 RVA: 0x0002381C File Offset: 0x00021A1C
|
||||
private void SendCertificates()
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
for (X509Certificate x509Certificate = this.ClientCertificate; x509Certificate != null; x509Certificate = this.FindParentCertificate(x509Certificate))
|
||||
{
|
||||
byte[] rawCertData = x509Certificate.GetRawCertData();
|
||||
tlsStream.WriteInt24(rawCertData.Length);
|
||||
tlsStream.Write(rawCertData);
|
||||
}
|
||||
base.WriteInt24((int)tlsStream.Length);
|
||||
base.Write(tlsStream.ToArray());
|
||||
}
|
||||
|
||||
// Token: 0x06000663 RID: 1635 RVA: 0x0002387C File Offset: 0x00021A7C
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
if (this.ClientCertificate != null)
|
||||
{
|
||||
this.SendCertificates();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000664 RID: 1636 RVA: 0x00023894 File Offset: 0x00021A94
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
if (this.ClientCertificate != null)
|
||||
{
|
||||
this.SendCertificates();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.WriteInt24(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000665 RID: 1637 RVA: 0x000238B4 File Offset: 0x00021AB4
|
||||
private X509Certificate FindParentCertificate(X509Certificate cert)
|
||||
{
|
||||
if (cert.GetName() == cert.GetIssuerName())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (X509Certificate x509Certificate in base.Context.ClientSettings.Certificates)
|
||||
{
|
||||
if (cert.GetName() == cert.GetIssuerName())
|
||||
{
|
||||
return x509Certificate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x0400031B RID: 795
|
||||
private bool clientCertSelected;
|
||||
|
||||
// Token: 0x0400031C RID: 796
|
||||
private X509Certificate clientCert;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000A8 RID: 168
|
||||
internal class TlsClientCertificateVerify : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000666 RID: 1638 RVA: 0x0002395C File Offset: 0x00021B5C
|
||||
public TlsClientCertificateVerify(Context context)
|
||||
: base(context, HandshakeType.CertificateVerify)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000667 RID: 1639 RVA: 0x00023968 File Offset: 0x00021B68
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x06000668 RID: 1640 RVA: 0x00023978 File Offset: 0x00021B78
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
AsymmetricAlgorithm asymmetricAlgorithm = null;
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
asymmetricAlgorithm = clientContext.SslStream.RaisePrivateKeySelection(clientContext.ClientSettings.ClientCertificate, clientContext.ClientSettings.TargetHost);
|
||||
if (asymmetricAlgorithm == null)
|
||||
{
|
||||
throw new TlsException(AlertDescription.UserCancelled, "Client certificate Private Key unavailable.");
|
||||
}
|
||||
SslHandshakeHash sslHandshakeHash = new SslHandshakeHash(clientContext.MasterSecret);
|
||||
sslHandshakeHash.TransformFinalBlock(clientContext.HandshakeMessages.ToArray(), 0, (int)clientContext.HandshakeMessages.Length);
|
||||
byte[] array = null;
|
||||
if (!(asymmetricAlgorithm is RSACryptoServiceProvider))
|
||||
{
|
||||
try
|
||||
{
|
||||
array = sslHandshakeHash.CreateSignature((RSA)asymmetricAlgorithm);
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (array == null)
|
||||
{
|
||||
RSA clientCertRSA = this.getClientCertRSA((RSA)asymmetricAlgorithm);
|
||||
array = sslHandshakeHash.CreateSignature(clientCertRSA);
|
||||
}
|
||||
base.Write((short)array.Length);
|
||||
this.Write(array, 0, array.Length);
|
||||
}
|
||||
|
||||
// Token: 0x06000669 RID: 1641 RVA: 0x00023A68 File Offset: 0x00021C68
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
AsymmetricAlgorithm asymmetricAlgorithm = null;
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
asymmetricAlgorithm = clientContext.SslStream.RaisePrivateKeySelection(clientContext.ClientSettings.ClientCertificate, clientContext.ClientSettings.TargetHost);
|
||||
if (asymmetricAlgorithm == null)
|
||||
{
|
||||
throw new TlsException(AlertDescription.UserCancelled, "Client certificate Private Key unavailable.");
|
||||
}
|
||||
MD5SHA1 md5SHA = new MD5SHA1();
|
||||
md5SHA.ComputeHash(clientContext.HandshakeMessages.ToArray(), 0, (int)clientContext.HandshakeMessages.Length);
|
||||
byte[] array = null;
|
||||
if (!(asymmetricAlgorithm is RSACryptoServiceProvider))
|
||||
{
|
||||
try
|
||||
{
|
||||
array = md5SHA.CreateSignature((RSA)asymmetricAlgorithm);
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (array == null)
|
||||
{
|
||||
RSA clientCertRSA = this.getClientCertRSA((RSA)asymmetricAlgorithm);
|
||||
array = md5SHA.CreateSignature(clientCertRSA);
|
||||
}
|
||||
base.Write((short)array.Length);
|
||||
this.Write(array, 0, array.Length);
|
||||
}
|
||||
|
||||
// Token: 0x0600066A RID: 1642 RVA: 0x00023B50 File Offset: 0x00021D50
|
||||
private RSA getClientCertRSA(RSA privKey)
|
||||
{
|
||||
RSAParameters rsaparameters = default(RSAParameters);
|
||||
RSAParameters rsaparameters2 = privKey.ExportParameters(true);
|
||||
ASN1 asn = new ASN1(base.Context.ClientSettings.Certificates[0].GetPublicKey());
|
||||
ASN1 asn2 = asn[0];
|
||||
if (asn2 == null || asn2.Tag != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ASN1 asn3 = asn[1];
|
||||
if (asn3.Tag != 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
rsaparameters.Modulus = this.getUnsignedBigInteger(asn2.Value);
|
||||
rsaparameters.Exponent = asn3.Value;
|
||||
rsaparameters.D = rsaparameters2.D;
|
||||
rsaparameters.DP = rsaparameters2.DP;
|
||||
rsaparameters.DQ = rsaparameters2.DQ;
|
||||
rsaparameters.InverseQ = rsaparameters2.InverseQ;
|
||||
rsaparameters.P = rsaparameters2.P;
|
||||
rsaparameters.Q = rsaparameters2.Q;
|
||||
int num = rsaparameters.Modulus.Length << 3;
|
||||
RSAManaged rsamanaged = new RSAManaged(num);
|
||||
rsamanaged.ImportParameters(rsaparameters);
|
||||
return rsamanaged;
|
||||
}
|
||||
|
||||
// Token: 0x0600066B RID: 1643 RVA: 0x00023C58 File Offset: 0x00021E58
|
||||
private byte[] getUnsignedBigInteger(byte[] integer)
|
||||
{
|
||||
if (integer[0] == 0)
|
||||
{
|
||||
int num = integer.Length - 1;
|
||||
byte[] array = new byte[num];
|
||||
Buffer.BlockCopy(integer, 1, array, 0, num);
|
||||
return array;
|
||||
}
|
||||
return integer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000A9 RID: 169
|
||||
internal class TlsClientFinished : HandshakeMessage
|
||||
{
|
||||
// Token: 0x0600066C RID: 1644 RVA: 0x00023C88 File Offset: 0x00021E88
|
||||
public TlsClientFinished(Context context)
|
||||
: base(context, HandshakeType.Finished)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600066E RID: 1646 RVA: 0x00023CAC File Offset: 0x00021EAC
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x0600066F RID: 1647 RVA: 0x00023CBC File Offset: 0x00021EBC
|
||||
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(TlsClientFinished.Ssl3Marker, 0, TlsClientFinished.Ssl3Marker.Length, TlsClientFinished.Ssl3Marker, 0);
|
||||
hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
base.Write(hashAlgorithm.Hash);
|
||||
}
|
||||
|
||||
// Token: 0x06000670 RID: 1648 RVA: 0x00023D30 File Offset: 0x00021F30
|
||||
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.Write.Cipher.PRF(base.Context.MasterSecret, "client finished", array2, 12));
|
||||
}
|
||||
|
||||
// Token: 0x0400031D RID: 797
|
||||
private static byte[] Ssl3Marker = new byte[] { 67, 76, 78, 84 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000AA RID: 170
|
||||
internal class TlsClientHello : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000671 RID: 1649 RVA: 0x00023D90 File Offset: 0x00021F90
|
||||
public TlsClientHello(Context context)
|
||||
: base(context, HandshakeType.ClientHello)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000672 RID: 1650 RVA: 0x00023D9C File Offset: 0x00021F9C
|
||||
public override void Update()
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
base.Update();
|
||||
clientContext.ClientRandom = this.random;
|
||||
clientContext.ClientHelloProtocol = base.Context.Protocol;
|
||||
this.random = null;
|
||||
}
|
||||
|
||||
// Token: 0x06000673 RID: 1651 RVA: 0x00023DE0 File Offset: 0x00021FE0
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x06000674 RID: 1652 RVA: 0x00023DE8 File Offset: 0x00021FE8
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
base.Write(base.Context.Protocol);
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(base.Context.GetUnixTime());
|
||||
tlsStream.Write(base.Context.GetSecureRandomBytes(28));
|
||||
this.random = tlsStream.ToArray();
|
||||
tlsStream.Reset();
|
||||
base.Write(this.random);
|
||||
base.Context.SessionId = ClientSessionCache.FromHost(base.Context.ClientSettings.TargetHost);
|
||||
if (base.Context.SessionId != null)
|
||||
{
|
||||
base.Write((byte)base.Context.SessionId.Length);
|
||||
if (base.Context.SessionId.Length > 0)
|
||||
{
|
||||
base.Write(base.Context.SessionId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Write(0);
|
||||
}
|
||||
base.Write((short)(base.Context.SupportedCiphers.Count * 2));
|
||||
for (int i = 0; i < base.Context.SupportedCiphers.Count; i++)
|
||||
{
|
||||
base.Write(base.Context.SupportedCiphers[i].Code);
|
||||
}
|
||||
base.Write(1);
|
||||
base.Write((byte)base.Context.CompressionMethod);
|
||||
}
|
||||
|
||||
// Token: 0x0400031E RID: 798
|
||||
private byte[] random;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000AB RID: 171
|
||||
internal class TlsClientKeyExchange : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000675 RID: 1653 RVA: 0x00023F34 File Offset: 0x00022134
|
||||
public TlsClientKeyExchange(Context context)
|
||||
: base(context, HandshakeType.ClientKeyExchange)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000676 RID: 1654 RVA: 0x00023F40 File Offset: 0x00022140
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessCommon(false);
|
||||
}
|
||||
|
||||
// Token: 0x06000677 RID: 1655 RVA: 0x00023F4C File Offset: 0x0002214C
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
this.ProcessCommon(true);
|
||||
}
|
||||
|
||||
// Token: 0x06000678 RID: 1656 RVA: 0x00023F58 File Offset: 0x00022158
|
||||
public void ProcessCommon(bool sendLength)
|
||||
{
|
||||
byte[] array = base.Context.Negotiating.Cipher.CreatePremasterSecret();
|
||||
RSA rsa;
|
||||
if (base.Context.ServerSettings.ServerKeyExchange)
|
||||
{
|
||||
rsa = new RSAManaged();
|
||||
rsa.ImportParameters(base.Context.ServerSettings.RsaParameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
rsa = base.Context.ServerSettings.CertificateRSA;
|
||||
}
|
||||
RSAPKCS1KeyExchangeFormatter rsapkcs1KeyExchangeFormatter = new RSAPKCS1KeyExchangeFormatter(rsa);
|
||||
byte[] array2 = rsapkcs1KeyExchangeFormatter.CreateKeyExchange(array);
|
||||
if (sendLength)
|
||||
{
|
||||
base.Write((short)array2.Length);
|
||||
}
|
||||
base.Write(array2);
|
||||
base.Context.Negotiating.Cipher.ComputeMasterSecret(array);
|
||||
base.Context.Negotiating.Cipher.ComputeKeys();
|
||||
rsa.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text.RegularExpressions;
|
||||
using Mono.Security.X509;
|
||||
using Mono.Security.X509.Extensions;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000AC RID: 172
|
||||
internal class TlsServerCertificate : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000679 RID: 1657 RVA: 0x0002401C File Offset: 0x0002221C
|
||||
public TlsServerCertificate(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.Certificate, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600067A RID: 1658 RVA: 0x00024028 File Offset: 0x00022228
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Context.ServerSettings.Certificates = this.certificates;
|
||||
base.Context.ServerSettings.UpdateCertificateRSA();
|
||||
}
|
||||
|
||||
// Token: 0x0600067B RID: 1659 RVA: 0x00024064 File Offset: 0x00022264
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x0600067C RID: 1660 RVA: 0x0002406C File Offset: 0x0002226C
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
this.certificates = new Mono.Security.X509.X509CertificateCollection();
|
||||
int i = 0;
|
||||
int num = base.ReadInt24();
|
||||
while (i < num)
|
||||
{
|
||||
int num2 = base.ReadInt24();
|
||||
i += 3;
|
||||
if (num2 > 0)
|
||||
{
|
||||
byte[] array = base.ReadBytes(num2);
|
||||
Mono.Security.X509.X509Certificate x509Certificate = new Mono.Security.X509.X509Certificate(array);
|
||||
this.certificates.Add(x509Certificate);
|
||||
i += num2;
|
||||
}
|
||||
}
|
||||
this.validateCertificates(this.certificates);
|
||||
}
|
||||
|
||||
// Token: 0x0600067D RID: 1661 RVA: 0x000240DC File Offset: 0x000222DC
|
||||
private bool checkCertificateUsage(Mono.Security.X509.X509Certificate cert)
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
if (cert.Version < 3)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
KeyUsages keyUsages = KeyUsages.none;
|
||||
switch (clientContext.Negotiating.Cipher.ExchangeAlgorithmType)
|
||||
{
|
||||
case ExchangeAlgorithmType.DiffieHellman:
|
||||
keyUsages = KeyUsages.keyAgreement;
|
||||
break;
|
||||
case ExchangeAlgorithmType.Fortezza:
|
||||
return false;
|
||||
case ExchangeAlgorithmType.RsaKeyX:
|
||||
keyUsages = KeyUsages.keyEncipherment;
|
||||
break;
|
||||
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.1") || extendedKeyUsageExtension.KeyPurpose.Contains("2.16.840.1.113730.4.1"));
|
||||
}
|
||||
if (keyUsageExtension != null)
|
||||
{
|
||||
return keyUsageExtension.Support(keyUsages);
|
||||
}
|
||||
if (extendedKeyUsageExtension != null)
|
||||
{
|
||||
return extendedKeyUsageExtension.KeyPurpose.Contains("1.3.6.1.5.5.7.3.1") || extendedKeyUsageExtension.KeyPurpose.Contains("2.16.840.1.113730.4.1");
|
||||
}
|
||||
x509Extension = cert.Extensions["2.16.840.1.113730.1.1"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
NetscapeCertTypeExtension netscapeCertTypeExtension = new NetscapeCertTypeExtension(x509Extension);
|
||||
return netscapeCertTypeExtension.Support(NetscapeCertTypeExtension.CertTypes.SslServer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x0600067E RID: 1662 RVA: 0x00024248 File Offset: 0x00022448
|
||||
private static void VerifyOSX(Mono.Security.X509.X509CertificateCollection certificates)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600067F RID: 1663 RVA: 0x0002424C File Offset: 0x0002244C
|
||||
private void validateCertificates(Mono.Security.X509.X509CertificateCollection certificates)
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
AlertDescription alertDescription = AlertDescription.BadCertificate;
|
||||
if (clientContext.SslStream.HaveRemoteValidation2Callback)
|
||||
{
|
||||
ValidationResult validationResult = clientContext.SslStream.RaiseServerCertificateValidation2(certificates);
|
||||
if (validationResult.Trusted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
long num = (long)validationResult.ErrorCode;
|
||||
long num2 = num;
|
||||
if (num2 != (long)((ulong)(-2146762487)))
|
||||
{
|
||||
if (num2 != (long)((ulong)(-2146762486)))
|
||||
{
|
||||
if (num2 != (long)((ulong)(-2146762495)))
|
||||
{
|
||||
alertDescription = AlertDescription.CertificateUnknown;
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDescription = AlertDescription.CertificateExpired;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDescription = AlertDescription.UnknownCA;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alertDescription = AlertDescription.UnknownCA;
|
||||
}
|
||||
string text = string.Format("0x{0:x}", num);
|
||||
throw new TlsException(alertDescription, "Invalid certificate received from server. Error code: " + text);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mono.Security.X509.X509Certificate x509Certificate = certificates[0];
|
||||
global::System.Security.Cryptography.X509Certificates.X509Certificate x509Certificate2 = new global::System.Security.Cryptography.X509Certificates.X509Certificate(x509Certificate.RawData);
|
||||
ArrayList arrayList = new ArrayList();
|
||||
if (!this.checkCertificateUsage(x509Certificate))
|
||||
{
|
||||
arrayList.Add(-2146762490);
|
||||
}
|
||||
if (!this.checkServerIdentity(x509Certificate))
|
||||
{
|
||||
arrayList.Add(-2146762481);
|
||||
}
|
||||
Mono.Security.X509.X509CertificateCollection x509CertificateCollection = new Mono.Security.X509.X509CertificateCollection(certificates);
|
||||
x509CertificateCollection.Remove(x509Certificate);
|
||||
Mono.Security.X509.X509Chain x509Chain = new Mono.Security.X509.X509Chain(x509CertificateCollection);
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
flag = x509Chain.Build(x509Certificate);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
int[] array = (int[])arrayList.ToArray(typeof(int));
|
||||
if (!clientContext.SslStream.RaiseServerCertificateValidation(x509Certificate2, array))
|
||||
{
|
||||
throw new TlsException(alertDescription, "Invalid certificate received from server.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000680 RID: 1664 RVA: 0x000244F0 File Offset: 0x000226F0
|
||||
private bool checkServerIdentity(Mono.Security.X509.X509Certificate cert)
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
string targetHost = clientContext.ClientSettings.TargetHost;
|
||||
Mono.Security.X509.X509Extension x509Extension = cert.Extensions["2.5.29.17"];
|
||||
if (x509Extension != null)
|
||||
{
|
||||
SubjectAltNameExtension subjectAltNameExtension = new SubjectAltNameExtension(x509Extension);
|
||||
foreach (string text in subjectAltNameExtension.DNSNames)
|
||||
{
|
||||
if (TlsServerCertificate.Match(targetHost, text))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach (string text2 in subjectAltNameExtension.IPAddresses)
|
||||
{
|
||||
if (text2 == targetHost)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.checkDomainName(cert.SubjectName);
|
||||
}
|
||||
|
||||
// Token: 0x06000681 RID: 1665 RVA: 0x000245B0 File Offset: 0x000227B0
|
||||
private bool checkDomainName(string subjectName)
|
||||
{
|
||||
ClientContext clientContext = (ClientContext)base.Context;
|
||||
string text = string.Empty;
|
||||
Regex regex = new Regex("CN\\s*=\\s*([^,]*)");
|
||||
MatchCollection matchCollection = regex.Matches(subjectName);
|
||||
if (matchCollection.Count == 1 && matchCollection[0].Success)
|
||||
{
|
||||
text = matchCollection[0].Groups[1].Value.ToString();
|
||||
}
|
||||
return TlsServerCertificate.Match(clientContext.ClientSettings.TargetHost, text);
|
||||
}
|
||||
|
||||
// Token: 0x06000682 RID: 1666 RVA: 0x00024630 File Offset: 0x00022830
|
||||
private static bool Match(string hostname, string pattern)
|
||||
{
|
||||
int num = pattern.IndexOf('*');
|
||||
if (num == -1)
|
||||
{
|
||||
return string.Compare(hostname, pattern, true, CultureInfo.InvariantCulture) == 0;
|
||||
}
|
||||
if (num != pattern.Length - 1 && pattern[num + 1] != '.')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int num2 = pattern.IndexOf('*', num + 1);
|
||||
if (num2 != -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string text = pattern.Substring(num + 1);
|
||||
int num3 = hostname.Length - text.Length;
|
||||
if (num3 <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (string.Compare(hostname, num3, text, 0, text.Length, true, CultureInfo.InvariantCulture) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
int num4 = hostname.IndexOf('.');
|
||||
return num4 == -1 || num4 >= hostname.Length - text.Length;
|
||||
}
|
||||
string text2 = pattern.Substring(0, num);
|
||||
return string.Compare(hostname, 0, text2, 0, text2.Length, true, CultureInfo.InvariantCulture) == 0;
|
||||
}
|
||||
|
||||
// Token: 0x0400031F RID: 799
|
||||
private Mono.Security.X509.X509CertificateCollection certificates;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000AD RID: 173
|
||||
internal class TlsServerCertificateRequest : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000683 RID: 1667 RVA: 0x00024724 File Offset: 0x00022924
|
||||
public TlsServerCertificateRequest(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.CertificateRequest, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000684 RID: 1668 RVA: 0x00024730 File Offset: 0x00022930
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Context.ServerSettings.CertificateTypes = this.certificateTypes;
|
||||
base.Context.ServerSettings.DistinguisedNames = this.distinguisedNames;
|
||||
base.Context.ServerSettings.CertificateRequest = true;
|
||||
}
|
||||
|
||||
// Token: 0x06000685 RID: 1669 RVA: 0x00024780 File Offset: 0x00022980
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x06000686 RID: 1670 RVA: 0x00024788 File Offset: 0x00022988
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
int num = (int)base.ReadByte();
|
||||
this.certificateTypes = new ClientCertificateType[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
this.certificateTypes[i] = (ClientCertificateType)base.ReadByte();
|
||||
}
|
||||
if (base.ReadInt16() != 0)
|
||||
{
|
||||
ASN1 asn = new ASN1(base.ReadBytes((int)base.ReadInt16()));
|
||||
this.distinguisedNames = new string[asn.Count];
|
||||
for (int j = 0; j < asn.Count; j++)
|
||||
{
|
||||
ASN1 asn2 = new ASN1(asn[j].Value);
|
||||
this.distinguisedNames[j] = Encoding.UTF8.GetString(asn2[1].Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000320 RID: 800
|
||||
private ClientCertificateType[] certificateTypes;
|
||||
|
||||
// Token: 0x04000321 RID: 801
|
||||
private string[] distinguisedNames;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000AE RID: 174
|
||||
internal class TlsServerFinished : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000687 RID: 1671 RVA: 0x00024840 File Offset: 0x00022A40
|
||||
public TlsServerFinished(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.Finished, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000689 RID: 1673 RVA: 0x00024864 File Offset: 0x00022A64
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Context.HandshakeState = HandshakeState.Finished;
|
||||
}
|
||||
|
||||
// Token: 0x0600068A RID: 1674 RVA: 0x00024878 File Offset: 0x00022A78
|
||||
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);
|
||||
byte[] array2 = base.ReadBytes((int)this.Length);
|
||||
byte[] hash = hashAlgorithm.Hash;
|
||||
if (!HandshakeMessage.Compare(hash, array2))
|
||||
{
|
||||
throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid ServerFinished message received.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600068B RID: 1675 RVA: 0x0002490C File Offset: 0x00022B0C
|
||||
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, "server finished", array3, 12);
|
||||
if (!HandshakeMessage.Compare(array4, array))
|
||||
{
|
||||
throw new TlsException("Invalid ServerFinished message received.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000322 RID: 802
|
||||
private static byte[] Ssl3Marker = new byte[] { 83, 82, 86, 82 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000AF RID: 175
|
||||
internal class TlsServerHello : HandshakeMessage
|
||||
{
|
||||
// Token: 0x0600068C RID: 1676 RVA: 0x0002498C File Offset: 0x00022B8C
|
||||
public TlsServerHello(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.ServerHello, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600068D RID: 1677 RVA: 0x00024998 File Offset: 0x00022B98
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Context.SessionId = this.sessionId;
|
||||
base.Context.ServerRandom = this.random;
|
||||
base.Context.Negotiating.Cipher = this.cipherSuite;
|
||||
base.Context.CompressionMethod = this.compressionMethod;
|
||||
base.Context.ProtocolNegotiated = true;
|
||||
int num = base.Context.ClientRandom.Length;
|
||||
int num2 = base.Context.ServerRandom.Length;
|
||||
int num3 = num + num2;
|
||||
byte[] array = new byte[num3];
|
||||
Buffer.BlockCopy(base.Context.ClientRandom, 0, array, 0, num);
|
||||
Buffer.BlockCopy(base.Context.ServerRandom, 0, array, num, num2);
|
||||
base.Context.RandomCS = array;
|
||||
byte[] array2 = new byte[num3];
|
||||
Buffer.BlockCopy(base.Context.ServerRandom, 0, array2, 0, num2);
|
||||
Buffer.BlockCopy(base.Context.ClientRandom, 0, array2, num2, num);
|
||||
base.Context.RandomSC = array2;
|
||||
}
|
||||
|
||||
// Token: 0x0600068E RID: 1678 RVA: 0x00024A9C File Offset: 0x00022C9C
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x0600068F RID: 1679 RVA: 0x00024AA4 File Offset: 0x00022CA4
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
this.processProtocol(base.ReadInt16());
|
||||
this.random = base.ReadBytes(32);
|
||||
int num = (int)base.ReadByte();
|
||||
if (num > 0)
|
||||
{
|
||||
this.sessionId = base.ReadBytes(num);
|
||||
ClientSessionCache.Add(base.Context.ClientSettings.TargetHost, this.sessionId);
|
||||
base.Context.AbbreviatedHandshake = HandshakeMessage.Compare(this.sessionId, base.Context.SessionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Context.AbbreviatedHandshake = false;
|
||||
}
|
||||
short num2 = base.ReadInt16();
|
||||
if (base.Context.SupportedCiphers.IndexOf(num2) == -1)
|
||||
{
|
||||
throw new TlsException(AlertDescription.InsuficientSecurity, "Invalid cipher suite received from server");
|
||||
}
|
||||
this.cipherSuite = base.Context.SupportedCiphers[num2];
|
||||
this.compressionMethod = (SecurityCompressionType)base.ReadByte();
|
||||
}
|
||||
|
||||
// Token: 0x06000690 RID: 1680 RVA: 0x00024B84 File Offset: 0x00022D84
|
||||
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: 0x04000323 RID: 803
|
||||
private SecurityCompressionType compressionMethod;
|
||||
|
||||
// Token: 0x04000324 RID: 804
|
||||
private byte[] random;
|
||||
|
||||
// Token: 0x04000325 RID: 805
|
||||
private byte[] sessionId;
|
||||
|
||||
// Token: 0x04000326 RID: 806
|
||||
private CipherSuite cipherSuite;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000B0 RID: 176
|
||||
internal class TlsServerHelloDone : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000691 RID: 1681 RVA: 0x00024C18 File Offset: 0x00022E18
|
||||
public TlsServerHelloDone(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.ServerHelloDone, buffer)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000692 RID: 1682 RVA: 0x00024C24 File Offset: 0x00022E24
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000693 RID: 1683 RVA: 0x00024C28 File Offset: 0x00022E28
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake.Client
|
||||
{
|
||||
// Token: 0x020000B1 RID: 177
|
||||
internal class TlsServerKeyExchange : HandshakeMessage
|
||||
{
|
||||
// Token: 0x06000694 RID: 1684 RVA: 0x00024C2C File Offset: 0x00022E2C
|
||||
public TlsServerKeyExchange(Context context, byte[] buffer)
|
||||
: base(context, HandshakeType.ServerKeyExchange, buffer)
|
||||
{
|
||||
this.verifySignature();
|
||||
}
|
||||
|
||||
// Token: 0x06000695 RID: 1685 RVA: 0x00024C40 File Offset: 0x00022E40
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
base.Context.ServerSettings.ServerKeyExchange = true;
|
||||
base.Context.ServerSettings.RsaParameters = this.rsaParams;
|
||||
base.Context.ServerSettings.SignedParams = this.signedParams;
|
||||
}
|
||||
|
||||
// Token: 0x06000696 RID: 1686 RVA: 0x00024C90 File Offset: 0x00022E90
|
||||
protected override void ProcessAsSsl3()
|
||||
{
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x06000697 RID: 1687 RVA: 0x00024C98 File Offset: 0x00022E98
|
||||
protected override void ProcessAsTls1()
|
||||
{
|
||||
this.rsaParams = default(RSAParameters);
|
||||
this.rsaParams.Modulus = base.ReadBytes((int)base.ReadInt16());
|
||||
this.rsaParams.Exponent = base.ReadBytes((int)base.ReadInt16());
|
||||
this.signedParams = base.ReadBytes((int)base.ReadInt16());
|
||||
}
|
||||
|
||||
// Token: 0x06000698 RID: 1688 RVA: 0x00024CF4 File Offset: 0x00022EF4
|
||||
private void verifySignature()
|
||||
{
|
||||
MD5SHA1 md5SHA = new MD5SHA1();
|
||||
int num = this.rsaParams.Modulus.Length + this.rsaParams.Exponent.Length + 4;
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(base.Context.RandomCS);
|
||||
tlsStream.Write(base.ToArray(), 0, num);
|
||||
md5SHA.ComputeHash(tlsStream.ToArray());
|
||||
tlsStream.Reset();
|
||||
if (!md5SHA.VerifySignature(base.Context.ServerSettings.CertificateRSA, this.signedParams))
|
||||
{
|
||||
throw new TlsException(AlertDescription.DecodeError, "Data was not signed with the server certificate.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000327 RID: 807
|
||||
private RSAParameters rsaParams;
|
||||
|
||||
// Token: 0x04000328 RID: 808
|
||||
private byte[] signedParams;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake
|
||||
{
|
||||
// Token: 0x020000A4 RID: 164
|
||||
[Serializable]
|
||||
internal enum ClientCertificateType
|
||||
{
|
||||
// Token: 0x04000306 RID: 774
|
||||
RSA = 1,
|
||||
// Token: 0x04000307 RID: 775
|
||||
DSS,
|
||||
// Token: 0x04000308 RID: 776
|
||||
RSAFixed,
|
||||
// Token: 0x04000309 RID: 777
|
||||
DSSFixed,
|
||||
// Token: 0x0400030A RID: 778
|
||||
Unknown = 255
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake
|
||||
{
|
||||
// Token: 0x020000A5 RID: 165
|
||||
internal abstract class HandshakeMessage : TlsStream
|
||||
{
|
||||
// Token: 0x06000652 RID: 1618 RVA: 0x00023558 File Offset: 0x00021758
|
||||
public HandshakeMessage(Context context, HandshakeType handshakeType)
|
||||
: this(context, handshakeType, ContentType.Handshake)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000653 RID: 1619 RVA: 0x00023564 File Offset: 0x00021764
|
||||
public HandshakeMessage(Context context, HandshakeType handshakeType, ContentType contentType)
|
||||
{
|
||||
this.context = context;
|
||||
this.handshakeType = handshakeType;
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
// Token: 0x06000654 RID: 1620 RVA: 0x00023584 File Offset: 0x00021784
|
||||
public HandshakeMessage(Context context, HandshakeType handshakeType, byte[] data)
|
||||
: base(data)
|
||||
{
|
||||
this.context = context;
|
||||
this.handshakeType = handshakeType;
|
||||
}
|
||||
|
||||
// Token: 0x170001A0 RID: 416
|
||||
// (get) Token: 0x06000655 RID: 1621 RVA: 0x0002359C File Offset: 0x0002179C
|
||||
public Context Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.context;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A1 RID: 417
|
||||
// (get) Token: 0x06000656 RID: 1622 RVA: 0x000235A4 File Offset: 0x000217A4
|
||||
public HandshakeType HandshakeType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.handshakeType;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170001A2 RID: 418
|
||||
// (get) Token: 0x06000657 RID: 1623 RVA: 0x000235AC File Offset: 0x000217AC
|
||||
public ContentType ContentType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.contentType;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000658 RID: 1624
|
||||
protected abstract void ProcessAsTls1();
|
||||
|
||||
// Token: 0x06000659 RID: 1625
|
||||
protected abstract void ProcessAsSsl3();
|
||||
|
||||
// Token: 0x0600065A RID: 1626 RVA: 0x000235B4 File Offset: 0x000217B4
|
||||
public void Process()
|
||||
{
|
||||
SecurityProtocolType securityProtocol = this.Context.SecurityProtocol;
|
||||
if (securityProtocol != SecurityProtocolType.Default)
|
||||
{
|
||||
if (securityProtocol != SecurityProtocolType.Ssl2)
|
||||
{
|
||||
if (securityProtocol == SecurityProtocolType.Ssl3)
|
||||
{
|
||||
this.ProcessAsSsl3();
|
||||
return;
|
||||
}
|
||||
if (securityProtocol == SecurityProtocolType.Tls)
|
||||
{
|
||||
goto IL_37;
|
||||
}
|
||||
}
|
||||
throw new NotSupportedException("Unsupported security protocol type");
|
||||
}
|
||||
IL_37:
|
||||
this.ProcessAsTls1();
|
||||
}
|
||||
|
||||
// Token: 0x0600065B RID: 1627 RVA: 0x0002361C File Offset: 0x0002181C
|
||||
public virtual void Update()
|
||||
{
|
||||
if (this.CanWrite)
|
||||
{
|
||||
if (this.cache == null)
|
||||
{
|
||||
this.cache = this.EncodeMessage();
|
||||
}
|
||||
this.context.HandshakeMessages.Write(this.cache);
|
||||
base.Reset();
|
||||
this.cache = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600065C RID: 1628 RVA: 0x00023670 File Offset: 0x00021870
|
||||
public virtual byte[] EncodeMessage()
|
||||
{
|
||||
this.cache = null;
|
||||
if (this.CanWrite)
|
||||
{
|
||||
byte[] array = base.ToArray();
|
||||
int num = array.Length;
|
||||
this.cache = new byte[4 + num];
|
||||
this.cache[0] = (byte)this.HandshakeType;
|
||||
this.cache[1] = (byte)(num >> 16);
|
||||
this.cache[2] = (byte)(num >> 8);
|
||||
this.cache[3] = (byte)num;
|
||||
Buffer.BlockCopy(array, 0, this.cache, 4, num);
|
||||
}
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
// Token: 0x0600065D RID: 1629 RVA: 0x000236F0 File Offset: 0x000218F0
|
||||
public static bool Compare(byte[] buffer1, byte[] buffer2)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
// Token: 0x0400030B RID: 779
|
||||
private Context context;
|
||||
|
||||
// Token: 0x0400030C RID: 780
|
||||
private HandshakeType handshakeType;
|
||||
|
||||
// Token: 0x0400030D RID: 781
|
||||
private ContentType contentType;
|
||||
|
||||
// Token: 0x0400030E RID: 782
|
||||
private byte[] cache;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls.Handshake
|
||||
{
|
||||
// Token: 0x020000A6 RID: 166
|
||||
[Serializable]
|
||||
internal enum HandshakeType : byte
|
||||
{
|
||||
// Token: 0x04000310 RID: 784
|
||||
HelloRequest,
|
||||
// Token: 0x04000311 RID: 785
|
||||
ClientHello,
|
||||
// Token: 0x04000312 RID: 786
|
||||
ServerHello,
|
||||
// Token: 0x04000313 RID: 787
|
||||
Certificate = 11,
|
||||
// Token: 0x04000314 RID: 788
|
||||
ServerKeyExchange,
|
||||
// Token: 0x04000315 RID: 789
|
||||
CertificateRequest,
|
||||
// Token: 0x04000316 RID: 790
|
||||
ServerHelloDone,
|
||||
// Token: 0x04000317 RID: 791
|
||||
CertificateVerify,
|
||||
// Token: 0x04000318 RID: 792
|
||||
ClientKeyExchange,
|
||||
// Token: 0x04000319 RID: 793
|
||||
Finished = 20,
|
||||
// Token: 0x0400031A RID: 794
|
||||
None = 255
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200008B RID: 139
|
||||
[Serializable]
|
||||
internal enum HandshakeState
|
||||
{
|
||||
// Token: 0x0400028D RID: 653
|
||||
None,
|
||||
// Token: 0x0400028E RID: 654
|
||||
Started,
|
||||
// Token: 0x0400028F RID: 655
|
||||
Finished
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200008C RID: 140
|
||||
[Serializable]
|
||||
public enum HashAlgorithmType
|
||||
{
|
||||
// Token: 0x04000291 RID: 657
|
||||
Md5,
|
||||
// Token: 0x04000292 RID: 658
|
||||
None,
|
||||
// Token: 0x04000293 RID: 659
|
||||
Sha1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200008D RID: 141
|
||||
internal class HttpsClientStream : SslClientStream
|
||||
{
|
||||
// Token: 0x0600051F RID: 1311 RVA: 0x0001E2E4 File Offset: 0x0001C4E4
|
||||
public HttpsClientStream(Stream stream, X509CertificateCollection clientCertificates, HttpWebRequest request, byte[] buffer)
|
||||
: base(stream, request.Address.Host, false, (SecurityProtocolType)ServicePointManager.SecurityProtocol, clientCertificates)
|
||||
{
|
||||
this._request = request;
|
||||
this._status = 0;
|
||||
if (buffer != null)
|
||||
{
|
||||
base.InputBuffer.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
base.CheckCertRevocationStatus = ServicePointManager.CheckCertificateRevocationList;
|
||||
base.ClientCertSelection += (X509CertificateCollection clientCerts, X509Certificate serverCertificate, string targetHost, X509CertificateCollection serverRequestedCertificates) => (clientCerts != null && clientCerts.Count != 0) ? clientCerts[0] : null;
|
||||
base.PrivateKeySelection += delegate(X509Certificate certificate, string targetHost)
|
||||
{
|
||||
X509Certificate2 x509Certificate = certificate as X509Certificate2;
|
||||
return (x509Certificate != null) ? x509Certificate.PrivateKey : null;
|
||||
};
|
||||
}
|
||||
|
||||
// Token: 0x1700014A RID: 330
|
||||
// (get) Token: 0x06000520 RID: 1312 RVA: 0x0001E384 File Offset: 0x0001C584
|
||||
public bool TrustFailure
|
||||
{
|
||||
get
|
||||
{
|
||||
int status = this._status;
|
||||
return status == -2146762487 || status == -2146762486;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000521 RID: 1313 RVA: 0x0001E3B8 File Offset: 0x0001C5B8
|
||||
internal override bool RaiseServerCertificateValidation(X509Certificate certificate, int[] certificateErrors)
|
||||
{
|
||||
bool flag = certificateErrors.Length > 0;
|
||||
this._status = ((!flag) ? 0 : certificateErrors[0]);
|
||||
if (ServicePointManager.CertificatePolicy != null)
|
||||
{
|
||||
ServicePoint servicePoint = this._request.ServicePoint;
|
||||
if (!ServicePointManager.CertificatePolicy.CheckValidationResult(servicePoint, certificate, this._request, this._status))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
if (this.HaveRemoteValidation2Callback)
|
||||
{
|
||||
return flag;
|
||||
}
|
||||
RemoteCertificateValidationCallback serverCertificateValidationCallback = ServicePointManager.ServerCertificateValidationCallback;
|
||||
if (serverCertificateValidationCallback != null)
|
||||
{
|
||||
SslPolicyErrors sslPolicyErrors = SslPolicyErrors.None;
|
||||
foreach (int num in certificateErrors)
|
||||
{
|
||||
if (num == -2146762490)
|
||||
{
|
||||
sslPolicyErrors |= SslPolicyErrors.RemoteCertificateNotAvailable;
|
||||
}
|
||||
else if (num == -2146762481)
|
||||
{
|
||||
sslPolicyErrors |= SslPolicyErrors.RemoteCertificateNameMismatch;
|
||||
}
|
||||
else
|
||||
{
|
||||
sslPolicyErrors |= SslPolicyErrors.RemoteCertificateChainErrors;
|
||||
}
|
||||
}
|
||||
X509Certificate2 x509Certificate = new X509Certificate2(certificate.GetRawCertData());
|
||||
X509Chain x509Chain = new X509Chain();
|
||||
if (!x509Chain.Build(x509Certificate))
|
||||
{
|
||||
sslPolicyErrors |= SslPolicyErrors.RemoteCertificateChainErrors;
|
||||
}
|
||||
return serverCertificateValidationCallback(this._request, x509Certificate, x509Chain, sslPolicyErrors);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x04000294 RID: 660
|
||||
private HttpWebRequest _request;
|
||||
|
||||
// Token: 0x04000295 RID: 661
|
||||
private int _status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000CE RID: 206
|
||||
// (Invoke) Token: 0x0600071D RID: 1821
|
||||
public delegate AsymmetricAlgorithm PrivateKeySelectionCallback(X509Certificate certificate, string targetHost);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000091 RID: 145
|
||||
internal class RSASslSignatureDeformatter : AsymmetricSignatureDeformatter
|
||||
{
|
||||
// Token: 0x0600055C RID: 1372 RVA: 0x0001F64C File Offset: 0x0001D84C
|
||||
public RSASslSignatureDeformatter()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600055D RID: 1373 RVA: 0x0001F654 File Offset: 0x0001D854
|
||||
public RSASslSignatureDeformatter(AsymmetricAlgorithm key)
|
||||
{
|
||||
this.SetKey(key);
|
||||
}
|
||||
|
||||
// Token: 0x0600055E RID: 1374 RVA: 0x0001F664 File Offset: 0x0001D864
|
||||
public override bool VerifySignature(byte[] rgbHash, byte[] rgbSignature)
|
||||
{
|
||||
if (this.key == null)
|
||||
{
|
||||
throw new CryptographicUnexpectedOperationException("The key is a null reference");
|
||||
}
|
||||
if (this.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 PKCS1.Verify_v15(this.key, this.hash, rgbHash, rgbSignature);
|
||||
}
|
||||
|
||||
// Token: 0x0600055F RID: 1375 RVA: 0x0001F6C4 File Offset: 0x0001D8C4
|
||||
public override void SetHashAlgorithm(string strName)
|
||||
{
|
||||
if (strName != null)
|
||||
{
|
||||
if (RSASslSignatureDeformatter.<>f__switch$map15 == null)
|
||||
{
|
||||
RSASslSignatureDeformatter.<>f__switch$map15 = new Dictionary<string, int>(1) { { "MD5SHA1", 0 } };
|
||||
}
|
||||
int num;
|
||||
if (RSASslSignatureDeformatter.<>f__switch$map15.TryGetValue(strName, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
this.hash = new MD5SHA1();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hash = HashAlgorithm.Create(strName);
|
||||
}
|
||||
|
||||
// Token: 0x06000560 RID: 1376 RVA: 0x0001F73C File Offset: 0x0001D93C
|
||||
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;
|
||||
}
|
||||
|
||||
// Token: 0x040002AB RID: 683
|
||||
private RSA key;
|
||||
|
||||
// Token: 0x040002AC RID: 684
|
||||
private HashAlgorithm hash;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000092 RID: 146
|
||||
internal class RSASslSignatureFormatter : AsymmetricSignatureFormatter
|
||||
{
|
||||
// Token: 0x06000561 RID: 1377 RVA: 0x0001F76C File Offset: 0x0001D96C
|
||||
public RSASslSignatureFormatter()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000562 RID: 1378 RVA: 0x0001F774 File Offset: 0x0001D974
|
||||
public RSASslSignatureFormatter(AsymmetricAlgorithm key)
|
||||
{
|
||||
this.SetKey(key);
|
||||
}
|
||||
|
||||
// Token: 0x06000563 RID: 1379 RVA: 0x0001F784 File Offset: 0x0001D984
|
||||
public override byte[] CreateSignature(byte[] rgbHash)
|
||||
{
|
||||
if (this.key == null)
|
||||
{
|
||||
throw new CryptographicUnexpectedOperationException("The key is a null reference");
|
||||
}
|
||||
if (this.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 PKCS1.Sign_v15(this.key, this.hash, rgbHash);
|
||||
}
|
||||
|
||||
// Token: 0x06000564 RID: 1380 RVA: 0x0001F7E0 File Offset: 0x0001D9E0
|
||||
public override void SetHashAlgorithm(string strName)
|
||||
{
|
||||
if (strName != null)
|
||||
{
|
||||
if (RSASslSignatureFormatter.<>f__switch$map16 == null)
|
||||
{
|
||||
RSASslSignatureFormatter.<>f__switch$map16 = new Dictionary<string, int>(1) { { "MD5SHA1", 0 } };
|
||||
}
|
||||
int num;
|
||||
if (RSASslSignatureFormatter.<>f__switch$map16.TryGetValue(strName, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
this.hash = new MD5SHA1();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.hash = HashAlgorithm.Create(strName);
|
||||
}
|
||||
|
||||
// Token: 0x06000565 RID: 1381 RVA: 0x0001F858 File Offset: 0x0001DA58
|
||||
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;
|
||||
}
|
||||
|
||||
// Token: 0x040002AE RID: 686
|
||||
private RSA key;
|
||||
|
||||
// Token: 0x040002AF RID: 687
|
||||
private HashAlgorithm hash;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,963 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200008E RID: 142
|
||||
internal abstract class RecordProtocol
|
||||
{
|
||||
// Token: 0x06000524 RID: 1316 RVA: 0x0001E514 File Offset: 0x0001C714
|
||||
public RecordProtocol(Stream innerStream, Context context)
|
||||
{
|
||||
this.innerStream = innerStream;
|
||||
this.context = context;
|
||||
this.context.RecordProtocol = this;
|
||||
}
|
||||
|
||||
// Token: 0x1700014B RID: 331
|
||||
// (get) Token: 0x06000526 RID: 1318 RVA: 0x0001E554 File Offset: 0x0001C754
|
||||
// (set) Token: 0x06000527 RID: 1319 RVA: 0x0001E55C File Offset: 0x0001C75C
|
||||
public Context Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.context;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.context = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000528 RID: 1320 RVA: 0x0001E568 File Offset: 0x0001C768
|
||||
public virtual void SendRecord(HandshakeType type)
|
||||
{
|
||||
IAsyncResult asyncResult = this.BeginSendRecord(type, null, null);
|
||||
this.EndSendRecord(asyncResult);
|
||||
}
|
||||
|
||||
// Token: 0x06000529 RID: 1321
|
||||
protected abstract void ProcessHandshakeMessage(TlsStream handMsg);
|
||||
|
||||
// Token: 0x0600052A RID: 1322 RVA: 0x0001E588 File Offset: 0x0001C788
|
||||
protected virtual void ProcessChangeCipherSpec()
|
||||
{
|
||||
Context context = this.Context;
|
||||
context.ReadSequenceNumber = 0UL;
|
||||
if (context is ClientContext)
|
||||
{
|
||||
context.EndSwitchingSecurityParameters(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.StartSwitchingSecurityParameters(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600052B RID: 1323 RVA: 0x0001E5C4 File Offset: 0x0001C7C4
|
||||
public virtual HandshakeMessage GetMessage(HandshakeType type)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
// Token: 0x0600052C RID: 1324 RVA: 0x0001E5CC File Offset: 0x0001C7CC
|
||||
public IAsyncResult BeginReceiveRecord(Stream record, AsyncCallback callback, object state)
|
||||
{
|
||||
if (this.context.ReceivedConnectionEnd)
|
||||
{
|
||||
throw new TlsException(AlertDescription.InternalError, "The session is finished and it's no longer valid.");
|
||||
}
|
||||
RecordProtocol.record_processing.Reset();
|
||||
byte[] array = new byte[1];
|
||||
RecordProtocol.ReceiveRecordAsyncResult receiveRecordAsyncResult = new RecordProtocol.ReceiveRecordAsyncResult(callback, state, array, record);
|
||||
record.BeginRead(receiveRecordAsyncResult.InitialBuffer, 0, receiveRecordAsyncResult.InitialBuffer.Length, new AsyncCallback(this.InternalReceiveRecordCallback), receiveRecordAsyncResult);
|
||||
return receiveRecordAsyncResult;
|
||||
}
|
||||
|
||||
// Token: 0x0600052D RID: 1325 RVA: 0x0001E638 File Offset: 0x0001C838
|
||||
private void InternalReceiveRecordCallback(IAsyncResult asyncResult)
|
||||
{
|
||||
RecordProtocol.ReceiveRecordAsyncResult receiveRecordAsyncResult = asyncResult.AsyncState as RecordProtocol.ReceiveRecordAsyncResult;
|
||||
Stream record = receiveRecordAsyncResult.Record;
|
||||
try
|
||||
{
|
||||
if (receiveRecordAsyncResult.Record.EndRead(asyncResult) == 0)
|
||||
{
|
||||
receiveRecordAsyncResult.SetComplete(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = (int)receiveRecordAsyncResult.InitialBuffer[0];
|
||||
this.context.LastHandshakeMsg = HandshakeType.ClientHello;
|
||||
ContentType contentType = (ContentType)num;
|
||||
byte[] array = this.ReadRecordBuffer(num, record);
|
||||
if (array == null)
|
||||
{
|
||||
receiveRecordAsyncResult.SetComplete(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (contentType != ContentType.Alert || array.Length != 2)
|
||||
{
|
||||
if (this.Context.Read != null && this.Context.Read.Cipher != null)
|
||||
{
|
||||
array = this.decryptRecordFragment(contentType, array);
|
||||
}
|
||||
}
|
||||
ContentType contentType2 = contentType;
|
||||
switch (contentType2)
|
||||
{
|
||||
case ContentType.ChangeCipherSpec:
|
||||
this.ProcessChangeCipherSpec();
|
||||
break;
|
||||
case ContentType.Alert:
|
||||
this.ProcessAlert((AlertLevel)array[0], (AlertDescription)array[1]);
|
||||
if (record.CanSeek)
|
||||
{
|
||||
record.SetLength(0L);
|
||||
}
|
||||
array = null;
|
||||
break;
|
||||
case ContentType.Handshake:
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream(array);
|
||||
while (!tlsStream.EOF)
|
||||
{
|
||||
this.ProcessHandshakeMessage(tlsStream);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ContentType.ApplicationData:
|
||||
break;
|
||||
default:
|
||||
if (contentType2 != (ContentType)128)
|
||||
{
|
||||
throw new TlsException(AlertDescription.UnexpectedMessage, "Unknown record received from server.");
|
||||
}
|
||||
this.context.HandshakeMessages.Write(array);
|
||||
break;
|
||||
}
|
||||
receiveRecordAsyncResult.SetComplete(array);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
receiveRecordAsyncResult.SetComplete(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600052E RID: 1326 RVA: 0x0001E7E4 File Offset: 0x0001C9E4
|
||||
public byte[] EndReceiveRecord(IAsyncResult asyncResult)
|
||||
{
|
||||
RecordProtocol.ReceiveRecordAsyncResult receiveRecordAsyncResult = asyncResult as RecordProtocol.ReceiveRecordAsyncResult;
|
||||
if (receiveRecordAsyncResult == null)
|
||||
{
|
||||
throw new ArgumentException("Either the provided async result is null or was not created by this RecordProtocol.");
|
||||
}
|
||||
if (!receiveRecordAsyncResult.IsCompleted)
|
||||
{
|
||||
receiveRecordAsyncResult.AsyncWaitHandle.WaitOne();
|
||||
}
|
||||
if (receiveRecordAsyncResult.CompletedWithError)
|
||||
{
|
||||
throw receiveRecordAsyncResult.AsyncException;
|
||||
}
|
||||
byte[] resultingBuffer = receiveRecordAsyncResult.ResultingBuffer;
|
||||
RecordProtocol.record_processing.Set();
|
||||
return resultingBuffer;
|
||||
}
|
||||
|
||||
// Token: 0x0600052F RID: 1327 RVA: 0x0001E848 File Offset: 0x0001CA48
|
||||
public byte[] ReceiveRecord(Stream record)
|
||||
{
|
||||
IAsyncResult asyncResult = this.BeginReceiveRecord(record, null, null);
|
||||
return this.EndReceiveRecord(asyncResult);
|
||||
}
|
||||
|
||||
// Token: 0x06000530 RID: 1328 RVA: 0x0001E868 File Offset: 0x0001CA68
|
||||
private byte[] ReadRecordBuffer(int contentType, Stream record)
|
||||
{
|
||||
if (contentType == 128)
|
||||
{
|
||||
return this.ReadClientHelloV2(record);
|
||||
}
|
||||
if (!Enum.IsDefined(typeof(ContentType), (ContentType)contentType))
|
||||
{
|
||||
throw new TlsException(AlertDescription.DecodeError);
|
||||
}
|
||||
return this.ReadStandardRecordBuffer(record);
|
||||
}
|
||||
|
||||
// Token: 0x06000531 RID: 1329 RVA: 0x0001E8BC File Offset: 0x0001CABC
|
||||
private byte[] ReadClientHelloV2(Stream record)
|
||||
{
|
||||
int num = record.ReadByte();
|
||||
if (record.CanSeek && (long)(num + 1) > record.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] array = new byte[num];
|
||||
record.Read(array, 0, num);
|
||||
int num2 = (int)array[0];
|
||||
if (num2 != 1)
|
||||
{
|
||||
throw new TlsException(AlertDescription.DecodeError);
|
||||
}
|
||||
int num3 = ((int)array[1] << 8) | (int)array[2];
|
||||
int num4 = ((int)array[3] << 8) | (int)array[4];
|
||||
int num5 = ((int)array[5] << 8) | (int)array[6];
|
||||
int num6 = ((int)array[7] << 8) | (int)array[8];
|
||||
int num7 = ((num6 <= 32) ? num6 : 32);
|
||||
byte[] array2 = new byte[num4];
|
||||
Buffer.BlockCopy(array, 9, array2, 0, num4);
|
||||
byte[] array3 = new byte[num5];
|
||||
Buffer.BlockCopy(array, 9 + num4, array3, 0, num5);
|
||||
byte[] array4 = new byte[num6];
|
||||
Buffer.BlockCopy(array, 9 + num4 + num5, array4, 0, num6);
|
||||
if (num6 < 16 || num4 == 0 || num4 % 3 != 0)
|
||||
{
|
||||
throw new TlsException(AlertDescription.DecodeError);
|
||||
}
|
||||
if (array3.Length > 0)
|
||||
{
|
||||
this.context.SessionId = array3;
|
||||
}
|
||||
this.Context.ChangeProtocol((short)num3);
|
||||
this.ProcessCipherSpecV2Buffer(this.Context.SecurityProtocol, array2);
|
||||
this.context.ClientRandom = new byte[32];
|
||||
Buffer.BlockCopy(array4, array4.Length - num7, this.context.ClientRandom, 32 - num7, num7);
|
||||
this.context.LastHandshakeMsg = HandshakeType.ClientHello;
|
||||
this.context.ProtocolNegotiated = true;
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000532 RID: 1330 RVA: 0x0001EA40 File Offset: 0x0001CC40
|
||||
private byte[] ReadStandardRecordBuffer(Stream record)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
if (record.Read(array, 0, 4) != 4)
|
||||
{
|
||||
throw new TlsException("buffer underrun");
|
||||
}
|
||||
short num = (short)(((int)array[0] << 8) | (int)array[1]);
|
||||
short num2 = (short)(((int)array[2] << 8) | (int)array[3]);
|
||||
if (record.CanSeek && (long)(num2 + 5) > record.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int num3 = 0;
|
||||
byte[] array2 = new byte[(int)num2];
|
||||
while (num3 != (int)num2)
|
||||
{
|
||||
int num4 = record.Read(array2, num3, array2.Length - num3);
|
||||
if (num4 == 0)
|
||||
{
|
||||
throw new TlsException(AlertDescription.CloseNotify, "Received 0 bytes from stream. It must be closed.");
|
||||
}
|
||||
num3 += num4;
|
||||
}
|
||||
if (num != this.context.Protocol && this.context.ProtocolNegotiated)
|
||||
{
|
||||
throw new TlsException(AlertDescription.ProtocolVersion, "Invalid protocol version on message received");
|
||||
}
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x06000533 RID: 1331 RVA: 0x0001EB10 File Offset: 0x0001CD10
|
||||
private void ProcessAlert(AlertLevel alertLevel, AlertDescription alertDesc)
|
||||
{
|
||||
if (alertLevel != AlertLevel.Warning)
|
||||
{
|
||||
if (alertLevel == AlertLevel.Fatal)
|
||||
{
|
||||
throw new TlsException(alertLevel, alertDesc);
|
||||
}
|
||||
}
|
||||
if (alertDesc == AlertDescription.CloseNotify)
|
||||
{
|
||||
this.context.ReceivedConnectionEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000534 RID: 1332 RVA: 0x0001EB60 File Offset: 0x0001CD60
|
||||
public void SendAlert(AlertDescription description)
|
||||
{
|
||||
this.SendAlert(new Alert(description));
|
||||
}
|
||||
|
||||
// Token: 0x06000535 RID: 1333 RVA: 0x0001EB70 File Offset: 0x0001CD70
|
||||
public void SendAlert(AlertLevel level, AlertDescription description)
|
||||
{
|
||||
this.SendAlert(new Alert(level, description));
|
||||
}
|
||||
|
||||
// Token: 0x06000536 RID: 1334 RVA: 0x0001EB80 File Offset: 0x0001CD80
|
||||
public void SendAlert(Alert alert)
|
||||
{
|
||||
AlertLevel alertLevel;
|
||||
AlertDescription alertDescription;
|
||||
bool flag;
|
||||
if (alert == null)
|
||||
{
|
||||
alertLevel = AlertLevel.Fatal;
|
||||
alertDescription = AlertDescription.InternalError;
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
alertLevel = alert.Level;
|
||||
alertDescription = alert.Description;
|
||||
flag = alert.IsCloseNotify;
|
||||
}
|
||||
this.SendRecord(ContentType.Alert, new byte[]
|
||||
{
|
||||
(byte)alertLevel,
|
||||
(byte)alertDescription
|
||||
});
|
||||
if (flag)
|
||||
{
|
||||
this.context.SentConnectionEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000537 RID: 1335 RVA: 0x0001EBDC File Offset: 0x0001CDDC
|
||||
public void SendChangeCipherSpec()
|
||||
{
|
||||
this.SendRecord(ContentType.ChangeCipherSpec, new byte[] { 1 });
|
||||
Context context = this.context;
|
||||
context.WriteSequenceNumber = 0UL;
|
||||
if (context is ClientContext)
|
||||
{
|
||||
context.StartSwitchingSecurityParameters(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.EndSwitchingSecurityParameters(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000538 RID: 1336 RVA: 0x0001EC28 File Offset: 0x0001CE28
|
||||
public IAsyncResult BeginSendRecord(HandshakeType handshakeType, AsyncCallback callback, object state)
|
||||
{
|
||||
HandshakeMessage message = this.GetMessage(handshakeType);
|
||||
message.Process();
|
||||
RecordProtocol.SendRecordAsyncResult sendRecordAsyncResult = new RecordProtocol.SendRecordAsyncResult(callback, state, message);
|
||||
this.BeginSendRecord(message.ContentType, message.EncodeMessage(), new AsyncCallback(this.InternalSendRecordCallback), sendRecordAsyncResult);
|
||||
return sendRecordAsyncResult;
|
||||
}
|
||||
|
||||
// Token: 0x06000539 RID: 1337 RVA: 0x0001EC70 File Offset: 0x0001CE70
|
||||
private void InternalSendRecordCallback(IAsyncResult ar)
|
||||
{
|
||||
RecordProtocol.SendRecordAsyncResult sendRecordAsyncResult = ar.AsyncState as RecordProtocol.SendRecordAsyncResult;
|
||||
try
|
||||
{
|
||||
this.EndSendRecord(ar);
|
||||
sendRecordAsyncResult.Message.Update();
|
||||
sendRecordAsyncResult.Message.Reset();
|
||||
sendRecordAsyncResult.SetComplete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sendRecordAsyncResult.SetComplete(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600053A RID: 1338 RVA: 0x0001ECDC File Offset: 0x0001CEDC
|
||||
public IAsyncResult BeginSendRecord(ContentType contentType, byte[] recordData, AsyncCallback callback, object state)
|
||||
{
|
||||
if (this.context.SentConnectionEnd)
|
||||
{
|
||||
throw new TlsException(AlertDescription.InternalError, "The session is finished and it's no longer valid.");
|
||||
}
|
||||
byte[] array = this.EncodeRecord(contentType, recordData);
|
||||
return this.innerStream.BeginWrite(array, 0, array.Length, callback, state);
|
||||
}
|
||||
|
||||
// Token: 0x0600053B RID: 1339 RVA: 0x0001ED24 File Offset: 0x0001CF24
|
||||
public void EndSendRecord(IAsyncResult asyncResult)
|
||||
{
|
||||
if (asyncResult is RecordProtocol.SendRecordAsyncResult)
|
||||
{
|
||||
RecordProtocol.SendRecordAsyncResult sendRecordAsyncResult = asyncResult as RecordProtocol.SendRecordAsyncResult;
|
||||
if (!sendRecordAsyncResult.IsCompleted)
|
||||
{
|
||||
sendRecordAsyncResult.AsyncWaitHandle.WaitOne();
|
||||
}
|
||||
if (sendRecordAsyncResult.CompletedWithError)
|
||||
{
|
||||
throw sendRecordAsyncResult.AsyncException;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.innerStream.EndWrite(asyncResult);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600053C RID: 1340 RVA: 0x0001ED80 File Offset: 0x0001CF80
|
||||
public void SendRecord(ContentType contentType, byte[] recordData)
|
||||
{
|
||||
IAsyncResult asyncResult = this.BeginSendRecord(contentType, recordData, null, null);
|
||||
this.EndSendRecord(asyncResult);
|
||||
}
|
||||
|
||||
// Token: 0x0600053D RID: 1341 RVA: 0x0001EDA0 File Offset: 0x0001CFA0
|
||||
public byte[] EncodeRecord(ContentType contentType, byte[] recordData)
|
||||
{
|
||||
return this.EncodeRecord(contentType, recordData, 0, recordData.Length);
|
||||
}
|
||||
|
||||
// Token: 0x0600053E RID: 1342 RVA: 0x0001EDB0 File Offset: 0x0001CFB0
|
||||
public byte[] EncodeRecord(ContentType contentType, byte[] recordData, int offset, int count)
|
||||
{
|
||||
if (this.context.SentConnectionEnd)
|
||||
{
|
||||
throw new TlsException(AlertDescription.InternalError, "The session is finished and it's no longer valid.");
|
||||
}
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
short num;
|
||||
for (int i = offset; i < offset + count; i += (int)num)
|
||||
{
|
||||
if (count + offset - i > 16384)
|
||||
{
|
||||
num = 16384;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = (short)(count + offset - i);
|
||||
}
|
||||
byte[] array = new byte[(int)num];
|
||||
Buffer.BlockCopy(recordData, i, array, 0, (int)num);
|
||||
if (this.Context.Write != null && this.Context.Write.Cipher != null)
|
||||
{
|
||||
array = this.encryptRecordFragment(contentType, array);
|
||||
}
|
||||
tlsStream.Write((byte)contentType);
|
||||
tlsStream.Write(this.context.Protocol);
|
||||
tlsStream.Write((short)array.Length);
|
||||
tlsStream.Write(array);
|
||||
}
|
||||
return tlsStream.ToArray();
|
||||
}
|
||||
|
||||
// Token: 0x0600053F RID: 1343 RVA: 0x0001EE88 File Offset: 0x0001D088
|
||||
private byte[] encryptRecordFragment(ContentType contentType, byte[] fragment)
|
||||
{
|
||||
byte[] array;
|
||||
if (this.Context is ClientContext)
|
||||
{
|
||||
array = this.context.Write.Cipher.ComputeClientRecordMAC(contentType, fragment);
|
||||
}
|
||||
else
|
||||
{
|
||||
array = this.context.Write.Cipher.ComputeServerRecordMAC(contentType, fragment);
|
||||
}
|
||||
byte[] array2 = this.context.Write.Cipher.EncryptRecord(fragment, array);
|
||||
this.context.WriteSequenceNumber += 1UL;
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x06000540 RID: 1344 RVA: 0x0001EF0C File Offset: 0x0001D10C
|
||||
private byte[] decryptRecordFragment(ContentType contentType, byte[] fragment)
|
||||
{
|
||||
byte[] array = null;
|
||||
byte[] array2 = null;
|
||||
try
|
||||
{
|
||||
this.context.Read.Cipher.DecryptRecord(fragment, out array, out array2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (this.context is ServerContext)
|
||||
{
|
||||
this.Context.RecordProtocol.SendAlert(AlertDescription.DecryptionFailed);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
byte[] array3;
|
||||
if (this.Context is ClientContext)
|
||||
{
|
||||
array3 = this.context.Read.Cipher.ComputeServerRecordMAC(contentType, array);
|
||||
}
|
||||
else
|
||||
{
|
||||
array3 = this.context.Read.Cipher.ComputeClientRecordMAC(contentType, array);
|
||||
}
|
||||
if (!this.Compare(array3, array2))
|
||||
{
|
||||
throw new TlsException(AlertDescription.BadRecordMAC, "Bad record MAC");
|
||||
}
|
||||
this.context.ReadSequenceNumber += 1UL;
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000541 RID: 1345 RVA: 0x0001EFF8 File Offset: 0x0001D1F8
|
||||
private bool Compare(byte[] array1, byte[] array2)
|
||||
{
|
||||
if (array1 == null)
|
||||
{
|
||||
return array2 == null;
|
||||
}
|
||||
if (array2 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (array1.Length != array2.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < array1.Length; i++)
|
||||
{
|
||||
if (array1[i] != array2[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000542 RID: 1346 RVA: 0x0001F048 File Offset: 0x0001D248
|
||||
private void ProcessCipherSpecV2Buffer(SecurityProtocolType protocol, byte[] buffer)
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream(buffer);
|
||||
string text = ((protocol != SecurityProtocolType.Ssl3) ? "TLS_" : "SSL_");
|
||||
while (tlsStream.Position < tlsStream.Length)
|
||||
{
|
||||
byte b = tlsStream.ReadByte();
|
||||
if (b == 0)
|
||||
{
|
||||
short num = tlsStream.ReadInt16();
|
||||
int num2 = this.Context.SupportedCiphers.IndexOf(num);
|
||||
if (num2 != -1)
|
||||
{
|
||||
this.Context.Negotiating.Cipher = this.Context.SupportedCiphers[num2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] array = new byte[2];
|
||||
tlsStream.Read(array, 0, array.Length);
|
||||
int num3 = ((int)(b & byte.MaxValue) << 16) | ((int)(array[0] & byte.MaxValue) << 8) | (int)(array[1] & byte.MaxValue);
|
||||
CipherSuite cipherSuite = this.MapV2CipherCode(text, num3);
|
||||
if (cipherSuite != null)
|
||||
{
|
||||
this.Context.Negotiating.Cipher = cipherSuite;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.Context.Negotiating == null)
|
||||
{
|
||||
throw new TlsException(AlertDescription.InsuficientSecurity, "Insuficient Security");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000543 RID: 1347 RVA: 0x0001F168 File Offset: 0x0001D368
|
||||
private CipherSuite MapV2CipherCode(string prefix, int code)
|
||||
{
|
||||
CipherSuite cipherSuite;
|
||||
try
|
||||
{
|
||||
if (code != 65664)
|
||||
{
|
||||
if (code != 131200)
|
||||
{
|
||||
if (code != 196736)
|
||||
{
|
||||
if (code != 262272)
|
||||
{
|
||||
if (code != 327808)
|
||||
{
|
||||
if (code != 393280)
|
||||
{
|
||||
if (code != 458944)
|
||||
{
|
||||
cipherSuite = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = this.Context.SupportedCiphers[prefix + "RSA_EXPORT_WITH_RC2_CBC_40_MD5"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = this.Context.SupportedCiphers[prefix + "RSA_EXPORT_WITH_RC2_CBC_40_MD5"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = this.Context.SupportedCiphers[prefix + "RSA_EXPORT_WITH_RC4_40_MD5"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cipherSuite = this.Context.SupportedCiphers[prefix + "RSA_WITH_RC4_128_MD5"];
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
cipherSuite = null;
|
||||
}
|
||||
return cipherSuite;
|
||||
}
|
||||
|
||||
// Token: 0x04000298 RID: 664
|
||||
private static ManualResetEvent record_processing = new ManualResetEvent(true);
|
||||
|
||||
// Token: 0x04000299 RID: 665
|
||||
protected Stream innerStream;
|
||||
|
||||
// Token: 0x0400029A RID: 666
|
||||
protected Context context;
|
||||
|
||||
// Token: 0x0200008F RID: 143
|
||||
private class ReceiveRecordAsyncResult : IAsyncResult
|
||||
{
|
||||
// Token: 0x06000544 RID: 1348 RVA: 0x0001F298 File Offset: 0x0001D498
|
||||
public ReceiveRecordAsyncResult(AsyncCallback userCallback, object userState, byte[] initialBuffer, Stream record)
|
||||
{
|
||||
this._userCallback = userCallback;
|
||||
this._userState = userState;
|
||||
this._initialBuffer = initialBuffer;
|
||||
this._record = record;
|
||||
}
|
||||
|
||||
// Token: 0x1700014C RID: 332
|
||||
// (get) Token: 0x06000545 RID: 1349 RVA: 0x0001F2D4 File Offset: 0x0001D4D4
|
||||
public Stream Record
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._record;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014D RID: 333
|
||||
// (get) Token: 0x06000546 RID: 1350 RVA: 0x0001F2DC File Offset: 0x0001D4DC
|
||||
public byte[] ResultingBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._resultingBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014E RID: 334
|
||||
// (get) Token: 0x06000547 RID: 1351 RVA: 0x0001F2E4 File Offset: 0x0001D4E4
|
||||
public byte[] InitialBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._initialBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014F RID: 335
|
||||
// (get) Token: 0x06000548 RID: 1352 RVA: 0x0001F2EC File Offset: 0x0001D4EC
|
||||
public object AsyncState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._userState;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000150 RID: 336
|
||||
// (get) Token: 0x06000549 RID: 1353 RVA: 0x0001F2F4 File Offset: 0x0001D4F4
|
||||
public Exception AsyncException
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._asyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000151 RID: 337
|
||||
// (get) Token: 0x0600054A RID: 1354 RVA: 0x0001F2FC File Offset: 0x0001D4FC
|
||||
public bool CompletedWithError
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.IsCompleted && null != this._asyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000152 RID: 338
|
||||
// (get) Token: 0x0600054B RID: 1355 RVA: 0x0001F318 File Offset: 0x0001D518
|
||||
public WaitHandle AsyncWaitHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = this.locker;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.handle == null)
|
||||
{
|
||||
this.handle = new ManualResetEvent(this.completed);
|
||||
}
|
||||
}
|
||||
return this.handle;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000153 RID: 339
|
||||
// (get) Token: 0x0600054C RID: 1356 RVA: 0x0001F37C File Offset: 0x0001D57C
|
||||
public bool CompletedSynchronously
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000154 RID: 340
|
||||
// (get) Token: 0x0600054D RID: 1357 RVA: 0x0001F380 File Offset: 0x0001D580
|
||||
public bool IsCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = this.locker;
|
||||
bool flag;
|
||||
lock (obj)
|
||||
{
|
||||
flag = this.completed;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600054E RID: 1358 RVA: 0x0001F3D0 File Offset: 0x0001D5D0
|
||||
private void SetComplete(Exception ex, byte[] resultingBuffer)
|
||||
{
|
||||
object obj = this.locker;
|
||||
lock (obj)
|
||||
{
|
||||
if (!this.completed)
|
||||
{
|
||||
this.completed = true;
|
||||
this._asyncException = ex;
|
||||
this._resultingBuffer = resultingBuffer;
|
||||
if (this.handle != null)
|
||||
{
|
||||
this.handle.Set();
|
||||
}
|
||||
if (this._userCallback != null)
|
||||
{
|
||||
this._userCallback.BeginInvoke(this, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600054F RID: 1359 RVA: 0x0001F468 File Offset: 0x0001D668
|
||||
public void SetComplete(Exception ex)
|
||||
{
|
||||
this.SetComplete(ex, null);
|
||||
}
|
||||
|
||||
// Token: 0x06000550 RID: 1360 RVA: 0x0001F474 File Offset: 0x0001D674
|
||||
public void SetComplete(byte[] resultingBuffer)
|
||||
{
|
||||
this.SetComplete(null, resultingBuffer);
|
||||
}
|
||||
|
||||
// Token: 0x06000551 RID: 1361 RVA: 0x0001F480 File Offset: 0x0001D680
|
||||
public void SetComplete()
|
||||
{
|
||||
this.SetComplete(null, null);
|
||||
}
|
||||
|
||||
// Token: 0x0400029B RID: 667
|
||||
private object locker = new object();
|
||||
|
||||
// Token: 0x0400029C RID: 668
|
||||
private AsyncCallback _userCallback;
|
||||
|
||||
// Token: 0x0400029D RID: 669
|
||||
private object _userState;
|
||||
|
||||
// Token: 0x0400029E RID: 670
|
||||
private Exception _asyncException;
|
||||
|
||||
// Token: 0x0400029F RID: 671
|
||||
private ManualResetEvent handle;
|
||||
|
||||
// Token: 0x040002A0 RID: 672
|
||||
private byte[] _resultingBuffer;
|
||||
|
||||
// Token: 0x040002A1 RID: 673
|
||||
private Stream _record;
|
||||
|
||||
// Token: 0x040002A2 RID: 674
|
||||
private bool completed;
|
||||
|
||||
// Token: 0x040002A3 RID: 675
|
||||
private byte[] _initialBuffer;
|
||||
}
|
||||
|
||||
// Token: 0x02000090 RID: 144
|
||||
private class SendRecordAsyncResult : IAsyncResult
|
||||
{
|
||||
// Token: 0x06000552 RID: 1362 RVA: 0x0001F48C File Offset: 0x0001D68C
|
||||
public SendRecordAsyncResult(AsyncCallback userCallback, object userState, HandshakeMessage message)
|
||||
{
|
||||
this._userCallback = userCallback;
|
||||
this._userState = userState;
|
||||
this._message = message;
|
||||
}
|
||||
|
||||
// Token: 0x17000155 RID: 341
|
||||
// (get) Token: 0x06000553 RID: 1363 RVA: 0x0001F4C0 File Offset: 0x0001D6C0
|
||||
public HandshakeMessage Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._message;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000156 RID: 342
|
||||
// (get) Token: 0x06000554 RID: 1364 RVA: 0x0001F4C8 File Offset: 0x0001D6C8
|
||||
public object AsyncState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._userState;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000157 RID: 343
|
||||
// (get) Token: 0x06000555 RID: 1365 RVA: 0x0001F4D0 File Offset: 0x0001D6D0
|
||||
public Exception AsyncException
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._asyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000158 RID: 344
|
||||
// (get) Token: 0x06000556 RID: 1366 RVA: 0x0001F4D8 File Offset: 0x0001D6D8
|
||||
public bool CompletedWithError
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.IsCompleted && null != this._asyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000159 RID: 345
|
||||
// (get) Token: 0x06000557 RID: 1367 RVA: 0x0001F4F4 File Offset: 0x0001D6F4
|
||||
public WaitHandle AsyncWaitHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = this.locker;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.handle == null)
|
||||
{
|
||||
this.handle = new ManualResetEvent(this.completed);
|
||||
}
|
||||
}
|
||||
return this.handle;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015A RID: 346
|
||||
// (get) Token: 0x06000558 RID: 1368 RVA: 0x0001F558 File Offset: 0x0001D758
|
||||
public bool CompletedSynchronously
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015B RID: 347
|
||||
// (get) Token: 0x06000559 RID: 1369 RVA: 0x0001F55C File Offset: 0x0001D75C
|
||||
public bool IsCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = this.locker;
|
||||
bool flag;
|
||||
lock (obj)
|
||||
{
|
||||
flag = this.completed;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600055A RID: 1370 RVA: 0x0001F5AC File Offset: 0x0001D7AC
|
||||
public void SetComplete(Exception ex)
|
||||
{
|
||||
object obj = this.locker;
|
||||
lock (obj)
|
||||
{
|
||||
if (!this.completed)
|
||||
{
|
||||
this.completed = true;
|
||||
if (this.handle != null)
|
||||
{
|
||||
this.handle.Set();
|
||||
}
|
||||
if (this._userCallback != null)
|
||||
{
|
||||
this._userCallback.BeginInvoke(this, null, null);
|
||||
}
|
||||
this._asyncException = ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600055B RID: 1371 RVA: 0x0001F640 File Offset: 0x0001D840
|
||||
public void SetComplete()
|
||||
{
|
||||
this.SetComplete(null);
|
||||
}
|
||||
|
||||
// Token: 0x040002A4 RID: 676
|
||||
private object locker = new object();
|
||||
|
||||
// Token: 0x040002A5 RID: 677
|
||||
private AsyncCallback _userCallback;
|
||||
|
||||
// Token: 0x040002A6 RID: 678
|
||||
private object _userState;
|
||||
|
||||
// Token: 0x040002A7 RID: 679
|
||||
private Exception _asyncException;
|
||||
|
||||
// Token: 0x040002A8 RID: 680
|
||||
private ManualResetEvent handle;
|
||||
|
||||
// Token: 0x040002A9 RID: 681
|
||||
private HandshakeMessage _message;
|
||||
|
||||
// Token: 0x040002AA RID: 682
|
||||
private bool completed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000093 RID: 147
|
||||
public enum SecurityCompressionType
|
||||
{
|
||||
// Token: 0x040002B2 RID: 690
|
||||
None,
|
||||
// Token: 0x040002B3 RID: 691
|
||||
Zlib
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000094 RID: 148
|
||||
internal class SecurityParameters
|
||||
{
|
||||
// Token: 0x1700015C RID: 348
|
||||
// (get) Token: 0x06000567 RID: 1383 RVA: 0x0001F890 File Offset: 0x0001DA90
|
||||
// (set) Token: 0x06000568 RID: 1384 RVA: 0x0001F898 File Offset: 0x0001DA98
|
||||
public CipherSuite Cipher
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cipher;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cipher = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015D RID: 349
|
||||
// (get) Token: 0x06000569 RID: 1385 RVA: 0x0001F8A4 File Offset: 0x0001DAA4
|
||||
// (set) Token: 0x0600056A RID: 1386 RVA: 0x0001F8AC File Offset: 0x0001DAAC
|
||||
public byte[] ClientWriteMAC
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientWriteMAC;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.clientWriteMAC = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015E RID: 350
|
||||
// (get) Token: 0x0600056B RID: 1387 RVA: 0x0001F8B8 File Offset: 0x0001DAB8
|
||||
// (set) Token: 0x0600056C RID: 1388 RVA: 0x0001F8C0 File Offset: 0x0001DAC0
|
||||
public byte[] ServerWriteMAC
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverWriteMAC;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.serverWriteMAC = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600056D RID: 1389 RVA: 0x0001F8CC File Offset: 0x0001DACC
|
||||
public void Clear()
|
||||
{
|
||||
this.cipher = null;
|
||||
}
|
||||
|
||||
// Token: 0x040002B4 RID: 692
|
||||
private CipherSuite cipher;
|
||||
|
||||
// Token: 0x040002B5 RID: 693
|
||||
private byte[] clientWriteMAC;
|
||||
|
||||
// Token: 0x040002B6 RID: 694
|
||||
private byte[] serverWriteMAC;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000095 RID: 149
|
||||
[Flags]
|
||||
[Serializable]
|
||||
public enum SecurityProtocolType
|
||||
{
|
||||
// Token: 0x040002B8 RID: 696
|
||||
Default = -1073741824,
|
||||
// Token: 0x040002B9 RID: 697
|
||||
Ssl2 = 12,
|
||||
// Token: 0x040002BA RID: 698
|
||||
Ssl3 = 48,
|
||||
// Token: 0x040002BB RID: 699
|
||||
Tls = 192
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000096 RID: 150
|
||||
internal class ServerContext : Context
|
||||
{
|
||||
// Token: 0x0600056E RID: 1390 RVA: 0x0001F8D8 File Offset: 0x0001DAD8
|
||||
public ServerContext(SslServerStream stream, SecurityProtocolType securityProtocolType, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool requestClientCertificate)
|
||||
: base(securityProtocolType)
|
||||
{
|
||||
this.sslStream = stream;
|
||||
this.clientCertificateRequired = clientCertificateRequired;
|
||||
this.request_client_certificate = requestClientCertificate;
|
||||
Mono.Security.X509.X509Certificate x509Certificate = new Mono.Security.X509.X509Certificate(serverCertificate.GetRawCertData());
|
||||
base.ServerSettings.Certificates = new Mono.Security.X509.X509CertificateCollection();
|
||||
base.ServerSettings.Certificates.Add(x509Certificate);
|
||||
base.ServerSettings.UpdateCertificateRSA();
|
||||
base.ServerSettings.CertificateTypes = new ClientCertificateType[1];
|
||||
base.ServerSettings.CertificateTypes[0] = ClientCertificateType.RSA;
|
||||
Mono.Security.X509.X509CertificateCollection trustedRootCertificates = X509StoreManager.TrustedRootCertificates;
|
||||
string[] array = new string[trustedRootCertificates.Count];
|
||||
int num = 0;
|
||||
foreach (Mono.Security.X509.X509Certificate x509Certificate2 in trustedRootCertificates)
|
||||
{
|
||||
array[num++] = x509Certificate2.IssuerName;
|
||||
}
|
||||
base.ServerSettings.DistinguisedNames = array;
|
||||
}
|
||||
|
||||
// Token: 0x1700015F RID: 351
|
||||
// (get) Token: 0x0600056F RID: 1391 RVA: 0x0001F9E4 File Offset: 0x0001DBE4
|
||||
public SslServerStream SslStream
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sslStream;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000160 RID: 352
|
||||
// (get) Token: 0x06000570 RID: 1392 RVA: 0x0001F9EC File Offset: 0x0001DBEC
|
||||
public bool ClientCertificateRequired
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientCertificateRequired;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000161 RID: 353
|
||||
// (get) Token: 0x06000571 RID: 1393 RVA: 0x0001F9F4 File Offset: 0x0001DBF4
|
||||
public bool RequestClientCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.request_client_certificate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002BC RID: 700
|
||||
private SslServerStream sslStream;
|
||||
|
||||
// Token: 0x040002BD RID: 701
|
||||
private bool request_client_certificate;
|
||||
|
||||
// Token: 0x040002BE RID: 702
|
||||
private bool clientCertificateRequired;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.Protocol.Tls.Handshake.Server;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000097 RID: 151
|
||||
internal class ServerRecordProtocol : RecordProtocol
|
||||
{
|
||||
// Token: 0x06000572 RID: 1394 RVA: 0x0001F9FC File Offset: 0x0001DBFC
|
||||
public ServerRecordProtocol(Stream innerStream, ServerContext context)
|
||||
: base(innerStream, context)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000573 RID: 1395 RVA: 0x0001FA08 File Offset: 0x0001DC08
|
||||
public override HandshakeMessage GetMessage(HandshakeType type)
|
||||
{
|
||||
return this.createServerHandshakeMessage(type);
|
||||
}
|
||||
|
||||
// Token: 0x06000574 RID: 1396 RVA: 0x0001FA20 File Offset: 0x0001DC20
|
||||
protected override void ProcessHandshakeMessage(TlsStream handMsg)
|
||||
{
|
||||
HandshakeType handshakeType = (HandshakeType)handMsg.ReadByte();
|
||||
int num = handMsg.ReadInt24();
|
||||
byte[] array = new byte[num];
|
||||
handMsg.Read(array, 0, num);
|
||||
HandshakeMessage handshakeMessage = this.createClientHandshakeMessage(handshakeType, array);
|
||||
handshakeMessage.Process();
|
||||
base.Context.LastHandshakeMsg = handshakeType;
|
||||
if (handshakeMessage != null)
|
||||
{
|
||||
handshakeMessage.Update();
|
||||
base.Context.HandshakeMessages.WriteByte((byte)handshakeType);
|
||||
base.Context.HandshakeMessages.WriteInt24(num);
|
||||
base.Context.HandshakeMessages.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000575 RID: 1397 RVA: 0x0001FAAC File Offset: 0x0001DCAC
|
||||
private HandshakeMessage createClientHandshakeMessage(HandshakeType type, byte[] buffer)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HandshakeType.CertificateVerify:
|
||||
return new TlsClientCertificateVerify(this.context, buffer);
|
||||
case HandshakeType.ClientKeyExchange:
|
||||
return new TlsClientKeyExchange(this.context, buffer);
|
||||
default:
|
||||
if (type == HandshakeType.ClientHello)
|
||||
{
|
||||
return new TlsClientHello(this.context, buffer);
|
||||
}
|
||||
if (type != HandshakeType.Certificate)
|
||||
{
|
||||
throw new TlsException(AlertDescription.UnexpectedMessage, string.Format(CultureInfo.CurrentUICulture, "Unknown server handshake message received ({0})", new object[] { type.ToString() }));
|
||||
}
|
||||
return new TlsClientCertificate(this.context, buffer);
|
||||
case HandshakeType.Finished:
|
||||
return new TlsClientFinished(this.context, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000576 RID: 1398 RVA: 0x0001FB5C File Offset: 0x0001DD5C
|
||||
private HandshakeMessage createServerHandshakeMessage(HandshakeType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HandshakeType.Certificate:
|
||||
return new TlsServerCertificate(this.context);
|
||||
case HandshakeType.ServerKeyExchange:
|
||||
return new TlsServerKeyExchange(this.context);
|
||||
case HandshakeType.CertificateRequest:
|
||||
return new TlsServerCertificateRequest(this.context);
|
||||
case HandshakeType.ServerHelloDone:
|
||||
return new TlsServerHelloDone(this.context);
|
||||
default:
|
||||
switch (type)
|
||||
{
|
||||
case HandshakeType.HelloRequest:
|
||||
this.SendRecord(HandshakeType.ClientHello);
|
||||
return null;
|
||||
case HandshakeType.ServerHello:
|
||||
return new TlsServerHello(this.context);
|
||||
}
|
||||
throw new InvalidOperationException("Unknown server handshake message type: " + type.ToString());
|
||||
case HandshakeType.Finished:
|
||||
return new TlsServerFinished(this.context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200009A RID: 154
|
||||
internal class SslCipherSuite : CipherSuite
|
||||
{
|
||||
// Token: 0x0600059F RID: 1439 RVA: 0x000202B8 File Offset: 0x0001E4B8
|
||||
public SslCipherSuite(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)
|
||||
{
|
||||
int num = ((hashAlgorithmType != HashAlgorithmType.Md5) ? 40 : 48);
|
||||
this.pad1 = new byte[num];
|
||||
this.pad2 = new byte[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
this.pad1[i] = 54;
|
||||
this.pad2[i] = 92;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005A0 RID: 1440 RVA: 0x00020330 File Offset: 0x0001E530
|
||||
public override byte[] ComputeServerRecordMAC(ContentType contentType, byte[] fragment)
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(base.HashAlgorithmName);
|
||||
byte[] serverWriteMAC = base.Context.Read.ServerWriteMAC;
|
||||
hashAlgorithm.TransformBlock(serverWriteMAC, 0, serverWriteMAC.Length, serverWriteMAC, 0);
|
||||
hashAlgorithm.TransformBlock(this.pad1, 0, this.pad1.Length, this.pad1, 0);
|
||||
if (this.header == null)
|
||||
{
|
||||
this.header = new byte[11];
|
||||
}
|
||||
ulong num = ((!(base.Context is ClientContext)) ? base.Context.WriteSequenceNumber : base.Context.ReadSequenceNumber);
|
||||
base.Write(this.header, 0, num);
|
||||
this.header[8] = (byte)contentType;
|
||||
base.Write(this.header, 9, (short)fragment.Length);
|
||||
hashAlgorithm.TransformBlock(this.header, 0, this.header.Length, this.header, 0);
|
||||
hashAlgorithm.TransformBlock(fragment, 0, fragment.Length, fragment, 0);
|
||||
hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
byte[] hash = hashAlgorithm.Hash;
|
||||
hashAlgorithm.Initialize();
|
||||
hashAlgorithm.TransformBlock(serverWriteMAC, 0, serverWriteMAC.Length, serverWriteMAC, 0);
|
||||
hashAlgorithm.TransformBlock(this.pad2, 0, this.pad2.Length, this.pad2, 0);
|
||||
hashAlgorithm.TransformBlock(hash, 0, hash.Length, hash, 0);
|
||||
hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
return hashAlgorithm.Hash;
|
||||
}
|
||||
|
||||
// Token: 0x060005A1 RID: 1441 RVA: 0x00020488 File Offset: 0x0001E688
|
||||
public override byte[] ComputeClientRecordMAC(ContentType contentType, byte[] fragment)
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(base.HashAlgorithmName);
|
||||
byte[] clientWriteMAC = base.Context.Current.ClientWriteMAC;
|
||||
hashAlgorithm.TransformBlock(clientWriteMAC, 0, clientWriteMAC.Length, clientWriteMAC, 0);
|
||||
hashAlgorithm.TransformBlock(this.pad1, 0, this.pad1.Length, this.pad1, 0);
|
||||
if (this.header == null)
|
||||
{
|
||||
this.header = new byte[11];
|
||||
}
|
||||
ulong num = ((!(base.Context is ClientContext)) ? base.Context.ReadSequenceNumber : base.Context.WriteSequenceNumber);
|
||||
base.Write(this.header, 0, num);
|
||||
this.header[8] = (byte)contentType;
|
||||
base.Write(this.header, 9, (short)fragment.Length);
|
||||
hashAlgorithm.TransformBlock(this.header, 0, this.header.Length, this.header, 0);
|
||||
hashAlgorithm.TransformBlock(fragment, 0, fragment.Length, fragment, 0);
|
||||
hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
byte[] hash = hashAlgorithm.Hash;
|
||||
hashAlgorithm.Initialize();
|
||||
hashAlgorithm.TransformBlock(clientWriteMAC, 0, clientWriteMAC.Length, clientWriteMAC, 0);
|
||||
hashAlgorithm.TransformBlock(this.pad2, 0, this.pad2.Length, this.pad2, 0);
|
||||
hashAlgorithm.TransformBlock(hash, 0, hash.Length, hash, 0);
|
||||
hashAlgorithm.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
return hashAlgorithm.Hash;
|
||||
}
|
||||
|
||||
// Token: 0x060005A2 RID: 1442 RVA: 0x000205E0 File Offset: 0x0001E7E0
|
||||
public override void ComputeMasterSecret(byte[] preMasterSecret)
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(this.prf(preMasterSecret, "A", base.Context.RandomCS));
|
||||
tlsStream.Write(this.prf(preMasterSecret, "BB", base.Context.RandomCS));
|
||||
tlsStream.Write(this.prf(preMasterSecret, "CCC", base.Context.RandomCS));
|
||||
base.Context.MasterSecret = tlsStream.ToArray();
|
||||
}
|
||||
|
||||
// Token: 0x060005A3 RID: 1443 RVA: 0x0002065C File Offset: 0x0001E85C
|
||||
public override void ComputeKeys()
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
char c = 'A';
|
||||
int num = 1;
|
||||
while (tlsStream.Length < (long)base.KeyBlockSize)
|
||||
{
|
||||
string text = string.Empty;
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
text += c.ToString();
|
||||
}
|
||||
byte[] array = this.prf(base.Context.MasterSecret, text.ToString(), base.Context.RandomSC);
|
||||
int num2 = ((tlsStream.Length + (long)array.Length <= (long)base.KeyBlockSize) ? array.Length : (base.KeyBlockSize - (int)tlsStream.Length));
|
||||
tlsStream.Write(array, 0, num2);
|
||||
c += '\u0001';
|
||||
num++;
|
||||
}
|
||||
TlsStream tlsStream2 = new TlsStream(tlsStream.ToArray());
|
||||
base.Context.Negotiating.ClientWriteMAC = tlsStream2.ReadBytes(base.HashSize);
|
||||
base.Context.Negotiating.ServerWriteMAC = tlsStream2.ReadBytes(base.HashSize);
|
||||
base.Context.ClientWriteKey = tlsStream2.ReadBytes((int)base.KeyMaterialSize);
|
||||
base.Context.ServerWriteKey = tlsStream2.ReadBytes((int)base.KeyMaterialSize);
|
||||
if (!base.IsExportable)
|
||||
{
|
||||
if (base.IvSize != 0)
|
||||
{
|
||||
base.Context.ClientWriteIV = tlsStream2.ReadBytes((int)base.IvSize);
|
||||
base.Context.ServerWriteIV = tlsStream2.ReadBytes((int)base.IvSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Context.ClientWriteIV = CipherSuite.EmptyArray;
|
||||
base.Context.ServerWriteIV = CipherSuite.EmptyArray;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = MD5.Create();
|
||||
int num3 = hashAlgorithm.HashSize >> 3;
|
||||
byte[] array2 = new byte[num3];
|
||||
hashAlgorithm.TransformBlock(base.Context.ClientWriteKey, 0, base.Context.ClientWriteKey.Length, array2, 0);
|
||||
hashAlgorithm.TransformFinalBlock(base.Context.RandomCS, 0, base.Context.RandomCS.Length);
|
||||
byte[] array3 = new byte[(int)base.ExpandedKeyMaterialSize];
|
||||
Buffer.BlockCopy(hashAlgorithm.Hash, 0, array3, 0, (int)base.ExpandedKeyMaterialSize);
|
||||
hashAlgorithm.Initialize();
|
||||
hashAlgorithm.TransformBlock(base.Context.ServerWriteKey, 0, base.Context.ServerWriteKey.Length, array2, 0);
|
||||
hashAlgorithm.TransformFinalBlock(base.Context.RandomSC, 0, base.Context.RandomSC.Length);
|
||||
byte[] array4 = new byte[(int)base.ExpandedKeyMaterialSize];
|
||||
Buffer.BlockCopy(hashAlgorithm.Hash, 0, array4, 0, (int)base.ExpandedKeyMaterialSize);
|
||||
base.Context.ClientWriteKey = array3;
|
||||
base.Context.ServerWriteKey = array4;
|
||||
if (base.IvSize > 0)
|
||||
{
|
||||
hashAlgorithm.Initialize();
|
||||
array2 = hashAlgorithm.ComputeHash(base.Context.RandomCS, 0, base.Context.RandomCS.Length);
|
||||
base.Context.ClientWriteIV = new byte[(int)base.IvSize];
|
||||
Buffer.BlockCopy(array2, 0, base.Context.ClientWriteIV, 0, (int)base.IvSize);
|
||||
hashAlgorithm.Initialize();
|
||||
array2 = hashAlgorithm.ComputeHash(base.Context.RandomSC, 0, base.Context.RandomSC.Length);
|
||||
base.Context.ServerWriteIV = new byte[(int)base.IvSize];
|
||||
Buffer.BlockCopy(array2, 0, base.Context.ServerWriteIV, 0, (int)base.IvSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Context.ClientWriteIV = CipherSuite.EmptyArray;
|
||||
base.Context.ServerWriteIV = CipherSuite.EmptyArray;
|
||||
}
|
||||
}
|
||||
ClientSessionCache.SetContextInCache(base.Context);
|
||||
tlsStream2.Reset();
|
||||
tlsStream.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x060005A4 RID: 1444 RVA: 0x00020A10 File Offset: 0x0001EC10
|
||||
private byte[] prf(byte[] secret, string label, byte[] random)
|
||||
{
|
||||
HashAlgorithm hashAlgorithm = MD5.Create();
|
||||
HashAlgorithm hashAlgorithm2 = SHA1.Create();
|
||||
TlsStream tlsStream = new TlsStream();
|
||||
tlsStream.Write(Encoding.ASCII.GetBytes(label));
|
||||
tlsStream.Write(secret);
|
||||
tlsStream.Write(random);
|
||||
byte[] array = hashAlgorithm2.ComputeHash(tlsStream.ToArray(), 0, (int)tlsStream.Length);
|
||||
tlsStream.Reset();
|
||||
tlsStream.Write(secret);
|
||||
tlsStream.Write(array);
|
||||
byte[] array2 = hashAlgorithm.ComputeHash(tlsStream.ToArray(), 0, (int)tlsStream.Length);
|
||||
tlsStream.Reset();
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x040002C6 RID: 710
|
||||
private const int MacHeaderLength = 11;
|
||||
|
||||
// Token: 0x040002C7 RID: 711
|
||||
private byte[] pad1;
|
||||
|
||||
// Token: 0x040002C8 RID: 712
|
||||
private byte[] pad2;
|
||||
|
||||
// Token: 0x040002C9 RID: 713
|
||||
private byte[] header;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000099 RID: 153
|
||||
public class SslClientStream : SslStreamBase
|
||||
{
|
||||
// Token: 0x0600057B RID: 1403 RVA: 0x0001FC58 File Offset: 0x0001DE58
|
||||
public SslClientStream(Stream stream, string targetHost, bool ownsStream)
|
||||
: this(stream, targetHost, ownsStream, SecurityProtocolType.Default, null)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600057C RID: 1404 RVA: 0x0001FC6C File Offset: 0x0001DE6C
|
||||
public SslClientStream(Stream stream, string targetHost, global::System.Security.Cryptography.X509Certificates.X509Certificate clientCertificate)
|
||||
: this(stream, targetHost, false, SecurityProtocolType.Default, new global::System.Security.Cryptography.X509Certificates.X509CertificateCollection(new global::System.Security.Cryptography.X509Certificates.X509Certificate[] { clientCertificate }))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600057D RID: 1405 RVA: 0x0001FC98 File Offset: 0x0001DE98
|
||||
public SslClientStream(Stream stream, string targetHost, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates)
|
||||
: this(stream, targetHost, false, SecurityProtocolType.Default, clientCertificates)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600057E RID: 1406 RVA: 0x0001FCAC File Offset: 0x0001DEAC
|
||||
public SslClientStream(Stream stream, string targetHost, bool ownsStream, SecurityProtocolType securityProtocolType)
|
||||
: this(stream, targetHost, ownsStream, securityProtocolType, new global::System.Security.Cryptography.X509Certificates.X509CertificateCollection())
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600057F RID: 1407 RVA: 0x0001FCC0 File Offset: 0x0001DEC0
|
||||
public SslClientStream(Stream stream, string targetHost, bool ownsStream, SecurityProtocolType securityProtocolType, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates)
|
||||
: base(stream, ownsStream)
|
||||
{
|
||||
if (targetHost == null || targetHost.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException("targetHost is null or an empty string.");
|
||||
}
|
||||
this.context = new ClientContext(this, securityProtocolType, targetHost, clientCertificates);
|
||||
this.protocol = new ClientRecordProtocol(this.innerStream, (ClientContext)this.context);
|
||||
}
|
||||
|
||||
// Token: 0x14000002 RID: 2
|
||||
// (add) Token: 0x06000580 RID: 1408 RVA: 0x0001FD20 File Offset: 0x0001DF20
|
||||
// (remove) Token: 0x06000581 RID: 1409 RVA: 0x0001FD3C File Offset: 0x0001DF3C
|
||||
internal event CertificateValidationCallback ServerCertValidation;
|
||||
|
||||
// Token: 0x14000003 RID: 3
|
||||
// (add) Token: 0x06000582 RID: 1410 RVA: 0x0001FD58 File Offset: 0x0001DF58
|
||||
// (remove) Token: 0x06000583 RID: 1411 RVA: 0x0001FD74 File Offset: 0x0001DF74
|
||||
internal event CertificateSelectionCallback ClientCertSelection;
|
||||
|
||||
// Token: 0x14000004 RID: 4
|
||||
// (add) Token: 0x06000584 RID: 1412 RVA: 0x0001FD90 File Offset: 0x0001DF90
|
||||
// (remove) Token: 0x06000585 RID: 1413 RVA: 0x0001FDAC File Offset: 0x0001DFAC
|
||||
internal event PrivateKeySelectionCallback PrivateKeySelection;
|
||||
|
||||
// Token: 0x14000005 RID: 5
|
||||
// (add) Token: 0x06000586 RID: 1414 RVA: 0x0001FDC8 File Offset: 0x0001DFC8
|
||||
// (remove) Token: 0x06000587 RID: 1415 RVA: 0x0001FDE4 File Offset: 0x0001DFE4
|
||||
public event CertificateValidationCallback2 ServerCertValidation2;
|
||||
|
||||
// Token: 0x17000165 RID: 357
|
||||
// (get) Token: 0x06000588 RID: 1416 RVA: 0x0001FE00 File Offset: 0x0001E000
|
||||
internal Stream InputBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000166 RID: 358
|
||||
// (get) Token: 0x06000589 RID: 1417 RVA: 0x0001FE08 File Offset: 0x0001E008
|
||||
public global::System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.context.ClientSettings.Certificates;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000167 RID: 359
|
||||
// (get) Token: 0x0600058A RID: 1418 RVA: 0x0001FE1C File Offset: 0x0001E01C
|
||||
public global::System.Security.Cryptography.X509Certificates.X509Certificate SelectedClientCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.context.ClientSettings.ClientCertificate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000168 RID: 360
|
||||
// (get) Token: 0x0600058B RID: 1419 RVA: 0x0001FE30 File Offset: 0x0001E030
|
||||
// (set) Token: 0x0600058C RID: 1420 RVA: 0x0001FE38 File Offset: 0x0001E038
|
||||
public CertificateValidationCallback ServerCertValidationDelegate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ServerCertValidation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.ServerCertValidation = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000169 RID: 361
|
||||
// (get) Token: 0x0600058D RID: 1421 RVA: 0x0001FE44 File Offset: 0x0001E044
|
||||
// (set) Token: 0x0600058E RID: 1422 RVA: 0x0001FE4C File Offset: 0x0001E04C
|
||||
public CertificateSelectionCallback ClientCertSelectionDelegate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ClientCertSelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.ClientCertSelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016A RID: 362
|
||||
// (get) Token: 0x0600058F RID: 1423 RVA: 0x0001FE58 File Offset: 0x0001E058
|
||||
// (set) Token: 0x06000590 RID: 1424 RVA: 0x0001FE60 File Offset: 0x0001E060
|
||||
public PrivateKeySelectionCallback PrivateKeyCertSelectionDelegate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.PrivateKeySelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.PrivateKeySelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000591 RID: 1425 RVA: 0x0001FE6C File Offset: 0x0001E06C
|
||||
~SslClientStream()
|
||||
{
|
||||
base.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x06000592 RID: 1426 RVA: 0x0001FEA8 File Offset: 0x0001E0A8
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
this.ServerCertValidation = null;
|
||||
this.ClientCertSelection = null;
|
||||
this.PrivateKeySelection = null;
|
||||
this.ServerCertValidation2 = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000593 RID: 1427 RVA: 0x0001FED4 File Offset: 0x0001E0D4
|
||||
internal override IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state)
|
||||
{
|
||||
IAsyncResult asyncResult;
|
||||
try
|
||||
{
|
||||
if (this.context.HandshakeState != HandshakeState.None)
|
||||
{
|
||||
this.context.Clear();
|
||||
}
|
||||
this.context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(this.context.SecurityProtocol);
|
||||
this.context.HandshakeState = HandshakeState.Started;
|
||||
asyncResult = this.protocol.BeginSendRecord(HandshakeType.ClientHello, callback, state);
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.protocol.SendAlert(ex.Alert);
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
this.protocol.SendAlert(AlertDescription.InternalError);
|
||||
throw new IOException("The authentication or decryption has failed.", ex2);
|
||||
}
|
||||
return asyncResult;
|
||||
}
|
||||
|
||||
// Token: 0x06000594 RID: 1428 RVA: 0x0001FFB4 File Offset: 0x0001E1B4
|
||||
private void SafeReceiveRecord(Stream s)
|
||||
{
|
||||
byte[] array = this.protocol.ReceiveRecord(s);
|
||||
if (array == null || array.Length == 0)
|
||||
{
|
||||
throw new TlsException(AlertDescription.HandshakeFailiure, "The server stopped the handshake.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000595 RID: 1429 RVA: 0x0001FFEC File Offset: 0x0001E1EC
|
||||
internal override void OnNegotiateHandshakeCallback(IAsyncResult asyncResult)
|
||||
{
|
||||
this.protocol.EndSendRecord(asyncResult);
|
||||
while (this.context.LastHandshakeMsg != HandshakeType.ServerHelloDone)
|
||||
{
|
||||
this.SafeReceiveRecord(this.innerStream);
|
||||
if (this.context.AbbreviatedHandshake && this.context.LastHandshakeMsg == HandshakeType.ServerHello)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.context.AbbreviatedHandshake)
|
||||
{
|
||||
ClientSessionCache.SetContextFromCache(this.context);
|
||||
this.context.Negotiating.Cipher.ComputeKeys();
|
||||
this.context.Negotiating.Cipher.InitializeCipher();
|
||||
this.protocol.SendChangeCipherSpec();
|
||||
while (this.context.HandshakeState != HandshakeState.Finished)
|
||||
{
|
||||
this.SafeReceiveRecord(this.innerStream);
|
||||
}
|
||||
this.protocol.SendRecord(HandshakeType.Finished);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool flag = this.context.ServerSettings.CertificateRequest;
|
||||
if (this.context.SecurityProtocol == SecurityProtocolType.Ssl3)
|
||||
{
|
||||
flag = this.context.ClientSettings.Certificates != null && this.context.ClientSettings.Certificates.Count > 0;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.protocol.SendRecord(HandshakeType.Certificate);
|
||||
}
|
||||
this.protocol.SendRecord(HandshakeType.ClientKeyExchange);
|
||||
this.context.Negotiating.Cipher.InitializeCipher();
|
||||
if (flag && this.context.ClientSettings.ClientCertificate != null)
|
||||
{
|
||||
this.protocol.SendRecord(HandshakeType.CertificateVerify);
|
||||
}
|
||||
this.protocol.SendChangeCipherSpec();
|
||||
this.protocol.SendRecord(HandshakeType.Finished);
|
||||
while (this.context.HandshakeState != HandshakeState.Finished)
|
||||
{
|
||||
this.SafeReceiveRecord(this.innerStream);
|
||||
}
|
||||
}
|
||||
this.context.HandshakeMessages.Reset();
|
||||
this.context.ClearKeyInfo();
|
||||
}
|
||||
|
||||
// Token: 0x06000596 RID: 1430 RVA: 0x000201DC File Offset: 0x0001E3DC
|
||||
internal override global::System.Security.Cryptography.X509Certificates.X509Certificate OnLocalCertificateSelection(global::System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, string targetHost, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection serverRequestedCertificates)
|
||||
{
|
||||
if (this.ClientCertSelection != null)
|
||||
{
|
||||
return this.ClientCertSelection(clientCertificates, serverCertificate, targetHost, serverRequestedCertificates);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x1700016B RID: 363
|
||||
// (get) Token: 0x06000597 RID: 1431 RVA: 0x000201FC File Offset: 0x0001E3FC
|
||||
internal override bool HaveRemoteValidation2Callback
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ServerCertValidation2 != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000598 RID: 1432 RVA: 0x0002020C File Offset: 0x0001E40C
|
||||
internal override ValidationResult OnRemoteCertificateValidation2(Mono.Security.X509.X509CertificateCollection collection)
|
||||
{
|
||||
CertificateValidationCallback2 serverCertValidation = this.ServerCertValidation2;
|
||||
if (serverCertValidation != null)
|
||||
{
|
||||
return serverCertValidation(collection);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000599 RID: 1433 RVA: 0x00020230 File Offset: 0x0001E430
|
||||
internal override bool OnRemoteCertificateValidation(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, int[] errors)
|
||||
{
|
||||
if (this.ServerCertValidation != null)
|
||||
{
|
||||
return this.ServerCertValidation(certificate, errors);
|
||||
}
|
||||
return errors != null && errors.Length == 0;
|
||||
}
|
||||
|
||||
// Token: 0x0600059A RID: 1434 RVA: 0x00020268 File Offset: 0x0001E468
|
||||
internal virtual bool RaiseServerCertificateValidation(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, int[] certificateErrors)
|
||||
{
|
||||
return base.RaiseRemoteCertificateValidation(certificate, certificateErrors);
|
||||
}
|
||||
|
||||
// Token: 0x0600059B RID: 1435 RVA: 0x00020274 File Offset: 0x0001E474
|
||||
internal virtual ValidationResult RaiseServerCertificateValidation2(Mono.Security.X509.X509CertificateCollection collection)
|
||||
{
|
||||
return base.RaiseRemoteCertificateValidation2(collection);
|
||||
}
|
||||
|
||||
// Token: 0x0600059C RID: 1436 RVA: 0x00020280 File Offset: 0x0001E480
|
||||
internal global::System.Security.Cryptography.X509Certificates.X509Certificate RaiseClientCertificateSelection(global::System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, string targetHost, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection serverRequestedCertificates)
|
||||
{
|
||||
return base.RaiseLocalCertificateSelection(clientCertificates, serverCertificate, targetHost, serverRequestedCertificates);
|
||||
}
|
||||
|
||||
// Token: 0x0600059D RID: 1437 RVA: 0x00020290 File Offset: 0x0001E490
|
||||
internal override AsymmetricAlgorithm OnLocalPrivateKeySelection(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost)
|
||||
{
|
||||
if (this.PrivateKeySelection != null)
|
||||
{
|
||||
return this.PrivateKeySelection(certificate, targetHost);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x0600059E RID: 1438 RVA: 0x000202AC File Offset: 0x0001E4AC
|
||||
internal AsymmetricAlgorithm RaisePrivateKeySelection(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost)
|
||||
{
|
||||
return base.RaiseLocalPrivateKeySelection(certificate, targetHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200009B RID: 155
|
||||
internal class SslHandshakeHash : HashAlgorithm
|
||||
{
|
||||
// Token: 0x060005A5 RID: 1445 RVA: 0x00020A98 File Offset: 0x0001EC98
|
||||
public SslHandshakeHash(byte[] secret)
|
||||
{
|
||||
this.md5 = HashAlgorithm.Create("MD5");
|
||||
this.sha = HashAlgorithm.Create("SHA1");
|
||||
this.HashSizeValue = this.md5.HashSize + this.sha.HashSize;
|
||||
this.secret = secret;
|
||||
this.Initialize();
|
||||
}
|
||||
|
||||
// Token: 0x060005A6 RID: 1446 RVA: 0x00020AF8 File Offset: 0x0001ECF8
|
||||
public override void Initialize()
|
||||
{
|
||||
this.md5.Initialize();
|
||||
this.sha.Initialize();
|
||||
this.initializePad();
|
||||
this.hashing = false;
|
||||
}
|
||||
|
||||
// Token: 0x060005A7 RID: 1447 RVA: 0x00020B20 File Offset: 0x0001ED20
|
||||
protected override byte[] HashFinal()
|
||||
{
|
||||
if (!this.hashing)
|
||||
{
|
||||
this.hashing = true;
|
||||
}
|
||||
this.md5.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0);
|
||||
this.md5.TransformFinalBlock(this.innerPadMD5, 0, this.innerPadMD5.Length);
|
||||
byte[] hash = 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(hash, 0, hash.Length);
|
||||
this.sha.TransformBlock(this.secret, 0, this.secret.Length, this.secret, 0);
|
||||
this.sha.TransformFinalBlock(this.innerPadSHA, 0, this.innerPadSHA.Length);
|
||||
byte[] hash2 = 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(hash2, 0, hash2.Length);
|
||||
this.Initialize();
|
||||
byte[] array = new byte[36];
|
||||
Buffer.BlockCopy(this.md5.Hash, 0, array, 0, 16);
|
||||
Buffer.BlockCopy(this.sha.Hash, 0, array, 16, 20);
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x060005A8 RID: 1448 RVA: 0x00020CCC File Offset: 0x0001EECC
|
||||
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);
|
||||
}
|
||||
|
||||
// Token: 0x060005A9 RID: 1449 RVA: 0x00020D10 File Offset: 0x0001EF10
|
||||
public byte[] CreateSignature(RSA rsa)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
throw new CryptographicUnexpectedOperationException("missing key");
|
||||
}
|
||||
RSASslSignatureFormatter rsasslSignatureFormatter = new RSASslSignatureFormatter(rsa);
|
||||
rsasslSignatureFormatter.SetHashAlgorithm("MD5SHA1");
|
||||
return rsasslSignatureFormatter.CreateSignature(this.Hash);
|
||||
}
|
||||
|
||||
// Token: 0x060005AA RID: 1450 RVA: 0x00020D4C File Offset: 0x0001EF4C
|
||||
public bool VerifySignature(RSA rsa, byte[] rgbSignature)
|
||||
{
|
||||
if (rsa == null)
|
||||
{
|
||||
throw new CryptographicUnexpectedOperationException("missing key");
|
||||
}
|
||||
if (rgbSignature == null)
|
||||
{
|
||||
throw new ArgumentNullException("rgbSignature");
|
||||
}
|
||||
RSASslSignatureDeformatter rsasslSignatureDeformatter = new RSASslSignatureDeformatter(rsa);
|
||||
rsasslSignatureDeformatter.SetHashAlgorithm("MD5SHA1");
|
||||
return rsasslSignatureDeformatter.VerifySignature(this.Hash, rgbSignature);
|
||||
}
|
||||
|
||||
// Token: 0x060005AB RID: 1451 RVA: 0x00020D9C File Offset: 0x0001EF9C
|
||||
private void initializePad()
|
||||
{
|
||||
this.innerPadMD5 = new byte[48];
|
||||
this.outerPadMD5 = new byte[48];
|
||||
for (int i = 0; i < 48; i++)
|
||||
{
|
||||
this.innerPadMD5[i] = 54;
|
||||
this.outerPadMD5[i] = 92;
|
||||
}
|
||||
this.innerPadSHA = new byte[40];
|
||||
this.outerPadSHA = new byte[40];
|
||||
for (int j = 0; j < 40; j++)
|
||||
{
|
||||
this.innerPadSHA[j] = 54;
|
||||
this.outerPadSHA[j] = 92;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002CA RID: 714
|
||||
private HashAlgorithm md5;
|
||||
|
||||
// Token: 0x040002CB RID: 715
|
||||
private HashAlgorithm sha;
|
||||
|
||||
// Token: 0x040002CC RID: 716
|
||||
private bool hashing;
|
||||
|
||||
// Token: 0x040002CD RID: 717
|
||||
private byte[] secret;
|
||||
|
||||
// Token: 0x040002CE RID: 718
|
||||
private byte[] innerPadMD5;
|
||||
|
||||
// Token: 0x040002CF RID: 719
|
||||
private byte[] outerPadMD5;
|
||||
|
||||
// Token: 0x040002D0 RID: 720
|
||||
private byte[] innerPadSHA;
|
||||
|
||||
// Token: 0x040002D1 RID: 721
|
||||
private byte[] outerPadSHA;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200009C RID: 156
|
||||
public class SslServerStream : SslStreamBase
|
||||
{
|
||||
// Token: 0x060005AC RID: 1452 RVA: 0x00020E2C File Offset: 0x0001F02C
|
||||
public SslServerStream(Stream stream, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate)
|
||||
: this(stream, serverCertificate, false, false, SecurityProtocolType.Default)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060005AD RID: 1453 RVA: 0x00020E40 File Offset: 0x0001F040
|
||||
public SslServerStream(Stream stream, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool ownsStream)
|
||||
: this(stream, serverCertificate, clientCertificateRequired, ownsStream, SecurityProtocolType.Default)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060005AE RID: 1454 RVA: 0x00020E54 File Offset: 0x0001F054
|
||||
public SslServerStream(Stream stream, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool requestClientCertificate, bool ownsStream)
|
||||
: this(stream, serverCertificate, clientCertificateRequired, requestClientCertificate, ownsStream, SecurityProtocolType.Default)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060005AF RID: 1455 RVA: 0x00020E68 File Offset: 0x0001F068
|
||||
public SslServerStream(Stream stream, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool ownsStream, SecurityProtocolType securityProtocolType)
|
||||
: this(stream, serverCertificate, clientCertificateRequired, false, ownsStream, securityProtocolType)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060005B0 RID: 1456 RVA: 0x00020E78 File Offset: 0x0001F078
|
||||
public SslServerStream(Stream stream, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, bool clientCertificateRequired, bool requestClientCertificate, bool ownsStream, SecurityProtocolType securityProtocolType)
|
||||
: base(stream, ownsStream)
|
||||
{
|
||||
this.context = new ServerContext(this, securityProtocolType, serverCertificate, clientCertificateRequired, requestClientCertificate);
|
||||
this.protocol = new ServerRecordProtocol(this.innerStream, (ServerContext)this.context);
|
||||
}
|
||||
|
||||
// Token: 0x14000006 RID: 6
|
||||
// (add) Token: 0x060005B1 RID: 1457 RVA: 0x00020EBC File Offset: 0x0001F0BC
|
||||
// (remove) Token: 0x060005B2 RID: 1458 RVA: 0x00020ED8 File Offset: 0x0001F0D8
|
||||
internal event CertificateValidationCallback ClientCertValidation;
|
||||
|
||||
// Token: 0x14000007 RID: 7
|
||||
// (add) Token: 0x060005B3 RID: 1459 RVA: 0x00020EF4 File Offset: 0x0001F0F4
|
||||
// (remove) Token: 0x060005B4 RID: 1460 RVA: 0x00020F10 File Offset: 0x0001F110
|
||||
internal event PrivateKeySelectionCallback PrivateKeySelection;
|
||||
|
||||
// Token: 0x14000008 RID: 8
|
||||
// (add) Token: 0x060005B5 RID: 1461 RVA: 0x00020F2C File Offset: 0x0001F12C
|
||||
// (remove) Token: 0x060005B6 RID: 1462 RVA: 0x00020F48 File Offset: 0x0001F148
|
||||
public event CertificateValidationCallback2 ClientCertValidation2;
|
||||
|
||||
// Token: 0x1700016C RID: 364
|
||||
// (get) Token: 0x060005B7 RID: 1463 RVA: 0x00020F64 File Offset: 0x0001F164
|
||||
public global::System.Security.Cryptography.X509Certificates.X509Certificate ClientCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.ClientSettings.ClientCertificate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016D RID: 365
|
||||
// (get) Token: 0x060005B8 RID: 1464 RVA: 0x00020F8C File Offset: 0x0001F18C
|
||||
// (set) Token: 0x060005B9 RID: 1465 RVA: 0x00020F94 File Offset: 0x0001F194
|
||||
public CertificateValidationCallback ClientCertValidationDelegate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ClientCertValidation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.ClientCertValidation = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700016E RID: 366
|
||||
// (get) Token: 0x060005BA RID: 1466 RVA: 0x00020FA0 File Offset: 0x0001F1A0
|
||||
// (set) Token: 0x060005BB RID: 1467 RVA: 0x00020FA8 File Offset: 0x0001F1A8
|
||||
public PrivateKeySelectionCallback PrivateKeyCertSelectionDelegate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.PrivateKeySelection;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.PrivateKeySelection = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005BC RID: 1468 RVA: 0x00020FB4 File Offset: 0x0001F1B4
|
||||
~SslServerStream()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x060005BD RID: 1469 RVA: 0x00020FF0 File Offset: 0x0001F1F0
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
this.ClientCertValidation = null;
|
||||
this.PrivateKeySelection = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005BE RID: 1470 RVA: 0x00021010 File Offset: 0x0001F210
|
||||
internal override IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state)
|
||||
{
|
||||
if (this.context.HandshakeState != HandshakeState.None)
|
||||
{
|
||||
this.context.Clear();
|
||||
}
|
||||
this.context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(this.context.SecurityProtocol);
|
||||
this.context.HandshakeState = HandshakeState.Started;
|
||||
return this.protocol.BeginReceiveRecord(this.innerStream, callback, state);
|
||||
}
|
||||
|
||||
// Token: 0x060005BF RID: 1471 RVA: 0x00021074 File Offset: 0x0001F274
|
||||
internal override void OnNegotiateHandshakeCallback(IAsyncResult asyncResult)
|
||||
{
|
||||
this.protocol.EndReceiveRecord(asyncResult);
|
||||
if (this.context.LastHandshakeMsg != HandshakeType.ClientHello)
|
||||
{
|
||||
this.protocol.SendAlert(AlertDescription.UnexpectedMessage);
|
||||
}
|
||||
this.protocol.SendRecord(HandshakeType.ServerHello);
|
||||
this.protocol.SendRecord(HandshakeType.Certificate);
|
||||
if (this.context.Negotiating.Cipher.IsExportable)
|
||||
{
|
||||
this.protocol.SendRecord(HandshakeType.ServerKeyExchange);
|
||||
}
|
||||
bool flag = false;
|
||||
if (this.context.Negotiating.Cipher.IsExportable || ((ServerContext)this.context).ClientCertificateRequired || ((ServerContext)this.context).RequestClientCertificate)
|
||||
{
|
||||
this.protocol.SendRecord(HandshakeType.CertificateRequest);
|
||||
flag = true;
|
||||
}
|
||||
this.protocol.SendRecord(HandshakeType.ServerHelloDone);
|
||||
while (this.context.LastHandshakeMsg != HandshakeType.Finished)
|
||||
{
|
||||
byte[] array = this.protocol.ReceiveRecord(this.innerStream);
|
||||
if (array == null || array.Length == 0)
|
||||
{
|
||||
throw new TlsException(AlertDescription.HandshakeFailiure, "The client stopped the handshake.");
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
global::System.Security.Cryptography.X509Certificates.X509Certificate clientCertificate = this.context.ClientSettings.ClientCertificate;
|
||||
if (clientCertificate == null && ((ServerContext)this.context).ClientCertificateRequired)
|
||||
{
|
||||
throw new TlsException(AlertDescription.BadCertificate, "No certificate received from client.");
|
||||
}
|
||||
if (!this.RaiseClientCertificateValidation(clientCertificate, new int[0]))
|
||||
{
|
||||
throw new TlsException(AlertDescription.BadCertificate, "Client certificate not accepted.");
|
||||
}
|
||||
}
|
||||
this.protocol.SendChangeCipherSpec();
|
||||
this.protocol.SendRecord(HandshakeType.Finished);
|
||||
this.context.HandshakeState = HandshakeState.Finished;
|
||||
this.context.HandshakeMessages.Reset();
|
||||
this.context.ClearKeyInfo();
|
||||
}
|
||||
|
||||
// Token: 0x060005C0 RID: 1472 RVA: 0x00021230 File Offset: 0x0001F430
|
||||
internal override global::System.Security.Cryptography.X509Certificates.X509Certificate OnLocalCertificateSelection(global::System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, string targetHost, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection serverRequestedCertificates)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
// Token: 0x060005C1 RID: 1473 RVA: 0x00021238 File Offset: 0x0001F438
|
||||
internal override bool OnRemoteCertificateValidation(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, int[] errors)
|
||||
{
|
||||
if (this.ClientCertValidation != null)
|
||||
{
|
||||
return this.ClientCertValidation(certificate, errors);
|
||||
}
|
||||
return errors != null && errors.Length == 0;
|
||||
}
|
||||
|
||||
// Token: 0x1700016F RID: 367
|
||||
// (get) Token: 0x060005C2 RID: 1474 RVA: 0x00021270 File Offset: 0x0001F470
|
||||
internal override bool HaveRemoteValidation2Callback
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ClientCertValidation2 != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005C3 RID: 1475 RVA: 0x00021280 File Offset: 0x0001F480
|
||||
internal override ValidationResult OnRemoteCertificateValidation2(Mono.Security.X509.X509CertificateCollection collection)
|
||||
{
|
||||
CertificateValidationCallback2 clientCertValidation = this.ClientCertValidation2;
|
||||
if (clientCertValidation != null)
|
||||
{
|
||||
return clientCertValidation(collection);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060005C4 RID: 1476 RVA: 0x000212A4 File Offset: 0x0001F4A4
|
||||
internal bool RaiseClientCertificateValidation(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, int[] certificateErrors)
|
||||
{
|
||||
return base.RaiseRemoteCertificateValidation(certificate, certificateErrors);
|
||||
}
|
||||
|
||||
// Token: 0x060005C5 RID: 1477 RVA: 0x000212B0 File Offset: 0x0001F4B0
|
||||
internal override AsymmetricAlgorithm OnLocalPrivateKeySelection(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost)
|
||||
{
|
||||
if (this.PrivateKeySelection != null)
|
||||
{
|
||||
return this.PrivateKeySelection(certificate, targetHost);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x060005C6 RID: 1478 RVA: 0x000212CC File Offset: 0x0001F4CC
|
||||
internal AsymmetricAlgorithm RaisePrivateKeySelection(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost)
|
||||
{
|
||||
return base.RaiseLocalPrivateKeySelection(certificate, targetHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,1266 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Threading;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200009D RID: 157
|
||||
public abstract class SslStreamBase : Stream, IDisposable
|
||||
{
|
||||
// Token: 0x060005C7 RID: 1479 RVA: 0x000212D8 File Offset: 0x0001F4D8
|
||||
protected SslStreamBase(Stream stream, bool ownsStream)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException("stream is null.");
|
||||
}
|
||||
if (!stream.CanRead || !stream.CanWrite)
|
||||
{
|
||||
throw new ArgumentNullException("stream is not both readable and writable.");
|
||||
}
|
||||
this.inputBuffer = new MemoryStream();
|
||||
this.innerStream = stream;
|
||||
this.ownsStream = ownsStream;
|
||||
this.negotiate = new object();
|
||||
this.read = new object();
|
||||
this.write = new object();
|
||||
this.negotiationComplete = new ManualResetEvent(false);
|
||||
}
|
||||
|
||||
// Token: 0x060005C9 RID: 1481 RVA: 0x00021390 File Offset: 0x0001F590
|
||||
private void AsyncHandshakeCallback(IAsyncResult asyncResult)
|
||||
{
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = asyncResult.AsyncState as SslStreamBase.InternalAsyncResult;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
this.OnNegotiateHandshakeCallback(asyncResult);
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.protocol.SendAlert(ex.Alert);
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
this.protocol.SendAlert(AlertDescription.InternalError);
|
||||
throw new IOException("The authentication or decryption has failed.", ex2);
|
||||
}
|
||||
if (internalAsyncResult.ProceedAfterHandshake)
|
||||
{
|
||||
if (internalAsyncResult.FromWrite)
|
||||
{
|
||||
this.InternalBeginWrite(internalAsyncResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.InternalBeginRead(internalAsyncResult);
|
||||
}
|
||||
this.negotiationComplete.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.negotiationComplete.Set();
|
||||
internalAsyncResult.SetComplete();
|
||||
}
|
||||
}
|
||||
catch (Exception ex3)
|
||||
{
|
||||
this.negotiationComplete.Set();
|
||||
internalAsyncResult.SetComplete(ex3);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000170 RID: 368
|
||||
// (get) Token: 0x060005CA RID: 1482 RVA: 0x000214B0 File Offset: 0x0001F6B0
|
||||
internal bool MightNeedHandshake
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
object obj = this.negotiate;
|
||||
bool flag;
|
||||
lock (obj)
|
||||
{
|
||||
flag = this.context.HandshakeState != HandshakeState.Finished;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005CB RID: 1483 RVA: 0x00021520 File Offset: 0x0001F720
|
||||
internal void NegotiateHandshake()
|
||||
{
|
||||
if (this.MightNeedHandshake)
|
||||
{
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = new SslStreamBase.InternalAsyncResult(null, null, null, 0, 0, false, false);
|
||||
if (!this.BeginNegotiateHandshake(internalAsyncResult))
|
||||
{
|
||||
this.negotiationComplete.WaitOne();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.EndNegotiateHandshake(internalAsyncResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005CC RID: 1484
|
||||
internal abstract IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state);
|
||||
|
||||
// Token: 0x060005CD RID: 1485
|
||||
internal abstract void OnNegotiateHandshakeCallback(IAsyncResult asyncResult);
|
||||
|
||||
// Token: 0x060005CE RID: 1486
|
||||
internal abstract global::System.Security.Cryptography.X509Certificates.X509Certificate OnLocalCertificateSelection(global::System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, global::System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, string targetHost, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection serverRequestedCertificates);
|
||||
|
||||
// Token: 0x060005CF RID: 1487
|
||||
internal abstract bool OnRemoteCertificateValidation(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, int[] errors);
|
||||
|
||||
// Token: 0x060005D0 RID: 1488
|
||||
internal abstract ValidationResult OnRemoteCertificateValidation2(Mono.Security.X509.X509CertificateCollection collection);
|
||||
|
||||
// Token: 0x17000171 RID: 369
|
||||
// (get) Token: 0x060005D1 RID: 1489
|
||||
internal abstract bool HaveRemoteValidation2Callback { get; }
|
||||
|
||||
// Token: 0x060005D2 RID: 1490
|
||||
internal abstract AsymmetricAlgorithm OnLocalPrivateKeySelection(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost);
|
||||
|
||||
// Token: 0x060005D3 RID: 1491 RVA: 0x0002156C File Offset: 0x0001F76C
|
||||
internal global::System.Security.Cryptography.X509Certificates.X509Certificate RaiseLocalCertificateSelection(global::System.Security.Cryptography.X509Certificates.X509CertificateCollection certificates, global::System.Security.Cryptography.X509Certificates.X509Certificate remoteCertificate, string targetHost, global::System.Security.Cryptography.X509Certificates.X509CertificateCollection requestedCertificates)
|
||||
{
|
||||
return this.OnLocalCertificateSelection(certificates, remoteCertificate, targetHost, requestedCertificates);
|
||||
}
|
||||
|
||||
// Token: 0x060005D4 RID: 1492 RVA: 0x0002157C File Offset: 0x0001F77C
|
||||
internal bool RaiseRemoteCertificateValidation(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, int[] errors)
|
||||
{
|
||||
return this.OnRemoteCertificateValidation(certificate, errors);
|
||||
}
|
||||
|
||||
// Token: 0x060005D5 RID: 1493 RVA: 0x00021588 File Offset: 0x0001F788
|
||||
internal ValidationResult RaiseRemoteCertificateValidation2(Mono.Security.X509.X509CertificateCollection collection)
|
||||
{
|
||||
return this.OnRemoteCertificateValidation2(collection);
|
||||
}
|
||||
|
||||
// Token: 0x060005D6 RID: 1494 RVA: 0x00021594 File Offset: 0x0001F794
|
||||
internal AsymmetricAlgorithm RaiseLocalPrivateKeySelection(global::System.Security.Cryptography.X509Certificates.X509Certificate certificate, string targetHost)
|
||||
{
|
||||
return this.OnLocalPrivateKeySelection(certificate, targetHost);
|
||||
}
|
||||
|
||||
// Token: 0x17000172 RID: 370
|
||||
// (get) Token: 0x060005D7 RID: 1495 RVA: 0x000215A0 File Offset: 0x0001F7A0
|
||||
// (set) Token: 0x060005D8 RID: 1496 RVA: 0x000215A8 File Offset: 0x0001F7A8
|
||||
public bool CheckCertRevocationStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.checkCertRevocationStatus;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.checkCertRevocationStatus = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000173 RID: 371
|
||||
// (get) Token: 0x060005D9 RID: 1497 RVA: 0x000215B4 File Offset: 0x0001F7B4
|
||||
public CipherAlgorithmType CipherAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.Current.Cipher.CipherAlgorithmType;
|
||||
}
|
||||
return CipherAlgorithmType.None;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000174 RID: 372
|
||||
// (get) Token: 0x060005DA RID: 1498 RVA: 0x000215EC File Offset: 0x0001F7EC
|
||||
public int CipherStrength
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return (int)this.context.Current.Cipher.EffectiveKeyBits;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000175 RID: 373
|
||||
// (get) Token: 0x060005DB RID: 1499 RVA: 0x00021624 File Offset: 0x0001F824
|
||||
public HashAlgorithmType HashAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.Current.Cipher.HashAlgorithmType;
|
||||
}
|
||||
return HashAlgorithmType.None;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000176 RID: 374
|
||||
// (get) Token: 0x060005DC RID: 1500 RVA: 0x0002165C File Offset: 0x0001F85C
|
||||
public int HashStrength
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.Current.Cipher.HashSize * 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000177 RID: 375
|
||||
// (get) Token: 0x060005DD RID: 1501 RVA: 0x00021694 File Offset: 0x0001F894
|
||||
public int KeyExchangeStrength
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.ServerSettings.Certificates[0].RSA.KeySize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000178 RID: 376
|
||||
// (get) Token: 0x060005DE RID: 1502 RVA: 0x000216D4 File Offset: 0x0001F8D4
|
||||
public ExchangeAlgorithmType KeyExchangeAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.Current.Cipher.ExchangeAlgorithmType;
|
||||
}
|
||||
return ExchangeAlgorithmType.None;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000179 RID: 377
|
||||
// (get) Token: 0x060005DF RID: 1503 RVA: 0x0002170C File Offset: 0x0001F90C
|
||||
public SecurityProtocolType SecurityProtocol
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished)
|
||||
{
|
||||
return this.context.SecurityProtocol;
|
||||
}
|
||||
return (SecurityProtocolType)0;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017A RID: 378
|
||||
// (get) Token: 0x060005E0 RID: 1504 RVA: 0x0002172C File Offset: 0x0001F92C
|
||||
public global::System.Security.Cryptography.X509Certificates.X509Certificate ServerCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished && this.context.ServerSettings.Certificates != null && this.context.ServerSettings.Certificates.Count > 0)
|
||||
{
|
||||
return new global::System.Security.Cryptography.X509Certificates.X509Certificate(this.context.ServerSettings.Certificates[0].RawData);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017B RID: 379
|
||||
// (get) Token: 0x060005E1 RID: 1505 RVA: 0x0002179C File Offset: 0x0001F99C
|
||||
internal Mono.Security.X509.X509CertificateCollection ServerCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.context.ServerSettings.Certificates;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005E2 RID: 1506 RVA: 0x000217B0 File Offset: 0x0001F9B0
|
||||
private bool BeginNegotiateHandshake(SslStreamBase.InternalAsyncResult asyncResult)
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
object obj = this.negotiate;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.None)
|
||||
{
|
||||
this.OnBeginNegotiateHandshake(new AsyncCallback(this.AsyncHandshakeCallback), asyncResult);
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.negotiationComplete.Set();
|
||||
this.protocol.SendAlert(ex.Alert);
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
this.negotiationComplete.Set();
|
||||
this.protocol.SendAlert(AlertDescription.InternalError);
|
||||
throw new IOException("The authentication or decryption has failed.", ex2);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x060005E3 RID: 1507 RVA: 0x000218B4 File Offset: 0x0001FAB4
|
||||
private void EndNegotiateHandshake(SslStreamBase.InternalAsyncResult asyncResult)
|
||||
{
|
||||
if (!asyncResult.IsCompleted)
|
||||
{
|
||||
asyncResult.AsyncWaitHandle.WaitOne();
|
||||
}
|
||||
if (asyncResult.CompletedWithError)
|
||||
{
|
||||
throw asyncResult.AsyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005E4 RID: 1508 RVA: 0x000218EC File Offset: 0x0001FAEC
|
||||
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
this.checkDisposed();
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer is a null reference.");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is less than 0.");
|
||||
}
|
||||
if (offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than 0.");
|
||||
}
|
||||
if (count > buffer.Length - offset)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
|
||||
}
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = new SslStreamBase.InternalAsyncResult(callback, state, buffer, offset, count, false, true);
|
||||
if (this.MightNeedHandshake)
|
||||
{
|
||||
if (!this.BeginNegotiateHandshake(internalAsyncResult))
|
||||
{
|
||||
this.negotiationComplete.WaitOne();
|
||||
this.InternalBeginRead(internalAsyncResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.InternalBeginRead(internalAsyncResult);
|
||||
}
|
||||
return internalAsyncResult;
|
||||
}
|
||||
|
||||
// Token: 0x060005E5 RID: 1509 RVA: 0x000219A4 File Offset: 0x0001FBA4
|
||||
private void InternalBeginRead(SslStreamBase.InternalAsyncResult asyncResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
int num = 0;
|
||||
object obj = this.read;
|
||||
lock (obj)
|
||||
{
|
||||
bool flag = this.inputBuffer.Position == this.inputBuffer.Length && this.inputBuffer.Length > 0L;
|
||||
bool flag2 = this.inputBuffer.Length > 0L && asyncResult.Count > 0;
|
||||
if (flag)
|
||||
{
|
||||
this.resetBuffer();
|
||||
}
|
||||
else if (flag2)
|
||||
{
|
||||
num = this.inputBuffer.Read(asyncResult.Buffer, asyncResult.Offset, asyncResult.Count);
|
||||
}
|
||||
}
|
||||
if (0 < num)
|
||||
{
|
||||
asyncResult.SetComplete(num);
|
||||
}
|
||||
else if (!this.context.ReceivedConnectionEnd)
|
||||
{
|
||||
this.innerStream.BeginRead(this.recbuf, 0, this.recbuf.Length, new AsyncCallback(this.InternalReadCallback), new object[] { this.recbuf, asyncResult });
|
||||
}
|
||||
else
|
||||
{
|
||||
asyncResult.SetComplete(0);
|
||||
}
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.protocol.SendAlert(ex.Alert);
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
throw new IOException("IO exception during read.", ex2);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005E6 RID: 1510 RVA: 0x00021B44 File Offset: 0x0001FD44
|
||||
private void InternalReadCallback(IAsyncResult result)
|
||||
{
|
||||
if (this.disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
object[] array = (object[])result.AsyncState;
|
||||
byte[] array2 = (byte[])array[0];
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = (SslStreamBase.InternalAsyncResult)array[1];
|
||||
try
|
||||
{
|
||||
int num = this.innerStream.EndRead(result);
|
||||
if (num > 0)
|
||||
{
|
||||
this.recordStream.Write(array2, 0, num);
|
||||
bool flag = false;
|
||||
long num2 = this.recordStream.Position;
|
||||
this.recordStream.Position = 0L;
|
||||
byte[] array3 = null;
|
||||
if (this.recordStream.Length >= 5L)
|
||||
{
|
||||
array3 = this.protocol.ReceiveRecord(this.recordStream);
|
||||
}
|
||||
while (array3 != null)
|
||||
{
|
||||
long num3 = this.recordStream.Length - this.recordStream.Position;
|
||||
byte[] array4 = null;
|
||||
if (num3 > 0L)
|
||||
{
|
||||
array4 = new byte[num3];
|
||||
this.recordStream.Read(array4, 0, array4.Length);
|
||||
}
|
||||
object obj = this.read;
|
||||
lock (obj)
|
||||
{
|
||||
long position = this.inputBuffer.Position;
|
||||
if (array3.Length > 0)
|
||||
{
|
||||
this.inputBuffer.Seek(0L, SeekOrigin.End);
|
||||
this.inputBuffer.Write(array3, 0, array3.Length);
|
||||
this.inputBuffer.Seek(position, SeekOrigin.Begin);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
this.recordStream.SetLength(0L);
|
||||
array3 = null;
|
||||
if (num3 > 0L)
|
||||
{
|
||||
this.recordStream.Write(array4, 0, array4.Length);
|
||||
if (this.recordStream.Length >= 5L)
|
||||
{
|
||||
this.recordStream.Position = 0L;
|
||||
array3 = this.protocol.ReceiveRecord(this.recordStream);
|
||||
if (array3 == null)
|
||||
{
|
||||
num2 = this.recordStream.Length;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = num3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = 0L;
|
||||
}
|
||||
}
|
||||
if (!flag && num > 0)
|
||||
{
|
||||
if (this.context.ReceivedConnectionEnd)
|
||||
{
|
||||
internalAsyncResult.SetComplete(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.recordStream.Position = this.recordStream.Length;
|
||||
this.innerStream.BeginRead(array2, 0, array2.Length, new AsyncCallback(this.InternalReadCallback), array);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.recordStream.Position = num2;
|
||||
int num4 = 0;
|
||||
object obj2 = this.read;
|
||||
lock (obj2)
|
||||
{
|
||||
num4 = this.inputBuffer.Read(internalAsyncResult.Buffer, internalAsyncResult.Offset, internalAsyncResult.Count);
|
||||
}
|
||||
internalAsyncResult.SetComplete(num4);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
internalAsyncResult.SetComplete(0);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
internalAsyncResult.SetComplete(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005E7 RID: 1511 RVA: 0x00021E44 File Offset: 0x00020044
|
||||
private void InternalBeginWrite(SslStreamBase.InternalAsyncResult asyncResult)
|
||||
{
|
||||
try
|
||||
{
|
||||
object obj = this.write;
|
||||
lock (obj)
|
||||
{
|
||||
byte[] array = this.protocol.EncodeRecord(ContentType.ApplicationData, asyncResult.Buffer, asyncResult.Offset, asyncResult.Count);
|
||||
this.innerStream.BeginWrite(array, 0, array.Length, new AsyncCallback(this.InternalWriteCallback), asyncResult);
|
||||
}
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.protocol.SendAlert(ex.Alert);
|
||||
this.Close();
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
throw new IOException("IO exception during Write.", ex2);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005E8 RID: 1512 RVA: 0x00021F34 File Offset: 0x00020134
|
||||
private void InternalWriteCallback(IAsyncResult ar)
|
||||
{
|
||||
if (this.disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = (SslStreamBase.InternalAsyncResult)ar.AsyncState;
|
||||
try
|
||||
{
|
||||
this.innerStream.EndWrite(ar);
|
||||
internalAsyncResult.SetComplete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
internalAsyncResult.SetComplete(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005E9 RID: 1513 RVA: 0x00021F9C File Offset: 0x0002019C
|
||||
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||
{
|
||||
this.checkDisposed();
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer is a null reference.");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is less than 0.");
|
||||
}
|
||||
if (offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than 0.");
|
||||
}
|
||||
if (count > buffer.Length - offset)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
|
||||
}
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = new SslStreamBase.InternalAsyncResult(callback, state, buffer, offset, count, true, true);
|
||||
if (this.MightNeedHandshake)
|
||||
{
|
||||
if (!this.BeginNegotiateHandshake(internalAsyncResult))
|
||||
{
|
||||
this.negotiationComplete.WaitOne();
|
||||
this.InternalBeginWrite(internalAsyncResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.InternalBeginWrite(internalAsyncResult);
|
||||
}
|
||||
return internalAsyncResult;
|
||||
}
|
||||
|
||||
// Token: 0x060005EA RID: 1514 RVA: 0x00022054 File Offset: 0x00020254
|
||||
public override int EndRead(IAsyncResult asyncResult)
|
||||
{
|
||||
this.checkDisposed();
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = asyncResult as SslStreamBase.InternalAsyncResult;
|
||||
if (internalAsyncResult == null)
|
||||
{
|
||||
throw new ArgumentNullException("asyncResult is null or was not obtained by calling BeginRead.");
|
||||
}
|
||||
if (!asyncResult.IsCompleted && !asyncResult.AsyncWaitHandle.WaitOne(300000, false))
|
||||
{
|
||||
throw new TlsException(AlertDescription.InternalError, "Couldn't complete EndRead");
|
||||
}
|
||||
if (internalAsyncResult.CompletedWithError)
|
||||
{
|
||||
throw internalAsyncResult.AsyncException;
|
||||
}
|
||||
return internalAsyncResult.BytesRead;
|
||||
}
|
||||
|
||||
// Token: 0x060005EB RID: 1515 RVA: 0x000220C8 File Offset: 0x000202C8
|
||||
public override void EndWrite(IAsyncResult asyncResult)
|
||||
{
|
||||
this.checkDisposed();
|
||||
SslStreamBase.InternalAsyncResult internalAsyncResult = asyncResult as SslStreamBase.InternalAsyncResult;
|
||||
if (internalAsyncResult == null)
|
||||
{
|
||||
throw new ArgumentNullException("asyncResult is null or was not obtained by calling BeginWrite.");
|
||||
}
|
||||
if (!asyncResult.IsCompleted && !internalAsyncResult.AsyncWaitHandle.WaitOne(300000, false))
|
||||
{
|
||||
throw new TlsException(AlertDescription.InternalError, "Couldn't complete EndWrite");
|
||||
}
|
||||
if (internalAsyncResult.CompletedWithError)
|
||||
{
|
||||
throw internalAsyncResult.AsyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005EC RID: 1516 RVA: 0x00022134 File Offset: 0x00020334
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
}
|
||||
|
||||
// Token: 0x060005ED RID: 1517 RVA: 0x0002213C File Offset: 0x0002033C
|
||||
public override void Flush()
|
||||
{
|
||||
this.checkDisposed();
|
||||
this.innerStream.Flush();
|
||||
}
|
||||
|
||||
// Token: 0x060005EE RID: 1518 RVA: 0x00022150 File Offset: 0x00020350
|
||||
public int Read(byte[] buffer)
|
||||
{
|
||||
return this.Read(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060005EF RID: 1519 RVA: 0x00022160 File Offset: 0x00020360
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
this.checkDisposed();
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is less than 0.");
|
||||
}
|
||||
if (offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than 0.");
|
||||
}
|
||||
if (count > buffer.Length - offset)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
|
||||
}
|
||||
if (this.context.HandshakeState != HandshakeState.Finished)
|
||||
{
|
||||
this.NegotiateHandshake();
|
||||
}
|
||||
object obj = this.read;
|
||||
int num6;
|
||||
lock (obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
SslStreamBase.record_processing.Reset();
|
||||
if (this.inputBuffer.Position > 0L)
|
||||
{
|
||||
if (this.inputBuffer.Position == this.inputBuffer.Length)
|
||||
{
|
||||
this.inputBuffer.SetLength(0L);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = this.inputBuffer.Read(buffer, offset, count);
|
||||
if (num > 0)
|
||||
{
|
||||
SslStreamBase.record_processing.Set();
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool flag = false;
|
||||
for (;;)
|
||||
{
|
||||
if (this.recordStream.Position == 0L || flag)
|
||||
{
|
||||
flag = false;
|
||||
byte[] array = new byte[16384];
|
||||
int num2 = 0;
|
||||
if (count == 1)
|
||||
{
|
||||
int num3 = this.innerStream.ReadByte();
|
||||
if (num3 >= 0)
|
||||
{
|
||||
array[0] = (byte)num3;
|
||||
num2 = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = this.innerStream.Read(array, 0, array.Length);
|
||||
}
|
||||
if (num2 <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (this.recordStream.Length > 0L && this.recordStream.Position != this.recordStream.Length)
|
||||
{
|
||||
this.recordStream.Seek(0L, SeekOrigin.End);
|
||||
}
|
||||
this.recordStream.Write(array, 0, num2);
|
||||
}
|
||||
bool flag2 = false;
|
||||
this.recordStream.Position = 0L;
|
||||
byte[] array2 = null;
|
||||
if (this.recordStream.Length >= 5L)
|
||||
{
|
||||
array2 = this.protocol.ReceiveRecord(this.recordStream);
|
||||
flag = array2 == null;
|
||||
}
|
||||
while (array2 != null)
|
||||
{
|
||||
long num4 = this.recordStream.Length - this.recordStream.Position;
|
||||
byte[] array3 = null;
|
||||
if (num4 > 0L)
|
||||
{
|
||||
array3 = new byte[num4];
|
||||
this.recordStream.Read(array3, 0, array3.Length);
|
||||
}
|
||||
long position = this.inputBuffer.Position;
|
||||
if (array2.Length > 0)
|
||||
{
|
||||
this.inputBuffer.Seek(0L, SeekOrigin.End);
|
||||
this.inputBuffer.Write(array2, 0, array2.Length);
|
||||
this.inputBuffer.Seek(position, SeekOrigin.Begin);
|
||||
flag2 = true;
|
||||
}
|
||||
this.recordStream.SetLength(0L);
|
||||
array2 = null;
|
||||
if (num4 > 0L)
|
||||
{
|
||||
this.recordStream.Write(array3, 0, array3.Length);
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
goto Block_23;
|
||||
}
|
||||
}
|
||||
}
|
||||
SslStreamBase.record_processing.Set();
|
||||
return 0;
|
||||
Block_23:
|
||||
int num5 = this.inputBuffer.Read(buffer, offset, count);
|
||||
SslStreamBase.record_processing.Set();
|
||||
num6 = num5;
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
throw new IOException("IO exception during read.", ex2);
|
||||
}
|
||||
}
|
||||
return num6;
|
||||
}
|
||||
|
||||
// Token: 0x060005F0 RID: 1520 RVA: 0x000224F0 File Offset: 0x000206F0
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
// Token: 0x060005F1 RID: 1521 RVA: 0x000224F8 File Offset: 0x000206F8
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
// Token: 0x060005F2 RID: 1522 RVA: 0x00022500 File Offset: 0x00020700
|
||||
public void Write(byte[] buffer)
|
||||
{
|
||||
this.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060005F3 RID: 1523 RVA: 0x00022510 File Offset: 0x00020710
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
this.checkDisposed();
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is less than 0.");
|
||||
}
|
||||
if (offset > buffer.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset is greater than the length of buffer.");
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than 0.");
|
||||
}
|
||||
if (count > buffer.Length - offset)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count is less than the length of buffer minus the value of the offset parameter.");
|
||||
}
|
||||
if (this.context.HandshakeState != HandshakeState.Finished)
|
||||
{
|
||||
this.NegotiateHandshake();
|
||||
}
|
||||
object obj = this.write;
|
||||
lock (obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] array = this.protocol.EncodeRecord(ContentType.ApplicationData, buffer, offset, count);
|
||||
this.innerStream.Write(array, 0, array.Length);
|
||||
}
|
||||
catch (TlsException ex)
|
||||
{
|
||||
this.protocol.SendAlert(ex.Alert);
|
||||
this.Close();
|
||||
throw new IOException("The authentication or decryption has failed.", ex);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
throw new IOException("IO exception during Write.", ex2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017C RID: 380
|
||||
// (get) Token: 0x060005F4 RID: 1524 RVA: 0x00022660 File Offset: 0x00020860
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.innerStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017D RID: 381
|
||||
// (get) Token: 0x060005F5 RID: 1525 RVA: 0x00022670 File Offset: 0x00020870
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017E RID: 382
|
||||
// (get) Token: 0x060005F6 RID: 1526 RVA: 0x00022674 File Offset: 0x00020874
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.innerStream.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700017F RID: 383
|
||||
// (get) Token: 0x060005F7 RID: 1527 RVA: 0x00022684 File Offset: 0x00020884
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000180 RID: 384
|
||||
// (get) Token: 0x060005F8 RID: 1528 RVA: 0x0002268C File Offset: 0x0002088C
|
||||
// (set) Token: 0x060005F9 RID: 1529 RVA: 0x00022694 File Offset: 0x00020894
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005FA RID: 1530 RVA: 0x0002269C File Offset: 0x0002089C
|
||||
~SslStreamBase()
|
||||
{
|
||||
this.Dispose(false);
|
||||
}
|
||||
|
||||
// Token: 0x060005FB RID: 1531 RVA: 0x000226D8 File Offset: 0x000208D8
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (!this.disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (this.innerStream != null)
|
||||
{
|
||||
if (this.context.HandshakeState == HandshakeState.Finished && !this.context.SentConnectionEnd)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.protocol.SendAlert(AlertDescription.CloseNotify);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (this.ownsStream)
|
||||
{
|
||||
this.innerStream.Close();
|
||||
}
|
||||
}
|
||||
this.ownsStream = false;
|
||||
this.innerStream = null;
|
||||
}
|
||||
this.disposed = true;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060005FC RID: 1532 RVA: 0x0002278C File Offset: 0x0002098C
|
||||
private void resetBuffer()
|
||||
{
|
||||
this.inputBuffer.SetLength(0L);
|
||||
this.inputBuffer.Position = 0L;
|
||||
}
|
||||
|
||||
// Token: 0x060005FD RID: 1533 RVA: 0x000227A8 File Offset: 0x000209A8
|
||||
internal void checkDisposed()
|
||||
{
|
||||
if (this.disposed)
|
||||
{
|
||||
throw new ObjectDisposedException("The Stream is closed.");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002D5 RID: 725
|
||||
private const int WaitTimeOut = 300000;
|
||||
|
||||
// Token: 0x040002D6 RID: 726
|
||||
private static ManualResetEvent record_processing = new ManualResetEvent(true);
|
||||
|
||||
// Token: 0x040002D7 RID: 727
|
||||
internal Stream innerStream;
|
||||
|
||||
// Token: 0x040002D8 RID: 728
|
||||
internal MemoryStream inputBuffer;
|
||||
|
||||
// Token: 0x040002D9 RID: 729
|
||||
internal Context context;
|
||||
|
||||
// Token: 0x040002DA RID: 730
|
||||
internal RecordProtocol protocol;
|
||||
|
||||
// Token: 0x040002DB RID: 731
|
||||
internal bool ownsStream;
|
||||
|
||||
// Token: 0x040002DC RID: 732
|
||||
private volatile bool disposed;
|
||||
|
||||
// Token: 0x040002DD RID: 733
|
||||
private bool checkCertRevocationStatus;
|
||||
|
||||
// Token: 0x040002DE RID: 734
|
||||
private object negotiate;
|
||||
|
||||
// Token: 0x040002DF RID: 735
|
||||
private object read;
|
||||
|
||||
// Token: 0x040002E0 RID: 736
|
||||
private object write;
|
||||
|
||||
// Token: 0x040002E1 RID: 737
|
||||
private ManualResetEvent negotiationComplete;
|
||||
|
||||
// Token: 0x040002E2 RID: 738
|
||||
private byte[] recbuf = new byte[16384];
|
||||
|
||||
// Token: 0x040002E3 RID: 739
|
||||
private MemoryStream recordStream = new MemoryStream();
|
||||
|
||||
// Token: 0x0200009E RID: 158
|
||||
private class InternalAsyncResult : IAsyncResult
|
||||
{
|
||||
// Token: 0x060005FE RID: 1534 RVA: 0x000227C4 File Offset: 0x000209C4
|
||||
public InternalAsyncResult(AsyncCallback userCallback, object userState, byte[] buffer, int offset, int count, bool fromWrite, bool proceedAfterHandshake)
|
||||
{
|
||||
this._userCallback = userCallback;
|
||||
this._userState = userState;
|
||||
this._buffer = buffer;
|
||||
this._offset = offset;
|
||||
this._count = count;
|
||||
this._fromWrite = fromWrite;
|
||||
this._proceedAfterHandshake = proceedAfterHandshake;
|
||||
}
|
||||
|
||||
// Token: 0x17000181 RID: 385
|
||||
// (get) Token: 0x060005FF RID: 1535 RVA: 0x00022818 File Offset: 0x00020A18
|
||||
public bool ProceedAfterHandshake
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._proceedAfterHandshake;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000182 RID: 386
|
||||
// (get) Token: 0x06000600 RID: 1536 RVA: 0x00022820 File Offset: 0x00020A20
|
||||
public bool FromWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._fromWrite;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000183 RID: 387
|
||||
// (get) Token: 0x06000601 RID: 1537 RVA: 0x00022828 File Offset: 0x00020A28
|
||||
public byte[] Buffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._buffer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000184 RID: 388
|
||||
// (get) Token: 0x06000602 RID: 1538 RVA: 0x00022830 File Offset: 0x00020A30
|
||||
public int Offset
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._offset;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000185 RID: 389
|
||||
// (get) Token: 0x06000603 RID: 1539 RVA: 0x00022838 File Offset: 0x00020A38
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._count;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000186 RID: 390
|
||||
// (get) Token: 0x06000604 RID: 1540 RVA: 0x00022840 File Offset: 0x00020A40
|
||||
public int BytesRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._bytesRead;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000187 RID: 391
|
||||
// (get) Token: 0x06000605 RID: 1541 RVA: 0x00022848 File Offset: 0x00020A48
|
||||
public object AsyncState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._userState;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000188 RID: 392
|
||||
// (get) Token: 0x06000606 RID: 1542 RVA: 0x00022850 File Offset: 0x00020A50
|
||||
public Exception AsyncException
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._asyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000189 RID: 393
|
||||
// (get) Token: 0x06000607 RID: 1543 RVA: 0x00022858 File Offset: 0x00020A58
|
||||
public bool CompletedWithError
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.IsCompleted && null != this._asyncException;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018A RID: 394
|
||||
// (get) Token: 0x06000608 RID: 1544 RVA: 0x00022874 File Offset: 0x00020A74
|
||||
public WaitHandle AsyncWaitHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = this.locker;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.handle == null)
|
||||
{
|
||||
this.handle = new ManualResetEvent(this.completed);
|
||||
}
|
||||
}
|
||||
return this.handle;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018B RID: 395
|
||||
// (get) Token: 0x06000609 RID: 1545 RVA: 0x000228D8 File Offset: 0x00020AD8
|
||||
public bool CompletedSynchronously
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018C RID: 396
|
||||
// (get) Token: 0x0600060A RID: 1546 RVA: 0x000228DC File Offset: 0x00020ADC
|
||||
public bool IsCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj = this.locker;
|
||||
bool flag;
|
||||
lock (obj)
|
||||
{
|
||||
flag = this.completed;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600060B RID: 1547 RVA: 0x0002292C File Offset: 0x00020B2C
|
||||
private void SetComplete(Exception ex, int bytesRead)
|
||||
{
|
||||
object obj = this.locker;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.completed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.completed = true;
|
||||
this._asyncException = ex;
|
||||
this._bytesRead = bytesRead;
|
||||
if (this.handle != null)
|
||||
{
|
||||
this.handle.Set();
|
||||
}
|
||||
}
|
||||
if (this._userCallback != null)
|
||||
{
|
||||
this._userCallback.BeginInvoke(this, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600060C RID: 1548 RVA: 0x000229C4 File Offset: 0x00020BC4
|
||||
public void SetComplete(Exception ex)
|
||||
{
|
||||
this.SetComplete(ex, 0);
|
||||
}
|
||||
|
||||
// Token: 0x0600060D RID: 1549 RVA: 0x000229D0 File Offset: 0x00020BD0
|
||||
public void SetComplete(int bytesRead)
|
||||
{
|
||||
this.SetComplete(null, bytesRead);
|
||||
}
|
||||
|
||||
// Token: 0x0600060E RID: 1550 RVA: 0x000229DC File Offset: 0x00020BDC
|
||||
public void SetComplete()
|
||||
{
|
||||
this.SetComplete(null, 0);
|
||||
}
|
||||
|
||||
// Token: 0x040002E4 RID: 740
|
||||
private object locker = new object();
|
||||
|
||||
// Token: 0x040002E5 RID: 741
|
||||
private AsyncCallback _userCallback;
|
||||
|
||||
// Token: 0x040002E6 RID: 742
|
||||
private object _userState;
|
||||
|
||||
// Token: 0x040002E7 RID: 743
|
||||
private Exception _asyncException;
|
||||
|
||||
// Token: 0x040002E8 RID: 744
|
||||
private ManualResetEvent handle;
|
||||
|
||||
// Token: 0x040002E9 RID: 745
|
||||
private bool completed;
|
||||
|
||||
// Token: 0x040002EA RID: 746
|
||||
private int _bytesRead;
|
||||
|
||||
// Token: 0x040002EB RID: 747
|
||||
private bool _fromWrite;
|
||||
|
||||
// Token: 0x040002EC RID: 748
|
||||
private bool _proceedAfterHandshake;
|
||||
|
||||
// Token: 0x040002ED RID: 749
|
||||
private byte[] _buffer;
|
||||
|
||||
// Token: 0x040002EE RID: 750
|
||||
private int _offset;
|
||||
|
||||
// Token: 0x040002EF RID: 751
|
||||
private int _count;
|
||||
}
|
||||
|
||||
// Token: 0x020000C9 RID: 201
|
||||
// (Invoke) Token: 0x06000709 RID: 1801
|
||||
private delegate void AsyncHandshakeDelegate(SslStreamBase.InternalAsyncResult asyncResult, bool fromWrite);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x0200009F RID: 159
|
||||
internal class TlsCipherSuite : CipherSuite
|
||||
{
|
||||
// Token: 0x0600060F RID: 1551 RVA: 0x000229E8 File Offset: 0x00020BE8
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000610 RID: 1552 RVA: 0x00022A1C File Offset: 0x00020C1C
|
||||
public override byte[] ComputeServerRecordMAC(ContentType contentType, byte[] fragment)
|
||||
{
|
||||
object obj = this.headerLock;
|
||||
byte[] hash;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.header == null)
|
||||
{
|
||||
this.header = new byte[13];
|
||||
}
|
||||
ulong num = ((!(base.Context is ClientContext)) ? base.Context.WriteSequenceNumber : base.Context.ReadSequenceNumber);
|
||||
base.Write(this.header, 0, num);
|
||||
this.header[8] = (byte)contentType;
|
||||
base.Write(this.header, 9, base.Context.Protocol);
|
||||
base.Write(this.header, 11, (short)fragment.Length);
|
||||
HashAlgorithm serverHMAC = base.ServerHMAC;
|
||||
serverHMAC.TransformBlock(this.header, 0, this.header.Length, this.header, 0);
|
||||
serverHMAC.TransformBlock(fragment, 0, fragment.Length, fragment, 0);
|
||||
serverHMAC.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
hash = serverHMAC.Hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Token: 0x06000611 RID: 1553 RVA: 0x00022B34 File Offset: 0x00020D34
|
||||
public override byte[] ComputeClientRecordMAC(ContentType contentType, byte[] fragment)
|
||||
{
|
||||
object obj = this.headerLock;
|
||||
byte[] hash;
|
||||
lock (obj)
|
||||
{
|
||||
if (this.header == null)
|
||||
{
|
||||
this.header = new byte[13];
|
||||
}
|
||||
ulong num = ((!(base.Context is ClientContext)) ? base.Context.ReadSequenceNumber : base.Context.WriteSequenceNumber);
|
||||
base.Write(this.header, 0, num);
|
||||
this.header[8] = (byte)contentType;
|
||||
base.Write(this.header, 9, base.Context.Protocol);
|
||||
base.Write(this.header, 11, (short)fragment.Length);
|
||||
HashAlgorithm clientHMAC = base.ClientHMAC;
|
||||
clientHMAC.TransformBlock(this.header, 0, this.header.Length, this.header, 0);
|
||||
clientHMAC.TransformBlock(fragment, 0, fragment.Length, fragment, 0);
|
||||
clientHMAC.TransformFinalBlock(CipherSuite.EmptyArray, 0, 0);
|
||||
hash = clientHMAC.Hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Token: 0x06000612 RID: 1554 RVA: 0x00022C4C File Offset: 0x00020E4C
|
||||
public override void ComputeMasterSecret(byte[] preMasterSecret)
|
||||
{
|
||||
base.Context.MasterSecret = new byte[preMasterSecret.Length];
|
||||
base.Context.MasterSecret = base.PRF(preMasterSecret, "master secret", base.Context.RandomCS, 48);
|
||||
}
|
||||
|
||||
// Token: 0x06000613 RID: 1555 RVA: 0x00022C90 File Offset: 0x00020E90
|
||||
public override void ComputeKeys()
|
||||
{
|
||||
TlsStream tlsStream = new TlsStream(base.PRF(base.Context.MasterSecret, "key expansion", base.Context.RandomSC, base.KeyBlockSize));
|
||||
base.Context.Negotiating.ClientWriteMAC = tlsStream.ReadBytes(base.HashSize);
|
||||
base.Context.Negotiating.ServerWriteMAC = tlsStream.ReadBytes(base.HashSize);
|
||||
base.Context.ClientWriteKey = tlsStream.ReadBytes((int)base.KeyMaterialSize);
|
||||
base.Context.ServerWriteKey = tlsStream.ReadBytes((int)base.KeyMaterialSize);
|
||||
if (!base.IsExportable)
|
||||
{
|
||||
if (base.IvSize != 0)
|
||||
{
|
||||
base.Context.ClientWriteIV = tlsStream.ReadBytes((int)base.IvSize);
|
||||
base.Context.ServerWriteIV = tlsStream.ReadBytes((int)base.IvSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Context.ClientWriteIV = CipherSuite.EmptyArray;
|
||||
base.Context.ServerWriteIV = CipherSuite.EmptyArray;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] array = base.PRF(base.Context.ClientWriteKey, "client write key", base.Context.RandomCS, (int)base.ExpandedKeyMaterialSize);
|
||||
byte[] array2 = base.PRF(base.Context.ServerWriteKey, "server write key", base.Context.RandomCS, (int)base.ExpandedKeyMaterialSize);
|
||||
base.Context.ClientWriteKey = array;
|
||||
base.Context.ServerWriteKey = array2;
|
||||
if (base.IvSize > 0)
|
||||
{
|
||||
byte[] array3 = base.PRF(CipherSuite.EmptyArray, "IV block", base.Context.RandomCS, (int)(base.IvSize * 2));
|
||||
base.Context.ClientWriteIV = new byte[(int)base.IvSize];
|
||||
Buffer.BlockCopy(array3, 0, base.Context.ClientWriteIV, 0, base.Context.ClientWriteIV.Length);
|
||||
base.Context.ServerWriteIV = new byte[(int)base.IvSize];
|
||||
Buffer.BlockCopy(array3, (int)base.IvSize, base.Context.ServerWriteIV, 0, base.Context.ServerWriteIV.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Context.ClientWriteIV = CipherSuite.EmptyArray;
|
||||
base.Context.ServerWriteIV = CipherSuite.EmptyArray;
|
||||
}
|
||||
}
|
||||
ClientSessionCache.SetContextInCache(base.Context);
|
||||
tlsStream.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x040002F0 RID: 752
|
||||
private const int MacHeaderLength = 13;
|
||||
|
||||
// Token: 0x040002F1 RID: 753
|
||||
private byte[] header;
|
||||
|
||||
// Token: 0x040002F2 RID: 754
|
||||
private object headerLock = new object();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Security.Cryptography;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000A0 RID: 160
|
||||
internal sealed class TlsClientSettings
|
||||
{
|
||||
// Token: 0x06000614 RID: 1556 RVA: 0x00022EE0 File Offset: 0x000210E0
|
||||
public TlsClientSettings()
|
||||
{
|
||||
this.certificates = new global::System.Security.Cryptography.X509Certificates.X509CertificateCollection();
|
||||
this.targetHost = string.Empty;
|
||||
}
|
||||
|
||||
// Token: 0x1700018D RID: 397
|
||||
// (get) Token: 0x06000615 RID: 1557 RVA: 0x00022F00 File Offset: 0x00021100
|
||||
// (set) Token: 0x06000616 RID: 1558 RVA: 0x00022F08 File Offset: 0x00021108
|
||||
public string TargetHost
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.targetHost;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.targetHost = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018E RID: 398
|
||||
// (get) Token: 0x06000617 RID: 1559 RVA: 0x00022F14 File Offset: 0x00021114
|
||||
// (set) Token: 0x06000618 RID: 1560 RVA: 0x00022F1C File Offset: 0x0002111C
|
||||
public global::System.Security.Cryptography.X509Certificates.X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certificates;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.certificates = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700018F RID: 399
|
||||
// (get) Token: 0x06000619 RID: 1561 RVA: 0x00022F28 File Offset: 0x00021128
|
||||
// (set) Token: 0x0600061A RID: 1562 RVA: 0x00022F30 File Offset: 0x00021130
|
||||
public global::System.Security.Cryptography.X509Certificates.X509Certificate ClientCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.clientCertificate;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.clientCertificate = value;
|
||||
this.UpdateCertificateRSA();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000190 RID: 400
|
||||
// (get) Token: 0x0600061B RID: 1563 RVA: 0x00022F40 File Offset: 0x00021140
|
||||
public RSAManaged CertificateRSA
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certificateRSA;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600061C RID: 1564 RVA: 0x00022F48 File Offset: 0x00021148
|
||||
public void UpdateCertificateRSA()
|
||||
{
|
||||
if (this.clientCertificate == null)
|
||||
{
|
||||
this.certificateRSA = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
Mono.Security.X509.X509Certificate x509Certificate = new Mono.Security.X509.X509Certificate(this.clientCertificate.GetRawCertData());
|
||||
this.certificateRSA = new RSAManaged(x509Certificate.RSA.KeySize);
|
||||
this.certificateRSA.ImportParameters(x509Certificate.RSA.ExportParameters(false));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002F3 RID: 755
|
||||
private string targetHost;
|
||||
|
||||
// Token: 0x040002F4 RID: 756
|
||||
private global::System.Security.Cryptography.X509Certificates.X509CertificateCollection certificates;
|
||||
|
||||
// Token: 0x040002F5 RID: 757
|
||||
private global::System.Security.Cryptography.X509Certificates.X509Certificate clientCertificate;
|
||||
|
||||
// Token: 0x040002F6 RID: 758
|
||||
private RSAManaged certificateRSA;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000A1 RID: 161
|
||||
[Serializable]
|
||||
internal sealed class TlsException : Exception
|
||||
{
|
||||
// Token: 0x0600061D RID: 1565 RVA: 0x00022FAC File Offset: 0x000211AC
|
||||
internal TlsException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600061E RID: 1566 RVA: 0x00022FB8 File Offset: 0x000211B8
|
||||
internal TlsException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600061F RID: 1567 RVA: 0x00022FC4 File Offset: 0x000211C4
|
||||
internal TlsException(string message, Exception ex)
|
||||
: base(message, ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000620 RID: 1568 RVA: 0x00022FD0 File Offset: 0x000211D0
|
||||
internal TlsException(AlertLevel level, AlertDescription description)
|
||||
: this(level, description, Alert.GetAlertMessage(description))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000621 RID: 1569 RVA: 0x00022FE0 File Offset: 0x000211E0
|
||||
internal TlsException(AlertLevel level, AlertDescription description, string message)
|
||||
: base(message)
|
||||
{
|
||||
this.alert = new Alert(level, description);
|
||||
}
|
||||
|
||||
// Token: 0x06000622 RID: 1570 RVA: 0x00022FF8 File Offset: 0x000211F8
|
||||
internal TlsException(AlertDescription description)
|
||||
: this(description, Alert.GetAlertMessage(description))
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000623 RID: 1571 RVA: 0x00023008 File Offset: 0x00021208
|
||||
internal TlsException(AlertDescription description, string message)
|
||||
: base(message)
|
||||
{
|
||||
this.alert = new Alert(description);
|
||||
}
|
||||
|
||||
// Token: 0x17000191 RID: 401
|
||||
// (get) Token: 0x06000624 RID: 1572 RVA: 0x00023020 File Offset: 0x00021220
|
||||
public Alert Alert
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.alert;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002F7 RID: 759
|
||||
private Alert alert;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using Mono.Security.Cryptography;
|
||||
using Mono.Security.Protocol.Tls.Handshake;
|
||||
using Mono.Security.X509;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000A2 RID: 162
|
||||
internal class TlsServerSettings
|
||||
{
|
||||
// Token: 0x17000192 RID: 402
|
||||
// (get) Token: 0x06000626 RID: 1574 RVA: 0x00023030 File Offset: 0x00021230
|
||||
// (set) Token: 0x06000627 RID: 1575 RVA: 0x00023038 File Offset: 0x00021238
|
||||
public bool ServerKeyExchange
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.serverKeyExchange;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.serverKeyExchange = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000193 RID: 403
|
||||
// (get) Token: 0x06000628 RID: 1576 RVA: 0x00023044 File Offset: 0x00021244
|
||||
// (set) Token: 0x06000629 RID: 1577 RVA: 0x0002304C File Offset: 0x0002124C
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certificates;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.certificates = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000194 RID: 404
|
||||
// (get) Token: 0x0600062A RID: 1578 RVA: 0x00023058 File Offset: 0x00021258
|
||||
public RSA CertificateRSA
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certificateRSA;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000195 RID: 405
|
||||
// (get) Token: 0x0600062B RID: 1579 RVA: 0x00023060 File Offset: 0x00021260
|
||||
// (set) Token: 0x0600062C RID: 1580 RVA: 0x00023068 File Offset: 0x00021268
|
||||
public RSAParameters RsaParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.rsaParameters;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.rsaParameters = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000196 RID: 406
|
||||
// (get) Token: 0x0600062D RID: 1581 RVA: 0x00023074 File Offset: 0x00021274
|
||||
// (set) Token: 0x0600062E RID: 1582 RVA: 0x0002307C File Offset: 0x0002127C
|
||||
public byte[] SignedParams
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signedParams;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.signedParams = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000197 RID: 407
|
||||
// (get) Token: 0x0600062F RID: 1583 RVA: 0x00023088 File Offset: 0x00021288
|
||||
// (set) Token: 0x06000630 RID: 1584 RVA: 0x00023090 File Offset: 0x00021290
|
||||
public bool CertificateRequest
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certificateRequest;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.certificateRequest = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000198 RID: 408
|
||||
// (get) Token: 0x06000631 RID: 1585 RVA: 0x0002309C File Offset: 0x0002129C
|
||||
// (set) Token: 0x06000632 RID: 1586 RVA: 0x000230A4 File Offset: 0x000212A4
|
||||
public ClientCertificateType[] CertificateTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.certificateTypes;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.certificateTypes = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000199 RID: 409
|
||||
// (get) Token: 0x06000633 RID: 1587 RVA: 0x000230B0 File Offset: 0x000212B0
|
||||
// (set) Token: 0x06000634 RID: 1588 RVA: 0x000230B8 File Offset: 0x000212B8
|
||||
public string[] DistinguisedNames
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.distinguisedNames;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.distinguisedNames = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000635 RID: 1589 RVA: 0x000230C4 File Offset: 0x000212C4
|
||||
public void UpdateCertificateRSA()
|
||||
{
|
||||
if (this.certificates == null || this.certificates.Count == 0)
|
||||
{
|
||||
this.certificateRSA = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.certificateRSA = new RSAManaged(this.certificates[0].RSA.KeySize);
|
||||
this.certificateRSA.ImportParameters(this.certificates[0].RSA.ExportParameters(false));
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002F8 RID: 760
|
||||
private X509CertificateCollection certificates;
|
||||
|
||||
// Token: 0x040002F9 RID: 761
|
||||
private RSA certificateRSA;
|
||||
|
||||
// Token: 0x040002FA RID: 762
|
||||
private RSAParameters rsaParameters;
|
||||
|
||||
// Token: 0x040002FB RID: 763
|
||||
private byte[] signedParams;
|
||||
|
||||
// Token: 0x040002FC RID: 764
|
||||
private string[] distinguisedNames;
|
||||
|
||||
// Token: 0x040002FD RID: 765
|
||||
private bool serverKeyExchange;
|
||||
|
||||
// Token: 0x040002FE RID: 766
|
||||
private bool certificateRequest;
|
||||
|
||||
// Token: 0x040002FF RID: 767
|
||||
private ClientCertificateType[] certificateTypes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x020000A3 RID: 163
|
||||
internal class TlsStream : Stream
|
||||
{
|
||||
// Token: 0x06000636 RID: 1590 RVA: 0x0002313C File Offset: 0x0002133C
|
||||
public TlsStream()
|
||||
{
|
||||
this.buffer = new MemoryStream(0);
|
||||
this.canRead = false;
|
||||
this.canWrite = true;
|
||||
}
|
||||
|
||||
// Token: 0x06000637 RID: 1591 RVA: 0x0002316C File Offset: 0x0002136C
|
||||
public TlsStream(byte[] data)
|
||||
{
|
||||
if (data != null)
|
||||
{
|
||||
this.buffer = new MemoryStream(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buffer = new MemoryStream();
|
||||
}
|
||||
this.canRead = true;
|
||||
this.canWrite = false;
|
||||
}
|
||||
|
||||
// Token: 0x1700019A RID: 410
|
||||
// (get) Token: 0x06000638 RID: 1592 RVA: 0x000231B0 File Offset: 0x000213B0
|
||||
public bool EOF
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Position >= this.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019B RID: 411
|
||||
// (get) Token: 0x06000639 RID: 1593 RVA: 0x000231C8 File Offset: 0x000213C8
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.canWrite;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019C RID: 412
|
||||
// (get) Token: 0x0600063A RID: 1594 RVA: 0x000231D0 File Offset: 0x000213D0
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.canRead;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019D RID: 413
|
||||
// (get) Token: 0x0600063B RID: 1595 RVA: 0x000231D8 File Offset: 0x000213D8
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.buffer.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019E RID: 414
|
||||
// (get) Token: 0x0600063C RID: 1596 RVA: 0x000231E8 File Offset: 0x000213E8
|
||||
// (set) Token: 0x0600063D RID: 1597 RVA: 0x000231F8 File Offset: 0x000213F8
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.buffer.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.buffer.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700019F RID: 415
|
||||
// (get) Token: 0x0600063E RID: 1598 RVA: 0x00023208 File Offset: 0x00021408
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.buffer.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600063F RID: 1599 RVA: 0x00023218 File Offset: 0x00021418
|
||||
private byte[] ReadSmallValue(int length)
|
||||
{
|
||||
if (length > 4)
|
||||
{
|
||||
throw new ArgumentException("8 bytes maximum");
|
||||
}
|
||||
if (this.temp == null)
|
||||
{
|
||||
this.temp = new byte[4];
|
||||
}
|
||||
if (this.Read(this.temp, 0, length) != length)
|
||||
{
|
||||
throw new TlsException(string.Format("buffer underrun", new object[0]));
|
||||
}
|
||||
return this.temp;
|
||||
}
|
||||
|
||||
// Token: 0x06000640 RID: 1600 RVA: 0x00023280 File Offset: 0x00021480
|
||||
public new byte ReadByte()
|
||||
{
|
||||
byte[] array = this.ReadSmallValue(1);
|
||||
return array[0];
|
||||
}
|
||||
|
||||
// Token: 0x06000641 RID: 1601 RVA: 0x00023298 File Offset: 0x00021498
|
||||
public short ReadInt16()
|
||||
{
|
||||
byte[] array = this.ReadSmallValue(2);
|
||||
return (short)(((int)array[0] << 8) | (int)array[1]);
|
||||
}
|
||||
|
||||
// Token: 0x06000642 RID: 1602 RVA: 0x000232B8 File Offset: 0x000214B8
|
||||
public int ReadInt24()
|
||||
{
|
||||
byte[] array = this.ReadSmallValue(3);
|
||||
return ((int)array[0] << 16) | ((int)array[1] << 8) | (int)array[2];
|
||||
}
|
||||
|
||||
// Token: 0x06000643 RID: 1603 RVA: 0x000232E0 File Offset: 0x000214E0
|
||||
public int ReadInt32()
|
||||
{
|
||||
byte[] array = this.ReadSmallValue(4);
|
||||
return ((int)array[0] << 24) | ((int)array[1] << 16) | ((int)array[2] << 8) | (int)array[3];
|
||||
}
|
||||
|
||||
// Token: 0x06000644 RID: 1604 RVA: 0x0002330C File Offset: 0x0002150C
|
||||
public byte[] ReadBytes(int count)
|
||||
{
|
||||
byte[] array = new byte[count];
|
||||
if (this.Read(array, 0, count) != count)
|
||||
{
|
||||
throw new TlsException("buffer underrun");
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
// Token: 0x06000645 RID: 1605 RVA: 0x0002333C File Offset: 0x0002153C
|
||||
public void Write(byte value)
|
||||
{
|
||||
if (this.temp == null)
|
||||
{
|
||||
this.temp = new byte[4];
|
||||
}
|
||||
this.temp[0] = value;
|
||||
this.Write(this.temp, 0, 1);
|
||||
}
|
||||
|
||||
// Token: 0x06000646 RID: 1606 RVA: 0x00023378 File Offset: 0x00021578
|
||||
public void Write(short value)
|
||||
{
|
||||
if (this.temp == null)
|
||||
{
|
||||
this.temp = new byte[4];
|
||||
}
|
||||
this.temp[0] = (byte)(value >> 8);
|
||||
this.temp[1] = (byte)value;
|
||||
this.Write(this.temp, 0, 2);
|
||||
}
|
||||
|
||||
// Token: 0x06000647 RID: 1607 RVA: 0x000233B8 File Offset: 0x000215B8
|
||||
public void WriteInt24(int value)
|
||||
{
|
||||
if (this.temp == null)
|
||||
{
|
||||
this.temp = new byte[4];
|
||||
}
|
||||
this.temp[0] = (byte)(value >> 16);
|
||||
this.temp[1] = (byte)(value >> 8);
|
||||
this.temp[2] = (byte)value;
|
||||
this.Write(this.temp, 0, 3);
|
||||
}
|
||||
|
||||
// Token: 0x06000648 RID: 1608 RVA: 0x00023410 File Offset: 0x00021610
|
||||
public void Write(int value)
|
||||
{
|
||||
if (this.temp == null)
|
||||
{
|
||||
this.temp = new byte[4];
|
||||
}
|
||||
this.temp[0] = (byte)(value >> 24);
|
||||
this.temp[1] = (byte)(value >> 16);
|
||||
this.temp[2] = (byte)(value >> 8);
|
||||
this.temp[3] = (byte)value;
|
||||
this.Write(this.temp, 0, 4);
|
||||
}
|
||||
|
||||
// Token: 0x06000649 RID: 1609 RVA: 0x00023474 File Offset: 0x00021674
|
||||
public void Write(ulong value)
|
||||
{
|
||||
this.Write((int)(value >> 32));
|
||||
this.Write((int)value);
|
||||
}
|
||||
|
||||
// Token: 0x0600064A RID: 1610 RVA: 0x0002348C File Offset: 0x0002168C
|
||||
public void Write(byte[] buffer)
|
||||
{
|
||||
this.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
// Token: 0x0600064B RID: 1611 RVA: 0x0002349C File Offset: 0x0002169C
|
||||
public void Reset()
|
||||
{
|
||||
this.buffer.SetLength(0L);
|
||||
this.buffer.Position = 0L;
|
||||
}
|
||||
|
||||
// Token: 0x0600064C RID: 1612 RVA: 0x000234B8 File Offset: 0x000216B8
|
||||
public byte[] ToArray()
|
||||
{
|
||||
return this.buffer.ToArray();
|
||||
}
|
||||
|
||||
// Token: 0x0600064D RID: 1613 RVA: 0x000234C8 File Offset: 0x000216C8
|
||||
public override void Flush()
|
||||
{
|
||||
this.buffer.Flush();
|
||||
}
|
||||
|
||||
// Token: 0x0600064E RID: 1614 RVA: 0x000234D8 File Offset: 0x000216D8
|
||||
public override void SetLength(long length)
|
||||
{
|
||||
this.buffer.SetLength(length);
|
||||
}
|
||||
|
||||
// Token: 0x0600064F RID: 1615 RVA: 0x000234E8 File Offset: 0x000216E8
|
||||
public override long Seek(long offset, SeekOrigin loc)
|
||||
{
|
||||
return this.buffer.Seek(offset, loc);
|
||||
}
|
||||
|
||||
// Token: 0x06000650 RID: 1616 RVA: 0x000234F8 File Offset: 0x000216F8
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (this.canRead)
|
||||
{
|
||||
return this.buffer.Read(buffer, offset, count);
|
||||
}
|
||||
throw new InvalidOperationException("Read operations are not allowed by this stream");
|
||||
}
|
||||
|
||||
// Token: 0x06000651 RID: 1617 RVA: 0x0002352C File Offset: 0x0002172C
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (this.canWrite)
|
||||
{
|
||||
this.buffer.Write(buffer, offset, count);
|
||||
return;
|
||||
}
|
||||
throw new InvalidOperationException("Write operations are not allowed by this stream");
|
||||
}
|
||||
|
||||
// Token: 0x04000300 RID: 768
|
||||
private const int temp_size = 4;
|
||||
|
||||
// Token: 0x04000301 RID: 769
|
||||
private bool canRead;
|
||||
|
||||
// Token: 0x04000302 RID: 770
|
||||
private bool canWrite;
|
||||
|
||||
// Token: 0x04000303 RID: 771
|
||||
private MemoryStream buffer;
|
||||
|
||||
// Token: 0x04000304 RID: 772
|
||||
private byte[] temp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.Protocol.Tls
|
||||
{
|
||||
// Token: 0x02000098 RID: 152
|
||||
public class ValidationResult
|
||||
{
|
||||
// Token: 0x06000577 RID: 1399 RVA: 0x0001FC20 File Offset: 0x0001DE20
|
||||
public ValidationResult(bool trusted, bool user_denied, int error_code)
|
||||
{
|
||||
this.trusted = trusted;
|
||||
this.user_denied = user_denied;
|
||||
this.error_code = error_code;
|
||||
}
|
||||
|
||||
// Token: 0x17000162 RID: 354
|
||||
// (get) Token: 0x06000578 RID: 1400 RVA: 0x0001FC40 File Offset: 0x0001DE40
|
||||
public bool Trusted
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.trusted;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000163 RID: 355
|
||||
// (get) Token: 0x06000579 RID: 1401 RVA: 0x0001FC48 File Offset: 0x0001DE48
|
||||
public bool UserDenied
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.user_denied;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000164 RID: 356
|
||||
// (get) Token: 0x0600057A RID: 1402 RVA: 0x0001FC50 File Offset: 0x0001DE50
|
||||
public int ErrorCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.error_code;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002BF RID: 703
|
||||
private bool trusted;
|
||||
|
||||
// Token: 0x040002C0 RID: 704
|
||||
private bool user_denied;
|
||||
|
||||
// Token: 0x040002C1 RID: 705
|
||||
private int error_code;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user