51 lines
2.3 KiB
C#
51 lines
2.3 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|