Retval = cmox_rsa_pkcs1v15_encrypt(&Rsa_Ctx, /* RSA context */Īes_key_to_crypt, 16, /* Message to encrypt */ * Compute directly the encrypted message passing all the needed parameters */ HAL_RNG_GenerateRandomNumber(&hrng, &rand_num) If (cmox_initialize(NULL) != CMOX_INIT_SUCCESS)Ĭmox_rsa_construct(&Rsa_Ctx, CMOX_RSA_MATH_FUNCS, CMOX_MODEXP_PUBLIC, Working_Buffer, 7000) 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. 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'.