| OLD | NEW |
| 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 "components/ownership/mock_owner_key_util.h" | 5 #include "components/ownership/mock_owner_key_util.h" |
| 6 | 6 |
| 7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 void MockOwnerKeyUtil::SetPublicKey(const std::vector<uint8_t>& key) { | 46 void MockOwnerKeyUtil::SetPublicKey(const std::vector<uint8_t>& key) { |
| 47 public_key_ = key; | 47 public_key_ = key; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void MockOwnerKeyUtil::SetPublicKeyFromPrivateKey( | 50 void MockOwnerKeyUtil::SetPublicKeyFromPrivateKey( |
| 51 const crypto::RSAPrivateKey& key) { | 51 const crypto::RSAPrivateKey& key) { |
| 52 CHECK(key.ExportPublicKey(&public_key_)); | 52 CHECK(key.ExportPublicKey(&public_key_)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void MockOwnerKeyUtil::SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key) { | 55 void MockOwnerKeyUtil::SetPrivateKey( |
| 56 std::unique_ptr<crypto::RSAPrivateKey> key) { |
| 56 crypto::EnsureNSSInit(); | 57 crypto::EnsureNSSInit(); |
| 57 | 58 |
| 58 CHECK(key->ExportPublicKey(&public_key_)); | 59 CHECK(key->ExportPublicKey(&public_key_)); |
| 59 | 60 |
| 60 std::vector<uint8_t> key_exported; | 61 std::vector<uint8_t> key_exported; |
| 61 CHECK(key->ExportPrivateKey(&key_exported)); | 62 CHECK(key->ExportPrivateKey(&key_exported)); |
| 62 | 63 |
| 63 crypto::ScopedPK11Slot slot(PK11_GetInternalSlot()); | 64 crypto::ScopedPK11Slot slot(PK11_GetInternalSlot()); |
| 64 CHECK(slot); | 65 CHECK(slot); |
| 65 private_key_ = crypto::ImportNSSKeyFromPrivateKeyInfo( | 66 private_key_ = crypto::ImportNSSKeyFromPrivateKeyInfo( |
| 66 slot.get(), key_exported, false /* not permanent */); | 67 slot.get(), key_exported, false /* not permanent */); |
| 67 CHECK(private_key_); | 68 CHECK(private_key_); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace ownership | 71 } // namespace ownership |
| OLD | NEW |