Shawn Willden | c67a8aa | 2017-12-03 17:51:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2017, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #ifndef SYSTEM_SECURITY_KEYSTORE_KEYMASTER__H_ |
| 19 | #define SYSTEM_SECURITY_KEYSTORE_KEYMASTER__H_ |
| 20 | |
Shawn Willden | c67a8aa | 2017-12-03 17:51:29 -0700 | [diff] [blame] | 21 | #include <keystore/keymaster_types.h> |
| 22 | |
| 23 | namespace keystore { |
| 24 | |
| 25 | /** |
| 26 | * Keymaster abstracts the underlying Keymaster device. It will always inherit from the latest |
| 27 | * keymaster HAL interface, and there will be one subclass which is a trivial passthrough, for |
| 28 | * devices that actually support the latest version. One or more additional subclasses will handle |
| 29 | * wrapping older HAL versions, if needed. |
| 30 | * |
| 31 | * The reason for adding this additional layer, rather than simply using the latest HAL directly and |
| 32 | * subclassing it to wrap any older HAL, is because this provides a place to put additional |
| 33 | * methods which keystore can use when it needs to distinguish between different underlying HAL |
| 34 | * versions, while still having to use only the latest interface. |
| 35 | */ |
| 36 | class Keymaster : public keymaster::IKeymasterDevice { |
| 37 | public: |
| 38 | virtual ~Keymaster() {} |
| 39 | |
| 40 | struct VersionResult { |
| 41 | ErrorCode error; |
| 42 | uint8_t majorVersion; |
| 43 | bool isSecure; |
| 44 | bool supportsEc; |
| 45 | }; |
| 46 | |
| 47 | virtual VersionResult halVersion() = 0; |
| 48 | }; |
| 49 | |
| 50 | } // namespace keystore |
| 51 | |
| 52 | #endif // SYSTEM_SECURITY_KEYSTORE_KEYMASTER_DEVICE_H_ |