Verifying RSA Signatures from Google Licensing with PyCrypto

I am creating a Python implementation of the Google License Signature Validation . I am having a problem importing an RSA public key into a python module.

The key is the 2048-bit RSA and the public part of this key, which you get from the Google Play Developer Console. This is "base64 encoded."

When I try to load it using the following Python code

from Crypto.PublicKey import RSA
BASE64_PUBLIC_KEY = "MIIBIjANBgkqhkiG.."
pubkey = RSA.importKey(BASE64_PUBLIC_KEY)

I get an error ValueError: RSA key format is not supported

I get the same error when I add base64 decoding.

from Crypto.PublicKey import RSA
import base64
BASE64_PUBLIC_KEY = "MIIBIjANBgkqhkiG.."
pubkey = RSA.importKey(base64.b64decode(BASE64_PUBLIC_KEY))

Checking the standard implementation of how the key is loaded into Android, it is decoded by base64 and then sent to a class called X509EncodedKeySpec . The constructor of this class takes one argument.

encodedKey - the key, which is assumed to be encoded according to the X.509 standard. The contents of the array are copied to protect against subsequent modification.

, , X.509, base64. importKey RSA

X.509 subjectPublicKeyInfo DER SEQUENCE (binary or PEM encoding)
+4
2

, , @GregS.

0

, 64 x509, , , .

X.509 subjectPublicKeyInfo DER SEQUENCE ( PEM-)

pem-. 64 , , ( , X509)

0

Source: https://habr.com/ru/post/1526795/


All Articles