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

Side by Side Diff: net/base/keygen_handler_openssl.cc

Issue 5541002: Implements keygen handler for openssl, but without private key persistence (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/keygen_handler_unittest.cc » ('j') | net/base/keygen_handler_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/base/keygen_handler.h" 5 #include "net/base/keygen_handler.h"
6 6
7 #include <openssl/ssl.h>
8 #include <openssl/x509.h>
9
10 #include "base/crypto/rsa_private_key.h"
7 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/openssl_util.h"
13 #include "base/scoped_ptr.h"
8 14
9 namespace net { 15 namespace net {
10 16
11 std::string KeygenHandler::GenKeyAndSignChallenge() { 17 std::string KeygenHandler::GenKeyAndSignChallenge() {
12 // TODO(bulach): implement me. 18 scoped_ptr<base::RSAPrivateKey> key(
13 NOTIMPLEMENTED(); 19 base::RSAPrivateKey::Create(key_size_in_bits_));
14 return ""; 20 DCHECK(key != NULL);
21 EVP_PKEY* pkey = key->key();
22
23 if (stores_key_) {
24 // TODO(joth): Add an abstraction for persisting OpenSSL private keys.
25 NOTIMPLEMENTED();
26 }
27
28 base::ScopedOpenSSL<NETSCAPE_SPKI, NETSCAPE_SPKI_free> spki(
29 NETSCAPE_SPKI_new());
30 ASN1_STRING_set(spki.get()->spkac->challenge,
31 challenge_.data(), challenge_.size());
32 NETSCAPE_SPKI_set_pubkey(spki.get(), pkey);
33 NETSCAPE_SPKI_sign(spki.get(), pkey, EVP_md5());
wtc 2010/12/03 19:15:44 Please add a comment to note that you're using MD5
joth 2010/12/06 18:04:20 Done.
34 char* spkistr = NETSCAPE_SPKI_b64_encode(spki.get());
35
36 std::string result(spkistr);
37 OPENSSL_free(spkistr);
38
39 return result;
15 } 40 }
16 41
17 } // namespace net 42 } // namespace net
18 43
OLDNEW
« no previous file with comments | « no previous file | net/base/keygen_handler_unittest.cc » ('j') | net/base/keygen_handler_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698