blob: 7fc2e99f888515b91037fcebb8948dfdd032ed04 [file] [log] [blame]
Shawn Willdenc67a8aa2017-12-03 17:51:29 -07001/*
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
21#include <keystore/keymaster_tags.h>
22#include <keystore/keymaster_types.h>
23
24namespace keystore {
25
26/**
27 * Keymaster abstracts the underlying Keymaster device. It will always inherit from the latest
28 * keymaster HAL interface, and there will be one subclass which is a trivial passthrough, for
29 * devices that actually support the latest version. One or more additional subclasses will handle
30 * wrapping older HAL versions, if needed.
31 *
32 * The reason for adding this additional layer, rather than simply using the latest HAL directly and
33 * subclassing it to wrap any older HAL, is because this provides a place to put additional
34 * methods which keystore can use when it needs to distinguish between different underlying HAL
35 * versions, while still having to use only the latest interface.
36 */
37class Keymaster : public keymaster::IKeymasterDevice {
38 public:
39 virtual ~Keymaster() {}
40
41 struct VersionResult {
42 ErrorCode error;
43 uint8_t majorVersion;
44 bool isSecure;
45 bool supportsEc;
46 };
47
48 virtual VersionResult halVersion() = 0;
49};
50
51} // namespace keystore
52
53#endif // SYSTEM_SECURITY_KEYSTORE_KEYMASTER_DEVICE_H_