Sometimes, after a person makes a purchase on and android device via IAB, the signature the client sends back to the server cannot be base64 decoded due to a "TypeError: Incorrect padding" exception.
the server code looks like this, where "signature" is passed to the server from our clients which got the value from the IAB API:
signature_encoded = signature.encode()
key = RSA.importKey(GOOGLE_PLAY_STORE_KEY_PEM)
verifier = PKCS1_v1_5.new(key)
signed_data_hash = SHA.new(signed_data)
# fails here SOMETIMES
signature_decoded = base64.urlsafe_b64decode(signature_encoded)
The length of the "signature" string is supposed to be divisible by 4, but sometimes they come in with length 342 and give this padding error.
I've tried adding "==" to the end and that gets us around the exception but the result is not valid when compared to "signed_data_hash" (i.e. verifier.verify(signed_data_hash, signature_decoded) returns False).
I don't think this is a hack attempt since the client logs we're seeing indicate they are going through our purchase flow.
Any help here would be greatly appreciated! Thanks!