为 Google Android 应用内购买伪造签名字符串
我正在验证来自 Android 应用内购买的签名字符串,我知道足以编写一个基于服务器的独立验证来检查该字符串是否使用我的公钥和 JSON 响应中发送的私钥进行签名,这很好。在我缺乏知识的情况下,如果人们可以访问我的公钥,他们是否能够使用私钥对字符串进行签名并向我的外部服务器发送响应,从而成功验证?
我可能错过了一些东西,但是在我的iPhone应用程序上,我联系Apple,他们联系应用程序,我用苹果响应联系我的服务器,它联系苹果并独立验证响应,我对我的WP7应用程序与PayPal做同样的事情,与Google,我没有连接到 Google 来验证该字符串,我只是检查该字符串是否用我的密钥签名,这真的足够了吗?
谢谢
I am verifying a signed string from Android inapp purchases, I know enough to have written a server based independent verification to check that the string is signed with my public key and the private key sent in the JSON response, thats fine. Where my knowledge is lacking, wouldn't it be possible for people, if they have access to my public key, to be able to sign a string with a private key and send a response to my external server, which would successfully validate?
I am probably missing something, but on my iPhone app I contact Apple, they contact the app back, I contact my server with apples response, it contacts apple and independantly verifies the response, I do the same for my WP7 app with PayPal, with Google, I am not connecting to Google to verify the string, I am just checking the string is signed with my Keys, is this truly enough?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简而言之,不。如果有时间,您可以阅读 RSA,但非对称算法(加密/签名的密钥与解密/验证的密钥不同)的全部要点是,实际上不可能找出另一半如果您只有一把钥匙。因此,如果某人拥有您的公钥,您可以非常确定他们无法生成私钥。或者,如果他们只是生成一个新密钥,那么当您验证签名时,您将收到验证错误。
如果您的随机数确实是随机的并且实际上只使用了一次,那么它们也无法重播相同的消息,因此您应该相当安全。 (假设没有实现问题)
您应该更担心的是人们使用字节码修补工具绕过整个验证过程并从
isLicensed()
方法返回 true。In short, no. You can read up on RSA if you have the time, but the whole point of asymmetric algorithms (where the key you encrypt/sign is different from the one you decrypt/verify with), is that is practically impossible to figure out the other half of the key if you only have one. Thus, if someone has your public key, you can be pretty sure they cannot produce the private one. Alternatively, if they just generate a new key, when you verify the signature, you will get a verification error.
If your nonces are truly random and really only used once, they cannot replay the same message either, so you should be reasonably safe. (assuming there are no implementation problems)
What you should be more worried about is people using bytecode patching tools to bypass the whole validation process and just return true from the
isLicensed()
method.