blob: d99f6902dccb9b222cd85362a7f2cfea87b8db77 [file] [log] [blame]
Bob Beckbc97b7a2023-04-18 08:35:15 -06001// 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#include "mock_signature_verify_cache.h"
6
7#include <algorithm>
8
9namespace bssl {
10
11MockSignatureVerifyCache::MockSignatureVerifyCache() = default;
12
13MockSignatureVerifyCache::~MockSignatureVerifyCache() = default;
14
Bob Beck5c7a2a02023-11-20 17:28:21 -070015void MockSignatureVerifyCache::Store(const std::string &key,
Bob Beckbc97b7a2023-04-18 08:35:15 -060016 SignatureVerifyCache::Value value) {
17 cache_.insert_or_assign(key, value);
18 stores_++;
19}
20
21SignatureVerifyCache::Value MockSignatureVerifyCache::Check(
Bob Beck5c7a2a02023-11-20 17:28:21 -070022 const std::string &key) {
Bob Beckbc97b7a2023-04-18 08:35:15 -060023 auto iter = cache_.find(key);
24 if (iter == cache_.end()) {
25 misses_++;
26 return SignatureVerifyCache::Value::kUnknown;
27 }
28 hits_++;
29 return iter->second;
30}
31
Bob Beck5c7a2a02023-11-20 17:28:21 -070032} // namespace bssl