#include "keymaster_tools.h" #include "avb_tools.h" #include "gtest/gtest.h" #include "nugget/app/keymaster/keymaster.pb.h" #include #include "Keymaster.client.h" #include #include #include #include #include #include #ifdef ANDROID #include #include "nos/CitadeldProxyClient.h" #else #include "gflags/gflags.h" #endif // ANDROID using std::string; using namespace nugget::app::keymaster; using namespace avb_tools; namespace keymaster_tools { void SetRootOfTrust(nos::NuggetClientInterface *client) { // Do keymaster setup that is normally executed by the bootloader. avb_tools::SetBootloader(client); SetRootOfTrustRequest request; SetRootOfTrustResponse response; Keymaster service(*client); request.set_digest(string(32, '\0')); ASSERT_NO_ERROR(service.SetRootOfTrust(request, &response), ""); EXPECT_EQ((ErrorCode)response.error_code(), ErrorCode::OK); avb_tools::BootloaderDone(client); } void SetBootState(nos::NuggetClientInterface *client) { // Do keymaster setup that is normally executed by the bootloader. avb_tools::SetBootloader(client); SetBootStateRequest request; SetBootStateResponse response; Keymaster service(*client); request.set_public_key(string(32, '\0')); request.set_boot_hash(string(32, '\0')); ASSERT_NO_ERROR(service.SetBootState(request, &response), ""); EXPECT_EQ((ErrorCode)response.error_code(), ErrorCode::OK); avb_tools::BootloaderDone(client); } } // namespace keymaster_tools