<div dir="ltr">Hi!<br><div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-29 6:05 GMT+01:00 Xiaobin Xu <span dir="ltr"><<a href="mailto:xuxb1979@gmail.com" target="_blank">xuxb1979@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi, <div><br></div><div> I tried to implement google play store signature verification in erlang this morning, I think i can use public_key:verify(Msg, DigestType, Signature, Key) -> boolean() to do my job, but I don't know how to generate a public key from encoded public key provided by play store.</div><div><br></div></div></blockquote><div><br></div><div>It depends on what encoding you have? There is public_key:pem_decode that handles PEM-encoding. (Basically Base64 encoded ASN-1 DER blobs rapped in some<br></div><div>header/footer lines)<br><br></div><div>When you have a ASN-1 DER blob you can use public_key:der_decode(ASN1-type, DER) to get the erlang record for that ASN-1 type.<br></div><div><br><br></div><div>Regards Ingela Erlang/OTP team - Ericsson AB <br></div><div><br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div> In case of java, we can do this:</div><div><br></div><div> <span>byte</span><span>[] </span>decodedKey<span> = Base64.decode(</span>encodedPublicKey<span>, Base64.</span>DEFAULT<span>);</span></div>
<p> KeyFactory <span>keyFactory</span> = KeyFactory.getInstance(<span>KEY_FACTORY_ALGORITHM</span>);</p>
<p> <span>return</span> <span>keyFactory</span>.generatePublic(<span>new</span> X509EncodedKeySpec(<span>decodedKey</span>));</p><p> </p><p> Thanks,</p><p> Xiaobin, Xu </p><p> </p></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div></div></div>