- if(!n || !e || !d || RSA_set0_key(myself->connection->rsa_key, n, e, d) != 1) {
- BN_free(d);
- BN_free(e);
- BN_free(n);
- logger(LOG_ERR, "RSA_set0_key() failed with PrivateKey for myself!");
+ bld = OSSL_PARAM_BLD_new();
+
+ if(!bld) {
+ abort();
+ }
+
+ OSSL_PARAM_BLD_push_BN(bld, "n", n);
+ OSSL_PARAM_BLD_push_BN(bld, "e", e);
+ OSSL_PARAM_BLD_push_BN(bld, "d", d);
+ param = OSSL_PARAM_BLD_to_param(bld);
+ OSSL_PARAM_BLD_free(bld);
+
+ ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);
+
+ if(!ctx) {
+ abort();
+ }
+
+ EVP_PKEY_fromdata_init(ctx);
+ result = EVP_PKEY_fromdata(ctx, &myself->connection->rsa_key, EVP_PKEY_KEYPAIR, param);
+ EVP_PKEY_CTX_free(ctx);
+
+ if(result <= 0) {
+ logger(LOG_ERR, "Failed to parse PrivateKey for myself!");