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

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

Issue 494093002: OwnerKeyUtil is moved to components/ownership. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed GYP file. Created 6 years, 3 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 | « components/ownership/mock_owner_key_util.h ('k') | components/ownership/owner_key_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 (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 "chrome/browser/chromeos/settings/mock_owner_key_util.h" 5 #include "components/ownership/mock_owner_key_util.h"
6 6
7 #include "base/files/file_path.h"
7 #include "crypto/rsa_private_key.h" 8 #include "crypto/rsa_private_key.h"
8 9
9 namespace chromeos { 10 namespace ownership {
10 11
11 MockOwnerKeyUtil::MockOwnerKeyUtil() {} 12 MockOwnerKeyUtil::MockOwnerKeyUtil() {
13 }
12 14
13 MockOwnerKeyUtil::~MockOwnerKeyUtil() {} 15 MockOwnerKeyUtil::~MockOwnerKeyUtil() {
16 }
14 17
15 bool MockOwnerKeyUtil::ImportPublicKey(std::vector<uint8>* output) { 18 bool MockOwnerKeyUtil::ImportPublicKey(std::vector<uint8>* output) {
16 *output = public_key_; 19 *output = public_key_;
17 return !public_key_.empty(); 20 return !public_key_.empty();
18 } 21 }
19 22
23 #if defined(USE_NSS)
20 crypto::RSAPrivateKey* MockOwnerKeyUtil::FindPrivateKeyInSlot( 24 crypto::RSAPrivateKey* MockOwnerKeyUtil::FindPrivateKeyInSlot(
21 const std::vector<uint8>& key, 25 const std::vector<uint8>& key,
22 PK11SlotInfo* slot) { 26 PK11SlotInfo* slot) {
23 return private_key_.get() ? private_key_->Copy() : NULL; 27 return private_key_.get() ? private_key_->Copy() : NULL;
24 } 28 }
29 #endif // defined(USE_NSS)
25 30
26 bool MockOwnerKeyUtil::IsPublicKeyPresent() { 31 bool MockOwnerKeyUtil::IsPublicKeyPresent() {
27 return !public_key_.empty(); 32 return !public_key_.empty();
28 } 33 }
29 34
30 void MockOwnerKeyUtil::Clear() { 35 void MockOwnerKeyUtil::Clear() {
31 public_key_.clear(); 36 public_key_.clear();
32 private_key_.reset(); 37 private_key_.reset();
33 } 38 }
34 39
35 void MockOwnerKeyUtil::SetPublicKey(const std::vector<uint8>& key) { 40 void MockOwnerKeyUtil::SetPublicKey(const std::vector<uint8>& key) {
36 public_key_ = key; 41 public_key_ = key;
37 } 42 }
38 43
39 void MockOwnerKeyUtil::SetPublicKeyFromPrivateKey( 44 void MockOwnerKeyUtil::SetPublicKeyFromPrivateKey(
40 const crypto::RSAPrivateKey& key) { 45 const crypto::RSAPrivateKey& key) {
41 key.ExportPublicKey(&public_key_); 46 key.ExportPublicKey(&public_key_);
42 } 47 }
43 48
44 void MockOwnerKeyUtil::SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key) { 49 void MockOwnerKeyUtil::SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key) {
45 private_key_ = key.Pass(); 50 private_key_ = key.Pass();
46 private_key_->ExportPublicKey(&public_key_); 51 private_key_->ExportPublicKey(&public_key_);
47 } 52 }
48 53
49 } // namespace chromeos 54 } // namespace ownership
OLDNEW
« no previous file with comments | « components/ownership/mock_owner_key_util.h ('k') | components/ownership/owner_key_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698