1 /* 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_ASYMMETRIC_KEY_H 18 #define SYSTEM_KEYMASTER_ASYMMETRIC_KEY_H 19 20 #include <utility> 21 22 #include <openssl/evp.h> 23 24 #include <keymaster/key.h> 25 #include <keymaster/km_openssl/openssl_utils.h> 26 27 namespace keymaster { 28 29 class AsymmetricKey : public Key { 30 public: AsymmetricKey(AuthorizationSet && hw_enforced,AuthorizationSet && sw_enforced,const KeyFactory * key_factory)31 AsymmetricKey(AuthorizationSet&& hw_enforced, AuthorizationSet&& sw_enforced, 32 const KeyFactory* key_factory) 33 : Key(std::move(hw_enforced), std::move(sw_enforced), key_factory) {} ~AsymmetricKey()34 virtual ~AsymmetricKey() {} 35 36 virtual int evp_key_type() const = 0; 37 38 keymaster_error_t formatted_key_material(keymaster_key_format_t format, 39 UniquePtr<uint8_t[]>* material, 40 size_t* size) const override; 41 42 // Create an OpenSSL EVP_PKEY for the key. 43 virtual EVP_PKEY_Ptr InternalToEvp() const = 0; 44 // Set the contents from an OpenSSL EVP_PKEY. 45 virtual bool EvpToInternal(const EVP_PKEY* pkey) = 0; 46 }; 47 48 } // namespace keymaster 49 50 #endif // SYSTEM_KEYMASTER_ASYMMETRIC_KEY_H 51