1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <array> 20 #include <optional> 21 #include <string> 22 #include <tuple> 23 #include <vector> 24 25 #include <cppbor.h> 26 #include <keymaster/cppcose/cppcose.h> 27 28 namespace keymaster { 29 30 class RemoteProvisioningContext { 31 public: RemoteProvisioningContext()32 RemoteProvisioningContext() {} ~RemoteProvisioningContext()33 virtual ~RemoteProvisioningContext(){}; 34 virtual std::vector<uint8_t> DeriveBytesFromHbk(const std::string& context, 35 size_t numBytes) const = 0; 36 virtual std::unique_ptr<cppbor::Map> CreateDeviceInfo() const = 0; 37 virtual std::pair<std::vector<uint8_t>, cppbor::Array> GenerateBcc(bool testMode) const = 0; 38 39 // Generate an HMAC-SHA256 over the given input. This is used to verify a given 40 // input hasn't changed across multiple calls to the remote provisioning HAL. 41 virtual std::optional<cppcose::HmacSha256> 42 GenerateHmacSha256(const cppcose::bytevec& input) const = 0; 43 44 std::vector<uint8_t> devicePrivKey_; 45 cppbor::Array bcc_; 46 47 private: 48 // Uncopyable. 49 RemoteProvisioningContext(const RemoteProvisioningContext&); 50 void operator=(const RemoteProvisioningContext&); 51 }; 52 53 } // namespace keymaster 54