I have app which uses Fingerprint and 4 digit pin (which can be set by user in application settings, this is not system pin/pattern/password) authorization.
With Fingerprint everything is fine, I have problem with pin.
What I'm trying to do is:
- Let user set pin from application settings
- Generate Keypair in keystore for some alias protected by entered pin (so that private key can not be accessed without this pin)
- Send public key to server for future signature verification
- Get user token from server and store it in local storage
Then during Authorization:
- Request user to enter the pin
- Retrieve private key by entered pin
- Retrieve token from local storage
- Sign token with private key from step 6
- Send it to server with signed data
- Verify signature on server and if it is valid, open session for user.
My question is: How can I generate KeyPair protected by pin entered by user
P.S. For fingerprint this logic is handled by:
KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_SIGN).setUserAuthenticationRequired(true)