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 #include "chromecast/crypto/signature_cache.h"
7 #include "base/logging.h"
12 const int kSignatureCacheSize
= 10;
15 SignatureCache::SignatureCache()
16 : contents_(kSignatureCacheSize
) {}
18 SignatureCache::~SignatureCache() {}
20 std::string
SignatureCache::Get(const std::string
& wrapped_private_key
,
21 const std::string
& hash
) {
23 base::AutoLock
lock(lock_
);
25 if (wrapped_private_key
!= key_
)
28 const auto iter
= contents_
.Get(hash
);
29 if (iter
!= contents_
.end())
30 result
= iter
->second
;
35 void SignatureCache::Put(const std::string
& wrapped_private_key
,
36 const std::string
& hash
,
37 const std::string
& signature
) {
38 base::AutoLock
lock(lock_
);
40 if (wrapped_private_key
!= key_
) {
41 key_
= wrapped_private_key
;
45 contents_
.Put(hash
, signature
);
48 } // namespace chromecast