5

I have been given some Python code from the backend that decrypts some data. On my side, the Android app, I need to also decrypt it.

Here are some snippets of the Python code which I believe are the most relevant.

cipher = PKCS1_OAEP.new(privkey)

And this is the module that it comes from

from Crypto.Cipher import PKCS1_v1_5
from Crypto.Cipher import PKCS1_OAEP

Looking at the documentation for PKCS1_OAEP.new https://www.dlitz.net/software/pycrypto/api/2.6/Crypto.Cipher.PKCS1_OAEP-module.html

And then comparing with the JavaDoc for Cipher https://docs.oracle.com/javase/6/docs/technotes/guides/security/StandardNames.html#Cipher

I deduced that this Python algorithm can be expressed as follows using the Java Cipher class (Note the code is in Kotlin)

   val cipher = Cipher.getInstance("RSA/NONE/OAEPWithSHA1AndMGF1Padding", "BC")

Note that BC is the provider. I found out that BouncyCastle is popular and is included in the Android framework

So what is the error?

The backend returns me a 404 when the answer to the challenge is wrong. When I execute the Python code (which hits the same endpoints) it works. In terms of the POST request, I compared both and I am sending it in the correct way.

What would I like to know

Am I using the correct algorithm? I am trying to systematically cross out potential issues before moving onto another

Note that I also tried

    val cipher = Cipher.getInstance("RSA/NONE/OAEPPadding", "BC")
Kubuntuer82
  • 1,487
  • 3
  • 18
  • 40
Ersen Osman
  • 7,067
  • 8
  • 47
  • 80

0 Answers0