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

Side by Side Diff: components/ownership/owner_key_util_impl.cc

Issue 1461703009: Switch //components from vector_as_array to vector::data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: eroman comment Created 5 years, 1 month 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
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 "components/ownership/owner_key_util_impl.h" 5 #include "components/ownership/owner_key_util_impl.h"
6 6
7 #include <keythi.h> 7 #include <keythi.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 29 matching lines...) Expand all
40 40
41 output->resize(safe_file_size); 41 output->resize(safe_file_size);
42 42
43 if (safe_file_size == 0) { 43 if (safe_file_size == 0) {
44 LOG(WARNING) << "Public key file is empty. This seems wrong."; 44 LOG(WARNING) << "Public key file is empty. This seems wrong.";
45 return false; 45 return false;
46 } 46 }
47 47
48 // Get the key data off of disk 48 // Get the key data off of disk
49 int data_read = 49 int data_read =
50 base::ReadFile(public_key_file_, 50 base::ReadFile(public_key_file_, reinterpret_cast<char*>(output->data()),
51 reinterpret_cast<char*>(vector_as_array(output)),
52 safe_file_size); 51 safe_file_size);
53 return data_read == safe_file_size; 52 return data_read == safe_file_size;
54 } 53 }
55 54
56 crypto::ScopedSECKEYPrivateKey OwnerKeyUtilImpl::FindPrivateKeyInSlot( 55 crypto::ScopedSECKEYPrivateKey OwnerKeyUtilImpl::FindPrivateKeyInSlot(
57 const std::vector<uint8>& key, 56 const std::vector<uint8>& key,
58 PK11SlotInfo* slot) { 57 PK11SlotInfo* slot) {
59 if (!slot) 58 if (!slot)
60 return nullptr; 59 return nullptr;
61 60
62 crypto::ScopedSECKEYPrivateKey private_key( 61 crypto::ScopedSECKEYPrivateKey private_key(
63 crypto::FindNSSKeyFromPublicKeyInfoInSlot(key, slot)); 62 crypto::FindNSSKeyFromPublicKeyInfoInSlot(key, slot));
64 if (!private_key || SECKEY_GetPrivateKeyType(private_key.get()) != rsaKey) 63 if (!private_key || SECKEY_GetPrivateKeyType(private_key.get()) != rsaKey)
65 return nullptr; 64 return nullptr;
66 return private_key.Pass(); 65 return private_key.Pass();
67 } 66 }
68 67
69 bool OwnerKeyUtilImpl::IsPublicKeyPresent() { 68 bool OwnerKeyUtilImpl::IsPublicKeyPresent() {
70 return base::PathExists(public_key_file_); 69 return base::PathExists(public_key_file_);
71 } 70 }
72 71
73 } // namespace ownership 72 } // namespace ownership
OLDNEW
« no previous file with comments | « components/ownership/owner_key_util.h ('k') | components/ownership/owner_key_util_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698