security/manager/ssl/src/nsRecentBadCerts.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/manager/ssl/src/nsRecentBadCerts.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef __RECENTBADCERTS_H__
    1.11 +#define __RECENTBADCERTS_H__
    1.12 +
    1.13 +#include "mozilla/Attributes.h"
    1.14 +#include "mozilla/ReentrantMonitor.h"
    1.15 +
    1.16 +#include "nsIRecentBadCertsService.h"
    1.17 +#include "nsTHashtable.h"
    1.18 +#include "nsString.h"
    1.19 +#include "cert.h"
    1.20 +#include "secitem.h"
    1.21 +
    1.22 +class RecentBadCert
    1.23 +{
    1.24 +public:
    1.25 +
    1.26 +  RecentBadCert()
    1.27 +  {
    1.28 +    mDERCert.len = 0;
    1.29 +    mDERCert.data = nullptr;
    1.30 +    isDomainMismatch = false;
    1.31 +    isNotValidAtThisTime = false;
    1.32 +    isUntrusted = false;
    1.33 +  }
    1.34 +
    1.35 +  ~RecentBadCert()
    1.36 +  {
    1.37 +    Clear();
    1.38 +  }
    1.39 +
    1.40 +  void Clear()
    1.41 +  {
    1.42 +    mHostWithPort.Truncate();
    1.43 +    if (mDERCert.len)
    1.44 +      nsMemory::Free(mDERCert.data);
    1.45 +    mDERCert.len = 0;
    1.46 +    mDERCert.data = nullptr;
    1.47 +  }
    1.48 +
    1.49 +  nsString mHostWithPort;
    1.50 +  SECItem mDERCert;
    1.51 +  bool isDomainMismatch;
    1.52 +  bool isNotValidAtThisTime;
    1.53 +  bool isUntrusted;
    1.54 +
    1.55 +private:
    1.56 +  RecentBadCert(const RecentBadCert &other) MOZ_DELETE;
    1.57 +  RecentBadCert &operator=(const RecentBadCert &other) MOZ_DELETE;
    1.58 +};
    1.59 +
    1.60 +class nsRecentBadCerts MOZ_FINAL : public nsIRecentBadCerts
    1.61 +{
    1.62 +public:
    1.63 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.64 +  NS_DECL_NSIRECENTBADCERTS
    1.65 +
    1.66 +  nsRecentBadCerts();
    1.67 +  ~nsRecentBadCerts();
    1.68 +
    1.69 +protected:
    1.70 +    mozilla::ReentrantMonitor monitor;
    1.71 +
    1.72 +    enum {const_recently_seen_list_size = 5};
    1.73 +    RecentBadCert mCerts[const_recently_seen_list_size];
    1.74 +
    1.75 +    // will be in the range of 0 to list_size-1
    1.76 +    uint32_t mNextStorePosition;
    1.77 +};
    1.78 +
    1.79 +#define NS_RECENTBADCERTS_CID { /* e7caf8c0-3570-47fe-aa1b-da47539b5d07 */ \
    1.80 +    0xe7caf8c0,                                                        \
    1.81 +    0x3570,                                                            \
    1.82 +    0x47fe,                                                            \
    1.83 +    {0xaa, 0x1b, 0xda, 0x47, 0x53, 0x9b, 0x5d, 0x07}                   \
    1.84 +  }
    1.85 +
    1.86 +#endif

mercurial