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

Side by Side Diff: net/android/keystore_unittest.cc

Issue 12294008: Fix more remaining FilePath -> base::FilePath. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/gpu/gpu_info_collector_win.cc ('k') | testing/android/native_test_launcher.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <openssl/bn.h> 5 #include <openssl/bn.h>
6 #include <openssl/dsa.h> 6 #include <openssl/dsa.h>
7 #include <openssl/ecdsa.h> 7 #include <openssl/ecdsa.h>
8 #include <openssl/err.h> 8 #include <openssl/err.h>
9 #include <openssl/evp.h> 9 #include <openssl/evp.h>
10 #include <openssl/pem.h> 10 #include <openssl/pem.h>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // pointer. 108 // pointer.
109 unsigned char* OpenSSLWriteInto(std::string* str, size_t size) { 109 unsigned char* OpenSSLWriteInto(std::string* str, size_t size) {
110 return reinterpret_cast<unsigned char*>(WriteInto(str, size + 1)); 110 return reinterpret_cast<unsigned char*>(WriteInto(str, size + 1));
111 } 111 }
112 112
113 // Load a given private key file into an EVP_PKEY. 113 // Load a given private key file into an EVP_PKEY.
114 // |filename| is the key file path. 114 // |filename| is the key file path.
115 // Returns a new EVP_PKEY on success, NULL on failure. 115 // Returns a new EVP_PKEY on success, NULL on failure.
116 EVP_PKEY* ImportPrivateKeyFile(const char* filename) { 116 EVP_PKEY* ImportPrivateKeyFile(const char* filename) {
117 // Load file in memory. 117 // Load file in memory.
118 FilePath certs_dir = GetTestCertsDirectory(); 118 base::FilePath certs_dir = GetTestCertsDirectory();
119 FilePath file_path = certs_dir.AppendASCII(filename); 119 base::FilePath file_path = certs_dir.AppendASCII(filename);
120 ScopedStdioHandle handle( 120 ScopedStdioHandle handle(
121 file_util::OpenFile(file_path, "rb")); 121 file_util::OpenFile(file_path, "rb"));
122 if (!handle.get()) { 122 if (!handle.get()) {
123 LOG(ERROR) << "Could not open private key file: " << filename; 123 LOG(ERROR) << "Could not open private key file: " << filename;
124 return NULL; 124 return NULL;
125 } 125 }
126 // Assume it is PEM_encoded. Load it as an EVP_PKEY. 126 // Assume it is PEM_encoded. Load it as an EVP_PKEY.
127 EVP_PKEY* pkey = PEM_read_PrivateKey(handle.get(), NULL, NULL, NULL); 127 EVP_PKEY* pkey = PEM_read_PrivateKey(handle.get(), NULL, NULL, NULL);
128 if (!pkey) { 128 if (!pkey) {
129 LOG(ERROR) << "Could not load public key file: " << filename 129 LOG(ERROR) << "Could not load public key file: " << filename
(...skipping 28 matching lines...) Expand all
158 std::string* pkcs8) { 158 std::string* pkcs8) {
159 ScopedEVP_PKEY pkey(ImportPrivateKeyFile(filename)); 159 ScopedEVP_PKEY pkey(ImportPrivateKeyFile(filename));
160 if (!pkey.get()) 160 if (!pkey.get())
161 return false; 161 return false;
162 return GetPrivateKeyPkcs8Bytes(pkey, pkcs8); 162 return GetPrivateKeyPkcs8Bytes(pkey, pkcs8);
163 } 163 }
164 164
165 // Same as ImportPrivateKey, but for public ones. 165 // Same as ImportPrivateKey, but for public ones.
166 EVP_PKEY* ImportPublicKeyFile(const char* filename) { 166 EVP_PKEY* ImportPublicKeyFile(const char* filename) {
167 // Load file as PEM data. 167 // Load file as PEM data.
168 FilePath certs_dir = GetTestCertsDirectory(); 168 base::FilePath certs_dir = GetTestCertsDirectory();
169 FilePath file_path = certs_dir.AppendASCII(filename); 169 base::FilePath file_path = certs_dir.AppendASCII(filename);
170 ScopedStdioHandle handle(file_util::OpenFile(file_path, "rb")); 170 ScopedStdioHandle handle(file_util::OpenFile(file_path, "rb"));
171 if (!handle.get()) { 171 if (!handle.get()) {
172 LOG(ERROR) << "Could not open public key file: " << filename; 172 LOG(ERROR) << "Could not open public key file: " << filename;
173 return NULL; 173 return NULL;
174 } 174 }
175 EVP_PKEY* pkey = PEM_read_PUBKEY(handle.get(), NULL, NULL, NULL); 175 EVP_PKEY* pkey = PEM_read_PUBKEY(handle.get(), NULL, NULL, NULL);
176 if (!pkey) { 176 if (!pkey) {
177 LOG(ERROR) << "Could not load public key file: " << filename 177 LOG(ERROR) << "Could not load public key file: " << filename
178 << ", " << GetOpenSSLErrorString(); 178 << ", " << GetOpenSSLErrorString();
179 return NULL; 179 return NULL;
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 std::string signature; 716 std::string signature;
717 DoKeySigningWithWrapper(wrapper_key.get(), 717 DoKeySigningWithWrapper(wrapper_key.get(),
718 openssl_key.get(), 718 openssl_key.get(),
719 message, 719 message,
720 &signature); 720 &signature);
721 ASSERT_TRUE(VerifyTestECDSASignature(message, signature)); 721 ASSERT_TRUE(VerifyTestECDSASignature(message, signature));
722 } 722 }
723 723
724 } // namespace android 724 } // namespace android
725 } // namespace net 725 } // namespace net
OLDNEW
« no previous file with comments | « content/gpu/gpu_info_collector_win.cc ('k') | testing/android/native_test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698