security/manager/ssl/src/nsNSSCertificate.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/manager/ssl/src/nsNSSCertificate.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,143 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef _NS_NSSCERTIFICATE_H_
    1.10 +#define _NS_NSSCERTIFICATE_H_
    1.11 +
    1.12 +#include "nsIX509Cert.h"
    1.13 +#include "nsIX509Cert2.h"
    1.14 +#include "nsIX509Cert3.h"
    1.15 +#include "nsIX509CertDB.h"
    1.16 +#include "nsIX509CertList.h"
    1.17 +#include "nsIASN1Object.h"
    1.18 +#include "nsISMimeCert.h"
    1.19 +#include "nsIIdentityInfo.h"
    1.20 +#include "nsCOMPtr.h"
    1.21 +#include "nsNSSShutDown.h"
    1.22 +#include "nsISimpleEnumerator.h"
    1.23 +#include "nsISerializable.h"
    1.24 +#include "nsIClassInfo.h"
    1.25 +#include "pkix/pkixtypes.h"
    1.26 +#include "certt.h"
    1.27 +
    1.28 +class nsAutoString;
    1.29 +class nsINSSComponent;
    1.30 +class nsIASN1Sequence;
    1.31 +
    1.32 +class nsNSSCertificate : public nsIX509Cert3,
    1.33 +                         public nsIIdentityInfo,
    1.34 +                         public nsISMimeCert,
    1.35 +                         public nsISerializable,
    1.36 +                         public nsIClassInfo,
    1.37 +                         public nsNSSShutDownObject
    1.38 +{
    1.39 +public:
    1.40 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.41 +  NS_DECL_NSIX509CERT
    1.42 +  NS_DECL_NSIX509CERT2
    1.43 +  NS_DECL_NSIX509CERT3
    1.44 +  NS_DECL_NSIIDENTITYINFO
    1.45 +  NS_DECL_NSISMIMECERT
    1.46 +  NS_DECL_NSISERIALIZABLE
    1.47 +  NS_DECL_NSICLASSINFO
    1.48 +
    1.49 +  friend class nsNSSCertificateFakeTransport;
    1.50 +
    1.51 +  nsNSSCertificate(CERTCertificate* cert, SECOidTag* evOidPolicy = nullptr);
    1.52 +  nsNSSCertificate();
    1.53 +  virtual ~nsNSSCertificate();
    1.54 +  nsresult FormatUIStrings(const nsAutoString& nickname,
    1.55 +                           nsAutoString& nickWithSerial,
    1.56 +                           nsAutoString& details);
    1.57 +  static nsNSSCertificate* Create(CERTCertificate*cert = nullptr,
    1.58 +                                  SECOidTag* evOidPolicy = nullptr);
    1.59 +  static nsNSSCertificate* ConstructFromDER(char* certDER, int derLen);
    1.60 +
    1.61 +private:
    1.62 +  mozilla::pkix::ScopedCERTCertificate mCert;
    1.63 +  bool             mPermDelete;
    1.64 +  uint32_t         mCertType;
    1.65 +  nsresult CreateASN1Struct(nsIASN1Object** aRetVal);
    1.66 +  nsresult CreateTBSCertificateASN1Struct(nsIASN1Sequence** retSequence,
    1.67 +                                          nsINSSComponent* nssComponent);
    1.68 +  nsresult GetSortableDate(PRTime aTime, nsAString& _aSortableDate);
    1.69 +  virtual void virtualDestroyNSSReference();
    1.70 +  void destructorSafeDestroyNSSReference();
    1.71 +  bool InitFromDER(char* certDER, int derLen);  // return false on failure
    1.72 +
    1.73 +  enum {
    1.74 +    ev_status_invalid = 0, ev_status_valid = 1, ev_status_unknown = 2
    1.75 +  } mCachedEVStatus;
    1.76 +  SECOidTag mCachedEVOidTag;
    1.77 +  nsresult hasValidEVOidTag(SECOidTag& resultOidTag, bool& validEV);
    1.78 +  nsresult getValidEVOidTag(SECOidTag& resultOidTag, bool& validEV);
    1.79 +};
    1.80 +
    1.81 +class nsNSSCertList: public nsIX509CertList,
    1.82 +                     public nsNSSShutDownObject
    1.83 +{
    1.84 +public:
    1.85 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.86 +  NS_DECL_NSIX509CERTLIST
    1.87 +
    1.88 +  // certList is adopted
    1.89 +  nsNSSCertList(mozilla::pkix::ScopedCERTCertList& certList,
    1.90 +                const nsNSSShutDownPreventionLock& proofOfLock);
    1.91 +
    1.92 +  nsNSSCertList();
    1.93 +
    1.94 +  static CERTCertList* DupCertList(CERTCertList* aCertList,
    1.95 +                                   const nsNSSShutDownPreventionLock&
    1.96 +                                     proofOfLock);
    1.97 +private:
    1.98 +   virtual ~nsNSSCertList();
    1.99 +   virtual void virtualDestroyNSSReference();
   1.100 +   void destructorSafeDestroyNSSReference();
   1.101 +
   1.102 +   mozilla::pkix::ScopedCERTCertList mCertList;
   1.103 +
   1.104 +   nsNSSCertList(const nsNSSCertList&) MOZ_DELETE;
   1.105 +   void operator=(const nsNSSCertList&) MOZ_DELETE;
   1.106 +};
   1.107 +
   1.108 +class nsNSSCertListEnumerator: public nsISimpleEnumerator,
   1.109 +                               public nsNSSShutDownObject
   1.110 +{
   1.111 +public:
   1.112 +   NS_DECL_THREADSAFE_ISUPPORTS
   1.113 +   NS_DECL_NSISIMPLEENUMERATOR
   1.114 +
   1.115 +   nsNSSCertListEnumerator(CERTCertList* certList,
   1.116 +                           const nsNSSShutDownPreventionLock& proofOfLock);
   1.117 +private:
   1.118 +   virtual ~nsNSSCertListEnumerator();
   1.119 +   virtual void virtualDestroyNSSReference();
   1.120 +   void destructorSafeDestroyNSSReference();
   1.121 +
   1.122 +   mozilla::pkix::ScopedCERTCertList mCertList;
   1.123 +
   1.124 +   nsNSSCertListEnumerator(const nsNSSCertListEnumerator&) MOZ_DELETE;
   1.125 +   void operator=(const nsNSSCertListEnumerator&) MOZ_DELETE;
   1.126 +};
   1.127 +
   1.128 +
   1.129 +#define NS_NSS_LONG 4
   1.130 +#define NS_NSS_GET_LONG(x) ((((unsigned long)((x)[0])) << 24) | \
   1.131 +                            (((unsigned long)((x)[1])) << 16) | \
   1.132 +                            (((unsigned long)((x)[2])) <<  8) | \
   1.133 +                             ((unsigned long)((x)[3])) )
   1.134 +#define NS_NSS_PUT_LONG(src,dest) (dest)[0] = (((src) >> 24) & 0xff); \
   1.135 +                                  (dest)[1] = (((src) >> 16) & 0xff); \
   1.136 +                                  (dest)[2] = (((src) >>  8) & 0xff); \
   1.137 +                                  (dest)[3] = ((src) & 0xff);
   1.138 +
   1.139 +#define NS_X509CERT_CID { /* 660a3226-915c-4ffb-bb20-8985a632df05 */   \
   1.140 +    0x660a3226,                                                        \
   1.141 +    0x915c,                                                            \
   1.142 +    0x4ffb,                                                            \
   1.143 +    { 0xbb, 0x20, 0x89, 0x85, 0xa6, 0x32, 0xdf, 0x05 }                 \
   1.144 +  }
   1.145 +
   1.146 +#endif // _NS_NSSCERTIFICATE_H_

mercurial