我正在使用Android M指纹API来允许用户登录该应用程序.为此,我需要在设备上存储用户名和密码.目前我有登录工作,以及指纹API,但用户名和密码都存储为纯文本.我想在存储之前加密密码,并且能够在用户使用指纹进行身份验证后检索密码.
我正在努力解决这个问题.我一直试图从Android安全样本中应用我能做的,但每个例子似乎只处理加密或签名,而不是解密.
到目前为止,我必须获得AndroidKeyStorea KeyPairGenerator和a 的实例Cipher,使用非对称加密技术来允许使用Android KeyGenParameterSpec.Builder().setUserAuthenticationRequired(true).非对称加密的原因是因为如果用户未经过身份验证,该setUserAuthenticationRequired方法将阻止对密钥的任何使用,但是:
此授权仅适用于密钥和私钥操作.公钥操作不受限制.
这应该允许我在用户使用其指纹进行身份验证之前使用公钥加密密码,然后仅在用户通过身份验证后使用私钥进行解密.
public KeyStore getKeyStore() {
try {
return KeyStore.getInstance("AndroidKeyStore");
} catch (KeyStoreException exception) {
throw new RuntimeException("Failed to get an instance of KeyStore", exception);
}
}
public KeyPairGenerator getKeyPairGenerator() {
try {
return KeyPairGenerator.getInstance("EC", "AndroidKeyStore");
} catch(NoSuchAlgorithmException | NoSuchProviderException exception) {
throw new RuntimeException("Failed to get an instance of KeyPairGenerator", exception);
}
}
public Cipher getCipher() {
try {
return …Run Code Online (Sandbox Code Playgroud) 例如,我有一个带身份验证的网站.是否有可以从JavaScript使用的指纹API登录用户?Android和iOS等移动操作系统都有这样的API.因此,理论上至少移动版浏览器可以提供这样的功能.但我无法在网上找到任何关于它的信息.
javascript fingerprint asp.net-web-api touch-id android-fingerprint-api
我已经浏览了谷歌提供的android指纹样本.
https://github.com/googlesamples/android-FingerprintDialog
由于我是安全标准的新手,我无法理解以下内容.
我的应用程序使用Android的密钥库在使用指纹进行身份验证后加密某些数据.这似乎适用于大多数设备,但我收到了OnePlus2用户的错误报告,但有例外
android.security.KeyStoreException: Signature/MAC verification failed
at android.security.KeyStore.getKeyStoreException(KeyStore.java:632)
at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.update(KeyStoreCryptoOperationChunkedStreamer.java:132)
at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:217)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:473)
at javax.crypto.Cipher.doFinal(Cipher.java:1502)
Run Code Online (Sandbox Code Playgroud)
我的代码基本上是这样的(用Mono for Android编写):
Cipher _cipher = Cipher.GetInstance(KeyProperties.KeyAlgorithmAes + "/"
+ KeyProperties.BlockModeCbc + "/"
+ KeyProperties.EncryptionPaddingPkcs7);
KeyStore _keystore = KeyStore.GetInstance("AndroidKeyStore");
FingerprintManager _fingerprintManager = (FingerprintManager) Context.GetSystemService(Context.FingerprintService);
_keystore.Load(null);
var key = _keystore.GetKey(_keyId, null);
_cipher.Init(CipherMode.EncryptMode, key);
_cryptoObject = new FingerprintManager.CryptoObject(_cipher);
_fingerprintManager.Authenticate(_cryptoObject, _cancellationSignal, 0 /* flags */, this, null);
//OnAuthSucceeded:
var mySecret = _cipher.DoFinal(System.Text.Encoding.UTF8.GetBytes(textToEncrypt));
Run Code Online (Sandbox Code Playgroud)
代码有什么问题吗?这个例外是什么意思?
我在生产应用程序中看到很多异常,因为它们来自Android 6用户的指纹,我无法在我的任何本地三星设备上重现.堆栈跟踪是:
Message: SecurityException: Permission Denial: getCurrentUser() from pid=24365, uid=10229 requires android.permission.INTERACT_ACROSS_USERS
android.os.Parcel.readException in Parcel.java::1620
android.os.Parcel.readException in Parcel.java::1573
android.hardware.fingerprint.IFingerprintService$Stub$Proxy.hasEnrolledFingerprints in IFingerprintService.java::503
android.hardware.fingerprint.FingerprintManager.hasEnrolledFingerprints in FingerprintManager.java::762
android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23.a in SourceFile::39
android.support.v4.hardware.fingerprint.FingerprintManagerCompat$Api23FingerprintManagerCompatImpl.a in SourceFile::239
android.support.v4.hardware.fingerprint.FingerprintManagerCompat.a in SourceFile::66
Run Code Online (Sandbox Code Playgroud)
这只是使用FingerprintManagerCompat支持库中的标准类,并且检查在其他设备上正常工作.
我不想将此权限添加到我的应用程序 - 它似乎与指纹无关.
有人遇到过这样的事吗?
如何在Android Emulator中禁用指纹传感器?我在设置窗口或config.ini文件中找不到任何选项.
默认情况下,SDK 23以上的所有模拟器都具有指纹支持.我想在SDK 23上面测试我的流程,没有指纹支持.
从Android P(API 28)开始,FingerprintManagerAPI已被弃用,Google建议我们应该切换到BiometricPromptAPI.
但是FingerprintManager有一个名为hasEnrolledFingerprints我们正在使用的方法,用于在用电子邮件/密码登录后立即向用户显示提示,我们询问他是否要将他的指纹用于将来的身份验证(例如会话到期时).
BiometricPrompt API没有类似的方法,因此这打破了我们当前的用户体验,我们不确定如何解决这个问题.
我想替代方法是简单地加密用户的密码而不允许他选择手动"注册",并且只是BiometricPrompt在他的会话到期时使用API,但我们认为应该通知用户并选择加入此功能.
我做了一些挖掘试图找出我可以在谷歌的反馈平台上问这样一个问题的地方,但找不到哪里.
对此有任何建议将不胜感激.
我正在尝试在我的应用程序中实现Google的指纹API(特别是在我的片段中).谷歌给了一个例子,但它是一个活动内部实现这里.
我的具体问题是下面的代码检查是否已经注册了指纹,它给了我一个错误(截图如下):
问题 - >我需要做些什么改变才能让它在我的片段中工作(而不是谷歌这样的活动)?
if (!mFingerprintManager.hasEnrolledFingerprints()) {
purchaseButton.setEnabled(false);
// This happens when no fingerprints are registered.
Toast.makeText(getActivity(),
"Go to 'Settings -> Security -> Fingerprint' and register at least one fingerprint",
Toast.LENGTH_LONG).show();
return;
}
Run Code Online (Sandbox Code Playgroud)
android android-fragments android-6.0-marshmallow android-fingerprint-api
I have a DialogFragment that handles login and fingerprint authentication for my application. This fragment uses two classes that are exclusive to API 23, KeyGenParameterSpec and KeyPermanentlyInvalidatedException. I had been under the impression that I could use these classes, as long as I check the build version before I try to initialize the classes (outlined here):
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
...
} else {
...
}
Run Code Online (Sandbox Code Playgroud)
But it appears that this is not the case. If I try …
android dalvik android-version android-api-levels android-fingerprint-api
我有一个Android指纹实现工作,我希望用Espresso添加UI测试.我无法找到解决方案的一个问题是如何模拟手指的扫描.有一个adb命令
adb -e emu finger touch可以在模拟器上运行.
关于如何将这样的东西与Espresso整合的任何想法?