I’m working on encrypting a message using public key.

The usecase is that we will encrypt the message using public key code is written in mbedtls c code and send it to server. In server the decryption is done by private key. The algorithm in server is written in java which is having the configuration as RSA/ECB/PKCS1PADDING.

The code snippet I’m trying out in c code is
note rsa context is having the public key information loaded.

ret = mbedtls_rsa_pkcs1_encrypt(rsa, mbedtls_ctr_drbg_random,
&ctr_drbg, strlen(inputToEncrypt),inputToEncrypt , rsa_ciphertext);
Does this code snippet is having the configuration as RSA/ECB/PKCS1PADDING or do I need to set the mode and padding using some other api before calling mbedtls_rsa_pkcs1_encrypt. While checking the source code of mbedtls library I’m not able to find an api which sets the configuration.

The server is not able to decrypt the message successfully.

Do I need to use some other api for encryption or some error in the code I’m using

The configuration I need is of RSA/ECB/PKCS1PADDING.