Home | History | Annotate | Download | only in tools
      1 #include "keymaster_tools.h"
      2 #include "avb_tools.h"
      3 
      4 #include "gtest/gtest.h"
      5 #include "nugget/app/keymaster/keymaster.pb.h"
      6 
      7 #include <app_nugget.h>
      8 #include "Keymaster.client.h"
      9 #include <keymaster.h>
     10 #include <nos/NuggetClient.h>
     11 
     12 #include <chrono>
     13 #include <iostream>
     14 #include <thread>
     15 #include <vector>
     16 
     17 #ifdef ANDROID
     18 #include <android-base/endian.h>
     19 #include "nos/CitadeldProxyClient.h"
     20 #else
     21 #include "gflags/gflags.h"
     22 #endif  // ANDROID
     23 
     24 using std::string;
     25 using namespace nugget::app::keymaster;
     26 using namespace avb_tools;
     27 
     28 namespace keymaster_tools {
     29 
     30 void SetRootOfTrust(nos::NuggetClientInterface *client)
     31 {
     32 
     33   // Do keymaster setup that is normally executed by the bootloader.
     34   avb_tools::SetBootloader(client);
     35 
     36   SetRootOfTrustRequest request;
     37   SetRootOfTrustResponse response;
     38   Keymaster service(*client);
     39   request.set_digest(string(32, '\0'));
     40   ASSERT_NO_ERROR(service.SetRootOfTrust(request, &response), "");
     41   EXPECT_EQ((ErrorCode)response.error_code(), ErrorCode::OK);
     42 
     43   avb_tools::BootloaderDone(client);
     44 }
     45 
     46 }  // namespace keymaster_tools
     47