blob: 1410e7c9a8ac19081b8f56f3f67f6087406bb054 [file] [log] [blame]
/*
* Copyright 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <keymaster/attestation_context.h>
#include <keymaster/remote_provisioning_context.h>
#include <keymaster/serializable.h>
#include <cppbor.h>
namespace keymaster {
struct BootParams {
uint32_t boot_os_version = 0;
uint32_t boot_os_patchlevel = 0;
Buffer verified_boot_key;
keymaster_verified_boot_t verified_boot_state = KM_VERIFIED_BOOT_UNVERIFIED;
bool device_locked = false;
Buffer verified_boot_hash;
};
/**
* TrustyKeymasterContext provides the context for a secure implementation of
* RemoteProvisioningContext.
*/
class TrustyRemoteProvisioningContext : public RemoteProvisioningContext {
public:
TrustyRemoteProvisioningContext();
~TrustyRemoteProvisioningContext() override;
std::vector<uint8_t> DeriveBytesFromHbk(const std::string& context,
size_t numBytes) const override;
std::unique_ptr<cppbor::Map> CreateDeviceInfo() const override;
std::pair<std::vector<uint8_t>, cppbor::Array> GenerateBcc(
bool testMode) const override;
std::optional<cppcose::HmacSha256> GenerateHmacSha256(
const cppcose::bytevec& input) const override;
void SetBootParams(const BootParams* bootParams);
private:
bool bootParamsSet_ = false;
const BootParams* bootParams_ = nullptr;
};
} // namespace keymaster