forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pinsets.h
55 lines (39 loc) · 1.61 KB
/
pinsets.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_
#define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_
#include <map>
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/strings/string_piece.h"
#include "net/tools/transport_security_state_generator/cert_util.h"
#include "net/tools/transport_security_state_generator/pinset.h"
#include "net/tools/transport_security_state_generator/spki_hash.h"
namespace net {
namespace transport_security_state {
// Contains SPKIHashes and their names. The names are used to reference
// the hashes from Pinset's.
using SPKIHashMap = std::map<std::string, SPKIHash>;
using PinsetMap = std::map<std::string, std::unique_ptr<Pinset>>;
class Pinsets {
public:
Pinsets();
~Pinsets();
void RegisterSPKIHash(base::StringPiece name, const SPKIHash& hash);
void RegisterPinset(std::unique_ptr<Pinset> set);
size_t size() const { return pinsets_.size(); }
size_t spki_size() const { return spki_hashes_.size(); }
const SPKIHashMap& spki_hashes() const { return spki_hashes_; }
const PinsetMap& pinsets() const { return pinsets_; }
private:
// Contains all SPKI hashes found in the input pins file.
SPKIHashMap spki_hashes_;
// Contains all pinsets in the input JSON file.
PinsetMap pinsets_;
DISALLOW_COPY_AND_ASSIGN(Pinsets);
};
} // namespace transport_security_state
} // namespace net
#endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PINSETS_H_