Encrypt and decrypt rsa python

broken image

Here is my code for calling the library: static void dcu_encrypt_aes_key(uint8_t aes_key_to_crypt, uint8_t encrypted_aes_key, size_t* encrypted_key_size) Stepping through the python RSA library I have found that the resulting clear text message doesn't contain the original message anywhere which leads me to believe it is an issue with ST's library. I've tried manually adding padding, so I know that the issue is not of the ST library not automatically doing padding. Upon attempting to decrypt the message it throws the error for not being able to find proper pkcs#1 v1.5 padding. I've verified the key being received by the MCU is identical to the one generated and I've verified the encrypted message is identical once it makes it back to the Raspberry Pi running the python script.

broken image

I'm using STM's cryptographic library on a STMf412ret6 to encrypt a 16 byte message using a 2048 bit public key generated by the Python-RSA 4.8 library, first result on google for 'python rsa'.

broken image