Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "FuzzySecurityInfo.h"
8
#include "mozilla/Logging.h"
9
#include "mozilla/OriginAttributes.h"
10
#include "nsThreadManager.h"
11
12
namespace mozilla {
13
namespace net {
14
15
FuzzySecurityInfo::FuzzySecurityInfo() {}
16
17
FuzzySecurityInfo::~FuzzySecurityInfo() {}
18
19
NS_IMPL_ISUPPORTS(FuzzySecurityInfo, nsITransportSecurityInfo,
20
nsIInterfaceRequestor, nsISSLSocketControl)
21
22
NS_IMETHODIMP
23
FuzzySecurityInfo::GetErrorCode(int32_t* state) {
24
*state = 0;
25
return NS_OK;
26
}
27
28
NS_IMETHODIMP
29
FuzzySecurityInfo::GetSecurityState(uint32_t* state) {
30
*state = 0;
31
return NS_OK;
32
}
33
34
NS_IMETHODIMP
35
FuzzySecurityInfo::GetErrorCodeString(nsAString& aErrorString) {
36
MOZ_CRASH("Unused");
37
return NS_OK;
38
}
39
40
NS_IMETHODIMP
41
FuzzySecurityInfo::GetFailedCertChain(
42
nsTArray<RefPtr<nsIX509Cert>>& aFailedCertChain) {
43
MOZ_CRASH("Unused");
44
return NS_OK;
45
}
46
47
NS_IMETHODIMP
48
FuzzySecurityInfo::GetServerCert(nsIX509Cert** aServerCert) {
49
NS_ENSURE_ARG_POINTER(aServerCert);
50
// This method is called by nsHttpChannel::ProcessSSLInformation()
51
// in order to display certain information in the console.
52
// Returning NULL is okay here and handled by the caller.
53
*aServerCert = NULL;
54
return NS_OK;
55
}
56
57
NS_IMETHODIMP
58
FuzzySecurityInfo::GetSucceededCertChain(
59
nsTArray<RefPtr<nsIX509Cert>>& aSucceededCertChain) {
60
MOZ_CRASH("Unused");
61
return NS_OK;
62
}
63
64
NS_IMETHODIMP
65
FuzzySecurityInfo::GetCipherName(nsACString& aCipherName) {
66
MOZ_CRASH("Unused");
67
return NS_OK;
68
}
69
70
NS_IMETHODIMP
71
FuzzySecurityInfo::GetKeyLength(uint32_t* aKeyLength) {
72
MOZ_CRASH("Unused");
73
return NS_OK;
74
}
75
76
NS_IMETHODIMP
77
FuzzySecurityInfo::GetSecretKeyLength(uint32_t* aSecretKeyLength) {
78
MOZ_CRASH("Unused");
79
*aSecretKeyLength = 4096;
80
return NS_OK;
81
}
82
83
NS_IMETHODIMP
84
FuzzySecurityInfo::GetKeaGroupName(nsACString& aKeaGroup) {
85
MOZ_CRASH("Unused");
86
return NS_OK;
87
}
88
89
NS_IMETHODIMP
90
FuzzySecurityInfo::GetSignatureSchemeName(nsACString& aSignatureScheme) {
91
MOZ_CRASH("Unused");
92
return NS_OK;
93
}
94
95
NS_IMETHODIMP
96
FuzzySecurityInfo::GetProtocolVersion(uint16_t* aProtocolVersion) {
97
NS_ENSURE_ARG_POINTER(aProtocolVersion);
98
// Must be >= TLS 1.2 for HTTP2
99
*aProtocolVersion = nsITransportSecurityInfo::TLS_VERSION_1_2;
100
return NS_OK;
101
}
102
103
NS_IMETHODIMP
104
FuzzySecurityInfo::GetCertificateTransparencyStatus(
105
uint16_t* aCertificateTransparencyStatus) {
106
NS_ENSURE_ARG_POINTER(aCertificateTransparencyStatus);
107
MOZ_CRASH("Unused");
108
return NS_OK;
109
}
110
111
NS_IMETHODIMP
112
FuzzySecurityInfo::GetIsDomainMismatch(bool* aIsDomainMismatch) {
113
NS_ENSURE_ARG_POINTER(aIsDomainMismatch);
114
*aIsDomainMismatch = false;
115
return NS_OK;
116
}
117
118
NS_IMETHODIMP
119
FuzzySecurityInfo::GetIsNotValidAtThisTime(bool* aIsNotValidAtThisTime) {
120
NS_ENSURE_ARG_POINTER(aIsNotValidAtThisTime);
121
*aIsNotValidAtThisTime = false;
122
return NS_OK;
123
}
124
125
NS_IMETHODIMP
126
FuzzySecurityInfo::GetIsUntrusted(bool* aIsUntrusted) {
127
NS_ENSURE_ARG_POINTER(aIsUntrusted);
128
*aIsUntrusted = false;
129
return NS_OK;
130
}
131
132
NS_IMETHODIMP
133
FuzzySecurityInfo::GetIsExtendedValidation(bool* aIsEV) {
134
NS_ENSURE_ARG_POINTER(aIsEV);
135
*aIsEV = true;
136
return NS_OK;
137
}
138
139
NS_IMETHODIMP
140
FuzzySecurityInfo::GetIsDelegatedCredential(bool* aIsDelegCred) {
141
NS_ENSURE_ARG_POINTER(aIsDelegCred);
142
*aIsDelegCred = false;
143
return NS_OK;
144
}
145
146
NS_IMETHODIMP
147
FuzzySecurityInfo::GetInterface(const nsIID& uuid, void** result) {
148
if (!NS_IsMainThread()) {
149
MOZ_CRASH("FuzzySecurityInfo::GetInterface called off the main thread");
150
return NS_ERROR_NOT_SAME_THREAD;
151
}
152
153
nsresult rv = NS_ERROR_NO_INTERFACE;
154
if (mCallbacks) {
155
rv = mCallbacks->GetInterface(uuid, result);
156
}
157
return rv;
158
}
159
160
NS_IMETHODIMP
161
FuzzySecurityInfo::GetNotificationCallbacks(
162
nsIInterfaceRequestor** aCallbacks) {
163
nsCOMPtr<nsIInterfaceRequestor> ir(mCallbacks);
164
ir.forget(aCallbacks);
165
return NS_OK;
166
}
167
168
NS_IMETHODIMP
169
FuzzySecurityInfo::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks) {
170
mCallbacks = aCallbacks;
171
return NS_OK;
172
}
173
174
NS_IMETHODIMP
175
FuzzySecurityInfo::GetProviderFlags(uint32_t* aProviderFlags) {
176
MOZ_CRASH("Unused");
177
return NS_OK;
178
}
179
180
NS_IMETHODIMP
181
FuzzySecurityInfo::GetProviderTlsFlags(uint32_t* aProviderTlsFlags) {
182
MOZ_CRASH("Unused");
183
return NS_OK;
184
}
185
186
NS_IMETHODIMP
187
FuzzySecurityInfo::GetKEAUsed(int16_t* aKea) {
188
// Can be ssl_kea_dh or ssl_kea_ecdh for HTTP2
189
*aKea = ssl_kea_ecdh;
190
return NS_OK;
191
}
192
193
NS_IMETHODIMP
194
FuzzySecurityInfo::GetKEAKeyBits(uint32_t* aKeyBits) {
195
// Must be >= 224 for ecdh and >= 2048 for dh when using HTTP2
196
*aKeyBits = 256;
197
return NS_OK;
198
}
199
200
NS_IMETHODIMP
201
FuzzySecurityInfo::GetSSLVersionUsed(int16_t* aSSLVersionUsed) {
202
// Must be >= TLS 1.2 for HTTP2
203
*aSSLVersionUsed = nsISSLSocketControl::TLS_VERSION_1_2;
204
return NS_OK;
205
}
206
207
NS_IMETHODIMP
208
FuzzySecurityInfo::GetSSLVersionOffered(int16_t* aSSLVersionOffered) {
209
*aSSLVersionOffered = nsISSLSocketControl::TLS_VERSION_1_2;
210
return NS_OK;
211
}
212
213
NS_IMETHODIMP
214
FuzzySecurityInfo::GetMACAlgorithmUsed(int16_t* aMac) {
215
// The only valid choice for HTTP2 is SSL_MAC_AEAD
216
*aMac = nsISSLSocketControl::SSL_MAC_AEAD;
217
return NS_OK;
218
}
219
220
NS_IMETHODIMP
221
FuzzySecurityInfo::GetClientCert(nsIX509Cert** aClientCert) {
222
NS_ENSURE_ARG_POINTER(aClientCert);
223
*aClientCert = nullptr;
224
return NS_OK;
225
}
226
227
NS_IMETHODIMP
228
FuzzySecurityInfo::SetClientCert(nsIX509Cert* aClientCert) {
229
MOZ_CRASH("Unused");
230
return NS_OK;
231
}
232
233
bool FuzzySecurityInfo::GetDenyClientCert() { return false; }
234
235
void FuzzySecurityInfo::SetDenyClientCert(bool aDenyClientCert) {
236
// Called by mozilla::net::nsHttpConnection::StartSpdy
237
}
238
239
NS_IMETHODIMP
240
FuzzySecurityInfo::GetClientCertSent(bool* arg) {
241
*arg = false;
242
return NS_OK;
243
}
244
245
NS_IMETHODIMP
246
FuzzySecurityInfo::GetFailedVerification(bool* arg) {
247
*arg = false;
248
return NS_OK;
249
}
250
251
NS_IMETHODIMP
252
FuzzySecurityInfo::GetNegotiatedNPN(nsACString& aNegotiatedNPN) {
253
aNegotiatedNPN = "h2";
254
return NS_OK;
255
}
256
257
NS_IMETHODIMP
258
FuzzySecurityInfo::GetAlpnEarlySelection(nsACString& aAlpnSelected) {
259
// TODO: For now we don't support early selection
260
return NS_ERROR_NOT_AVAILABLE;
261
}
262
263
NS_IMETHODIMP
264
FuzzySecurityInfo::GetEarlyDataAccepted(bool* aAccepted) {
265
*aAccepted = false;
266
return NS_OK;
267
}
268
269
NS_IMETHODIMP
270
FuzzySecurityInfo::GetResumed(bool* aResumed) {
271
*aResumed = false;
272
return NS_OK;
273
}
274
275
NS_IMETHODIMP
276
FuzzySecurityInfo::DriveHandshake() { return NS_OK; }
277
278
NS_IMETHODIMP
279
FuzzySecurityInfo::IsAcceptableForHost(const nsACString& hostname,
280
bool* _retval) {
281
NS_ENSURE_ARG(_retval);
282
*_retval = true;
283
return NS_OK;
284
}
285
286
NS_IMETHODIMP
287
FuzzySecurityInfo::TestJoinConnection(const nsACString& npnProtocol,
288
const nsACString& hostname, int32_t port,
289
bool* _retval) {
290
*_retval = false;
291
return NS_OK;
292
}
293
294
NS_IMETHODIMP
295
FuzzySecurityInfo::JoinConnection(const nsACString& npnProtocol,
296
const nsACString& hostname, int32_t port,
297
bool* _retval) {
298
*_retval = false;
299
return NS_OK;
300
}
301
302
NS_IMETHODIMP
303
FuzzySecurityInfo::ProxyStartSSL() { return NS_OK; }
304
305
NS_IMETHODIMP
306
FuzzySecurityInfo::StartTLS() { return NS_OK; }
307
308
NS_IMETHODIMP
309
FuzzySecurityInfo::SetNPNList(nsTArray<nsCString>& protocolArray) {
310
return NS_OK;
311
}
312
313
NS_IMETHODIMP
314
FuzzySecurityInfo::GetEsniTxt(nsACString& aEsniTxt) { return NS_OK; }
315
316
NS_IMETHODIMP
317
FuzzySecurityInfo::SetEsniTxt(const nsACString& aEsniTxt) {
318
MOZ_CRASH("Unused");
319
return NS_OK;
320
}
321
322
void FuzzySecurityInfo::SerializeToIPC(IPC::Message* aMsg) {
323
MOZ_CRASH("Unused");
324
}
325
326
bool FuzzySecurityInfo::DeserializeFromIPC(const IPC::Message* aMsg,
327
PickleIterator* aIter) {
328
MOZ_CRASH("Unused");
329
return false;
330
}
331
332
NS_IMETHODIMP
333
FuzzySecurityInfo::GetPeerId(nsACString& aResult) {
334
aResult.Assign(EmptyCString());
335
return NS_OK;
336
}
337
338
} // namespace net
339
} // namespace mozilla