1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.
3  *
4  * Portions created by Open Source Applications Foundation (OSAF) are
5  * Copyright (C) 2004-2006 OSAF. All Rights Reserved.
6  *
7  * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved.
8  *
9  */
10 
11 %module(threads=1) m2crypto
12 /* We really don't need threadblock (PyGILState_Ensure() etc.) anywhere.
13    Disable threadallow as well, only enable it for operations likely to
14    block. */
15 %nothreadblock;
16 %nothreadallow;
17 
18 #if SWIG_VERSION >= 0x030000
19 #define __WCHAR_MAX__ __WCHAR_MAX
20 #define __WCHAR_MIN__ __WCHAR_MIN
21 #endif
22 /* https://gitlab.com/m2crypto/m2crypto/issues/246 */
23 %ignore WCHAR_MAX;
24 %ignore WCHAR_MIN;
25 /* http://swig.10945.n7.nabble.com/SWIG-AsVal-wchar-t-error-td2264.html */
26 %{
SWIG_AsVal_wchar_t(PyObject * p,wchar_t * c)27 int SWIG_AsVal_wchar_t(PyObject *p, wchar_t *c) { return SWIG_OK; }
SWIG_From_wchar_t(wchar_t c)28 PyObject *SWIG_From_wchar_t(wchar_t c) { return SWIG_Py_Void(); }
29 %}
30 
31 %{
32 #ifdef _WIN32
33 #define _WINSOCKAPI_
34 #include <WinSock2.h>
35 #include <Windows.h>
36 #pragma comment(lib, "Ws2_32")
37 typedef unsigned __int64 uint64_t;
38 #endif
39 %}
40 
41 %{
42 #if defined __GNUC__ && __GNUC__ < 5
43 #pragma GCC diagnostic ignored "-Wunused-label"
44 #pragma GCC diagnostic warning "-Wstrict-prototypes"
45 #endif
46 
47 #include <openssl/err.h>
48 #include <openssl/rand.h>
49 #include <_lib.h>
50 #include <libcrypto-compat.h>
51 #include <py3k_compat.h>
52 
53 #include "compile.h"
54 
55 static PyObject *ssl_verify_cb_func;
56 static PyObject *ssl_info_cb_func;
57 static PyObject *ssl_set_tmp_dh_cb_func;
58 static PyObject *ssl_set_tmp_rsa_cb_func;
59 static PyObject *x509_store_verify_cb_func;
60 %}
61 
62 %include <openssl/opensslv.h>
63 
64 /* Bring in STACK_OF macro definition */
65 #ifdef _WIN32
66 %include <windows.i>
67 #endif
68 #ifndef LIBRESSL_VERSION_NUMBER
69 %include <openssl/e_os2.h>
70 #endif
71 %include <openssl/safestack.h>
72 
73 /* Bring in LHASH_OF macro definition */
74 /* XXX Can't include lhash.h where LHASH_OF is defined, because it includes
75    XXX stdio.h etc. which we fail to include. So we have to (re)define
76    XXX LHASH_OF here instead.
77 %include <openssl/lhash.h>
78 */
79 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
80 #define LHASH_OF(type) struct lhash_st_##type
81 #endif
82 
83 
84 %include constraints.i
85 %include _threads.i
86 %include _lib.i
87 %include _bio.i
88 %include _bn.i
89 %include _rand.i
90 %include _evp.i
91 %include _aes.i
92 %include _rc4.i
93 %include _dh.i
94 %include _rsa.i
95 %include _dsa.i
96 %include _ssl.i
97 %include _x509.i
98 %include _asn1.i
99 %include _pkcs7.i
100 %include _util.i
101 %include _ec.i
102 %include _engine.i
103 %include _objects.i
104 
105 #ifdef SWIG_VERSION
106 %constant int encrypt = 1;
107 %constant int decrypt = 0;
108 #endif
109 
110