mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-07 04:05:49 +00:00
a028ea5c2d
--HG-- rename : security/manager/boot/src/CertBlocklist.cpp => security/manager/ssl/CertBlocklist.cpp rename : security/manager/boot/src/CertBlocklist.h => security/manager/ssl/CertBlocklist.h rename : security/manager/boot/src/DataStorage.cpp => security/manager/ssl/DataStorage.cpp rename : security/manager/boot/src/DataStorage.h => security/manager/ssl/DataStorage.h rename : security/manager/boot/src/PublicKeyPinningService.cpp => security/manager/ssl/PublicKeyPinningService.cpp rename : security/manager/boot/src/PublicKeyPinningService.h => security/manager/ssl/PublicKeyPinningService.h rename : security/manager/boot/src/RootCertificateTelemetryUtils.cpp => security/manager/ssl/RootCertificateTelemetryUtils.cpp rename : security/manager/boot/src/RootCertificateTelemetryUtils.h => security/manager/ssl/RootCertificateTelemetryUtils.h rename : security/manager/boot/src/RootHashes.inc => security/manager/ssl/RootHashes.inc rename : security/manager/boot/src/StaticHPKPins.errors => security/manager/ssl/StaticHPKPins.errors rename : security/manager/boot/src/StaticHPKPins.h => security/manager/ssl/StaticHPKPins.h rename : security/manager/boot/src/nsEntropyCollector.cpp => security/manager/ssl/nsEntropyCollector.cpp rename : security/manager/boot/src/nsEntropyCollector.h => security/manager/ssl/nsEntropyCollector.h rename : security/manager/boot/public/nsIBufEntropyCollector.idl => security/manager/ssl/nsIBufEntropyCollector.idl rename : security/manager/boot/public/nsICertBlocklist.idl => security/manager/ssl/nsICertBlocklist.idl rename : security/manager/boot/public/nsISSLStatusProvider.idl => security/manager/ssl/nsISSLStatusProvider.idl rename : security/manager/boot/public/nsISecurityUITelemetry.idl => security/manager/ssl/nsISecurityUITelemetry.idl rename : security/manager/boot/src/nsSTSPreloadList.errors => security/manager/ssl/nsSTSPreloadList.errors rename : security/manager/boot/src/nsSTSPreloadList.inc => security/manager/ssl/nsSTSPreloadList.inc rename : security/manager/boot/src/nsSecureBrowserUIImpl.cpp => security/manager/ssl/nsSecureBrowserUIImpl.cpp rename : security/manager/boot/src/nsSecureBrowserUIImpl.h => security/manager/ssl/nsSecureBrowserUIImpl.h rename : security/manager/boot/src/nsSecurityHeaderParser.cpp => security/manager/ssl/nsSecurityHeaderParser.cpp rename : security/manager/boot/src/nsSecurityHeaderParser.h => security/manager/ssl/nsSecurityHeaderParser.h rename : security/manager/boot/src/nsSiteSecurityService.cpp => security/manager/ssl/nsSiteSecurityService.cpp rename : security/manager/boot/src/nsSiteSecurityService.h => security/manager/ssl/nsSiteSecurityService.h
88 lines
2.7 KiB
C++
88 lines
2.7 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef CertBlocklist_h
|
|
#define CertBlocklist_h
|
|
|
|
#include "mozilla/Mutex.h"
|
|
#include "nsClassHashtable.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsICertBlocklist.h"
|
|
#include "nsIOutputStream.h"
|
|
#include "nsTHashtable.h"
|
|
#include "nsIX509CertDB.h"
|
|
#include "pkix/Input.h"
|
|
|
|
#define NS_CERT_BLOCKLIST_CID \
|
|
{0x11aefd53, 0x2fbb, 0x4c92, {0xa0, 0xc1, 0x05, 0x32, 0x12, 0xae, 0x42, 0xd0} }
|
|
|
|
enum CertBlocklistItemMechanism {
|
|
BlockByIssuerAndSerial,
|
|
BlockBySubjectAndPubKey
|
|
};
|
|
|
|
enum CertBlocklistItemState {
|
|
CertNewFromBlocklist,
|
|
CertOldFromLocalCache
|
|
};
|
|
|
|
class CertBlocklistItem
|
|
{
|
|
public:
|
|
CertBlocklistItem(const uint8_t* DNData, size_t DNLength,
|
|
const uint8_t* otherData, size_t otherLength,
|
|
CertBlocklistItemMechanism itemMechanism);
|
|
CertBlocklistItem(const CertBlocklistItem& aItem);
|
|
~CertBlocklistItem();
|
|
nsresult ToBase64(nsACString& b64IssuerOut, nsACString& b64SerialOut);
|
|
bool operator==(const CertBlocklistItem& aItem) const;
|
|
uint32_t Hash() const;
|
|
bool mIsCurrent;
|
|
CertBlocklistItemMechanism mItemMechanism;
|
|
|
|
private:
|
|
size_t mDNLength;
|
|
uint8_t* mDNData;
|
|
size_t mOtherLength;
|
|
uint8_t* mOtherData;
|
|
};
|
|
|
|
typedef nsGenericHashKey<CertBlocklistItem> BlocklistItemKey;
|
|
typedef nsTHashtable<BlocklistItemKey> BlocklistTable;
|
|
typedef nsTHashtable<nsCStringHashKey> BlocklistStringSet;
|
|
typedef nsClassHashtable<nsCStringHashKey, BlocklistStringSet> IssuerTable;
|
|
|
|
class CertBlocklist : public nsICertBlocklist
|
|
{
|
|
public:
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
|
NS_DECL_NSICERTBLOCKLIST
|
|
CertBlocklist();
|
|
nsresult Init();
|
|
|
|
private:
|
|
BlocklistTable mBlocklist;
|
|
nsresult AddRevokedCertInternal(const nsACString& aEncodedDN,
|
|
const nsACString& aEncodedOther,
|
|
CertBlocklistItemMechanism aMechanism,
|
|
CertBlocklistItemState aItemState,
|
|
mozilla::MutexAutoLock& /*proofOfLock*/);
|
|
mozilla::Mutex mMutex;
|
|
bool mModified;
|
|
bool mBackingFileIsInitialized;
|
|
// call EnsureBackingFileInitialized before operations that read or
|
|
// modify CertBlocklist data
|
|
nsresult EnsureBackingFileInitialized(mozilla::MutexAutoLock& lock);
|
|
nsCOMPtr<nsIFile> mBackingFile;
|
|
|
|
protected:
|
|
static void PreferenceChanged(const char* aPref, void* aClosure);
|
|
static uint32_t sLastBlocklistUpdate;
|
|
static uint32_t sMaxStaleness;
|
|
virtual ~CertBlocklist();
|
|
};
|
|
|
|
#endif // CertBlocklist_h
|