security/manager/ssl/src/nsRecentBadCerts.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef __RECENTBADCERTS_H__
     8 #define __RECENTBADCERTS_H__
    10 #include "mozilla/Attributes.h"
    11 #include "mozilla/ReentrantMonitor.h"
    13 #include "nsIRecentBadCertsService.h"
    14 #include "nsTHashtable.h"
    15 #include "nsString.h"
    16 #include "cert.h"
    17 #include "secitem.h"
    19 class RecentBadCert
    20 {
    21 public:
    23   RecentBadCert()
    24   {
    25     mDERCert.len = 0;
    26     mDERCert.data = nullptr;
    27     isDomainMismatch = false;
    28     isNotValidAtThisTime = false;
    29     isUntrusted = false;
    30   }
    32   ~RecentBadCert()
    33   {
    34     Clear();
    35   }
    37   void Clear()
    38   {
    39     mHostWithPort.Truncate();
    40     if (mDERCert.len)
    41       nsMemory::Free(mDERCert.data);
    42     mDERCert.len = 0;
    43     mDERCert.data = nullptr;
    44   }
    46   nsString mHostWithPort;
    47   SECItem mDERCert;
    48   bool isDomainMismatch;
    49   bool isNotValidAtThisTime;
    50   bool isUntrusted;
    52 private:
    53   RecentBadCert(const RecentBadCert &other) MOZ_DELETE;
    54   RecentBadCert &operator=(const RecentBadCert &other) MOZ_DELETE;
    55 };
    57 class nsRecentBadCerts MOZ_FINAL : public nsIRecentBadCerts
    58 {
    59 public:
    60   NS_DECL_THREADSAFE_ISUPPORTS
    61   NS_DECL_NSIRECENTBADCERTS
    63   nsRecentBadCerts();
    64   ~nsRecentBadCerts();
    66 protected:
    67     mozilla::ReentrantMonitor monitor;
    69     enum {const_recently_seen_list_size = 5};
    70     RecentBadCert mCerts[const_recently_seen_list_size];
    72     // will be in the range of 0 to list_size-1
    73     uint32_t mNextStorePosition;
    74 };
    76 #define NS_RECENTBADCERTS_CID { /* e7caf8c0-3570-47fe-aa1b-da47539b5d07 */ \
    77     0xe7caf8c0,                                                        \
    78     0x3570,                                                            \
    79     0x47fe,                                                            \
    80     {0xaa, 0x1b, 0xda, 0x47, 0x53, 0x9b, 0x5d, 0x07}                   \
    81   }
    83 #endif

mercurial