| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import sys | 6 import sys |
| 7 | 7 |
| 8 SCRIPT_PATH = os.path.dirname(sys.argv[0]) | 8 SCRIPT_PATH = os.path.dirname(sys.argv[0]) |
| 9 if SCRIPT_PATH == "": | 9 if SCRIPT_PATH == "": |
| 10 SCRIPT_PATH = os.getcwd() | 10 SCRIPT_PATH = os.getcwd() |
| 11 | 11 |
| 12 PATHS_TO_TRY = [ | 12 PATHS_TO_TRY = [ |
| 13 '\\..\\..\\build\\Debug\\chromoting_host_keygen.exe', | 13 '\\..\\..\\build\\Debug\\remoting_host_keygen.exe', |
| 14 '\\..\\..\\build\\Release\\chromoting_host_keygen.exe', | 14 '\\..\\..\\build\\Release\\remoting_host_keygen.exe', |
| 15 '\\..\\Debug\\chromoting_host_keygen.exe', | 15 '\\..\\Debug\\remoting_host_keygen.exe', |
| 16 '\\..\\Release\\chromoting_host_keygen.exe', | 16 '\\..\\Release\\remoting_host_keygen.exe', |
| 17 '/../../xcodebuild/Debug/chromoting_host_keygen', | 17 '/../../xcodebuild/Debug/remoting_host_keygen', |
| 18 '/../../xcodebuild/Release/chromoting_host_keygen', | 18 '/../../xcodebuild/Release/remoting_host_keygen', |
| 19 '/../../out/Debug/chromoting_host_keygen', | 19 '/../../out/Debug/remoting_host_keygen', |
| 20 '/../../out/Release/chromoting_host_keygen'] | 20 '/../../out/Release/remoting_host_keygen'] |
| 21 | 21 |
| 22 KEYGEN_PATH = None | 22 KEYGEN_PATH = None |
| 23 for path in PATHS_TO_TRY: | 23 for path in PATHS_TO_TRY: |
| 24 if os.path.exists(SCRIPT_PATH + path): | 24 if os.path.exists(SCRIPT_PATH + path): |
| 25 KEYGEN_PATH = SCRIPT_PATH + path | 25 KEYGEN_PATH = SCRIPT_PATH + path |
| 26 break | 26 break |
| 27 | 27 |
| 28 if not KEYGEN_PATH: | 28 if not KEYGEN_PATH: |
| 29 raise Exception("Unable to find chromoting_host_keygen. Please build it " + | 29 raise Exception("Unable to find remoting_host_keygen. Please build it " + |
| 30 "and try again") | 30 "and try again") |
| 31 | 31 |
| 32 def generateRSAKeyPair(): | 32 def generateRSAKeyPair(): |
| 33 """Returns (priv, pub) keypair where priv is a new private key and | 33 """Returns (priv, pub) keypair where priv is a new private key and |
| 34 pub is the corresponding public key. Both keys are BASE64 encoded.""" | 34 pub is the corresponding public key. Both keys are BASE64 encoded.""" |
| 35 pipe = os.popen(KEYGEN_PATH) | 35 pipe = os.popen(KEYGEN_PATH) |
| 36 out = pipe.readlines() | 36 out = pipe.readlines() |
| 37 if len(out) != 2: | 37 if len(out) != 2: |
| 38 raise Exception("chromoting_host_keygen failed.") | 38 raise Exception("remoting_host_keygen failed.") |
| 39 return (out[0].strip(), out[1].strip()) | 39 return (out[0].strip(), out[1].strip()) |
| OLD | NEW |