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

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

Issue 5594009: Adds first cut implementation of a private key store abstraction for openssl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wtc comment from http://codereview.chromium.org/5592003/ 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 | « net/base/cert_database_openssl.cc ('k') | net/base/openssl_memory_private_key_store.cc » ('j') | no next file with comments »
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> 7 #include <openssl/ssl.h>
8 8
9 #include "base/crypto/rsa_private_key.h" 9 #include "base/crypto/rsa_private_key.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/openssl_util.h" 11 #include "base/openssl_util.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "net/base/openssl_private_key_store.h"
13 14
14 namespace net { 15 namespace net {
15 16
16 std::string KeygenHandler::GenKeyAndSignChallenge() { 17 std::string KeygenHandler::GenKeyAndSignChallenge() {
17 scoped_ptr<base::RSAPrivateKey> key( 18 scoped_ptr<base::RSAPrivateKey> key(
18 base::RSAPrivateKey::Create(key_size_in_bits_)); 19 base::RSAPrivateKey::Create(key_size_in_bits_));
19 EVP_PKEY* pkey = key->key(); 20 EVP_PKEY* pkey = key->key();
20 21
21 if (stores_key_) { 22 if (stores_key_)
22 // TODO(joth): Add an abstraction for persisting OpenSSL private keys. 23 OpenSSLPrivateKeyStore::GetInstance()->StorePrivateKey(url_, pkey);
23 // See http://crbug.com/64917
24 NOTIMPLEMENTED();
25 }
26 24
27 base::ScopedOpenSSL<NETSCAPE_SPKI, NETSCAPE_SPKI_free> spki( 25 base::ScopedOpenSSL<NETSCAPE_SPKI, NETSCAPE_SPKI_free> spki(
28 NETSCAPE_SPKI_new()); 26 NETSCAPE_SPKI_new());
29 ASN1_STRING_set(spki.get()->spkac->challenge, 27 ASN1_STRING_set(spki.get()->spkac->challenge,
30 challenge_.data(), challenge_.size()); 28 challenge_.data(), challenge_.size());
31 NETSCAPE_SPKI_set_pubkey(spki.get(), pkey); 29 NETSCAPE_SPKI_set_pubkey(spki.get(), pkey);
32 // Using MD5 as this is what is required in HTML5, even though the SPKI 30 // Using MD5 as this is what is required in HTML5, even though the SPKI
33 // structure does allow the use of a SHA-1 signature. 31 // structure does allow the use of a SHA-1 signature.
34 NETSCAPE_SPKI_sign(spki.get(), pkey, EVP_md5()); 32 NETSCAPE_SPKI_sign(spki.get(), pkey, EVP_md5());
35 char* spkistr = NETSCAPE_SPKI_b64_encode(spki.get()); 33 char* spkistr = NETSCAPE_SPKI_b64_encode(spki.get());
36 34
37 std::string result(spkistr); 35 std::string result(spkistr);
38 OPENSSL_free(spkistr); 36 OPENSSL_free(spkistr);
39 37
40 return result; 38 return result;
41 } 39 }
42 40
43 } // namespace net 41 } // namespace net
44 42
OLDNEW
« no previous file with comments | « net/base/cert_database_openssl.cc ('k') | net/base/openssl_memory_private_key_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698