【问题标题】:Store AES key in Android在 Android 中存储 AES 密钥
【发布时间】:2016-05-19 13:05:23
【问题描述】:

我想将 AES 密钥存储在 pre-M 设备上的 AndroidKeyStore 中

我尝试使用KeyGenerator生成的密钥

KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES);
keyGen.init(256);
SecretKey secretKey = keyGen.generateKey();

但我无法从 KeyStore 访问该密钥,后来我尝试使用 KeyPairGenerator

KeyPairGenerator kpg = KeyPairGenerator.getInstance(
                KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
kpg.initialize(new KeyPairGeneratorSpec.Builder(this)
                .setAlias("alias")
                .build());
KeyPair kp = kpg.genKeyPair();

但是

java.security.NoSuchAlgorithmException:未找到 KeyPairGenerator AES 实现

【问题讨论】:

标签: android encryption keystore android-keystore


【解决方案1】:

Android Keystore 仅从 API 级别 23 开始支持 AES(请参阅https://developer.android.com/training/articles/keystore.html#SupportedAlgorithms)。在旧平台上,您可以使用 Android Keystore RSA 密钥包装 AES 密钥。但是,这意味着 AES 密钥的密钥材料将在您的应用进程中可用,这消除了使用 Android Keystore 的许多安全优势。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-03
    • 2012-09-06
    • 1970-01-01
    • 2010-12-29
    • 2011-10-14
    • 1970-01-01
    • 2017-04-16
    相关资源
    最近更新 更多