• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021, 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/secure_key_storage.h>
20 
21 namespace keymaster {
22 
23 class PureSoftSecureStorageMap;
24 
25 /**
26  * This is the pure software emulation of secure key storage.
27  */
28 class PureSoftSecureKeyStorage : public SecureKeyStorage {
29   public:
30     explicit PureSoftSecureKeyStorage(uint32_t max_slot);
31     ~PureSoftSecureKeyStorage() override;
32 
33     /**
34      * Writes the key blob along with the keyid as the index into pure software emulated secure
35      * key storage.
36      */
37     keymaster_error_t WriteKey(const km_id_t keyid, const KeymasterKeyBlob& blob) override;
38 
39     /**
40      * Checks if the key blob with key id exists in pure software secure key storage.
41      */
42     keymaster_error_t KeyExists(const km_id_t keyid, bool* exists) override;
43 
44     /**
45      * Deletes the key blob with key id from pure software secure key storage.
46      */
47     keymaster_error_t DeleteKey(const km_id_t keyid) override;
48 
49     /**
50      * Deletes all the key blob from pure software secure key storage.
51      */
52     keymaster_error_t DeleteAllKeys() override;
53 
54     /**
55      * Checks if the pure software secure key storage still has available slot.
56      */
57     keymaster_error_t HasSlot(bool* has_slot) override;
58 
59   private:
60     PureSoftSecureStorageMap* pure_soft_secure_storage_map_;
61 };
62 
63 }  // namespace keymaster
64