- Initial commit
This commit is contained in:
52
Runtime/3rdParty/BouncyCastle/tls/crypto/impl/bc/BcVerifyingStreamSigner.cs
vendored
Normal file
52
Runtime/3rdParty/BouncyCastle/tls/crypto/impl/bc/BcVerifyingStreamSigner.cs
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.IO;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto.Impl.BC
|
||||
{
|
||||
internal sealed class BcVerifyingStreamSigner
|
||||
: TlsStreamSigner
|
||||
{
|
||||
private readonly ISigner m_signer;
|
||||
private readonly ISigner m_verifier;
|
||||
private readonly TeeOutputStream m_output;
|
||||
|
||||
internal BcVerifyingStreamSigner(ISigner signer, ISigner verifier)
|
||||
{
|
||||
Stream outputSigner = new SignerSink(signer);
|
||||
Stream outputVerifier = new SignerSink(verifier);
|
||||
|
||||
this.m_signer = signer;
|
||||
this.m_verifier = verifier;
|
||||
this.m_output = new TeeOutputStream(outputSigner, outputVerifier);
|
||||
}
|
||||
|
||||
public Stream Stream
|
||||
{
|
||||
get { return m_output; }
|
||||
}
|
||||
|
||||
public byte[] GetSignature()
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] signature = m_signer.GenerateSignature();
|
||||
if (m_verifier.VerifySignature(signature))
|
||||
return signature;
|
||||
}
|
||||
catch (CryptoException e)
|
||||
{
|
||||
throw new TlsFatalAlert(AlertDescription.internal_error, e);
|
||||
}
|
||||
|
||||
throw new TlsFatalAlert(AlertDescription.internal_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
Reference in New Issue
Block a user