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_SOFTWARE_KEY_FACTORY_H_ 18 #define SYSTEM_KEYMASTER_SOFTWARE_KEY_FACTORY_H_ 19 20 #include "key_factory.h" 21 #include <keymaster/attestation_record.h> 22 23 namespace keymaster { 24 25 class SoftwareKeyBlobMaker { 26 protected: 27 // make destructor protected so only implementers can destroy instances. ~SoftwareKeyBlobMaker()28 virtual ~SoftwareKeyBlobMaker() {} 29 30 public: 31 /** 32 * CreateKeyBlob takes authorization sets and key material and produces a key blob and hardware 33 * and software authorization lists ready to be returned to the AndroidKeymaster client 34 * (Keystore, generally). The blob must be integrity-checked and may be encrypted, depending 35 * on the needs of the context. 36 */ 37 virtual keymaster_error_t CreateKeyBlob(const AuthorizationSet& key_description, 38 keymaster_key_origin_t origin, 39 const KeymasterKeyBlob& key_material, 40 KeymasterKeyBlob* blob, AuthorizationSet* hw_enforced, 41 AuthorizationSet* sw_enforced) const = 0; 42 }; 43 44 class SoftKeyFactoryMixin { 45 public: SoftKeyFactoryMixin(const SoftwareKeyBlobMaker * blob_maker)46 explicit SoftKeyFactoryMixin(const SoftwareKeyBlobMaker* blob_maker) 47 : blob_maker_(*blob_maker) {} ~SoftKeyFactoryMixin()48 virtual ~SoftKeyFactoryMixin() {} 49 50 protected: 51 const SoftwareKeyBlobMaker& blob_maker_; 52 }; 53 54 } // namespace keymaster 55 56 #endif // SYSTEM_KEYMASTER_SOFTWARE_KEY_FACTORY_H_ 57