1 /*
2  * Copyright 2020 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 "string"
20 
21 namespace bluetooth {
22 namespace bluetooth_keystore {
23 
24 class BluetoothKeystoreCallbacks {
25 public:
26   virtual ~BluetoothKeystoreCallbacks() = default;
27 
28   /** Callback for key encrypt or remove key */
29   virtual void set_encrypt_key_or_remove_key(std::string prefix, std::string encryptedString) = 0;
30 
31   /** Callback for get key. */
32   virtual std::string get_key(std::string prefix) = 0;
33 };
34 
35 class BluetoothKeystoreInterface {
36 public:
37   virtual ~BluetoothKeystoreInterface() = default;
38 
39   /** Register the bluetooth keystore callbacks */
40   virtual void init(BluetoothKeystoreCallbacks* callbacks) = 0;
41 
42   /** Get bonded devices number to get all bonded devices key */
43   virtual void ConvertEncryptOrDecryptKeyIfNeeded() = 0;
44 
45   /** Interface for key encrypt or remove key */
46   virtual bool set_encrypt_key_or_remove_key(std::string prefix, std::string encryptedString) = 0;
47 
48   /** Interface for get key. */
49   virtual std::string get_key(std::string prefix) = 0;
50 
51   /** Interface for clear map. */
52   virtual void clear_map() = 0;
53 };
54 
55 }  // namespace bluetooth_keystore
56 }  // namespace bluetooth
57