@@ -39,9 +39,9 @@ The identity authentication consists of User_auth and basic authentication servi
...
@@ -39,9 +39,9 @@ The identity authentication consists of User_auth and basic authentication servi
To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between User_auth and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with User_auth.
To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between User_auth and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with User_auth.
The executor uses the User_auth public key to verify scheduling instructions.
The executor uses the User_auth public key to verify scheduling instructions.
User_auth uses the executor public key to verify the authentication result accuracy and the integrity of the information exchanged with the executor.
User_auth uses the executor public key to verify the authentication result accuracy and the integrity of the information exchanged with the executor.
- Authentication credential template
- Authentication credential template
...
@@ -61,7 +61,7 @@ The identity authentication consists of User_auth and basic authentication servi
...
@@ -61,7 +61,7 @@ The identity authentication consists of User_auth and basic authentication servi
- IPC
- IPC
Inter-Process Communication (IPC) is a mechanism that allows processes to communicate with each other. For details, see [IPC](https://gitee.com/openharmony/communication_ipc/blob/master/README.md).
Inter-process communication (IPC) is a mechanism that allows processes to communicate with each other. For details, see [IPC](https://gitee.com/openharmony/communication_ipc/blob/master/README.md).
- HDI
- HDI
...
@@ -90,7 +90,7 @@ The Face_auth driver provides basic facial authentication capabilities for the U
...
@@ -90,7 +90,7 @@ The Face_auth driver provides basic facial authentication capabilities for the U
### Available APIs
### Available APIs
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/face_auth/v1_0/**.
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/face_auth/**.
**Table 1** describes the HDI APIs for face credential enrollment, authentication, recognition, and deletion. **Table 2** describes the callbacks used to return the executor operation result to the framework or return the authentication tip information to upper-layer applications.
**Table 1** describes the HDI APIs for face credential enrollment, authentication, recognition, and deletion. **Table 2** describes the callbacks used to return the executor operation result to the framework or return the authentication tip information to upper-layer applications.
...
@@ -98,23 +98,29 @@ The following table describes the C++ APIs generated from the Interface Definiti
...
@@ -98,23 +98,29 @@ The following table describes the C++ APIs generated from the Interface Definiti
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | Obtains the executor list. |
| GetExecutorList(std::vector\<sptr\<V1_0::IExecutor>>& executorList) | Obtains the executor list (version V1_0).|
| GetExecutorListV1_1(std::vector\<sptr\<V1_1::IExecutor>>& executorList) | Obtains the executor list (version V1_1). |
| GetExecutorInfo(ExecutorInfo& info) | Obtains the executor information, including the executor type, executor role, authentication type, security level, and executor public key.|
| GetExecutorInfo(ExecutorInfo& info) | Obtains the executor information, including the executor type, executor role, authentication type, security level, and executor public key.|
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about a face image template based on the specified template ID. |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about a face image template based on the specified template ID. |
| OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br> const std::vector<uint8_t>& frameworkPublicKey, const std::vector<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| OnRegisterFinish(const std::vector\<uint64_t>& templateIdList,<br> const std::vector\<uint8_t>& frameworkPublicKey, const std::vector\<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| Enroll(uint64_t scheduleId, const std::vector<uint8_t>& extraInfo,<br> const sptr<IExecutorCallback>& callbackObj) | Enrolls a face image. |
| Enroll(uint64_t scheduleId, const std::vector\<uint8_t>& extraInfo,<br> const sptr\<IExecutorCallback>& callbackObj) | Enrolls a face image template. |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the operation result. |
| IExecutorCallback::OnResult(int32_t code, const std::vector\<uint8_t>& extraInfo) | Called to return the operation result. |
| IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
| IExecutorCallback::OnTip(int32_t code, const std::vector\<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
| ISaCommandCallback::OnSaCommands(const std::vector\<SaCommand>& commands) | Called to send the command list.|
### How to Develop
### How to Develop
...
@@ -122,12 +128,12 @@ The following uses the Hi3516D V300 development board as an example to demonstra
...
@@ -122,12 +128,12 @@ The following uses the Hi3516D V300 development board as an example to demonstra
```undefined
```undefined
// drivers/peripheral/face_auth
// drivers/peripheral/face_auth
├── BUILD.gn # Build script
├── BUILD.gn # Build script
├── bundle.json # Component description file
├── bundle.json # Component description file
└── hdi_service # Face_auth driver implementation
└── hdi_service # Face_auth driver implementation
├── BUILD.gn # Build script
├── BUILD.gn # Build script
├── include # Header files
├── include # Header files
└── src # Source files
└── src # Source files
├── executor_impl.cpp # Implementation of authentication and enrollment APIs
├── executor_impl.cpp # Implementation of authentication and enrollment APIs
@@ -229,7 +235,7 @@ The development procedure is as follows:
...
@@ -229,7 +235,7 @@ The development procedure is as follows:
.Init=HdfFaceAuthInterfaceDriverInit,
.Init=HdfFaceAuthInterfaceDriverInit,
.Release=HdfFaceAuthInterfaceDriverRelease,
.Release=HdfFaceAuthInterfaceDriverRelease,
};
};
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
HDF_INIT(g_faceAuthInterfaceDriverEntry);
HDF_INIT(g_faceAuthInterfaceDriverEntry);
```
```
...
@@ -238,19 +244,19 @@ The development procedure is as follows:
...
@@ -238,19 +244,19 @@ The development procedure is as follows:
```c++
```c++
// Executor implementation class
// Executor implementation class
classExecutorImpl:publicIExecutor{
classExecutorImpl:publicV1_1::IExecutor{
public:
public:
ExecutorImpl(structExecutorInfoexecutorInfo);
ExecutorImpl(structExecutorInfoexecutorInfo);
virtual~ExecutorImpl(){}
virtual~ExecutorImpl(){}
private:
private:
structExecutorInfoexecutorInfo_;// Executor information
structExecutorInfoexecutorInfo_;// Executor information
};
};
staticconstexpruint16_tSENSOR_ID=123;// Executor sensor ID
staticconstexpruint16_tSENSOR_ID=123;// Executor sensor ID
staticconstexpruint32_tEXECUTOR_TYPE=123;// Executor type
staticconstexpruint32_tEXECUTOR_TYPE=123;// Executor type
staticconstexprsize_tPUBLIC_KEY_LEN=32;//32-byte public key of the executor
staticconstexprsize_tPUBLIC_KEY_LEN=32;//32-byte public key of the executor
3. Implement the functions of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/face_auth/hdi_service/src/executor_impl.cpp).
3. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/face_auth/hdi_service/src/executor_impl.cpp).
```c++
```c++
// Obtain the executor information.
// Obtain the executor information.
...
@@ -298,7 +315,7 @@ The development procedure is as follows:
...
@@ -298,7 +315,7 @@ The development procedure is as follows:
IAM_LOGI("Executor information got successfully");
IAM_LOGI("Executor information got successfully");
returnHDF_SUCCESS;
returnHDF_SUCCESS;
}
}
// Obtain template information based on templateId.
// Obtain template information based on templateId.
@@ -308,7 +325,7 @@ The development procedure is as follows:
...
@@ -308,7 +325,7 @@ The development procedure is as follows:
IAM_LOGI("Template information got successfully");
IAM_LOGI("Template information got successfully");
returnHDF_SUCCESS;
returnHDF_SUCCESS;
}
}
// After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
// After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
@@ -39,9 +39,9 @@ The identity authentication consists of the User_auth framework and basic authen
...
@@ -39,9 +39,9 @@ The identity authentication consists of the User_auth framework and basic authen
To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between User_auth and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with User_auth.
To ensure user data security and authentication result accuracy, measures must be taken to protect the integrity of the key information exchanged between User_auth and basic authentication services. Public keys must be exchanged when the executor provided by a basic authentication service interworks with User_auth.
The executor uses the User_auth public key to verify scheduling instructions.
The executor uses the User_auth public key to verify scheduling instructions.
User_auth uses the executor public key to verify the authentication result accuracy and the integrity of the information exchanged with the executor.
User_auth uses the executor public key to verify the authentication result accuracy and the integrity of the information exchanged with the executor.
- Authentication credential
- Authentication credential
...
@@ -61,7 +61,7 @@ The identity authentication consists of the User_auth framework and basic authen
...
@@ -61,7 +61,7 @@ The identity authentication consists of the User_auth framework and basic authen
- IPC
- IPC
Inter-Process Communication (IPC) is a mechanism that allows processes to communicate with each other. For details, see [IPC](https://gitee.com/openharmony/communication_ipc/blob/master/README.md).
Inter-process communication (IPC) is a mechanism that allows processes to communicate with each other. For details, see [IPC](https://gitee.com/openharmony/communication_ipc/blob/master/README.md).
- HDI
- HDI
...
@@ -88,30 +88,36 @@ The fingerprint_auth driver provides stable basic fingerprint authentication cap
...
@@ -88,30 +88,36 @@ The fingerprint_auth driver provides stable basic fingerprint authentication cap
### Available APIs
### Available APIs
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/fingerprint_auth/v1_0/**.
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/fingerprint_auth/**.
**Table 1** describes the HDI APIs for fingerprint credential enrollment, authentication, recognition, and deletion. **Table 2** describes the callbacks used to return the executor operation result to the framework or return the authentication tip information to upper-layer applications.
**Table 1** describes the HDI APIs for fingerprint credential enrollment, authentication, recognition, and deletion. **Table 2** describes the callbacks used to return the executor operation result to the framework or return the authentication tip information to upper-layer applications.
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | Obtains the executor list. |
| GetExecutorList(std::vector\<sptr\<V1_0::IExecutor>>& executorList) | Obtains the executor list (version V1_0).|
| GetExecutorListV1_1(std::vector\<sptr\<V1_1::IExecutor>>& executorList) | Obtains the executor list (version V1_1). |
| GetExecutorInfo(ExecutorInfo& info) | Obtains the executor information, including the executor type, executor role, authentication type, security level, and executor public key.|
| GetExecutorInfo(ExecutorInfo& info) | Obtains the executor information, including the executor type, executor role, authentication type, security level, and executor public key.|
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about the template based on the specified ID. |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about the template based on the specified ID. |
| OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br> const std::vector<uint8_t>& frameworkPublicKey, const std::vector<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| OnRegisterFinish(const std::vector\<uint64_t>& templateIdList,<br> const std::vector\<uint8_t>& frameworkPublicKey, const std::vector\<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the operation result. |
| IExecutorCallback::OnResult(int32_t code, const std::vector\<uint8_t>& extraInfo) | Called to return the operation result. |
| IExecutorCallback::OnTip(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
| IExecutorCallback::OnTip(int32_t code, const std::vector\<uint8_t>& extraInfo) | Called to return the interaction information about the operation process.|
| ISaCommandCallback::OnSaCommands(const std::vector\<SaCommand>& commands) | Called to send the command list.|
### How to Develop
### How to Develop
...
@@ -119,12 +125,12 @@ The following uses the Hi3516D V300 development board as an example to demonstra
...
@@ -119,12 +125,12 @@ The following uses the Hi3516D V300 development board as an example to demonstra
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
HDF_INIT(g_fingerprintAuthInterfaceDriverEntry);
HDF_INIT(g_fingerprintAuthInterfaceDriverEntry);
```
```
...
@@ -239,15 +245,15 @@ The development procedure is as follows:
...
@@ -239,15 +245,15 @@ The development procedure is as follows:
public:
public:
ExecutorImpl(structExecutorInfoexecutorInfo);
ExecutorImpl(structExecutorInfoexecutorInfo);
virtual~ExecutorImpl(){}
virtual~ExecutorImpl(){}
private:
private:
structExecutorInfoexecutorInfo_;// Executor information
structExecutorInfoexecutorInfo_;// Executor information
};
};
staticconstexpruint16_tSENSOR_ID=123;// Executor sensor ID
staticconstexpruint16_tSENSOR_ID=123;// Executor sensor ID
staticconstexpruint32_tEXECUTOR_TYPE=123;// Executor type
staticconstexpruint32_tEXECUTOR_TYPE=123;// Executor type
staticconstexprsize_tPUBLIC_KEY_LEN=32;//32-byte public key of the executor
staticconstexprsize_tPUBLIC_KEY_LEN=32;//32-byte public key of the executor
3. Implement functions of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/fingerprint_auth/hdi_service/src/executor_impl.cpp).<br>The sample code is as follows:
3. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/fingerprint_auth/hdi_service/src/executor_impl.cpp).<br>The sample code is as follows:
```c++
```c++
// Obtain the executor information.
// Obtain the executor information.
...
@@ -295,7 +312,7 @@ The development procedure is as follows:
...
@@ -295,7 +312,7 @@ The development procedure is as follows:
IAM_LOGI("Executor information got successfully");
IAM_LOGI("Executor information got successfully");
returnHDF_SUCCESS;
returnHDF_SUCCESS;
}
}
// Obtain template information based on templateId.
// Obtain template information based on templateId.
@@ -305,7 +322,7 @@ The development procedure is as follows:
...
@@ -305,7 +322,7 @@ The development procedure is as follows:
IAM_LOGI("Template information got successfully");
IAM_LOGI("Template information got successfully");
returnHDF_SUCCESS;
returnHDF_SUCCESS;
}
}
// After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
// After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
@@ -74,7 +74,6 @@ The Pin_auth driver provides basic PIN authentication capabilities for the upper
...
@@ -74,7 +74,6 @@ The Pin_auth driver provides basic PIN authentication capabilities for the upper
### Constraints
### Constraints
PIN authentication must be implemented in a Trusted Execution Environment (TEE), and the confidential information, such as PINs and credentials, must be encrypted and stored in a TEE.
PIN authentication must be implemented in a Trusted Execution Environment (TEE), and the confidential information, such as PINs and credentials, must be encrypted and stored in a TEE.
## Development Guidelines
## Development Guidelines
### When to Use
### When to Use
...
@@ -82,30 +81,32 @@ The Pin_auth driver provides basic PIN authentication capabilities for the User_
...
@@ -82,30 +81,32 @@ The Pin_auth driver provides basic PIN authentication capabilities for the User_
### Available APIs
### Available APIs
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/pin_auth/v1_0/**.
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/pin_auth**.
**Table 1** describes the HDI APIs for PIN credential enrollment, authentication, and deletion. **Table 2** describes the callbacks used to return the executor operation result to the framework or return the PIN entered by the user.
**Table 1** describes the HDI APIs for PIN credential enrollment, authentication, and deletion. **Table 2** describes the callbacks used to return the executor operation result to the framework or return the PIN entered by the user.
| GetExecutorList(std::vector<sptr<IExecutor>>& executorList) | Obtains the executor list.|
| GetExecutorList(std::vector\<sptr\<V1_0::IExecutor>>& executorList) | Obtains the executor list (version V1_0).|
| GetExecutorInfo(ExecutorInfo& info) | Obtains information about an executor. |
| GetExecutorListV1_1(std::vector\<sptr\<V1_1::IExecutor>>& executorList) | Obtains the executor list (version V1_1). |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about a template. |
| GetTemplateInfo(uint64_t templateId, TemplateInfo& info) | Obtains information about a template. |
| OnRegisterFinish(const std::vector<uint64_t>& templateIdList,<br>const std::vector<uint8_t>& frameworkPublicKey,<br>const std::vector<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| OnRegisterFinish(const std::vector\<uint64_t>& templateIdList,<br>const std::vector\<uint8_t>& frameworkPublicKey,<br>const std::vector\<uint8_t>& extraInfo) | Obtains the public key and template ID list from User_auth after the executor is registered successfully.|
| OnSetData(uint64_t scheduleId, uint64_t authSubType, <br>const std::vector<uint8_t> &data) | Called to return the subtype of the PIN enrolled by the user and the anonymization PIN data. |
| OnSetData(uint64_t scheduleId, uint64_t authSubType, <br>const std::vector\<uint8_t> &data) | Called to return the subtype of the PIN enrolled by the user and the anonymization PIN data. |
| IExecutorCallback::OnResult(int32_t code, const std::vector<uint8_t>& extraInfo) | Called to return the operation result.|
| IExecutorCallback::OnResult(int32_t code, const std::vector\<uint8_t>& extraInfo) | Called to return the operation result.|
| IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector<uint8_t>& salt,<br> uint64_t authSubType)| Called to return the PIN information obtained. |
| IExecutorCallback::OnGetData(uint64_t scheduleId, const std::vector\<uint8_t>& salt,<br> uint64_t authSubType)| Called to return the PIN information obtained. |
### How to Develop
### How to Develop
...
@@ -113,21 +114,21 @@ The following uses the RK3568 platform as an example to demonstrate how to devel
...
@@ -113,21 +114,21 @@ The following uses the RK3568 platform as an example to demonstrate how to devel
```text
```text
// drivers/peripheral/pin_auth
// drivers/peripheral/pin_auth
├── BUILD.gn # Build script
├── BUILD.gn # Build script
├── bundle.json # Component description file
├── bundle.json # Component description file
├── test # Test cases
├── test # Test cases
└── hdi_service # Pin_auth driver implementation
└── hdi_service # Pin_auth driver implementation
├── BUILD.gn # Build script
├── BUILD.gn # Build script
├── adaptor # Implementation of related algorithms
├── adaptor # Implementation of related algorithms
├── common # Implementation of common interfaces
├── common # Implementation of common interfaces
├── database # Database implementation
├── database # Database implementation
├── main # Entry for implementing PIN-related functions
├── main # Entry for implementing PIN-related functions
└── service # Entry for implementing the Pin_auth driver
└── service # Entry for implementing the Pin_auth driver
├── inc # Header files
├── inc # Header files
└── src # Source files
└── src # Source files
├── executor_impl.cpp # Implementation of authentication and enrollment APIs
├── executor_impl.cpp # Implementation of authentication and enrollment APIs
@@ -227,18 +228,18 @@ The development procedure is as follows:
...
@@ -227,18 +228,18 @@ The development procedure is as follows:
.Init=HdfPinAuthInterfaceDriverInit,
.Init=HdfPinAuthInterfaceDriverInit,
.Release=HdfPinAuthInterfaceDriverRelease,
.Release=HdfPinAuthInterfaceDriverRelease,
};
};
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
HDF_INIT(g_pinauthinterfaceDriverEntry);
HDF_INIT(g_pinauthinterfaceDriverEntry);
```
```
1. Obtain the executor list. For details about the code, see [pin_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_service.cpp).
1. Obtain the executor list. For details about the code, see [pin_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/pin_auth_interface_service.cpp).
1. Implement functions of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/executor_impl.cpp).
1. Implement each function of the executor. For details about the code, see [executor_impl.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/pin_auth/hdi_service/service/src/executor_impl.cpp).
```c++
```c++
// Obtain executor information (example only).
// Obtain executor information (example only).
...
@@ -330,10 +344,10 @@ The development procedure is as follows:
...
@@ -330,10 +344,10 @@ The development procedure is as follows:
@@ -354,14 +368,14 @@ The development procedure is as follows:
...
@@ -354,14 +368,14 @@ The development procedure is as follows:
IAM_LOGE("Failed to copy subType to extraInfo.");
IAM_LOGE("Failed to copy subType to extraInfo.");
returnHDF_FAILURE;
returnHDF_FAILURE;
}
}
info.executorType=EXECUTOR_TYPE;
info.executorType=EXECUTOR_TYPE;
info.remainAttempts=infoRet.remainTimes;
info.remainAttempts=infoRet.remainTimes;
info.lockoutDuration=infoRet.freezingTime;
info.lockoutDuration=infoRet.freezingTime;
returnHDF_SUCCESS;
returnHDF_SUCCESS;
}
}
// After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key obtained. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
// After the executor is successfully registered, obtain the public key and template ID list from User_auth and save the public key obtained. The executor compares its template ID list with the template ID list obtained and updates its template ID list.
@@ -109,7 +109,7 @@ The User_auth driver provides stable user credential management, authentication
...
@@ -109,7 +109,7 @@ The User_auth driver provides stable user credential management, authentication
### Available APIs
### Available APIs
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/user_auth/v1_0/**.
The following table describes the C++ APIs generated from the Interface Definition Language (IDL) interface description. For details about the interface declaration, see the .idl file in **/drivers/interface/user_auth**.
**Table 1** describes the HDI APIs for executor registration, credential enrollment and deletion, user authentication, and user identification.
**Table 1** describes the HDI APIs for executor registration, credential enrollment and deletion, user authentication, and user identification.
**Table 1** Available APIs
**Table 1** Available APIs
...
@@ -117,38 +117,40 @@ The following table describes the C++ APIs generated from the Interface Definiti
...
@@ -117,38 +117,40 @@ The following table describes the C++ APIs generated from the Interface Definiti
| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector<uint8_t>& publicKey,<br> std::vector<uint64_t>& templateIds) | Adds an executor to obtain the authentication capability. |
| AddExecutor(const ExecutorRegisterInfo& info, uint64_t& index, std::vector\<uint8_t>& publicKey,<br> std::vector\<uint64_t>& templateIds) | Adds an executor to obtain the authentication capability. |
| DeleteExecutor(uint64_t index) | Deletes an executor. |
| DeleteExecutor(uint64_t index) | Deletes an executor. |
| OpenSession(int32_t userId, std::vector<uint8_t>& challenge) | Opens a session for authentication credential management. |
| OpenSession(int32_t userId, std::vector\<uint8_t>& challenge) | Opens a session for authentication credential management. |
| CloseSession(int32_t userId) | Closes a session for authentication credential management. |
| CloseSession(int32_t userId) | Closes a session for authentication credential management. |
| BeginEnrollment(int32_t userId, const std::vector<uint8_t>& authToken, const EnrollParam& param,<br> ScheduleInfo& info) | Enrolls the user authentication credential. If a user has enrolled a PIN, the old PIN will be overwritten.|
| BeginEnrollment(int32_t userId, const std::vector\<uint8_t>& authToken, const EnrollParam& param,<br> ScheduleInfo& info) | Enrolls the user authentication credential (version V1_0). If a user has enrolled a PIN, the old PIN will be overwritten .|
| UpdateEnrollmentResult(int32_t userId, const std::vector<uint8_t>& scheduleResult, uint64_t& credentialId,<br> CredentialInfo& oldInfo) | Updates the data to complete this enrollment. |
| UpdateEnrollmentResult(int32_t userId, const std::vector\<uint8_t>& scheduleResult, uint64_t& credentialId,<br> CredentialInfo& oldInfo) | Updates the data to complete this enrollment. |
| CancelEnrollment(int32_t userId) | Cancels an enrollment operation. |
| CancelEnrollment(int32_t userId) | Cancels an enrollment operation. |
| DeleteCredential(int32_t userId, uint64_t credentialId, const std::vector<uint8_t>& authToken,<br> CredentialInfo& info) | Deletes credential information based on the specified **credentialId**. |
| DeleteCredential(int32_t userId, uint64_t credentialId, const std::vector\<uint8_t>& authToken,<br> CredentialInfo& info) | Deletes credential information based on the specified **credentialId**. |
| DeleteUser(int32_t userId, const std::vector<uint8_t>& authToken,<br> std::vector<CredentialInfo>& deletedInfos) | Deletes a user PIN from User_auth. |
| DeleteUser(int32_t userId, const std::vector\<uint8_t>& authToken,<br> std::vector\<CredentialInfo>& deletedInfos) | Deletes a user PIN from User_auth. |
| EnforceDeleteUser(int32_t userId, std::vector<CredentialInfo>& deletedInfos) | Forcibly deletes a user. This API will be called when a user is deleted from the system. |
| EnforceDeleteUser(int32_t userId, std::vector\<CredentialInfo>& deletedInfos) | Forcibly deletes a user. This API will be called when a user is deleted from the system. |
| GetCredential(int32_t userId, AuthType authType, std::vector<CredentialInfo>& infos) | Obtains user credential information by authentication type. |
| GetCredential(int32_t userId, AuthType authType, std::vector\<CredentialInfo>& infos) | Obtains user credential information by authentication type. |
| GetSecureInfo(int32_t userId, uint64_t& secureUid, std::vector<EnrolledInfo>& infos) | Obtains the secure user ID and the enrolled tag ID of each authentication type. |
| GetSecureInfo(int32_t userId, uint64_t& secureUid, std::vector\<EnrolledInfo>& infos) | Obtains the secure user ID and the enrolled tag ID of each authentication type. |
| BeginAuthentication(uint64_t contextId, const AuthSolution& param,<br> std::vector<ScheduleInfo>& scheduleInfos) | Starts an authentication to generate the authentication scheme and scheduling information. |
| BeginAuthentication(uint64_t contextId, const AuthSolution& param,<br> std::vector\<ScheduleInfo>& scheduleInfos) | Starts authentication and generates the authentication scheme and scheduling information (version V1_0). |
| UpdateAuthenticationResult(uint64_t contextId, const std::vector<uint8_t>& scheduleResult,<br> AuthResultInfo& info) | Updates the authentication result to evaluate the authentication scheme. |
| UpdateAuthenticationResult(uint64_t contextId, const std::vector\<uint8_t>& scheduleResult,<br> AuthResultInfo& info) | Updates the authentication result to evaluate the authentication scheme. |
| CancelAuthentication(uint64_t contextId) | Cancels an authentication. |
| CancelAuthentication(uint64_t contextId) | Cancels an authentication. |
| BeginIdentification(uint64_t contextId, AuthType authType, const std::vector<int8_t>& challenge,<br> uint32_t executorId, ScheduleInfo& scheduleInfo) | Starts an identification to generate the identification scheme and scheduling information. |
| BeginIdentification(uint64_t contextId, AuthType authType, const std::vector\<int8_t>& challenge,<br> uint32_t executorId, ScheduleInfo& scheduleInfo) | Starts identification and generates the identification scheme and scheduling information (version V1_0). |
| UpdateIdentificationResult(uint64_t contextId, const std::vector<uint8_t>& scheduleResult,<br> IdentifyResultInfo& info) | Updates the identification result to evaluate the identification scheme. |
| UpdateIdentificationResult(uint64_t contextId, const std::vector\<uint8_t>& scheduleResult,<br> IdentifyResultInfo& info) | Updates the identification result to evaluate the identification scheme. |
| CancelIdentification(uint64_t contextId) | Cancels an identification. |
| CancelIdentification(uint64_t contextId) | Cancels an identification. |
| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | Obtains the authentication trust level of the specified authentication type. |
| GetAuthTrustLevel(int32_t userId, AuthType authType, uint32_t& authTrustLevel) | Obtains the authentication trust level of the specified authentication type. |
| GetValidSolution(int32_t userId, const std::vector<AuthType>& authTypes, uint32_t authTrustLevel,<br> std::vector<AuthType>& validTypes) | Obtains the valid authentication scheme based on the authentication trust level for a user. |
| GetValidSolution(int32_t userId, const std::vector\<AuthType>& authTypes, uint32_t authTrustLevel,<br> std::vector\<AuthType>& validTypes) | Obtains the valid authentication scheme based on the authentication trust level for a user. |
| BeginEnrollmentV1_1(int32_t userId, const std::vector\<uint8_t>& authToken, const EnrollParam& param, ScheduleInfoV1_1& info) | Enrolls the user authentication credential (version V1_1). If a user has enrolled a PIN, the old PIN will be overwritten.|
| BeginAuthenticationV1_1(uint64_t contextId, const AuthSolution& param, std::vector\<ScheduleInfoV1_1>& scheduleInfos) | Starts authentication and generates the authentication scheme and scheduling information (version V1_1). |
| BeginIdentificationV1_1(uint64_t contextId, AuthType authType,<br/> const std::vector\<uint8_t>& challenge, uint32_t executorSensorHint, ScheduleInfoV1_1& scheduleInfo) | Starts identification and generates the identification scheme and scheduling information (version V1_1). |
### How to Develop
### How to Develop
The following uses the Hi3516D V300 development board as an example to demonstrate how to develop the User_auth driver. <br/>The directory structure is as follows:
The following uses the Hi3516D V300 development board as an example to demonstrate how to develop the User_auth driver. <br/>The directory structure is as follows:
@@ -242,7 +244,7 @@ The development procedure is as follows:
...
@@ -242,7 +244,7 @@ The development procedure is as follows:
.Init=HdfUserAuthInterfaceDriverInit,
.Init=HdfUserAuthInterfaceDriverInit,
.Release=HdfUserAuthInterfaceDriverRelease,
.Release=HdfUserAuthInterfaceDriverRelease,
};
};
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
// Call HDF_INIT to register the driver entry with the HDF. When loading the driver, the HDF calls the Bind() function and then the Init() function. If the Init() function fails to be called, the HDF will call Release() to release driver resources and exit the driver model.
#ifndef __cplusplus
#ifndef __cplusplus
extern"C"{
extern"C"{
...
@@ -267,14 +269,14 @@ The development procedure is as follows:
...
@@ -267,14 +269,14 @@ The development procedure is as follows:
3. Enroll user authentication data. For details about the code, see [user_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/user_auth/hdi_service/service/user_auth_interface_service.cpp).
3. Enroll user authentication data. For details about the code, see [user_auth_interface_service.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/user_auth/hdi_service/service/user_auth_interface_service.cpp).
```c++
```c++
...
@@ -286,13 +288,13 @@ The development procedure is as follows:
...
@@ -286,13 +288,13 @@ The development procedure is as follows:
@@ -342,7 +344,18 @@ The development procedure is as follows:
...
@@ -342,7 +344,18 @@ The development procedure is as follows:
GlobalUnLock();
GlobalUnLock();
returnret;
returnret;
}
}
// Start enrollment and generate scheduling information (V1_0 version). The method of V1_0 is called to invoke the method of V1_1 through parameter conversion.
@@ -436,7 +449,7 @@ The development procedure is as follows:
...
@@ -436,7 +449,7 @@ The development procedure is as follows:
returnret;
returnret;
}
}
for(uint32_ti=0;i<scheduleIdNum;i++){
for(uint32_ti=0;i<scheduleIdNum;i++){
ScheduleInfotemp;
ScheduleInfoV1_1temp;
if(!CopyScheduleInfo(schedulesGet+i,&temp)){
if(!CopyScheduleInfo(schedulesGet+i,&temp)){
infos.clear();
infos.clear();
ret=RESULT_GENERAL_ERROR;
ret=RESULT_GENERAL_ERROR;
...
@@ -448,7 +461,18 @@ The development procedure is as follows:
...
@@ -448,7 +461,18 @@ The development procedure is as follows:
GlobalUnLock();
GlobalUnLock();
returnret;
returnret;
}
}
// Start user authentication, generate the authentication scheme and scheduling information. The method of V1_0 is called to invoke the method of V1_1 through parameter conversion.