11 #if !defined(_OSSL_H_)
14 #include RUBY_EXTCONF_H
16 #if defined(__cplusplus)
40 #include <openssl/opensslv.h>
45 # define assert(condition)
49 # include <openssl/e_os2.h>
50 # define OSSL_NO_CONF_API 1
51 # if !defined(OPENSSL_SYS_WIN32)
52 # define OPENSSL_SYS_WIN32 1
54 # include <winsock2.h>
57 #include <openssl/err.h>
58 #include <openssl/asn1_mac.h>
59 #include <openssl/x509v3.h>
60 #include <openssl/ssl.h>
61 #include <openssl/pkcs12.h>
62 #include <openssl/pkcs7.h>
63 #include <openssl/hmac.h>
64 #include <openssl/rand.h>
65 #include <openssl/conf.h>
66 #include <openssl/conf_api.h>
68 #undef PKCS7_SIGNER_INFO
69 #if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ST_ENGINE)
70 # define OSSL_ENGINE_ENABLED
71 # include <openssl/engine.h>
73 #if defined(HAVE_OPENSSL_OCSP_H)
74 # define OSSL_OCSP_ENABLED
75 # include <openssl/ocsp.h>
81 #define OSSL_MIN_PWD_LEN 4
96 #define OSSL_Check_Kind(obj, klass) do {\
97 if (!rb_obj_is_kind_of((obj), (klass))) {\
98 ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\
99 rb_obj_classname(obj), rb_class2name(klass));\
103 #define OSSL_Check_Instance(obj, klass) do {\
104 if (!rb_obj_is_instance_of((obj), (klass))) {\
105 ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\
106 rb_obj_classname(obj), rb_class2name(klass));\
110 #define OSSL_Check_Same_Class(obj1, obj2) do {\
111 if (!rb_obj_is_instance_of((obj1), rb_obj_class(obj2))) {\
112 ossl_raise(rb_eTypeError, "wrong argument type");\
119 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
126 int string2hex(
const unsigned char *,
int,
char **,
int *);
138 #define ossl_str_adjust(str, p) \
140 int len = RSTRING_LENINT(str);\
141 int newlen = rb_long2int((p) - (unsigned char*)RSTRING_PTR(str));\
142 assert(newlen <= len);\
143 rb_str_set_len((str), newlen);\
155 #define OSSL_BIO_reset(bio) (void)BIO_reset((bio)); \
161 #define OSSL_ErrMsg() ERR_reason_error_string(ERR_get_error())
191 #if defined(HAVE_VA_ARGS_MACRO)
192 #define OSSL_Debug(...) do { \
193 if (dOSSL == Qtrue) { \
194 fprintf(stderr, "OSSL_DEBUG: "); \
195 fprintf(stderr, __VA_ARGS__); \
196 fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
200 #define OSSL_Warning(fmt, ...) do { \
201 OSSL_Debug((fmt), ##__VA_ARGS__); \
202 rb_warning((fmt), ##__VA_ARGS__); \
205 #define OSSL_Warn(fmt, ...) do { \
206 OSSL_Debug((fmt), ##__VA_ARGS__); \
207 rb_warn((fmt), ##__VA_ARGS__); \
211 #define OSSL_Debug ossl_debug
212 #define OSSL_Warning rb_warning
213 #define OSSL_Warn rb_warn
242 #if defined(__cplusplus)
VALUE ossl_x509name_sk2ary(STACK_OF(X509_NAME)*names)
int *VALUE ossl_x509_sk2ary(STACK_OF(X509)*certs)
void ossl_debug(const char *fmt,...)
VALUE ossl_exc_new(VALUE exc, const char *fmt,...)
STACK_OF(X509)*ossl_x509_ary2sk0(VALUE)
VALUE ossl_to_der_if_possible(VALUE obj)
unsigned char buf[MIME_BUF_SIZE]
VALUE ossl_x509crl_sk2ary(STACK_OF(X509_CRL)*crl)
VALUE rb_define_module_under(VALUE outer, const char *name)
VALUE ossl_buf2str(char *buf, int len)
void ossl_raise(VALUE exc, const char *fmt,...)
int ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
VALUE ossl_call_verify_cb_proc(struct ossl_verify_cb_args *args)
VALUE rb_define_module(const char *name)
int string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
int ossl_verify_cb(int ok, X509_STORE_CTX *ctx)
VALUE ossl_to_der(VALUE obj)