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

Side by Side Diff: chrome/browser/chromeos/login/owner_key_utils.cc

Issue 5763006: Remove unneeded NSS headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/chromeos/login/owner_key_utils.h" 5 #include "chrome/browser/chromeos/login/owner_key_utils.h"
6 6
7 #include <keyhi.h> // SECKEY_CreateSubjectPublicKeyInfo()
8 #include <pk11pub.h>
9 #include <prerror.h> // PR_GetError()
10 #include <secder.h> // DER_Encode()
11 #include <secmod.h>
12
13 #include <limits> 7 #include <limits>
14 8
15 #include "base/crypto/rsa_private_key.h" 9 #include "base/crypto/rsa_private_key.h"
16 #include "base/crypto/signature_creator.h" 10 #include "base/crypto/signature_creator.h"
17 #include "base/crypto/signature_verifier.h" 11 #include "base/crypto/signature_verifier.h"
18 #include "base/file_path.h" 12 #include "base/file_path.h"
19 #include "base/file_util.h" 13 #include "base/file_util.h"
20 #include "base/logging.h" 14 #include "base/logging.h"
21 #include "base/nss_util.h" 15 #include "base/nss_util.h"
22 #include "base/nss_util_internal.h" 16 #include "base/nss_util_internal.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 88
95 // static 89 // static
96 const char OwnerKeyUtilsImpl::kOwnerKeyFile[] = "/var/lib/whitelist/owner.key"; 90 const char OwnerKeyUtilsImpl::kOwnerKeyFile[] = "/var/lib/whitelist/owner.key";
97 91
98 // We're generating and using 2048-bit RSA keys. 92 // We're generating and using 2048-bit RSA keys.
99 // static 93 // static
100 const uint16 OwnerKeyUtilsImpl::kKeySizeInBits = 2048; 94 const uint16 OwnerKeyUtilsImpl::kKeySizeInBits = 2048;
101 95
102 OwnerKeyUtilsImpl::OwnerKeyUtilsImpl() { 96 OwnerKeyUtilsImpl::OwnerKeyUtilsImpl() {
103 // Ensure NSS is initialized. 97 // Ensure NSS is initialized.
104 base::EnsureNSSInit(); 98 base::EnsureNSSInit();
wtc 2010/12/14 21:32:49 I suspect this base::EnsureNSSInit() call can also
Chris Masone 2010/12/14 22:21:53 That makes sense to me; I wouldn't mind if you too
105 } 99 }
106 100
107 OwnerKeyUtilsImpl::~OwnerKeyUtilsImpl() {} 101 OwnerKeyUtilsImpl::~OwnerKeyUtilsImpl() {}
108 102
109 RSAPrivateKey* OwnerKeyUtilsImpl::GenerateKeyPair() { 103 RSAPrivateKey* OwnerKeyUtilsImpl::GenerateKeyPair() {
110 return RSAPrivateKey::CreateSensitive(kKeySizeInBits); 104 return RSAPrivateKey::CreateSensitive(kKeySizeInBits);
111 } 105 }
112 106
113 bool OwnerKeyUtilsImpl::ExportPublicKeyViaDbus(RSAPrivateKey* pair, 107 bool OwnerKeyUtilsImpl::ExportPublicKeyViaDbus(RSAPrivateKey* pair,
114 LoginLibrary::Delegate* d) { 108 LoginLibrary::Delegate* d) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ok = (safe_file_size == 141 ok = (safe_file_size ==
148 file_util::WriteFile(key_file, 142 file_util::WriteFile(key_file,
149 reinterpret_cast<char*>(&to_export.front()), 143 reinterpret_cast<char*>(&to_export.front()),
150 safe_file_size)); 144 safe_file_size));
151 } 145 }
152 return ok; 146 return ok;
153 } 147 }
154 148
155 bool OwnerKeyUtilsImpl::ImportPublicKey(const FilePath& key_file, 149 bool OwnerKeyUtilsImpl::ImportPublicKey(const FilePath& key_file,
156 std::vector<uint8>* output) { 150 std::vector<uint8>* output) {
157 // Get the file size (must fit in a 32 bit int for NSS). 151 // Get the file size (must fit in a 32 bit int for NSS).
wtc 2010/12/14 21:32:49 Just wondering: is this because NSS functions use
Chris Masone 2010/12/14 22:21:53 yes
158 int64 file_size; 152 int64 file_size;
159 if (!file_util::GetFileSize(key_file, &file_size)) { 153 if (!file_util::GetFileSize(key_file, &file_size)) {
160 LOG(ERROR) << "Could not get size of " << key_file.value(); 154 LOG(ERROR) << "Could not get size of " << key_file.value();
161 return false; 155 return false;
162 } 156 }
163 if (file_size > static_cast<int64>(std::numeric_limits<int>::max())) { 157 if (file_size > static_cast<int64>(std::numeric_limits<int>::max())) {
164 LOG(ERROR) << key_file.value() << "is " 158 LOG(ERROR) << key_file.value() << "is "
165 << file_size << "bytes!!! Too big!"; 159 << file_size << "bytes!!! Too big!";
166 return false; 160 return false;
167 } 161 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 RSAPrivateKey* OwnerKeyUtilsImpl::FindPrivateKey( 199 RSAPrivateKey* OwnerKeyUtilsImpl::FindPrivateKey(
206 const std::vector<uint8>& key) { 200 const std::vector<uint8>& key) {
207 return RSAPrivateKey::FindFromPublicKeyInfo(key); 201 return RSAPrivateKey::FindFromPublicKeyInfo(key);
208 } 202 }
209 203
210 FilePath OwnerKeyUtilsImpl::GetOwnerKeyFilePath() { 204 FilePath OwnerKeyUtilsImpl::GetOwnerKeyFilePath() {
211 return FilePath(OwnerKeyUtilsImpl::kOwnerKeyFile); 205 return FilePath(OwnerKeyUtilsImpl::kOwnerKeyFile);
212 } 206 }
213 207
214 } // namespace chromeos 208 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698