• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2023 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 #include <android-base/logging.h>
17 #include <gflags/gflags.h>
18 
19 #include "host/commands/secure_env/secure_env_windows_lib.h"
20 
21 DEFINE_string(keymaster_pipe, "", "Keymaster pipe path");
22 DEFINE_string(gatekeeper_pipe, "", "Gatekeeper pipe path");
23 DEFINE_bool(use_tpm, false, "Whether to use TPM for cryptography primitives.");
24 
main(int argc,char ** argv)25 int main(int argc, char** argv) {
26   ::android::base::InitLogging(argv, android::base::StderrLogger);
27   gflags::ParseCommandLineFlags(&argc, &argv, true);
28 
29   std::string keymaster_pipe = FLAGS_keymaster_pipe;
30   if (keymaster_pipe.empty()) {
31     LOG(FATAL) << "Keymaster pipe (--keymaster_pipe) not specified.";
32   }
33   std::string gatekeeper_pipe = FLAGS_gatekeeper_pipe;
34   if (gatekeeper_pipe.empty()) {
35     LOG(FATAL) << "Gatekeeper pipe (--gatekeeper_pipe) not specified.";
36   }
37 
38   bool use_tpm = FLAGS_use_tpm;
39   if (keymaster_pipe.empty() || gatekeeper_pipe.empty()) {
40     LOG(ERROR) << "Invalid arguments. See --help for details.";
41     return 1;
42   }
43 
44   // Start up secure_env and wait for its threads to exit before returning.
45   if (!secure_env::StartSecureEnv(keymaster_pipe.c_str(),
46                                   gatekeeper_pipe.c_str(), use_tpm)) {
47     return 1;
48   }
49 
50   return 0;
51 }