1# PIN Authentication (pinauth) 2 3 4## Introduction 5 6The PIN authentication (pinauth) module supports the setting, deletion, and authentication of user PINs. Working with the User IAM subsystem framework, the pinauth module supports PIN change. 7 8pinauth is one of the basic user identity authentication executors of OpenHarmony. It registers PIN authentication resource information with the collaborative authentication framework based on the resource registration interface defined by collaborative authentication, and implements PIN setting, deletion, and authentication based on the scheduling of the collaborative authentication framework. 9 10**Figure 1** pinauth architecture 11 12<img src="figures/pinauth_architecture.png" alt="pinauth_architecture" style="zoom:80%;" /> 13 14 15 16PINs are core assets in the system. The following security measures are taken in PIN authentication for security purposes: 17 18- The PIN input user interface (currently including the PIN setting and PIN authentication dialog boxes) is provided by system applications (<sup>NOTE 1</sup>). The dialog boxes involved in user settings are provided by the **Settings** application, and the PIN input dialog boxes involved in the screen unlock authentication are provided by the **Lock screen** application. 19- Password data transmission: The raw PIN data is not transmitted across devices. After a user PIN is entered in the PIN input dialog box, the raw PIN data entered is transmitted to the pinauth Service ability only after unidirectional processing in the input model management innerAPI. 20- Secure storage and comparison of PIN data: The pinauth HDI defines the adaptation interfaces for device vendors. Device vendors can implement secure PIN comparison and storage in a TEE. <sup>NOTE 2</sup> 21 22**NOTE 1**: To implement the PIN input dialog box, the application needs to register the PIN input dialog box with the pinauth Service ability through the input dialog box management API. The input box management API requires a high-level access permission and can be invoked only by system users. 23 24**NOTE 2**: The OpenHarmony framework provides pure software implementation of PIN authentication for developers to demonstrate the PIN authentication function. The pure software implementation does not include the secure storage capability. 25 26## Directory Structure 27 28```undefined 29//base/useriam/pin_auth 30├── common # Common code 31├── figures # Figures for README.md 32├── frameworks # Framework code 33├── interfaces # APIs exposed externally 34│ └── inner_api # Header file exposed to internal subsystems for system abilities 35├── sa_profile # Service ability profile (configuration) 36├── services # Implementation for the Service ability 37├── test # Directory for storing test code 38├── bundle.json # Component description file 39└── pinauth.gni # Build configuration 40``` 41 42 43## Usage 44 45### Available APIs 46 47**Table 1** APIs for managing input dialog boxes 48 49| API | Description | 50| ------ | -------------------------------- | 51| function registerInputer(inputer:IInputer) : boolean; | Registers the **inputer** callback with the pinauth Service ability. | 52| function unregisterInputer():void; | Unregisters the **inputer** callback from the pinauth Service ability.| 53 54**Table 2** APIs for transferring data 55 56| API| Description | 57| ------ | -------------------------------- | 58| onGetData: (callback:IInputData)=>void | **inputer** callback invoked by the pinauth Service ability to obtain the PIN data. | 59| onSetData: (pinSubType:AuthSubType, data:Uint8Array)=>void | **inputerdata** callback invoked to transfer the PIN data from the PIN input dialog box to the pinauth Service ability. | 60 61### Usage Guidelines 62 63The interfaces defined in **driver\interface\pin_auth\IExecutor.idl** must be implemented in a secure environment (trusted execution environment or security chip) to ensure protection of the highest security level on user PIN information. 64 65## Repositories Involved 66 67[useriam_user_auth_framework](https://gitee.com/openharmony/useriam_user_auth_framework) 68 69[useriam_face_auth](https://gitee.com/openharmony/useriam_face_auth) 70 71**[useriam_pin_auth](https://gitee.com/openharmony/useriam_pin_auth)** 72 73[drivers_peripheral](https://gitee.com/openharmony/drivers_peripheral) 74 75[drivers_interface](https://gitee.com/openharmony/drivers_interface) 76