blob: 5d9185d159a8267ca131e1d17db1b03fd43fc2bd [file] [log] [blame]
Shawn Willden128ffe02014-08-06 12:31:33 -06001/*
2 * Copyright 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Shawn Willden301646f2014-08-08 21:44:10 -060017#ifndef SYSTEM_KEYMASTER_GOOGLE_SOFT_KEYMASTER_H_
18#define SYSTEM_KEYMASTER_GOOGLE_SOFT_KEYMASTER_H_
Shawn Willden128ffe02014-08-06 12:31:33 -060019
20#include "google_keymaster.h"
21
22namespace keymaster {
23
24class GoogleSoftKeymaster : public GoogleKeymaster {
25 public:
Shawn Willden2f3be362014-08-25 11:31:39 -060026 GoogleSoftKeymaster(size_t operation_table_size)
27 : GoogleKeymaster(operation_table_size, new Logger) {
Shawn Willden76364712014-08-11 17:48:04 -060028 root_of_trust.tag = KM_TAG_ROOT_OF_TRUST;
29 root_of_trust.blob.data = reinterpret_cast<const uint8_t*>("SW");
30 root_of_trust.blob.data_length = 2;
31 }
Shawn Willden2f3be362014-08-25 11:31:39 -060032 GoogleSoftKeymaster(size_t operation_table_size, Logger* logger)
33 : GoogleKeymaster(operation_table_size, logger) {
34 root_of_trust.tag = KM_TAG_ROOT_OF_TRUST;
35 root_of_trust.blob.data = reinterpret_cast<const uint8_t*>("SW");
36 root_of_trust.blob.data_length = 2;
Shawn Willden1615f2e2014-08-13 10:37:40 -060037 }
Shawn Willden2f3be362014-08-25 11:31:39 -060038 bool is_enforced(keymaster_tag_t /* tag */) { return false; }
39 keymaster_key_origin_t origin() { return KM_ORIGIN_SOFTWARE; }
Shawn Willden128ffe02014-08-06 12:31:33 -060040
41 private:
42 static uint8_t master_key_[];
43
Shawn Willden4db3fbd2014-08-08 22:13:44 -060044 keymaster_key_blob_t MasterKey() {
45 keymaster_key_blob_t blob;
46 blob.key_material = master_key_;
47 blob.key_material_size = 16;
48 return blob;
49 }
Shawn Willden128ffe02014-08-06 12:31:33 -060050
Shawn Willden4db3fbd2014-08-08 22:13:44 -060051 void GenerateNonce(uint8_t* nonce, size_t length) {
Shawn Willden128ffe02014-08-06 12:31:33 -060052 for (size_t i = 0; i < length; ++i)
53 nonce[i] = 0;
54 }
Shawn Willden76364712014-08-11 17:48:04 -060055
Shawn Willden2f3be362014-08-25 11:31:39 -060056 keymaster_key_param_t RootOfTrustTag() { return root_of_trust; }
Shawn Willden76364712014-08-11 17:48:04 -060057
58 keymaster_key_param_t root_of_trust;
Shawn Willden128ffe02014-08-06 12:31:33 -060059};
60
61uint8_t GoogleSoftKeymaster::master_key_[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
62
63} // namespace
64
Shawn Willden301646f2014-08-08 21:44:10 -060065#endif // SYSTEM_KEYMASTER_GOOGLE_SOFT_KEYMASTER_H_