Bug 1275841 - Rename nsSDR.(cpp|h) to SecretDecoderRing.(cpp|h). r=keeler
There are currently two ways of naming files containing the implementation of
interface nsIFoo:
1. nsFoo.(cpp|h) (previous convention)
2. Foo.(cpp|h) (new convention)
nsSDR.(cpp|h) matches neither of these. Renaming the files to follow convention
makes it easier to discover what the files implement, and increases codebase
consistency.
MozReview-Commit-ID: 3ThPxPouiie
rename from security/manager/ssl/nsSDR.cpp
rename to security/manager/ssl/SecretDecoderRing.cpp
--- a/security/manager/ssl/nsSDR.cpp
+++ b/security/manager/ssl/SecretDecoderRing.cpp
@@ -1,70 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#include "stdlib.h"
-#include "plstr.h"
-#include "plbase64.h"
+#include "SecretDecoderRing.h"
+#include "ScopedNSSTypes.h"
#include "mozilla/Base64.h"
#include "mozilla/Casting.h"
#include "mozilla/Services.h"
-#include "nsMemory.h"
-#include "nsString.h"
#include "nsCOMPtr.h"
-#include "nsThreadUtils.h"
+#include "nsCRT.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsITokenPasswordDialogs.h"
-
-#include "nsISecretDecoderRing.h"
-#include "nsCRT.h"
-#include "nsSDR.h"
+#include "nsMemory.h"
#include "nsNSSComponent.h"
#include "nsNSSHelper.h"
-#include "nsNSSShutDown.h"
-#include "ScopedNSSTypes.h"
-
+#include "nsString.h"
+#include "nsThreadUtils.h"
#include "pk11func.h"
#include "pk11sdr.h" // For PK11SDR_Encrypt, PK11SDR_Decrypt
-
+#include "plstr.h"
#include "ssl.h" // For SSL_ClearSessionCache
+#include "stdlib.h"
using namespace mozilla;
-// Standard ISupports implementation
// NOTE: Should these be the thread-safe versions?
-NS_IMPL_ISUPPORTS(nsSecretDecoderRing, nsISecretDecoderRing, nsISecretDecoderRingConfig)
+NS_IMPL_ISUPPORTS(SecretDecoderRing, nsISecretDecoderRing,
+ nsISecretDecoderRingConfig)
-// nsSecretDecoderRing constructor
-nsSecretDecoderRing::nsSecretDecoderRing()
+SecretDecoderRing::SecretDecoderRing()
{
- // initialize superclass
}
-// nsSecretDecoderRing destructor
-nsSecretDecoderRing::~nsSecretDecoderRing()
+SecretDecoderRing::~SecretDecoderRing()
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown()) {
return;
}
shutdown(calledFromObject);
}
NS_IMETHODIMP
-nsSecretDecoderRing::Encrypt(unsigned char* data, uint32_t dataLen,
- unsigned char** result, uint32_t* _retval)
+SecretDecoderRing::Encrypt(unsigned char* data, uint32_t dataLen,
+ unsigned char** result, uint32_t* _retval)
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown()) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
@@ -100,18 +91,18 @@ nsSecretDecoderRing::Encrypt(unsigned ch
*result = reply.data;
*_retval = reply.len;
return NS_OK;
}
NS_IMETHODIMP
-nsSecretDecoderRing::Decrypt(unsigned char* data, uint32_t dataLen,
- unsigned char** result, uint32_t* _retval)
+SecretDecoderRing::Decrypt(unsigned char* data, uint32_t dataLen,
+ unsigned char** result, uint32_t* _retval)
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown()) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
@@ -141,17 +132,17 @@ nsSecretDecoderRing::Decrypt(unsigned ch
*result = reply.data;
*_retval = reply.len;
return NS_OK;
}
NS_IMETHODIMP
-nsSecretDecoderRing::EncryptString(const char* text, char** _retval)
+SecretDecoderRing::EncryptString(const char* text, char** _retval)
{
nsresult rv = NS_OK;
unsigned char *encrypted = 0;
uint32_t eLen = 0;
if (!text || !_retval) {
rv = NS_ERROR_INVALID_POINTER;
goto loser;
@@ -164,17 +155,17 @@ nsSecretDecoderRing::EncryptString(const
loser:
if (encrypted) PORT_Free(encrypted);
return rv;
}
NS_IMETHODIMP
-nsSecretDecoderRing::DecryptString(const char* crypt, char** _retval)
+SecretDecoderRing::DecryptString(const char* crypt, char** _retval)
{
nsresult rv = NS_OK;
char *r = 0;
unsigned char *decoded = 0;
uint32_t decodedLen = 0;
unsigned char *decrypted = 0;
uint32_t decryptedLen = 0;
@@ -203,17 +194,17 @@ nsSecretDecoderRing::DecryptString(const
loser:
if (decrypted) PORT_Free(decrypted);
if (decoded) free(decoded);
return rv;
}
NS_IMETHODIMP
-nsSecretDecoderRing::ChangePassword()
+SecretDecoderRing::ChangePassword()
{
nsNSSShutDownPreventionLock locker;
if (isAlreadyShutDown()) {
return NS_ERROR_NOT_AVAILABLE;
}
UniquePK11SlotInfo slot(PK11_GetInternalKeySlot());
if (!slot) {
@@ -231,17 +222,17 @@ nsSecretDecoderRing::ChangePassword()
}
nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
bool canceled; // Ignored
return dialogs->SetPassword(ctx, tokenName.get(), &canceled);
}
NS_IMETHODIMP
-nsSecretDecoderRing::Logout()
+SecretDecoderRing::Logout()
{
static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
nsresult rv;
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
if (NS_FAILED(rv))
return rv;
@@ -254,17 +245,17 @@ nsSecretDecoderRing::Logout()
PK11_LogoutAll();
SSL_ClearSessionCache();
}
return NS_OK;
}
NS_IMETHODIMP
-nsSecretDecoderRing::LogoutAndTeardown()
+SecretDecoderRing::LogoutAndTeardown()
{
static NS_DEFINE_CID(kNSSComponentCID, NS_NSSCOMPONENT_CID);
nsresult rv;
nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
if (NS_FAILED(rv))
return rv;
@@ -286,13 +277,13 @@ nsSecretDecoderRing::LogoutAndTeardown()
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os)
os->NotifyObservers(nullptr, "net:prune-dead-connections", nullptr);
return rv;
}
NS_IMETHODIMP
-nsSecretDecoderRing::SetWindow(nsISupports*)
+SecretDecoderRing::SetWindow(nsISupports*)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
rename from security/manager/ssl/nsSDR.h
rename to security/manager/ssl/SecretDecoderRing.h
--- a/security/manager/ssl/nsSDR.h
+++ b/security/manager/ssl/SecretDecoderRing.h
@@ -1,52 +1,41 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef _NSSDR_H_
-#define _NSSDR_H_
+#ifndef SecretDecoderRing_h
+#define SecretDecoderRing_h
#include "nsISecretDecoderRing.h"
#include "nsNSSShutDown.h"
/**
- * NS_SDR_CONTRACTID - contract id for SDR services.
* Implements nsISecretDecoderRing.
* Should eventually implement an interface to set window
* context and other information. (nsISecretDecoderRingConfig)
- *
- * NOTE: This definition should move to base code. It
- * is conditionally defined here until it is moved.
- * Delete this after defining in the new location.
*/
-#ifndef NS_SDR_CONTRACTID
-#define NS_SDR_CONTRACTID "@mozilla.org/security/sdr;1"
-#endif
+#define NS_SECRETDECODERRING_CONTRACTID "@mozilla.org/security/sdr;1"
-// ===============================================
-// nsSecretDecoderRing - implementation of nsISecretDecoderRing
-// ===============================================
-
-#define NS_SDR_CID \
+#define NS_SECRETDECODERRING_CID \
{ 0x0c4f1ddc, 0x1dd2, 0x11b2, { 0x9d, 0x95, 0xf2, 0xfd, 0xf1, 0x13, 0x04, 0x4b } }
-class nsSecretDecoderRing : public nsISecretDecoderRing
- , public nsISecretDecoderRingConfig
- , public nsNSSShutDownObject
+class SecretDecoderRing : public nsISecretDecoderRing
+ , public nsISecretDecoderRingConfig
+ , public nsNSSShutDownObject
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISECRETDECODERRING
NS_DECL_NSISECRETDECODERRINGCONFIG
- nsSecretDecoderRing();
+ SecretDecoderRing();
// Nothing to release.
virtual void virtualDestroyNSSReference() override {}
protected:
- virtual ~nsSecretDecoderRing();
+ virtual ~SecretDecoderRing();
};
-#endif /* _NSSDR_H_ */
+#endif // SecretDecoderRing_h
--- a/security/manager/ssl/moz.build
+++ b/security/manager/ssl/moz.build
@@ -118,28 +118,28 @@ UNIFIED_SOURCES += [
'nsNSSVersion.cpp',
'nsNTLMAuthModule.cpp',
'nsPK11TokenDB.cpp',
'nsPKCS11Slot.cpp',
'nsPKCS12Blob.cpp',
'nsProtectedAuthThread.cpp',
'nsPSMBackgroundThread.cpp',
'nsRandomGenerator.cpp',
- 'nsSDR.cpp',
'nsSecureBrowserUIImpl.cpp',
'nsSecurityHeaderParser.cpp',
'NSSErrorsService.cpp',
'nsSiteSecurityService.cpp',
'nsSSLSocketProvider.cpp',
'nsSSLStatus.cpp',
'nsTLSSocketProvider.cpp',
'PSMContentListener.cpp',
'PSMRunnable.cpp',
'PublicKeyPinningService.cpp',
'RootCertificateTelemetryUtils.cpp',
+ 'SecretDecoderRing.cpp',
'SharedSSLState.cpp',
'SSLServerCertVerification.cpp',
'TransportSecurityInfo.cpp',
'WeakCryptoOverride.cpp',
]
IPDL_SOURCES += [
'PPSMContentDownloader.ipdl',
--- a/security/manager/ssl/nsCertOverrideService.cpp
+++ b/security/manager/ssl/nsCertOverrideService.cpp
@@ -10,22 +10,23 @@
#include "ScopedNSSTypes.h"
#include "SharedSSLState.h"
#include "mozilla/Telemetry.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsCRT.h"
#include "nsILineInputStream.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
+#include "nsIOutputStream.h"
+#include "nsISafeOutputStream.h"
#include "nsIX509Cert.h"
#include "nsNSSCertHelper.h"
#include "nsNSSCertificate.h"
#include "nsNSSComponent.h"
#include "nsNetUtil.h"
-#include "nsISafeOutputStream.h"
#include "nsPromiseFlatString.h"
#include "nsStreamUtils.h"
#include "nsStringBuffer.h"
#include "nsThreadUtils.h"
#include "ssl.h" // For SSL_ClearSessionCache
using namespace mozilla;
using namespace mozilla::psm;
--- a/security/manager/ssl/nsNSSModule.cpp
+++ b/security/manager/ssl/nsNSSModule.cpp
@@ -1,48 +1,48 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "CertBlocklist.h"
#include "ContentSignatureVerifier.h"
+#include "NSSErrorsService.h"
+#include "PSMContentListener.h"
+#include "SecretDecoderRing.h"
+#include "TransportSecurityInfo.h"
+#include "WeakCryptoOverride.h"
+#include "mozilla/ModuleUtils.h"
+#include "nsCURILoader.h"
#include "nsCertOverrideService.h"
#include "nsCertPicker.h"
#include "nsCrypto.h"
#include "nsCryptoHash.h"
-#include "nsCURILoader.h"
+#include "nsDOMCID.h" // For the NS_CRYPTO_CONTRACTID define
#include "nsDataSignatureVerifier.h"
-#include "nsDOMCID.h" //For the NS_CRYPTO_CONTRACTID define
#include "nsICategoryManager.h"
+#include "nsKeyModule.h"
#include "nsKeygenHandler.h"
-#include "nsKeyModule.h"
-#include "mozilla/ModuleUtils.h"
-#include "nsNetCID.h"
#include "nsNSSCertificate.h"
#include "nsNSSCertificateDB.h"
#include "nsNSSCertificateFakeTransport.h"
#include "nsNSSComponent.h"
-#include "NSSErrorsService.h"
#include "nsNSSU2FToken.h"
#include "nsNSSVersion.h"
#include "nsNTLMAuthModule.h"
+#include "nsNetCID.h"
#include "nsPK11TokenDB.h"
#include "nsPKCS11Slot.h"
-#include "PSMContentListener.h"
#include "nsRandomGenerator.h"
-#include "nsSDR.h"
+#include "nsSSLSocketProvider.h"
+#include "nsSSLStatus.h"
#include "nsSecureBrowserUIImpl.h"
#include "nsSiteSecurityService.h"
-#include "nsSSLSocketProvider.h"
-#include "nsSSLStatus.h"
#include "nsTLSSocketProvider.h"
-#include "TransportSecurityInfo.h"
-#include "WeakCryptoOverride.h"
#include "nsXULAppAPI.h"
#ifdef MOZ_XUL
#include "nsCertTree.h"
#endif
#define NS_IS_PROCESS_DEFAULT \
(GeckoProcessType_Default == XRE_GetProcessType())
@@ -181,17 +181,17 @@ namespace {
// Use the special factory constructor for everything this module implements,
// because all code could potentially require the NSS library.
// Our factory constructor takes an additional boolean parameter.
// Only for the nsNSSComponent, set this to true.
// All other classes must have this set to false.
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsSSLSocketProvider)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsTLSSocketProvider)
-NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsSecretDecoderRing)
+NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, SecretDecoderRing)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsPK11TokenDB)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsPKCS11ModuleDB)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(PSMContentListener, init)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR_BYPROCESS(nssEnsureOnChromeOnly,
nsNSSCertificate,
nsNSSCertificateFakeTransport)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(nssEnsure, nsNSSCertificateDB)
NS_NSS_GENERIC_FACTORY_CONSTRUCTOR_BYPROCESS(nssEnsureOnChromeOnly,
@@ -221,17 +221,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCe
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSecureBrowserUIImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(CertBlocklist, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSiteSecurityService, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(WeakCryptoOverride)
NS_DEFINE_NAMED_CID(NS_NSSCOMPONENT_CID);
NS_DEFINE_NAMED_CID(NS_SSLSOCKETPROVIDER_CID);
NS_DEFINE_NAMED_CID(NS_STARTTLSSOCKETPROVIDER_CID);
-NS_DEFINE_NAMED_CID(NS_SDR_CID);
+NS_DEFINE_NAMED_CID(NS_SECRETDECODERRING_CID);
NS_DEFINE_NAMED_CID(NS_PK11TOKENDB_CID);
NS_DEFINE_NAMED_CID(NS_PKCS11MODULEDB_CID);
NS_DEFINE_NAMED_CID(NS_PSMCONTENTLISTEN_CID);
NS_DEFINE_NAMED_CID(NS_X509CERT_CID);
NS_DEFINE_NAMED_CID(NS_X509CERTDB_CID);
NS_DEFINE_NAMED_CID(NS_X509CERTLIST_CID);
NS_DEFINE_NAMED_CID(NS_FORMPROCESSOR_CID);
#ifdef MOZ_XUL
@@ -257,17 +257,17 @@ NS_DEFINE_NAMED_CID(NS_SECURE_BROWSER_UI
NS_DEFINE_NAMED_CID(NS_SITE_SECURITY_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_CERT_BLOCKLIST_CID);
NS_DEFINE_NAMED_CID(NS_WEAKCRYPTOOVERRIDE_CID);
static const mozilla::Module::CIDEntry kNSSCIDs[] = {
{ &kNS_NSSCOMPONENT_CID, false, nullptr, nsNSSComponentConstructor },
{ &kNS_SSLSOCKETPROVIDER_CID, false, nullptr, nsSSLSocketProviderConstructor },
{ &kNS_STARTTLSSOCKETPROVIDER_CID, false, nullptr, nsTLSSocketProviderConstructor },
- { &kNS_SDR_CID, false, nullptr, nsSecretDecoderRingConstructor },
+ { &kNS_SECRETDECODERRING_CID, false, nullptr, SecretDecoderRingConstructor },
{ &kNS_PK11TOKENDB_CID, false, nullptr, nsPK11TokenDBConstructor },
{ &kNS_PKCS11MODULEDB_CID, false, nullptr, nsPKCS11ModuleDBConstructor },
{ &kNS_PSMCONTENTLISTEN_CID, false, nullptr, PSMContentListenerConstructor },
{ &kNS_X509CERT_CID, false, nullptr, nsNSSCertificateConstructor },
{ &kNS_X509CERTDB_CID, false, nullptr, nsNSSCertificateDBConstructor },
{ &kNS_X509CERTLIST_CID, false, nullptr, nsNSSCertListConstructor },
{ &kNS_FORMPROCESSOR_CID, false, nullptr, nsKeygenFormProcessor::Create },
#ifdef MOZ_XUL
@@ -297,17 +297,17 @@ static const mozilla::Module::CIDEntry k
};
static const mozilla::Module::ContractIDEntry kNSSContracts[] = {
{ PSM_COMPONENT_CONTRACTID, &kNS_NSSCOMPONENT_CID },
{ NS_NSS_ERRORS_SERVICE_CONTRACTID, &kNS_NSSERRORSSERVICE_CID },
{ NS_NSSVERSION_CONTRACTID, &kNS_NSSVERSION_CID },
{ NS_SSLSOCKETPROVIDER_CONTRACTID, &kNS_SSLSOCKETPROVIDER_CID },
{ NS_STARTTLSSOCKETPROVIDER_CONTRACTID, &kNS_STARTTLSSOCKETPROVIDER_CID },
- { NS_SDR_CONTRACTID, &kNS_SDR_CID },
+ { NS_SECRETDECODERRING_CONTRACTID, &kNS_SECRETDECODERRING_CID },
{ NS_PK11TOKENDB_CONTRACTID, &kNS_PK11TOKENDB_CID },
{ NS_PKCS11MODULEDB_CONTRACTID, &kNS_PKCS11MODULEDB_CID },
{ NS_PSMCONTENTLISTEN_CONTRACTID, &kNS_PSMCONTENTLISTEN_CID },
{ NS_X509CERTDB_CONTRACTID, &kNS_X509CERTDB_CID },
{ NS_X509CERTLIST_CONTRACTID, &kNS_X509CERTLIST_CID },
{ NS_FORMPROCESSOR_CONTRACTID, &kNS_FORMPROCESSOR_CID },
#ifdef MOZ_XUL
{ NS_CERTTREE_CONTRACTID, &kNS_CERTTREE_CID },