Shawn Willden | d67afae | 2014-08-19 12:36:27 -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 | |
| 17 | #ifndef SYSTEM_KEYMASTER_KEY_H_ |
| 18 | #define SYSTEM_KEYMASTER_KEY_H_ |
| 19 | |
Shawn Willden | 0629810 | 2015-05-25 23:12:48 -0600 | [diff] [blame] | 20 | #include <UniquePtr.h> |
| 21 | |
Shawn Willden | b9d584d | 2015-01-22 16:35:00 -0700 | [diff] [blame] | 22 | #include <hardware/keymaster_defs.h> |
Shawn Willden | aa58329 | 2016-01-28 12:13:28 -0700 | [diff] [blame^] | 23 | |
| 24 | #include <keymaster/android_keymaster_utils.h> |
Shawn Willden | 98d9b92 | 2014-08-26 08:14:10 -0600 | [diff] [blame] | 25 | #include <keymaster/authorization_set.h> |
Shawn Willden | aa58329 | 2016-01-28 12:13:28 -0700 | [diff] [blame^] | 26 | #include <keymaster/keymaster_context.h> |
Shawn Willden | a278f61 | 2014-12-23 11:22:21 -0700 | [diff] [blame] | 27 | |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 28 | namespace keymaster { |
| 29 | |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 30 | class Key { |
| 31 | public: |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 32 | virtual ~Key() {} |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 33 | |
| 34 | /** |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 35 | * Return a copy of raw key material, in the specified format. |
| 36 | */ |
Shawn Willden | f268d74 | 2014-08-19 15:36:26 -0600 | [diff] [blame] | 37 | virtual keymaster_error_t formatted_key_material(keymaster_key_format_t format, |
| 38 | UniquePtr<uint8_t[]>* material, |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 39 | size_t* size) const = 0; |
| 40 | |
Shawn Willden | aa58329 | 2016-01-28 12:13:28 -0700 | [diff] [blame^] | 41 | /** |
| 42 | * Generate an attestation certificate chain. |
| 43 | */ |
| 44 | virtual keymaster_error_t GenerateAttestation( |
| 45 | const KeymasterContext& /* context */, const AuthorizationSet& /* attest_params */, |
| 46 | const AuthorizationSet& /* tee_enforced */, const AuthorizationSet& /* sw_enforced */, |
| 47 | keymaster_cert_chain_t* /* certificate_chain */) const { |
| 48 | return KM_ERROR_INCOMPATIBLE_ALGORITHM; |
| 49 | } |
| 50 | |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 51 | const AuthorizationSet& authorizations() const { return authorizations_; } |
| 52 | |
| 53 | protected: |
Shawn Willden | 0cb6942 | 2015-05-26 08:31:37 -0600 | [diff] [blame] | 54 | Key(const AuthorizationSet& hw_enforced, const AuthorizationSet& sw_enforced, |
| 55 | keymaster_error_t* error); |
Shawn Willden | d67afae | 2014-08-19 12:36:27 -0600 | [diff] [blame] | 56 | |
| 57 | private: |
| 58 | AuthorizationSet authorizations_; |
| 59 | }; |
| 60 | |
| 61 | } // namespace keymaster |
| 62 | |
| 63 | #endif // SYSTEM_KEYMASTER_KEY_H_ |