Phi*_*ipp 15 encryption android android-fingerprint-api
我的应用程序使用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 指纹在各种设备上往往会出现很多奇怪的边缘情况错误。我无法准确回答,但这听起来像是 OnePlus 的 FP api 的硬件或实现问题。我知道小米甚至谷歌都承认其实施过程中存在各种奇怪的问题。
尖端:
确保您只听一次指纹。如果您听两次,您可能会收到不正确的密码对象,因此加密将不匹配。
更新你的 gradle/min sdk/支持库,所有这些东西
抓住你的屁股
| 归档时间: |
|
| 查看次数: |
2698 次 |
| 最近记录: |