首页 > 解决方案 > 未能在 Diffie-Hellman 加密上解开密钥异常 android O

问题描述

我正在为我的应用程序用户名和密码使用 Diffie-Hellman 加密和解密算法。我正在使用我的密钥库来存储信息和检索它在 android O 下正常工作。最近我遇到了这个问题,请帮助我

java.security.InvalidKeyException: Failed to unwrap key
java.security.InvalidKeyException: Failed to unwrap key\n
Caused by: com.sample.example.sdk.manager.utils.CustomException: java.security.InvalidKeyException: Failed to unwrap key\n\tat 
com.sample.example.sdk.manager.KeyPairHelper.getDevicePrivatekKey(KeyPairHelper.java:60)\n\tat 
com.sample.example.sdk.manager.SampleTask.buildAesKey(SampleTask.java:100)\n\tat 
com.sample.example.sdk.manager.SampleTask.call(SampleTask.java:186)\n\tat 
com.sample.example.sdk.manager.SampleTask.call(SampleTask.java:66)\n\tat 
io.reactivex.internal.operators.observable.ObservableFromCallable.subscribeActual(ObservableFromCallable.java:42)\n\tat 
io.reactivex.Observable.subscribe(Observable.java:10842)\n\tat 
io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)\n\tat 
io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)\n\tat io.reactivex.internal.
schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)\n\tat 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)\n\tat 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)\n\tat 
java.lang.Thread.run(Thread.java:764)\n
Caused by: java.security.InvalidKeyException: Failed to unwrap key\n\tat 
android.security.keystore.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:682)\n\tat 
javax.crypto.Cipher.unwrap(Cipher.java:2121)\n\tat 
com.sample.example.sdk.manager.utils.Custom.getEncryptionKey(Custom.java:312)\n\tat 
com.sample.example.sdk.manager.utils.Custom.\u003cinit\u003e(Custom.java:108)\n\t
... 15 more\nCaused by: javax.crypto.IllegalBlockSizeException\n\tat 
android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:519)\n\tat 
android.security.keystore.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:680)\n\t... 18 more\n
Caused by: android.security.KeyStoreException: Unknown error\n\tat 
android.security.KeyStore.getKeyStoreException(KeyStore.java:1137)\n\tat android.security.keystore.KeyStoreCryptoOp

标签: androidandroid-8.0-oreoandroid-keystorediffie-hellman

解决方案


推荐阅读