static VALUE ossl_engine_s_alloc(VALUE klass) { ENGINE *e; VALUE obj; if (!(e = ENGINE_new())) { ossl_raise(eEngineError, NULL); } WrapEngine(klass, obj, e); return obj; }
static VALUE ossl_engine_s_engines(VALUE klass, SEL sel) { ENGINE *e; VALUE ary, obj; ary = rb_ary_new(); for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){ WrapEngine(klass, obj, e); rb_ary_push(ary, obj); } return ary; }
static VALUE ossl_engine_s_engines(VALUE klass) { ENGINE *e; VALUE ary, obj; ary = rb_ary_new(); for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){ /* Need a ref count of two here because of ENGINE_free being * called internally by OpenSSL when moving to the next ENGINE * and by us when releasing the ENGINE reference */ ENGINE_up_ref(e); WrapEngine(klass, obj, e); rb_ary_push(ary, obj); } return ary; }
static VALUE ossl_engine_s_by_id(VALUE klass, VALUE id) { ENGINE *e; VALUE obj; StringValue(id); ossl_engine_s_load(1, &id, klass); if(!(e = ENGINE_by_id(RSTRING_PTR(id)))) ossl_raise(eEngineError, NULL); WrapEngine(klass, obj, e); if(rb_block_given_p()) rb_yield(obj); if(!ENGINE_init(e)) ossl_raise(eEngineError, NULL); ENGINE_ctrl(e, ENGINE_CTRL_SET_PASSWORD_CALLBACK, 0, NULL, (void(*)(void))ossl_pem_passwd_cb); ERR_clear_error(); return obj; }