Index: remoting/host/keygen_main.cc |
diff --git a/remoting/host/keygen_main.cc b/remoting/host/keygen_main.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6eaf898dc43906fc2cdbe35eb13e3f2a13c3b628 |
--- /dev/null |
+++ b/remoting/host/keygen_main.cc |
@@ -0,0 +1,36 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+// |
+// This is a tool used by register_host.py to generate RSA keypair. It just |
awong
2010/07/14 19:36:32
...doesn't python have a rsa key generator?
Sergey Ulanov
2010/07/14 19:56:55
It does, but only in 2.6, i.e. it wouldn't work on
|
+// generates new keys and prints them on stdout. |
+// |
+// This code will need to be integrated with the host registration UI. |
+ |
+#include <vector> |
+#include <cstdio> |
awong
2010/07/14 19:36:32
stdio.h is more common.
Also C includes go before
Sergey Ulanov
2010/07/14 19:56:55
Done.
|
+ |
+#include "base/at_exit.h" |
+#include "base/base64.h" |
+#include "base/crypto/rsa_private_key.h" |
+#include "base/scoped_ptr.h" |
+ |
+int main(int argc, char** argv) { |
+ base::AtExitManager exit_manager; |
+ |
+ scoped_ptr<base::RSAPrivateKey> key(base::RSAPrivateKey::Create(2048)); |
+ |
+ std::vector<uint8> private_key_buf; |
+ key->ExportPrivateKey(&private_key_buf); |
+ std::string private_key_str(private_key_buf.begin(), private_key_buf.end()); |
+ std::string private_key_base64; |
+ base::Base64Encode(private_key_str, &private_key_base64); |
+ printf("%s\n", private_key_base64.c_str()); |
+ |
+ std::vector<uint8> public_key_buf; |
+ key->ExportPublicKey(&public_key_buf); |
+ std::string public_key_str(public_key_buf.begin(), public_key_buf.end()); |
+ std::string public_key_base64; |
+ base::Base64Encode(public_key_str, &public_key_base64); |
+ printf("%s\n", public_key_base64.c_str()); |
+} |