blob: 495f993397edf4e432b31115c2199eece43b87ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/ownership/mock_owner_key_util.h"
#include "base/files/file_path.h"
#include "crypto/rsa_private_key.h"
namespace ownership {
MockOwnerKeyUtil::MockOwnerKeyUtil() {
}
MockOwnerKeyUtil::~MockOwnerKeyUtil() {
}
bool MockOwnerKeyUtil::ImportPublicKey(std::vector<uint8>* output) {
*output = public_key_;
return !public_key_.empty();
}
#if defined(USE_NSS)
crypto::RSAPrivateKey* MockOwnerKeyUtil::FindPrivateKeyInSlot(
const std::vector<uint8>& key,
PK11SlotInfo* slot) {
return private_key_.get() ? private_key_->Copy() : NULL;
}
#endif // defined(USE_NSS)
bool MockOwnerKeyUtil::IsPublicKeyPresent() {
return !public_key_.empty();
}
void MockOwnerKeyUtil::Clear() {
public_key_.clear();
private_key_.reset();
}
void MockOwnerKeyUtil::SetPublicKey(const std::vector<uint8>& key) {
public_key_ = key;
}
void MockOwnerKeyUtil::SetPublicKeyFromPrivateKey(
const crypto::RSAPrivateKey& key) {
key.ExportPublicKey(&public_key_);
}
void MockOwnerKeyUtil::SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key) {
private_key_ = key.Pass();
private_key_->ExportPublicKey(&public_key_);
}
} // namespace ownership
|