-bool rsa_set_hex_private_key(rsa_t *rsa, char *n, char *e, char *d) {
- *rsa = RSA_new();
- if(BN_hex2bn(&(*rsa)->n, n) != strlen(n))
- return false;
- if(BN_hex2bn(&(*rsa)->e, e) != strlen(e))
- return false;
- if(BN_hex2bn(&(*rsa)->d, d) != strlen(d))
+rsa_t *rsa_set_hex_private_key(char *n, char *e, char *d) {
+ BIGNUM *bn_n = NULL;
+ BIGNUM *bn_e = NULL;
+ BIGNUM *bn_d = NULL;
+
+ if((size_t)BN_hex2bn(&bn_n, n) != strlen(n) || (size_t)BN_hex2bn(&bn_e, e) != strlen(e) || (size_t)BN_hex2bn(&bn_d, d) != strlen(d)) {
+ BN_free(bn_d);
+ BN_free(bn_e);
+ BN_free(bn_n);