0

I have a client (c#) and server (python) and I need to transfer the public RSA key. I have tried few ways to transfer the public key, in python I get the public key as modulus and exponent whereas in C# I get it as this

<RSAKeyValue><Modulus>1xyM/vAqggdtR6JWqF228FrEC+jWo9XWGvFERzaOw1NWL/ROgVfi4chFJXJXLsnqGeBksUAL81jo/bZlUbjsUnaYDaan9ggb403qdYgg1AwR2PilccsHo1EDexYABD0oCKI+Cu94MmFfpU2g4g50Kr07OhSpdVpbQITpItrT0Yk=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>

or as byte arrays of modulus and exponent. I got stuck because that the python couldn't decode the messages after receiving them encrypted from the c#. I prefer not to mess around with byte arrays and build a xmlString like this in python but I couldn't find in which way the long modulus is encoded and how can I write a function that receive long number(modulus) and another long number (exponent) and create this xml string in python?

Is it the best way I can do this? I mean, sending and receiving xml strings, creating xml trees out of them in python and taking the data. P.S: In c# I use the RSACryptoServiceProvider so it can read and write from/to xml strings.

  • They are Base64-encoded. The only thing that you have to figure out is whether the integer is big-endian or little-endian encoded. – Artjom B. May 06 '17 at 17:51
  • RSAParameters and the RSAKeyValue xml are both big-endian. No idea what python expects. – bartonjs May 06 '17 at 20:30

0 Answers0