aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_ssl_session.c
diff options
context:
space:
mode:
authorZachary Scott <e@zzak.io>2015-01-05 11:59:50 -0800
committerZachary Scott <e@zzak.io>2015-01-05 11:59:50 -0800
commit2953dfd4ad925a669110fed1993d6e83b24e420f (patch)
tree05e4d2a6750e0ce6dd408c2b8f2f5bf597cfe54a /ext/openssl/ossl_ssl_session.c
parent77269de78e376981342127d30dc0b953b9bcd781 (diff)
downloadruby-openssl-2953dfd4ad925a669110fed1993d6e83b24e420f.tar.gz
Sync with ruby trunk
Diffstat (limited to 'ext/openssl/ossl_ssl_session.c')
-rw-r--r--ext/openssl/ossl_ssl_session.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c
index a7437caf..e1bbc6fb 100644
--- a/ext/openssl/ossl_ssl_session.c
+++ b/ext/openssl/ossl_ssl_session.c
@@ -4,25 +4,26 @@
#include "ossl.h"
-#define GetSSLSession(obj, sess) do { \
- Data_Get_Struct((obj), SSL_SESSION, (sess)); \
- if (!(sess)) { \
- ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
- } \
-} while (0)
-
-#define SafeGetSSLSession(obj, sess) do { \
- OSSL_Check_Kind((obj), cSSLSession); \
- GetSSLSession((obj), (sess)); \
-} while (0)
-
-
VALUE cSSLSession;
static VALUE eSSLSession;
+static void
+ossl_ssl_session_free(void *ptr)
+{
+ SSL_SESSION_free(ptr);
+}
+
+const rb_data_type_t ossl_ssl_session_type = {
+ "OpenSSL/SSL/Session",
+ {
+ 0, ossl_ssl_session_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
static VALUE ossl_ssl_session_alloc(VALUE klass)
{
- return Data_Wrap_Struct(klass, 0, SSL_SESSION_free, NULL);
+ return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
}
/*
@@ -43,7 +44,7 @@ static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1)
if (rb_obj_is_instance_of(arg1, cSSLSocket)) {
SSL *ssl;
- Data_Get_Struct(arg1, SSL, ssl);
+ GetSSL(arg1, ssl);
if (!ssl || (ctx = SSL_get1_session(ssl)) == NULL)
ossl_raise(eSSLSession, "no session available");
@@ -78,7 +79,11 @@ int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b)
if (a->ssl_version != b->ssl_version ||
a->session_id_length != b->session_id_length)
return 1;
- return memcmp(a->session_id,b-> session_id, a->session_id_length);
+#if defined(_WIN32)
+ return memcmp(a->session_id, b->session_id, a->session_id_length);
+#else
+ return CRYPTO_memcmp(a->session_id, b->session_id, a->session_id_length);
+#endif
}
#endif