培训考核三期,新版培训,网页版培训登录器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

70 lines
2.6 KiB

#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto.Impl;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls
{
/// <summary>Container class for generating signatures that carries the signature type, parameters, public key
/// certificate and public key's associated signer object.</summary>
public class DefaultTlsCredentialedSigner
: TlsCredentialedSigner
{
protected readonly TlsCryptoParameters m_cryptoParams;
protected readonly Certificate m_certificate;
protected readonly SignatureAndHashAlgorithm m_signatureAndHashAlgorithm;
protected readonly TlsSigner m_signer;
public DefaultTlsCredentialedSigner(TlsCryptoParameters cryptoParams, TlsSigner signer,
Certificate certificate, SignatureAndHashAlgorithm signatureAndHashAlgorithm)
{
if (certificate == null)
throw new ArgumentNullException("certificate");
if (certificate.IsEmpty)
throw new ArgumentException("cannot be empty", "certificate");
if (signer == null)
throw new ArgumentNullException("signer");
this.m_cryptoParams = cryptoParams;
this.m_certificate = certificate;
this.m_signatureAndHashAlgorithm = signatureAndHashAlgorithm;
this.m_signer = signer;
}
public virtual Certificate Certificate
{
get { return m_certificate; }
}
public virtual byte[] GenerateRawSignature(byte[] hash)
{
return m_signer.GenerateRawSignature(GetEffectiveAlgorithm(), hash);
}
public virtual SignatureAndHashAlgorithm SignatureAndHashAlgorithm
{
get { return m_signatureAndHashAlgorithm; }
}
public virtual TlsStreamSigner GetStreamSigner()
{
return m_signer.GetStreamSigner(GetEffectiveAlgorithm());
}
protected virtual SignatureAndHashAlgorithm GetEffectiveAlgorithm()
{
SignatureAndHashAlgorithm algorithm = null;
if (TlsImplUtilities.IsTlsV12(m_cryptoParams))
{
algorithm = SignatureAndHashAlgorithm;
if (algorithm == null)
throw new InvalidOperationException("'signatureAndHashAlgorithm' cannot be null for (D)TLS 1.2+");
}
return algorithm;
}
}
}
#pragma warning restore
#endif