| 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_android.h" | 5 #include "net/ssl/ssl_platform_key_android.h" |
| 6 | 6 |
| 7 #include <openssl/ecdsa.h> | 7 #include <openssl/ecdsa.h> |
| 8 #include <openssl/mem.h> |
| 9 #include <openssl/nid.h> |
| 8 #include <openssl/rsa.h> | 10 #include <openssl/rsa.h> |
| 9 #include <strings.h> | 11 #include <strings.h> |
| 10 | 12 |
| 11 #include <memory> | 13 #include <memory> |
| 12 #include <utility> | 14 #include <utility> |
| 13 #include <vector> | 15 #include <vector> |
| 14 | 16 |
| 15 #include "base/android/build_info.h" | 17 #include "base/android/build_info.h" |
| 16 #include "base/android/scoped_java_ref.h" | 18 #include "base/android/scoped_java_ref.h" |
| 17 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 18 #include "base/logging.h" | 20 #include "base/logging.h" |
| 19 #include "base/macros.h" | 21 #include "base/macros.h" |
| 20 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
| 21 #include "crypto/scoped_openssl_types.h" | |
| 22 #include "net/android/keystore.h" | 23 #include "net/android/keystore.h" |
| 23 #include "net/android/legacy_openssl.h" | 24 #include "net/android/legacy_openssl.h" |
| 24 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 25 #include "net/ssl/openssl_client_key_store.h" | 26 #include "net/ssl/openssl_client_key_store.h" |
| 26 #include "net/ssl/ssl_platform_key.h" | 27 #include "net/ssl/ssl_platform_key.h" |
| 27 #include "net/ssl/ssl_platform_key_task_runner.h" | 28 #include "net/ssl/ssl_platform_key_task_runner.h" |
| 28 #include "net/ssl/threaded_ssl_private_key.h" | 29 #include "net/ssl/threaded_ssl_private_key.h" |
| 29 | 30 |
| 30 using base::android::JavaRef; | 31 using base::android::JavaRef; |
| 31 using base::android::ScopedJavaGlobalRef; | 32 using base::android::ScopedJavaGlobalRef; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 95 } |
| 95 | 96 |
| 96 size_t GetMaxSignatureLengthInBytes() override { return max_length_; } | 97 size_t GetMaxSignatureLengthInBytes() override { return max_length_; } |
| 97 | 98 |
| 98 Error SignDigest(SSLPrivateKey::Hash hash, | 99 Error SignDigest(SSLPrivateKey::Hash hash, |
| 99 const base::StringPiece& input_in, | 100 const base::StringPiece& input_in, |
| 100 std::vector<uint8_t>* signature) override { | 101 std::vector<uint8_t>* signature) override { |
| 101 base::StringPiece input = input_in; | 102 base::StringPiece input = input_in; |
| 102 | 103 |
| 103 // Prepend the DigestInfo for RSA. | 104 // Prepend the DigestInfo for RSA. |
| 104 crypto::ScopedOpenSSLBytes digest_info_storage; | 105 bssl::UniquePtr<uint8_t> digest_info_storage; |
| 105 if (type_ == SSLPrivateKey::Type::RSA) { | 106 if (type_ == SSLPrivateKey::Type::RSA) { |
| 106 int hash_nid = NID_undef; | 107 int hash_nid = NID_undef; |
| 107 switch (hash) { | 108 switch (hash) { |
| 108 case SSLPrivateKey::Hash::MD5_SHA1: | 109 case SSLPrivateKey::Hash::MD5_SHA1: |
| 109 hash_nid = NID_md5_sha1; | 110 hash_nid = NID_md5_sha1; |
| 110 break; | 111 break; |
| 111 case SSLPrivateKey::Hash::SHA1: | 112 case SSLPrivateKey::Hash::SHA1: |
| 112 hash_nid = NID_sha1; | 113 hash_nid = NID_sha1; |
| 113 break; | 114 break; |
| 114 case SSLPrivateKey::Hash::SHA256: | 115 case SSLPrivateKey::Hash::SHA256: |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 std::move(delegate), GetSSLPlatformKeyTaskRunner())); | 260 std::move(delegate), GetSSLPlatformKeyTaskRunner())); |
| 260 } | 261 } |
| 261 | 262 |
| 262 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( | 263 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( |
| 263 X509Certificate* certificate) { | 264 X509Certificate* certificate) { |
| 264 return OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey( | 265 return OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey( |
| 265 certificate); | 266 certificate); |
| 266 } | 267 } |
| 267 | 268 |
| 268 } // namespace net | 269 } // namespace net |
| OLD | NEW |