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

Side by Side Diff: net/test/cert_test_util_nss.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 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
« no previous file with comments | « net/ssl/threaded_ssl_private_key.h ('k') | net/test/ct_test_util.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/test/cert_test_util.h" 5 #include "net/test/cert_test_util.h"
6 6
7 #include <pk11pub.h> 7 #include <pk11pub.h>
8 #include <secmodt.h> 8 #include <secmodt.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "crypto/nss_key_util.h" 12 #include "crypto/nss_key_util.h"
13 #include "crypto/nss_util.h" 13 #include "crypto/nss_util.h"
14 #include "crypto/scoped_nss_types.h" 14 #include "crypto/scoped_nss_types.h"
15 #include "net/cert/cert_type.h" 15 #include "net/cert/cert_type.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 bool ImportSensitiveKeyFromFile(const base::FilePath& dir, 19 bool ImportSensitiveKeyFromFile(const base::FilePath& dir,
20 const std::string& key_filename, 20 const std::string& key_filename,
21 PK11SlotInfo* slot) { 21 PK11SlotInfo* slot) {
22 base::FilePath key_path = dir.AppendASCII(key_filename); 22 base::FilePath key_path = dir.AppendASCII(key_filename);
23 std::string key_pkcs8; 23 std::string key_pkcs8;
24 bool success = base::ReadFileToString(key_path, &key_pkcs8); 24 bool success = base::ReadFileToString(key_path, &key_pkcs8);
25 if (!success) { 25 if (!success) {
26 LOG(ERROR) << "Failed to read file " << key_path.value(); 26 LOG(ERROR) << "Failed to read file " << key_path.value();
27 return false; 27 return false;
28 } 28 }
29 29
30 const uint8* key_pkcs8_begin = 30 const uint8_t* key_pkcs8_begin =
31 reinterpret_cast<const uint8*>(key_pkcs8.data()); 31 reinterpret_cast<const uint8_t*>(key_pkcs8.data());
32 std::vector<uint8> key_vector(key_pkcs8_begin, 32 std::vector<uint8_t> key_vector(key_pkcs8_begin,
33 key_pkcs8_begin + key_pkcs8.length()); 33 key_pkcs8_begin + key_pkcs8.length());
34 34
35 crypto::ScopedSECKEYPrivateKey private_key( 35 crypto::ScopedSECKEYPrivateKey private_key(
36 crypto::ImportNSSKeyFromPrivateKeyInfo(slot, key_vector, 36 crypto::ImportNSSKeyFromPrivateKeyInfo(slot, key_vector,
37 true /* permanent */)); 37 true /* permanent */));
38 LOG_IF(ERROR, !private_key) << "Could not create key from file " 38 LOG_IF(ERROR, !private_key) << "Could not create key from file "
39 << key_path.value(); 39 << key_path.value();
40 return private_key; 40 return private_key;
41 } 41 }
42 42
43 bool ImportClientCertToSlot(const scoped_refptr<X509Certificate>& cert, 43 bool ImportClientCertToSlot(const scoped_refptr<X509Certificate>& cert,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (!ImportClientCertToSlot(cert, slot)) 78 if (!ImportClientCertToSlot(cert, slot))
79 return NULL; 79 return NULL;
80 80
81 // |cert| continues to point to the original X509Certificate before the 81 // |cert| continues to point to the original X509Certificate before the
82 // import to |slot|. However this should not make a difference as NSS handles 82 // import to |slot|. However this should not make a difference as NSS handles
83 // state globally. 83 // state globally.
84 return cert; 84 return cert;
85 } 85 }
86 86
87 } // namespace net 87 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/threaded_ssl_private_key.h ('k') | net/test/ct_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698