1 
2 /*
3  * Copyright (c) 2024 Huawei Device Co., Ltd.
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 #include "fbex_mock.h"
18 
19 using namespace std;
20 
21 using namespace OHOS::StorageDaemon;
22 
IsFBEXSupported()23 bool FBEX::IsFBEXSupported()
24 {
25     return IFbexMoc::fbexMoc->IsFBEXSupported();
26 }
27 
InstallEL5KeyToKernel(uint32_t userIdSingle,uint32_t userIdDouble,uint8_t flag,bool & isSupport,bool & isNeedEncryptClassE)28 int FBEX::InstallEL5KeyToKernel(uint32_t userIdSingle, uint32_t userIdDouble, uint8_t flag,
29                                 bool &isSupport, bool &isNeedEncryptClassE)
30 {
31     return IFbexMoc::fbexMoc->InstallEL5KeyToKernel(userIdSingle, userIdDouble, flag, isSupport, isNeedEncryptClassE);
32 }
33 
InstallKeyToKernel(uint32_t userId,uint32_t type,uint8_t * iv,uint32_t size,uint8_t flag)34 int FBEX::InstallKeyToKernel(uint32_t userId, uint32_t type, uint8_t *iv, uint32_t size, uint8_t flag)
35 {
36     return IFbexMoc::fbexMoc->InstallKeyToKernel(userId, type, iv, size, flag);
37 }
38 
UninstallOrLockUserKeyToKernel(uint32_t userId,uint32_t type,uint8_t * iv,uint32_t size,bool destroy)39 int FBEX::UninstallOrLockUserKeyToKernel(uint32_t userId, uint32_t type, uint8_t *iv, uint32_t size, bool destroy)
40 {
41     return IFbexMoc::fbexMoc->UninstallOrLockUserKeyToKernel(userId, type, iv, size, destroy);
42 }
43 
InstallDoubleDeKeyToKernel(UserIdToFbeStr & userIdToFbe,uint8_t * iv,uint32_t size,uint8_t flag)44 int FBEX::InstallDoubleDeKeyToKernel(UserIdToFbeStr &userIdToFbe, uint8_t *iv, uint32_t size, uint8_t flag)
45 {
46     return IFbexMoc::fbexMoc->InstallDoubleDeKeyToKernel(userIdToFbe, iv, size, flag);
47 }
48 
DeleteClassEPinCode(uint32_t userIdSingle,uint32_t userIdDouble)49 int FBEX::DeleteClassEPinCode(uint32_t userIdSingle, uint32_t userIdDouble)
50 {
51     return IFbexMoc::fbexMoc->DeleteClassEPinCode(userIdSingle, userIdDouble);
52 }
53 
ChangePinCodeClassE(uint32_t userIdSingle,uint32_t userIdDouble,bool & isFbeSupport)54 int FBEX::ChangePinCodeClassE(uint32_t userIdSingle, uint32_t userIdDouble, bool &isFbeSupport)
55 {
56     return IFbexMoc::fbexMoc->ChangePinCodeClassE(userIdSingle, userIdDouble, isFbeSupport);
57 }
58 
59 // for el3 & el4
LockScreenToKernel(uint32_t userId)60 int FBEX::LockScreenToKernel(uint32_t userId)
61 {
62     return IFbexMoc::fbexMoc->LockScreenToKernel(userId);
63 }
64 
GenerateAppkey(UserIdToFbeStr & userIdToFbe,uint32_t appUid,std::unique_ptr<uint8_t[]> & appKey,uint32_t size)65 int FBEX::GenerateAppkey(UserIdToFbeStr &userIdToFbe, uint32_t appUid, std::unique_ptr<uint8_t[]> &appKey,
66                          uint32_t size)
67 {
68     return IFbexMoc::fbexMoc->GenerateAppkey(userIdToFbe, appUid, appKey, size);
69 }
70 
71 // for el5
LockUece(uint32_t userIdSingle,uint32_t userIdDouble,bool & isFbeSupport)72 int FBEX::LockUece(uint32_t userIdSingle, uint32_t userIdDouble, bool &isFbeSupport)
73 {
74     return IFbexMoc::fbexMoc->LockUece(userIdSingle, userIdDouble, isFbeSupport);
75 }
76 
UnlockScreenToKernel(uint32_t userId,uint32_t type,uint8_t * iv,uint32_t size)77 int FBEX::UnlockScreenToKernel(uint32_t userId, uint32_t type, uint8_t *iv, uint32_t size)
78 {
79     return IFbexMoc::fbexMoc->UnlockScreenToKernel(userId, type, iv, size);
80 }
81 
ReadESecretToKernel(UserIdToFbeStr & userIdToFbe,uint32_t status,std::unique_ptr<uint8_t[]> & eBuffer,uint32_t length,bool & isFbeSupport)82 int FBEX::ReadESecretToKernel(UserIdToFbeStr &userIdToFbe, uint32_t status, std::unique_ptr<uint8_t[]> &eBuffer,
83                               uint32_t length, bool &isFbeSupport)
84 {
85     return IFbexMoc::fbexMoc->ReadESecretToKernel(userIdToFbe, status, eBuffer, length, isFbeSupport);
86 }
87 
WriteESecretToKernel(UserIdToFbeStr & userIdToFbe,uint32_t status,uint8_t * eBuffer,uint32_t length)88 int FBEX::WriteESecretToKernel(UserIdToFbeStr &userIdToFbe, uint32_t status, uint8_t *eBuffer, uint32_t length)
89 {
90     return IFbexMoc::fbexMoc->WriteESecretToKernel(userIdToFbe, status, eBuffer, length);
91 }
92 
IsMspReady()93 bool FBEX::IsMspReady()
94 {
95     return IFbexMoc::fbexMoc->IsMspReady();
96 }
97 
GetStatus()98 int FBEX::GetStatus()
99 {
100     return IFbexMoc::fbexMoc->GetStatus();
101 }