Bug 1275841 - Remove unnecessary methods and interfaces from nsISecretDecoderRing.idl. r=keeler
authorCykesiopka <cykesiopka.bmo@gmail.com>
Fri, 19 Aug 2016 09:37:43 +0800
changeset 403457 655dfcd1a76934159cd8d71fcc2ae53106ecff4b
parent 403456 9406ee08579419ea687a42512b28e22ac21a9ff5
child 403458 72357ad5852b94d5bac976f2301298dc16fec3f4
push id26920
push userbmo:tchiovoloni@mozilla.com
push dateFri, 19 Aug 2016 21:00:16 +0000
reviewerskeeler
bugs1275841
milestone51.0a1
Bug 1275841 - Remove unnecessary methods and interfaces from nsISecretDecoderRing.idl. r=keeler 1. encrypt() and decrypt() are C++ only. The only callers are in SecretDecoderRing.cpp, and binary add-ons aren't supported anymore. So, there is no need for these methods to be defined in the IDL, and they should be treated as private to the nsISecretDecoderRing implementation. 2. nsISecretDecoderRingConfig has never been implemented. The interface and implementation are currently just bloat. If there is a need for specifying the window for prompts in the future, a better way can be devised then. MozReview-Commit-ID: 1wXCDTIBJA2
security/manager/ssl/SecretDecoderRing.cpp
security/manager/ssl/SecretDecoderRing.h
security/manager/ssl/nsISecretDecoderRing.idl
--- a/security/manager/ssl/SecretDecoderRing.cpp
+++ b/security/manager/ssl/SecretDecoderRing.cpp
@@ -26,36 +26,35 @@
 #include "pk11sdr.h" // For PK11SDR_Encrypt, PK11SDR_Decrypt
 #include "plstr.h"
 #include "ssl.h" // For SSL_ClearSessionCache
 #include "stdlib.h"
 
 using namespace mozilla;
 
 // NOTE: Should these be the thread-safe versions?
-NS_IMPL_ISUPPORTS(SecretDecoderRing, nsISecretDecoderRing,
-                  nsISecretDecoderRingConfig)
+NS_IMPL_ISUPPORTS(SecretDecoderRing, nsISecretDecoderRing)
 
 SecretDecoderRing::SecretDecoderRing()
 {
 }
 
 SecretDecoderRing::~SecretDecoderRing()
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown()) {
     return;
   }
 
   shutdown(calledFromObject);
 }
 
-NS_IMETHODIMP
+nsresult
 SecretDecoderRing::Encrypt(unsigned char* data, uint32_t dataLen,
-                           unsigned char** result, uint32_t* _retval)
+                   /*out*/ unsigned char** result, /*out*/ uint32_t* resultLen)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
 
@@ -85,34 +84,34 @@ SecretDecoderRing::Encrypt(unsigned char
   SECItem reply;
   reply.data = nullptr;
   reply.len = 0;
   if (PK11SDR_Encrypt(&keyid, &request, &reply, ctx) != SECSuccess) {
     return NS_ERROR_FAILURE;
   }
 
   *result = reply.data;
-  *_retval = reply.len;
+  *resultLen = reply.len;
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
+nsresult
 SecretDecoderRing::Decrypt(unsigned char* data, uint32_t dataLen,
-                           unsigned char** result, uint32_t* _retval)
+                   /*out*/ unsigned char** result, /*out*/ uint32_t* resultLen)
 {
   nsNSSShutDownPreventionLock locker;
   if (isAlreadyShutDown()) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   nsCOMPtr<nsIInterfaceRequestor> ctx = new PipUIContext();
 
   *result = nullptr;
-  *_retval = 0;
+  *resultLen = 0;
 
   /* Find token with SDR key */
   UniquePK11SlotInfo slot(PK11_GetInternalKeySlot());
   if (!slot) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   /* Force authentication */
@@ -126,17 +125,17 @@ SecretDecoderRing::Decrypt(unsigned char
   SECItem reply;
   reply.data = nullptr;
   reply.len = 0;
   if (PK11SDR_Decrypt(&request, &reply, ctx) != SECSuccess) {
     return NS_ERROR_FAILURE;
   }
 
   *result = reply.data;
-  *_retval = reply.len;
+  *resultLen = reply.len;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 SecretDecoderRing::EncryptString(const char* text, char** _retval)
 {
   nsresult rv = NS_OK;
@@ -275,15 +274,8 @@ SecretDecoderRing::LogoutAndTeardown()
   // sure that all connections that should be stopped, are stopped. See
   // bug 517584.
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os)
     os->NotifyObservers(nullptr, "net:prune-dead-connections", nullptr);
 
   return rv;
 }
-
-NS_IMETHODIMP
-SecretDecoderRing::SetWindow(nsISupports*)
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
--- a/security/manager/ssl/SecretDecoderRing.h
+++ b/security/manager/ssl/SecretDecoderRing.h
@@ -5,37 +5,36 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef SecretDecoderRing_h
 #define SecretDecoderRing_h
 
 #include "nsISecretDecoderRing.h"
 #include "nsNSSShutDown.h"
 
-/**
- *   Implements nsISecretDecoderRing.
- *   Should eventually implement an interface to set window
- *   context and other information. (nsISecretDecoderRingConfig)
- */
 #define NS_SECRETDECODERRING_CONTRACTID "@mozilla.org/security/sdr;1"
 
 #define NS_SECRETDECODERRING_CID \
   { 0x0c4f1ddc, 0x1dd2, 0x11b2, { 0x9d, 0x95, 0xf2, 0xfd, 0xf1, 0x13, 0x04, 0x4b } }
 
 class SecretDecoderRing : public nsISecretDecoderRing
-                        , public nsISecretDecoderRingConfig
                         , public nsNSSShutDownObject
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISECRETDECODERRING
-  NS_DECL_NSISECRETDECODERRINGCONFIG
 
   SecretDecoderRing();
 
   // Nothing to release.
   virtual void virtualDestroyNSSReference() override {}
 
 protected:
   virtual ~SecretDecoderRing();
+
+private:
+  nsresult Encrypt(unsigned char* data, uint32_t dataLen,
+                   /*out*/ unsigned char** result, /*out*/ uint32_t* resultLen);
+  nsresult Decrypt(unsigned char* data, uint32_t dataLen,
+                   /*out*/ unsigned char** result, /*out*/ uint32_t* resultLen);
 };
 
 #endif // SecretDecoderRing_h
--- a/security/manager/ssl/nsISecretDecoderRing.idl
+++ b/security/manager/ssl/nsISecretDecoderRing.idl
@@ -1,39 +1,17 @@
 /* -*- 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 "nsISupports.idl"
 
-/**
- * Buffer type - for storing 8-bit octet values.
- */
-[ptr] native buffer(unsigned char);
-
 [scriptable, uuid(0EC80360-075C-11d4-9FD4-00C04F1B83D8)]
 interface nsISecretDecoderRing: nsISupports {
-
-  /**
-   * Encrypt a buffer - callable only from C++.
-   *
-   * @return The length of the data in the output buffer.
-   */
-  [noscript] unsigned long encrypt(in buffer data, in unsigned long dataLen,
-                                   out buffer result);
-
-  /**
-   * Decrypt a buffer - callable only from C++.
-   *
-   * @return The length of the data in the output buffer.
-   */
-  [noscript] unsigned long decrypt(in buffer data, in unsigned long dataLen,
-                                   out buffer result);
-
   /**
    * Encrypt nul-terminated string to BASE64 output.
    */
   string encryptString(in string text);
 
   /**
    * Decrypt BASE64 input to nul-terminated string output.  There is
    * no check for embedded nul values in the decrypted output.
@@ -51,18 +29,8 @@ interface nsISecretDecoderRing: nsISuppo
   void logout();
 
   /**
    * Logout of the security device that protects the SDR key and tear
    * down authenticated objects.
    */
   void logoutAndTeardown();
 };
-
-/**
- * Configuration interface for the Secret Decoder Ring
- *  - this interface allows setting the window that will be
- *    used as parent for dialog windows (such as password prompts)
- */
-[scriptable, uuid(01D8C0F0-0CCC-11d4-9FDD-000064657374)]
-interface nsISecretDecoderRingConfig: nsISupports {
-  void setWindow(in nsISupports w);
-};