blob: 4d95068571c2140c8bed8d26caef7709fa9b2232 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
using System;
using System.IO;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.IO;
using Org.BouncyCastle.Utilities.IO;
namespace 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 GetOutputStream()
{
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);
}
}
}
|