Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp support #204

Merged
merged 18 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ext/openssl/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ def find_openssl_library
have_func("SSL_CTX_get_security_level")
have_func("X509_get0_notBefore")
have_func("SSL_SESSION_get_protocol_version")
have_func("TS_STATUS_INFO_get0_status")
have_func("TS_STATUS_INFO_get0_text")
have_func("TS_STATUS_INFO_get0_failure_info")
have_func("TS_VERIFY_CTS_set_certs")
have_func("TS_VERIFY_CTX_set_store")
have_func("TS_VERIFY_CTX_add_flags")
have_func("TS_RESP_CTX_set_time_cb")
have_func("EVP_PBE_scrypt")
have_func("SSL_CTX_set_post_handshake_auth")

Expand Down
31 changes: 31 additions & 0 deletions ext/openssl/openssl_missing.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,35 @@ IMPL_PKEY_GETTER(EC_KEY, ec)
# define SSL_SESSION_get_protocol_version(s) ((s)->ssl_version)
#endif

#if !defined(HAVE_TS_STATUS_INFO_GET0_STATUS)
# define TS_STATUS_INFO_get0_status(a) ((a)->status)
#endif

#if !defined(HAVE_TS_STATUS_INFO_GET0_TEXT)
# define TS_STATUS_INFO_get0_text(a) ((a)->text)
#endif

#if !defined(HAVE_TS_STATUS_INFO_GET0_FAILURE_INFO)
# define TS_STATUS_INFO_get0_failure_info(a) ((a)->failure_info)
#endif

#if !defined(HAVE_TS_VERIFY_CTS_SET_CERTS)
# define TS_VERIFY_CTS_set_certs(ctx, crts) ((ctx)->certs=(crts))
#endif

#if !defined(HAVE_TS_VERIFY_CTX_SET_STORE)
# define TS_VERIFY_CTX_set_store(ctx, str) ((ctx)->store=(str))
#endif

#if !defined(HAVE_TS_VERIFY_CTX_ADD_FLAGS)
# define TS_VERIFY_CTX_add_flags(ctx, f) ((ctx)->flags |= (f))
#endif

#if !defined(HAVE_TS_RESP_CTX_SET_TIME_CB)
# define TS_RESP_CTX_set_time_cb(ctx, callback, dta) do { \
(ctx)->time_cb = (callback); \
(ctx)->time_cb_data = (dta); \
} while (0)
#endif

#endif /* _OSSL_OPENSSL_MISSING_H_ */
3 changes: 3 additions & 0 deletions ext/openssl/ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,9 @@ Init_openssl(void)
Init_ossl_pkey();
Init_ossl_rand();
Init_ossl_ssl();
#ifndef OPENSSL_NO_TS
Init_ossl_ts();
#endif
Init_ossl_x509();
Init_ossl_ocsp();
Init_ossl_engine();
Expand Down
6 changes: 6 additions & 0 deletions ext/openssl/ossl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include <openssl/rand.h>
#include <openssl/conf.h>
#include <openssl/conf_api.h>
#ifndef OPENSSL_NO_TS
#include <openssl/ts.h>
#endif
#include <openssl/crypto.h>
#if !defined(OPENSSL_NO_ENGINE)
# include <openssl/engine.h>
Expand Down Expand Up @@ -168,6 +171,9 @@ void ossl_debug(const char *, ...);
#include "ossl_pkey.h"
#include "ossl_rand.h"
#include "ossl_ssl.h"
#ifndef OPENSSL_NO_TS
#include "ossl_ts.h"
#endif
#include "ossl_version.h"
#include "ossl_x509.h"
#include "ossl_engine.h"
Expand Down
17 changes: 1 addition & 16 deletions ext/openssl/ossl_pkcs7.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@
*/
#include "ossl.h"

#define NewPKCS7(klass) \
TypedData_Wrap_Struct((klass), &ossl_pkcs7_type, 0)
#define SetPKCS7(obj, pkcs7) do { \
if (!(pkcs7)) { \
ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
} \
RTYPEDDATA_DATA(obj) = (pkcs7); \
} while (0)
#define GetPKCS7(obj, pkcs7) do { \
TypedData_Get_Struct((obj), PKCS7, &ossl_pkcs7_type, (pkcs7)); \
if (!(pkcs7)) { \
ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
} \
} while (0)

#define NewPKCS7si(klass) \
TypedData_Wrap_Struct((klass), &ossl_pkcs7_signer_info_type, 0)
#define SetPKCS7si(obj, p7si) do { \
Expand Down Expand Up @@ -75,7 +60,7 @@ ossl_pkcs7_free(void *ptr)
PKCS7_free(ptr);
}

static const rb_data_type_t ossl_pkcs7_type = {
const rb_data_type_t ossl_pkcs7_type = {
"OpenSSL/PKCS7",
{
0, ossl_pkcs7_free,
Expand Down
16 changes: 16 additions & 0 deletions ext/openssl/ossl_pkcs7.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@
#if !defined(_OSSL_PKCS7_H_)
#define _OSSL_PKCS7_H_

#define NewPKCS7(klass) \
TypedData_Wrap_Struct((klass), &ossl_pkcs7_type, 0)
#define SetPKCS7(obj, pkcs7) do { \
if (!(pkcs7)) { \
ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
} \
RTYPEDDATA_DATA(obj) = (pkcs7); \
} while (0)
#define GetPKCS7(obj, pkcs7) do { \
TypedData_Get_Struct((obj), PKCS7, &ossl_pkcs7_type, (pkcs7)); \
if (!(pkcs7)) { \
ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
} \
} while (0)

extern const rb_data_type_t ossl_pkcs7_type;
extern VALUE cPKCS7;
extern VALUE cPKCS7Signer;
extern VALUE cPKCS7Recipient;
Expand Down
Loading