Android android.credentials.UNLOCK初始化没有密码的密钥库 [英] Android android.credentials.UNLOCK Initializing keystore without password

查看:271
本文介绍了Android android.credentials.UNLOCK初始化没有密码的密钥库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个随机密钥可以通过AES加密本地凭据,我正在按照下面的教程尝试安全地存储 该密钥,然后稍后可以解密:

Having a random key to encrypt local credentials through AES, I'm following the below tutorial to try to store securely that key and then be able to decrypt later on:

nelenkov.blogspot。 co.uk将应用程序秘密存储在androids中

本教程说明了如何访问系统 keystore 并将密码存储在其中。

This tutorial explains how access to the system keystore and store your passwords in it.

我面临的问题集中在对 UNLOCK android.credentials.UNLOCK )的调用中密钥库。未初始化KeyStore的设备(目前API低于14)正在显示一个对话框,要求输入8位数字的密码。

The issue I'm facing it's focused in the call to UNLOCK (android.credentials.UNLOCK) the KeyStore. Devices (at the moment with API below 14) that don't have KeyStore initialized, they are showing a dialog requesting a 8 digits password.

该教程效果很好,但显示此对话框甚至只是一次,这会困扰大多数用户。

The tutorial works fine however showing this dialog even do being only once, it's going to bother most of the users.

有什么方法可以跳过此对话框?

are there any way to skip this dialog?

如果有人描述了一种更好的在本地保存密钥的方法,我会更加高兴。

I would be even happier if someone described a better way to keep locally a Key.

推荐答案

KeyStore 不仅可以在ICS之前的设备上显示为已锁定。锁定 KeyStore 的最简单方法是:

KeyStore can appear locked not only on pre-ICS devices. The simplest way to get KeyStore locked is:


  1. 通过设置KeyGuard初始化KeyStore(屏幕锁上的图案,密码或
    密码)

  2. 添加密钥或您存储在KeyStore中的任何内容

  3. 转到设置>安全并将屏幕锁定更改为不安全的
    ,例如Slide。

  4. 重新启动设备。

  1. Initialize KeyStore by setting KeyGuard (pattern, pin, or password on the Screen Lock)
  2. Add keys or whatever you store in the KeyStore
  3. Go to Settings > Security and change Screen Lock to something "not secure", for example, Slide.
  4. Reboot your device.

启动设备后, KeyStore 将被锁定。 com.android.credentials.UNLOCK 意图将开始 com.android.settings.CredentialStorage 活动,会显示 UnlockDialog ,提示输入密码。

After the device is booted, KeyStore will be LOCKED. com.android.credentials.UNLOCK intent will start com.android.settings.CredentialStorage activity, which, in turn, will show UnlockDialog, prompting for a password.

 * KeyStore: LOCKED
 * KeyGuard: OFF/ON
 * Action:   old unlock dialog
 * Notes:    assume old password, need to use it to unlock.
 *           if unlock, ensure key guard before install.
 *           if reset, treat as UNINITALIZED/OFF

KeyStore 在5次尝试输入错误密码后被重置。但是,重置KeyStore实际上并不会将其关闭或取消初始化。 KeyStore保持锁定状态,并且唯一初始化它的方法似乎是调用 com.android.credentials.RESET 。但这将重置KeyStore和KeyChain(用户安装的证书)。

如果要静默重置KeyStore和KeyChain,而无需用户确认,可以通过绑定到 IKeyChainService 并调用其 reset()方法。

但我不建议您这样做。更好的解决方案是显示一些通知消息,要求用户手动设置屏幕锁定

KeyStore gets reset after 5 attempts to enter incorrect password. But resetting KeyStore actually doesn't turn it off or uninitialize. KeyStore remains locked and the only way to uninitialize it seems to call for com.android.credentials.RESET. But this will reset both KeyStore and KeyChain (user installed certificates).

If you want to reset KeyStore and KeyChain silently, without user confirmation, you can do it by binding to IKeyChainService and calling its reset() method.

But I'd not recommend doing this. A better solution could be to display some notification message asking user to set Screen Lock manually

这篇关于Android android.credentials.UNLOCK初始化没有密码的密钥库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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