1 /*
2  * Copyright 2015 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_ASYMMETRIC_KEY_FACTORY_H_
18 #define SYSTEM_KEYMASTER_ASYMMETRIC_KEY_FACTORY_H_
19 
20 #include <keymaster/key_factory.h>
21 
22 namespace keymaster {
23 
24 /**
25  * Abstract base for KeyFactories that handle asymmetric keys.
26  */
27 class AsymmetricKey;
28 class AsymmetricKeyFactory : public KeyFactory {
29   public:
30     keymaster_error_t LoadKey(KeymasterKeyBlob&& key_material,
31                               const AuthorizationSet& additional_params,
32                               AuthorizationSet&& hw_enforced,
33                               AuthorizationSet&& sw_enforced,
34                               UniquePtr<Key>* key) const override;
35 
36     virtual keymaster_error_t CreateEmptyKey(AuthorizationSet&& hw_enforced,
37                                              AuthorizationSet&& sw_enforced,
38                                              UniquePtr<AsymmetricKey>* key) const = 0;
39 
40     virtual keymaster_algorithm_t keymaster_key_type() const = 0;
41     virtual int evp_key_type() const = 0;
42 
43     virtual const keymaster_key_format_t* SupportedImportFormats(size_t* format_count) const override;
44     virtual const keymaster_key_format_t* SupportedExportFormats(size_t* format_count) const override;
45 };
46 
47 }  // namespace keymaster
48 
49 #endif  // SYSTEM_KEYMASTER_ASYMMETRIC_KEY_FACTORY_H_
50