【发布时间】:2021-08-28 17:32:56
【问题描述】:
我最近一直在围绕 Android (info here) 的 Secure Key Import 功能开发解决方案,但遇到了问题。
我按照记录的程序进行操作。在最后一步,当调用keyStore.setEntry(...) 时,我得到一个错误代码-1000,即KM_ERROR_UNKNOWN_ERROR (error codes)。我真的不知道如何从这里开始。关于问题可能出在哪里的任何想法?
一些相关代码:
// (app) send attestation challenge request to server
// (server) generate and send challenge to the app
// (app) use challenge to generate a PURPOSE_WRAP_KEY key pair
// (app) get certificate and send to server
// (server) do wrap operations and return a blob (ASN.1 sequence as required in docs)
// (app) code below
byte[] wrappedKeySequence = response.body().getSequenceAsBytes();
AlgorithmParameterSpec spec = new KeyGenParameterSpec.Builder(WRAP_KEY_ALIAS, KeyProperties.PURPOSE_WRAP_KEY)
.setDigests(KeyProperties.DIGEST_SHA256)
.build();
KeyStore.Entry wrappedKeyEntry = new WrappedKeyEntry(wrappedKeySequence, WRAP_KEY_ALIAS, WRAP_ALGORITHM, spec);
String keyAlias = "SECRET_KEY";
keyStore.setEntry(keyAlias, wrappedKeyEntry, null);
更多随机细节:
- 我正在尝试导入 AES128 密钥
- 它将仅用于加密数据
- 根据文档的要求定位 API 28 及更高版本
再次感谢任何帮助。
谢谢, G.
【问题讨论】:
标签: android security import cryptography keystore