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/. */
7 #include "FuzzySecurityInfo.h"
8 #include "mozilla/Logging.h"
9 #include "mozilla/OriginAttributes.h"
10 #include "nsThreadManager.h"
15 FuzzySecurityInfo::FuzzySecurityInfo() {}
17 FuzzySecurityInfo::~FuzzySecurityInfo() {}
19 NS_IMPL_ISUPPORTS(FuzzySecurityInfo
, nsITransportSecurityInfo
,
20 nsIInterfaceRequestor
, nsISSLSocketControl
)
23 FuzzySecurityInfo::GetErrorCode(int32_t* state
) {
29 FuzzySecurityInfo::GetSecurityState(uint32_t* state
) {
35 FuzzySecurityInfo::GetErrorCodeString(nsAString
& aErrorString
) {
41 FuzzySecurityInfo::GetFailedCertChain(
42 nsTArray
<RefPtr
<nsIX509Cert
>>& aFailedCertChain
) {
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.
58 FuzzySecurityInfo::GetSucceededCertChain(
59 nsTArray
<RefPtr
<nsIX509Cert
>>& aSucceededCertChain
) {
65 FuzzySecurityInfo::GetCipherName(nsACString
& aCipherName
) {
71 FuzzySecurityInfo::GetKeyLength(uint32_t* aKeyLength
) {
77 FuzzySecurityInfo::GetSecretKeyLength(uint32_t* aSecretKeyLength
) {
79 *aSecretKeyLength
= 4096;
84 FuzzySecurityInfo::GetKeaGroupName(nsACString
& aKeaGroup
) {
90 FuzzySecurityInfo::GetSignatureSchemeName(nsACString
& aSignatureScheme
) {
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
;
104 FuzzySecurityInfo::GetCertificateTransparencyStatus(
105 uint16_t* aCertificateTransparencyStatus
) {
106 NS_ENSURE_ARG_POINTER(aCertificateTransparencyStatus
);
112 FuzzySecurityInfo::GetIsDomainMismatch(bool* aIsDomainMismatch
) {
113 NS_ENSURE_ARG_POINTER(aIsDomainMismatch
);
114 *aIsDomainMismatch
= false;
119 FuzzySecurityInfo::GetIsNotValidAtThisTime(bool* aIsNotValidAtThisTime
) {
120 NS_ENSURE_ARG_POINTER(aIsNotValidAtThisTime
);
121 *aIsNotValidAtThisTime
= false;
126 FuzzySecurityInfo::GetIsUntrusted(bool* aIsUntrusted
) {
127 NS_ENSURE_ARG_POINTER(aIsUntrusted
);
128 *aIsUntrusted
= false;
133 FuzzySecurityInfo::GetIsExtendedValidation(bool* aIsEV
) {
134 NS_ENSURE_ARG_POINTER(aIsEV
);
140 FuzzySecurityInfo::GetIsDelegatedCredential(bool* aIsDelegCred
) {
141 NS_ENSURE_ARG_POINTER(aIsDelegCred
);
142 *aIsDelegCred
= false;
147 FuzzySecurityInfo::GetIsAcceptedEch(bool* aIsAcceptedEch
) {
148 NS_ENSURE_ARG_POINTER(aIsAcceptedEch
);
149 *aIsAcceptedEch
= false;
154 FuzzySecurityInfo::GetInterface(const nsIID
& uuid
, void** result
) {
155 if (!NS_IsMainThread()) {
156 MOZ_CRASH("FuzzySecurityInfo::GetInterface called off the main thread");
157 return NS_ERROR_NOT_SAME_THREAD
;
160 nsresult rv
= NS_ERROR_NO_INTERFACE
;
162 rv
= mCallbacks
->GetInterface(uuid
, result
);
168 FuzzySecurityInfo::GetNotificationCallbacks(
169 nsIInterfaceRequestor
** aCallbacks
) {
170 nsCOMPtr
<nsIInterfaceRequestor
> ir(mCallbacks
);
171 ir
.forget(aCallbacks
);
176 FuzzySecurityInfo::SetNotificationCallbacks(nsIInterfaceRequestor
* aCallbacks
) {
177 mCallbacks
= aCallbacks
;
182 FuzzySecurityInfo::GetProviderFlags(uint32_t* aProviderFlags
) {
188 FuzzySecurityInfo::GetProviderTlsFlags(uint32_t* aProviderTlsFlags
) {
194 FuzzySecurityInfo::GetKEAUsed(int16_t* aKea
) {
195 // Can be ssl_kea_dh or ssl_kea_ecdh for HTTP2
196 *aKea
= ssl_kea_ecdh
;
201 FuzzySecurityInfo::GetKEAKeyBits(uint32_t* aKeyBits
) {
202 // Must be >= 224 for ecdh and >= 2048 for dh when using HTTP2
208 FuzzySecurityInfo::GetSSLVersionUsed(int16_t* aSSLVersionUsed
) {
209 // Must be >= TLS 1.2 for HTTP2
210 *aSSLVersionUsed
= nsISSLSocketControl::TLS_VERSION_1_2
;
215 FuzzySecurityInfo::GetSSLVersionOffered(int16_t* aSSLVersionOffered
) {
216 *aSSLVersionOffered
= nsISSLSocketControl::TLS_VERSION_1_2
;
221 FuzzySecurityInfo::GetMACAlgorithmUsed(int16_t* aMac
) {
222 // The only valid choice for HTTP2 is SSL_MAC_AEAD
223 *aMac
= nsISSLSocketControl::SSL_MAC_AEAD
;
228 FuzzySecurityInfo::GetClientCert(nsIX509Cert
** aClientCert
) {
229 NS_ENSURE_ARG_POINTER(aClientCert
);
230 *aClientCert
= nullptr;
235 FuzzySecurityInfo::SetClientCert(nsIX509Cert
* aClientCert
) {
240 bool FuzzySecurityInfo::GetDenyClientCert() { return false; }
242 void FuzzySecurityInfo::SetDenyClientCert(bool aDenyClientCert
) {
243 // Called by mozilla::net::nsHttpConnection::StartSpdy
247 FuzzySecurityInfo::GetClientCertSent(bool* arg
) {
253 FuzzySecurityInfo::GetFailedVerification(bool* arg
) {
259 FuzzySecurityInfo::GetNegotiatedNPN(nsACString
& aNegotiatedNPN
) {
260 aNegotiatedNPN
= "h2";
265 FuzzySecurityInfo::GetAlpnEarlySelection(nsACString
& aAlpnSelected
) {
266 // TODO: For now we don't support early selection
267 return NS_ERROR_NOT_AVAILABLE
;
271 FuzzySecurityInfo::GetEarlyDataAccepted(bool* aAccepted
) {
277 FuzzySecurityInfo::GetResumed(bool* aResumed
) {
283 FuzzySecurityInfo::DriveHandshake() { return NS_OK
; }
286 FuzzySecurityInfo::IsAcceptableForHost(const nsACString
& hostname
,
288 NS_ENSURE_ARG(_retval
);
294 FuzzySecurityInfo::TestJoinConnection(const nsACString
& npnProtocol
,
295 const nsACString
& hostname
, int32_t port
,
302 FuzzySecurityInfo::JoinConnection(const nsACString
& npnProtocol
,
303 const nsACString
& hostname
, int32_t port
,
310 FuzzySecurityInfo::ProxyStartSSL() { return NS_OK
; }
313 FuzzySecurityInfo::StartTLS() { return NS_OK
; }
316 FuzzySecurityInfo::SetNPNList(nsTArray
<nsCString
>& protocolArray
) {
321 FuzzySecurityInfo::GetEsniTxt(nsACString
& aEsniTxt
) { return NS_OK
; }
324 FuzzySecurityInfo::SetEsniTxt(const nsACString
& aEsniTxt
) {
330 FuzzySecurityInfo::GetEchConfig(nsACString
& aEchConfig
) { return NS_OK
; }
333 FuzzySecurityInfo::SetEchConfig(const nsACString
& aEchConfig
) {
339 FuzzySecurityInfo::GetRetryEchConfig(nsACString
& aEchConfig
) { return NS_OK
; }
341 void FuzzySecurityInfo::SerializeToIPC(IPC::Message
* aMsg
) {
345 bool FuzzySecurityInfo::DeserializeFromIPC(const IPC::Message
* aMsg
,
346 PickleIterator
* aIter
) {
352 FuzzySecurityInfo::GetPeerId(nsACString
& aResult
) {
353 aResult
.Assign(""_ns
);
357 NS_IMETHODIMP
FuzzySecurityInfo::SetIsBuiltCertChainRootBuiltInRoot(
358 bool aIsBuiltInRoot
) {
362 NS_IMETHODIMP
FuzzySecurityInfo::GetIsBuiltCertChainRootBuiltInRoot(
363 bool* aIsBuiltInRoot
) {
364 *aIsBuiltInRoot
= false;
368 NS_IMETHODIMP
FuzzySecurityInfo::DisableEarlyData(void) {
372 NS_IMETHODIMP
FuzzySecurityInfo::SetHandshakeCallbackListener(
373 nsITlsHandshakeCallbackListener
* callback
) {
378 } // namespace mozilla