• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #pragma once
18 
19 #include <keymaster/key_factory.h>
20 
21 namespace keymaster {
22 
23 class KeymasterContext;
24 
25 /**
26  * Abstract base for KeyFactories that handle asymmetric keys.
27  */
28 class AsymmetricKey;
29 class AsymmetricKeyFactory : public KeyFactory {
30   public:
AsymmetricKeyFactory(const KeymasterContext & context)31     explicit AsymmetricKeyFactory(const KeymasterContext& context) : context_(context) {}
32     keymaster_error_t LoadKey(KeymasterKeyBlob&& key_material,
33                               const AuthorizationSet& additional_params,
34                               AuthorizationSet&& hw_enforced,  //
35                               AuthorizationSet&& sw_enforced,  //
36                               UniquePtr<Key>* key) const override;
37 
38     virtual keymaster_error_t CreateEmptyKey(AuthorizationSet&& hw_enforced,
39                                              AuthorizationSet&& sw_enforced,
40                                              UniquePtr<AsymmetricKey>* key) const = 0;
41 
42     virtual keymaster_algorithm_t keymaster_key_type() const = 0;
43 
44     virtual const keymaster_key_format_t*
45     SupportedImportFormats(size_t* format_count) const override;
46     virtual const keymaster_key_format_t*
47     SupportedExportFormats(size_t* format_count) const override;
48 
49   protected:
50     const KeymasterContext& context_;
51 };
52 
53 }  // namespace keymaster
54