12#if !defined(OPENSSL_NO_ENGINE)
14#define NewEngine(klass) \
15 TypedData_Wrap_Struct((klass), &ossl_engine_type, 0)
16#define SetEngine(obj, engine) do { \
18 ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
20 RTYPEDDATA_DATA(obj) = (engine); \
22#define GetEngine(obj, engine) do { \
23 TypedData_Get_Struct((obj), ENGINE, &ossl_engine_type, (engine)); \
25 ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
49#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
50#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x) \
52 if(!strcmp(#engine_name, RSTRING_PTR(name))){\
53 if (OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_##x, NULL))\
56 ossl_raise(eEngineError, "OPENSSL_init_crypto"); \
60#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x) \
62 if(!strcmp(#engine_name, RSTRING_PTR(name))){\
63 ENGINE_load_##engine_name();\
70ossl_engine_free(
void *engine)
96#if !defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES)
103 ENGINE_load_builtin_engines();
107#ifndef OPENSSL_NO_STATIC_ENGINE
108#if HAVE_ENGINE_LOAD_DYNAMIC
111#if HAVE_ENGINE_LOAD_4758CCA
114#if HAVE_ENGINE_LOAD_AEP
117#if HAVE_ENGINE_LOAD_ATALLA
120#if HAVE_ENGINE_LOAD_CHIL
123#if HAVE_ENGINE_LOAD_CSWIFT
126#if HAVE_ENGINE_LOAD_NURON
129#if HAVE_ENGINE_LOAD_SUREWARE
132#if HAVE_ENGINE_LOAD_UBSEC
135#if HAVE_ENGINE_LOAD_PADLOCK
138#if HAVE_ENGINE_LOAD_CAPI
141#if HAVE_ENGINE_LOAD_GMP
144#if HAVE_ENGINE_LOAD_GOST
147#if HAVE_ENGINE_LOAD_CRYPTODEV
150#if HAVE_ENGINE_LOAD_AESNI
154#ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO
173ossl_engine_s_cleanup(
VALUE self)
175#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100000
194 for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){
225 ossl_engine_s_load(1, &
id,
klass);
233 ENGINE_ctrl(e, ENGINE_CTRL_SET_PASSWORD_CALLBACK,
252ossl_engine_get_id(
VALUE self)
272ossl_engine_get_name(
VALUE self)
288ossl_engine_finish(
VALUE self)
317 const EVP_CIPHER *ciph, *tmp;
322 nid = EVP_CIPHER_nid(tmp);
324 ciph = ENGINE_get_cipher(e,
nid);
349 const EVP_MD *md, *tmp;
354 nid = EVP_MD_nid(tmp);
356 md = ENGINE_get_digest(e,
nid);
383 pkey = ENGINE_load_private_key(e, sid,
NULL, sdata);
412 pkey = ENGINE_load_public_key(e, sid,
NULL, sdata);
435ossl_engine_set_default(
VALUE self,
VALUE flag)
441 ENGINE_set_default(e,
f);
471ossl_engine_cmd_flag_to_name(
int flag)
474 case ENGINE_CMD_FLAG_NUMERIC:
return rb_str_new2(
"NUMERIC");
475 case ENGINE_CMD_FLAG_STRING:
return rb_str_new2(
"STRING");
476 case ENGINE_CMD_FLAG_NO_INPUT:
return rb_str_new2(
"NO_INPUT");
477 case ENGINE_CMD_FLAG_INTERNAL:
return rb_str_new2(
"INTERNAL");
489ossl_engine_get_cmds(
VALUE self)
492 const ENGINE_CMD_DEFN *defn, *p;
497 if ((defn = ENGINE_get_cmd_defns(e)) !=
NULL){
498 for (p = defn; p->cmd_num > 0; p++){
502 rb_ary_push(tmp, ossl_engine_cmd_flag_to_name(p->cmd_flags));
517ossl_engine_inspect(
VALUE self)
523 rb_obj_class(
self), ENGINE_get_id(e), ENGINE_get_name(e));
526#define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x))
561#ifdef ENGINE_METHOD_BN_MOD_EXP
564#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT
VALUE rb_define_class_under(VALUE, const char *, VALUE)
Defines a class under the namespace of outer.
VALUE rb_define_module(const char *)
int rb_block_given_p(void)
Determines if the current method is given a block.
VALUE rb_cObject
Object class.
VALUE rb_obj_class(VALUE)
Equivalent to Object#class in Ruby.
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
void ossl_raise(VALUE exc, const char *fmt,...)
void ossl_clear_error(void)
VALUE ossl_cipher_new(const EVP_CIPHER *cipher)
VALUE ossl_digest_new(const EVP_MD *md)
#define SetEngine(obj, engine)
#define DefEngineConst(x)
#define GetEngine(obj, engine)
#define OSSL_ENGINE_LOAD_IF_MATCH(engine_name, x)
void Init_ossl_engine(void)
VALUE ossl_pkey_new(EVP_PKEY *pkey)
#define OSSL_PKEY_SET_PRIVATE(obj)