Mbedtls PK - Loading the private and public key into the same context

Hello,

Is there any hack that makes it possible to load a private key into a pk context where you’ve only loaded a public key (or vise versa)? I can see, that it is possible to instantiate a single context with both, but I cannot parse both PEM files into the same context.

Basically I would like to be able to do something like this:

    int operation_result;

    //Get the key ready
    rsa_Cryptographer->generate_CTRX_context();
    operation_result = rsa_Cryptographer->generate_key();
    if(!isGoodResult(operation_result)){
        Serial.println(-operation_result,HEX);
    }

    assert(rsa_Cryptographer->validate_key() == RSABooleanTrue);

    mbedtls_pk_context pk_ctx = rsa_Cryptographer->get_RSA_context();

    //Filling the buffer with keys
    unsigned char * pub;
    unsigned char * priv;
    rsa_Cryptographer->get_key_pem(&pub,0);
    println_unsignedString(pub,PEMPublicKeyLen,CHR);
    rsa_Cryptographer->get_key_pem(&priv,1);
    println_unsignedString(priv,PEMPrivKeyLen,CHR);

    //Parsing these keys into a context
    mbedtls_pk_context pk_ctx_pub;
    mbedtls_pk_context pk_ctx_priv;

    mbedtls_pk_init(&pk_ctx_pub);
    mbedtls_pk_init(&pk_ctx_priv);
    operation_result = mbedtls_pk_parse_public_key(&pk_ctx_pub,pub,PEMPublicKeyLen);
    if(!isGoodResult(operation_result)){
        Serial.print(operation_result);
    }

    operation_result = mbedtls_pk_parse_key(&pk_ctx_pub,priv,PEMPrivKeyLen,NULL,69);
    if(!isGoodResult(operation_result)){
        Serial.print(-operation_result,HEX);
    }

    //Asserting, that the keys match
    assert(mbedtls_pk_check_pair(&pk_ctx_pub,&pk_ctx_priv) == 0);
    Serial.print("DONEE"); //Print statement for added swag