Parsing a private key only throws an error if trying to decrypt, but not by itself

Ron,

Super appreciate your response. Based on your info, I made MBEDTLS_MPI_MAX_SIZE 385 and made sure that my stack size was a healthy 10000kb.

The key is in PKCS#1 format which should be valid according to my understanding.

Am I correct in adding in a null terminator and length to my key for parsing?

char buffer[prvtkey_pem_bytes + 1]; 
memcpy(buffer, prvtkey_pem_start, prvtkey_pem_bytes); buffer[prvtkey_pem_bytes + 1] = '\0'; 
printf("\n%s\n", buffer);

Anything wrong standout with how i’m decrypting either?

ret = mbedtls_pk_decrypt(&pk, (unsigned char *)encrypted_token, sizeof(encrypted_token), result, &olen, sizeof(result), mbedtls_ctr_drbg_random, &ctr_drbg);

Either way, not sure how i only get the key parse error when i try to decrypt and not by itself.

Any further advice is greatly appreciated, and thanks again for your help.

Spencer