1 // Copyright 2016 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PRELOADED_STATE_GENERATOR_H_ 6 #define NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PRELOADED_STATE_GENERATOR_H_ 7 8 #include <stdint.h> 9 10 #include <memory> 11 #include <string> 12 13 #include "base/time/time.h" 14 #include "net/tools/huffman_trie/trie/trie_writer.h" 15 #include "net/tools/transport_security_state_generator/pinset.h" 16 #include "net/tools/transport_security_state_generator/pinsets.h" 17 #include "net/tools/transport_security_state_generator/transport_security_state_entry.h" 18 19 namespace net::transport_security_state { 20 21 // PreloadedStateGenerator generates C++ code that contains the preloaded 22 // entries in a way the Chromium code understands. The code that reads the 23 // output can be found in net/http/transport_security_state.cc. The output gets 24 // compiled into the binary. 25 class PreloadedStateGenerator { 26 public: 27 PreloadedStateGenerator(); 28 ~PreloadedStateGenerator(); 29 30 // Returns the generated C++ code on success and the empty string on failure. 31 std::string Generate(const std::string& preload_template, 32 const TransportSecurityStateEntries& entries, 33 const Pinsets& pinsets, 34 const base::Time& timestamp); 35 36 private: 37 void ProcessSPKIHashes(const Pinsets& pinset, std::string* tpl); 38 void ProcessPinsets(const Pinsets& pinset, 39 NameIDMap* pinset_map, 40 std::string* tpl); 41 }; 42 43 } // namespace net::transport_security_state 44 45 #endif // NET_TOOLS_TRANSPORT_SECURITY_STATE_GENERATOR_PRELOADED_STATE_GENERATOR_H_ 46