Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: remoting/host/keygen_main.cc

Issue 2958001: Added RSA key generator for register_host.py (Closed)
Patch Set: - Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // 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
6 // generates new keys and prints them on stdout.
7 //
8 // This code will need to be integrated with the host registration UI.
9
10 #include <vector>
11 #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.
12
13 #include "base/at_exit.h"
14 #include "base/base64.h"
15 #include "base/crypto/rsa_private_key.h"
16 #include "base/scoped_ptr.h"
17
18 int main(int argc, char** argv) {
19 base::AtExitManager exit_manager;
20
21 scoped_ptr<base::RSAPrivateKey> key(base::RSAPrivateKey::Create(2048));
22
23 std::vector<uint8> private_key_buf;
24 key->ExportPrivateKey(&private_key_buf);
25 std::string private_key_str(private_key_buf.begin(), private_key_buf.end());
26 std::string private_key_base64;
27 base::Base64Encode(private_key_str, &private_key_base64);
28 printf("%s\n", private_key_base64.c_str());
29
30 std::vector<uint8> public_key_buf;
31 key->ExportPublicKey(&public_key_buf);
32 std::string public_key_str(public_key_buf.begin(), public_key_buf.end());
33 std::string public_key_base64;
34 base::Base64Encode(public_key_str, &public_key_base64);
35 printf("%s\n", public_key_base64.c_str());
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698