Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.h" |
| 6 | 6 |
| 7 #include <openssl/digest.h> | 7 #include <openssl/digest.h> |
| 8 #include <openssl/evp.h> | 8 #include <openssl/evp.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.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" | 15 #include "net/ssl/openssl_client_key_store.h" |
| 16 #include "net/ssl/ssl_platform_key_task_runner.h" | |
| 16 #include "net/ssl/ssl_private_key.h" | 17 #include "net/ssl/ssl_private_key.h" |
| 17 #include "net/ssl/threaded_ssl_private_key.h" | 18 #include "net/ssl/threaded_ssl_private_key.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 class SSLPlatformKeyAndroid : public ThreadedSSLPrivateKey::Delegate { | 24 class SSLPlatformKeyAndroid : public ThreadedSSLPrivateKey::Delegate { |
| 24 public: | 25 public: |
| 25 SSLPlatformKeyAndroid(crypto::ScopedEVP_PKEY key, SSLPrivateKey::Type type) | 26 SSLPlatformKeyAndroid(crypto::ScopedEVP_PKEY key, SSLPrivateKey::Type type) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 crypto::ScopedEVP_PKEY key_; | 103 crypto::ScopedEVP_PKEY key_; |
| 103 SSLPrivateKey::Type type_; | 104 SSLPrivateKey::Type type_; |
| 104 | 105 |
| 105 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyAndroid); | 106 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyAndroid); |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 } // namespace | 109 } // namespace |
| 109 | 110 |
| 110 scoped_ptr<SSLPrivateKey> FetchClientCertPrivateKey( | 111 #if false |
|
davidben
2015/11/04 17:03:01
Try bots are unhappy. I think you want to keep thi
| |
| 111 X509Certificate* certificate, | 112 scoped_refptr<SSLPrivateKey> WrapOpenSSLPrivateKey(crypto::ScopedEVP_PKEY key) { |
| 112 scoped_refptr<base::SequencedTaskRunner> task_runner) { | |
| 113 crypto::ScopedEVP_PKEY key = | |
| 114 OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey( | |
| 115 certificate); | |
| 116 if (!key) | 113 if (!key) |
| 117 return nullptr; | 114 return nullptr; |
| 118 | 115 |
| 119 SSLPrivateKey::Type type; | 116 SSLPrivateKey::Type type; |
| 120 switch (EVP_PKEY_id(key.get())) { | 117 switch (EVP_PKEY_id(key.get())) { |
| 121 case EVP_PKEY_RSA: | 118 case EVP_PKEY_RSA: |
| 122 type = SSLPrivateKey::Type::RSA; | 119 type = SSLPrivateKey::Type::RSA; |
| 123 break; | 120 break; |
| 124 case EVP_PKEY_EC: | 121 case EVP_PKEY_EC: |
| 125 type = SSLPrivateKey::Type::ECDSA; | 122 type = SSLPrivateKey::Type::ECDSA; |
| 126 break; | 123 break; |
| 127 default: | 124 default: |
| 128 LOG(ERROR) << "Unknown key type: " << EVP_PKEY_id(key.get()); | 125 LOG(ERROR) << "Unknown key type: " << EVP_PKEY_id(key.get()); |
| 129 return nullptr; | 126 return nullptr; |
| 130 } | 127 } |
| 131 return make_scoped_ptr(new ThreadedSSLPrivateKey( | 128 return make_scoped_refptr(new ThreadedSSLPrivateKey( |
| 132 make_scoped_ptr(new SSLPlatformKeyAndroid(key.Pass(), type)), | 129 make_scoped_ptr(new SSLPlatformKeyAndroid(key.Pass(), type)), |
| 133 task_runner.Pass())); | 130 GetSSLPlatformKeyTaskRunner())); |
| 131 } | |
| 132 #endif | |
| 133 | |
| 134 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( | |
| 135 X509Certificate* certificate) { | |
| 136 crypto::ScopedEVP_PKEY key = | |
| 137 OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey( | |
| 138 certificate); | |
| 139 return WrapOpenSSLPrivateKey(key.Pass()); | |
| 134 } | 140 } |
| 135 | 141 |
| 136 } // namespace net | 142 } // namespace net |
| OLD | NEW |