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