1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_CRYPTO_SIGNATURE_CACHE_H_
6 #define CHROMECAST_CRYPTO_SIGNATURE_CACHE_H_
10 #include "base/containers/mru_cache.h"
11 #include "base/macros.h"
12 #include "base/synchronization/lock.h"
14 namespace chromecast
{
16 // Cache the signatures of hashes corresponding to a particular private key
17 // (only the most recent one for which a signature was cached). We expect that
18 // normally the same private key will be used always, however we also
19 // accommodate the case where the key is changed and a new key becomes current.
20 // In this case we flush the cache and start over with the new key.
21 class SignatureCache
{
26 std::string
Get(const std::string
& wrapped_private_key
,
27 const std::string
& hash
);
29 void Put(const std::string
& wrapped_private_key
,
30 const std::string
& hash
,
31 const std::string
& signature
);
36 base::HashingMRUCache
<std::string
, std::string
> contents_
;
38 DISALLOW_COPY_AND_ASSIGN(SignatureCache
);
41 } // namespace chromecast
43 #endif // CHROMECAST_CRYPTO_SIGNATURE_CACHE_H_