• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 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_CERT_PKI_SIGNATURE_VERIFY_CACHE_H_
6 #define NET_CERT_PKI_SIGNATURE_VERIFY_CACHE_H_
7 
8 #include <string>
9 
10 namespace net {
11 
12 class NET_EXPORT SignatureVerifyCache {
13  public:
14   enum class Value {
15     kValid,    // Cached as a valid signature result.
16     kInvalid,  // Cached as an invalid signature result.
17     kUnknown,  // Cache has no information.
18   };
19 
20   virtual ~SignatureVerifyCache() = default;
21 
22   // This interface uses a const std::string reference instead of
23   // std::string_view because any implementation that may reasonably want to use
24   // std::unordered_map or similar can run into problems with std::hash before
25   // C++20. (https://en.cppreference.com/w/cpp/container/unordered_map/find)
26 
27   // |Store| is called to store the result of a verification for |key| as kValid
28   // or kInvalid after a signature check.
29   virtual void Store(const std::string& key, Value value) = 0;
30 
31   // |Check| is called to fetch a cached value for a verification for |key|. If
32   // the result is kValid, or kInvalid, signature checking is skipped and the
33   // corresponding cached result is used.  If the result is kUnknown signature
34   // checking is performed and the corresponding result saved using |Store|.
35   virtual Value Check(const std::string& key) = 0;
36 };
37 
38 }  // namespace net
39 
40 #endif  // NET_CERT_PKI_SIGNATURE_VERIFY_CACHE_H_
41