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

Side by Side Diff: net/ssl/ssl_platform_key_android.cc

Issue 1304143010: Plumbing SSLPrivateKey Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix rebase. Created 4 years, 10 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
« no previous file with comments | « net/ssl/ssl_platform_key_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ssl/ssl_platform_key.h" 5 #include "net/ssl/ssl_platform_key_android.h"
6 6
7 #include <openssl/digest.h> 7 #include <openssl/digest.h>
8 #include <openssl/evp.h> 8 #include <openssl/evp.h>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "crypto/scoped_openssl_types.h" 13 #include "crypto/scoped_openssl_types.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/ssl/openssl_client_key_store.h"
16 #include "net/ssl/ssl_platform_key_task_runner.h" 15 #include "net/ssl/ssl_platform_key_task_runner.h"
17 #include "net/ssl/ssl_private_key.h" 16 #include "net/ssl/ssl_private_key.h"
18 #include "net/ssl/threaded_ssl_private_key.h" 17 #include "net/ssl/threaded_ssl_private_key.h"
19 18
20 namespace net { 19 namespace net {
21 20
22 namespace { 21 namespace {
23 22
24 class SSLPlatformKeyAndroid : public ThreadedSSLPrivateKey::Delegate { 23 class SSLPlatformKeyAndroid : public ThreadedSSLPrivateKey::Delegate {
25 public: 24 public:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return OK; 95 return OK;
97 } 96 }
98 97
99 private: 98 private:
100 crypto::ScopedEVP_PKEY key_; 99 crypto::ScopedEVP_PKEY key_;
101 SSLPrivateKey::Type type_; 100 SSLPrivateKey::Type type_;
102 101
103 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyAndroid); 102 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyAndroid);
104 }; 103 };
105 104
105 } // namespace
106
106 scoped_refptr<SSLPrivateKey> WrapOpenSSLPrivateKey(crypto::ScopedEVP_PKEY key) { 107 scoped_refptr<SSLPrivateKey> WrapOpenSSLPrivateKey(crypto::ScopedEVP_PKEY key) {
107 if (!key) 108 if (!key)
108 return nullptr; 109 return nullptr;
109 110
110 SSLPrivateKey::Type type; 111 SSLPrivateKey::Type type;
111 switch (EVP_PKEY_id(key.get())) { 112 switch (EVP_PKEY_id(key.get())) {
112 case EVP_PKEY_RSA: 113 case EVP_PKEY_RSA:
113 type = SSLPrivateKey::Type::RSA; 114 type = SSLPrivateKey::Type::RSA;
114 break; 115 break;
115 case EVP_PKEY_EC: 116 case EVP_PKEY_EC:
116 type = SSLPrivateKey::Type::ECDSA; 117 type = SSLPrivateKey::Type::ECDSA;
117 break; 118 break;
118 default: 119 default:
119 LOG(ERROR) << "Unknown key type: " << EVP_PKEY_id(key.get()); 120 LOG(ERROR) << "Unknown key type: " << EVP_PKEY_id(key.get());
120 return nullptr; 121 return nullptr;
121 } 122 }
122 return make_scoped_refptr(new ThreadedSSLPrivateKey( 123 return make_scoped_refptr(new ThreadedSSLPrivateKey(
123 make_scoped_ptr(new SSLPlatformKeyAndroid(std::move(key), type)), 124 make_scoped_ptr(new SSLPlatformKeyAndroid(std::move(key), type)),
124 GetSSLPlatformKeyTaskRunner())); 125 GetSSLPlatformKeyTaskRunner()));
125 } 126 }
126 127
127 } // namespace
128
129 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey(
130 X509Certificate* certificate) {
131 crypto::ScopedEVP_PKEY key =
132 OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey(
133 certificate);
134 return WrapOpenSSLPrivateKey(std::move(key));
135 }
136
137 } // namespace net 128 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/ssl_platform_key_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698