diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-04-20 17:15:54 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-04-27 23:07:41 +0900 |
commit | e9cc5e209b520a87f05f994b2961da0ac0fd1e6d (patch) | |
tree | 78872a48b6c6700cccab6f38bfe0667b949e7955 /ext/openssl/ossl_pkey_rsa.c | |
parent | 94cdf4aa2f4aa0dcacaca5127b4c8beb009d9e9f (diff) | |
download | ruby-e9cc5e209b520a87f05f994b2961da0ac0fd1e6d.tar.gz |
ext/openssl: BIGNUM and BN_GENCB is made opaque
Diffstat (limited to 'ext/openssl/ossl_pkey_rsa.c')
-rw-r--r-- | ext/openssl/ossl_pkey_rsa.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c index 52bab79245..3686d34361 100644 --- a/ext/openssl/ossl_pkey_rsa.c +++ b/ext/openssl/ossl_pkey_rsa.c @@ -97,15 +97,16 @@ static RSA * rsa_generate(int size, unsigned long exp) { int i; - BN_GENCB cb; struct ossl_generate_cb_arg cb_arg; struct rsa_blocking_gen_arg gen_arg; RSA *rsa = RSA_new(); BIGNUM *e = BN_new(); + BN_GENCB *cb = BN_GENCB_new(); - if (!rsa || !e) { - if (e) BN_free(e); + if (!rsa || !e || !cb) { if (rsa) RSA_free(rsa); + if (e) BN_free(e); + if (cb) BN_GENCB_free(cb); return 0; } for (i = 0; i < (int)sizeof(exp) * 8; ++i) { @@ -121,11 +122,11 @@ rsa_generate(int size, unsigned long exp) memset(&cb_arg, 0, sizeof(struct ossl_generate_cb_arg)); if (rb_block_given_p()) cb_arg.yield = 1; - BN_GENCB_set(&cb, ossl_generate_cb_2, &cb_arg); + BN_GENCB_set(cb, ossl_generate_cb_2, &cb_arg); gen_arg.rsa = rsa; gen_arg.e = e; gen_arg.size = size; - gen_arg.cb = &cb; + gen_arg.cb = cb; if (cb_arg.yield == 1) { /* we cannot release GVL when callback proc is supplied */ rsa_blocking_gen(&gen_arg); @@ -133,6 +134,8 @@ rsa_generate(int size, unsigned long exp) /* there's a chance to unblock */ rb_thread_call_without_gvl(rsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg); } + + BN_GENCB_free(cb); if (!gen_arg.result) { BN_free(e); RSA_free(rsa); |