Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 1 | /* |
| 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 Willden | 301646f | 2014-08-08 21:44:10 -0600 | [diff] [blame] | 17 | #ifndef SYSTEM_KEYMASTER_GOOGLE_SOFT_KEYMASTER_H_ |
| 18 | #define SYSTEM_KEYMASTER_GOOGLE_SOFT_KEYMASTER_H_ |
Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 19 | |
Shawn Willden | 98d9b92 | 2014-08-26 08:14:10 -0600 | [diff] [blame] | 20 | #include <keymaster/google_keymaster.h> |
Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 21 | |
| 22 | namespace keymaster { |
| 23 | |
| 24 | class GoogleSoftKeymaster : public GoogleKeymaster { |
| 25 | public: |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame] | 26 | GoogleSoftKeymaster(size_t operation_table_size, Logger* logger) |
| 27 | : GoogleKeymaster(operation_table_size, logger) { |
| 28 | 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; |
Shawn Willden | 1615f2e | 2014-08-13 10:37:40 -0600 | [diff] [blame] | 31 | } |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame] | 32 | bool is_enforced(keymaster_tag_t /* tag */) { return false; } |
| 33 | keymaster_key_origin_t origin() { return KM_ORIGIN_SOFTWARE; } |
Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 34 | |
| 35 | private: |
| 36 | static uint8_t master_key_[]; |
| 37 | |
Shawn Willden | 4db3fbd | 2014-08-08 22:13:44 -0600 | [diff] [blame] | 38 | keymaster_key_blob_t MasterKey() { |
| 39 | keymaster_key_blob_t blob; |
| 40 | blob.key_material = master_key_; |
| 41 | blob.key_material_size = 16; |
| 42 | return blob; |
| 43 | } |
Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 44 | |
Shawn Willden | 4db3fbd | 2014-08-08 22:13:44 -0600 | [diff] [blame] | 45 | void GenerateNonce(uint8_t* nonce, size_t length) { |
Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 46 | for (size_t i = 0; i < length; ++i) |
| 47 | nonce[i] = 0; |
| 48 | } |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 49 | |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame] | 50 | keymaster_key_param_t RootOfTrustTag() { return root_of_trust; } |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 51 | |
| 52 | keymaster_key_param_t root_of_trust; |
Shawn Willden | 128ffe0 | 2014-08-06 12:31:33 -0600 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | uint8_t GoogleSoftKeymaster::master_key_[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 56 | |
| 57 | } // namespace |
| 58 | |
Shawn Willden | 301646f | 2014-08-08 21:44:10 -0600 | [diff] [blame] | 59 | #endif // SYSTEM_KEYMASTER_GOOGLE_SOFT_KEYMASTER_H_ |