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