Home | History | Annotate | Download | only in keymaster
      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     explicit AsymmetricKeyFactory(const KeymasterContext* context) : KeyFactory(context) {}
     31 
     32     keymaster_error_t LoadKey(const KeymasterKeyBlob& key_material,
     33                               const AuthorizationSet& additional_params,
     34                               const AuthorizationSet& hw_enforced,
     35                               const AuthorizationSet& sw_enforced,
     36                               UniquePtr<Key>* key) const override;
     37 
     38     virtual keymaster_error_t CreateEmptyKey(const AuthorizationSet& hw_enforced,
     39                                              const AuthorizationSet& sw_enforced,
     40                                              UniquePtr<AsymmetricKey>* key) const = 0;
     41 
     42     virtual keymaster_algorithm_t keymaster_key_type() const = 0;
     43     virtual int evp_key_type() const = 0;
     44 
     45     virtual const keymaster_key_format_t* SupportedImportFormats(size_t* format_count) const override;
     46     virtual const keymaster_key_format_t* SupportedExportFormats(size_t* format_count) const override;
     47 };
     48 
     49 }  // namespace keymaster
     50 
     51 #endif  // SYSTEM_KEYMASTER_ASYMMETRIC_KEY_FACTORY_H_
     52