blob: f0aee5598626dad9f9d86ae6ad17d42b55976ee4 [file] [log] [blame]
// Copyright 2020 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "trunks/tpm_cache.h"
#include <base/macros.h>
#include <base/optional.h>
#include "trunks/tpm_generated.h"
#include "trunks/trunks_export.h"
#include "trunks/trunks_factory.h"
namespace trunks {
// Implementation of the interface TpmCache.
class TRUNKS_EXPORT TpmCacheImpl : public TpmCache {
explicit TpmCacheImpl(const TrunksFactory& factory);
TpmCacheImpl(const TpmCacheImpl&) = delete;
TpmCacheImpl& operator=(const TpmCacheImpl&) = delete;
~TpmCacheImpl() override = default;
TPM_RC GetSaltingKeyPublicArea(TPMT_PUBLIC* public_area) override;
TPM_ALG_ID GetBestSupportedKeyType() override;
// Salting key public area cache.
base::Optional<TPMT_PUBLIC> salting_key_pub_area_;
// Cache of the best SRK and salting key type. If the optional value exists,
// it can only be TPM_ALG_ECC or TPM_ALG_RSA.
base::Optional<TPM_ALG_ID> best_key_type_;
const TrunksFactory& factory_;
} // namespace trunks