Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years ago.
MBEDTLS Inavlid padding
Hi, Currently I am trying to encrypt and decrypt a message using RSA. I am able to decrpyt a message encrypted with another tool, and I am able to encrypt something like "hello world" BUT I am not able to decrypt the data encrypted by my own program...
I always get err= -16640 -> RSA - Input data contains invalid padding and is rejected.
The Keypair I am using is definitly valid. any Ideas what I am doing wrong?
RSA test
unsigned char output[1000]; int err = mbedtls_pk_encrypt( pubK, (unsigned char*)"hallo123", 8,bbuf, &olen, sizeof(bbuf),mbedtls_ctr_drbg_random, ctr_drbg); if(err!=0) { char buf[128]; mbedtls_strerror(err,buf,sizeof(buf)); logger.logInfo("rsa encryption failed, err= %i -> %s",err,buf); return; } err = mbedtls_pk_decrypt(prvK, bbuf, olen, output, &olenR, sizeof(output), mbedtls_ctr_drbg_random, ctr_drbg); if (err != 0) { char buf[128]; mbedtls_strerror(err, buf, sizeof(buf)); logger.logInfo("rsa decryption failed, err= %i -> %s", err, buf); return; }
thanks, Jonas