如何在Android KeyStore中生成受自定义密码保护的KeyPair [英] How to generate KeyPair in android KeyStore, protected by custom password

查看:284
本文介绍了如何在Android KeyStore中生成受自定义密码保护的KeyPair的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用指纹和4位数PIN码的应用程序(可以由用户在应用程序设置中设置,这不是系统PIN码/模式/密码)授权.

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.

我想做的是:

  1. 让用户从应用程序设置中设置图钉
  2. 在密钥存储区中为由输入的针脚保护的别名生成密钥对(这样,如果没有此针脚就无法访问私钥)
  3. 将公钥发送到服务器以供将来的签名验证
  4. 从服务器获取用户令牌并将其存储在本地存储中

然后在授权期间:

  1. 要求用户输入图钉
  2. 通过输入的密码检索私钥
  3. 从本地存储中检索令牌
  4. 使用第6步中的私钥对令牌进行签名
  5. 将其与签名数据一起发送到服务器
  6. 验证服务器上的签名,如果签名有效,则为用户打开会话.

我的问题是:如何生成受用户输入密码保护的KeyPair

P.S.对于指纹,此逻辑由以下方式处理:

P.S. For fingerprint this logic is handled by:

KeyGenParameterSpec.Builder(KEY_NAME, KeyProperties.PURPOSE_SIGN).setUserAuthenticationRequired(true)

推荐答案

我建议尝试使用此帖子

I will suggest try to use this post Use the Android KeyStore to securely store arbitrary strings post.

该帖子的重点是

  1. 在设备上生成,安全存储和检索加密密钥.

  1. Generate, securely store, and retrieve encryption keys on the device.

加密任意数据并将其保存在设备上.

Encrypt arbitrary data and save it on the device.

访问和解密数据以供以后使用.

Access and decrypt the data for subsequent use.

我希望它会有所帮助.

这篇关于如何在Android KeyStore中生成受自定义密码保护的KeyPair的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆