LCOV - code coverage report
Current view: top level - security/manager/ssl - nsPKCS12Blob.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef nsPKCS12Blob_h
       6             : #define nsPKCS12Blob_h
       7             : 
       8             : #include "nsCOMPtr.h"
       9             : #include "nsIMutableArray.h"
      10             : #include "nsNSSShutDown.h"
      11             : #include "nsString.h"
      12             : #include "p12.h"
      13             : #include "seccomon.h"
      14             : 
      15             : class nsIFile;
      16             : class nsIX509Cert;
      17             : 
      18             : //
      19             : // nsPKCS12Blob
      20             : //
      21             : // Class for importing/exporting PKCS#12 blobs
      22             : //
      23             : class nsPKCS12Blob : public nsNSSShutDownObject
      24             : {
      25             : public:
      26             :   nsPKCS12Blob();
      27             :   virtual ~nsPKCS12Blob();
      28             : 
      29             :   // Nothing to release.
      30           0 :   virtual void virtualDestroyNSSReference() override {}
      31             : 
      32             :   // PKCS#12 Import
      33             :   nsresult ImportFromFile(nsIFile *file);
      34             : 
      35             :   // PKCS#12 Export
      36             :   nsresult ExportToFile(nsIFile *file, nsIX509Cert **certs, int numCerts);
      37             : 
      38             : private:
      39             : 
      40             :   nsCOMPtr<nsIMutableArray>       mCertArray;
      41             :   nsCOMPtr<nsIInterfaceRequestor> mUIContext;
      42             : 
      43             :   // local helper functions
      44             :   nsresult getPKCS12FilePassword(SECItem *);
      45             :   nsresult newPKCS12FilePassword(SECItem *);
      46             :   nsresult inputToDecoder(SEC_PKCS12DecoderContext *, nsIFile *);
      47             :   nsresult unicodeToItem(const nsString& uni, SECItem* item);
      48             :   void handleError(int myerr = 0);
      49             : 
      50             :   // RetryReason and ImportMode are used when importing a PKCS12 file.
      51             :   // There are two reasons that cause us to retry:
      52             :   // - When the password entered by the user is incorrect.
      53             :   //   The user will be prompted to try again.
      54             :   // - When the user entered a zero length password.
      55             :   //   An empty password should be represented as an empty
      56             :   //   string (a SECItem that contains a single terminating
      57             :   //   null UTF16 character), but some applications use a
      58             :   //   zero length SECItem.
      59             :   //   We try both variations, zero length item and empty string,
      60             :   //   without giving a user prompt when trying the different empty password flavors.
      61             : 
      62             :   enum RetryReason { rr_do_not_retry, rr_bad_password, rr_auto_retry_empty_password_flavors };
      63             :   enum ImportMode { im_standard_prompt, im_try_zero_length_secitem };
      64             : 
      65             :   nsresult ImportFromFileHelper(nsIFile *file, ImportMode aImportMode, RetryReason &aWantRetry);
      66             : 
      67             :   // NSPR file I/O for export file
      68             :   PRFileDesc *mTmpFile;
      69             : 
      70             :   static SECItem * nickname_collision(SECItem *, PRBool *, void *);
      71             :   static void write_export_file(void *arg, const char *buf, unsigned long len);
      72             : };
      73             : 
      74             : #endif // nsPKCS12Blob_h

Generated by: LCOV version 1.13