• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PIN_AUTH_H
17 #define PIN_AUTH_H
18 
19 #include <cstdint>
20 #include <vector>
21 
22 #include "nocopyable.h"
23 
24 namespace OHOS {
25 namespace UserIAM {
26 namespace PinAuth {
27 struct PinCredentialInfo {
28     uint64_t subType;
29     uint8_t remainTimes;
30     uint64_t freezingTime;
31 };
32 
33 class PinAuth {
34 public:
35     DISALLOW_COPY_AND_MOVE(PinAuth);
36     explicit PinAuth();
37     ~PinAuth() = default;
38     int32_t Init();
39     int32_t Close();
40     int32_t EnrollPin(uint64_t scheduleId, uint64_t subType, std::vector<uint8_t> &salt,
41         std::vector<uint8_t> &pinData, std::vector<uint8_t> &result);
42     int32_t GetSalt(uint64_t templateId, std::vector<uint8_t> &salt);
43     int32_t AuthPin(uint64_t scheduleId, uint64_t templateId, std::vector<uint8_t> &pinData,
44         std::vector<uint8_t> &result);
45     int32_t QueryPinInfo(uint64_t templateId, PinCredentialInfo &pinCredentialInfoRet);
46     int32_t DeleteTemplate(uint64_t templateId);
47     int32_t GetExecutorInfo(std::vector<uint8_t> &pubKey, uint32_t &esl, uint64_t &authAbility);
48     int32_t VerifyTemplateData(std::vector<uint64_t> templateIdList);
49 
50 private:
51     int32_t PinResultToCoAuthResult(int resultCode);
52 };
53 } // namespace PinAuth
54 } // namespace UserIAM
55 } // namespace OHOS
56 #endif // PIN_AUTH_H
57