diff --git a/jansson.pxd b/jansson.pxd index 93a4b8a..681d1f5 100644 --- a/jansson.pxd +++ b/jansson.pxd @@ -10,3 +10,6 @@ cdef extern from "jansson.h": void json_decref(json_t *json) json_t *json_loads(const char *input, size_t flags, json_error_t *error) char *json_dumps(const json_t *json, size_t flags) + + # misc + void json_object_seed(size_t seed) diff --git a/jose.pxd b/jose.pxd index 55c058b..b04b05e 100644 --- a/jose.pxd +++ b/jose.pxd @@ -6,6 +6,10 @@ cdef extern from "stdbool.h": ctypedef signed char bool +cdef extern from "openssl/evp.h": + void OpenSSL_add_all_algorithms() + + cdef extern from "jose/buf.h": ctypedef struct jose_buf_t: size_t size diff --git a/jose.pyx b/jose.pyx index cf84e9d..b5e22fb 100644 --- a/jose.pyx +++ b/jose.pyx @@ -416,3 +416,19 @@ def to_compact(flat): finally: jansson.json_decref(cjose) free(ret) + + +cdef init(): + # init jansson hash randomization seed + jansson.json_object_seed(0) + + # initialize OpenSSL + jose.OpenSSL_add_all_algorithms() + + # try to import _ssl to set up threading locks + try: + __import__('_ssl') + except ImportError: + pass + +init()