blob: 959729ef939b4ab83333a306b41f1d900a29508d [file] [log] [blame]
Shawn Willdend67afae2014-08-19 12:36:27 -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
17#ifndef SYSTEM_KEYMASTER_KEY_H_
18#define SYSTEM_KEYMASTER_KEY_H_
19
Shawn Willden06298102015-05-25 23:12:48 -060020#include <UniquePtr.h>
21
Shawn Willdenb9d584d2015-01-22 16:35:00 -070022#include <hardware/keymaster_defs.h>
Shawn Willden98d9b922014-08-26 08:14:10 -060023#include <keymaster/authorization_set.h>
Shawn Willdena278f612014-12-23 11:22:21 -070024
Shawn Willdend67afae2014-08-19 12:36:27 -060025namespace keymaster {
26
Shawn Willdend67afae2014-08-19 12:36:27 -060027class Key {
28 public:
Shawn Willdend67afae2014-08-19 12:36:27 -060029 virtual ~Key() {}
Shawn Willdend67afae2014-08-19 12:36:27 -060030
31 /**
Shawn Willdend67afae2014-08-19 12:36:27 -060032 * Return a copy of raw key material, in the specified format.
33 */
Shawn Willdenf268d742014-08-19 15:36:26 -060034 virtual keymaster_error_t formatted_key_material(keymaster_key_format_t format,
35 UniquePtr<uint8_t[]>* material,
Shawn Willdend67afae2014-08-19 12:36:27 -060036 size_t* size) const = 0;
37
38 const AuthorizationSet& authorizations() const { return authorizations_; }
39
40 protected:
Shawn Willden0cb69422015-05-26 08:31:37 -060041 Key(const AuthorizationSet& hw_enforced, const AuthorizationSet& sw_enforced,
42 keymaster_error_t* error);
Shawn Willdend67afae2014-08-19 12:36:27 -060043
44 private:
45 AuthorizationSet authorizations_;
46};
47
48} // namespace keymaster
49
50#endif // SYSTEM_KEYMASTER_KEY_H_