简体   繁体   English

Android - 安全存储

[英]Android - Secure storage

How I do to store a secret key in a android device with the only possibility to use the key, not retrieve it. 我如何在Android设备中存储一个秘密密钥,唯一可能使用密钥,而不是检索它。 Eg: I import a private/generate a RSA keypair or a symmetric key from a application to this "secure storage". 例如:我从应用程序向此“安全存储”导入私有/生成RSA密钥对或对称密钥。 Now, NOBODY should be able to retrieve the secret key, not even the original application. 现在,NOBODY应该能够检索密钥,甚至是原始应用程序。 (The non-secret part of key - the public key of a RSA keypair - but no part of a symmetric key - should still be retrieveable, especially if the key is generated in the secure storage) (密钥的非秘密部分 - RSA密钥对的公钥 - 但不是对称密钥的一部分 - 仍然应该是可检索的,特别是如果密钥是在安全存储中生成的)

The keystore should now act as a black box, providing a input for encrypted data and a output for decrypted data, eg I feed my encrypted values that I want to decrypt, and gets the decrypted values back. 密钥库现在应该充当黑盒子,提供加密数据的输入和解密数据的输出,例如,我提供我想要解密的加密值,并获取解密的值。

Its a big plus if this is implemented in a hardware security chip in the android device, like a smart card chip, which is tamper-resistant, which would also keep the keys secure even if the device is rooted & cloned. 如果这是在Android设备的硬件安全芯片中实现的话,这是一个很大的优点,就像智能​​卡芯片一样,它具有防篡改功能,即使设备被植根和克隆也可以保证密钥的安全。

Any ideas which android mobile phones, that has such a tamper-resistant chip? Android手机的哪些想法,有这样的防篡改芯片? Any ideas on how to use such a storage? 关于如何使用这种存储的任何想法?

Found a similiar question: Android Secure Storage but this does not answer my questions. 发现了一个类似的问题: Android安全存储,但这不能回答我的问题。

I'll answer this but with reservation. 我会回答这个但是有所保留。

https://developer.android.com/training/articles/keystore.html https://developer.android.com/training/articles/keystore.html

"Key material may be bound to the secure hardware (eg, Trusted Execution Environment (TEE), Secure Element (SE)) of the Android device. When this feature is enabled for a key, its key material is never exposed outside of secure hardware ." “密钥材料可能绑定到Android设备的安全硬件(例如,可信执行环境(TEE),安全元素(SE))。 当为密钥启用此功能时,其密钥材料永远不会暴露在安全硬件之外 “。

So you enable the feature for the key. 因此,您为密钥启用了该功能。 However, 然而,

"If the Android OS is compromised or an attacker can read the device's internal storage, the attacker may be able to use any app's Android Keystore keys on the Android device , but not extract them from the device." “如果Android操作系统受到攻击或攻击者可以读取设备的内部存储, 攻击者可能可以在Android设备上使用任何应用程序的Android Keystore密钥 ,但不能从设备中提取它们。”

This is due to Android allowing the keys to be used without the secret which is inherently unsafe. 这是因为Android允许使用密钥而没有本质上不安全的秘密。 Hence my reservation. 因此我的预订。

In answer to android devices with the secure chip I'd say to a search. 在使用安全芯片回答Android设备时,我会对搜索说。 Seems TEE socs have been around for a while. 似乎TEE soc已经存在了一段时间。

secret: [ ______________ ] 秘密:[______________]

Found out what you need to do to get secure storage on Android: 找到了在Android上获取安全存储所需的操作:

You need to buy a Secure MicroSD card, one which conforms to the ASSD specification (Advanced Security SD). 您需要购买符合ASSD规范(高级安全SD)的Secure MicroSD卡。 That is a MicroSD card that contains a Secure Element, often a PKI solution where you can generate a private key on-card so the private key is impossible to extract, but the public key can be extracted and use it to encrypt things that only the MicroSD card can decrypt. 这是一个包含安全元素的MicroSD卡,通常是PKI解决方案,您可以在卡上生成私钥,因此无法提取私钥,但可以提取公钥并使用它来加密只有MicroSD卡可以解密。

Two examples is CertGate MicroSD (which is available as a consumer version called "SmartCard-HSM Android") and one that is no longer available in consumer version, is the G&D Mobile Security Card. 两个例子是CertGate MicroSD(可作为消费者版本称为“SmartCard-HSM Android”)和一个不再用于消费者版本的是G&D移动安全卡。

That makes it a secure storage that CANNOT be hacked by a rooted phone, and it CANNOT be copied, impossible per the definition. 这使得它成为一个安全的存储设备,不会被根电话攻击,并且根据定义不能复制,也不可能。 Only way is to brute-force the private key using the public key as verification if you hit correctly. 如果你正确点击,唯一的方法是使用公钥强制私钥作为验证。 But if you use RSA-2048, that is technically impossible too. 但是如果你使用RSA-2048,那在技术上也是不可能的。

The reason is that the Phone Manufacturers seems to lock the built-in Phone Secure Element to manufacturer approved apps, so you cannot use it arbitrarily. 原因是手机制造商似乎将内置的手机安全元件锁定到制造商认可的应用程序,因此您无法任意使用它。 Only way is actually add a Secure Element to the phone in the form of a MicroSD card. 唯一的方法是以MicroSD卡的形式向手机添加安全元素。

(This answer is only valid for Android versions prior to 5.0) (此答案仅适用于5.0之前的Android版本)

You might check out CertStore or KeyStore , although I do not know how these are implemented on Android. 您可以查看CertStoreKeyStore ,但我不知道这些是如何在Android上实现的。 I did some searching around but couldn't find any promising examples, and actually found a post on the Android-Security-Discussions group indicating that this might not even work on Android. 我做了一些搜索,但找不到任何有希望的例子,实际上在Android-Security-Discussions小组上发现了一个帖子 ,表明这可能甚至不适用于Android。

What you are asking is impossible. 你问的是不可能的。 A user with a jail-broken device has more control over the device than you do. 具有越狱设备的用户可以比您更多地控制设备。 There is no place to hide anything, and there never will be. 没有地方可以隐藏任何东西,而且永远不会有。 What you are looking for is "(in) Security Though Obscurity ". 您正在寻找的是“(在) 安全虽然不安全 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM