mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathAbstractTlsKeyExchange.cs
More file actions
72 lines (51 loc) · 2.23 KB
/
Copy pathAbstractTlsKeyExchange.cs
File metadata and controls
72 lines (51 loc) · 2.23 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System.IO;
using Org.BouncyCastle.Tls.Crypto;
namespace Org.BouncyCastle.Tls
{
/// <summary>Base class for supporting a TLS key exchange implementation.</summary>
public abstract class AbstractTlsKeyExchange
: TlsKeyExchange
{
protected readonly int m_keyExchange;
protected TlsContext m_context;
protected AbstractTlsKeyExchange(int keyExchange)
{
m_keyExchange = keyExchange;
}
public virtual void Init(TlsContext context)
{
m_context = context;
}
public abstract void SkipServerCredentials();
public abstract void ProcessServerCredentials(TlsCredentials serverCredentials);
public virtual void ProcessServerCertificate(Certificate serverCertificate) =>
throw new TlsFatalAlert(AlertDescription.internal_error);
public virtual bool RequiresServerKeyExchange => false;
public virtual byte[] GenerateServerKeyExchange()
{
if (RequiresServerKeyExchange)
throw new TlsFatalAlert(AlertDescription.internal_error);
return null;
}
public virtual void SkipServerKeyExchange()
{
if (RequiresServerKeyExchange)
throw new TlsFatalAlert(AlertDescription.unexpected_message);
}
public virtual void ProcessServerKeyExchange(Stream input)
{
if (!RequiresServerKeyExchange)
throw new TlsFatalAlert(AlertDescription.unexpected_message);
}
public virtual short[] GetClientCertificateTypes() => null;
public virtual void SkipClientCredentials() {}
public abstract void ProcessClientCredentials(TlsCredentials clientCredentials);
public virtual void ProcessClientCertificate(Certificate clientCertificate) {}
public abstract void GenerateClientKeyExchange(Stream output);
// Key exchange implementation MUST support client key exchange
public virtual void ProcessClientKeyExchange(Stream input) =>
throw new TlsFatalAlert(AlertDescription.internal_error);
public virtual bool RequiresCertificateVerify => true;
public abstract TlsSecret GeneratePreMasterSecret();
}
}