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

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

mercurial