Не удается получить ключ хранилища ключей android - PullRequest
0 голосов
/ 18 марта 2020

Я пытаюсь сохранить симметрию c SecretKey в android хранилище ключей и получаю странную ошибку без каких-либо полезных подробностей:

SecretKey sk = new SecretKeySpec(key, HMAC_SHA224);

keyStore.setEntry("key_name1",
        new KeyStore.SecretKeyEntry(sk),
        new KeyProtection.Builder(KeyProperties.PURPOSE_SIGN | KeyProperties.PURPOSE_VERIFY).build());

boolean b = keyStore.isKeyEntry("key_name1");

KeyStore.Entry e = keyStore.getEntry("key_name1", null);

В последней строке выдается следующее исключение. Я не смог найти, что такое -62.

b - это true, что меня смущает.

W/System.err: java.security.UnrecoverableKeyException: Failed to obtain information about key
W/System.err:     at android.security.keystore.AndroidKeyStoreProvider.getKeyCharacteristics(AndroidKeyStoreProvider.java:238)
W/System.err:     at android.security.keystore.AndroidKeyStoreProvider.loadAndroidKeyStoreKeyFromKeystore(AndroidKeyStoreProvider.java:360)
W/System.err:     at android.security.keystore.AndroidKeyStoreSpi.engineGetKey(AndroidKeyStoreSpi.java:116)
W/System.err:     at java.security.KeyStoreSpi.engineGetEntry(KeyStoreSpi.java:524)
W/System.err:     at java.security.KeyStore.getEntry(KeyStore.java:1621)
W/System.err:     at com.company.appname.MainActivity$17.onCharacteristicChanged(MainActivity.java:1580)
W/System.err:     at android.bluetooth.BluetoothGatt$1$8.run(BluetoothGatt.java:519)
W/System.err:     at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:876)
W/System.err:     at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:43)
W/System.err:     at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:513)
W/System.err:     at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:185)
W/System.err:     at android.os.Binder.execTransact(Binder.java:739)
W/System.err: Caused by: android.security.KeyStoreException: -62
W/System.err:     at android.security.KeyStore.getKeyStoreException(KeyStore.java:1168)
W/System.err:     at android.security.keystore.AndroidKeyStoreProvider.getKeyCharacteristics(AndroidKeyStoreProvider.java:240)
W/System.err:   ... 11 more
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...