Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsNSSComponent.cpp File Reference
#include "nsNSSComponent.h"
#include "nsNSSCallbacks.h"
#include "nsNSSIOLayer.h"
#include "nsSSLThread.h"
#include "nsCertVerificationThread.h"
#include "nsNSSEvent.h"
#include "nsNetUtil.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsDirectoryService.h"
#include "nsIStreamListener.h"
#include "nsIStringBundle.h"
#include "nsIDirectoryService.h"
#include "nsIDOMNode.h"
#include "nsCURILoader.h"
#include "nsDirectoryServiceDefs.h"
#include "nsIProxyObjectManager.h"
#include "nsIX509Cert.h"
#include "nsIX509CertDB.h"
#include "nsIProfileChangeStatus.h"
#include "nsNSSCertificate.h"
#include "nsNSSHelper.h"
#include "nsSmartCardMonitor.h"
#include "prlog.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefBranch2.h"
#include "nsIDateTimeFormat.h"
#include "nsDateTimeFormatCID.h"
#include "nsAutoLock.h"
#include "nsIEventQueue.h"
#include "nsIDOMEvent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentEvent.h"
#include "nsIDOMWindow.h"
#include "nsIDOMWindowCollection.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMSmartCardEvent.h"
#include "nsIDOMCrypto.h"
#include "nsIRunnable.h"
#include "plevent.h"
#include "nsCRT.h"
#include "nsCRLInfo.h"
#include "nsIWindowWatcher.h"
#include "nsIPrompt.h"
#include "nsProxiedService.h"
#include "nsIPrincipal.h"
#include "nsReadableUtils.h"
#include "prtypes.h"
#include "nsInt64.h"
#include "nsTime.h"
#include "nsIEntropyCollector.h"
#include "nsIBufEntropyCollector.h"
#include "nsIServiceManager.h"
#include "nsILocalFile.h"
#include "nsITokenPasswordDialogs.h"
#include "nsICRLManager.h"
#include "nsNSSShutDown.h"
#include "nsSmartCardEvent.h"
#include "nsICryptoHash.h"
#include "nss.h"
#include "pk11func.h"
#include "ssl.h"
#include "sslproto.h"
#include "secmod.h"
#include "sechash.h"
#include "secmime.h"
#include "ocsp.h"
#include "cms.h"
#include "nssckbi.h"
#include "base64.h"
#include "pkcs12.h"
#include "p12plcy.h"

Go to the source code of this file.

Classes

struct  CRLDownloadEvent
class  nsTokenEventRunnable
struct  CipherPref

Defines

#define NS_CRYPTO_HASH_BUFFER_SIZE   4096
#define PIPNSS_STRBUNDLE_URL   "chrome://pipnss/locale/pipnss.properties"
#define PROFILE_CHANGE_NET_TEARDOWN_TOPIC   "profile-change-net-teardown"
#define PROFILE_CHANGE_NET_RESTORE_TOPIC   "profile-change-net-restore"
#define PROFILE_APPROVE_CHANGE_TOPIC   "profile-approve-change"
#define PROFILE_CHANGE_TEARDOWN_TOPIC   "profile-change-teardown"
#define PROFILE_CHANGE_TEARDOWN_VETO_TOPIC   "profile-change-teardown-veto"
#define PROFILE_BEFORE_CHANGE_TOPIC   "profile-before-change"
#define PROFILE_AFTER_CHANGE_TOPIC   "profile-after-change"
#define SESSION_LOGOUT_TOPIC   "session-logout"

Functions

static NS_DEFINE_CID (kNSSComponentCID, NS_NSSCOMPONENT_CID)
char *PR_CALLBACK pk11PasswordPrompt (PK11SlotInfo *slot, PRBool retry, void *arg)
static PLHashNumber PR_CALLBACK certHashtable_keyHash (const void *key)
static PRIntn PR_CALLBACK certHashtable_keyCompare (const void *k1, const void *k2)
static PRIntn PR_CALLBACK certHashtable_valueCompare (const void *v1, const void *v2)
static PRIntn PR_CALLBACK certHashtable_clearEntry (PLHashEntry *he, PRIntn, void *)
static void PR_CALLBACK HandleCRLImportPLEvent (CRLDownloadEvent *aEvent)
static void PR_CALLBACK DestroyCRLImportPLEvent (CRLDownloadEvent *aEvent)
static void setOCSPOptions (nsIPrefBranch *pref)
 NS_IMPL_THREADSAFE_ISUPPORTS6 (nsNSSComponent, nsISignatureVerifier, nsIEntropyCollector, nsINSSComponent, nsIObserver, nsISupportsWeakReference, nsITimerCallback) static void ContentCallback(void *arg
const char unsigned long
static len PK11SymKey * 
GetDecryptKeyCallback (void *arg, SECAlgorithmID *algid)
static PRBool DecryptionAllowedCallback (SECAlgorithmID *algid, PK11SymKey *bulkkey)
static voidGetPasswordKeyCallback (void *arg, void *handle)
nsresult getNSSDialogs (void **_result, REFNSIID aIID, const char *contract)
nsresult setPassword (PK11SlotInfo *slot, nsIInterfaceRequestor *ctx)
PRUint32 getPSMContentType (const char *aContentType)
 NS_IMPL_ISUPPORTS2 (PSMContentListener, nsIURIContentListener, nsISupportsWeakReference) PSMContentListener

Variables

static CipherPref CipherPrefs []
const char * buf
const PRInt32 kDefaultCertAllocLength = 2048

Class Documentation

struct CipherPref

Definition at line 835 of file nsNSSComponent.cpp.

Class Members
long id
const char * pref

Define Documentation

Definition at line 131 of file nsNSSComponent.cpp.

#define PIPNSS_STRBUNDLE_URL   "chrome://pipnss/locale/pipnss.properties"

Definition at line 140 of file nsNSSComponent.cpp.

#define PROFILE_AFTER_CHANGE_TOPIC   "profile-after-change"

Definition at line 1813 of file nsNSSComponent.cpp.

#define PROFILE_APPROVE_CHANGE_TOPIC   "profile-approve-change"

Definition at line 1809 of file nsNSSComponent.cpp.

#define PROFILE_BEFORE_CHANGE_TOPIC   "profile-before-change"

Definition at line 1812 of file nsNSSComponent.cpp.

#define PROFILE_CHANGE_NET_RESTORE_TOPIC   "profile-change-net-restore"

Definition at line 1808 of file nsNSSComponent.cpp.

#define PROFILE_CHANGE_NET_TEARDOWN_TOPIC   "profile-change-net-teardown"

Definition at line 1807 of file nsNSSComponent.cpp.

#define PROFILE_CHANGE_TEARDOWN_TOPIC   "profile-change-teardown"

Definition at line 1810 of file nsNSSComponent.cpp.

#define PROFILE_CHANGE_TEARDOWN_VETO_TOPIC   "profile-change-teardown-veto"

Definition at line 1811 of file nsNSSComponent.cpp.

#define SESSION_LOGOUT_TOPIC   "session-logout"

Definition at line 1814 of file nsNSSComponent.cpp.


Function Documentation

static PRIntn PR_CALLBACK certHashtable_clearEntry ( PLHashEntry he,
PRIntn  ,
void  
) [static]

Definition at line 203 of file nsNSSComponent.cpp.

{
  if (he && he->value) {
    CERT_DestroyCertificate((CERTCertificate*)he->value);
  }
  
  return HT_ENUMERATE_NEXT;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRIntn PR_CALLBACK certHashtable_keyCompare ( const void k1,
const void k2 
) [static]

Definition at line 163 of file nsNSSComponent.cpp.

{
  // return type is a bool, answering the question "are the keys equal?"

  if (!k1 || !k2)
    return PR_FALSE;
  
  SECItem *certKey1 = (SECItem*)k1;
  SECItem *certKey2 = (SECItem*)k2;
  
  if (certKey1->len != certKey2->len) {
    return PR_FALSE;
  }
  
  unsigned int i = 0;
  unsigned char *c1 = certKey1->data;
  unsigned char *c2 = certKey2->data;
  
  for (i = 0; i < certKey1->len; ++i, ++c1, ++c2) {
    if (*c1 != *c2) {
      return PR_FALSE;
    }
  }
  
  return PR_TRUE;
}

Here is the caller graph for this function:

Definition at line 143 of file nsNSSComponent.cpp.

{
  if (!key)
    return 0;
  
  SECItem *certKey = (SECItem*)key;
  
  // lazy hash function, sum up all char values of SECItem
  
  PLHashNumber hash = 0;
  unsigned int i = 0;
  unsigned char *c = certKey->data;
  
  for (i = 0; i < certKey->len; ++i, ++c) {
    hash += *c;
  }
  
  return hash;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRIntn PR_CALLBACK certHashtable_valueCompare ( const void v1,
const void v2 
) [static]

Definition at line 190 of file nsNSSComponent.cpp.

{
  // two values are identical if their keys are identical
  
  if (!v1 || !v2)
    return PR_FALSE;
  
  CERTCertificate *cert1 = (CERTCertificate*)v1;
  CERTCertificate *cert2 = (CERTCertificate*)v2;
  
  return certHashtable_keyCompare(&cert1->certKey, &cert2->certKey);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool DecryptionAllowedCallback ( SECAlgorithmID *  algid,
PK11SymKey *  bulkkey 
) [static]

Definition at line 1657 of file nsNSSComponent.cpp.

{
  return SECMIME_DecryptionAllowed(algid, bulkkey);
}

Here is the call graph for this function:

Definition at line 234 of file nsNSSComponent.cpp.

{
  delete aEvent->urlString;
  delete aEvent;
}

Here is the caller graph for this function:

const char unsigned long static len PK11SymKey* GetDecryptKeyCallback ( void arg,
SECAlgorithmID *  algid 
) [static]

Definition at line 1651 of file nsNSSComponent.cpp.

{
  return nsnull;
}
nsresult getNSSDialogs ( void **  _result,
REFNSIID  aIID,
const char *  contract 
)

Definition at line 2311 of file nsNSSComponent.cpp.

{
  nsresult rv;

  nsCOMPtr<nsISupports> svc = do_GetService(contract, &rv);
  if (NS_FAILED(rv)) 
    return rv;

  nsCOMPtr<nsIProxyObjectManager> proxyman =
      do_GetService(NS_XPCOMPROXY_CONTRACTID, &rv);
  if (NS_FAILED(rv))
    return rv;
 
  rv = proxyman->GetProxyForObject(NS_UI_THREAD_EVENTQ,
                                   aIID, svc, PROXY_SYNC,
                                   _result);
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void* GetPasswordKeyCallback ( void arg,
void handle 
) [static]

Definition at line 1663 of file nsNSSComponent.cpp.

{
  return NULL;
}
PRUint32 getPSMContentType ( const char *  aContentType)

Definition at line 2602 of file nsNSSComponent.cpp.

{ 
  // Don't forget to update RegisterPSMContentListeners in nsNSSModule.cpp 
  // for every supported content type.
  
  if (!nsCRT::strcasecmp(aContentType, "application/x-x509-ca-cert"))
    return PSMContentDownloader::X509_CA_CERT;
  else if (!nsCRT::strcasecmp(aContentType, "application/x-x509-server-cert"))
    return PSMContentDownloader::X509_SERVER_CERT;
  else if (!nsCRT::strcasecmp(aContentType, "application/x-x509-user-cert"))
    return PSMContentDownloader::X509_USER_CERT;
  else if (!nsCRT::strcasecmp(aContentType, "application/x-x509-email-cert"))
    return PSMContentDownloader::X509_EMAIL_CERT;
  else if (!nsCRT::strcasecmp(aContentType, "application/x-pkcs7-crl"))
    return PSMContentDownloader::PKCS7_CRL;
  else if (!nsCRT::strcasecmp(aContentType, "application/x-x509-crl"))
    return PSMContentDownloader::PKCS7_CRL;
  else if (!nsCRT::strcasecmp(aContentType, "application/pkix-crl"))
    return PSMContentDownloader::PKCS7_CRL;
  return PSMContentDownloader::UNKNOWN_TYPE;
}

Here is the call graph for this function:

Definition at line 220 of file nsNSSComponent.cpp.

{
  nsresult rv;
  nsIURI *pURL;
  
  if((aEvent->psmDownloader==nsnull) || (aEvent->urlString==nsnull) )
    return;

  rv = NS_NewURI(&pURL, aEvent->urlString->get());
  if(NS_SUCCEEDED(rv)){
    NS_OpenURI(aEvent->psmDownloader, nsnull, pURL);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_DEFINE_CID ( kNSSComponentCID  ,
NS_NSSCOMPONENT_CID   
) [static]

Definition at line 2625 of file nsNSSComponent.cpp.

{
  mLoadCookie = nsnull;
  mParentContentListener = nsnull;
}
char* PR_CALLBACK pk11PasswordPrompt ( PK11SlotInfo *  slot,
PRBool  retry,
void arg 
)
static void setOCSPOptions ( nsIPrefBranch pref) [static]

Definition at line 913 of file nsNSSComponent.cpp.

{
  nsNSSShutDownPreventionLock locker;
  // Set up OCSP //
  PRInt32 ocspEnabled;
  pref->GetIntPref("security.OCSP.enabled", &ocspEnabled);
  switch (ocspEnabled) {
  case 0:
    CERT_DisableOCSPChecking(CERT_GetDefaultCertDB());
    CERT_DisableOCSPDefaultResponder(CERT_GetDefaultCertDB());
    break;
  case 1:
    CERT_EnableOCSPChecking(CERT_GetDefaultCertDB());
    break;
  case 2:
    {
      char *signingCA = nsnull;
      char *url = nsnull;

      // Get the signing CA and service url //
      pref->GetCharPref("security.OCSP.signingCA", &signingCA);
      pref->GetCharPref("security.OCSP.URL", &url);

      // Set OCSP up
      CERT_EnableOCSPChecking(CERT_GetDefaultCertDB());
      CERT_SetOCSPDefaultResponder(CERT_GetDefaultCertDB(), url, signingCA);
      CERT_EnableOCSPDefaultResponder(CERT_GetDefaultCertDB());

      nsMemory::Free(signingCA);
      nsMemory::Free(url);
    }
    break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult setPassword ( PK11SlotInfo *  slot,
nsIInterfaceRequestor ctx 
)

Definition at line 2331 of file nsNSSComponent.cpp.

{
  nsNSSShutDownPreventionLock locker;
  nsresult rv = NS_OK;
  
  if (PK11_NeedUserInit(slot)) {
    nsITokenPasswordDialogs *dialogs;
    PRBool canceled;
    NS_ConvertUTF8toUCS2 tokenName(PK11_GetTokenName(slot));

    rv = getNSSDialogs((void**)&dialogs,
                       NS_GET_IID(nsITokenPasswordDialogs),
                       NS_TOKENPASSWORDSDIALOG_CONTRACTID);

    if (NS_FAILED(rv)) goto loser;

    {
      nsPSMUITracker tracker;
      if (tracker.isUIForbidden()) {
        rv = NS_ERROR_NOT_AVAILABLE;
      }
      else {
        rv = dialogs->SetPassword(ctx,
                                  tokenName.get(),
                                  &canceled);
      }
    }
    NS_RELEASE(dialogs);
    if (NS_FAILED(rv)) goto loser;

    if (canceled) { rv = NS_ERROR_NOT_AVAILABLE; goto loser; }
  }
 loser:
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char* buf

Definition at line 1646 of file nsNSSComponent.cpp.

CipherPref CipherPrefs[] [static]

Definition at line 840 of file nsNSSComponent.cpp.

Definition at line 2384 of file nsNSSComponent.cpp.