summary refs log tree commit diff
path: root/crypto/src/tls/SecurityParameters.cs
blob: 548e4a4cae5565db502fa3db21543aa7c6f76b3f (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
using System;
using System.Collections;

using Org.BouncyCastle.Tls.Crypto;

namespace Org.BouncyCastle.Tls
{
    public sealed class SecurityParameters
    {
        internal int m_entity = -1;
        internal bool m_secureRenegotiation = false;
        internal int m_cipherSuite = Tls.CipherSuite.TLS_NULL_WITH_NULL_NULL;
        internal short m_maxFragmentLength = -1;
        internal int m_prfAlgorithm = -1;
        internal int m_prfCryptoHashAlgorithm = -1;
        internal int m_prfHashLength = -1;
        internal int m_verifyDataLength = -1;
        internal TlsSecret m_baseKeyClient = null;
        internal TlsSecret m_baseKeyServer = null;
        internal TlsSecret m_earlyExporterMasterSecret = null;
        internal TlsSecret m_earlySecret = null;
        internal TlsSecret m_exporterMasterSecret = null;
        internal TlsSecret m_handshakeSecret = null;
        internal TlsSecret m_masterSecret = null;
        internal TlsSecret m_trafficSecretClient = null;
        internal TlsSecret m_trafficSecretServer = null;
        internal byte[] m_clientRandom = null;
        internal byte[] m_serverRandom = null;
        internal byte[] m_sessionHash = null;
        internal byte[] m_sessionID = null;
        internal byte[] m_pskIdentity = null;
        internal byte[] m_srpIdentity = null;
        internal byte[] m_tlsServerEndPoint = null;
        internal byte[] m_tlsUnique = null;
        internal bool m_encryptThenMac = false;
        internal bool m_extendedMasterSecret = false;
        internal bool m_extendedPadding = false;
        internal bool m_truncatedHmac = false;
        internal ProtocolName m_applicationProtocol = null;
        internal bool m_applicationProtocolSet = false;
        internal short[] m_clientCertTypes = null;
        internal IList m_clientServerNames = null;
        internal IList m_clientSigAlgs = null;
        internal IList m_clientSigAlgsCert = null;
        internal int[] m_clientSupportedGroups = null;
        internal IList m_serverSigAlgs = null;
        internal IList m_serverSigAlgsCert = null;
        internal int[] m_serverSupportedGroups = null;
        internal int m_keyExchangeAlgorithm = -1;
        internal Certificate m_localCertificate = null;
        internal Certificate m_peerCertificate = null;
        internal ProtocolVersion m_negotiatedVersion = null;
        internal int m_statusRequestVersion = 0;

        // TODO[tls-ops] Investigate whether we can handle verify data using TlsSecret
        internal byte[] m_localVerifyData = null;
        internal byte[] m_peerVerifyData = null;

        internal void Clear()
        {
            this.m_sessionHash = null;
            this.m_sessionID = null;
            this.m_clientCertTypes = null;
            this.m_clientServerNames = null;
            this.m_clientSigAlgs = null;
            this.m_clientSigAlgsCert = null;
            this.m_clientSupportedGroups = null;
            this.m_serverSigAlgs = null;
            this.m_serverSigAlgsCert = null;
            this.m_serverSupportedGroups = null;
            this.m_statusRequestVersion = 0;

            this.m_baseKeyClient = ClearSecret(m_baseKeyClient);
            this.m_baseKeyServer = ClearSecret(m_baseKeyServer);
            this.m_earlyExporterMasterSecret = ClearSecret(m_earlyExporterMasterSecret);
            this.m_earlySecret = ClearSecret(m_earlySecret);
            this.m_exporterMasterSecret = ClearSecret(m_exporterMasterSecret);
            this.m_handshakeSecret = ClearSecret(m_handshakeSecret);
            this.m_masterSecret = ClearSecret(m_masterSecret);
        }

        public ProtocolName ApplicationProtocol
        {
            get { return m_applicationProtocol; }
        }

        public TlsSecret BaseKeyClient
        {
            get { return m_baseKeyClient; }
        }

        public TlsSecret BaseKeyServer
        {
            get { return m_baseKeyServer; }
        }

        public int CipherSuite
        {
            get { return m_cipherSuite; }
        }

        public short[] ClientCertTypes
        {
            get { return m_clientCertTypes; }
        }

        public byte[] ClientRandom
        {
            get { return m_clientRandom; }
        }

        public IList ClientServerNames
        {
            get { return m_clientServerNames; }
        }

        public IList ClientSigAlgs
        {
            get { return m_clientSigAlgs; }
        }

        public IList ClientSigAlgsCert
        {
            get { return m_clientSigAlgsCert; }
        }

        public int[] ClientSupportedGroups
        {
            get { return m_clientSupportedGroups; }
        }

        public TlsSecret EarlyExporterMasterSecret
        {
            get { return m_earlyExporterMasterSecret; }
        }

        public TlsSecret EarlySecret
        {
            get { return m_earlySecret; }
        }

        public TlsSecret ExporterMasterSecret
        {
            get { return m_exporterMasterSecret; }
        }

        public int Entity
        {
            get { return m_entity; }
        }

        public TlsSecret HandshakeSecret
        {
            get { return m_handshakeSecret; }
        }

        public bool IsApplicationProtocolSet
        {
            get { return m_applicationProtocolSet; }
        }

        public bool IsEncryptThenMac
        {
            get { return m_encryptThenMac; }
        }

        public bool IsExtendedMasterSecret
        {
            get { return m_extendedMasterSecret; }
        }

        public bool IsExtendedPadding
        {
            get { return m_extendedPadding; }
        }

        public bool IsSecureRenegotiation
        {
            get { return m_secureRenegotiation; }
        }

        public bool IsTruncatedHmac
        {
            get { return m_truncatedHmac; }
        }

        public int KeyExchangeAlgorithm
        {
            get { return m_keyExchangeAlgorithm; }
        }

        public Certificate LocalCertificate
        {
            get { return m_localCertificate; }
        }

        public byte[] LocalVerifyData
        {
            get { return m_localVerifyData; }
        }

        public TlsSecret MasterSecret
        {
            get { return m_masterSecret; }
        }

        public short MaxFragmentLength
        {
            get { return m_maxFragmentLength; }
        }

        public ProtocolVersion NegotiatedVersion
        {
            get { return m_negotiatedVersion; }
        }

        public Certificate PeerCertificate
        {
            get { return m_peerCertificate; }
        }

        public byte[] PeerVerifyData
        {
            get { return m_peerVerifyData; }
        }

        public int PrfAlgorithm
        {
            get { return m_prfAlgorithm; }
        }

        public int PrfCryptoHashAlgorithm
        {
            get { return m_prfCryptoHashAlgorithm; }
        }

        public int PrfHashLength
        {
            get { return m_prfHashLength; }
        }

        public byte[] PskIdentity
        {
            get { return m_pskIdentity; }
        }

        public byte[] ServerRandom
        {
            get { return m_serverRandom; }
        }

        public IList ServerSigAlgs
        {
            get { return m_serverSigAlgs; }
        }

        public IList ServerSigAlgsCert
        {
            get { return m_serverSigAlgsCert; }
        }

        public int[] ServerSupportedGroups
        {
            get { return m_serverSupportedGroups; }
        }

        public byte[] SessionHash
        {
            get { return m_sessionHash; }
        }

        public byte[] SessionID
        {
            get { return m_sessionID; }
        }

        public byte[] SrpIdentity
        {
            get { return m_srpIdentity; }
        }

        public int StatusRequestVersion
        {
            get { return m_statusRequestVersion; }
        }

        public byte[] TlsServerEndPoint
        {
            get { return m_tlsServerEndPoint; }
        }

        public byte[] TlsUnique
        {
            get { return m_tlsUnique; }
        }

        public TlsSecret TrafficSecretClient
        {
            get { return m_trafficSecretClient; }
        }

        public TlsSecret TrafficSecretServer
        {
            get { return m_trafficSecretServer; }
        }

        public int VerifyDataLength
        {
            get { return m_verifyDataLength; }
        }

        private static TlsSecret ClearSecret(TlsSecret secret)
        {
            if (null != secret)
            {
                secret.Destroy();
            }
            return null;
        }
    }
}