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

Side by Side Diff: crypto/nss_util.cc

Issue 2677583002: Fix non-noise cpplint errors in //crypto. (Closed)
Patch Set: fix p224_unittest.cc Created 3 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
« no previous file with comments | « crypto/nss_crypto_module_delegate.h ('k') | crypto/nss_util_internal.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "crypto/nss_util.h" 5 #include "crypto/nss_util.h"
6 6
7 #include <nss.h> 7 #include <nss.h>
8 #include <pk11pub.h> 8 #include <pk11pub.h>
9 #include <plarena.h> 9 #include <plarena.h>
10 #include <prerror.h> 10 #include <prerror.h>
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 ScopedPK11Slot private_slot_; 257 ScopedPK11Slot private_slot_;
258 258
259 bool private_slot_initialization_started_; 259 bool private_slot_initialization_started_;
260 260
261 typedef std::vector<base::Callback<void(ScopedPK11Slot)> > 261 typedef std::vector<base::Callback<void(ScopedPK11Slot)> >
262 SlotReadyCallbackList; 262 SlotReadyCallbackList;
263 SlotReadyCallbackList tpm_ready_callback_list_; 263 SlotReadyCallbackList tpm_ready_callback_list_;
264 }; 264 };
265 265
266 class ScopedChapsLoadFixup { 266 class ScopedChapsLoadFixup {
267 public: 267 public:
268 ScopedChapsLoadFixup(); 268 ScopedChapsLoadFixup();
269 ~ScopedChapsLoadFixup(); 269 ~ScopedChapsLoadFixup();
270 270
271 private: 271 private:
272 #if defined(COMPONENT_BUILD) 272 #if defined(COMPONENT_BUILD)
273 void *chaps_handle_; 273 void* chaps_handle_;
274 #endif 274 #endif
275 }; 275 };
276 276
277 #if defined(COMPONENT_BUILD) 277 #if defined(COMPONENT_BUILD)
278 278
279 ScopedChapsLoadFixup::ScopedChapsLoadFixup() { 279 ScopedChapsLoadFixup::ScopedChapsLoadFixup() {
280 // HACK: libchaps links the system protobuf and there are symbol conflicts 280 // HACK: libchaps links the system protobuf and there are symbol conflicts
281 // with the bundled copy. Load chaps with RTLD_DEEPBIND to workaround. 281 // with the bundled copy. Load chaps with RTLD_DEEPBIND to workaround.
282 chaps_handle_ = dlopen(kChapsPath, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND); 282 chaps_handle_ = dlopen(kChapsPath, RTLD_LOCAL | RTLD_NOW | RTLD_DEEPBIND);
283 } 283 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 361 }
362 362
363 // Note that a reference is not taken to chaps_module_. This is safe since 363 // Note that a reference is not taken to chaps_module_. This is safe since
364 // NSSInitSingleton is Leaky, so the reference it holds is never released. 364 // NSSInitSingleton is Leaky, so the reference it holds is never released.
365 std::unique_ptr<TPMModuleAndSlot> tpm_args( 365 std::unique_ptr<TPMModuleAndSlot> tpm_args(
366 new TPMModuleAndSlot(chaps_module_)); 366 new TPMModuleAndSlot(chaps_module_));
367 TPMModuleAndSlot* tpm_args_ptr = tpm_args.get(); 367 TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
368 if (base::WorkerPool::PostTaskAndReply( 368 if (base::WorkerPool::PostTaskAndReply(
369 FROM_HERE, 369 FROM_HERE,
370 base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread, 370 base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
371 system_slot_id, 371 system_slot_id, tpm_args_ptr),
372 tpm_args_ptr),
373 base::Bind(&NSSInitSingleton::OnInitializedTPMTokenAndSystemSlot, 372 base::Bind(&NSSInitSingleton::OnInitializedTPMTokenAndSystemSlot,
374 base::Unretained(this), // NSSInitSingleton is leaky 373 base::Unretained(this), // NSSInitSingleton is leaky
375 callback, 374 callback, base::Passed(&tpm_args)),
376 base::Passed(&tpm_args)), 375 true /* task_is_slow */)) {
377 true /* task_is_slow */
378 )) {
379 initializing_tpm_token_ = true; 376 initializing_tpm_token_ = true;
380 } else { 377 } else {
381 base::ThreadTaskRunnerHandle::Get()->PostTask( 378 base::ThreadTaskRunnerHandle::Get()->PostTask(
382 FROM_HERE, base::Bind(callback, false)); 379 FROM_HERE, base::Bind(callback, false));
383 } 380 }
384 } 381 }
385 382
386 static void InitializeTPMTokenOnWorkerThread(CK_SLOT_ID token_slot_id, 383 static void InitializeTPMTokenOnWorkerThread(CK_SLOT_ID token_slot_id,
387 TPMModuleAndSlot* tpm_args) { 384 TPMModuleAndSlot* tpm_args) {
388 // This tries to load the Chaps module so NSS can talk to the hardware 385 // This tries to load the Chaps module so NSS can talk to the hardware
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 if (!chaps_module_) 520 if (!chaps_module_)
524 return; 521 return;
525 522
526 // Note that a reference is not taken to chaps_module_. This is safe since 523 // Note that a reference is not taken to chaps_module_. This is safe since
527 // NSSInitSingleton is Leaky, so the reference it holds is never released. 524 // NSSInitSingleton is Leaky, so the reference it holds is never released.
528 std::unique_ptr<TPMModuleAndSlot> tpm_args( 525 std::unique_ptr<TPMModuleAndSlot> tpm_args(
529 new TPMModuleAndSlot(chaps_module_)); 526 new TPMModuleAndSlot(chaps_module_));
530 TPMModuleAndSlot* tpm_args_ptr = tpm_args.get(); 527 TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
531 base::WorkerPool::PostTaskAndReply( 528 base::WorkerPool::PostTaskAndReply(
532 FROM_HERE, 529 FROM_HERE,
533 base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread, 530 base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread, slot_id,
534 slot_id,
535 tpm_args_ptr), 531 tpm_args_ptr),
536 base::Bind(&NSSInitSingleton::OnInitializedTPMForChromeOSUser, 532 base::Bind(&NSSInitSingleton::OnInitializedTPMForChromeOSUser,
537 base::Unretained(this), // NSSInitSingleton is leaky 533 base::Unretained(this), // NSSInitSingleton is leaky
538 username_hash, 534 username_hash, base::Passed(&tpm_args)),
539 base::Passed(&tpm_args)), 535 true /* task_is_slow */);
540 true /* task_is_slow */
541 );
542 } 536 }
543 537
544 void OnInitializedTPMForChromeOSUser( 538 void OnInitializedTPMForChromeOSUser(
545 const std::string& username_hash, 539 const std::string& username_hash,
546 std::unique_ptr<TPMModuleAndSlot> tpm_args) { 540 std::unique_ptr<TPMModuleAndSlot> tpm_args) {
547 DCHECK(thread_checker_.CalledOnValidThread()); 541 DCHECK(thread_checker_.CalledOnValidThread());
548 DVLOG(2) << "Got tpm slot for " << username_hash << " " 542 DVLOG(2) << "Got tpm slot for " << username_hash << " "
549 << !!tpm_args->tpm_slot; 543 << !!tpm_args->tpm_slot;
550 chromeos_user_map_[username_hash]->SetPrivateSlot( 544 chromeos_user_map_[username_hash]->SetPrivateSlot(
551 std::move(tpm_args->tpm_slot)); 545 std::move(tpm_args->tpm_slot));
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue(); 975 return time.ToInternalValue() - base::Time::UnixEpoch().ToInternalValue();
982 } 976 }
983 977
984 #if !defined(OS_CHROMEOS) 978 #if !defined(OS_CHROMEOS)
985 PK11SlotInfo* GetPersistentNSSKeySlot() { 979 PK11SlotInfo* GetPersistentNSSKeySlot() {
986 return g_nss_singleton.Get().GetPersistentNSSKeySlot(); 980 return g_nss_singleton.Get().GetPersistentNSSKeySlot();
987 } 981 }
988 #endif 982 #endif
989 983
990 } // namespace crypto 984 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/nss_crypto_module_delegate.h ('k') | crypto/nss_util_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698