【问题标题】:Secure place to store encryption/decryption key on android在 android 上存储加密/解密密钥的安全位置
【发布时间】:2015-11-08 03:41:30
【问题描述】:

在我的场景中,应用用户不应该能够操作一组字符串,因为它们是不完整的游戏分数,当他们完成游戏时会进入排行榜。如果他们修改它们,这是不必要的优势。 我使用此处显示的代码测试了字符串加密和存储在文件中。
https://github.com/tozny/java-aes-crypto/blob/master/AesCbcWithIntegrityTests.java

上面写着

注意:如果您正在生成一个随机密钥,您可能会将其存储在某个地方

存储此密钥的最佳位置是什么,或者有更好的方法来实现我的目标。

 try {
        SecretKeys key;

        key = generateKey();
       //Note: If you are generating a random key, you'll probably be storing it somewhere


        // The encryption / storage & display:

        String keyStr = keyString(key);
        key = null; //Pretend to throw that away so we can demonstrate converting it from str
        String path = getPath();
        String textToEncrypt = savePuzzle(path + "/intput.txt");
        Log.i("Tozny", "Before encryption: " + textToEncrypt);

        // Read from storage & decrypt
        key = keys(keyStr); // alternately, regenerate the key from password/salt.
        CipherTextIvMac civ = encrypt(textToEncrypt, key);
        String temp = civ.toString();
        Log.i("Tozny", "Encrypted: " + temp);


        CipherTextIvMac civ2 = new CipherTextIvMac(temp);
        String decryptedText = decryptString(civ2, key);

【问题讨论】:

  • 我只想指出,在有根手机上,您可以轻松访问只是纯文本 XML 文档的SharedPreferences。所以别想了。
  • 将其存储在您的服务器上怎么样?唯一的限制是保存分数时用户必须有互联网连接
  • 您真正需要的是专业的应用保护和混淆框架(例如 Apk Protect、DexGuard、DashO、DexProtector 或 Stringer)。
  • 感谢大家的意见。我认为服务器或混淆是唯一的选择。

标签: android encryption


【解决方案1】:

使用 AndroidKeyStore 添加 keystoreEntry。

此链接可以帮助您: http://developer.android.com/training/articles/keystore.html

【讨论】:

    【解决方案2】:

    有很多方法。

    -在资源中提供(可以轻松反编译)

    • 作为常量存储(可以反编译)
    • 我更喜欢什么 创建名为 MyKeyGenerator 的类。 进行一些逻辑,如追加、反向或等操作,最后我们得到一些密钥。 使用 progauard 使用代码混淆。

    这可能对你有用。

    【讨论】:

    • 谢谢,所以 MyKeyGenerator 上的逻辑会隐藏 progauard 的限制,因为它不会隐藏键对吗?你有什么好的试用 MyKeyGenerator 逻辑吗?
    猜你喜欢
    • 2015-11-24
    • 2018-03-16
    • 2014-10-18
    • 2015-07-04
    • 1970-01-01
    • 2015-07-21
    • 2014-06-24
    • 1970-01-01
    相关资源
    最近更新 更多