48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
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.");
|
|
}
|
|
}
|
|
}
|
|
}
|