【发布时间】:2012-12-30 10:31:14
【问题描述】:
来自 Android In App Billing 版本 3 (TrivialDrive) 示例应用程序附带 sdk
MainActivity.java
/* base64EncodedPublicKey should be YOUR APPLICATION'S PUBLIC KEY
* (that you got from the Google Play developer console). This is not your
* developer public key, it's the *app-specific* public key.
*
* Instead of just storing the entire literal string here embedded in the
* program, construct the key at runtime from pieces or
* use bit manipulation (for example, XOR with some other string) to hide
* the actual key. The key itself is not secret information, but we don't
* want to make it easy for an attacker to replace the public key with one
* of their own and then fake messages from the server.
*/
String base64EncodedPublicKey = "CONSTRUCT_YOUR_KEY_AND_PLACE_IT_HERE";
好吧,我不确定我是否了解此安全措施。我知道如何从 Google Play Developer Console 获取应用程序公钥(已经是 base 64 编码)。
我不明白的是这部分
/* Instead of just storing the entire literal string here embedded in the
* program, construct the key at runtime from pieces or
* use bit manipulation (for example, XOR with some other string) to hide
* the actual key
*/
据我所知,这个公钥是一个常量字符串,它是在应用程序上传过程中由谷歌提供的。
我们如何使用任何位操作过程以编程方式创建相同的密钥?以前有人做过吗?有没有关于如何做到这一点的示例代码?
【问题讨论】:
-
为什么要隐藏 public 密钥,因为它是公开的?
-
@GameScripting 好吧,这是我问自己的第一个问题。但我认为我们不是在谈论密钥对(私钥/公钥对)中的公钥。应用程序公钥可能是不同.. 太糟糕了,谷歌没有太多关于它的文档,特别是在他们自己认为这是一个安全威胁之后..
-
'A string' XOR 'secret' 变成 'Another string'。 'Another string' 再次对相同的 'secret' 进行异或运算,它变成了 'A string'。这是一个 XOR 用例。
-
@Krishnabhadra 它有助于防止攻击者轻松地用他自己的公钥替换您的公钥并使用他自己的服务器(当然使用他的私钥)验证购买,因此执行此类技巧会使攻击者正常工作有点难。当然,为了真正缓解这个问题,鼓励在您自己的服务器上进行二次验证......
标签: android security bit-manipulation in-app-billing public-key