From 9178c4d56b7270a6b813995f55a4828ce96256d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Wed, 13 Jan 2021 11:47:29 +0100 Subject: Move project to src/ layout --- .gitignore | 2 +- M2Crypto/ASN1.py | 252 - M2Crypto/AuthCookie.py | 168 - M2Crypto/BIO.py | 390 - M2Crypto/BN.py | 57 - M2Crypto/DH.py | 113 - M2Crypto/DSA.py | 448 - M2Crypto/EC.py | 460 - M2Crypto/EVP.py | 582 - M2Crypto/Engine.py | 150 - M2Crypto/Err.py | 76 - M2Crypto/RC4.py | 36 - M2Crypto/RSA.py | 466 - M2Crypto/Rand.py | 146 - M2Crypto/SMIME.py | 291 - M2Crypto/SSL/Checker.py | 296 - M2Crypto/SSL/Cipher.py | 59 - M2Crypto/SSL/Connection.py | 712 - M2Crypto/SSL/Context.py | 445 - M2Crypto/SSL/SSLServer.py | 65 - M2Crypto/SSL/Session.py | 69 - M2Crypto/SSL/TwistedProtocolWrapper.py | 490 - M2Crypto/SSL/__init__.py | 44 - M2Crypto/SSL/cb.py | 96 - M2Crypto/SSL/ssl_dispatcher.py | 43 - M2Crypto/SSL/timeout.py | 50 - M2Crypto/X509.py | 1443 -- M2Crypto/__init__.py | 41 - M2Crypto/callback.py | 11 - M2Crypto/ftpslib.py | 91 - M2Crypto/httpslib.py | 268 - M2Crypto/m2.py | 31 - M2Crypto/m2crypto.py | 67 - M2Crypto/m2urllib.py | 120 - M2Crypto/m2urllib2.py | 185 - M2Crypto/m2xmlrpclib.py | 78 - M2Crypto/six.py | 982 - M2Crypto/threading.py | 25 - M2Crypto/util.py | 89 - SWIG/Makefile | 25 - SWIG/_aes.i | 90 - SWIG/_asn1.i | 209 - SWIG/_bio.i | 545 - SWIG/_bn.i | 128 - SWIG/_dh.i | 186 - SWIG/_dsa.i | 400 - SWIG/_ec.i | 521 - SWIG/_engine.i | 208 - SWIG/_evp.i | 886 - SWIG/_lib.h | 31 - SWIG/_lib.i | 777 - SWIG/_lib11_compat.i | 458 - SWIG/_m2crypto.def | 2 - SWIG/_m2crypto.i | 106 - SWIG/_m2crypto_wrap.c | 34500 --------------------------- SWIG/_objects.i | 97 - SWIG/_pkcs7.i | 284 - SWIG/_py3k_compat.i | 43 - SWIG/_rand.i | 150 - SWIG/_rc4.i | 69 - SWIG/_rsa.i | 518 - SWIG/_ssl.i | 953 - SWIG/_threads.i | 67 - SWIG/_util.i | 60 - SWIG/_x509.i | 851 - SWIG/libcrypto-compat.h | 62 - SWIG/py3k_compat.h | 32 - setup.py | 19 +- src/M2Crypto/ASN1.py | 252 + src/M2Crypto/AuthCookie.py | 168 + src/M2Crypto/BIO.py | 390 + src/M2Crypto/BN.py | 57 + src/M2Crypto/DH.py | 113 + src/M2Crypto/DSA.py | 448 + src/M2Crypto/EC.py | 460 + src/M2Crypto/EVP.py | 582 + src/M2Crypto/Engine.py | 150 + src/M2Crypto/Err.py | 76 + src/M2Crypto/RC4.py | 36 + src/M2Crypto/RSA.py | 466 + src/M2Crypto/Rand.py | 146 + src/M2Crypto/SMIME.py | 291 + src/M2Crypto/SSL/Checker.py | 296 + src/M2Crypto/SSL/Cipher.py | 59 + src/M2Crypto/SSL/Connection.py | 712 + src/M2Crypto/SSL/Context.py | 445 + src/M2Crypto/SSL/SSLServer.py | 65 + src/M2Crypto/SSL/Session.py | 69 + src/M2Crypto/SSL/TwistedProtocolWrapper.py | 490 + src/M2Crypto/SSL/__init__.py | 44 + src/M2Crypto/SSL/cb.py | 96 + src/M2Crypto/SSL/ssl_dispatcher.py | 43 + src/M2Crypto/SSL/timeout.py | 50 + src/M2Crypto/X509.py | 1443 ++ src/M2Crypto/__init__.py | 41 + src/M2Crypto/callback.py | 11 + src/M2Crypto/ftpslib.py | 91 + src/M2Crypto/httpslib.py | 268 + src/M2Crypto/m2.py | 31 + src/M2Crypto/m2crypto.py | 67 + src/M2Crypto/m2urllib.py | 120 + src/M2Crypto/m2urllib2.py | 185 + src/M2Crypto/m2xmlrpclib.py | 78 + src/M2Crypto/six.py | 982 + src/M2Crypto/threading.py | 25 + src/M2Crypto/util.py | 89 + src/SWIG/Makefile | 25 + src/SWIG/_aes.i | 90 + src/SWIG/_asn1.i | 209 + src/SWIG/_bio.i | 545 + src/SWIG/_bn.i | 128 + src/SWIG/_dh.i | 186 + src/SWIG/_dsa.i | 400 + src/SWIG/_ec.i | 521 + src/SWIG/_engine.i | 208 + src/SWIG/_evp.i | 886 + src/SWIG/_lib.h | 31 + src/SWIG/_lib.i | 777 + src/SWIG/_lib11_compat.i | 458 + src/SWIG/_m2crypto.def | 2 + src/SWIG/_m2crypto.i | 106 + src/SWIG/_m2crypto_wrap.c | 34500 +++++++++++++++++++++++++++ src/SWIG/_objects.i | 97 + src/SWIG/_pkcs7.i | 284 + src/SWIG/_py3k_compat.i | 43 + src/SWIG/_rand.i | 150 + src/SWIG/_rc4.i | 69 + src/SWIG/_rsa.i | 518 + src/SWIG/_ssl.i | 953 + src/SWIG/_threads.i | 67 + src/SWIG/_util.i | 60 + src/SWIG/_x509.i | 851 + src/SWIG/libcrypto-compat.h | 62 + src/SWIG/py3k_compat.h | 32 + 134 files changed, 51705 insertions(+), 51702 deletions(-) delete mode 100644 M2Crypto/ASN1.py delete mode 100644 M2Crypto/AuthCookie.py delete mode 100644 M2Crypto/BIO.py delete mode 100644 M2Crypto/BN.py delete mode 100644 M2Crypto/DH.py delete mode 100644 M2Crypto/DSA.py delete mode 100644 M2Crypto/EC.py delete mode 100644 M2Crypto/EVP.py delete mode 100644 M2Crypto/Engine.py delete mode 100644 M2Crypto/Err.py delete mode 100644 M2Crypto/RC4.py delete mode 100644 M2Crypto/RSA.py delete mode 100644 M2Crypto/Rand.py delete mode 100644 M2Crypto/SMIME.py delete mode 100644 M2Crypto/SSL/Checker.py delete mode 100644 M2Crypto/SSL/Cipher.py delete mode 100644 M2Crypto/SSL/Connection.py delete mode 100644 M2Crypto/SSL/Context.py delete mode 100644 M2Crypto/SSL/SSLServer.py delete mode 100644 M2Crypto/SSL/Session.py delete mode 100644 M2Crypto/SSL/TwistedProtocolWrapper.py delete mode 100644 M2Crypto/SSL/__init__.py delete mode 100644 M2Crypto/SSL/cb.py delete mode 100644 M2Crypto/SSL/ssl_dispatcher.py delete mode 100644 M2Crypto/SSL/timeout.py delete mode 100644 M2Crypto/X509.py delete mode 100644 M2Crypto/__init__.py delete mode 100644 M2Crypto/callback.py delete mode 100644 M2Crypto/ftpslib.py delete mode 100644 M2Crypto/httpslib.py delete mode 100644 M2Crypto/m2.py delete mode 100644 M2Crypto/m2crypto.py delete mode 100644 M2Crypto/m2urllib.py delete mode 100644 M2Crypto/m2urllib2.py delete mode 100644 M2Crypto/m2xmlrpclib.py delete mode 100644 M2Crypto/six.py delete mode 100644 M2Crypto/threading.py delete mode 100644 M2Crypto/util.py delete mode 100644 SWIG/Makefile delete mode 100644 SWIG/_aes.i delete mode 100644 SWIG/_asn1.i delete mode 100644 SWIG/_bio.i delete mode 100644 SWIG/_bn.i delete mode 100644 SWIG/_dh.i delete mode 100644 SWIG/_dsa.i delete mode 100644 SWIG/_ec.i delete mode 100644 SWIG/_engine.i delete mode 100644 SWIG/_evp.i delete mode 100644 SWIG/_lib.h delete mode 100644 SWIG/_lib.i delete mode 100644 SWIG/_lib11_compat.i delete mode 100644 SWIG/_m2crypto.def delete mode 100644 SWIG/_m2crypto.i delete mode 100644 SWIG/_m2crypto_wrap.c delete mode 100644 SWIG/_objects.i delete mode 100644 SWIG/_pkcs7.i delete mode 100644 SWIG/_py3k_compat.i delete mode 100644 SWIG/_rand.i delete mode 100644 SWIG/_rc4.i delete mode 100644 SWIG/_rsa.i delete mode 100644 SWIG/_ssl.i delete mode 100644 SWIG/_threads.i delete mode 100644 SWIG/_util.i delete mode 100644 SWIG/_x509.i delete mode 100644 SWIG/libcrypto-compat.h delete mode 100644 SWIG/py3k_compat.h create mode 100644 src/M2Crypto/ASN1.py create mode 100644 src/M2Crypto/AuthCookie.py create mode 100644 src/M2Crypto/BIO.py create mode 100644 src/M2Crypto/BN.py create mode 100644 src/M2Crypto/DH.py create mode 100644 src/M2Crypto/DSA.py create mode 100644 src/M2Crypto/EC.py create mode 100644 src/M2Crypto/EVP.py create mode 100644 src/M2Crypto/Engine.py create mode 100644 src/M2Crypto/Err.py create mode 100644 src/M2Crypto/RC4.py create mode 100644 src/M2Crypto/RSA.py create mode 100644 src/M2Crypto/Rand.py create mode 100644 src/M2Crypto/SMIME.py create mode 100644 src/M2Crypto/SSL/Checker.py create mode 100644 src/M2Crypto/SSL/Cipher.py create mode 100644 src/M2Crypto/SSL/Connection.py create mode 100644 src/M2Crypto/SSL/Context.py create mode 100644 src/M2Crypto/SSL/SSLServer.py create mode 100644 src/M2Crypto/SSL/Session.py create mode 100644 src/M2Crypto/SSL/TwistedProtocolWrapper.py create mode 100644 src/M2Crypto/SSL/__init__.py create mode 100644 src/M2Crypto/SSL/cb.py create mode 100644 src/M2Crypto/SSL/ssl_dispatcher.py create mode 100644 src/M2Crypto/SSL/timeout.py create mode 100644 src/M2Crypto/X509.py create mode 100644 src/M2Crypto/__init__.py create mode 100644 src/M2Crypto/callback.py create mode 100644 src/M2Crypto/ftpslib.py create mode 100644 src/M2Crypto/httpslib.py create mode 100644 src/M2Crypto/m2.py create mode 100644 src/M2Crypto/m2crypto.py create mode 100644 src/M2Crypto/m2urllib.py create mode 100644 src/M2Crypto/m2urllib2.py create mode 100644 src/M2Crypto/m2xmlrpclib.py create mode 100644 src/M2Crypto/six.py create mode 100644 src/M2Crypto/threading.py create mode 100644 src/M2Crypto/util.py create mode 100644 src/SWIG/Makefile create mode 100644 src/SWIG/_aes.i create mode 100644 src/SWIG/_asn1.i create mode 100644 src/SWIG/_bio.i create mode 100644 src/SWIG/_bn.i create mode 100644 src/SWIG/_dh.i create mode 100644 src/SWIG/_dsa.i create mode 100644 src/SWIG/_ec.i create mode 100644 src/SWIG/_engine.i create mode 100644 src/SWIG/_evp.i create mode 100644 src/SWIG/_lib.h create mode 100644 src/SWIG/_lib.i create mode 100644 src/SWIG/_lib11_compat.i create mode 100644 src/SWIG/_m2crypto.def create mode 100644 src/SWIG/_m2crypto.i create mode 100644 src/SWIG/_m2crypto_wrap.c create mode 100644 src/SWIG/_objects.i create mode 100644 src/SWIG/_pkcs7.i create mode 100644 src/SWIG/_py3k_compat.i create mode 100644 src/SWIG/_rand.i create mode 100644 src/SWIG/_rc4.i create mode 100644 src/SWIG/_rsa.i create mode 100644 src/SWIG/_ssl.i create mode 100644 src/SWIG/_threads.i create mode 100644 src/SWIG/_util.i create mode 100644 src/SWIG/_x509.i create mode 100644 src/SWIG/libcrypto-compat.h create mode 100644 src/SWIG/py3k_compat.h diff --git a/.gitignore b/.gitignore index 0b90429..3b7faab 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ /build /dist /M2Crypto/*_m2crypto*.so -/M2Crypto.egg-info +M2Crypto.egg-info /.eggs/ /EGG-INFO /tests/randpool.dat diff --git a/M2Crypto/ASN1.py b/M2Crypto/ASN1.py deleted file mode 100644 index 37fd7a0..0000000 --- a/M2Crypto/ASN1.py +++ /dev/null @@ -1,252 +0,0 @@ -from __future__ import absolute_import - -""" -M2Crypto wrapper for OpenSSL ASN1 API. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - -Portions created by Open Source Applications Foundation (OSAF) are -Copyright (C) 2005 OSAF. All Rights Reserved. -""" - -import datetime -import time - -from M2Crypto import BIO, m2, six -from typing import Optional # noqa - -MBSTRING_FLAG = 0x1000 -MBSTRING_ASC = MBSTRING_FLAG | 1 -MBSTRING_BMP = MBSTRING_FLAG | 2 - - -class ASN1_Integer(object): - - m2_asn1_integer_free = m2.asn1_integer_free - - def __init__(self, asn1int, _pyfree=0): - # type: (ASN1_Integer, int) -> None - self.asn1int = asn1int - self._pyfree = _pyfree - - def __cmp__(self, other): - # type: (ASN1_Integer) -> int - if not isinstance(other, ASN1_Integer): - raise TypeError( - "Comparisons supported only between ANS1_Integer objects") - - return m2.asn1_integer_cmp(self.asn1int, other.asn1int) - - def __del__(self): - # type: () -> None - if self._pyfree: - self.m2_asn1_integer_free(self.asn1int) - - def __int__(self): - # type: () -> int - return m2.asn1_integer_get(self.asn1int) - - -class ASN1_String(object): - - m2_asn1_string_free = m2.asn1_string_free - - def __init__(self, asn1str, _pyfree=0): - # type: (ASN1_String, int) -> None - self.asn1str = asn1str - self._pyfree = _pyfree - - def __bytes__(self): - # type: () -> bytes - buf = BIO.MemoryBuffer() - m2.asn1_string_print(buf.bio_ptr(), self.asn1str) - return buf.read_all() - - def __str__(self): - # type: () -> str - return six.ensure_text(self.__bytes__()) - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_asn1_string_free(self.asn1str) - - def _ptr(self): - return self.asn1str - - def as_text(self, flags=0): - # type: (int) -> str - """Output an ASN1_STRING structure according to the set flags. - - :param flags: determine the format of the output by using - predetermined constants, see ASN1_STRING_print_ex(3) - manpage for their meaning. - :return: output an ASN1_STRING structure. - """ - buf = BIO.MemoryBuffer() - m2.asn1_string_print_ex(buf.bio_ptr(), self.asn1str, flags) - return six.ensure_text(buf.read_all()) - - -class ASN1_Object(object): - - m2_asn1_object_free = m2.asn1_object_free - - def __init__(self, asn1obj, _pyfree=0): - # type: (ASN1_Object, int) -> None - self.asn1obj = asn1obj - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if self._pyfree: - self.m2_asn1_object_free(self.asn1obj) - - def _ptr(self): - return self.asn1obj - - -class _UTC(datetime.tzinfo): - def tzname(self, dt): - # type: (Optional[datetime.datetime]) -> str - return "UTC" - - def dst(self, dt): - # type: (Optional[datetime.datetime]) -> datetime.timedelta - return datetime.timedelta(0) - - def utcoffset(self, dt): - # type: (Optional[datetime.datetime]) -> datetime.timedelta - return datetime.timedelta(0) - - def __repr__(self): - return "" % self.tzname(None) - - -UTC = _UTC() # type: _UTC - - -class LocalTimezone(datetime.tzinfo): - """Localtimezone from datetime manual.""" - - def __init__(self): - # type: () -> None - self._stdoffset = datetime.timedelta(seconds=-time.timezone) - if time.daylight: - self._dstoffset = datetime.timedelta(seconds=-time.altzone) - else: - self._dstoffset = self._stdoffset - self._dstdiff = self._dstoffset - self._stdoffset - - def utcoffset(self, dt): - # type: (datetime.datetime) -> datetime.timedelta - if self._isdst(dt): - return self._dstoffset - else: - return self._stdoffset - - def dst(self, dt): - # type: (datetime.datetime) -> datetime.timedelta - if self._isdst(dt): - return self._dstdiff - else: - return datetime.timedelta(0) - - def tzname(self, dt): - # type: (datetime.datetime) -> str - return time.tzname[self._isdst(dt).real] - - def _isdst(self, dt): - # type: (datetime.datetime) -> bool - tt = (dt.year, dt.month, dt.day, - dt.hour, dt.minute, dt.second, - dt.weekday(), 0, -1) - stamp = time.mktime(tt) - tt = time.localtime(stamp) - return tt.tm_isdst > 0 - - -class ASN1_TIME(object): - _ssl_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", - "Sep", "Oct", "Nov", "Dec"] - m2_asn1_time_free = m2.asn1_time_free - - def __init__(self, asn1_time=None, _pyfree=0, asn1_utctime=None): - # type: (Optional[ASN1_TIME], Optional[int], Optional[ASN1_TIME]) -> None - # handle old keyword parameter - if asn1_time is None: - asn1_time = asn1_utctime - if asn1_time is not None: - assert m2.asn1_time_type_check(asn1_time), \ - "'asn1_time' type error'" - self.asn1_time = asn1_time - self._pyfree = _pyfree - else: - self.asn1_time = m2.asn1_time_new() - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_asn1_time_free(self.asn1_time) - - def __str__(self): - # type: () -> str - assert m2.asn1_time_type_check(self.asn1_time), \ - "'asn1_time' type error'" - buf = BIO.MemoryBuffer() - m2.asn1_time_print(buf.bio_ptr(), self.asn1_time) - return six.ensure_text(buf.read_all()) - - def _ptr(self): - assert m2.asn1_time_type_check(self.asn1_time), \ - "'asn1_time' type error'" - return self.asn1_time - - def set_string(self, string): - # type: (bytes) -> int - """Set time from UTC string.""" - assert m2.asn1_time_type_check(self.asn1_time), \ - "'asn1_time' type error'" - return m2.asn1_time_set_string(self.asn1_time, string) - - def set_time(self, time): - # type: (int) -> ASN1_TIME - """Set time from seconds since epoch (int).""" - assert m2.asn1_time_type_check(self.asn1_time), \ - "'asn1_time' type error'" - return m2.asn1_time_set(self.asn1_time, time) - - def get_datetime(self): - # type: () -> ASN1_TIME - date = str(self) - - timezone = None - if ' ' not in date: - raise ValueError("Invalid date: %s" % date) - month, rest = date.split(' ', 1) - if month not in self._ssl_months: - raise ValueError("Invalid date %s: Invalid month: %s" % - (date, month)) - if rest.endswith(' GMT'): - timezone = UTC - rest = rest[:-4] - if '.' in rest: - dt = datetime.datetime.strptime(rest, "%d %H:%M:%S.%f %Y") - else: - dt = datetime.datetime.strptime(rest, "%d %H:%M:%S %Y") - dt = dt.replace(month=self._ssl_months.index(month) + 1) - if timezone: - dt = dt.replace(tzinfo=UTC) - return dt - - def set_datetime(self, date): - # type: (datetime.datetime) -> ASN1_TIME - local = LocalTimezone() - if date.tzinfo is None: - date = date.replace(tzinfo=local) - date = date.astimezone(local) - return self.set_time(int(time.mktime(date.timetuple()))) - - -ASN1_UTCTIME = ASN1_TIME diff --git a/M2Crypto/AuthCookie.py b/M2Crypto/AuthCookie.py deleted file mode 100644 index ff6df2b..0000000 --- a/M2Crypto/AuthCookie.py +++ /dev/null @@ -1,168 +0,0 @@ -from __future__ import absolute_import - -"""Secure Authenticator Cookies - -Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" - -import logging -import re -import time - -from M2Crypto import Rand, m2, six, util -from M2Crypto.six.moves.http_cookies import SimpleCookie - -from typing import re as type_re, AnyStr, Optional, Union # noqa - -_MIX_FORMAT = 'exp=%f&data=%s&digest=' -_MIX_RE = re.compile(r'exp=(\d+\.\d+)&data=(.+)&digest=(\S*)') - -log = logging.getLogger(__name__) - - -def mix(expiry, data, format=_MIX_FORMAT): - # type: (float, AnyStr, str) -> AnyStr - return format % (expiry, data) - - -def unmix(dough, regex=_MIX_RE): - # type: (AnyStr, type_re) -> object - mo = regex.match(dough) - if mo: - return float(mo.group(1)), mo.group(2) - else: - return None - - -def unmix3(dough, regex=_MIX_RE): - # type: (AnyStr, type_re) -> Optional[tuple[float, AnyStr, AnyStr]] - mo = regex.match(dough) - if mo: - return float(mo.group(1)), mo.group(2), mo.group(3) - else: - return None - - -_TOKEN = '_M2AUTH_' # type: str - - -class AuthCookieJar(object): - - _keylen = 20 # type: int - - def __init__(self): - # type: () -> None - self._key = Rand.rand_bytes(self._keylen) - - def _hmac(self, key, data): - # type: (bytes, str) -> str - return util.bin_to_hex(m2.hmac(key, six.ensure_binary(data), m2.sha1())) - - def makeCookie(self, expiry, data): - # type: (float, str) -> AuthCookie - """ - Make a cookie - - :param expiry: expiration time (float in seconds) - :param data: cookie content - :return: AuthCookie object - """ - if not isinstance(expiry, (six.integer_types, float)): - raise ValueError('Expiration time must be number, not "%s' % expiry) - dough = mix(expiry, data) - return AuthCookie(expiry, data, dough, self._hmac(self._key, dough)) - - def isGoodCookie(self, cookie): - # type: (AuthCookie) -> Union[bool, int] - assert isinstance(cookie, AuthCookie) - if cookie.isExpired(): - return 0 - c = self.makeCookie(cookie._expiry, cookie._data) - return (c._expiry == cookie._expiry) \ - and (c._data == cookie._data) \ - and (c._mac == cookie._mac) \ - and (c.output() == cookie.output()) - - def isGoodCookieString(self, cookie_str, _debug=False): - # type: (Union[dict, bytes], bool) -> Union[bool, int] - c = SimpleCookie() - c.load(cookie_str) - if _TOKEN not in c: - log.debug('_TOKEN not in c (keys = %s)', dir(c)) - return 0 - undough = unmix3(c[_TOKEN].value) - if undough is None: - log.debug('undough is None') - return 0 - exp, data, mac = undough - c2 = self.makeCookie(exp, data) - if _debug and (c2._mac == mac): - log.error('cookie_str = %s', cookie_str) - log.error('c2.isExpired = %s', c2.isExpired()) - log.error('mac = %s', mac) - log.error('c2._mac = %s', c2._mac) - log.error('c2._mac == mac: %s', str(c2._mac == mac)) - return (not c2.isExpired()) and (c2._mac == mac) - - -class AuthCookie(object): - - def __init__(self, expiry, data, dough, mac): - # type: (float, str, str, str) -> None - """ - Create new authentication cookie - - :param expiry: expiration time (in seconds) - :param data: cookie payload (as a string) - :param dough: expiry & data concatenated to URL compliant - string - :param mac: SHA1-based HMAC of dough and random key - """ - self._expiry = expiry - self._data = data - self._mac = mac - self._cookie = SimpleCookie() - self._cookie[_TOKEN] = '%s%s' % (dough, mac) - self._name = '%s%s' % (dough, mac) # WebKit only. - - def expiry(self): - # type: () -> float - """Return the cookie's expiry time.""" - return self._expiry - - def data(self): - # type: () -> str - """Return the data portion of the cookie.""" - return self._data - - def mac(self): - # type: () -> str - """Return the cookie's MAC.""" - return self._mac - - def output(self, header="Set-Cookie:"): - # type: (Optional[str]) -> str - """Return the cookie's output in "Set-Cookie" format.""" - return self._cookie.output(header=header) - - def value(self): - # type: () -> str - """Return the cookie's output minus the "Set-Cookie: " portion. - """ - return self._cookie[_TOKEN].value - - def isExpired(self): - # type: () -> bool - """Return 1 if the cookie has expired, 0 otherwise.""" - return isinstance(self._expiry, (float, six.integer_types)) and \ - (time.time() > self._expiry) - - # Following two methods are for WebKit only. - # I may wish to push them to WKAuthCookie, but they are part - # of the API now. Oh well. - def name(self): - # type: () -> str - return self._name - - def headerValue(self): - # type: () -> str - return self.value() diff --git a/M2Crypto/BIO.py b/M2Crypto/BIO.py deleted file mode 100644 index 090064b..0000000 --- a/M2Crypto/BIO.py +++ /dev/null @@ -1,390 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL BIO API. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" - -import io -import logging -from typing import Any, AnyStr, Callable, Iterable, Optional, Union # noqa - -from M2Crypto import m2, six - -log = logging.getLogger('BIO') - - -class BIOError(ValueError): - pass - - -m2.bio_init(BIOError) - - -class BIO(object): - """Abstract object interface to the BIO API.""" - - m2_bio_free = m2.bio_free - - def __init__(self, bio=None, _pyfree=0, _close_cb=None): - # type: (Optional[BIO], int, Optional[Callable]) -> None - self.bio = bio - self._pyfree = _pyfree - self._close_cb = _close_cb - self.closed = 0 - self.write_closed = 0 - - def __del__(self): - if self._pyfree: - self.m2_bio_free(self.bio) - - def _ptr(self): - return self.bio - - # Deprecated. - bio_ptr = _ptr - - def fileno(self): - # type: () -> int - return m2.bio_get_fd(self.bio) - - def readable(self): - # type: () -> bool - return not self.closed - - def read(self, size=None): - # type: (int) -> Union[bytes, bytearray] - if not self.readable(): - raise IOError('cannot read') - if size is None: - buf = bytearray() - while 1: - data = m2.bio_read(self.bio, 4096) - if not data: - break - buf += data - return buf - elif size == 0: - return b'' - elif size < 0: - raise ValueError('read count is negative') - else: - return bytes(m2.bio_read(self.bio, size)) - - def readline(self, size=4096): - # type: (int) -> bytes - if not self.readable(): - raise IOError('cannot read') - buf = m2.bio_gets(self.bio, size) - buf = '' if buf is None else buf - return six.ensure_binary(buf) - - def readlines(self, sizehint='ignored'): - # type: (Union[AnyStr, int]) -> Iterable[bytes] - if not self.readable(): - raise IOError('cannot read') - lines = [] - while 1: - buf = m2.bio_gets(self.bio, 4096) - if buf is None: - break - lines.append(six.ensure_binary(buf)) - return lines - - def writeable(self): - # type: () -> bool - return (not self.closed) and (not self.write_closed) - - def write(self, data): - # type: (AnyStr) -> int - """Write data to BIO. - - :return: either data written, or [0, -1] for nothing written, - -2 not implemented - """ - if not self.writeable(): - raise IOError('cannot write') - if isinstance(data, six.text_type): - data = data.encode('utf8') - return m2.bio_write(self.bio, data) - - def write_close(self): - # type: () -> None - self.write_closed = 1 - - def flush(self): - # type: () -> None - """Flush the buffers. - - :return: 1 for success, and 0 or -1 for failure - """ - m2.bio_flush(self.bio) - - def reset(self): - # type: () -> int - """Set the bio to its initial state. - - :return: 1 for success, and 0 or -1 for failure - """ - return m2.bio_reset(self.bio) - - def close(self): - # type: () -> None - self.closed = 1 - if self._close_cb: - self._close_cb() - - def should_retry(self): - # type: () -> int - """ - Can the call be attempted again, or was there an error - ie do_handshake - - """ - return m2.bio_should_retry(self.bio) - - def should_read(self): - # type: () -> int - """Should we read more data?""" - - return m2.bio_should_read(self.bio) - - def should_write(self): - # type: () -> int - """Should we write more data?""" - return m2.bio_should_write(self.bio) - - def tell(self): - """Return the current offset.""" - return m2.bio_tell(self.bio) - - def seek(self, off): - """Seek to the specified absolute offset.""" - return m2.bio_seek(self.bio, off) - - def __enter__(self): - return self - - def __exit__(self, *args): - # type: (*Any) -> int - self.close() - - -class MemoryBuffer(BIO): - """Object interface to BIO_s_mem. - - Empirical testing suggests that this class performs less well than - cStringIO, because cStringIO is implemented in C, whereas this class - is implemented in Python. Thus, the recommended practice is to use - cStringIO for regular work and convert said cStringIO object to - a MemoryBuffer object only when necessary. - """ - - def __init__(self, data=None): - # type: (Optional[bytes]) -> None - super(MemoryBuffer, self).__init__(self) - if data is not None and not isinstance(data, bytes): - raise TypeError( - "data must be bytes or None, not %s" % (type(data).__name__, )) - self.bio = m2.bio_new(m2.bio_s_mem()) - self._pyfree = 1 - if data is not None: - m2.bio_write(self.bio, data) - - def __len__(self): - # type: () -> int - return m2.bio_ctrl_pending(self.bio) - - def read(self, size=0): - # type: (int) -> bytes - if not self.readable(): - raise IOError('cannot read') - if size: - return m2.bio_read(self.bio, size) - else: - return m2.bio_read(self.bio, m2.bio_ctrl_pending(self.bio)) - - # Backwards-compatibility. - getvalue = read_all = read - - def write_close(self): - # type: () -> None - super(MemoryBuffer, self).write_close() - m2.bio_set_mem_eof_return(self.bio, 0) - - close = write_close - - -class File(BIO): - """Object interface to BIO_s_pyfd. - - This class interfaces Python to OpenSSL functions that expect BIO. For - general file manipulation in Python, use Python's builtin file object. - """ - - def __init__(self, pyfile, close_pyfile=1, mode='rb'): - # type: (Union[io.BytesIO, AnyStr], int, AnyStr) -> None - super(File, self).__init__(self, _pyfree=1) - - if isinstance(pyfile, six.string_types): - pyfile = open(pyfile, mode) - - # This is for downward compatibility, but I don't think, that it is - # good practice to have two handles for the same file. Whats about - # concurrent write access? Last write, last wins? Especially since Py3 - # has its own buffer management. See: - # - # https://docs.python.org/3.3/c-api/file.html - # - pyfile.flush() - self.fname = pyfile.name - self.pyfile = pyfile - # Be wary of https://github.com/openssl/openssl/pull/1925 - # BIO_new_fd is NEVER to be used before OpenSSL 1.1.1 - if hasattr(m2, "bio_new_pyfd"): - self.bio = m2.bio_new_pyfd(pyfile.fileno(), m2.bio_noclose) - else: - self.bio = m2.bio_new_pyfile(pyfile, m2.bio_noclose) - - self.close_pyfile = close_pyfile - self.closed = False - - def flush(self): - # type: () -> None - super(File, self).flush() - self.pyfile.flush() - - def close(self): - # type: () -> None - self.flush() - super(File, self).close() - if self.close_pyfile: - self.pyfile.close() - - def reset(self): - # type: () -> int - """Set the bio to its initial state. - - :return: 0 for success, and -1 for failure - """ - return super(File, self).reset() - - def __del__(self): - if not self.closed: - m2.bio_free(self.bio) - - -def openfile(filename, mode='rb'): - # type: (AnyStr, AnyStr) -> File - try: - f = open(filename, mode) - except IOError as ex: - raise BIOError(ex.args) - - return File(f) - - -class IOBuffer(BIO): - """Object interface to BIO_f_buffer. - - Its principal function is to be BIO_push()'ed on top of a BIO_f_ssl, so - that makefile() of said underlying SSL socket works. - """ - - m2_bio_pop = m2.bio_pop - m2_bio_free = m2.bio_free - - def __init__(self, under_bio, mode='rwb', _pyfree=1): - # type: (BIO, str, int) -> None - super(IOBuffer, self).__init__(self, _pyfree=_pyfree) - self.io = m2.bio_new(m2.bio_f_buffer()) - self.bio = m2.bio_push(self.io, under_bio._ptr()) - # This reference keeps the underlying BIO alive while we're not closed. - self._under_bio = under_bio - if 'w' in mode: - self.write_closed = 0 - else: - self.write_closed = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_bio_pop(self.bio) - self.m2_bio_free(self.io) - - def close(self): - # type: () -> None - BIO.close(self) - - -class CipherStream(BIO): - """Object interface to BIO_f_cipher.""" - - SALT_LEN = m2.PKCS5_SALT_LEN - - m2_bio_pop = m2.bio_pop - m2_bio_free = m2.bio_free - - def __init__(self, obio): - # type: (BIO) -> None - super(CipherStream, self).__init__(self, _pyfree=1) - self.obio = obio - self.bio = m2.bio_new(m2.bio_f_cipher()) - self.closed = 0 - - def __del__(self): - # type: () -> None - if not getattr(self, 'closed', 1): - self.close() - - def close(self): - # type: () -> None - self.m2_bio_pop(self.bio) - self.m2_bio_free(self.bio) - self.closed = 1 - - def write_close(self): - # type: () -> None - self.obio.write_close() - - def set_cipher(self, algo, key, iv, op): - # type: (str, AnyStr, AnyStr, int) -> None - cipher = getattr(m2, algo, None) - if cipher is None: - raise ValueError('unknown cipher', algo) - else: - if not isinstance(key, bytes): - key = key.encode('utf8') - if not isinstance(iv, bytes): - iv = iv.encode('utf8') - m2.bio_set_cipher(self.bio, cipher(), key, iv, int(op)) - m2.bio_push(self.bio, self.obio._ptr()) - - -class SSLBio(BIO): - """Object interface to BIO_f_ssl.""" - - def __init__(self, _pyfree=1): - # type: (int) -> None - super(SSLBio, self).__init__(self, _pyfree=_pyfree) - self.bio = m2.bio_new(m2.bio_f_ssl()) - self.closed = 0 - - def set_ssl(self, conn, close_flag=m2.bio_noclose): - ## type: (Connection, int) -> None - """ - Sets the bio to the SSL pointer which is - contained in the connection object. - """ - self._pyfree = 0 - m2.bio_set_ssl(self.bio, conn.ssl, close_flag) - if close_flag == m2.bio_noclose: - conn.set_ssl_close_flag(m2.bio_close) - - def do_handshake(self): - # type: () -> int - """Do the handshake. - - Return 1 if the handshake completes - Return 0 or a negative number if there is a problem - """ - return m2.bio_do_handshake(self.bio) diff --git a/M2Crypto/BN.py b/M2Crypto/BN.py deleted file mode 100644 index 0d8c3b2..0000000 --- a/M2Crypto/BN.py +++ /dev/null @@ -1,57 +0,0 @@ -from __future__ import absolute_import - -""" -M2Crypto wrapper for OpenSSL BN (BIGNUM) API. - -Copyright (c) 2005 Open Source Applications Foundation. All rights reserved. -""" - -from M2Crypto import m2 -from typing import Optional # noqa - - -def rand(bits, top=-1, bottom=0): - # type: (int, int, int) -> Optional[int] - """ - Generate cryptographically strong random number. - - :param bits: Length of random number in bits. - :param top: If -1, the most significant bit can be 0. If 0, the most - significant bit is 1, and if 1, the two most significant - bits will be 1. - :param bottom: If bottom is true, the number will be odd. - """ - return m2.bn_rand(bits, top, bottom) - - -def rand_range(range): - # type: (int) -> int - """ - Generate a random number in a range. - - :param range: Upper limit for range. - :return: A random number in the range [0, range) - """ - return m2.bn_rand_range(range) - - -def randfname(length): - # type: (int) -> str - """ - Return a random filename, which is simply a string where all - the characters are from the set [a-zA-Z0-9]. - - :param length: Length of filename to return. - :return: random filename string - """ - import warnings - warnings.warn( - "Don't use BN.randfname(), use tempfile methods instead.", - DeprecationWarning, stacklevel=2) - letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890' - lettersLen = len(letters) - fname = [] # type: list - for x in range(length): - fname += [letters[m2.bn_rand_range(lettersLen)]] - - return ''.join(fname) diff --git a/M2Crypto/DH.py b/M2Crypto/DH.py deleted file mode 100644 index 38ea0d5..0000000 --- a/M2Crypto/DH.py +++ /dev/null @@ -1,113 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL DH API. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -from M2Crypto import BIO, m2 -from M2Crypto.util import genparam_callback -from typing import AnyStr, Callable, Optional # noqa - - -class DHError(Exception): - pass - - -m2.dh_init(DHError) - - -class DH(object): - """Object interface to the Diffie-Hellman key exchange protocol. - """ - - m2_dh_free = m2.dh_free - - def __init__(self, dh, _pyfree=0): - # type: (bytes, int) -> None - assert m2.dh_type_check(dh) - self.dh = dh - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_dh_free(self.dh) - - def __len__(self): - # type: () -> int - assert m2.dh_type_check(self.dh), "'dh' type error" - return int(m2.dh_size(self.dh)) - - def __getattr__(self, name): - # type: (str) -> bytes - if name in ('p', 'g', 'pub', 'priv'): - method = getattr(m2, 'dh_get_%s' % (name,)) - assert m2.dh_type_check(self.dh), "'dh' type error" - return method(self.dh) - else: - raise AttributeError - - def __setattr__(self, name, value): - # type: (str, bytes) -> bytes - if name in ('p', 'g'): - raise DHError('set (p, g) via set_params()') - elif name in ('pub', 'priv'): - raise DHError('generate (pub, priv) via gen_key()') - else: - self.__dict__[name] = value - - def _ptr(self): - return self.dh - - def check_params(self): - # type: () -> int - assert m2.dh_type_check(self.dh), "'dh' type error" - return m2.dh_check(self.dh) - - def gen_key(self): - # type: () -> None - assert m2.dh_type_check(self.dh), "'dh' type error" - m2.dh_generate_key(self.dh) - - def compute_key(self, pubkey): - # type: (bytes) -> bytes - assert m2.dh_type_check(self.dh), "'dh' type error" - return m2.dh_compute_key(self.dh, pubkey) - - def print_params(self, bio): - # type: (BIO.BIO) -> int - assert m2.dh_type_check(self.dh), "'dh' type error" - return m2.dhparams_print(bio._ptr(), self.dh) - - -def gen_params(plen, g, callback=genparam_callback): - # type: (int, int, Optional[Callable]) -> DH - dh_parms = m2.dh_generate_parameters(plen, g, callback) - dh_obj = DH(dh_parms, 1) - return dh_obj - - -def load_params(file): - # type: (AnyStr) -> DH - with BIO.openfile(file) as bio: - return load_params_bio(bio) - - -def load_params_bio(bio): - # type: (BIO.BIO) -> DH - return DH(m2.dh_read_parameters(bio._ptr()), 1) - - -def set_params(p, g): - # type: (bytes, bytes) -> DH - dh = m2.dh_new() - m2.dh_set_pg(dh, p, g) - return DH(dh, 1) - - -# def free_params(cptr): -# m2.dh_free(cptr) - - -DH_GENERATOR_2 = m2.DH_GENERATOR_2 -DH_GENERATOR_5 = m2.DH_GENERATOR_5 diff --git a/M2Crypto/DSA.py b/M2Crypto/DSA.py deleted file mode 100644 index d4f2073..0000000 --- a/M2Crypto/DSA.py +++ /dev/null @@ -1,448 +0,0 @@ -from __future__ import absolute_import, print_function - -""" - M2Crypto wrapper for OpenSSL DSA API. - - Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. - - Portions created by Open Source Applications Foundation (OSAF) are - Copyright (C) 2004 OSAF. All Rights Reserved. -""" - -from M2Crypto import BIO, m2, util -from typing import Any, AnyStr, Callable, Tuple # noqa - - -class DSAError(Exception): - pass - - -m2.dsa_init(DSAError) - - -class DSA(object): - - """ - This class is a context supporting DSA key and parameter - values, signing and verifying. - - Simple example:: - - from M2Crypto import EVP, DSA, util - - message = 'Kilroy was here!' - md = EVP.MessageDigest('sha1') - md.update(message) - digest = md.final() - - dsa = DSA.gen_params(1024) - dsa.gen_key() - r, s = dsa.sign(digest) - good = dsa.verify(digest, r, s) - if good: - print(' ** success **') - else: - print(' ** verification failed **') - """ - - m2_dsa_free = m2.dsa_free - - def __init__(self, dsa, _pyfree=0): - # type: (bytes, int) -> None - """ - Use one of the factory functions to create an instance. - :param dsa: binary representation of OpenSSL DSA type - """ - assert m2.dsa_type_check(dsa), "'dsa' type error" - self.dsa = dsa - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_dsa_free(self.dsa) - - def __len__(self): - # type: () -> int - """ - Return the key length. - - :return: the DSA key length in bits - """ - assert m2.dsa_type_check(self.dsa), "'dsa' type error" - return m2.dsa_keylen(self.dsa) - - def __getattr__(self, name): - # type: (str) -> bytes - """ - Return specified DSA parameters and key values. - - :param name: name of variable to be returned. Must be - one of 'p', 'q', 'g', 'pub', 'priv'. - :return: value of specified variable (a "byte string") - """ - if name in ['p', 'q', 'g', 'pub', 'priv']: - method = getattr(m2, 'dsa_get_%s' % (name,)) - assert m2.dsa_type_check(self.dsa), "'dsa' type error" - return method(self.dsa) - else: - raise AttributeError - - def __setattr__(self, name, value): - # type: (str, bytes) -> None - if name in ['p', 'q', 'g']: - raise DSAError('set (p, q, g) via set_params()') - elif name in ['pub', 'priv']: - raise DSAError('generate (pub, priv) via gen_key()') - else: - self.__dict__[name] = value - - def set_params(self, p, q, g): - # type: (bytes, bytes, bytes) -> None - """ - Set new parameters. - - :param p: MPI binary representation ... format that consists of - the number's length in bytes represented as a 4-byte - big-endian number, and the number itself in big-endian - format, where the most significant bit signals - a negative number (the representation of numbers with - the MSB set is prefixed with null byte). - :param q: ditto - :param g: ditto - - @warning: This does not change the private key, so it may be - unsafe to use this method. It is better to use - gen_params function to create a new DSA object. - """ - m2.dsa_set_pqg(self.dsa, p, q, g) - - def gen_key(self): - # type: () -> None - """ - Generate a key pair. - """ - assert m2.dsa_type_check(self.dsa), "'dsa' type error" - m2.dsa_gen_key(self.dsa) - - def save_params(self, filename): - # type: (AnyStr) -> int - """ - Save the DSA parameters to a file. - - :param filename: Save the DSA parameters to this file. - :return: 1 (true) if successful - """ - with BIO.openfile(filename, 'wb') as bio: - ret = m2.dsa_write_params_bio(self.dsa, bio._ptr()) - - return ret - - def save_params_bio(self, bio): - # type: (BIO.BIO) -> int - """ - Save DSA parameters to a BIO object. - - :param bio: Save DSA parameters to this object. - :return: 1 (true) if successful - """ - return m2.dsa_write_params_bio(self.dsa, bio._ptr()) - - def save_key(self, filename, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (AnyStr, str, Callable) -> int - """ - Save the DSA key pair to a file. - - :param filename: Save the DSA key pair to this file. - :param cipher: name of symmetric key algorithm and mode - to encrypt the private key. - :return: 1 (true) if successful - """ - with BIO.openfile(filename, 'wb') as bio: - ret = self.save_key_bio(bio, cipher, callback) - - return ret - - def save_key_bio(self, bio, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (BIO.BIO, str, Callable) -> int - """ - Save DSA key pair to a BIO object. - - :param bio: Save DSA parameters to this object. - :param cipher: name of symmetric key algorithm and mode - to encrypt the private key. - :return: 1 (true) if successful - """ - if cipher is None: - return m2.dsa_write_key_bio_no_cipher(self.dsa, - bio._ptr(), callback) - else: - ciph = getattr(m2, cipher, None) - if ciph is None: - raise DSAError('no such cipher: %s' % cipher) - else: - ciph = ciph() - return m2.dsa_write_key_bio(self.dsa, bio._ptr(), ciph, callback) - - def save_pub_key(self, filename): - # type: (AnyStr) -> int - """ - Save the DSA public key (with parameters) to a file. - - :param filename: Save DSA public key (with parameters) - to this file. - :return: 1 (true) if successful - """ - with BIO.openfile(filename, 'wb') as bio: - ret = self.save_pub_key_bio(bio) - - return ret - - def save_pub_key_bio(self, bio): - # type: (BIO.BIO) -> int - """ - Save DSA public key (with parameters) to a BIO object. - - :param bio: Save DSA public key (with parameters) - to this object. - :return: 1 (true) if successful - """ - return m2.dsa_write_pub_key_bio(self.dsa, bio._ptr()) - - def sign(self, digest): - # type: (bytes) -> Tuple[bytes, bytes] - """ - Sign the digest. - - :param digest: SHA-1 hash of message (same as output - from MessageDigest, a "byte string") - :return: DSA signature, a tuple of two values, r and s, - both "byte strings". - """ - assert self.check_key(), 'key is not initialised' - return m2.dsa_sign(self.dsa, digest) - - def verify(self, digest, r, s): - # type: (bytes, bytes, bytes) -> int - """ - Verify a newly calculated digest against the signature - values r and s. - - :param digest: SHA-1 hash of message (same as output - from MessageDigest, a "byte string") - :param r: r value of the signature, a "byte string" - :param s: s value of the signature, a "byte string" - :return: 1 (true) if verify succeeded, 0 if failed - """ - assert self.check_key(), 'key is not initialised' - return m2.dsa_verify(self.dsa, digest, r, s) - - def sign_asn1(self, digest): - assert self.check_key(), 'key is not initialised' - return m2.dsa_sign_asn1(self.dsa, digest) - - def verify_asn1(self, digest, blob): - assert self.check_key(), 'key is not initialised' - return m2.dsa_verify_asn1(self.dsa, digest, blob) - - def check_key(self): - """ - Check to be sure the DSA object has a valid private key. - - :return: 1 (true) if a valid private key - """ - assert m2.dsa_type_check(self.dsa), "'dsa' type error" - return m2.dsa_check_key(self.dsa) - - -class DSA_pub(DSA): - - """ - This class is a DSA context that only supports a public key - and verification. It does NOT support a private key or - signing. - - """ - - def sign(self, *argv): - # type: (*Any) -> None - raise DSAError('DSA_pub object has no private key') - - sign_asn1 = sign - - def check_key(self): - # type: () -> int - """ - :return: does DSA_pub contain a pub key? - """ - return m2.dsa_check_pub_key(self.dsa) - - save_key = DSA.save_pub_key - - save_key_bio = DSA.save_pub_key_bio - -# -------------------------------------------------------------- -# factories and other functions - - -def gen_params(bits, callback=util.genparam_callback): - # type: (int, Callable) -> DSA - """ - Factory function that generates DSA parameters and - instantiates a DSA object from the output. - - :param bits: The length of the prime to be generated. If - 'bits' < 512, it is set to 512. - :param callback: A Python callback object that will be - invoked during parameter generation; it usual - purpose is to provide visual feedback. - :return: instance of DSA. - """ - dsa = m2.dsa_generate_parameters(bits, callback) - return DSA(dsa, 1) - - -def set_params(p, q, g): - # type: (bytes, bytes, bytes) -> DSA - """ - Factory function that instantiates a DSA object with DSA - parameters. - - :param p: value of p, a "byte string" - :param q: value of q, a "byte string" - :param g: value of g, a "byte string" - :return: instance of DSA. - """ - dsa = m2.dsa_new() - m2.dsa_set_pqg(dsa, p, q, g) - return DSA(dsa, 1) - - -def load_params(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> DSA - """ - Factory function that instantiates a DSA object with DSA - parameters from a file. - - :param file: Names the file (a path) that contains the PEM - representation of the DSA parameters. - :param callback: A Python callback object that will be - invoked if the DSA parameters file is - passphrase-protected. - :return: instance of DSA. - """ - with BIO.openfile(file) as bio: - ret = load_params_bio(bio, callback) - - return ret - - -def load_params_bio(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> DSA - """ - Factory function that instantiates a DSA object with DSA - parameters from a M2Crypto.BIO object. - - :param bio: Contains the PEM representation of the DSA - parameters. - :param callback: A Python callback object that will be - invoked if the DSA parameters file is - passphrase-protected. - :return: instance of DSA. - """ - dsa = m2.dsa_read_params(bio._ptr(), callback) - return DSA(dsa, 1) - - -def load_key(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> DSA - """ - Factory function that instantiates a DSA object from a - PEM encoded DSA key pair. - - :param file: Names the file (a path) that contains the PEM - representation of the DSA key pair. - :param callback: A Python callback object that will be - invoked if the DSA key pair is - passphrase-protected. - :return: instance of DSA. - """ - with BIO.openfile(file) as bio: - ret = load_key_bio(bio, callback) - - return ret - - -def load_key_bio(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> DSA - """ - Factory function that instantiates a DSA object from a - PEM encoded DSA key pair. - - :param bio: Contains the PEM representation of the DSA - key pair. - :param callback: A Python callback object that will be - invoked if the DSA key pair is - passphrase-protected. - :return: instance of DSA. - """ - dsa = m2.dsa_read_key(bio._ptr(), callback) - return DSA(dsa, 1) - - -def pub_key_from_params(p, q, g, pub): - # type: (bytes, bytes, bytes, bytes) -> DSA_pub - """ - Factory function that instantiates a DSA_pub object using - the parameters and public key specified. - - :param p: value of p - :param q: value of q - :param g: value of g - :param pub: value of the public key - :return: instance of DSA_pub. - """ - dsa = m2.dsa_new() - m2.dsa_set_pqg(dsa, p, q, g) - m2.dsa_set_pub(dsa, pub) - return DSA_pub(dsa, 1) - - -def load_pub_key(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> DSA_pub - """ - Factory function that instantiates a DSA_pub object using - a DSA public key contained in PEM file. The PEM file - must contain the parameters in addition to the public key. - - :param file: Names the file (a path) that contains the PEM - representation of the DSA public key. - :param callback: A Python callback object that will be - invoked should the DSA public key be - passphrase-protected. - :return: instance of DSA_pub. - """ - with BIO.openfile(file) as bio: - ret = load_pub_key_bio(bio, callback) - - return ret - - -def load_pub_key_bio(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> DSA_pub - """ - Factory function that instantiates a DSA_pub object using - a DSA public key contained in PEM format. The PEM - must contain the parameters in addition to the public key. - - :param bio: Contains the PEM representation of the DSA - public key (with params). - :param callback: A Python callback object that will be - invoked should the DSA public key be - passphrase-protected. - :return: instance of DSA_pub. - """ - dsapub = m2.dsa_read_pub_key(bio._ptr(), callback) - return DSA_pub(dsapub, 1) diff --git a/M2Crypto/EC.py b/M2Crypto/EC.py deleted file mode 100644 index 522092a..0000000 --- a/M2Crypto/EC.py +++ /dev/null @@ -1,460 +0,0 @@ -from __future__ import absolute_import - -""" -M2Crypto wrapper for OpenSSL ECDH/ECDSA API. - -@requires: OpenSSL 0.9.8 or newer - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. - -Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. -All rights reserved.""" - -from M2Crypto import BIO, Err, EVP, m2, util -from typing import AnyStr, Callable, Dict, Optional, Tuple, Union # noqa -from M2Crypto.EVP import PKey - -EC_Key = bytes - - -class ECError(Exception): - pass - - -m2.ec_init(ECError) - -# Curve identifier constants -NID_secp112r1 = m2.NID_secp112r1 # type: int -NID_secp112r2 = m2.NID_secp112r2 # type: int -NID_secp128r1 = m2.NID_secp128r1 # type: int -NID_secp128r2 = m2.NID_secp128r2 # type: int -NID_secp160k1 = m2.NID_secp160k1 # type: int -NID_secp160r1 = m2.NID_secp160r1 # type: int -NID_secp160r2 = m2.NID_secp160r2 # type: int -NID_secp192k1 = m2.NID_secp192k1 # type: int -NID_secp224k1 = m2.NID_secp224k1 # type: int -NID_secp224r1 = m2.NID_secp224r1 # type: int -NID_secp256k1 = m2.NID_secp256k1 # type: int -NID_secp384r1 = m2.NID_secp384r1 # type: int -NID_secp521r1 = m2.NID_secp521r1 # type: int -NID_sect113r1 = m2.NID_sect113r1 # type: int -NID_sect113r2 = m2.NID_sect113r2 # type: int -NID_sect131r1 = m2.NID_sect131r1 # type: int -NID_sect131r2 = m2.NID_sect131r2 # type: int -NID_sect163k1 = m2.NID_sect163k1 # type: int -NID_sect163r1 = m2.NID_sect163r1 # type: int -NID_sect163r2 = m2.NID_sect163r2 # type: int -NID_sect193r1 = m2.NID_sect193r1 # type: int -NID_sect193r2 = m2.NID_sect193r2 # type: int -# default for secg.org TLS test server -NID_sect233k1 = m2.NID_sect233k1 # type: int -NID_sect233r1 = m2.NID_sect233r1 # type: int -NID_sect239k1 = m2.NID_sect239k1 # type: int -NID_sect283k1 = m2.NID_sect283k1 # type: int -NID_sect283r1 = m2.NID_sect283r1 # type: int -NID_sect409k1 = m2.NID_sect409k1 # type: int -NID_sect409r1 = m2.NID_sect409r1 # type: int -NID_sect571k1 = m2.NID_sect571k1 # type: int -NID_sect571r1 = m2.NID_sect571r1 # type: int - -NID_prime192v1 = m2.NID_X9_62_prime192v1 # type: int -NID_prime192v2 = m2.NID_X9_62_prime192v2 # type: int -NID_prime192v3 = m2.NID_X9_62_prime192v3 # type: int -NID_prime239v1 = m2.NID_X9_62_prime239v1 # type: int -NID_prime239v2 = m2.NID_X9_62_prime239v2 # type: int -NID_prime239v3 = m2.NID_X9_62_prime239v3 # type: int -NID_prime256v1 = m2.NID_X9_62_prime256v1 # type: int -NID_c2pnb163v1 = m2.NID_X9_62_c2pnb163v1 # type: int -NID_c2pnb163v2 = m2.NID_X9_62_c2pnb163v2 # type: int -NID_c2pnb163v3 = m2.NID_X9_62_c2pnb163v3 # type: int -NID_c2pnb176v1 = m2.NID_X9_62_c2pnb176v1 # type: int -NID_c2tnb191v1 = m2.NID_X9_62_c2tnb191v1 # type: int -NID_c2tnb191v2 = m2.NID_X9_62_c2tnb191v2 # type: int -NID_c2tnb191v3 = m2.NID_X9_62_c2tnb191v3 # type: int -NID_c2pnb208w1 = m2.NID_X9_62_c2pnb208w1 # type: int -NID_c2tnb239v1 = m2.NID_X9_62_c2tnb239v1 # type: int -NID_c2tnb239v2 = m2.NID_X9_62_c2tnb239v2 # type: int -NID_c2tnb239v3 = m2.NID_X9_62_c2tnb239v3 # type: int -NID_c2pnb272w1 = m2.NID_X9_62_c2pnb272w1 # type: int -NID_c2pnb304w1 = m2.NID_X9_62_c2pnb304w1 # type: int -NID_c2tnb359v1 = m2.NID_X9_62_c2tnb359v1 # type: int -NID_c2pnb368w1 = m2.NID_X9_62_c2pnb368w1 # type: int -NID_c2tnb431r1 = m2.NID_X9_62_c2tnb431r1 # type: int - -# To preserve compatibility with older names -NID_X9_62_prime192v1 = NID_prime192v1 # type: int -NID_X9_62_prime192v2 = NID_prime192v2 # type: int -NID_X9_62_prime192v3 = NID_prime192v3 # type: int -NID_X9_62_prime239v1 = NID_prime239v1 # type: int -NID_X9_62_prime239v2 = NID_prime239v2 # type: int -NID_X9_62_prime239v3 = NID_prime239v3 # type: int -NID_X9_62_prime256v1 = NID_prime256v1 # type: int -NID_X9_62_c2pnb163v1 = NID_c2pnb163v1 # type: int -NID_X9_62_c2pnb163v2 = NID_c2pnb163v2 # type: int -NID_X9_62_c2pnb163v3 = NID_c2pnb163v3 # type: int -NID_X9_62_c2pnb176v1 = NID_c2pnb176v1 # type: int -NID_X9_62_c2tnb191v1 = NID_c2tnb191v1 # type: int -NID_X9_62_c2tnb191v2 = NID_c2tnb191v2 # type: int -NID_X9_62_c2tnb191v3 = NID_c2tnb191v3 # type: int -NID_X9_62_c2pnb208w1 = NID_c2pnb208w1 # type: int -NID_X9_62_c2tnb239v1 = NID_c2tnb239v1 # type: int -NID_X9_62_c2tnb239v2 = NID_c2tnb239v2 # type: int -NID_X9_62_c2tnb239v3 = NID_c2tnb239v3 # type: int -NID_X9_62_c2pnb272w1 = NID_c2pnb272w1 # type: int -NID_X9_62_c2pnb304w1 = NID_c2pnb304w1 # type: int -NID_X9_62_c2tnb359v1 = NID_c2tnb359v1 # type: int -NID_X9_62_c2pnb368w1 = NID_c2pnb368w1 # type: int -NID_X9_62_c2tnb431r1 = NID_c2tnb431r1 # type: int - -NID_wap_wsg_idm_ecid_wtls1 = m2.NID_wap_wsg_idm_ecid_wtls1 # type: int -NID_wap_wsg_idm_ecid_wtls3 = m2.NID_wap_wsg_idm_ecid_wtls3 # type: int -NID_wap_wsg_idm_ecid_wtls4 = m2.NID_wap_wsg_idm_ecid_wtls4 # type: int -NID_wap_wsg_idm_ecid_wtls5 = m2.NID_wap_wsg_idm_ecid_wtls5 # type: int -NID_wap_wsg_idm_ecid_wtls6 = m2.NID_wap_wsg_idm_ecid_wtls6 # type: int -NID_wap_wsg_idm_ecid_wtls7 = m2.NID_wap_wsg_idm_ecid_wtls7 # type: int -NID_wap_wsg_idm_ecid_wtls8 = m2.NID_wap_wsg_idm_ecid_wtls8 # type: int -NID_wap_wsg_idm_ecid_wtls9 = m2.NID_wap_wsg_idm_ecid_wtls9 # type: int -NID_wap_wsg_idm_ecid_wtls10 = m2.NID_wap_wsg_idm_ecid_wtls10 # type: int -NID_wap_wsg_idm_ecid_wtls11 = m2.NID_wap_wsg_idm_ecid_wtls11 # type: int -NID_wap_wsg_idm_ecid_wtls12 = m2.NID_wap_wsg_idm_ecid_wtls12 # type: int - -# The following two curves, according to OpenSSL, have a -# "Questionable extension field!" and are not supported by -# the OpenSSL inverse function. ECError: no inverse. -# As such they cannot be used for signing. They might, -# however, be usable for encryption but that has not -# been tested. Until thir usefulness can be established, -# they are not supported at this time. -# NID_ipsec3 = m2.NID_ipsec3 -# NID_ipsec4 = m2.NID_ipsec4 - - -class EC(object): - - """ - Object interface to a EC key pair. - """ - - m2_ec_key_free = m2.ec_key_free - - def __init__(self, ec, _pyfree=0): - # type: (EC, int) -> None - assert m2.ec_key_type_check(ec), "'ec' type error" - self.ec = ec - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_ec_key_free(self.ec) - - def __len__(self): - # type: () -> int - assert m2.ec_key_type_check(self.ec), "'ec' type error" - return m2.ec_key_keylen(self.ec) - - def gen_key(self): - # type: () -> int - """ - Generates the key pair from its parameters. Use:: - - keypair = EC.gen_params(curve) - keypair.gen_key() - - to create an EC key pair. - """ - assert m2.ec_key_type_check(self.ec), "'ec' type error" - m2.ec_key_gen_key(self.ec) - - def pub(self): - # type: () -> EC_pub - # Don't let python free - return EC_pub(self.ec, 0) - - def sign_dsa(self, digest): - # type: (bytes) -> Tuple[bytes, bytes] - """ - Sign the given digest using ECDSA. Returns a tuple (r,s), the two - ECDSA signature parameters. - """ - assert self._check_key_type(), "'ec' type error" - return m2.ecdsa_sign(self.ec, digest) - - def verify_dsa(self, digest, r, s): - # type: (bytes, bytes, bytes) -> int - """ - Verify the given digest using ECDSA. r and s are the ECDSA - signature parameters. - """ - assert self._check_key_type(), "'ec' type error" - return m2.ecdsa_verify(self.ec, digest, r, s) - - def sign_dsa_asn1(self, digest): - # type: (bytes) -> bytes - assert self._check_key_type(), "'ec' type error" - return m2.ecdsa_sign_asn1(self.ec, digest) - - def verify_dsa_asn1(self, digest, blob): - assert self._check_key_type(), "'ec' type error" - return m2.ecdsa_verify_asn1(self.ec, digest, blob) - - def compute_dh_key(self, pub_key): - # type: (EC) -> Optional[bytes] - """ - Compute the ECDH shared key of this key pair and the given public - key object. They must both use the same curve. Returns the - shared key in binary as a buffer object. No Key Derivation Function is - applied. - """ - assert self.check_key(), 'key is not initialised' - return m2.ecdh_compute_key(self.ec, pub_key.ec) - - def save_key_bio(self, bio, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (BIO.BIO, Optional[str], Callable) -> int - """ - Save the key pair to an M2Crypto.BIO.BIO object in PEM format. - - :param bio: M2Crypto.BIO.BIO object to save key to. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is 'aes_128_cbc'. If cipher is None, then - the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - if cipher is None: - return m2.ec_key_write_bio_no_cipher(self.ec, bio._ptr(), callback) - else: - ciph = getattr(m2, cipher, None) - if ciph is None: - raise ValueError('not such cipher %s' % cipher) - return m2.ec_key_write_bio(self.ec, bio._ptr(), ciph(), callback) - - def save_key(self, file, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (AnyStr, Optional[str], Callable) -> int - """ - Save the key pair to a file in PEM format. - - :param file: Name of filename to save key to. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is 'aes_128_cbc'. If cipher is None, then - the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - with BIO.openfile(file, 'wb') as bio: - return self.save_key_bio(bio, cipher, callback) - - def save_pub_key_bio(self, bio): - # type: (BIO.BIO) -> int - """ - Save the public key to an M2Crypto.BIO.BIO object in PEM format. - - :param bio: M2Crypto.BIO.BIO object to save key to. - """ - return m2.ec_key_write_pubkey(self.ec, bio._ptr()) - - def save_pub_key(self, file): - # type: (AnyStr) -> int - """ - Save the public key to a filename in PEM format. - - :param file: Name of filename to save key to. - """ - with BIO.openfile(file, 'wb') as bio: - return m2.ec_key_write_pubkey(self.ec, bio._ptr()) - - def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): - """ - Returns the key(pair) as a string in PEM format. - If no password is passed and the cipher is set - it exits with error - """ - with BIO.MemoryBuffer() as bio: - self.save_key_bio(bio, cipher, callback) - return bio.read() - - def _check_key_type(self): - # type: () -> int - return m2.ec_key_type_check(self.ec) - - def check_key(self): - # type: () -> int - assert m2.ec_key_type_check(self.ec), "'ec' type error" - return m2.ec_key_check_key(self.ec) - - -class EC_pub(EC): - - """ - Object interface to an EC public key. - ((don't like this implementation inheritance)) - """ - def __init__(self, ec, _pyfree=0): - # type: (EC, int) -> None - EC.__init__(self, ec, _pyfree) - self.der = None # type: Optional[bytes] - - def get_der(self): - # type: () -> bytes - """ - Returns the public key in DER format as a buffer object. - """ - assert self.check_key(), 'key is not initialised' - if self.der is None: - self.der = m2.ec_key_get_public_der(self.ec) - return self.der - - def get_key(self): - # type: () -> bytes - """ - Returns the public key as a byte string. - """ - assert self.check_key(), 'key is not initialised' - return m2.ec_key_get_public_key(self.ec) - - save_key = EC.save_pub_key - - save_key_bio = EC.save_pub_key_bio - - -def gen_params(curve): - # type: (int) -> EC - """ - Factory function that generates EC parameters and - instantiates a EC object from the output. - - :param curve: This is the OpenSSL nid of the curve to use. - """ - assert curve in [x['NID'] for x in m2.ec_get_builtin_curves()], \ - 'Elliptic curve %s is not available on this system.' % \ - m2.obj_nid2sn(curve) - return EC(m2.ec_key_new_by_curve_name(curve), 1) - - -def load_key(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> EC - """ - Factory function that instantiates a EC object. - - :param file: Names the filename that contains the PEM representation - of the EC key pair. - - :param callback: Python callback object that will be invoked - if the EC key pair is passphrase-protected. - """ - with BIO.openfile(file) as bio: - return load_key_bio(bio, callback) - - -def load_key_string(string, callback=util.passphrase_callback): - # type: (str, Callable) -> EC - """ - Load an EC key pair from a string. - - :param string: String containing EC key pair in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to unlock the - key. The default is util.passphrase_callback. - - :return: M2Crypto.EC.EC object. - """ - with BIO.MemoryBuffer(string) as bio: - return load_key_bio(bio, callback) - - -def load_key_bio(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> EC - """ - Factory function that instantiates a EC object. - - :param bio: M2Crypto.BIO object that contains the PEM - representation of the EC key pair. - - :param callback: Python callback object that will be invoked - if the EC key pair is passphrase-protected. - """ - return EC(m2.ec_key_read_bio(bio._ptr(), callback), 1) - - -def load_pub_key(file): - # type: (AnyStr) -> EC_pub - """ - Load an EC public key from filename. - - :param file: Name of filename containing EC public key in PEM - format. - - :return: M2Crypto.EC.EC_pub object. - """ - with BIO.openfile(file) as bio: - return load_pub_key_bio(bio) - - -def load_key_string_pubkey(string, callback=util.passphrase_callback): - # type: (str, Callable) -> PKey - """ - Load an M2Crypto.EC.PKey from a public key as a string. - - :param string: String containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EC.PKey object. - """ - with BIO.MemoryBuffer(string) as bio: - return EVP.load_key_bio_pubkey(bio, callback) - - -def load_pub_key_bio(bio): - # type: (BIO.BIO) -> EC_pub - """ - Load an EC public key from an M2Crypto.BIO.BIO object. - - :param bio: M2Crypto.BIO.BIO object containing EC public key in PEM - format. - - :return: M2Crypto.EC.EC_pub object. - """ - ec = m2.ec_key_read_pubkey(bio._ptr()) - if ec is None: - ec_error() - return EC_pub(ec, 1) - - -def ec_error(): - # type: () -> ECError - raise ECError(Err.get_error_message()) - - -def pub_key_from_der(der): - # type: (bytes) -> EC_pub - """ - Create EC_pub from DER. - """ - return EC_pub(m2.ec_key_from_pubkey_der(der), 1) - - -def pub_key_from_params(curve, bytes): - # type: (bytes, bytes) -> EC_pub - """ - Create EC_pub from curve name and octet string. - """ - return EC_pub(m2.ec_key_from_pubkey_params(curve, bytes), 1) - - -def get_builtin_curves(): - # type: () -> Tuple[Dict[str, Union[int, str]]] - return m2.ec_get_builtin_curves() diff --git a/M2Crypto/EVP.py b/M2Crypto/EVP.py deleted file mode 100644 index c48b670..0000000 --- a/M2Crypto/EVP.py +++ /dev/null @@ -1,582 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL EVP API. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - -Portions Copyright (c) 2004-2007 Open Source Applications Foundation. -Author: Heikki Toivonen -""" - -import logging -from M2Crypto import BIO, Err, RSA, m2, util -from typing import AnyStr, Optional, Callable # noqa - -log = logging.getLogger('EVP') - - -class EVPError(ValueError): - pass - - -m2.evp_init(EVPError) - - -def pbkdf2(password, salt, iter, keylen): - # type: (bytes, bytes, int, int) -> bytes - """ - Derive a key from password using PBKDF2 algorithm specified in RFC 2898. - - :param password: Derive the key from this password. - :param salt: Salt. - :param iter: Number of iterations to perform. - :param keylen: Length of key to produce. - :return: Key. - """ - return m2.pkcs5_pbkdf2_hmac_sha1(password, salt, iter, keylen) - - -class MessageDigest(object): - """ - Message Digest - """ - m2_md_ctx_free = m2.md_ctx_free - - def __init__(self, algo): - # type: (str) -> None - md = getattr(m2, algo, None) # type: Optional[Callable] - if md is None: - # if the digest algorithm isn't found as an attribute of the m2 - # module, try to look up the digest using get_digestbyname() - self.md = m2.get_digestbyname(algo) - else: - self.md = md() - self.ctx = m2.md_ctx_new() - m2.digest_init(self.ctx, self.md) - - def __del__(self): - # type: () -> None - if getattr(self, 'ctx', None): - self.m2_md_ctx_free(self.ctx) - - def update(self, data): - # type: (bytes) -> int - """ - Add data to be digested. - - :return: -1 for Python error, 1 for success, 0 for OpenSSL failure. - """ - return m2.digest_update(self.ctx, data) - - def final(self): - return m2.digest_final(self.ctx) - - # Deprecated. - digest = final - - -class HMAC(object): - - m2_hmac_ctx_free = m2.hmac_ctx_free - - def __init__(self, key, algo='sha1'): - # type: (bytes, str) -> None - md = getattr(m2, algo, None) - if md is None: - raise ValueError('unknown algorithm', algo) - self.md = md() - self.ctx = m2.hmac_ctx_new() - m2.hmac_init(self.ctx, key, self.md) - - def __del__(self): - # type: () -> None - if getattr(self, 'ctx', None): - self.m2_hmac_ctx_free(self.ctx) - - def reset(self, key): - # type: (bytes) -> None - m2.hmac_init(self.ctx, key, self.md) - - def update(self, data): - # type: (bytes) -> None - m2.hmac_update(self.ctx, data) - - def final(self): - # type: () -> bytes - return m2.hmac_final(self.ctx) - - digest = final - - -def hmac(key, data, algo='sha1'): - # type: (bytes, bytes, str) -> bytes - md = getattr(m2, algo, None) - if md is None: - raise ValueError('unknown algorithm', algo) - return m2.hmac(key, data, md()) - - -class Cipher(object): - - m2_cipher_ctx_free = m2.cipher_ctx_free - - def __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', - salt=b'12345678', i=1, padding=1): - # type: (str, bytes, bytes, object, int, str, bytes, int, int) -> None - cipher = getattr(m2, alg, None) - if cipher is None: - raise ValueError('unknown cipher', alg) - self.cipher = cipher() - if key_as_bytes: - kmd = getattr(m2, d, None) - if kmd is None: - raise ValueError('unknown message digest', d) - key = m2.bytes_to_key(self.cipher, kmd(), key, salt, iv, i) - self.ctx = m2.cipher_ctx_new() - m2.cipher_init(self.ctx, self.cipher, key, iv, op) - self.set_padding(padding) - del key - - def __del__(self): - # type: () -> None - if getattr(self, 'ctx', None): - self.m2_cipher_ctx_free(self.ctx) - - def update(self, data): - # type: (bytes) -> bytes - return m2.cipher_update(self.ctx, data) - - def final(self): - # type: () -> bytes - return m2.cipher_final(self.ctx) - - def set_padding(self, padding=1): - # type: (int) -> int - """ - Actually always return 1 - """ - return m2.cipher_set_padding(self.ctx, padding) - - -class PKey(object): - """ - Public Key - """ - - m2_pkey_free = m2.pkey_free - m2_md_ctx_free = m2.md_ctx_free - - def __init__(self, pkey=None, _pyfree=0, md='sha1'): - # type: (Optional[bytes], int, str) -> None - if pkey is not None: - self.pkey = pkey # type: bytes - self._pyfree = _pyfree - else: - self.pkey = m2.pkey_new() - self._pyfree = 1 - self._set_context(md) - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_pkey_free(self.pkey) - if getattr(self, 'ctx', None): - self.m2_md_ctx_free(self.ctx) - - def _ptr(self): - return self.pkey - - def _set_context(self, md): - # type: (str) -> None - if not md: - self.md = None - else: - mda = getattr(m2, md, None) # type: Optional[Callable] - if mda is None: - raise ValueError('unknown message digest', md) - self.md = mda() - self.ctx = m2.md_ctx_new() ## type: Context - - def reset_context(self, md='sha1'): - # type: (str) -> None - """ - Reset internal message digest context. - - :param md: The message digest algorithm. - """ - self._set_context(md) - - def sign_init(self): - # type: () -> None - """ - Initialise signing operation with self. - """ - m2.sign_init(self.ctx, self.md) - - def sign_update(self, data): - # type: (bytes) -> None - """ - Feed data to signing operation. - - :param data: Data to be signed. - """ - m2.sign_update(self.ctx, data) - - def sign_final(self): - # type: () -> bytes - """ - Return signature. - - :return: The signature. - """ - return m2.sign_final(self.ctx, self.pkey) - - # Deprecated - update = sign_update - final = sign_final - - def verify_init(self): - # type: () -> None - """ - Initialise signature verification operation with self. - """ - m2.verify_init(self.ctx, self.md) - - def verify_update(self, data): - # type: (bytes) -> int - """ - Feed data to verification operation. - - :param data: Data to be verified. - :return: -1 on Python error, 1 for success, 0 for OpenSSL error - """ - return m2.verify_update(self.ctx, data) - - def verify_final(self, sign): - # type: (bytes) -> int - """ - Return result of verification. - - :param sign: Signature to use for verification - :return: Result of verification: 1 for success, 0 for failure, -1 on - other error. - """ - return m2.verify_final(self.ctx, sign, self.pkey) - - def digest_sign_init(self): - # type: () -> None - """ - Initialise digest signing operation with self. - """ - if self.md is None: - m2.digest_sign_init(self.ctx, self.pkey) - else: - m2.digest_sign_init(self.ctx, None, self.md, None, self.pkey) - - def digest_sign_update(self, data): - # type: (bytes) -> None - """ - Feed data to digest signing operation. - - :param data: Data to be signed. - """ - m2.digest_sign_update(self.ctx, data) - - def digest_sign_final(self): - # type: () -> bytes - """ - Return signature. - - :return: The signature. - """ - return m2.digest_sign_final(self.ctx) - - def digest_sign(self, data): - # type: () -> bytes - """ - Return signature. - - :return: The signature. - """ - - if m2.OPENSSL_VERSION_NUMBER < 0x10101000: - raise NotImplemented('This method requires OpenSSL version ' + - '1.1.1 or greater.') - - return m2.digest_sign(self.ctx, data) - - def digest_verify_init(self): - # type: () -> None - """ - Initialise verification operation with self. - """ - if self.md is None: - m2.digest_verify_init(self.ctx, self.pkey) - else: - m2.digest_verify_init(self.ctx, None, self.md, None, self.pkey) - - def digest_verify_update(self, data): - # type: (bytes) -> int - """ - Feed data to verification operation. - - :param data: Data to be verified. - :return: -1 on Python error, 1 for success, 0 for OpenSSL error - """ - return m2.digest_verify_update(self.ctx, data) - - def digest_verify_final(self, sign): - # type: (bytes) -> int - """ - Feed data to digest verification operation. - - :param sign: Signature to use for verification - :return: Result of verification: 1 for success, 0 for failure, -1 on - other error. - """ - return m2.digest_verify_final(self.ctx, sign) - - def digest_verify(self, sign, data): - # type: (bytes) -> int - """ - Return result of verification. - - :param sign: Signature to use for verification - :param data: Data to be verified. - :return: Result of verification: 1 for success, 0 for failure, -1 on - other error. - """ - - if m2.OPENSSL_VERSION_NUMBER < 0x10101000: - raise NotImplemented('This method requires OpenSSL version ' + - '1.1.1 or greater.') - - return m2.digest_verify(self.ctx, sign, data) - - def assign_rsa(self, rsa, capture=1): - # type: (RSA.RSA, int) -> int - """ - Assign the RSA key pair to self. - - :param rsa: M2Crypto.RSA.RSA object to be assigned to self. - - :param capture: If true (default), this PKey object will own the RSA - object, meaning that once the PKey object gets - deleted it is no longer safe to use the RSA object. - - :return: Return 1 for success and 0 for failure. - """ - if capture: - ret = m2.pkey_assign_rsa(self.pkey, rsa.rsa) - if ret: - rsa._pyfree = 0 - else: - ret = m2.pkey_set1_rsa(self.pkey, rsa.rsa) - return ret - - def get_rsa(self): - # type: () -> RSA.RSA_pub - """ - Return the underlying RSA key if that is what the EVP - instance is holding. - """ - rsa_ptr = m2.pkey_get1_rsa(self.pkey) - - rsa = RSA.RSA_pub(rsa_ptr, 1) - return rsa - - def save_key(self, file, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (AnyStr, Optional[str], Callable) -> int - """ - Save the key pair to a file in PEM format. - - :param file: Name of file to save key to. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is 'aes_128_cbc'. If cipher is None, then - the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - with BIO.openfile(file, 'wb') as bio: - return self.save_key_bio(bio, cipher, callback) - - def save_key_bio(self, bio, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (BIO.BIO, Optional[str], Callable) -> int - """ - Save the key pair to the M2Crypto.BIO object 'bio' in PEM format. - - :param bio: M2Crypto.BIO object to save key to. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is 'aes_128_cbc'. If cipher is None, then - the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - if cipher is None: - return m2.pkey_write_pem_no_cipher(self.pkey, bio._ptr(), callback) - else: - proto = getattr(m2, cipher, None) - if proto is None: - raise ValueError('no such cipher %s' % cipher) - return m2.pkey_write_pem(self.pkey, bio._ptr(), proto(), callback) - - def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): - # type: (Optional[str], Callable) -> bytes - """ - Return key in PEM format in a string. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is ``'aes_128_cbc'``. If cipher is None, - then the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - bio = BIO.MemoryBuffer() - self.save_key_bio(bio, cipher, callback) - return bio.read_all() - - def as_der(self): - # type: () -> bytes - """ - Return key in DER format in a string - """ - buf = m2.pkey_as_der(self.pkey) - bio = BIO.MemoryBuffer(buf) - return bio.read_all() - - def size(self): - # type: () -> int - """ - Return the size of the key in bytes. - """ - return m2.pkey_size(self.pkey) - - def get_modulus(self): - # type: () -> Optional[bytes] - """ - Return the modulus in hex format. - """ - return m2.pkey_get_modulus(self.pkey) - - -def load_key(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> PKey - """ - Load an M2Crypto.EVP.PKey from file. - - :param file: Name of file containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EVP.PKey object. - """ - with BIO.openfile(file, 'r') as bio: - cptr = m2.pkey_read_pem(bio.bio, callback) - - return PKey(cptr, 1) - - -def load_key_pubkey(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> PKey - """ - Load an M2Crypto.EVP.PKey from a public key as a file. - - :param file: Name of file containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EVP.PKey object. - """ - - with BIO.openfile(file, 'r') as bio: - cptr = m2.pkey_read_pem_pubkey(bio._ptr(), callback) - if cptr is None: - raise EVPError(Err.get_error()) - return PKey(cptr, 1) - - -def load_key_bio(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> PKey - """ - Load an M2Crypto.EVP.PKey from an M2Crypto.BIO object. - - :param bio: M2Crypto.BIO object containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EVP.PKey object. - """ - cptr = m2.pkey_read_pem(bio._ptr(), callback) - return PKey(cptr, 1) - - -def load_key_bio_pubkey(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> PKey - """ - Load an M2Crypto.EVP.PKey from a public key as a M2Crypto.BIO object. - - :param bio: M2Crypto.BIO object containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EVP.PKey object. - """ - cptr = m2.pkey_read_pem_pubkey(bio._ptr(), callback) - if cptr is None: - raise EVPError(Err.get_error()) - return PKey(cptr, 1) - - -def load_key_string(string, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> PKey - """ - Load an M2Crypto.EVP.PKey from a string. - - :param string: String containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EVP.PKey object. - """ - bio = BIO.MemoryBuffer(string) - return load_key_bio(bio, callback) - - -def load_key_string_pubkey(string, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> PKey - """ - Load an M2Crypto.EVP.PKey from a public key as a string. - - :param string: String containing the key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect the - key. - - :return: M2Crypto.EVP.PKey object. - """ - bio = BIO.MemoryBuffer(string) - return load_key_bio_pubkey(bio, callback) diff --git a/M2Crypto/Engine.py b/M2Crypto/Engine.py deleted file mode 100644 index 46b76a4..0000000 --- a/M2Crypto/Engine.py +++ /dev/null @@ -1,150 +0,0 @@ -# vim: sts=4 sw=4 et -from __future__ import absolute_import - -""" -M2Crypto wrapper for OpenSSL ENGINE API. - -Pavel Shramov -IMEC MSU -""" - -from M2Crypto import EVP, Err, X509, m2, six -from typing import AnyStr, Callable, Optional # noqa - - -class EngineError(Exception): - pass - - -m2.engine_init_error(EngineError) - - -class Engine(object): - """Wrapper for ENGINE object.""" - - m2_engine_free = m2.engine_free - - def __init__(self, id=None, _ptr=None, _pyfree=1): - # type: (Optional[bytes], Optional[bytes], int) -> None - """Create new Engine from ENGINE pointer or obtain by id""" - if not _ptr and not id: - raise ValueError("No engine id specified") - self._ptr = _ptr - if not self._ptr: - self._ptr = m2.engine_by_id(id) - if not self._ptr: - raise ValueError("Unknown engine: %s" % id) - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_engine_free(self._ptr) - - def init(self): - # type: () -> int - """Obtain a functional reference to the engine. - - :return: 0 on error, non-zero on success.""" - return m2.engine_init(self._ptr) - - def finish(self): - # type: () -> int - """Release a functional and structural reference to the engine.""" - return m2.engine_finish(self._ptr) - - def ctrl_cmd_string(self, cmd, arg, optional=0): - # type: (AnyStr, Optional[AnyStr], int) -> None - """Call ENGINE_ctrl_cmd_string""" - cmd = six.ensure_str(cmd) - if arg is not None: - arg = six.ensure_str(arg) - if not m2.engine_ctrl_cmd_string(self._ptr, cmd, arg, optional): - raise EngineError(Err.get_error()) - - def get_name(self): - # type: () -> bytes - """Return engine name""" - return m2.engine_get_name(self._ptr) - - def get_id(self): - # type: () -> bytes - """Return engine id""" - return m2.engine_get_id(self._ptr) - - def set_default(self, methods=m2.ENGINE_METHOD_ALL): - # type: (int) -> int - """ - Use this engine as default for methods specified in argument - - :param methods: Possible values are bitwise OR of m2.ENGINE_METHOD_* - """ - return m2.engine_set_default(self._ptr, methods) - - def _engine_load_key(self, func, name, pin=None): - # type: (Callable, bytes, Optional[bytes]) -> EVP.PKey - """Helper function for loading keys""" - ui = m2.ui_openssl() - cbd = m2.engine_pkcs11_data_new(pin) - try: - kptr = func(self._ptr, name, ui, cbd) - if not kptr: - raise EngineError(Err.get_error()) - key = EVP.PKey(kptr, _pyfree=1) - finally: - m2.engine_pkcs11_data_free(cbd) - return key - - def load_private_key(self, name, pin=None): - # type: (bytes, Optional[bytes]) -> X509.X509 - """Load private key with engine methods (e.g from smartcard). - If pin is not set it will be asked - """ - return self._engine_load_key(m2.engine_load_private_key, name, pin) - - def load_public_key(self, name, pin=None): - # type: (bytes, Optional[bytes]) -> EVP.PKey - """Load public key with engine methods (e.g from smartcard).""" - return self._engine_load_key(m2.engine_load_public_key, name, pin) - - def load_certificate(self, name): - # type: (bytes) -> X509.X509 - """Load certificate from engine (e.g from smartcard). - NOTE: This function may be not implemented by engine!""" - cptr = m2.engine_load_certificate(self._ptr, name) - if not cptr: - raise EngineError("Certificate or card not found") - return X509.X509(cptr, _pyfree=1) - - -def load_dynamic_engine(id, sopath): - # type: (bytes, AnyStr) -> Engine - """Load and return dymanic engine from sopath and assign id to it""" - if isinstance(sopath, six.text_type): - sopath = sopath.encode('utf8') - m2.engine_load_dynamic() - e = Engine('dynamic') - e.ctrl_cmd_string('SO_PATH', sopath) - e.ctrl_cmd_string('ID', id) - e.ctrl_cmd_string('LIST_ADD', '1') - e.ctrl_cmd_string('LOAD', None) - return e - - -def load_dynamic(): - # type: () -> None - """Load dynamic engine""" - m2.engine_load_dynamic() - - -def load_openssl(): - # type: () -> None - """Load openssl engine""" - m2.engine_load_openssl() - - -def cleanup(): - # type: () -> None - """If you load any engines, you need to clean up after your application - is finished with the engines.""" - m2.engine_cleanup() diff --git a/M2Crypto/Err.py b/M2Crypto/Err.py deleted file mode 100644 index dd55991..0000000 --- a/M2Crypto/Err.py +++ /dev/null @@ -1,76 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL Error API. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -from M2Crypto import BIO, m2, util, six # noqa -from typing import Optional # noqa - - -def get_error(): - # type: () -> Optional[str] - err = BIO.MemoryBuffer() - m2.err_print_errors(err.bio_ptr()) - err_msg = err.read() - if err_msg: - return six.ensure_text(err_msg) - - -def get_error_code(): - # type: () -> int - return m2.err_get_error() - - -def peek_error_code(): - # type: () -> int - return m2.err_peek_error() - - -def get_error_lib(err): - # type: (Optional[int]) -> str - err_str = m2.err_lib_error_string(err) - return six.ensure_text(err_str) if err_str else '' - - -def get_error_func(err): - # type: (Optional[int]) -> str - err_str = m2.err_func_error_string(err) - return six.ensure_text(err_str) if err_str else '' - - -def get_error_reason(err): - # type: (Optional[int]) -> str - err_str = m2.err_reason_error_string(err) - return six.ensure_text(err_str) if err_str else '' - - -def get_error_message(): - # type: () -> str - return six.ensure_text(get_error_reason(get_error_code())) - - -def get_x509_verify_error(err): - # type: (Optional[int]) -> str - err_str = m2.x509_get_verify_error(err) - return six.ensure_text(err_str) if err_str else '' - - -class SSLError(Exception): - def __init__(self, err, client_addr): - # type: (int, util.AddrType) -> None - self.err = err - self.client_addr = client_addr - - def __str__(self): - # type: () -> str - if not isinstance(self.client_addr, six.text_type): - s = self.client_addr.decode('utf8') - else: - s = self.client_addr - return "%s: %s: %s" % (get_error_func(self.err), s, - get_error_reason(self.err)) - - -class M2CryptoError(Exception): - pass diff --git a/M2Crypto/RC4.py b/M2Crypto/RC4.py deleted file mode 100644 index 26e1079..0000000 --- a/M2Crypto/RC4.py +++ /dev/null @@ -1,36 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL RC4 API. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -from M2Crypto.m2 import rc4_free, rc4_new, rc4_set_key, rc4_update - - -class RC4(object): - """Object interface to the stream cipher RC4.""" - - rc4_free = rc4_free - - def __init__(self, key=None): - # type: (bytes) -> None - self.cipher = rc4_new() - if key: - rc4_set_key(self.cipher, key) - - def __del__(self): - # type: () -> None - if getattr(self, 'cipher', None): - self.rc4_free(self.cipher) - - def set_key(self, key): - # type: (bytes) -> None - rc4_set_key(self.cipher, key) - - def update(self, data): - # type: (bytes) -> bytes - return rc4_update(self.cipher, data) - - def final(self): - # type: () -> str - return '' diff --git a/M2Crypto/RSA.py b/M2Crypto/RSA.py deleted file mode 100644 index d6e5c64..0000000 --- a/M2Crypto/RSA.py +++ /dev/null @@ -1,466 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL RSA API. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" - -import sys - -from M2Crypto import BIO, Err, m2, util -from typing import Any, AnyStr, Callable, IO, Optional, Tuple # noqa - - -class RSAError(Exception): - pass - - -m2.rsa_init(RSAError) - -no_padding = m2.no_padding -pkcs1_padding = m2.pkcs1_padding -sslv23_padding = m2.sslv23_padding -pkcs1_oaep_padding = m2.pkcs1_oaep_padding - - -class RSA(object): - """ - RSA Key Pair. - """ - - m2_rsa_free = m2.rsa_free - - def __init__(self, rsa, _pyfree=0): - # type: (bytes, int) -> None - """ - :param rsa: binary representation of OpenSSL RSA type - """ - assert m2.rsa_type_check(rsa), "'rsa' type error" - self.rsa = rsa - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_rsa_free(self.rsa) - - def __len__(self): - # type: () -> int - return int(m2.rsa_size(self.rsa) << 3) - - def __getattr__(self, name): - # type: (str) -> bytes - if name == 'e': - return m2.rsa_get_e(self.rsa) - elif name == 'n': - return m2.rsa_get_n(self.rsa) - else: - raise AttributeError - - def pub(self): - # type: () -> Tuple[bytes, bytes] - assert self.check_key(), 'key is not initialised' - return m2.rsa_get_e(self.rsa), m2.rsa_get_n(self.rsa) - - def public_encrypt(self, data, padding): - # type: (bytes, int) -> bytes - assert self.check_key(), 'key is not initialised' - return m2.rsa_public_encrypt(self.rsa, data, padding) - - def public_decrypt(self, data, padding): - # type: (bytes, int) -> bytes - assert self.check_key(), 'key is not initialised' - return m2.rsa_public_decrypt(self.rsa, data, padding) - - def private_encrypt(self, data, padding): - # type: (bytes, int) -> bytes - assert self.check_key(), 'key is not initialised' - return m2.rsa_private_encrypt(self.rsa, data, padding) - - def private_decrypt(self, data, padding): - # type: (bytes, int) -> bytes - assert self.check_key(), 'key is not initialised' - return m2.rsa_private_decrypt(self.rsa, data, padding) - - def save_key_bio(self, bio, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (BIO.BIO, Optional[str], Callable) -> int - """ - Save the key pair to an M2Crypto.BIO.BIO object in PEM format. - - :param bio: M2Crypto.BIO.BIO object to save key to. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is 'aes_128_cbc'. If cipher is None, then - the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - if cipher is None: - return m2.rsa_write_key_no_cipher(self.rsa, bio._ptr(), callback) - else: - ciph = getattr(m2, cipher, None) - if ciph is None: - raise RSAError('not such cipher %s' % cipher) - else: - ciph = ciph() - return m2.rsa_write_key(self.rsa, bio._ptr(), ciph, callback) - - def save_key(self, file, cipher='aes_128_cbc', - callback=util.passphrase_callback): - # type: (AnyStr, Optional[str], Callable) -> int - """ - Save the key pair to a file in PEM format. - - :param file: Name of file to save key to. - - :param cipher: Symmetric cipher to protect the key. The default - cipher is 'aes_128_cbc'. If cipher is None, then - the key is saved in the clear. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to protect - the key. The default is - util.passphrase_callback. - """ - with BIO.openfile(file, 'wb') as bio: - return self.save_key_bio(bio, cipher, callback) - - save_pem = save_key - - def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): - # type: (Optional[str], Callable) -> bytes - """ - Returns the key(pair) as a string in PEM format. - """ - bio = BIO.MemoryBuffer() - self.save_key_bio(bio, cipher, callback) - return bio.read() - - def save_key_der_bio(self, bio): - # type: (BIO.BIO) -> int - """ - Save the key pair to an M2Crypto.BIO.BIO object in DER format. - - :param bio: M2Crypto.BIO.BIO object to save key to. - """ - return m2.rsa_write_key_der(self.rsa, bio._ptr()) - - def save_key_der(self, file): - # type: (AnyStr) -> int - """ - Save the key pair to a file in DER format. - - :param file: Filename to save key to - """ - with BIO.openfile(file, 'wb') as bio: - return self.save_key_der_bio(bio) - - def save_pub_key_bio(self, bio): - # type: (BIO.BIO) -> int - """ - Save the public key to an M2Crypto.BIO.BIO object in PEM format. - - :param bio: M2Crypto.BIO.BIO object to save key to. - """ - return m2.rsa_write_pub_key(self.rsa, bio._ptr()) - - def save_pub_key(self, file): - # type: (AnyStr) -> int - """ - Save the public key to a file in PEM format. - - :param file: Name of file to save key to. - """ - with BIO.openfile(file, 'wb') as bio: - return m2.rsa_write_pub_key(self.rsa, bio._ptr()) - - def check_key(self): - # type: () -> int - """ - Validate RSA keys. - - It checks that p and q are in fact prime, and that n = p*q. - - :return: returns 1 if rsa is a valid RSA key, and 0 otherwise. - -1 is returned if an error occurs while checking the key. - If the key is invalid or an error occurred, the reason - code can be obtained using ERR_get_error(3). - """ - return m2.rsa_check_key(self.rsa) - - def sign_rsassa_pss(self, digest, algo='sha1', salt_length=20): - # type: (bytes, str, int) -> bytes - """ - Signs a digest with the private key using RSASSA-PSS - - :param digest: A digest created by using the digest method - - :param salt_length: The length of the salt to use - - :param algo: The hash algorithm to use - Legal values like 'sha1','sha224', 'sha256', - 'ripemd160', and 'md5'. - - :return: a string which is the signature - """ - hash = getattr(m2, algo, None) - - if hash is None: - raise RSAError('not such hash algorithm %s' % algo) - - signature = m2.rsa_padding_add_pkcs1_pss(self.rsa, digest, hash(), salt_length) - - return self.private_encrypt(signature, m2.no_padding) - - def verify_rsassa_pss(self, data, signature, algo='sha1', salt_length=20): - # type: (bytes, bytes, str, int) -> int - """ - Verifies the signature RSASSA-PSS - - :param data: Data that has been signed - - :param signature: The signature signed with RSASSA-PSS - - :param salt_length: The length of the salt that was used - - :param algo: The hash algorithm to use - Legal values are for example 'sha1','sha224', - 'sha256', 'ripemd160', and 'md5'. - - :return: 1 or 0, depending on whether the signature was - verified or not. - """ - hash = getattr(m2, algo, None) - - if hash is None: - raise RSAError('not such hash algorithm %s' % algo) - - plain_signature = self.public_decrypt(signature, m2.no_padding) - - return m2.rsa_verify_pkcs1_pss(self.rsa, data, plain_signature, hash(), salt_length) - - def sign(self, digest, algo='sha1'): - # type: (bytes, str) -> bytes - """ - Signs a digest with the private key - - :param digest: A digest created by using the digest method - - :param algo: The method that created the digest. - Legal values like 'sha1','sha224', 'sha256', - 'ripemd160', and 'md5'. - - :return: a string which is the signature - """ - digest_type = getattr(m2, 'NID_' + algo, None) - if digest_type is None: - raise ValueError('unknown algorithm', algo) - - return m2.rsa_sign(self.rsa, digest, digest_type) - - def verify(self, data, signature, algo='sha1'): - # type: (bytes, bytes, str) -> int - """ - Verifies the signature with the public key - - :param data: Data that has been signed - - :param signature: The signature signed with the private key - - :param algo: The method use to create digest from the data - before it was signed. Legal values like - 'sha1','sha224', 'sha256', 'ripemd160', and 'md5'. - - :return: 1 or 0, depending on whether the signature was - verified or not. - """ - digest_type = getattr(m2, 'NID_' + algo, None) - if digest_type is None: - raise ValueError('unknown algorithm', algo) - - return m2.rsa_verify(self.rsa, data, signature, digest_type) - - -class RSA_pub(RSA): - - """ - Object interface to an RSA public key. - """ - - def __setattr__(self, name, value): - # type: (str, bytes) -> None - if name in ['e', 'n']: - raise RSAError('use factory function new_pub_key() to set (e, n)') - else: - self.__dict__[name] = value - - def private_encrypt(self, *argv): - # type: (*Any) -> None - raise RSAError('RSA_pub object has no private key') - - def private_decrypt(self, *argv): - # type: (*Any) -> None - raise RSAError('RSA_pub object has no private key') - - def save_key(self, file, *args, **kw): - # type: (AnyStr, *Any, **Any) -> int - """ - Save public key to file. - """ - return self.save_pub_key(file) - - def save_key_bio(self, bio, *args, **kw): - # type: (BIO.BIO, *Any, **Any) -> int - """ - Save public key to BIO. - """ - return self.save_pub_key_bio(bio) - - # save_key_der - - # save_key_der_bio - - def check_key(self): - # type: () -> int - return m2.rsa_check_pub_key(self.rsa) - - -def rsa_error(): - # type: () -> None - raise RSAError(Err.get_error_message()) - - -def keygen_callback(p, n, out=sys.stdout): - # type: (int, Any, IO[str]) -> None - """ - Default callback for gen_key(). - """ - ch = ['.', '+', '*', '\n'] - out.write(ch[p]) - out.flush() - - -def gen_key(bits, e, callback=keygen_callback): - # type: (int, int, Callable) -> RSA - """ - Generate an RSA key pair. - - :param bits: Key length, in bits. - - :param e: The RSA public exponent. - - :param callback: A Python callable object that is invoked - during key generation; its usual purpose is to - provide visual feedback. The default callback is - keygen_callback. - - :return: M2Crypto.RSA.RSA object. - """ - return RSA(m2.rsa_generate_key(bits, e, callback), 1) - - -def load_key(file, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> RSA - """ - Load an RSA key pair from file. - - :param file: Name of file containing RSA public key in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to unlock the - key. The default is util.passphrase_callback. - - :return: M2Crypto.RSA.RSA object. - """ - with BIO.openfile(file) as bio: - return load_key_bio(bio, callback) - - -def load_key_bio(bio, callback=util.passphrase_callback): - # type: (BIO.BIO, Callable) -> RSA - """ - Load an RSA key pair from an M2Crypto.BIO.BIO object. - - :param bio: M2Crypto.BIO.BIO object containing RSA key pair in PEM - format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to unlock the - key. The default is util.passphrase_callback. - - :return: M2Crypto.RSA.RSA object. - """ - rsa = m2.rsa_read_key(bio._ptr(), callback) - if rsa is None: - rsa_error() - return RSA(rsa, 1) - - -def load_key_string(string, callback=util.passphrase_callback): - # type: (AnyStr, Callable) -> RSA - """ - Load an RSA key pair from a string. - - :param string: String containing RSA key pair in PEM format. - - :param callback: A Python callable object that is invoked - to acquire a passphrase with which to unlock the - key. The default is util.passphrase_callback. - - :return: M2Crypto.RSA.RSA object. - """ - bio = BIO.MemoryBuffer(string) - return load_key_bio(bio, callback) - - -def load_pub_key(file): - # type: (AnyStr) -> RSA_pub - """ - Load an RSA public key from file. - - :param file: Name of file containing RSA public key in PEM format. - - :return: M2Crypto.RSA.RSA_pub object. - """ - with BIO.openfile(file) as bio: - return load_pub_key_bio(bio) - - -def load_pub_key_bio(bio): - # type: (BIO.BIO) -> RSA_pub - """ - Load an RSA public key from an M2Crypto.BIO.BIO object. - - :param bio: M2Crypto.BIO.BIO object containing RSA public key in PEM - format. - - :return: M2Crypto.RSA.RSA_pub object. - """ - rsa = m2.rsa_read_pub_key(bio._ptr()) - if rsa is None: - rsa_error() - return RSA_pub(rsa, 1) - - -def new_pub_key(e_n): - # type: (Tuple[bytes, bytes]) -> RSA_pub - """ - Instantiate an RSA_pub object from an (e, n) tuple. - - :param e: The RSA public exponent; it is a string in OpenSSL's MPINT - format - 4-byte big-endian bit-count followed by the - appropriate number of bits. - - :param n: The RSA composite of primes; it is a string in OpenSSL's - MPINT format - 4-byte big-endian bit-count followed by the - appropriate number of bits. - - :return: M2Crypto.RSA.RSA_pub object. - """ - (e, n) = e_n - rsa = m2.rsa_new() - m2.rsa_set_en(rsa, e, n) - return RSA_pub(rsa, 1) diff --git a/M2Crypto/Rand.py b/M2Crypto/Rand.py deleted file mode 100644 index a178b1b..0000000 --- a/M2Crypto/Rand.py +++ /dev/null @@ -1,146 +0,0 @@ -"""M2Crypto wrapper for OpenSSL PRNG. Requires OpenSSL 0.9.5 and above. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. -Copyright (c) 2014-2017 Matej Cepl. All rights reserved. - -See LICENCE for the license information. -""" -from __future__ import absolute_import - -from M2Crypto import m2, six -from typing import AnyStr, Tuple # noqa - - -__all__ = ['rand_seed', 'rand_add', 'load_file', 'save_file', 'rand_bytes', - 'rand_pseudo_bytes', 'rand_file_name', 'rand_status'] - - -class RandError(ValueError): - pass - -m2.rand_init(RandError) - - -def rand_add(blob, entropy): - # type: (bytes, float) -> None - """ - Mixes blob into the PRNG state. - - :param blob: added data - :param entropy: (the lower bound of) an estimate of how much randomness - is contained in blob, measured in bytes. - - Thus, if the data at buf are unpredictable to an adversary, this - increases the uncertainty about the state and makes the PRNG output less - predictable. Suitable input comes from user interaction (random key - presses, mouse movements) and certain hardware events. - - Details about sources of randomness and how to estimate their entropy - can be found in the literature, e.g. RFC 1750. - """ - m2.rand_add(blob, entropy) # pylint: disable=no-member - - -def rand_seed(seed): - # type: (bytes) -> None - """ - Equivalent to rand_add() when len(seed) == entropy. - - :param seed: added data (see description at rand_add) - """ - m2.rand_seed(seed) # pylint: disable=no-member - - -def rand_status(): - # type: () -> int - """ - Check whether there is enough entropy in PRNG. - - :return: 1 if the PRNG has been seeded with enough - data, 0 otherwise. - """ - return m2.rand_status() # pylint: disable=no-member - - -def rand_file_name(): - # type: () -> str - """ - Generate a default path for the random seed file. - - :return: string with the filename. - The seed file is $RANDFILE if that environment variable - is set, $HOME/.rnd otherwise. If $HOME is not set either, - an error occurs. - """ - return six.ensure_text(m2.rand_file_name()) # pylint: disable=no-member - - -def load_file(filename, max_bytes): - # type: (AnyStr, int) -> int - """ - Read a number of bytes from file filename and adds them to the PRNG. - - If max_bytes is non-negative, up to to max_bytes are read; starting with - OpenSSL 0.9.5, if max_bytes is -1, the complete file is read. - - :param filename: - :param max_bytes: - :return: the number of bytes read. - """ - return m2.rand_load_file(six.ensure_str(filename), max_bytes) # pylint: disable=no-member - - -def save_file(filename): - # type: (AnyStr) -> int - """ - Write a number of random bytes (currently 1024) to file. - - The file then can be used to initialize the PRNG by calling load_file() in - a later session. - - :param filename: - :return: returns the number of bytes written, and -1 if the bytes - written were generated without appropriate seed. - """ - return m2.rand_save_file(filename) # pylint: disable=no-member - - -def rand_bytes(num): - # type: (int) -> bytes - """ - Return n cryptographically strong pseudo-random bytes. - - An error occurs if the PRNG has not been seeded with enough randomness - to ensure an unpredictable byte sequence. - - :param num: number of bytes to be returned - :return: random bytes - """ - return m2.rand_bytes(num) # pylint: disable=no-member - - -def rand_pseudo_bytes(num): - # type: (int) -> Tuple[bytes, int] - """ - Return num pseudo-random bytes into buf. - - Pseudo-random byte sequences generated by this method will be unique - if they are of sufficient length, but are not necessarily - unpredictable. They can be used for non-cryptographic purposes and for - certain purposes in cryptographic protocols, but usually not for key - generation etc. - - Output of the function is mixed into the entropy pool before - retrieving the new pseudo-random bytes unless disabled at compile - time (see FAQ). - - :param num: number of bytes to be returned - :return: random bytes - """ - import warnings - if m2.OPENSSL_VERSION_NUMBER >= 0x10100000: - warnings.warn('The underlying OpenSSL method has been ' + - 'deprecated. Use Rand.rand_bytes instead.', - DeprecationWarning) - - return m2.rand_pseudo_bytes(num) # pylint: disable=no-member diff --git a/M2Crypto/SMIME.py b/M2Crypto/SMIME.py deleted file mode 100644 index 1b7564a..0000000 --- a/M2Crypto/SMIME.py +++ /dev/null @@ -1,291 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL S/MIME API. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -from M2Crypto import BIO, EVP, Err, X509, m2, util -from typing import AnyStr, Callable, Optional # noqa - -PKCS7_TEXT = m2.PKCS7_TEXT # type: int -PKCS7_NOCERTS = m2.PKCS7_NOCERTS # type: int -PKCS7_NOSIGS = m2.PKCS7_NOSIGS # type: int -PKCS7_NOCHAIN = m2.PKCS7_NOCHAIN # type: int -PKCS7_NOINTERN = m2.PKCS7_NOINTERN # type: int -PKCS7_NOVERIFY = m2.PKCS7_NOVERIFY # type: int -PKCS7_DETACHED = m2.PKCS7_DETACHED # type: int -PKCS7_BINARY = m2.PKCS7_BINARY # type: int -PKCS7_NOATTR = m2.PKCS7_NOATTR # type: int - -PKCS7_SIGNED = m2.PKCS7_SIGNED # type: int -PKCS7_ENVELOPED = m2.PKCS7_ENVELOPED # type: int -PKCS7_SIGNED_ENVELOPED = m2.PKCS7_SIGNED_ENVELOPED # Deprecated -PKCS7_DATA = m2.PKCS7_DATA # type: int - - -class PKCS7_Error(Exception): - pass - - -m2.pkcs7_init(PKCS7_Error) - - -class PKCS7(object): - - m2_pkcs7_free = m2.pkcs7_free - - def __init__(self, pkcs7=None, _pyfree=0): - # type: (Optional[bytes], int) -> None - """PKCS7 object. - - :param pkcs7: binary representation of - the OpenSSL type PKCS7 - """ - if pkcs7 is not None: - self.pkcs7 = pkcs7 - self._pyfree = _pyfree - else: - self.pkcs7 = m2.pkcs7_new() - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_pkcs7_free(self.pkcs7) - - def _ptr(self): - return self.pkcs7 - - def type(self, text_name=0): - # type: (int) -> int - if text_name: - return m2.pkcs7_type_sn(self.pkcs7) - else: - return m2.pkcs7_type_nid(self.pkcs7) - - def write(self, bio): - # type: (BIO.BIO) -> int - return m2.pkcs7_write_bio(self.pkcs7, bio._ptr()) - - def write_der(self, bio): - # type: (BIO.BIO) -> int - return m2.pkcs7_write_bio_der(self.pkcs7, bio._ptr()) - - def get0_signers(self, certs, flags=0): - # type: (X509.X509_Stack, int) -> X509.X509_Stack - return X509.X509_Stack(m2.pkcs7_get0_signers(self.pkcs7, - certs.stack, flags), 1) - - -def load_pkcs7(p7file): - # type: (AnyStr) -> PKCS7 - with BIO.openfile(p7file, 'r') as bio: - p7_ptr = m2.pkcs7_read_bio(bio.bio) - - return PKCS7(p7_ptr, 1) - - -def load_pkcs7_der(p7file): - # type: (AnyStr) -> PKCS7 - with BIO.openfile(p7file, 'rb') as bio: - p7_ptr = m2.pkcs7_read_bio_der(bio.bio) - - return PKCS7(p7_ptr, 1) - - -def load_pkcs7_bio(p7_bio): - # type: (BIO.BIO) -> PKCS7 - p7_ptr = m2.pkcs7_read_bio(p7_bio._ptr()) - return PKCS7(p7_ptr, 1) - - -def load_pkcs7_bio_der(p7_bio): - # type: (BIO.BIO) -> PKCS7 - p7_ptr = m2.pkcs7_read_bio_der(p7_bio._ptr()) - return PKCS7(p7_ptr, 1) - - -def smime_load_pkcs7(p7file): - # type: (AnyStr) -> PKCS7 - bio = m2.bio_new_file(p7file, 'r') - - try: - p7_ptr, bio_ptr = m2.smime_read_pkcs7(bio) - finally: - m2.bio_free(bio) - - if bio_ptr is None: - return PKCS7(p7_ptr, 1), None - else: - return PKCS7(p7_ptr, 1), BIO.BIO(bio_ptr, 1) - - -def smime_load_pkcs7_bio(p7_bio): - # type: (BIO.BIO) -> PKCS7 - p7_ptr, bio_ptr = m2.smime_read_pkcs7(p7_bio._ptr()) - if p7_ptr is None: - raise SMIME_Error(Err.get_error()) - if bio_ptr is None: - return PKCS7(p7_ptr, 1), None - else: - return PKCS7(p7_ptr, 1), BIO.BIO(bio_ptr, 1) - - -class Cipher(object): - """Object interface to EVP_CIPHER without all the frills of - M2Crypto.EVP.Cipher. - """ - - def __init__(self, algo): - # type: (str) -> None - cipher = getattr(m2, algo, None) - if cipher is None: - raise ValueError('unknown cipher', algo) - self.cipher = cipher() - - def _ptr(self): - return self.cipher - - -class SMIME_Error(Exception): - pass - -m2.smime_init(SMIME_Error) - - -# FIXME class has no __init__ method -class SMIME(object): - def load_key(self, keyfile, certfile=None, - callback=util.passphrase_callback): - # type: (AnyStr, Optional[AnyStr], Callable) -> None - if certfile is None: - certfile = keyfile - self.pkey = EVP.load_key(keyfile, callback) - self.x509 = X509.load_cert(certfile) - - def load_key_bio(self, keybio, certbio=None, - callback=util.passphrase_callback): - # type: (BIO.BIO, Optional[BIO.BIO], Callable) -> None - if certbio is None: - certbio = keybio - self.pkey = EVP.load_key_bio(keybio, callback) - self.x509 = X509.load_cert_bio(certbio) - - def set_x509_stack(self, stack): - # type: (X509.X509_Stack) -> None - assert isinstance(stack, X509.X509_Stack) - self.x509_stack = stack - - def set_x509_store(self, store): - # type: (X509.X509_Store) -> None - assert isinstance(store, X509.X509_Store) - self.x509_store = store - - def set_cipher(self, cipher): - # type: (Cipher) -> None - assert isinstance(cipher, Cipher) - self.cipher = cipher - - def unset_key(self): - # type: () -> None - del self.pkey - del self.x509 - - def unset_x509_stack(self): - # type: () -> None - del self.x509_stack - - def unset_x509_store(self): - # type: () -> None - del self.x509_store - - def unset_cipher(self): - # type: () -> None - del self.cipher - - def encrypt(self, data_bio, flags=0): - # type: (BIO.BIO, int) -> PKCS7 - if not hasattr(self, 'cipher'): - raise SMIME_Error('no cipher: use set_cipher()') - if not hasattr(self, 'x509_stack'): - raise SMIME_Error('no recipient certs: use set_x509_stack()') - - pkcs7 = m2.pkcs7_encrypt(self.x509_stack._ptr(), data_bio._ptr(), - self.cipher._ptr(), flags) - - return PKCS7(pkcs7, 1) - - def decrypt(self, pkcs7, flags=0): - # type: (PKCS7, int) -> Optional[bytes] - if not hasattr(self, 'pkey'): - raise SMIME_Error('no private key: use load_key()') - if not hasattr(self, 'x509'): - raise SMIME_Error('no certificate: load_key() used incorrectly?') - blob = m2.pkcs7_decrypt(pkcs7._ptr(), self.pkey._ptr(), - self.x509._ptr(), flags) - return blob - - def sign(self, data_bio, flags=0, algo='sha1'): - # type: (BIO.BIO, int, Optional[str]) -> PKCS7 - if not hasattr(self, 'pkey'): - raise SMIME_Error('no private key: use load_key()') - - hash = getattr(m2, algo, None) - - if hash is None: - raise SMIME_Error('no such hash algorithm %s' % algo) - - if hasattr(self, 'x509_stack'): - pkcs7 = m2.pkcs7_sign1(self.x509._ptr(), self.pkey._ptr(), - self.x509_stack._ptr(), - data_bio._ptr(), hash(), flags) - return PKCS7(pkcs7, 1) - else: - pkcs7 = m2.pkcs7_sign0(self.x509._ptr(), self.pkey._ptr(), - data_bio._ptr(), hash(), flags) - return PKCS7(pkcs7, 1) - - def verify(self, pkcs7, data_bio=None, flags=0): - # type: (PKCS7, BIO.BIO, int) -> Optional[bytes] - if not hasattr(self, 'x509_stack'): - raise SMIME_Error('no signer certs: use set_x509_stack()') - if not hasattr(self, 'x509_store'): - raise SMIME_Error('no x509 cert store: use set_x509_store()') - assert isinstance(pkcs7, PKCS7), 'pkcs7 not an instance of PKCS7' - p7 = pkcs7._ptr() - if data_bio is None: - blob = m2.pkcs7_verify0(p7, self.x509_stack._ptr(), - self.x509_store._ptr(), flags) - else: - blob = m2.pkcs7_verify1(p7, self.x509_stack._ptr(), - self.x509_store._ptr(), - data_bio._ptr(), flags) - return blob - - def write(self, out_bio, pkcs7, data_bio=None, flags=0): - # type: (BIO.BIO, PKCS7, Optional[BIO.BIO], int) -> int - assert isinstance(pkcs7, PKCS7) - if data_bio is None: - return m2.smime_write_pkcs7(out_bio._ptr(), pkcs7._ptr(), flags) - else: - return m2.smime_write_pkcs7_multi(out_bio._ptr(), pkcs7._ptr(), - data_bio._ptr(), flags) - - -def text_crlf(text): - # type: (bytes) -> bytes - bio_in = BIO.MemoryBuffer(text) - bio_out = BIO.MemoryBuffer() - if m2.smime_crlf_copy(bio_in._ptr(), bio_out._ptr()): - return bio_out.read() - else: - raise SMIME_Error(Err.get_error()) - - -def text_crlf_bio(bio_in): - # type: (BIO.BIO) -> BIO.BIO - bio_out = BIO.MemoryBuffer() - if m2.smime_crlf_copy(bio_in._ptr(), bio_out._ptr()): - return bio_out - else: - raise SMIME_Error(Err.get_error()) diff --git a/M2Crypto/SSL/Checker.py b/M2Crypto/SSL/Checker.py deleted file mode 100644 index 46d397a..0000000 --- a/M2Crypto/SSL/Checker.py +++ /dev/null @@ -1,296 +0,0 @@ -""" -SSL peer certificate checking routines - -Copyright (c) 2004-2007 Open Source Applications Foundation. -All rights reserved. - -Copyright 2008 Heikki Toivonen. All rights reserved. -""" - -__all__ = ['SSLVerificationError', 'NoCertificate', 'WrongCertificate', - 'WrongHost', 'Checker'] - -import re -import socket - -from M2Crypto import X509, m2, six # noqa -from typing import AnyStr, Optional # noqa - - -class SSLVerificationError(Exception): - pass - - -class NoCertificate(SSLVerificationError): - pass - - -class WrongCertificate(SSLVerificationError): - pass - - -class WrongHost(SSLVerificationError): - def __init__(self, expectedHost, actualHost, fieldName='commonName'): - # type: (str, AnyStr, str) -> None - """ - This exception will be raised if the certificate returned by the - peer was issued for a different host than we tried to connect to. - This could be due to a server misconfiguration or an active attack. - - :param expectedHost: The name of the host we expected to find in the - certificate. - :param actualHost: The name of the host we actually found in the - certificate. - :param fieldName: The field name where we noticed the error. This - should be either 'commonName' or 'subjectAltName'. - """ - if fieldName not in ('commonName', 'subjectAltName'): - raise ValueError( - 'Unknown fieldName, should be either commonName ' + - 'or subjectAltName') - - SSLVerificationError.__init__(self) - self.expectedHost = expectedHost - self.actualHost = actualHost - self.fieldName = fieldName - - def __str__(self): - # type: () -> str - s = 'Peer certificate %s does not match host, expected %s, got %s' \ - % (self.fieldName, self.expectedHost, self.actualHost) - return six.ensure_text(s) - - -class Checker(object): - - numericIpMatch = re.compile('^[0-9]+(\.[0-9]+)*$') - - def __init__(self, host=None, peerCertHash=None, peerCertDigest='sha1'): - # type: (Optional[str], Optional[bytes], str) -> None - self.host = host - if peerCertHash is not None: - peerCertHash = six.ensure_binary(peerCertHash) - self.fingerprint = peerCertHash - self.digest = peerCertDigest # type: str - - def __call__(self, peerCert, host=None): - # type: (X509.X509, Optional[str]) -> bool - if peerCert is None: - raise NoCertificate('peer did not return certificate') - - if host is not None: - self.host = host # type: str - - if self.fingerprint: - if self.digest not in ('sha1', 'md5'): - raise ValueError('unsupported digest "%s"' % self.digest) - - if self.digest == 'sha1': - expected_len = 40 - elif self.digest == 'md5': - expected_len = 32 - else: - raise ValueError('Unexpected digest {0}'.format(self.digest)) - - if len(self.fingerprint) != expected_len: - raise WrongCertificate( - ('peer certificate fingerprint length does not match\n' + - 'fingerprint: {0}\nexpected = {1}\n' + - 'observed = {2}').format(self.fingerprint, - expected_len, - len(self.fingerprint))) - - expected_fingerprint = six.ensure_text(self.fingerprint) - observed_fingerprint = peerCert.get_fingerprint(md=self.digest) - if observed_fingerprint != expected_fingerprint: - raise WrongCertificate( - ('peer certificate fingerprint does not match\n' + - 'expected = {0},\n' + - 'observed = {1}').format(expected_fingerprint, - observed_fingerprint)) - - if self.host: - hostValidationPassed = False - self.useSubjectAltNameOnly = False - - # subjectAltName=DNS:somehost[, ...]* - try: - subjectAltName = peerCert.get_ext('subjectAltName').get_value() - if self._splitSubjectAltName(self.host, subjectAltName): - hostValidationPassed = True - elif self.useSubjectAltNameOnly: - raise WrongHost(expectedHost=self.host, - actualHost=subjectAltName, - fieldName='subjectAltName') - except LookupError: - pass - - # commonName=somehost[, ...]* - if not hostValidationPassed: - hasCommonName = False - commonNames = '' - for entry in peerCert.get_subject().get_entries_by_nid( - m2.NID_commonName): - hasCommonName = True - commonName = entry.get_data().as_text() - if not commonNames: - commonNames = commonName - else: - commonNames += ',' + commonName - if self._match(self.host, commonName): - hostValidationPassed = True - break - - if not hasCommonName: - raise WrongCertificate('no commonName in peer certificate') - - if not hostValidationPassed: - raise WrongHost(expectedHost=self.host, - actualHost=commonNames, - fieldName='commonName') - - return True - - def _splitSubjectAltName(self, host, subjectAltName): - # type: (AnyStr, AnyStr) -> bool - """ - >>> check = Checker() - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:my.example.com') - True - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:*.example.com') - True - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:m*.example.com') - True - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:m*ample.com') - False - >>> check.useSubjectAltNameOnly - True - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:m*ample.com, othername:') - False - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:m*ample.com, DNS:my.example.org') - False - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:m*ample.com, DNS:my.example.com') - True - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='DNS:my.example.com, DNS:my.example.org') - True - >>> check.useSubjectAltNameOnly - True - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='') - False - >>> check._splitSubjectAltName(host='my.example.com', - ... subjectAltName='othername:') - False - >>> check.useSubjectAltNameOnly - False - """ - self.useSubjectAltNameOnly = False - for certHost in subjectAltName.split(','): - certHost = certHost.lower().strip() - if certHost[:4] == 'dns:': - self.useSubjectAltNameOnly = True - if self._match(host, certHost[4:]): - return True - elif certHost[:11] == 'ip address:': - self.useSubjectAltNameOnly = True - if self._matchIPAddress(host, certHost[11:]): - return True - return False - - def _match(self, host, certHost): - # type: (str, str) -> bool - """ - >>> check = Checker() - >>> check._match(host='my.example.com', certHost='my.example.com') - True - >>> check._match(host='my.example.com', certHost='*.example.com') - True - >>> check._match(host='my.example.com', certHost='m*.example.com') - True - >>> check._match(host='my.example.com', certHost='m*.EXAMPLE.com') - True - >>> check._match(host='my.example.com', certHost='m*ample.com') - False - >>> check._match(host='my.example.com', certHost='*.*.com') - False - >>> check._match(host='1.2.3.4', certHost='1.2.3.4') - True - >>> check._match(host='1.2.3.4', certHost='*.2.3.4') - False - >>> check._match(host='1234', certHost='1234') - True - """ - # XXX See RFC 2818 and 3280 for matching rules, this is may not - # XXX yet be complete. - - host = host.lower() - certHost = certHost.lower() - - if host == certHost: - return True - - if certHost.count('*') > 1: - # Not sure about this, but being conservative - return False - - if self.numericIpMatch.match(host) or \ - self.numericIpMatch.match(certHost.replace('*', '')): - # Not sure if * allowed in numeric IP, but think not. - return False - - if certHost.find('\\') > -1: - # Not sure about this, maybe some encoding might have these. - # But being conservative for now, because regex below relies - # on this. - return False - - # Massage certHost so that it can be used in regex - certHost = certHost.replace('.', '\.') - certHost = certHost.replace('*', '[^\.]*') - if re.compile('^%s$' % certHost).match(host): - return True - - return False - - def _matchIPAddress(self, host, certHost): - # type: (AnyStr, AnyStr) -> bool - """ - >>> check = Checker() - >>> check._matchIPAddress(host='my.example.com', - ... certHost='my.example.com') - False - >>> check._matchIPAddress(host='1.2.3.4', certHost='1.2.3.4') - True - >>> check._matchIPAddress(host='1.2.3.4', certHost='*.2.3.4') - False - >>> check._matchIPAddress(host='1.2.3.4', certHost='1.2.3.40') - False - >>> check._matchIPAddress(host='::1', certHost='::1') - True - >>> check._matchIPAddress(host='::1', certHost='0:0:0:0:0:0:0:1') - True - >>> check._matchIPAddress(host='::1', certHost='::2') - False - """ - try: - canonical = socket.getaddrinfo(host, 0, 0, socket.SOCK_STREAM, 0, - socket.AI_NUMERICHOST) - certCanonical = socket.getaddrinfo(certHost, 0, 0, - socket.SOCK_STREAM, 0, - socket.AI_NUMERICHOST) - except: - return False - return canonical == certCanonical - - -if __name__ == '__main__': - import doctest - doctest.testmod() diff --git a/M2Crypto/SSL/Cipher.py b/M2Crypto/SSL/Cipher.py deleted file mode 100644 index 06f2dbf..0000000 --- a/M2Crypto/SSL/Cipher.py +++ /dev/null @@ -1,59 +0,0 @@ -"""SSL Ciphers - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -__all__ = ['Cipher', 'Cipher_Stack'] - -from M2Crypto import m2, six -from typing import Iterable # noqa - - -class Cipher(object): - def __init__(self, cipher): - # type: (str) -> None - self.cipher = cipher - - def __len__(self): - # type: () -> int - return m2.ssl_cipher_get_bits(self.cipher) - - def __repr__(self): - # type: () -> str - return "%s-%s" % (self.name(), len(self)) - - def __str__(self): - # type: () -> str - return "%s-%s" % (self.name(), len(self)) - - def version(self): - # type: () -> int - return m2.ssl_cipher_get_version(self.cipher) - - def name(self): - # type: () -> str - return six.ensure_text(m2.ssl_cipher_get_name(self.cipher)) - - -class Cipher_Stack(object): - def __init__(self, stack): - # type: (bytes) -> None - """ - :param stack: binary of the C-type STACK_OF(SSL_CIPHER) - """ - self.stack = stack - - def __len__(self): - # type: () -> int - return m2.sk_ssl_cipher_num(self.stack) - - def __getitem__(self, idx): - # type: (int) -> Cipher - if not 0 <= idx < m2.sk_ssl_cipher_num(self.stack): - raise IndexError('index out of range') - v = m2.sk_ssl_cipher_value(self.stack, idx) - return Cipher(v) - - def __iter__(self): - # type: () -> Iterable - for i in six.moves.range(m2.sk_ssl_cipher_num(self.stack)): - yield self[i] diff --git a/M2Crypto/SSL/Connection.py b/M2Crypto/SSL/Connection.py deleted file mode 100644 index c5693c9..0000000 --- a/M2Crypto/SSL/Connection.py +++ /dev/null @@ -1,712 +0,0 @@ -from __future__ import absolute_import - -"""SSL Connection aka socket - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - -Portions created by Open Source Applications Foundation (OSAF) are -Copyright (C) 2004-2007 OSAF. All Rights Reserved. - -Copyright 2008 Heikki Toivonen. All rights reserved. -""" - -import logging -import socket -import io - -from M2Crypto import BIO, Err, X509, m2, six, util # noqa -from M2Crypto.SSL import Checker, Context, timeout # noqa -from M2Crypto.SSL import SSLError -from M2Crypto.SSL.Cipher import Cipher, Cipher_Stack -from M2Crypto.SSL.Session import Session -from typing import Any, AnyStr, Callable, Optional, Tuple, Union # noqa - -__all__ = ['Connection', - 'timeout', # XXX Not really, but for documentation purposes - ] - -log = logging.getLogger(__name__) - - -def _serverPostConnectionCheck(*args, **kw): - # type: (*Any, **Any) -> int - return 1 - - -class Connection(object): - """An SSL connection.""" - - serverPostConnectionCheck = _serverPostConnectionCheck - - m2_bio_free = m2.bio_free - m2_ssl_free = m2.ssl_free - m2_bio_noclose = m2.bio_noclose - - def __init__(self, ctx, sock=None, family=socket.AF_INET): - # type: (Context, socket.socket, int) -> None - """ - - :param ctx: SSL.Context - :param sock: socket to be used - :param family: socket family - """ - # The Checker needs to be an instance attribute - # and not a class attribute for thread safety reason - self.clientPostConnectionCheck = Checker.Checker() - - self._bio_freed = False - self.ctx = ctx - self.ssl = m2.ssl_new(self.ctx.ctx) # type: bytes - if sock is not None: - self.socket = sock - else: - self.socket = socket.socket(family, socket.SOCK_STREAM) - self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self._fileno = self.socket.fileno() - - self._timeout = self.socket.gettimeout() - if self._timeout is None: - self._timeout = -1.0 - - self.ssl_close_flag = m2.bio_noclose - - if self.ctx.post_connection_check is not None: - self.set_post_connection_check_callback( - self.ctx.post_connection_check) - - self.host = None - - def _free_bio(self): - """ - Free the sslbio and sockbio, and close the socket. - """ - # Do not do it twice - if not self._bio_freed: - if getattr(self, 'sslbio', None): - self.m2_bio_free(self.sslbio) - if getattr(self, 'sockbio', None): - self.m2_bio_free(self.sockbio) - if self.ssl_close_flag == self.m2_bio_noclose and \ - getattr(self, 'ssl', None): - self.m2_ssl_free(self.ssl) - self.socket.close() - self._bio_freed = True - - - def __del__(self): - # type: () -> None - # Notice that M2Crypto doesn't automatically shuts down the - # connection here. You have to call self.close() in your - # program, M2Crypto won't do it automatically for you. - self._free_bio() - - def close(self, freeBio=False): - """ - if freeBio is true, call _free_bio - """ - # type: () -> None - m2.ssl_shutdown(self.ssl) - if freeBio: - self._free_bio() - - def clear(self): - # type: () -> int - """ - If there were errors in this connection, call clear() rather - than close() to end it, so that bad sessions will be cleared - from cache. - """ - return m2.ssl_clear(self.ssl) - - def set_shutdown(self, mode): - # type: (int) -> None - """Sets the shutdown state of the Connection to mode. - - The shutdown state of an ssl connection is a bitmask of (use - m2.SSL_* constants): - - 0 No shutdown setting, yet. - - SSL_SENT_SHUTDOWN - A "close notify" shutdown alert was sent to the peer, the - connection is being considered closed and the session is - closed and correct. - - SSL_RECEIVED_SHUTDOWN - A shutdown alert was received form the peer, either a normal - "close notify" or a fatal error. - - SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN can be set at the - same time. - - :param mode: set the mode bitmask. - """ - m2.ssl_set_shutdown1(self.ssl, mode) - - def get_shutdown(self): - # type: () -> None - """Get the current shutdown mode of the Connection.""" - return m2.ssl_get_shutdown(self.ssl) - - def bind(self, addr): - # type: (util.AddrType) -> None - self.socket.bind(addr) - - def listen(self, qlen=5): - # type: (int) -> None - self.socket.listen(qlen) - - def ssl_get_error(self, ret): - # type: (int) -> int - return m2.ssl_get_error(self.ssl, ret) - - def set_bio(self, readbio, writebio): - # type: (BIO.BIO, BIO.BIO) -> None - """Explicitly set read and write bios - - Connects the BIOs for the read and write operations of the - TLS/SSL (encrypted) side of ssl. - - The SSL engine inherits the behaviour of both BIO objects, - respectively. If a BIO is non-blocking, the Connection will also - have non-blocking behaviour. - - If there was already a BIO connected to Connection, BIO_free() - will be called (for both the reading and writing side, if - different). - - :param readbio: BIO for reading - :param writebio: BIO for writing. - """ - m2.ssl_set_bio(self.ssl, readbio._ptr(), writebio._ptr()) - - def set_client_CA_list_from_file(self, cafile): - # type: (AnyStr) -> None - """Set the acceptable client CA list. - - If the client returns a certificate, it must have been issued by - one of the CAs listed in cafile. - - Makes sense only for servers. - - :param cafile: Filename from which to load the CA list. - - :return: 0 A failure while manipulating the STACK_OF(X509_NAME) - object occurred or the X509_NAME could not be - extracted from cacert. Check the error stack to find - out the reason. - - 1 The operation succeeded. - """ - m2.ssl_set_client_CA_list_from_file(self.ssl, cafile) - - def set_client_CA_list_from_context(self): - # type: () -> None - """ - Set the acceptable client CA list. If the client - returns a certificate, it must have been issued by - one of the CAs listed in context. - - Makes sense only for servers. - """ - m2.ssl_set_client_CA_list_from_context(self.ssl, self.ctx.ctx) - - def setup_addr(self, addr): - # type: (util.AddrType) -> None - self.addr = addr - - def set_ssl_close_flag(self, flag): - # type: (int) -> None - """ - By default, SSL struct will be freed in __del__. Call with - m2.bio_close to override this default. - - :param flag: either m2.bio_close or m2.bio_noclose - """ - if flag not in (m2.bio_close, m2.bio_noclose): - raise ValueError("flag must be m2.bio_close or m2.bio_noclose") - self.ssl_close_flag = flag - - def setup_ssl(self): - # type: () -> None - # Make a BIO_s_socket. - self.sockbio = m2.bio_new_socket(self.socket.fileno(), 0) - # Link SSL struct with the BIO_socket. - m2.ssl_set_bio(self.ssl, self.sockbio, self.sockbio) - # Make a BIO_f_ssl. - self.sslbio = m2.bio_new(m2.bio_f_ssl()) - # Link BIO_f_ssl with the SSL struct. - m2.bio_set_ssl(self.sslbio, self.ssl, m2.bio_noclose) - - def _setup_ssl(self, addr): - # type: (util.AddrType) -> None - """Deprecated""" - self.setup_addr(addr) - self.setup_ssl() - - def set_accept_state(self): - # type: () -> None - """Sets Connection to work in the server mode.""" - m2.ssl_set_accept_state(self.ssl) - - def accept_ssl(self): - # type: () -> Optional[int] - """Waits for a TLS/SSL client to initiate the TLS/SSL handshake. - - The communication channel must already have been set and - assigned to the ssl by setting an underlying BIO. - - :return: 0 The TLS/SSL handshake was not successful but was shut - down controlled and by the specifications of the - TLS/SSL protocol. Call get_error() with the return - value ret to find out the reason. - - 1 The TLS/SSL handshake was successfully completed, - a TLS/SSL connection has been established. - - <0 The TLS/SSL handshake was not successful because - a fatal error occurred either at the protocol level - or a connection failure occurred. The shutdown was - not clean. It can also occur of action is need to - continue the operation for non-blocking BIOs. Call - get_error() with the return value ret to find - out the reason. - """ - return m2.ssl_accept(self.ssl, self._timeout) - - def accept(self): - # type: () -> Tuple[Connection, util.AddrType] - """Accept an SSL connection. - - The return value is a pair (ssl, addr) where ssl is a new SSL - connection object and addr is the address bound to the other end - of the SSL connection. - - :return: tuple of Connection and addr. Address can take very - various forms (see socket documentation), for IPv4 it - is tuple(str, int), for IPv6 a tuple of four (host, - port, flowinfo, scopeid), where the last two are - optional ints. - """ - sock, addr = self.socket.accept() - ssl = Connection(self.ctx, sock) - ssl.addr = addr - ssl.setup_ssl() - ssl.set_accept_state() - ssl.accept_ssl() - check = getattr(self, 'postConnectionCheck', - self.serverPostConnectionCheck) - if check is not None: - if not check(ssl.get_peer_cert(), ssl.addr[0]): - raise Checker.SSLVerificationError( - 'post connection check failed') - return ssl, addr - - def set_connect_state(self): - # type: () -> None - """Sets Connection to work in the client mode.""" - m2.ssl_set_connect_state(self.ssl) - - def connect_ssl(self): - # type: () -> Optional[int] - return m2.ssl_connect(self.ssl, self._timeout) - - def connect(self, addr): - # type: (util.AddrType) -> int - """Overloading socket.connect() - - :param addr: addresses have various depending on their type - - :return:status of ssl_connect() - """ - self.socket.connect(addr) - self.addr = addr - self.setup_ssl() - self.set_connect_state() - ret = self.connect_ssl() - check = getattr(self, 'postConnectionCheck', - self.clientPostConnectionCheck) - if check is not None: - if not check(self.get_peer_cert(), - self.host if self.host else self.addr[0]): - raise Checker.SSLVerificationError( - 'post connection check failed') - return ret - - def shutdown(self, how): - # type: (int) -> None - m2.ssl_set_shutdown(self.ssl, how) - - def renegotiate(self): - # type: () -> int - """Renegotiate this connection's SSL parameters.""" - return m2.ssl_renegotiate(self.ssl) - - def pending(self): - # type: () -> int - """Return the numbers of octets that can be read from the connection.""" - return m2.ssl_pending(self.ssl) - - def _write_bio(self, data): - # type: (bytes) -> int - return m2.ssl_write(self.ssl, data, self._timeout) - - def _write_nbio(self, data): - # type: (bytes) -> int - return m2.ssl_write_nbio(self.ssl, data) - - def _read_bio(self, size=1024): - # type: (int) -> bytes - if size <= 0: - raise ValueError('size <= 0') - return m2.ssl_read(self.ssl, size, self._timeout) - - def _read_nbio(self, size=1024): - # type: (int) -> bytes - if size <= 0: - raise ValueError('size <= 0') - return m2.ssl_read_nbio(self.ssl, size) - - def write(self, data): - # type: (bytes) -> int - if self._timeout != 0.0: - return self._write_bio(data) - return self._write_nbio(data) - sendall = send = write - - def _decref_socketios(self): - pass - - def recv_into(self, buff, nbytes=0): - # type: (Union[bytearray, memoryview], int) -> int - """ - A version of recv() that stores its data into a buffer rather - than creating a new string. Receive up to buffersize bytes from - the socket. If buffersize is not specified (or 0), receive up - to the size available in the given buffer. - - If buff is bytearray, it will have after return length of the - actually returned number of bytes. If buff is memoryview, then - the size of buff won't change (it cannot), but all bytes after - the number of returned bytes will be NULL. - - :param buffer: a buffer for the received bytes - :param nbytes: maximum number of bytes to read - :return: number of bytes read - - See recv() for documentation about the flags. - """ - n = len(buff) if nbytes == 0 else nbytes - - if n <= 0: - raise ValueError('size <= 0') - - # buff_bytes are actual bytes returned - buff_bytes = m2.ssl_read(self.ssl, n, self._timeout) - buflen = len(buff_bytes) - - # memoryview type has been added in 2.7 - if isinstance(buff, memoryview): - buff[:buflen] = buff_bytes - buff[buflen:] = b'\x00' * (len(buff) - buflen) - else: - buff[:] = buff_bytes - - return buflen - - def read(self, size=1024): - # type: (int) -> bytes - if self._timeout != 0.0: - return self._read_bio(size) - return self._read_nbio(size) - recv = read - - def setblocking(self, mode): - # type: (int) -> None - """Set this connection's underlying socket to _mode_. - - Set blocking or non-blocking mode of the socket: if flag is 0, - the socket is set to non-blocking, else to blocking mode. - Initially all sockets are in blocking mode. In non-blocking mode, - if a recv() call doesn't find any data, or if a send() call can't - immediately dispose of the data, a error exception is raised; - in blocking mode, the calls block until they can proceed. - s.setblocking(0) is equivalent to s.settimeout(0.0); - s.setblocking(1) is equivalent to s.settimeout(None). - - :param mode: new mode to be set - """ - self.socket.setblocking(mode) - if mode: - self._timeout = -1.0 - else: - self._timeout = 0.0 - - def settimeout(self, timeout): - # type: (float) -> None - """Set this connection's underlying socket's timeout to _timeout_.""" - self.socket.settimeout(timeout) - self._timeout = timeout - if self._timeout is None: - self._timeout = -1.0 - - def fileno(self): - # type: () -> int - return self.socket.fileno() - - def getsockopt(self, level, optname, buflen=None): - # type: (int, int, Optional[int]) -> Union[int, bytes] - """Get the value of the given socket option. - - :param level: level at which the option resides. - To manipulate options at the sockets API level, level is - specified as socket.SOL_SOCKET. To manipulate options at - any other level the protocol number of the appropriate - protocol controlling the option is supplied. For example, - to indicate that an option is to be interpreted by the - TCP protocol, level should be set to the protocol number - of socket.SOL_TCP; see getprotoent(3). - - :param optname: The value of the given socket option is - described in the Unix man page getsockopt(2)). The needed - symbolic constants (SO_* etc.) are defined in the socket - module. - - :param buflen: If it is absent, an integer option is assumed - and its integer value is returned by the function. If - buflen is present, it specifies the maximum length of the - buffer used to receive the option in, and this buffer is - returned as a bytes object. - - :return: Either integer or bytes value of the option. It is up - to the caller to decode the contents of the buffer (see - the optional built-in module struct for a way to decode - C structures encoded as byte strings). - """ - return self.socket.getsockopt(level, optname, buflen) - - def setsockopt(self, level, optname, value=None): - # type: (int, int, Union[int, bytes, None]) -> Optional[bytes] - """Set the value of the given socket option. - - :param level: same as with getsockopt() above - - :param optname: same as with getsockopt() above - - :param value: an integer or a string representing a buffer. In - the latter case it is up to the caller to ensure - that the string contains the proper bits (see the - optional built-in module struct for a way to - encode C structures as strings). - - :return: None for success or the error handler for failure. - """ - return self.socket.setsockopt(level, optname, value) - - def get_context(self): - # type: () -> Context - """Return the Context object associated with this connection.""" - return m2.ssl_get_ssl_ctx(self.ssl) - - def get_state(self): - # type: () -> bytes - """Return the SSL state of this connection. - - During its use, an SSL objects passes several states. The state - is internally maintained. Querying the state information is not - very informative before or when a connection has been - established. It however can be of significant interest during - the handshake. - - :return: 6 letter string indicating the current state of the SSL - object ssl. - """ - return m2.ssl_get_state(self.ssl) - - def verify_ok(self): - # type: () -> bool - return (m2.ssl_get_verify_result(self.ssl) == m2.X509_V_OK) - - def get_verify_mode(self): - # type: () -> int - """Return the peer certificate verification mode.""" - return m2.ssl_get_verify_mode(self.ssl) - - def get_verify_depth(self): - # type: () -> int - """Return the peer certificate verification depth.""" - return m2.ssl_get_verify_depth(self.ssl) - - def get_verify_result(self): - # type: () -> int - """Return the peer certificate verification result.""" - return m2.ssl_get_verify_result(self.ssl) - - def get_peer_cert(self): - # type: () -> X509.X509 - """Return the peer certificate. - - If the peer did not provide a certificate, return None. - """ - c = m2.ssl_get_peer_cert(self.ssl) - if c is None: - return None - # Need to free the pointer coz OpenSSL doesn't. - return X509.X509(c, 1) - - def get_peer_cert_chain(self): - # type: () -> Optional[X509.X509_Stack] - """Return the peer certificate chain; if the peer did not provide - a certificate chain, return None. - - :warning: The returned chain will be valid only for as long as the - connection object is alive. Once the connection object - gets freed, the chain will be freed as well. - """ - c = m2.ssl_get_peer_cert_chain(self.ssl) - if c is None: - return None - # No need to free the pointer coz OpenSSL does. - return X509.X509_Stack(c) - - def get_cipher(self): - # type: () -> Optional[Cipher] - """Return an M2Crypto.SSL.Cipher object for this connection; if the - connection has not been initialised with a cipher suite, return None. - """ - c = m2.ssl_get_current_cipher(self.ssl) - if c is None: - return None - return Cipher(c) - - def get_ciphers(self): - # type: () -> Optional[Cipher_Stack] - """Return an M2Crypto.SSL.Cipher_Stack object for this - connection; if the connection has not been initialised with - cipher suites, return None. - """ - c = m2.ssl_get_ciphers(self.ssl) - if c is None: - return None - return Cipher_Stack(c) - - def get_cipher_list(self, idx=0): - # type: (int) -> str - """Return the cipher suites for this connection as a string object.""" - return six.ensure_text(m2.ssl_get_cipher_list(self.ssl, idx)) - - def set_cipher_list(self, cipher_list): - # type: (str) -> int - """Set the cipher suites for this connection.""" - return m2.ssl_set_cipher_list(self.ssl, cipher_list) - - def makefile(self, mode='rb', bufsize=-1): - # type: (AnyStr, int) -> Union[io.BufferedRWPair,io.BufferedReader] - if six.PY3: - raw = socket.SocketIO(self, mode) - if 'rw' in mode: - return io.BufferedRWPair(raw, raw) - return io.BufferedReader(raw, io.DEFAULT_BUFFER_SIZE) - else: - return socket._fileobject(self, mode, bufsize) - - def getsockname(self): - # type: () -> util.AddrType - """Return the socket's own address. - - This is useful to find out the port number of an IPv4/v6 socket, - for instance. (The format of the address returned depends - on the address family -- see above.) - - :return:socket's address as addr type - """ - return self.socket.getsockname() - - def getpeername(self): - # type: () -> util.AddrType - """Return the remote address to which the socket is connected. - - This is useful to find out the port number of a remote IPv4/v6 socket, - for instance. - On some systems this function is not supported. - - :return: - """ - return self.socket.getpeername() - - def set_session_id_ctx(self, id): - # type: (bytes) -> int - ret = m2.ssl_set_session_id_context(self.ssl, id) - if not ret: - raise SSLError(Err.get_error_message()) - - def get_session(self): - # type: () -> Session - sess = m2.ssl_get_session(self.ssl) - return Session(sess) - - def set_session(self, session): - # type: (Session) -> None - m2.ssl_set_session(self.ssl, session._ptr()) - - def get_default_session_timeout(self): - # type: () -> int - return m2.ssl_get_default_session_timeout(self.ssl) - - def get_socket_read_timeout(self): - # type: () -> timeout - return timeout.struct_to_timeout( - self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, - timeout.struct_size())) - - @staticmethod - def _hexdump(s): - assert isinstance(s, six.binary_type) - return ":".join("{0:02x}".format(ord(c) if six.PY2 else c) for c in s) - - def get_socket_write_timeout(self): - # type: () -> timeout - binstr = self.socket.getsockopt( - socket.SOL_SOCKET, socket.SO_SNDTIMEO, timeout.struct_size()) - timeo = timeout.struct_to_timeout(binstr) - # print("Debug: get_socket_write_timeout: " - # "get sockopt value: %s -> ret timeout(sec=%r, microsec=%r)" % - # (self._hexdump(binstr), timeo.sec, timeo.microsec)) - return timeo - - def set_socket_read_timeout(self, timeo): - # type: (timeout) -> None - assert isinstance(timeo, timeout.timeout) - self.socket.setsockopt( - socket.SOL_SOCKET, socket.SO_RCVTIMEO, timeo.pack()) - - def set_socket_write_timeout(self, timeo): - # type: (timeout) -> None - assert isinstance(timeo, timeout.timeout) - binstr = timeo.pack() - # print("Debug: set_socket_write_timeout: " - # "input timeout(sec=%r, microsec=%r) -> set sockopt value: %s" % - # (timeo.sec, timeo.microsec, self._hexdump(binstr))) - self.socket.setsockopt( - socket.SOL_SOCKET, socket.SO_SNDTIMEO, binstr) - - def get_version(self): - # type: () -> str - """Return the TLS/SSL protocol version for this connection.""" - return six.ensure_text(m2.ssl_get_version(self.ssl)) - - def set_post_connection_check_callback(self, postConnectionCheck): # noqa - # type: (Callable) -> None - self.postConnectionCheck = postConnectionCheck - - def set_tlsext_host_name(self, name): - # type: (bytes) -> None - """Set the requested hostname for the SNI (Server Name Indication) - extension. - """ - m2.ssl_set_tlsext_host_name(self.ssl, name) - - def set1_host(self, name): - # type: (bytes) -> None - """Set the requested hostname to check in the server certificate.""" - self.host = name diff --git a/M2Crypto/SSL/Context.py b/M2Crypto/SSL/Context.py deleted file mode 100644 index d7cb7bc..0000000 --- a/M2Crypto/SSL/Context.py +++ /dev/null @@ -1,445 +0,0 @@ -from __future__ import absolute_import - -"""SSL Context - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" - -from M2Crypto import BIO, Err, RSA, X509, m2, util # noqa -from M2Crypto.SSL import cb # noqa -from M2Crypto.SSL.Session import Session # noqa -from weakref import WeakValueDictionary -from typing import Any, AnyStr, Callable, Optional, Union # noqa - -__all__ = ['ctxmap', 'Context', 'map'] - - -class _ctxmap(object): - singleton = None # type: Optional[_ctxmap] - - def __init__(self): - # type: () -> None - """Simple WeakReffed list. - """ - self._ctxmap = WeakValueDictionary() - - def __getitem__(self, key): - # type: (int) -> Any - return self._ctxmap[key] - - def __setitem__(self, key, value): - # type: (int, Any) -> None - self._ctxmap[key] = value - - def __delitem__(self, key): - # type: (int) -> None - del self._ctxmap[key] - - -def ctxmap(): - # type: () -> _ctxmap - if _ctxmap.singleton is None: - _ctxmap.singleton = _ctxmap() - return _ctxmap.singleton -# deprecated!!! -map = ctxmap - - -class Context(object): - - """'Context' for SSL connections.""" - - m2_ssl_ctx_free = m2.ssl_ctx_free - - def __init__(self, protocol='tls', weak_crypto=None, - post_connection_check=None): - # type: (str, Optional[int], Optional[Callable]) -> None - proto = getattr(m2, protocol + '_method', None) - if proto is None: - # default is 'sslv23' for older versions of OpenSSL - if protocol == 'tls': - proto = getattr(m2, 'sslv23_method') - else: - raise ValueError("no such protocol '%s'" % protocol) - self.ctx = m2.ssl_ctx_new(proto()) - self.allow_unknown_ca = 0 # type: Union[int, bool] - self.post_connection_check = post_connection_check - ctxmap()[int(self.ctx)] = self - m2.ssl_ctx_set_cache_size(self.ctx, 128) - if weak_crypto is None and protocol in ('sslv23', 'tls'): - self.set_options(m2.SSL_OP_ALL | m2.SSL_OP_NO_SSLv2 | - m2.SSL_OP_NO_SSLv3) - - def __del__(self): - # type: () -> None - if getattr(self, 'ctx', None): - self.m2_ssl_ctx_free(self.ctx) - - def close(self): - # type: () -> None - del ctxmap()[int(self.ctx)] - - def load_cert(self, certfile, keyfile=None, - callback=util.passphrase_callback): - # type: (AnyStr, Optional[AnyStr], Callable) -> None - """Load certificate and private key into the context. - - :param certfile: File that contains the PEM-encoded certificate. - :param keyfile: File that contains the PEM-encoded private key. - Default value of None indicates that the private key - is to be found in 'certfile'. - :param callback: Callable object to be invoked if the private key is - passphrase-protected. Default callback provides a - simple terminal-style input for the passphrase. - """ - m2.ssl_ctx_passphrase_callback(self.ctx, callback) - m2.ssl_ctx_use_cert(self.ctx, certfile) - if not keyfile: - keyfile = certfile - m2.ssl_ctx_use_privkey(self.ctx, keyfile) - if not m2.ssl_ctx_check_privkey(self.ctx): - raise ValueError('public/private key mismatch') - - def load_cert_chain(self, certchainfile, keyfile=None, - callback=util.passphrase_callback): - # type: (AnyStr, Optional[AnyStr], Callable) -> None - """Load certificate chain and private key into the context. - - :param certchainfile: File object containing the PEM-encoded - certificate chain. - :param keyfile: File object containing the PEM-encoded private - key. Default value of None indicates that the - private key is to be found in 'certchainfile'. - :param callback: Callable object to be invoked if the private key - is passphrase-protected. Default callback - provides a simple terminal-style input for the - passphrase. - """ - m2.ssl_ctx_passphrase_callback(self.ctx, callback) - m2.ssl_ctx_use_cert_chain(self.ctx, certchainfile) - if not keyfile: - keyfile = certchainfile - m2.ssl_ctx_use_privkey(self.ctx, keyfile) - if not m2.ssl_ctx_check_privkey(self.ctx): - raise ValueError('public/private key mismatch') - - def set_client_CA_list_from_file(self, cafile): - # type: (AnyStr) -> None - """Load CA certs into the context. These CA certs are sent to the - peer during *SSLv3 certificate request*. - - :param cafile: File object containing one or more PEM-encoded CA - certificates concatenated together. - """ - m2.ssl_ctx_set_client_CA_list_from_file(self.ctx, cafile) - - # Deprecated. - load_client_CA = load_client_ca = set_client_CA_list_from_file - - def load_verify_locations(self, cafile=None, capath=None): - # type: (Optional[AnyStr], Optional[AnyStr]) -> int - """Load CA certs into the context. - - These CA certs are used during verification of the peer's - certificate. - - :param cafile: File containing one or more PEM-encoded CA - certificates concatenated together. - - :param capath: Directory containing PEM-encoded CA certificates - (one certificate per file). - - :return: 0 if the operation failed because CAfile and CApath are NULL - or the processing at one of the locations specified failed. - Check the error stack to find out the reason. - - 1 The operation succeeded. - """ - if cafile is None and capath is None: - raise ValueError("cafile and capath can not both be None.") - return m2.ssl_ctx_load_verify_locations(self.ctx, cafile, capath) - - # Deprecated. - load_verify_info = load_verify_locations - - def set_session_id_ctx(self, id): - # type: (bytes) -> None - """Sets the session id for the SSL.Context w/in a session can be reused. - - :param id: Sessions are generated within a certain context. When - exporting/importing sessions with - i2d_SSL_SESSION/d2i_SSL_SESSION it would be possible, - to re-import a session generated from another context - (e.g. another application), which might lead to - malfunctions. Therefore each application must set its - own session id context sid_ctx which is used to - distinguish the contexts and is stored in exported - sessions. The sid_ctx can be any kind of binary data - with a given length, it is therefore possible to use - e.g. the name of the application and/or the hostname - and/or service name. - """ - ret = m2.ssl_ctx_set_session_id_context(self.ctx, id) - if not ret: - raise Err.SSLError(Err.get_error_code(), '') - - def set_default_verify_paths(self): - # type: () -> int - """ - Specifies that the default locations from which CA certs are - loaded should be used. - - There is one default directory and one default file. The default - CA certificates directory is called "certs" in the default - OpenSSL directory. Alternatively the SSL_CERT_DIR environment - variable can be defined to override this location. The default - CA certificates file is called "cert.pem" in the default OpenSSL - directory. Alternatively the SSL_CERT_FILE environment variable - can be defined to override this location. - - @return 0 if the operation failed. A missing default location is - still treated as a success. No error code is set. - - 1 The operation succeeded. - """ - ret = m2.ssl_ctx_set_default_verify_paths(self.ctx) - if not ret: - raise ValueError('Cannot use default SSL certificate store!') - - def set_allow_unknown_ca(self, ok): - # type: (Union[int, bool]) -> None - """Set the context to accept/reject a peer certificate if the - certificate's CA is unknown. - - :param ok: True to accept, False to reject. - """ - self.allow_unknown_ca = ok - - def get_allow_unknown_ca(self): - # type: () -> Union[int, bool] - """Get the context's setting that accepts/rejects a peer - certificate if the certificate's CA is unknown. - - FIXME 2Bconverted to bool - """ - return self.allow_unknown_ca - - def set_verify(self, mode, depth, callback=None): - # type: (int, int, Optional[Callable]) -> None - """ - Set verify options. Most applications will need to call this - method with the right options to make a secure SSL connection. - - :param mode: The verification mode to use. Typically at least - SSL.verify_peer is used. Clients would also typically - add SSL.verify_fail_if_no_peer_cert. - :param depth: The maximum allowed depth of the certificate chain - returned by the peer. - :param callback: Callable that can be used to specify custom - verification checks. - """ - if callback is None: - m2.ssl_ctx_set_verify_default(self.ctx, mode) - else: - m2.ssl_ctx_set_verify(self.ctx, mode, callback) - m2.ssl_ctx_set_verify_depth(self.ctx, depth) - - def get_verify_mode(self): - # type: () -> int - return m2.ssl_ctx_get_verify_mode(self.ctx) - - def get_verify_depth(self): - # type: () -> int - """Returns the verification mode currently set in the SSL Context.""" - return m2.ssl_ctx_get_verify_depth(self.ctx) - - def set_tmp_dh(self, dhpfile): - # type: (AnyStr) -> int - """Load ephemeral DH parameters into the context. - - :param dhpfile: Filename of the file containing the PEM-encoded - DH parameters. - """ - f = BIO.openfile(dhpfile) - dhp = m2.dh_read_parameters(f.bio_ptr()) - return m2.ssl_ctx_set_tmp_dh(self.ctx, dhp) - - def set_tmp_dh_callback(self, callback=None): - # type: (Optional[Callable]) -> None - """Sets the callback function for SSL.Context. - - :param callback: Callable to be used when a DH parameters are required. - """ - if callback is not None: - m2.ssl_ctx_set_tmp_dh_callback(self.ctx, callback) - - def set_tmp_rsa(self, rsa): - # type: (RSA.RSA) -> int - """Load ephemeral RSA key into the context. - - :param rsa: RSA.RSA instance. - """ - if isinstance(rsa, RSA.RSA): - return m2.ssl_ctx_set_tmp_rsa(self.ctx, rsa.rsa) - else: - raise TypeError("Expected an instance of RSA.RSA, got %s." % rsa) - - def set_tmp_rsa_callback(self, callback=None): - # type: (Optional[Callable]) -> None - """Sets the callback function to be used when - a temporary/ephemeral RSA key is required. - """ - if callback is not None: - m2.ssl_ctx_set_tmp_rsa_callback(self.ctx, callback) - - def set_info_callback(self, callback=cb.ssl_info_callback): - # type: (Callable) -> None - """Set a callback function to get state information. - - It can be used to get state information about the SSL - connections that are created from this context. - - :param callback: Callback function. The default prints - information to stderr. - """ - m2.ssl_ctx_set_info_callback(self.ctx, callback) - - def set_cipher_list(self, cipher_list): - # type: (str) -> int - """Sets the list of available ciphers. - - :param cipher_list: The format of the string is described in - ciphers(1). - :return: 1 if any cipher could be selected and 0 on complete - failure. - """ - return m2.ssl_ctx_set_cipher_list(self.ctx, cipher_list) - - def add_session(self, session): - # type: (Session) -> int - """Add the session to the context. - - :param session: the session to be added. - - :return: 0 The operation failed. It was tried to add the same - (identical) session twice. - - 1 The operation succeeded. - """ - return m2.ssl_ctx_add_session(self.ctx, session._ptr()) - - def remove_session(self, session): - # type: (Session) -> int - """Remove the session from the context. - - :param session: the session to be removed. - - :return: 0 The operation failed. The session was not found in - the cache. - - 1 The operation succeeded. - """ - return m2.ssl_ctx_remove_session(self.ctx, session._ptr()) - - def get_session_timeout(self): - # type: () -> int - """Get current session timeout. - - Whenever a new session is created, it is assigned a maximum - lifetime. This lifetime is specified by storing the creation - time of the session and the timeout value valid at this time. If - the actual time is later than creation time plus timeout, the - session is not reused. - - Due to this realization, all sessions behave according to the - timeout value valid at the time of the session negotiation. - Changes of the timeout value do not affect already established - sessions. - - Expired sessions are removed from the internal session cache, - whenever SSL_CTX_flush_sessions(3) is called, either directly by - the application or automatically (see - SSL_CTX_set_session_cache_mode(3)) - - The default value for session timeout is decided on a per - protocol basis, see SSL_get_default_timeout(3). All currently - supported protocols have the same default timeout value of 300 - seconds. - - SSL_CTX_set_timeout() returns the previously set timeout value. - - :return: the currently set timeout value. - """ - return m2.ssl_ctx_get_session_timeout(self.ctx) - - def set_session_timeout(self, timeout): - # type: (int) -> int - """Set new session timeout. - - See self.get_session_timeout() for explanation of the session - timeouts. - - :param timeout: new timeout value. - - :return: the previously set timeout value. - """ - return m2.ssl_ctx_set_session_timeout(self.ctx, timeout) - - def set_session_cache_mode(self, mode): - # type: (int) -> int - """Enables/disables session caching. - - The mode is set by using m2.SSL_SESS_CACHE_* constants. - - :param mode: new mode value. - - :return: the previously set cache mode value. - """ - return m2.ssl_ctx_set_session_cache_mode(self.ctx, mode) - - def get_session_cache_mode(self): - # type: () -> int - """Gets the current session caching. - - The mode is set to m2.SSL_SESS_CACHE_* constants. - - :return: the previously set cache mode value. - """ - return m2.ssl_ctx_get_session_cache_mode(self.ctx) - - def set_options(self, op): - # type: (int) -> int - """Adds the options set via bitmask in options to the Context. - - !!! Options already set before are not cleared! - - The behaviour of the SSL library can be changed by setting - several options. The options are coded as bitmasks and can be - combined by a logical or operation (|). - - SSL.Context.set_options() and SSL.set_options() affect the - (external) protocol behaviour of the SSL library. The (internal) - behaviour of the API can be changed by using the similar - SSL.Context.set_mode() and SSL.set_mode() functions. - - During a handshake, the option settings of the SSL object are - used. When a new SSL object is created from a context using - SSL(), the current option setting is copied. Changes to ctx - do not affect already created SSL objects. SSL.clear() does not - affect the settings. - - :param op: bitmask of additional options specified in - SSL_CTX_set_options(3) manpage. - - :return: the new options bitmask after adding options. - """ - return m2.ssl_ctx_set_options(self.ctx, op) - - def get_cert_store(self): - # type: () -> X509.X509 - """ - Get the certificate store associated with this context. - - :warning: The store is NOT refcounted, and as such can not be relied - to be valid once the context goes away or is changed. - """ - return X509.X509_Store(m2.ssl_ctx_get_cert_store(self.ctx)) diff --git a/M2Crypto/SSL/SSLServer.py b/M2Crypto/SSL/SSLServer.py deleted file mode 100644 index a44c9c7..0000000 --- a/M2Crypto/SSL/SSLServer.py +++ /dev/null @@ -1,65 +0,0 @@ -from __future__ import absolute_import, print_function - -"""SSLServer - -Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" - - -# M2Crypto -from M2Crypto.SSL import SSLError -from M2Crypto.SSL.Connection import Connection -from M2Crypto.SSL.Context import Context # noqa -# from M2Crypto import six # noqa -from M2Crypto import util # noqa -from M2Crypto.six.moves.socketserver import (BaseRequestHandler, BaseServer, - TCPServer, ThreadingMixIn) -import os -if os.name != 'nt': - from M2Crypto.six.moves.socketserver import ForkingMixIn -from socket import socket # noqa -from typing import Union # noqa - -__all__ = ['SSLServer', 'ForkingSSLServer', 'ThreadingSSLServer'] - - -class SSLServer(TCPServer): - def __init__(self, server_address, RequestHandlerClass, ssl_context, # noqa - bind_and_activate=True): - # type: (util.AddrType, BaseRequestHandler, Context, bool) -> None - """ - Superclass says: Constructor. May be extended, do not override. - This class says: Ho-hum. - """ - BaseServer.__init__(self, server_address, RequestHandlerClass) - self.ssl_ctx = ssl_context - self.socket = Connection(self.ssl_ctx) - if bind_and_activate: - self.server_bind() - self.server_activate() - - def handle_request(self): - # type: () -> None - request = None - client_address = None - try: - request, client_address = self.get_request() - if self.verify_request(request, client_address): - self.process_request(request, client_address) - except SSLError: - self.handle_error(request, client_address) - - def handle_error(self, request, client_address): - # type: (Union[socket, Connection], util.AddrType) -> None - print('-' * 40) - import traceback - traceback.print_exc() - print('-' * 40) - - -class ThreadingSSLServer(ThreadingMixIn, SSLServer): - pass - - -if os.name != 'nt': - class ForkingSSLServer(ForkingMixIn, SSLServer): - pass diff --git a/M2Crypto/SSL/Session.py b/M2Crypto/SSL/Session.py deleted file mode 100644 index c364d4e..0000000 --- a/M2Crypto/SSL/Session.py +++ /dev/null @@ -1,69 +0,0 @@ -"""SSL Session - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -__all__ = ['Session', 'load_session'] - -from M2Crypto import BIO, Err, m2 -from M2Crypto.SSL import SSLError -from typing import AnyStr # noqa - - -class Session(object): - - m2_ssl_session_free = m2.ssl_session_free - - def __init__(self, session, _pyfree=0): - # type: (bytes, int) -> None - assert session is not None - self.session = session - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_ssl_session_free(self.session) - - def _ptr(self): - # type: () -> bytes - return self.session - - def as_text(self): - # type: () -> bytes - buf = BIO.MemoryBuffer() - m2.ssl_session_print(buf.bio_ptr(), self.session) - return buf.read_all() - - def as_der(self): - # type: () -> bytes - buf = BIO.MemoryBuffer() - m2.i2d_ssl_session(buf.bio_ptr(), self.session) - return buf.read_all() - - def write_bio(self, bio): - # type: (BIO.BIO) -> int - return m2.ssl_session_write_bio(bio.bio_ptr(), self.session) - - def get_time(self): - # type: () -> int - return m2.ssl_session_get_time(self.session) - - def set_time(self, t): - # type: (int) -> int - return m2.ssl_session_set_time(self.session, t) - - def get_timeout(self): - # type: () -> int - return m2.ssl_session_get_timeout(self.session) - - def set_timeout(self, t): - # type: (int) -> int - return m2.ssl_session_set_timeout(self.session, t) - - -def load_session(pemfile): - # type: (AnyStr) -> Session - with BIO.openfile(pemfile) as f: - cptr = m2.ssl_session_read_pem(f.bio_ptr()) - - return Session(cptr, 1) diff --git a/M2Crypto/SSL/TwistedProtocolWrapper.py b/M2Crypto/SSL/TwistedProtocolWrapper.py deleted file mode 100644 index 5e94503..0000000 --- a/M2Crypto/SSL/TwistedProtocolWrapper.py +++ /dev/null @@ -1,490 +0,0 @@ -""" -Make Twisted use M2Crypto for SSL - -Copyright (c) 2004-2007 Open Source Applications Foundation. -All rights reserved. - -FIXME THIS HAS NOT BEEN FINISHED. NEITHER PEP484 NOR PORT PYTHON3 HAS -BEEN FINISHED. THE FURTHER WORK WILL BE DONE WHEN THE STATUS OF TWISTED -IN THE PYTHON 3 (AND ASYNCIO) WORLD WILL BE CLEAR. -""" - -__all__ = ['connectSSL', 'connectTCP', 'listenSSL', 'listenTCP', - 'TLSProtocolWrapper'] - -import logging - -from functools import partial - -import twisted.internet.reactor -import twisted.protocols.policies as policies - -from M2Crypto import BIO, X509, m2, util -from M2Crypto.SSL.Checker import Checker, SSLVerificationError - -from twisted.internet.interfaces import ITLSTransport -from twisted.protocols.policies import ProtocolWrapper -from typing import AnyStr, Callable, Iterable, Optional # noqa -from zope.interface import implementer - -log = logging.getLogger(__name__) - - -def _alwaysSucceedsPostConnectionCheck(peerX509, expectedHost): - return 1 - - -def connectSSL(host, port, factory, contextFactory, timeout=30, - bindAddress=None, - reactor=twisted.internet.reactor, - postConnectionCheck=Checker()): - # type: (str, int, object, object, int, Optional[str], twisted.internet.reactor, Checker) -> reactor.connectTCP - """ - A convenience function to start an SSL/TLS connection using Twisted. - - See IReactorSSL interface in Twisted. - """ - wrappingFactory = policies.WrappingFactory(factory) - wrappingFactory.protocol = lambda factory, wrappedProtocol: \ - TLSProtocolWrapper(factory, - wrappedProtocol, - startPassThrough=0, - client=1, - contextFactory=contextFactory, - postConnectionCheck=postConnectionCheck) - return reactor.connectTCP(host, port, wrappingFactory, timeout, bindAddress) - - -def connectTCP(host, port, factory, timeout=30, bindAddress=None, - reactor=twisted.internet.reactor, - postConnectionCheck=Checker()): - # type: (str, int, object, int, Optional[util.AddrType], object, Callable) -> object - """ - A convenience function to start a TCP connection using Twisted. - - NOTE: You must call startTLS(ctx) to go into SSL/TLS mode. - - See IReactorTCP interface in Twisted. - """ - wrappingFactory = policies.WrappingFactory(factory) - wrappingFactory.protocol = lambda factory, wrappedProtocol: \ - TLSProtocolWrapper(factory, - wrappedProtocol, - startPassThrough=1, - client=1, - contextFactory=None, - postConnectionCheck=postConnectionCheck) - return reactor.connectTCP(host, port, wrappingFactory, timeout, bindAddress) - - -def listenSSL(port, factory, contextFactory, backlog=5, interface='', - reactor=twisted.internet.reactor, - postConnectionCheck=_alwaysSucceedsPostConnectionCheck): - """ - A convenience function to listen for SSL/TLS connections using Twisted. - - See IReactorSSL interface in Twisted. - """ - wrappingFactory = policies.WrappingFactory(factory) - wrappingFactory.protocol = lambda factory, wrappedProtocol: \ - TLSProtocolWrapper(factory, - wrappedProtocol, - startPassThrough=0, - client=0, - contextFactory=contextFactory, - postConnectionCheck=postConnectionCheck) - return reactor.listenTCP(port, wrappingFactory, backlog, interface) - - -def listenTCP(port, factory, backlog=5, interface='', - reactor=twisted.internet.reactor, - postConnectionCheck=None): - """ - A convenience function to listen for TCP connections using Twisted. - - NOTE: You must call startTLS(ctx) to go into SSL/TLS mode. - - See IReactorTCP interface in Twisted. - """ - wrappingFactory = policies.WrappingFactory(factory) - wrappingFactory.protocol = lambda factory, wrappedProtocol: \ - TLSProtocolWrapper(factory, - wrappedProtocol, - startPassThrough=1, - client=0, - contextFactory=None, - postConnectionCheck=postConnectionCheck) - return reactor.listenTCP(port, wrappingFactory, backlog, interface) - - -class _BioProxy(object): - """ - The purpose of this class is to eliminate the __del__ method from - TLSProtocolWrapper, and thus letting it be garbage collected. - """ - - m2_bio_free_all = m2.bio_free_all - - def __init__(self, bio): - self.bio = bio - - def _ptr(self): - return self.bio - - def __del__(self): - if self.bio is not None: - self.m2_bio_free_all(self.bio) - - -class _SSLProxy(object): - """ - The purpose of this class is to eliminate the __del__ method from - TLSProtocolWrapper, and thus letting it be garbage collected. - """ - - m2_ssl_free = m2.ssl_free - - def __init__(self, ssl): - self.ssl = ssl - - def _ptr(self): - return self.ssl - - def __del__(self): - if self.ssl is not None: - self.m2_ssl_free(self.ssl) - - -@implementer(ITLSTransport) -class TLSProtocolWrapper(ProtocolWrapper): - """ - A SSL/TLS protocol wrapper to be used with Twisted. Typically - you would not use this class directly. Use connectTCP, - connectSSL, listenTCP, listenSSL functions defined above, - which will hook in this class. - """ - - def __init__(self, factory, wrappedProtocol, startPassThrough, client, - contextFactory, postConnectionCheck): - # type: (policies.WrappingFactory, object, int, int, object, Checker) -> None - """ - :param factory: - :param wrappedProtocol: - :param startPassThrough: If true we won't encrypt at all. Need to - call startTLS() later to switch to SSL/TLS. - :param client: True if this should be a client protocol. - :param contextFactory: Factory that creates SSL.Context objects. - The called function is getContext(). - :param postConnectionCheck: The post connection check callback that - will be called just after connection has - been established but before any real data - has been exchanged. The first argument to - this function is an X509 object, the second - is the expected host name string. - """ - # ProtocolWrapper.__init__(self, factory, wrappedProtocol) - # XXX: Twisted 2.0 has a new addition where the wrappingFactory is - # set as the factory of the wrappedProtocol. This is an issue - # as the wrap should be transparent. What we want is - # the factory of the wrappedProtocol to be the wrappedFactory and - # not the outer wrappingFactory. This is how it was implemented in - # Twisted 1.3 - self.factory = factory - self.wrappedProtocol = wrappedProtocol - - # wrappedProtocol == client/server instance - # factory.wrappedFactory == client/server factory - - self.data = b'' # Clear text to encrypt and send - self.encrypted = b'' # Encrypted data we need to decrypt and pass on - self.tlsStarted = 0 # SSL/TLS mode or pass through - self.checked = 0 # Post connection check done or not - self.isClient = client - self.helloDone = 0 # True when hello has been sent - if postConnectionCheck is None: - self.postConnectionCheck = _alwaysSucceedsPostConnectionCheck - else: - self.postConnectionCheck = postConnectionCheck - - if not startPassThrough: - self.startTLS(contextFactory.getContext()) - - def clear(self): - """ - Clear this instance, after which it is ready for reuse. - """ - if getattr(self, 'tlsStarted', 0): - self.sslBio = None - self.ssl = None - self.internalBio = None - self.networkBio = None - self.data = b'' - self.encrypted = b'' - self.tlsStarted = 0 - self.checked = 0 - self.isClient = 1 - self.helloDone = 0 - # We can reuse self.ctx and it will be deleted automatically - # when this instance dies - - def startTLS(self, ctx): - """ - Start SSL/TLS. If this is not called, this instance just passes data - through untouched. - """ - # NOTE: This method signature must match the startTLS() method Twisted - # expects transports to have. This will be called automatically - # by Twisted in STARTTLS situations, for example with SMTP. - if self.tlsStarted: - raise Exception('TLS already started') - - self.ctx = ctx - - self.internalBio = m2.bio_new(m2.bio_s_bio()) - m2.bio_set_write_buf_size(self.internalBio, 0) - self.networkBio = _BioProxy(m2.bio_new(m2.bio_s_bio())) - m2.bio_set_write_buf_size(self.networkBio._ptr(), 0) - m2.bio_make_bio_pair(self.internalBio, self.networkBio._ptr()) - - self.sslBio = _BioProxy(m2.bio_new(m2.bio_f_ssl())) - - self.ssl = _SSLProxy(m2.ssl_new(self.ctx.ctx)) - - if self.isClient: - m2.ssl_set_connect_state(self.ssl._ptr()) - else: - m2.ssl_set_accept_state(self.ssl._ptr()) - - m2.ssl_set_bio(self.ssl._ptr(), self.internalBio, self.internalBio) - m2.bio_set_ssl(self.sslBio._ptr(), self.ssl._ptr(), m2.bio_noclose) - - # Need this for writes that are larger than BIO pair buffers - mode = m2.ssl_get_mode(self.ssl._ptr()) - m2.ssl_set_mode(self.ssl._ptr(), - mode | - m2.SSL_MODE_ENABLE_PARTIAL_WRITE | - m2.SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER) - - self.tlsStarted = 1 - - def write(self, data): - # type: (bytes) -> None - if not self.tlsStarted: - ProtocolWrapper.write(self, data) - return - - try: - encryptedData = self._encrypt(data) - ProtocolWrapper.write(self, encryptedData) - self.helloDone = 1 - except BIO.BIOError as e: - # See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS - # for the error codes returned by SSL_get_verify_result. - e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0]) - raise e - - def writeSequence(self, data): - # type: (Iterable[bytes]) -> None - if not self.tlsStarted: - ProtocolWrapper.writeSequence(self, b''.join(data)) - return - - self.write(b''.join(data)) - - def loseConnection(self): - # XXX Do we need to do m2.ssl_shutdown(self.ssl._ptr())? - ProtocolWrapper.loseConnection(self) - - def connectionMade(self): - ProtocolWrapper.connectionMade(self) - if self.tlsStarted and self.isClient and not self.helloDone: - self._clientHello() - - def dataReceived(self, data): - # type: (bytes) -> None - if not self.tlsStarted: - ProtocolWrapper.dataReceived(self, data) - return - - self.encrypted += data - - try: - while 1: - decryptedData = self._decrypt() - - self._check() - - encryptedData = self._encrypt() - ProtocolWrapper.write(self, encryptedData) - - ProtocolWrapper.dataReceived(self, decryptedData) - - if decryptedData == b'' and encryptedData == b'': - break - except BIO.BIOError as e: - # See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS - # for the error codes returned by SSL_get_verify_result. - e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0]) - raise e - - def connectionLost(self, reason): - # type: (AnyStr) -> None - self.clear() - ProtocolWrapper.connectionLost(self, reason) - - def _check(self): - if not self.checked and m2.ssl_is_init_finished(self.ssl._ptr()): - x509 = m2.ssl_get_peer_cert(self.ssl._ptr()) - if x509 is not None: - x509 = X509.X509(x509, 1) - if self.isClient: - host = self.transport.addr[0] - else: - host = self.transport.getPeer().host - if not self.postConnectionCheck(x509, host): - raise SSLVerificationError('post connection check') - self.checked = 1 - - def _clientHello(self): - try: - # We rely on OpenSSL implicitly starting with client hello - # when we haven't yet established an SSL connection - encryptedData = self._encrypt(clientHello=1) - ProtocolWrapper.write(self, encryptedData) - self.helloDone = 1 - except BIO.BIOError as e: - # See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS - # for the error codes returned by SSL_get_verify_result. - e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0]) - raise e - - # Optimizations to reduce attribute accesses - - @property - def _get_wr_guar_ssl(self): - # type: () -> Callable[[], int] - """Return max. length of data can be written to the BIO. - - Writes larger than this value will return a value from - BIO_write() less than the amount requested or if the buffer is - full request a retry. - """ - return partial(m2.bio_ctrl_get_write_guarantee, - self.sslBio._ptr()) - - @property - def _get_wr_guar_net(self): - # type: () -> Callable[[], int] - return partial(m2.bio_ctrl_get_write_guarantee, - self.networkBio._ptr()) - - @property - def _shoud_retry_ssl(self): - # type: () -> Callable[[], int] - # BIO_should_retry() is true if the call that produced this - # condition should then be retried at a later time. - return partial(m2.bio_should_retry, self.sslBio._ptr()) - - @property - def _shoud_retry_net(self): - # type: () -> Callable[[], int] - return partial(m2.bio_should_retry, self.networkBio._ptr()) - - @property - def _ctrl_pend_ssl(self): - # type: () -> Callable[[], int] - # size_t BIO_ctrl_pending(BIO *b); - # BIO_ctrl_pending() return the number of pending characters in - # the BIOs read and write buffers. - return partial(m2.bio_ctrl_pending, self.sslBio._ptr()) - - @property - def _ctrl_pend_net(self): - # type: () -> Callable[[], int] - return partial(m2.bio_ctrl_pending, self.networkBio._ptr()) - - @property - def _write_ssl(self): - # type: () -> Callable[[bytes], int] - # All these functions return either the amount of data - # successfully read or written (if the return value is - # positive) or that no data was successfully read or written - # if the result is 0 or -1. If the return value is -2 then - # the operation is not implemented in the specific BIO type. - return partial(m2.bio_write, self.sslBio._ptr()) - - @property - def _write_net(self): - # type: () -> Callable[[bytes], int] - return partial(m2.bio_write, self.networkBio._ptr()) - - @property - def _read_ssl(self): - # type: () -> Callable[[int], Optional[bytes]] - return partial(m2.bio_read, self.sslBio._ptr()) - - @property - def _read_net(self): - # type: () -> Callable[[int], Optional[bytes]] - return partial(m2.bio_read, self.networkBio._ptr()) - - def _encrypt(self, data=b'', clientHello=0): - # type: (bytes, int) -> bytes - """ - :param data: - :param clientHello: - :return: - """ - encryptedData = b'' - self.data += data - - while 1: - if (self._get_wr_guar_ssl() > 0 and self.data != b'') or clientHello: - r = self._write_ssl(self.data) - if r <= 0: - if not self._shoud_retry_ssl(): - raise IOError( - ('Data left to be written to {}, ' + - 'but cannot retry SSL connection!').format(self.sslBio)) - else: - assert self.checked - self.data = self.data[r:] - - pending = self._ctrl_pend_net() - if pending: - d = self._read_net(pending) - if d is not None: # This is strange, but d can be None - encryptedData += d - else: - assert(self._shoud_retry_net()) - else: - break - return encryptedData - - def _decrypt(self, data=b''): - # type: (bytes) -> bytes - self.encrypted += data - decryptedData = b'' - - while 1: - if self._get_wr_guar_ssl() > 0 and self.encrypted != b'': - r = self._write_net(self.encrypted) - if r <= 0: - if not self._shoud_retry_net(): - raise IOError( - ('Data left to be written to {}, ' + - 'but cannot retry SSL connection!').format(self.networkBio)) - else: - self.encrypted = self.encrypted[r:] - - pending = self._ctrl_pend_ssl() - if pending: - d = self._read_ssl(pending) - if d is not None: # This is strange, but d can be None - decryptedData += d - else: - assert(self._shoud_retry_ssl()) - else: - break - - return decryptedData diff --git a/M2Crypto/SSL/__init__.py b/M2Crypto/SSL/__init__.py deleted file mode 100644 index 33bf1b9..0000000 --- a/M2Crypto/SSL/__init__.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto SSL services. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" - -import socket, os - -# M2Crypto -from M2Crypto import _m2crypto as m2 - - -class SSLError(Exception): - pass - - -class SSLTimeoutError(SSLError, socket.timeout): - pass - -m2.ssl_init(SSLError, SSLTimeoutError) - -# M2Crypto.SSL -from M2Crypto.SSL.Cipher import Cipher, Cipher_Stack -from M2Crypto.SSL.Connection import Connection -from M2Crypto.SSL.Context import Context -from M2Crypto.SSL.SSLServer import SSLServer, ThreadingSSLServer -if os.name != 'nt': - from M2Crypto.SSL.SSLServer import ForkingSSLServer -from M2Crypto.SSL.ssl_dispatcher import ssl_dispatcher -from M2Crypto.SSL.timeout import timeout, struct_to_timeout, struct_size - -verify_none = m2.SSL_VERIFY_NONE # type: int -verify_peer = m2.SSL_VERIFY_PEER # type: int -verify_fail_if_no_peer_cert = m2.SSL_VERIFY_FAIL_IF_NO_PEER_CERT # type: int -verify_client_once = m2.SSL_VERIFY_CLIENT_ONCE # type: int -verify_crl_check_chain = m2.VERIFY_CRL_CHECK_CHAIN # type: int -verify_crl_check_leaf = m2.VERIFY_CRL_CHECK_LEAF # type: int - -SSL_SENT_SHUTDOWN = m2.SSL_SENT_SHUTDOWN # type: int -SSL_RECEIVED_SHUTDOWN = m2.SSL_RECEIVED_SHUTDOWN # type: int - -op_all = m2.SSL_OP_ALL # type: int -op_no_sslv2 = m2.SSL_OP_NO_SSLv2 # type: int - diff --git a/M2Crypto/SSL/cb.py b/M2Crypto/SSL/cb.py deleted file mode 100644 index 47f102e..0000000 --- a/M2Crypto/SSL/cb.py +++ /dev/null @@ -1,96 +0,0 @@ -from __future__ import absolute_import - -"""SSL callbacks - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -import sys - -from M2Crypto import m2 -from typing import Any # noqa - -__all__ = ['unknown_issuer', 'ssl_verify_callback_stub', 'ssl_verify_callback', - 'ssl_verify_callback_allow_unknown_ca', 'ssl_info_callback'] - - -def ssl_verify_callback_stub(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok): - # Deprecated - return ok - - -unknown_issuer = [ - m2.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, - m2.X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, - m2.X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE, - m2.X509_V_ERR_CERT_UNTRUSTED, -] - - -def ssl_verify_callback(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok): - # type: (bytes, bytes, int, int, int) -> int - # Deprecated - - from M2Crypto.SSL.Context import Context - ssl_ctx = Context.ctxmap()[int(ssl_ctx_ptr)] - if errnum in unknown_issuer: - if ssl_ctx.get_allow_unknown_ca(): - sys.stderr.write("policy: %s: permitted...\n" % - (m2.x509_get_verify_error(errnum))) - sys.stderr.flush() - ok = 1 - # CRL checking goes here... - if ok: - if ssl_ctx.get_verify_depth() >= errdepth: - ok = 1 - else: - ok = 0 - return ok - - -def ssl_verify_callback_allow_unknown_ca(ok, store): - # type: (int, Any) -> int - errnum = store.get_error() - if errnum in unknown_issuer: - ok = 1 - return ok - - -# Cribbed from OpenSSL's apps/s_cb.c. -def ssl_info_callback(where, ret, ssl_ptr): - # type: (int, int, bytes) -> None - - w = where & ~m2.SSL_ST_MASK - if w & m2.SSL_ST_CONNECT: - state = "SSL connect" - elif w & m2.SSL_ST_ACCEPT: - state = "SSL accept" - else: - state = "SSL state unknown" - - if where & m2.SSL_CB_LOOP: - sys.stderr.write("LOOP: %s: %s\n" % - (state, m2.ssl_get_state_v(ssl_ptr))) - sys.stderr.flush() - return - - if where & m2.SSL_CB_EXIT: - if not ret: - sys.stderr.write("FAILED: %s: %s\n" % - (state, m2.ssl_get_state_v(ssl_ptr))) - sys.stderr.flush() - else: - sys.stderr.write("INFO: %s: %s\n" % - (state, m2.ssl_get_state_v(ssl_ptr))) - sys.stderr.flush() - return - - if where & m2.SSL_CB_ALERT: - if where & m2.SSL_CB_READ: - w = 'read' - else: - w = 'write' - sys.stderr.write("ALERT: %s: %s: %s\n" % - (w, m2.ssl_get_alert_type_v(ret), - m2.ssl_get_alert_desc_v(ret))) - sys.stderr.flush() - return diff --git a/M2Crypto/SSL/ssl_dispatcher.py b/M2Crypto/SSL/ssl_dispatcher.py deleted file mode 100644 index 73a4b82..0000000 --- a/M2Crypto/SSL/ssl_dispatcher.py +++ /dev/null @@ -1,43 +0,0 @@ -from __future__ import absolute_import - -"""SSL dispatcher - -Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" - -# Python -import asyncore -import socket - -# M2Crypto -from M2Crypto import util # noqa -from M2Crypto.SSL.Connection import Connection -from M2Crypto.SSL.Context import Context # noqa - -__all__ = ['ssl_dispatcher'] - - -class ssl_dispatcher(asyncore.dispatcher): - - def create_socket(self, ssl_context): - # type: (Context) -> None - self.family_and_type = socket.AF_INET, socket.SOCK_STREAM - self.ssl_ctx = ssl_context - self.socket = Connection(self.ssl_ctx) - # self.socket.setblocking(0) - self.add_channel() - - def connect(self, addr): - # type: (util.AddrType) -> None - self.socket.setblocking(1) - self.socket.connect(addr) - self.socket.setblocking(0) - - def recv(self, buffer_size=4096): - # type: (int) -> bytes - """Receive data over SSL.""" - return self.socket.recv(buffer_size) - - def send(self, buffer): - # type: (bytes) -> int - """Send data over SSL.""" - return self.socket.send(buffer) diff --git a/M2Crypto/SSL/timeout.py b/M2Crypto/SSL/timeout.py deleted file mode 100644 index 42b0291..0000000 --- a/M2Crypto/SSL/timeout.py +++ /dev/null @@ -1,50 +0,0 @@ -"""Support for SSL socket timeouts. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. - -Copyright 2008 Heikki Toivonen. All rights reserved. -""" - -__all__ = ['DEFAULT_TIMEOUT', 'timeout', 'struct_to_timeout', 'struct_size'] - -import sys -import struct - -DEFAULT_TIMEOUT = 600 # type: int - - -class timeout(object): - - def __init__(self, sec=DEFAULT_TIMEOUT, microsec=0): - # type: (int, int) -> None - self.sec = sec - self.microsec = microsec - - def pack(self): - if sys.platform == 'win32': - millisec = int(self.sec * 1000 + round(float(self.microsec) / 1000)) - binstr = struct.pack('l', millisec) - else: - binstr = struct.pack('ll', self.sec, self.microsec) - return binstr - - -def struct_to_timeout(binstr): - # type: (bytes) -> timeout - if sys.platform == 'win32': - millisec = struct.unpack('l', binstr)[0] - # On py3, int/int performs exact division and returns float. We want - # the whole number portion of the exact division result: - sec = int(millisec / 1000) - microsec = (millisec % 1000) * 1000 - else: - (sec, microsec) = struct.unpack('ll', binstr) - return timeout(sec, microsec) - - -def struct_size(): - # type: () -> int - if sys.platform == 'win32': - return struct.calcsize('l') - else: - return struct.calcsize('ll') diff --git a/M2Crypto/X509.py b/M2Crypto/X509.py deleted file mode 100644 index b27af13..0000000 --- a/M2Crypto/X509.py +++ /dev/null @@ -1,1443 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto wrapper for OpenSSL X509 API. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - -Portions created by Open Source Applications Foundation (OSAF) are -Copyright (C) 2004-2007 OSAF. All Rights Reserved. -Author: Heikki Toivonen -""" - -import binascii -import logging - -from M2Crypto import ASN1, BIO, EVP, m2, six # noqa -from typing import AnyStr, List, Optional # noqa - -FORMAT_DER = 0 -FORMAT_PEM = 1 - -if hasattr(m2, "VERIFY_ALLOW_PROXY_CERTS"): - verify_allow_proxy_certs = m2.VERIFY_ALLOW_PROXY_CERTS -if hasattr(m2, "VERIFY_CB_ISSUER_CHECK"): - verify_cb_issuer_check = m2.VERIFY_CB_ISSUER_CHECK -if hasattr(m2, "VERIFY_CHECK_SS_SIGNATURE"): - verify_check_ss_signature = m2.VERIFY_CHECK_SS_SIGNATURE -if hasattr(m2, "VERIFY_CRL_CHECK"): - verify_crl_check = m2.VERIFY_CRL_CHECK -if hasattr(m2, "VERIFY_CRL_CHECK_ALL"): - verify_crl_check_all = m2.VERIFY_CRL_CHECK_ALL -if hasattr(m2, "VERIFY_EXPLICIT_POLICY"): - verify_explicit_policy = m2.VERIFY_EXPLICIT_POLICY -if hasattr(m2, "VERIFY_EXTENDED_CRL_SUPPORT"): - verify_extended_crl_support = m2.VERIFY_EXTENDED_CRL_SUPPORT -if hasattr(m2, "VERIFY_IGNORE_CRITICAL"): - verify_ignore_critical = m2.VERIFY_IGNORE_CRITICAL -if hasattr(m2, "VERIFY_INHIBIT_ANY"): - verify_inhibit_any = m2.VERIFY_INHIBIT_ANY -if hasattr(m2, "VERIFY_INHIBIT_MAP"): - verify_inhibit_map = m2.VERIFY_INHIBIT_MAP -if hasattr(m2, "VERIFY_NO_ALT_CHAINS"): - verify_no_alt_chains = m2.VERIFY_NO_ALT_CHAINS -if hasattr(m2, "VERIFY_NO_CHECK_TIME"): - verify_no_check_time = m2.VERIFY_NO_CHECK_TIME -if hasattr(m2, "VERIFY_NOTIFY_POLICY"): - verify_notify_policy = m2.VERIFY_NOTIFY_POLICY -if hasattr(m2, "VERIFY_PARTIAL_CHAIN"): - verify_partial_chain = m2.VERIFY_PARTIAL_CHAIN -if hasattr(m2, "VERIFY_POLICY_CHECK"): - verify_policy_check = m2.VERIFY_POLICY_CHECK -if hasattr(m2, "VERIFY_TRUSTED_FIRST"): - verify_trusted_first = m2.VERIFY_TRUSTED_FIRST -if hasattr(m2, "VERIFY_USE_DELTAS"): - verify_use_deltas = m2.VERIFY_USE_DELTAS -if hasattr(m2, "VERIFY_X509_STRICT"): - verify_x509_strict = m2.VERIFY_X509_STRICT - -log = logging.getLogger(__name__) - - -class X509Error(ValueError): - pass - - -m2.x509_init(X509Error) - -V_OK = m2.X509_V_OK # type: int - - -def x509_store_default_cb(ok, ctx): - # type: (int, X509_Store_Context) -> int - return ok - - -def new_extension(name, value, critical=0, _pyfree=1): - # type: (str, bytes, int, int) -> X509_Extension - """ - Create new X509_Extension instance. - """ - if name == 'subjectKeyIdentifier' and \ - value.strip('0123456789abcdefABCDEF:') != '': - raise ValueError('value must be precomputed hash') - ctx = m2.x509v3_set_nconf() - x509_ext_ptr = m2.x509v3_ext_conf(None, ctx, name, value) - if x509_ext_ptr is None: - raise X509Error( - "Cannot create X509_Extension with name '%s' and value '%s'" % - (name, value)) - x509_ext = X509_Extension(x509_ext_ptr, _pyfree) - x509_ext.set_critical(critical) - return x509_ext - - -class X509_Extension(object): - """ - X509 Extension - """ - - m2_x509_extension_free = m2.x509_extension_free - - def __init__(self, x509_ext_ptr=None, _pyfree=1): - # type: (Optional[bytes], int) -> None - self.x509_ext = x509_ext_ptr - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0) and self.x509_ext: - self.m2_x509_extension_free(self.x509_ext) - - def _ptr(self): - # type: () -> bytes - return self.x509_ext - - def set_critical(self, critical=1): - # type: (int) -> int - """ - Mark this extension critical or noncritical. By default an - extension is not critical. - - :param critical: Nonzero sets this extension as critical. - Calling this method without arguments will - set this extension to critical. - :return: 1 for success, 0 for failure - """ - return m2.x509_extension_set_critical(self.x509_ext, critical) - - def get_critical(self): - # type: () -> int - """ - Return whether or not this is a critical extension. - - :return: Nonzero if this is a critical extension. - """ - return m2.x509_extension_get_critical(self.x509_ext) - - def get_name(self): - # type: () -> str - """ - Get the extension name, for example 'subjectAltName'. - """ - return six.ensure_text(m2.x509_extension_get_name(self.x509_ext)) - - def get_value(self, flag=0, indent=0): - # type: (int, int) -> str - """ - Get the extension value, for example 'DNS:www.example.com'. - - :param flag: Flag to control what and how to print. - :param indent: How many spaces to print before actual value. - """ - buf = BIO.MemoryBuffer() - m2.x509_ext_print(buf.bio_ptr(), self.x509_ext, flag, indent) - return six.ensure_text(buf.read_all()) - - -class X509_Extension_Stack(object): - """ - X509 Extension Stack - - :warning: Do not modify the underlying OpenSSL stack - except through this interface, or use any OpenSSL - functions that do so indirectly. Doing so will get the - OpenSSL stack and the internal pystack of this class out - of sync, leading to python memory leaks, exceptions or - even python crashes! - """ - - m2_sk_x509_extension_free = m2.sk_x509_extension_free - - def __init__(self, stack=None, _pyfree=0): - # type: (Optional[bytes], int) -> None - if stack is not None: - self.stack = stack - self._pyfree = _pyfree - num = m2.sk_x509_extension_num(self.stack) - for i in range(num): - self.pystack.append(X509_Extension( - m2.sk_x509_extension_value(self.stack, i), - _pyfree=_pyfree)) - else: - self.stack = m2.sk_x509_extension_new_null() - self._pyfree = 1 - self.pystack = [] # This must be kept in sync with self.stack - - def __del__(self): - # type: () -> None - # see BIO.py - unbalanced __init__ / __del__ - if getattr(self, '_pyfree', 0): - self.m2_sk_x509_extension_free(self.stack) - - def __len__(self): - # type: () -> int - assert m2.sk_x509_extension_num(self.stack) == len(self.pystack) - return len(self.pystack) - - def __getitem__(self, idx): - # type: (int) -> X509_Extension - return self.pystack[idx] - - def __iter__(self): - return iter(self.pystack) - - def _ptr(self): - # type: () -> bytes - return self.stack - - def push(self, x509_ext): - # type: (X509_Extension) -> int - """ - Push X509_Extension object onto the stack. - - :param x509_ext: X509_Extension object to be pushed onto the stack. - :return: The number of extensions on the stack. - """ - self.pystack.append(x509_ext) - ret = m2.sk_x509_extension_push(self.stack, x509_ext._ptr()) - assert ret == len(self.pystack) - return ret - - def pop(self): - # type: () -> X509_Extension - """ - Pop X509_Extension object from the stack. - - :return: X509_Extension popped - """ - x509_ext_ptr = m2.sk_x509_extension_pop(self.stack) - if x509_ext_ptr is None: - assert len(self.pystack) == 0 - return None - return self.pystack.pop() - - -class X509_Name_Entry(object): - """ - X509 Name Entry - """ - - m2_x509_name_entry_free = m2.x509_name_entry_free - - def __init__(self, x509_name_entry, _pyfree=0): - # type: (bytes, int) -> None - """ - :param x509_name_entry: this should be OpenSSL X509_NAME_ENTRY binary - :param _pyfree: - """ - self.x509_name_entry = x509_name_entry - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_x509_name_entry_free(self.x509_name_entry) - - def _ptr(self): - # type: () -> bytes - return self.x509_name_entry - - def set_object(self, asn1obj): - # type: (ASN1.ASN1_Object) -> int - """ - Sets the field name to asn1obj - - :param asn1obj: - :return: 0 on failure, 1 on success - """ - return m2.x509_name_entry_set_object(self.x509_name_entry, - asn1obj._ptr()) - - def set_data(self, data, type=ASN1.MBSTRING_ASC): - # type: (bytes, int) -> int - """ - Sets the field name to asn1obj - - :param data: data in a binary form to be set - :return: 0 on failure, 1 on success - """ - return m2.x509_name_entry_set_data(self.x509_name_entry, type, data) - - def get_object(self): - # type: () -> ASN1.ASN1_Object - return ASN1.ASN1_Object( - m2.x509_name_entry_get_object(self.x509_name_entry)) - - def get_data(self): - # type: () -> ASN1.ASN1_String - return ASN1.ASN1_String( - m2.x509_name_entry_get_data(self.x509_name_entry)) - - def create_by_txt(self, field, type, entry, len): - return m2.x509_name_entry_create_by_txt(self.x509_name_entry._ptr(), - field, type, entry, len) - - -class X509_Name(object): - """ - X509 Name - """ - - nid = {'C': m2.NID_countryName, - 'SP': m2.NID_stateOrProvinceName, - 'ST': m2.NID_stateOrProvinceName, - 'stateOrProvinceName': m2.NID_stateOrProvinceName, - 'L': m2.NID_localityName, - 'localityName': m2.NID_localityName, - 'O': m2.NID_organizationName, - 'organizationName': m2.NID_organizationName, - 'OU': m2.NID_organizationalUnitName, - 'organizationUnitName': m2.NID_organizationalUnitName, - 'CN': m2.NID_commonName, - 'commonName': m2.NID_commonName, - 'Email': m2.NID_pkcs9_emailAddress, - 'emailAddress': m2.NID_pkcs9_emailAddress, - 'serialNumber': m2.NID_serialNumber, - 'SN': m2.NID_surname, - 'surname': m2.NID_surname, - 'GN': m2.NID_givenName, - 'givenName': m2.NID_givenName - } - - m2_x509_name_free = m2.x509_name_free - - def __init__(self, x509_name=None, _pyfree=0): - # type: (bytes, int) -> None - """ - :param x509_name: this should be OpenSSL X509_NAME binary - :param _pyfree: - """ - if x509_name is not None: - assert m2.x509_name_type_check(x509_name), "'x509_name' type error" - self.x509_name = x509_name - self._pyfree = _pyfree - else: - self.x509_name = m2.x509_name_new() - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_x509_name_free(self.x509_name) - - def __str__(self): - # type: () -> bytes - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - return m2.x509_name_oneline(self.x509_name) - - def __getattr__(self, attr): - # type: (str) -> str - if attr in self.nid: - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - return six.ensure_text(m2.x509_name_by_nid(self.x509_name, self.nid[attr])) - - if attr in self.__dict__: - return self.__dict__[attr] - - raise AttributeError(self, attr) - - def __setattr__(self, attr, value): - # type: (str, AnyStr) -> int - """ - :return: 1 for success of 0 if an error occurred. - """ - if attr in self.nid: - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - return m2.x509_name_set_by_nid(self.x509_name, self.nid[attr], - six.ensure_binary(value)) - - self.__dict__[attr] = value - - def __len__(self): - # type: () -> int - return m2.x509_name_entry_count(self.x509_name) - - def __getitem__(self, idx): - # type: (int) -> X509_Name_Entry - if not 0 <= idx < self.entry_count(): - raise IndexError("index out of range") - return X509_Name_Entry(m2.x509_name_get_entry(self.x509_name, idx)) - - def __iter__(self): - for i in range(self.entry_count()): - yield self[i] - - def _ptr(self): - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - return self.x509_name - - def add_entry_by_txt(self, field, type, entry, len, loc, set): - # entry_type: (str, int, bytes, int, int, int) -> int - """ - Add X509_Name field whose name is identified by its name. - - :param field: name of the entry - :param type: use MBSTRING_ASC or MBSTRING_UTF8 - (or standard ASN1 type like V_ASN1_IA5STRING) - :param entry: value - :param len: buf_len of the entry - (-1 and the length is computed automagically) - - The ``loc`` and ``set`` parameters determine where a new entry - should be added. - For almost all applications loc can be set to -1 and set to 0. - This adds a new entry to the end of name as a single valued - RelativeDistinguishedName (RDN). - - :param loc: determines the index where the new entry is - inserted: if it is -1 it is appended. - :param set: determines how the new type is added. If it is zero - a new RDN is created. - If set is -1 or 1 it is added to the previous or next RDN - structure respectively. This will then be a multivalued - RDN: since multivalues RDNs are very seldom used set is - almost always set to zero. - - :return: 1 for success of 0 if an error occurred. - """ - return m2.x509_name_add_entry_by_txt(self.x509_name, - six.ensure_str(field), type, - six.ensure_str(entry), len, loc, set) - - def entry_count(self): - # type: () -> int - return m2.x509_name_entry_count(self.x509_name) - - def get_entries_by_nid(self, nid): - # type: (int) -> List[X509_Name_Entry] - """ - Retrieve the next index matching nid. - - :param nid: name of the entry (as m2.NID* constants) - - :return: list of X509_Name_Entry items - """ - ret = [] - lastpos = -1 - - while True: - lastpos = m2.x509_name_get_index_by_nid(self.x509_name, nid, - lastpos) - if lastpos == -1: - break - - ret.append(self[lastpos]) - - return ret - - def as_text(self, indent=0, flags=m2.XN_FLAG_COMPAT): - # type: (int, int) -> str - """ - as_text returns the name as a string. - - :param indent: Each line in multiline format is indented - by this many spaces. - :param flags: Flags that control how the output should be formatted. - """ - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - buf = BIO.MemoryBuffer() - m2.x509_name_print_ex(buf.bio_ptr(), self.x509_name, indent, flags) - return six.ensure_text(buf.read_all()) - - def as_der(self): - # type: () -> bytes - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - return m2.x509_name_get_der(self.x509_name) - - def as_hash(self): - # type: () -> int - assert m2.x509_name_type_check(self.x509_name), \ - "'x509_name' type error" - return m2.x509_name_hash(self.x509_name) - - -class X509(object): - """ - X.509 Certificate - """ - - m2_x509_free = m2.x509_free - - def __init__(self, x509=None, _pyfree=0): - # type: (Optional[bytes], int) -> None - """ - :param x509: binary representation of - the underlying OpenSSL X509 object. - :param _pyfree: - """ - if x509 is not None: - assert m2.x509_type_check(x509), "'x509' type error" - self.x509 = x509 - self._pyfree = _pyfree - else: - self.x509 = m2.x509_new() - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_x509_free(self.x509) - - def _ptr(self): - # type: () -> bytes - assert m2.x509_type_check(self.x509), "'x509' type error" - return self.x509 - - def as_text(self): - # type: () -> str - assert m2.x509_type_check(self.x509), "'x509' type error" - buf = BIO.MemoryBuffer() - m2.x509_print(buf.bio_ptr(), self.x509) - return six.ensure_text(buf.read_all()) - - def as_der(self): - # type: () -> bytes - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.i2d_x509(self.x509) - - def as_pem(self): - # type: () -> bytes - buf = BIO.MemoryBuffer() - m2.x509_write_pem(buf.bio_ptr(), self.x509) - return buf.read_all() - - def save_pem(self, filename): - # type: (AnyStr) -> int - """ - :param filename: name of the file to be loaded - :return: 1 for success or 0 for failure - """ - with BIO.openfile(filename, 'wb') as bio: - return m2.x509_write_pem(bio.bio_ptr(), self.x509) - - def save(self, filename, format=FORMAT_PEM): - # type: (AnyStr, int) -> int - """ - Saves X.509 certificate to a file. Default output - format is PEM. - - :param filename: Name of the file the cert will be saved to. - - :param format: Controls what output format is used to save the cert. - Either FORMAT_PEM or FORMAT_DER to save in PEM or - DER format. Raises a ValueError if an unknow - format is used. - - :return: 1 for success or 0 for failure - """ - with BIO.openfile(filename, 'wb') as bio: - if format == FORMAT_PEM: - return m2.x509_write_pem(bio.bio_ptr(), self.x509) - elif format == FORMAT_DER: - return m2.i2d_x509_bio(bio.bio_ptr(), self.x509) - else: - raise ValueError( - "Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER") - - def set_version(self, version): - # type: (int) -> int - """ - Set version of the certificate. - - :param version: Version number. - :return: Returns 0 on failure. - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_version(self.x509, version) - - def set_not_before(self, asn1_time): - # type: (ASN1.ASN1_TIME) -> int - """ - :return: 1 on success, 0 on failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_not_before(self.x509, asn1_time._ptr()) - - def set_not_after(self, asn1_time): - # type: (ASN1.ASN1_TIME) -> int - """ - :return: 1 on success, 0 on failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_not_after(self.x509, asn1_time._ptr()) - - def set_subject_name(self, name): - # type: (X509_Name) -> int - """ - :return: 1 on success, 0 on failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_subject_name(self.x509, name.x509_name) - - def set_issuer_name(self, name): - # type: (X509_Name) -> int - """ - :return: 1 on success, 0 on failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_issuer_name(self.x509, name.x509_name) - - def get_version(self): - # type: () -> int - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_get_version(self.x509) - - def get_serial_number(self): - # type: () -> ASN1.ASN1_Integer - assert m2.x509_type_check(self.x509), "'x509' type error" - asn1_integer = m2.x509_get_serial_number(self.x509) - return m2.asn1_integer_get(asn1_integer) - - def set_serial_number(self, serial): - # type: (ASN1.ASN1_Integer) -> int - """ - Set serial number. - - :param serial: Serial number. - - :return 1 for success and 0 for failure. - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - # This "magically" changes serial since asn1_integer - # is C pointer to x509's internal serial number. - asn1_integer = m2.x509_get_serial_number(self.x509) - return m2.asn1_integer_set(asn1_integer, serial) - # XXX Or should I do this? - # asn1_integer = m2.asn1_integer_new() - # m2.asn1_integer_set(asn1_integer, serial) - # return m2.x509_set_serial_number(self.x509, asn1_integer) - - def get_not_before(self): - # type: () -> ASN1.ASN1_TIME - assert m2.x509_type_check(self.x509), "'x509' type error" - return ASN1.ASN1_TIME(m2.x509_get_not_before(self.x509)) - - def get_not_after(self): - # type: () -> ASN1.ASN1_TIME - assert m2.x509_type_check(self.x509), "'x509' type error" - out = ASN1.ASN1_TIME(m2.x509_get_not_after(self.x509)) - if 'Bad time value' in str(out): - raise X509Error( - '''M2Crypto cannot handle dates after year 2050. - See RFC 5280 4.1.2.5 for more information. - ''') - return out - - def get_pubkey(self): - # type: () -> EVP.PKey - assert m2.x509_type_check(self.x509), "'x509' type error" - return EVP.PKey(m2.x509_get_pubkey(self.x509), _pyfree=1) - - def set_pubkey(self, pkey): - # type: (EVP.PKey) -> int - """ - Set the public key for the certificate - - :param pkey: Public key - - :return 1 for success and 0 for failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_pubkey(self.x509, pkey.pkey) - - def get_issuer(self): - # type: () -> X509_Name - assert m2.x509_type_check(self.x509), "'x509' type error" - return X509_Name(m2.x509_get_issuer_name(self.x509)) - - def set_issuer(self, name): - # type: (X509_Name) -> int - """ - Set issuer name. - - :param name: subjectName field. - - :return 1 for success and 0 for failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_issuer_name(self.x509, name.x509_name) - - def get_subject(self): - # type: () -> X509_Name - assert m2.x509_type_check(self.x509), "'x509' type error" - return X509_Name(m2.x509_get_subject_name(self.x509)) - - def set_subject(self, name): - # type: (X509_Name) -> int - """ - Set subject name. - - :param name: subjectName field. - - :return 1 for success and 0 for failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_set_subject_name(self.x509, name.x509_name) - - def add_ext(self, ext): - # type: (X509_Extension) -> int - """ - Add X509 extension to this certificate. - - :param ext: Extension - - :return 1 for success and 0 for failure - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - return m2.x509_add_ext(self.x509, ext.x509_ext, -1) - - def get_ext(self, name): - # type: (str) -> X509_Extension - """ - Get X509 extension by name. - - :param name: Name of the extension - - :return: X509_Extension - """ - # Optimizations to reduce attribute accesses - m2x509_get_ext = m2.x509_get_ext - m2x509_extension_get_name = m2.x509_extension_get_name - x509 = self.x509 - - name = six.ensure_binary(name) - for i in range(m2.x509_get_ext_count(x509)): - ext_ptr = m2x509_get_ext(x509, i) - if m2x509_extension_get_name(ext_ptr) == name: - return X509_Extension(ext_ptr, _pyfree=0) - - raise LookupError - - def get_ext_at(self, index): - # type: (int) -> X509_Extension - """ - Get X509 extension by index. - - :param index: Name of the extension - - :return: X509_Extension - """ - if index < 0 or index >= self.get_ext_count(): - raise IndexError - - return X509_Extension(m2.x509_get_ext(self.x509, index), - _pyfree=0) - - def get_ext_count(self): - # type: () -> int - """ - Get X509 extension count. - """ - return m2.x509_get_ext_count(self.x509) - - def sign(self, pkey, md): - # type: (EVP.PKey, str) -> int - """ - Sign the certificate. - - :param pkey: Public key - - :param md: Message digest algorithm to use for signing, - for example 'sha1'. - - :return int - """ - assert m2.x509_type_check(self.x509), "'x509' type error" - mda = getattr(m2, md, None) - if mda is None: - raise ValueError('unknown message digest', md) - return m2.x509_sign(self.x509, pkey.pkey, mda()) - - def verify(self, pkey=None): - # type: (Optional[EVP.PKey]) -> int - assert m2.x509_type_check(self.x509), "'x509' type error" - if pkey: - return m2.x509_verify(self.x509, pkey.pkey) - else: - return m2.x509_verify(self.x509, self.get_pubkey().pkey) - - def check_ca(self): - # type: () -> int - """ - Check if the certificate is a Certificate Authority (CA) certificate. - - :return: 0 if the certificate is not CA, nonzero otherwise. - - :requires: OpenSSL 0.9.8 or newer - """ - return m2.x509_check_ca(self.x509) - - def check_purpose(self, id, ca): - # type: (int, int) -> int - """ - Check if the certificate's purpose matches the asked purpose. - - :param id: Purpose id. See X509_PURPOSE_* constants. - - :param ca: 1 if the certificate should be CA, 0 otherwise. - - :return: 0 if the certificate purpose does not match, nonzero - otherwise. - """ - return m2.x509_check_purpose(self.x509, id, ca) - - def get_fingerprint(self, md='md5'): - # type: (str) -> str - """ - Get the fingerprint of the certificate. - - :param md: Message digest algorithm to use. - - :return: String containing the fingerprint in hex format. - """ - der = self.as_der() - md = EVP.MessageDigest(md) - md.update(der) - digest = md.final() - return six.ensure_text(binascii.hexlify(digest).upper()) - - -def load_cert(file, format=FORMAT_PEM): - # type: (AnyStr, int) -> X509 - """ - Load certificate from file. - - :param file: Name of file containing certificate in either DER or - PEM format. - - :param format: Describes the format of the file to be loaded, - either PEM or DER. - - :return: M2Crypto.X509.X509 object. - """ - with BIO.openfile(file) as bio: - if format == FORMAT_PEM: - return load_cert_bio(bio) - elif format == FORMAT_DER: - cptr = m2.d2i_x509(bio._ptr()) - return X509(cptr, _pyfree=1) - else: - raise ValueError( - "Unknown format. Must be either FORMAT_DER or FORMAT_PEM") - - -def load_cert_bio(bio, format=FORMAT_PEM): - # type: (BIO.BIO, int) -> X509 - """ - Load certificate from a bio. - - :param bio: BIO pointing at a certificate in either DER or PEM format. - - :param format: Describes the format of the cert to be loaded, - either PEM or DER (via constants FORMAT_PEM - and FORMAT_FORMAT_DER) - - :return: M2Crypto.X509.X509 object. - """ - if format == FORMAT_PEM: - cptr = m2.x509_read_pem(bio._ptr()) - elif format == FORMAT_DER: - cptr = m2.d2i_x509(bio._ptr()) - else: - raise ValueError( - "Unknown format. Must be either FORMAT_DER or FORMAT_PEM") - return X509(cptr, _pyfree=1) - - -def load_cert_string(string, format=FORMAT_PEM): - # type: (AnyStr, int) -> X509 - """ - Load certificate from a string. - - :param string: String containing a certificate in either DER or PEM format. - - :param format: Describes the format of the cert to be loaded, - either PEM or DER (via constants FORMAT_PEM - and FORMAT_FORMAT_DER) - - :return: M2Crypto.X509.X509 object. - """ - string = six.ensure_binary(string) - bio = BIO.MemoryBuffer(string) - return load_cert_bio(bio, format) - - -def load_cert_der_string(string): - # type: (AnyStr) -> X509 - """ - Load certificate from a string. - - :param string: String containing a certificate in DER format. - - :return: M2Crypto.X509.X509 object. - """ - string = six.ensure_binary(string) - bio = BIO.MemoryBuffer(string) - cptr = m2.d2i_x509(bio._ptr()) - return X509(cptr, _pyfree=1) - - -class X509_Store_Context(object): - """ - X509 Store Context - """ - - m2_x509_store_ctx_free = m2.x509_store_ctx_free - - def __init__(self, x509_store_ctx, _pyfree=0): - # type: (bytes, int) -> None - """ - - :param x509_store_ctx: binary data for - OpenSSL X509_STORE_CTX type - """ - self.ctx = x509_store_ctx - self._pyfree = _pyfree - - def __del__(self): - # type: () -> None - # see BIO.py - unbalanced __init__ / __del__ - if not hasattr(self, '_pyfree'): - pass # print("OOPS") - elif self._pyfree: - self.m2_x509_store_ctx_free(self.ctx) - - def _ptr(self): - return self.ctx - - def get_current_cert(self): - # type: () -> X509 - """ - Get current X.509 certificate. - - :warning: The returned certificate is NOT refcounted, so you can not - rely on it being valid once the store context goes - away or is modified. - """ - return X509(m2.x509_store_ctx_get_current_cert(self.ctx), _pyfree=0) - - def get_error(self): - # type: () -> int - """ - Get error code. - """ - return m2.x509_store_ctx_get_error(self.ctx) - - def get_error_depth(self): - # type: () -> int - """ - Get error depth. - """ - return m2.x509_store_ctx_get_error_depth(self.ctx) - - def get1_chain(self): - # type: () -> X509_Stack - """ - Get certificate chain. - - :return: Reference counted (i.e. safe to use even after the store - context goes away) stack of certificates in the chain. - """ - return X509_Stack(m2.x509_store_ctx_get1_chain(self.ctx), 1, 1) - - -class X509_Store(object): - """ - X509 Store - """ - - m2_x509_store_free = m2.x509_store_free - - def __init__(self, store=None, _pyfree=0): - # type: (Optional[bytes], int) -> None - """ - :param store: binary data for OpenSSL X509_STORE_CTX type. - """ - if store is not None: - self.store = store - self._pyfree = _pyfree - else: - self.store = m2.x509_store_new() - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_x509_store_free(self.store) - - def _ptr(self): - return self.store - - def load_info(self, file): - # type: (AnyStr) -> int - """ - :param file: filename - - :return: 1 on success, 0 on failure - """ - ret = m2.x509_store_load_locations(self.store, file) - return ret - - load_locations = load_info - - def add_x509(self, x509): - # type: (X509) -> int - assert isinstance(x509, X509) - return m2.x509_store_add_cert(self.store, x509._ptr()) - - def set_verify_cb(self, callback=None): - # type: (Optional[callable]) -> None - """ - Set callback which will be called when the store is verified. - Wrapper over OpenSSL X509_STORE_set_verify_cb(). - - :param callback: Callable to specify verification options. - Type of the callable must be: - (int, X509_Store_Context) -> int. - If None: set the standard options. - - :note: compile-time or run-time errors in the callback would result - in mysterious errors during verification, which could be hard - to trace. - - :note: Python exceptions raised in callbacks do not propagate to - verify() call. - - :return: None - """ - if callback is None: - return self.set_verify_cb(x509_store_default_cb) - - if not callable(callback): - raise X509Error("set_verify(): callback is not callable") - return m2.x509_store_set_verify_cb(self.store, callback) - - add_cert = add_x509 - - def set_flags(self, flags): - # type: (int) -> int - """ - Set the verification flags for the X509Store - Wrapper over OpenSSL X509_STORE_set_flags() - - :param flags: `VERIFICATION FLAGS` section of the - X509_VERIFY_PARAM_set_flags man page has - a complete description of values the flags - parameter can take. - Their M2Crypto equivalent is transformed following - the pattern: "X509_V_FLAG_XYZ" -> lowercase("VERIFY_XYZ") - """ - return m2.x509_store_set_flags(self.store, flags) - - -class X509_Stack(object): - """ - X509 Stack - - :warning: Do not modify the underlying OpenSSL stack - except through this interface, or use any OpenSSL - functions that do so indirectly. Doing so will get the - OpenSSL stack and the internal pystack of this class out - of sync, leading to python memory leaks, exceptions or - even python crashes! - """ - - m2_sk_x509_free = m2.sk_x509_free - - def __init__(self, stack=None, _pyfree=0, _pyfree_x509=0): - # type: (bytes, int, int) -> None - if stack is not None: - self.stack = stack - self._pyfree = _pyfree - self.pystack = [] # This must be kept in sync with self.stack - num = m2.sk_x509_num(self.stack) - for i in range(num): - self.pystack.append(X509(m2.sk_x509_value(self.stack, i), - _pyfree=_pyfree_x509)) - else: - self.stack = m2.sk_x509_new_null() - self._pyfree = 1 - self.pystack = [] # This must be kept in sync with self.stack - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_sk_x509_free(self.stack) - - def __len__(self): - # type: () -> int - assert m2.sk_x509_num(self.stack) == len(self.pystack) - return len(self.pystack) - - def __getitem__(self, idx): - # type: (int) -> X509 - return self.pystack[idx] - - def __iter__(self): - return iter(self.pystack) - - def _ptr(self): - return self.stack - - def push(self, x509): - # type: (X509) -> int - """ - push an X509 certificate onto the stack. - - :param x509: X509 object. - - :return: The number of X509 objects currently on the stack. - """ - assert isinstance(x509, X509) - self.pystack.append(x509) - ret = m2.sk_x509_push(self.stack, x509._ptr()) - assert ret == len(self.pystack) - return ret - - def pop(self): - # type: () -> X509 - """ - pop a certificate from the stack. - - :return: X509 object that was popped, or None if there is - nothing to pop. - """ - x509_ptr = m2.sk_x509_pop(self.stack) - if x509_ptr is None: - assert len(self.pystack) == 0 - return None - return self.pystack.pop() - - def as_der(self): - # type: () -> bytes - """ - Return the stack as a DER encoded string - """ - return m2.get_der_encoding_stack(self.stack) - - -def new_stack_from_der(der_string): - # type: (bytes) -> X509_Stack - """ - Create a new X509_Stack from DER string. - - :return: X509_Stack - """ - der_string = six.ensure_binary(der_string) - stack_ptr = m2.make_stack_from_der_sequence(der_string) - return X509_Stack(stack_ptr, 1, 1) - - -class Request(object): - """ - X509 Certificate Request. - """ - - m2_x509_req_free = m2.x509_req_free - - def __init__(self, req=None, _pyfree=0): - # type: (Optional[int], int) -> None - if req is not None: - self.req = req - self._pyfree = _pyfree - else: - self.req = m2.x509_req_new() - m2.x509_req_set_version(self.req, 0) - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_x509_req_free(self.req) - - def as_text(self): - # type: () -> str - buf = BIO.MemoryBuffer() - m2.x509_req_print(buf.bio_ptr(), self.req) - return six.ensure_text(buf.read_all()) - - def as_pem(self): - # type: () -> bytes - buf = BIO.MemoryBuffer() - m2.x509_req_write_pem(buf.bio_ptr(), self.req) - return buf.read_all() - - def as_der(self): - # type: () -> bytes - buf = BIO.MemoryBuffer() - m2.i2d_x509_req_bio(buf.bio_ptr(), self.req) - return buf.read_all() - - def save_pem(self, filename): - # type: (AnyStr) -> int - with BIO.openfile(filename, 'wb') as bio: - return m2.x509_req_write_pem(bio.bio_ptr(), self.req) - - def save(self, filename, format=FORMAT_PEM): - # type: (AnyStr, int) -> int - """ - Saves X.509 certificate request to a file. Default output - format is PEM. - - :param filename: Name of the file the request will be saved to. - - :param format: Controls what output format is used to save the - request. Either FORMAT_PEM or FORMAT_DER to save - in PEM or DER format. Raises ValueError if an - unknown format is used. - - :return: 1 for success, 0 for failure. - The error code can be obtained by ERR_get_error. - """ - with BIO.openfile(filename, 'wb') as bio: - if format == FORMAT_PEM: - return m2.x509_req_write_pem(bio.bio_ptr(), self.req) - elif format == FORMAT_DER: - return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req) - else: - raise ValueError( - "Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM") - - def get_pubkey(self): - # type: () -> EVP.PKey - """ - Get the public key for the request. - - :return: Public key from the request. - """ - return EVP.PKey(m2.x509_req_get_pubkey(self.req), _pyfree=1) - - def set_pubkey(self, pkey): - # type: (EVP.PKey) -> int - """ - Set the public key for the request. - - :param pkey: Public key - - :return: Return 1 for success and 0 for failure. - """ - return m2.x509_req_set_pubkey(self.req, pkey.pkey) - - def get_version(self): - # type: () -> int - """ - Get version. - - :return: Returns version. - """ - return m2.x509_req_get_version(self.req) - - def set_version(self, version): - # type: (int) -> int - """ - Set version. - - :param version: Version number. - :return: Returns 0 on failure. - """ - return m2.x509_req_set_version(self.req, version) - - def get_subject(self): - # type: () -> X509_Name - return X509_Name(m2.x509_req_get_subject_name(self.req)) - - def set_subject_name(self, name): - # type: (X509_Name) -> int - """ - Set subject name. - - :param name: subjectName field. - :return: 1 for success and 0 for failure - """ - return m2.x509_req_set_subject_name(self.req, name.x509_name) - - set_subject = set_subject_name - - def add_extensions(self, ext_stack): - # type: (X509_Extension_Stack) -> int - """ - Add X509 extensions to this request. - - :param ext_stack: Stack of extensions to add. - :return: 1 for success and 0 for failure - """ - return m2.x509_req_add_extensions(self.req, ext_stack._ptr()) - - def verify(self, pkey): - # type: (EVP.PKey) -> int - """ - - :param pkey: PKey to be verified - :return: 1 for success and 0 for failure - """ - return m2.x509_req_verify(self.req, pkey.pkey) - - def sign(self, pkey, md): - # type: (EVP.PKey, str) -> int - """ - - :param pkey: PKey to be signed - :param md: used algorigthm - :return: 1 for success and 0 for failure - """ - mda = getattr(m2, md, None) - if mda is None: - raise ValueError('unknown message digest', md) - return m2.x509_req_sign(self.req, pkey.pkey, mda()) - - -def load_request(file, format=FORMAT_PEM): - # type: (AnyStr, int) -> Request - """ - Load certificate request from file. - - :param file: Name of file containing certificate request in - either PEM or DER format. - :param format: Describes the format of the file to be loaded, - either PEM or DER. (using constants FORMAT_PEM - and FORMAT_DER) - :return: Request object. - """ - with BIO.openfile(file) as f: - if format == FORMAT_PEM: - cptr = m2.x509_req_read_pem(f.bio_ptr()) - elif format == FORMAT_DER: - cptr = m2.d2i_x509_req(f.bio_ptr()) - else: - raise ValueError( - "Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER") - - return Request(cptr, 1) - - -def load_request_bio(bio, format=FORMAT_PEM): - # type: (BIO.BIO, int) -> Request - """ - Load certificate request from a bio. - - :param bio: BIO pointing at a certificate request in - either DER or PEM format. - :param format: Describes the format of the request to be loaded, - either PEM or DER. (using constants FORMAT_PEM - and FORMAT_DER) - :return: M2Crypto.X509.Request object. - """ - if format == FORMAT_PEM: - cptr = m2.x509_req_read_pem(bio._ptr()) - elif format == FORMAT_DER: - cptr = m2.d2i_x509_req(bio._ptr()) - else: - raise ValueError( - "Unknown format. Must be either FORMAT_DER or FORMAT_PEM") - - return Request(cptr, _pyfree=1) - - -def load_request_string(string, format=FORMAT_PEM): - # type: (AnyStr, int) -> Request - """ - Load certificate request from a string. - - :param string: String containing a certificate request in - either DER or PEM format. - :param format: Describes the format of the request to be loaded, - either PEM or DER. (using constants FORMAT_PEM - and FORMAT_DER) - - :return: M2Crypto.X509.Request object. - """ - string = six.ensure_binary(string) - bio = BIO.MemoryBuffer(string) - return load_request_bio(bio, format) - - -def load_request_der_string(string): - # type: (AnyStr) -> Request - """ - Load certificate request from a string. - - :param string: String containing a certificate request in DER format. - :return: M2Crypto.X509.Request object. - """ - string = six.ensure_binary(string) - bio = BIO.MemoryBuffer(string) - return load_request_bio(bio, FORMAT_DER) - - -class CRL(object): - """ - X509 Certificate Revocation List - """ - - m2_x509_crl_free = m2.x509_crl_free - - def __init__(self, crl=None, _pyfree=0): - # type: (Optional[bytes], int) -> None - """ - - :param crl: binary representation of - the underlying OpenSSL X509_CRL object. - """ - if crl is not None: - self.crl = crl - self._pyfree = _pyfree - else: - self.crl = m2.x509_crl_new() - self._pyfree = 1 - - def __del__(self): - # type: () -> None - if getattr(self, '_pyfree', 0): - self.m2_x509_crl_free(self.crl) - - def as_text(self): - # type: () -> str - """ - Return CRL in PEM format in a string. - - :return: String containing the CRL in PEM format. - """ - buf = BIO.MemoryBuffer() - m2.x509_crl_print(buf.bio_ptr(), self.crl) - return six.ensure_text(buf.read_all()) - - -def load_crl(file): - # type: (AnyStr) -> CRL - """ - Load CRL from file. - - :param file: Name of file containing CRL in PEM format. - - :return: M2Crypto.X509.CRL object. - """ - with BIO.openfile(file) as f: - cptr = m2.x509_crl_read_pem(f.bio_ptr()) - - return CRL(cptr, 1) diff --git a/M2Crypto/__init__.py b/M2Crypto/__init__.py deleted file mode 100644 index 4fc489f..0000000 --- a/M2Crypto/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -from __future__ import absolute_import - -""" -M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, -DH, EC, HMACs, message digests, symmetric ciphers (including AES); SSL -functionality to implement clients and servers; HTTPS extensions to -Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies -for web session management; FTP/TLS client and server; S/MIME; ZServerSSL: -A HTTPS server for Zope and ZSmime: An S/MIME messenger for Zope. -M2Crypto can also be used to provide SSL for Twisted. Smartcards supported -through the Engine interface. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - -Portions created by Open Source Applications Foundation (OSAF) are -Copyright (C) 2004-2007 OSAF. All Rights Reserved. - -Copyright 2008-2011 Heikki Toivonen. All rights reserved. -""" -# noqa -from distutils.version import StrictVersion -__version__ = '0.37.1' -version = __version__ # type: str -version_info = StrictVersion(__version__).version - -from M2Crypto import (ASN1, AuthCookie, BIO, BN, DH, DSA, EVP, Engine, Err, - RSA, Rand, SMIME, SSL, X509, m2crypto, ftpslib, - httpslib, m2, m2urllib, m2xmlrpclib, threading, - util) - -if m2.OPENSSL_VERSION_NUMBER >= 0x90800F and m2.OPENSSL_NO_EC == 0: - from M2Crypto import EC -if m2.OPENSSL_NO_RC4 == 0: - from M2Crypto import RC4 -# Backwards compatibility. -urllib2 = m2urllib - -encrypt = 1 -decrypt = 0 - -m2crypto.lib_init() diff --git a/M2Crypto/callback.py b/M2Crypto/callback.py deleted file mode 100644 index c6f54d8..0000000 --- a/M2Crypto/callback.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import absolute_import - -"""Deprecated, use the util module instead. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -import warnings - -warnings.warn('Use the util module instead', DeprecationWarning) - -from M2Crypto.util import genparam_callback, passphrase_callback diff --git a/M2Crypto/ftpslib.py b/M2Crypto/ftpslib.py deleted file mode 100644 index e996981..0000000 --- a/M2Crypto/ftpslib.py +++ /dev/null @@ -1,91 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto client-side FTP/TLS. - -This implementation complies with draft-murray-auth-ftp-ssl-07.txt. - -Example: - ->>> from M2Crypto import ftpslib ->>> f = ftpslib.FTP_TLS() ->>> f.connect('', 9021) -'220 spinnaker.dyndns.org M2Crypto (Medusa) FTP/TLS server v0.07 ready.' ->>> f.auth_tls() ->>> f.set_pasv(0) ->>> f.login('ftp', 'ngps@') -'230 Ok.' ->>> f.retrlines('LIST') --rw-rw-r-- 1 0 198 2326 Jul 3 1996 apache_pb.gif -drwxrwxr-x 7 0 198 1536 Oct 10 2000 manual -drwxrwxr-x 2 0 198 512 Oct 31 2000 modpy -drwxrwxr-x 2 0 198 512 Oct 31 2000 bobo -drwxr-xr-x 2 0 198 14336 May 28 15:54 postgresql -drwxr-xr-x 4 100 198 512 May 16 17:19 home -drwxr-xr-x 7 100 100 3584 Sep 23 2000 openacs -drwxr-xr-x 10 0 0 512 Aug 5 2000 python1.5 --rw-r--r-- 1 100 198 326 Jul 29 03:29 index.html -drwxr-xr-x 12 0 0 512 May 31 17:08 python2.1 -'226 Transfer complete' ->>> f.quit() -'221 Goodbye.' ->>> - - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -# We want to import whole stdlib ftplib objects, because our users want -# to use them. -from ftplib import * # noqa - -# M2Crypto -from M2Crypto import SSL - - -class FTP_TLS(FTP): - - """Python OO interface to client-side FTP/TLS.""" - - def __init__(self, host=None, ssl_ctx=None): - """Initialise the client. If 'host' is supplied, connect to it.""" - if ssl_ctx is not None: - self.ssl_ctx = ssl_ctx - else: - self.ssl_ctx = SSL.Context() - FTP.__init__(self, host) - self.prot = 0 - - def auth_tls(self): - """Secure the control connection per AUTH TLS, aka AUTH TLS-C.""" - self.voidcmd('AUTH TLS') - s = SSL.Connection(self.ssl_ctx, self.sock) - s.setup_ssl() - s.set_connect_state() - s.connect_ssl() - self.sock = s - self.file = self.sock.makefile() - - def auth_ssl(self): - """Secure the control connection per AUTH SSL, aka AUTH TLS-P.""" - raise NotImplementedError - - def prot_p(self): - """Set up secure data connection.""" - self.voidcmd('PBSZ 0') - self.voidcmd('PROT P') - self.prot = 1 - - def prot_c(self): - """Set up data connection in the clear.""" - self.voidcmd('PROT C') - self.prot = 0 - - def ntransfercmd(self, cmd, rest=None): - """Initiate a data transfer.""" - conn, size = FTP.ntransfercmd(self, cmd, rest) - if self.prot: - conn = SSL.Connection(self.ssl_ctx, conn) - conn.setup_ssl() - conn.set_connect_state() - conn.set_session(self.sock.get_session()) - conn.connect_ssl() - return conn, size diff --git a/M2Crypto/httpslib.py b/M2Crypto/httpslib.py deleted file mode 100644 index 0deee64..0000000 --- a/M2Crypto/httpslib.py +++ /dev/null @@ -1,268 +0,0 @@ -from __future__ import absolute_import - -import warnings - -"""M2Crypto support for Python's httplib. - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" - -import base64 -import socket - -from M2Crypto import SSL, six -from M2Crypto.six.moves.urllib_parse import urlsplit, urlunsplit -from M2Crypto.six.moves.http_client import * # noqa -# This is not imported with just '*' -from M2Crypto.six.moves.http_client import HTTPS_PORT -from typing import Any, AnyStr, Callable, Dict, Optional # noqa - - -class HTTPSConnection(HTTPConnection): - - """ - This class allows communication via SSL using M2Crypto. - """ - - default_port = HTTPS_PORT - - def __init__(self, host, port=None, strict=None, **ssl): - # type: (str, Optional[int], Optional[bool], **Any) -> None - """ - Represents one transaction with an HTTP server over the SSL - connection. - - :param host: host name - :param port: port number - :param strict: if switched on, it raises BadStatusLine to be - raised if the status line can't be parsed as - a valid HTTP/1.0 or 1.1 status line. - :param ssl: dict with all remaining named real parameters of the - function. Specifically, ``ssl_context`` is expected - to be included with SSL.Context; if it is not - default ``'sslv23'`` is substituted). - """ - self.session = None # type: bytes - self.host = host - self.port = port - keys = set(ssl.keys()) - set(('key_file', 'cert_file', 'ssl_context')) - if keys: - raise ValueError('unknown keyword argument: %s', keys) - try: - self.ssl_ctx = ssl['ssl_context'] - assert isinstance(self.ssl_ctx, SSL.Context), self.ssl_ctx - except KeyError: - self.ssl_ctx = SSL.Context() - HTTPConnection.__init__(self, host, port, strict) - - def connect(self): - # type: () -> None - error = None - # We ignore the returned sockaddr because SSL.Connection.connect needs - # a host name. - for (family, _, _, _, _) in \ - socket.getaddrinfo(self.host, self.port, 0, - socket.SOCK_STREAM): - sock = None - try: - sock = SSL.Connection(self.ssl_ctx, family=family) - - # set SNI server name since we know it at this point - sock.set_tlsext_host_name(self.host) - - if self.session is not None: - sock.set_session(self.session) - sock.connect((self.host, self.port)) - - self.sock = sock - sock = None - return - except socket.error as e: - # Other exception are probably SSL-related, in that case we - # abort and the exception is forwarded to the caller. - error = e - finally: - if sock is not None: - sock.close() - - if error is None: - raise AssertionError("Empty list returned by getaddrinfo") - raise error - - def close(self): - # type: () -> None - # This kludges around line 545 of httplib.py, - # which closes the connection in this object; - # the connection remains open in the response - # object. - # - # M2Crypto doesn't close-here-keep-open-there, - # so, in effect, we don't close until the whole - # business is over and gc kicks in. - # - # XXX Long-running callers beware leakage. - # - # XXX 05-Jan-2002: This module works with Python 2.2, - # XXX but I've not investigated if the above conditions - # XXX remain. - pass - - def get_session(self): - # type: () -> SSL.Session.Session - return self.sock.get_session() - - def set_session(self, session): - # type: (SSL.Session.Session) -> None - self.session = session - - -class ProxyHTTPSConnection(HTTPSConnection): - """ - An HTTPS Connection that uses a proxy and the CONNECT request. - - When the connection is initiated, CONNECT is first sent to the proxy (along - with authorization headers, if supplied). If successful, an SSL connection - will be established over the socket through the proxy and to the target - host. - - Finally, the actual request is sent over the SSL connection tunneling - through the proxy. - """ - - _ports = {'http': 80, 'https': 443} - _AUTH_HEADER = "Proxy-Authorization" - _UA_HEADER = "User-Agent" - - def __init__(self, host, port=None, strict=None, username=None, - password=None, **ssl): - # type: (str, Optional[int], Optional[bool], Optional[AnyStr], Optional[AnyStr], **Any) -> None - """ - Create the ProxyHTTPSConnection object. - - :param host: host name of the proxy server - :param port: port number of the proxy server - :param strict: if switched on, it raises BadStatusLine to be - raised if the status line can't be parsed as - a valid HTTP/1.0 or 1.1 status line. - :param username: username on the proxy server, when required - Username can be ``str``, but preferred type - is ``bytes``. M2Crypto does some conversion to - ``bytes`` when necessary, but it's better when - the user of the library does it on its own. - :param password: password on the proxy server, when required - The same as with ``username``, ``str`` is accepted, - but ``bytes`` are preferred. - :param ssl: dict with all remaining named real parameters of the - function. Specifically, ``ssl_context`` is expected - to be included with SSL.Context; if it is not - default ``'sslv23'`` is substituted). - """ - HTTPSConnection.__init__(self, host, port, strict, **ssl) - - self._username = username.encode('utf8') \ - if isinstance(username, six.string_types) else username - self._password = password.encode('utf8') \ - if isinstance(password, six.string_types) else password - self._proxy_auth = None # type: str - self._proxy_UA = None # type: str - - def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): - # type: (AnyStr, AnyStr, int, int) -> None - """ - putrequest is called before connect, so can interpret url and get - real host/port to be used to make CONNECT request to proxy - """ - proto, netloc, path, query, fragment = urlsplit(url) - if not proto: - raise ValueError("unknown URL type: %s" % url) - - # get host & port - try: - username_password, host_port = netloc.split('@') - except ValueError: - host_port = netloc - - try: - host, port_s = host_port.split(':') - port = int(port_s) - except ValueError: - host = host_port - # try to get port from proto - try: - port = self._ports[proto] - except KeyError: - raise ValueError("unknown protocol for: %s" % url) - - self._real_host = host # type: str - self._real_port = port # type: int - rest = urlunsplit(('', '', path, query, fragment)) - HTTPSConnection.putrequest(self, method, rest, skip_host, - skip_accept_encoding) - - def putheader(self, header, value): - # type: (AnyStr, AnyStr) -> None - # Store the auth header if passed in. - if header.lower() == self._UA_HEADER.lower(): - self._proxy_UA = value - if header.lower() == self._AUTH_HEADER.lower(): - self._proxy_auth = value - else: - HTTPSConnection.putheader(self, header, value) - - def endheaders(self, *args, **kwargs): - # type: (*Any, **Any) -> None - # We've recieved all of hte headers. Use the supplied username - # and password for authorization, possibly overriding the authstring - # supplied in the headers. - if not self._proxy_auth: - self._proxy_auth = self._encode_auth() - - HTTPSConnection.endheaders(self, *args, **kwargs) - - def connect(self): - # type: () -> None - HTTPConnection.connect(self) - - # send proxy CONNECT request - self.sock.sendall(self._get_connect_msg()) - response = HTTPResponse(self.sock) - response.begin() - - code = response.status - if code != 200: - # proxy returned and error, abort connection, and raise exception - self.close() - raise socket.error("Proxy connection failed: %d" % code) - - self._start_ssl() - - def _get_connect_msg(self): - # type: () -> bytes - """ Return an HTTP CONNECT request to send to the proxy. """ - msg = "CONNECT %s:%d HTTP/1.1\r\n" % (self._real_host, self._real_port) - msg = msg + "Host: %s:%d\r\n" % (self._real_host, self._real_port) - if self._proxy_UA: - msg = msg + "%s: %s\r\n" % (self._UA_HEADER, self._proxy_UA) - if self._proxy_auth: - msg = msg + "%s: %s\r\n" % (self._AUTH_HEADER, self._proxy_auth) - msg = msg + "\r\n" - return six.ensure_binary(msg) - - def _start_ssl(self): - # type: () -> None - """ Make this connection's socket SSL-aware. """ - self.sock = SSL.Connection(self.ssl_ctx, self.sock) - self.sock.setup_ssl() - self.sock.set_connect_state() - self.sock.connect_ssl() - - def _encode_auth(self): - # type: () -> Optional[bytes] - """ Encode the username and password for use in the auth header. """ - if not (self._username and self._password): - return None - # Authenticated proxy - userpass = "%s:%s" % (self._username, self._password) - with warnings.catch_warnings(): - warnings.simplefilter("ignore", DeprecationWarning) - enc_userpass = base64.encodestring(userpass).replace("\n", "") - return six.ensure_binary("Basic %s" % enc_userpass) diff --git a/M2Crypto/m2.py b/M2Crypto/m2.py deleted file mode 100644 index 81e4315..0000000 --- a/M2Crypto/m2.py +++ /dev/null @@ -1,31 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto low level OpenSSL wrapper functions. - -m2 is the low level wrapper for OpenSSL functions. Typically you would not -need to use these directly, since these will be called by the higher level -objects you should try to use instead. - -Naming conventions: All functions wrapped by m2 are all lower case, -words separated by underscores. - -Examples: - -OpenSSL M2Crypto - -X509_get_version m2.x509_get_version -X509_get_notBefore m2.x509_get_not_before -X509_REQ_verify m2.x509_req_verify - -Exceptions to naming rules: - -XXX TDB - -Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - -Portions created by Open Source Applications Foundation (OSAF) are -Copyright (C) 2004 OSAF. All Rights Reserved. -""" - -from M2Crypto.m2crypto import * -lib_init() diff --git a/M2Crypto/m2crypto.py b/M2Crypto/m2crypto.py deleted file mode 100644 index 1323547..0000000 --- a/M2Crypto/m2crypto.py +++ /dev/null @@ -1,67 +0,0 @@ -# This file was automatically generated by SWIG (http://www.swig.org). -# Version 4.0.2 -# -# Do not make changes to this file unless you know what you are doing--modify -# the SWIG interface file instead. - -from sys import version_info as _swig_python_version_info -if _swig_python_version_info < (2, 7, 0): - raise RuntimeError("Python 2.7 or later required") - -# Pull in all the attributes from the low-level C/C++ module -if __package__ or "." in __name__: - from ._m2crypto import * -else: - from _m2crypto import * - -try: - import builtins as __builtin__ -except ImportError: - import __builtin__ - -def _swig_repr(self): - try: - strthis = "proxy of " + self.this.__repr__() - except __builtin__.Exception: - strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) - - -def _swig_setattr_nondynamic_instance_variable(set): - def set_instance_attr(self, name, value): - if name == "thisown": - self.this.own(value) - elif name == "this": - set(self, name, value) - elif hasattr(self, name) and isinstance(getattr(type(self), name), property): - set(self, name, value) - else: - raise AttributeError("You cannot add instance attributes to %s" % self) - return set_instance_attr - - -def _swig_setattr_nondynamic_class_variable(set): - def set_class_attr(cls, name, value): - if hasattr(cls, name) and not isinstance(getattr(cls, name), property): - set(cls, name, value) - else: - raise AttributeError("You cannot add class attributes to %s" % cls) - return set_class_attr - - -def _swig_add_metaclass(metaclass): - """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" - def wrapper(cls): - return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) - return wrapper - - -class _SwigNonDynamicMeta(type): - """Meta class to enforce nondynamic attributes (no new attributes) for a class""" - __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) - - - - - - diff --git a/M2Crypto/m2urllib.py b/M2Crypto/m2urllib.py deleted file mode 100644 index 06641b2..0000000 --- a/M2Crypto/m2urllib.py +++ /dev/null @@ -1,120 +0,0 @@ -from __future__ import absolute_import, print_function - -"""M2Crypto enhancement to Python's urllib for handling -'https' url's. - -FIXME: it is questionable whether we need this old-style module at all. urllib -(not urllib2) is in Python 3 support just as a legacy API. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -import base64 -import warnings - -from M2Crypto import SSL, httpslib, six - -from M2Crypto.six.moves.urllib_response import addinfourl -from typing import AnyStr, Optional # noqa - -# six.moves doesn't support star imports -if six.PY3: - from urllib.request import * # noqa for other modules to import - from urllib.parse import * # noqa for other modules to import - from urllib.error import * # noqa for other modules to import -else: - from urllib import * # noqa - - -def open_https(self, url, data=None, ssl_context=None): - # type: (URLOpener, AnyStr, Optional[bytes], Optional[SSL.Context]) -> addinfourl - """ - Open URL over the SSL connection. - - :param url: URL to be opened - :param data: data for the POST request - :param ssl_context: SSL.Context to be used - :return: - """ - if six.PY3: - warnings.warn('URLOpener has been deprecated in Py3k', DeprecationWarning) - - if ssl_context is not None and isinstance(ssl_context, SSL.Context): - self.ctx = ssl_context - else: - self.ctx = SSL.Context() - user_passwd = None - if isinstance(url, six.string_types): - try: # python 2 - # http://pydoc.org/2.5.1/urllib.html - host, selector = splithost(url) - if host: - user_passwd, host = splituser(host) - host = unquote(host) - realhost = host - except NameError: # python 3 has no splithost - # https://docs.python.org/3/library/urllib.parse.html - parsed = urlparse(url) - host = parsed.hostname - if parsed.port: - host += ":{0}".format(parsed.port) - user_passwd = parsed.password - if parsed.password: - user_passwd += ":{0}".format(parsed.password) - selector = parsed.path - else: - host, selector = url - urltype, rest = splittype(selector) - url = rest - user_passwd = None - if urltype.lower() != 'http': - realhost = None - else: - try: # python 2 - realhost, rest = splithost(rest) - if realhost: - user_passwd, realhost = splituser(realhost) - if user_passwd: - selector = "%s://%s%s" % (urltype, realhost, rest) - except NameError: # python 3 has no splithost - parsed = urlparse(rest) - host = parsed.hostname - if parsed.port: - host += ":{0}".format(parsed.port) - user_passwd = parsed.username - if parsed.password: - user_passwd += ":{0}".format(parsed.password) - # print("proxy via http:", host, selector) - if not host: - raise IOError('http error', 'no host given') - if user_passwd: - if six.PY3: - auth = base64.encodebytes(user_passwd).strip() - else: - auth = base64.encodestring(user_passwd).strip() - else: - auth = None - # Start here! - h = httpslib.HTTPSConnection(host=host, ssl_context=self.ctx) - # h.set_debuglevel(1) - # Stop here! - if data is not None: - h.putrequest('POST', selector) - h.putheader('Content-type', 'application/x-www-form-urlencoded') - h.putheader('Content-length', '%d' % len(data)) - else: - h.putrequest('GET', selector) - if auth: - h.putheader('Authorization', 'Basic %s' % auth) - for args in self.addheaders: - h.putheader(*args) # for python3 - used to use apply - h.endheaders() - if data is not None: - h.send(data + '\r\n') - # Here again! - resp = h.getresponse() - fp = resp.fp - return addinfourl(fp, resp.msg, "https:" + url) - # Stop again. - -# Minor brain surgery. -URLopener.open_https = open_https diff --git a/M2Crypto/m2urllib2.py b/M2Crypto/m2urllib2.py deleted file mode 100644 index 1849051..0000000 --- a/M2Crypto/m2urllib2.py +++ /dev/null @@ -1,185 +0,0 @@ -from __future__ import absolute_import - -""" -M2Crypto enhancement to Python's urllib2 for handling -'https' url's. - -Code from urllib2 is Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 -Python Software Foundation; All Rights Reserved - -Summary of changes: - - Use an HTTPSProxyConnection if the request is going through a proxy. - - Add the SSL context to the https connection when performing https_open. - - Add the M2Crypto HTTPSHandler when building a default opener. -""" - -import socket - -from M2Crypto import SSL, httpslib, six - -from M2Crypto.six.moves.urllib_parse import urldefrag, urlparse as url_parse -from M2Crypto.six.moves.urllib_response import addinfourl -from typing import Optional # noqa - -# six.moves doesn't support star imports -if six.PY3: - from urllib.request import * # noqa other modules want to import - from urllib.error import * # noqa other modules want to import -else: - from urllib2 import * # noqa - - -try: - mother_class = socket._fileobject -except AttributeError: - mother_class = socket.SocketIO - - -class _closing_fileobject(mother_class): # noqa - """socket._fileobject that propagates self.close() to the socket. - - Python 2.5 provides this as socket._fileobject(sock, close=True). - """ - -# for python 3 -try: - AbstractHTTPHandler -except NameError: - # somehow this won't get imported by the import * above - import urllib.request - AbstractHTTPHandler = urllib.request.AbstractHTTPHandler - - -class HTTPSHandler(AbstractHTTPHandler): - def __init__(self, ssl_context=None): - # type: (SSL.Context) -> None - AbstractHTTPHandler.__init__(self) - - if ssl_context is not None: - assert isinstance(ssl_context, SSL.Context), ssl_context - self.ctx = ssl_context - else: - self.ctx = SSL.Context() - - # Copied from urllib2, so we can set the ssl context. - def https_open(self, req): - # type: (Request) -> addinfourl - """Return an addinfourl object for the request, using http_class. - - http_class must implement the HTTPConnection API from httplib. - The addinfourl return value is a file-like object. It also - has methods and attributes including: - - - info(): return a mimetools.Message object for the headers - - - geturl(): return the original request URL - - - code: HTTP status code - """ - # https://docs.python.org/3.3/library/urllib.request.html#urllib.request.Request.get_host - try: # up to python-3.2 - host = req.get_host() - except AttributeError: # from python-3.3 - host = req.host - if not host: - raise URLError('no host given') - - # Our change: Check to see if we're using a proxy. - # Then create an appropriate ssl-aware connection. - full_url = req.get_full_url() - target_host = url_parse(full_url)[1] - - if target_host != host: - request_uri = urldefrag(full_url)[0] - h = httpslib.ProxyHTTPSConnection(host=host, ssl_context=self.ctx) - else: - try: # up to python-3.2 - request_uri = req.get_selector() - except AttributeError: # from python-3.3 - request_uri = req.selector - h = httpslib.HTTPSConnection(host=host, ssl_context=self.ctx) - # End our change - h.set_debuglevel(self._debuglevel) - - headers = dict(req.headers) - headers.update(req.unredirected_hdrs) - # We want to make an HTTP/1.1 request, but the addinfourl - # class isn't prepared to deal with a persistent connection. - # It will try to read all remaining data from the socket, - # which will block while the server waits for the next request. - # So make sure the connection gets closed after the (only) - # request. - headers["Connection"] = "close" - try: - h.request(req.get_method(), request_uri, req.data, headers) - r = h.getresponse() - except socket.error as err: # XXX what error? - raise URLError(err) - - # Pick apart the HTTPResponse object to get the addinfourl - # object initialized properly. - - # Wrap the HTTPResponse object in socket's file object adapter - # for Windows. That adapter calls recv(), so delegate recv() - # to read(). This weird wrapping allows the returned object to - # have readline() and readlines() methods. - r.recv = r.read - if six.PY2: - fp = socket._fileobject(r, close=True) - else: - r._decref_socketios = lambda: None - r.ssl = h.sock.ssl - r._timeout = -1.0 - r.recv_into = r.readinto - fp = socket.SocketIO(r, 'rb') - - resp = addinfourl(fp, r.msg, req.get_full_url()) - resp.code = r.status - resp.msg = r.reason - return resp - - https_request = AbstractHTTPHandler.do_request_ - - -# Copied from urllib2 with modifications for ssl -def build_opener(ssl_context=None, *handlers): - # type: (Optional[SSL.Context], *object) -> OpenerDirector - """Create an opener object from a list of handlers. - - The opener will use several default handlers, including support - for HTTP and FTP. - - If any of the handlers passed as arguments are subclasses of the - default handlers, the default handlers will not be used. - """ - - def isclass(obj): - return isinstance(obj, type) or hasattr(obj, "__bases__") - - opener = OpenerDirector() - default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, - HTTPDefaultErrorHandler, HTTPRedirectHandler, - FTPHandler, FileHandler, HTTPErrorProcessor] - skip = [] - for klass in default_classes: - for check in handlers: - if isclass(check): - if issubclass(check, klass): - skip.append(klass) - elif isinstance(check, klass): - skip.append(klass) - for klass in skip: - default_classes.remove(klass) - - for klass in default_classes: - opener.add_handler(klass()) - - # Add the HTTPS handler with ssl_context - if HTTPSHandler not in skip: - opener.add_handler(HTTPSHandler(ssl_context)) - - for h in handlers: - if isclass(h): - h = h() - opener.add_handler(h) - return opener diff --git a/M2Crypto/m2xmlrpclib.py b/M2Crypto/m2xmlrpclib.py deleted file mode 100644 index 8d8aa3e..0000000 --- a/M2Crypto/m2xmlrpclib.py +++ /dev/null @@ -1,78 +0,0 @@ -from __future__ import absolute_import - -"""M2Crypto enhancement to xmlrpclib. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -import base64 - -import M2Crypto - -from M2Crypto import SSL, httpslib, m2urllib, six -from typing import Any, AnyStr, Callable, Optional # noqa - -from M2Crypto.six.moves.xmlrpc_client import ProtocolError, Transport -# six.moves doesn't support star imports -if six.PY3: - from xmlrpc.client import * # noqa -else: - from xmlrpclib import * # noqa - -__version__ = M2Crypto.__version__ - - -class SSL_Transport(Transport): - - user_agent = "M2Crypto_XMLRPC/%s - %s" % (__version__, - Transport.user_agent) - - def __init__(self, ssl_context=None, *args, **kw): - # type: (Optional[SSL.Context], *Any, **Any) -> None - Transport.__init__(self, *args, **kw) - if ssl_context is None: - self.ssl_ctx = SSL.Context() - else: - self.ssl_ctx = ssl_context - - def request(self, host, handler, request_body, verbose=0): - # type: (AnyStr, Callable, bytes, int) -> object - # Handle username and password. - user_passwd, host_port = m2urllib.splituser(host) - _host, _port = m2urllib.splitport(host_port) - h = httpslib.HTTPSConnection(_host, int(_port), - ssl_context=self.ssl_ctx) - if verbose: - h.set_debuglevel(1) - - # What follows is as in xmlrpclib.Transport. (Except the authz bit.) - h.putrequest("POST", handler) - - # required by HTTP/1.1 - h.putheader("Host", _host) - - # required by XML-RPC - h.putheader("User-Agent", self.user_agent) - h.putheader("Content-Type", "text/xml") - h.putheader("Content-Length", str(len(request_body))) - - # Authorisation. - if user_passwd is not None: - auth = base64.encodestring(user_passwd).strip() - h.putheader('Authorization', 'Basic %s' % auth) - - h.endheaders() - - if request_body: - h.send(request_body) - - response = h.getresponse() - - if response.status != 200: - raise ProtocolError( - host + handler, - response.status, response.reason, - response.getheaders() - ) - - self.verbose = verbose - return self.parse_response(response) diff --git a/M2Crypto/six.py b/M2Crypto/six.py deleted file mode 100644 index 83f6978..0000000 --- a/M2Crypto/six.py +++ /dev/null @@ -1,982 +0,0 @@ -# Copyright (c) 2010-2020 Benjamin Peterson -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -"""Utilities for writing code that runs on Python 2 and 3""" - -from __future__ import absolute_import - -import functools -import itertools -import operator -import sys -import types - -__author__ = "Benjamin Peterson " -__version__ = "1.15.0" - - -# Useful for very coarse version differentiation. -PY2 = sys.version_info[0] == 2 -PY3 = sys.version_info[0] == 3 -PY34 = sys.version_info[0:2] >= (3, 4) - -if PY3: - string_types = str, - integer_types = int, - class_types = type, - text_type = str - binary_type = bytes - - MAXSIZE = sys.maxsize -else: - string_types = basestring, - integer_types = (int, long) - class_types = (type, types.ClassType) - text_type = unicode - binary_type = str - - if sys.platform.startswith("java"): - # Jython always uses 32 bits. - MAXSIZE = int((1 << 31) - 1) - else: - # It's possible to have sizeof(long) != sizeof(Py_ssize_t). - class X(object): - - def __len__(self): - return 1 << 31 - try: - len(X()) - except OverflowError: - # 32-bit - MAXSIZE = int((1 << 31) - 1) - else: - # 64-bit - MAXSIZE = int((1 << 63) - 1) - del X - - -def _add_doc(func, doc): - """Add documentation to a function.""" - func.__doc__ = doc - - -def _import_module(name): - """Import module, returning the module after the last dot.""" - __import__(name) - return sys.modules[name] - - -class _LazyDescr(object): - - def __init__(self, name): - self.name = name - - def __get__(self, obj, tp): - result = self._resolve() - setattr(obj, self.name, result) # Invokes __set__. - try: - # This is a bit ugly, but it avoids running this again by - # removing this descriptor. - delattr(obj.__class__, self.name) - except AttributeError: - pass - return result - - -class MovedModule(_LazyDescr): - - def __init__(self, name, old, new=None): - super(MovedModule, self).__init__(name) - if PY3: - if new is None: - new = name - self.mod = new - else: - self.mod = old - - def _resolve(self): - return _import_module(self.mod) - - def __getattr__(self, attr): - _module = self._resolve() - value = getattr(_module, attr) - setattr(self, attr, value) - return value - - -class _LazyModule(types.ModuleType): - - def __init__(self, name): - super(_LazyModule, self).__init__(name) - self.__doc__ = self.__class__.__doc__ - - def __dir__(self): - attrs = ["__doc__", "__name__"] - attrs += [attr.name for attr in self._moved_attributes] - return attrs - - # Subclasses should override this - _moved_attributes = [] - - -class MovedAttribute(_LazyDescr): - - def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): - super(MovedAttribute, self).__init__(name) - if PY3: - if new_mod is None: - new_mod = name - self.mod = new_mod - if new_attr is None: - if old_attr is None: - new_attr = name - else: - new_attr = old_attr - self.attr = new_attr - else: - self.mod = old_mod - if old_attr is None: - old_attr = name - self.attr = old_attr - - def _resolve(self): - module = _import_module(self.mod) - return getattr(module, self.attr) - - -class _SixMetaPathImporter(object): - - """ - A meta path importer to import six.moves and its submodules. - - This class implements a PEP302 finder and loader. It should be compatible - with Python 2.5 and all existing versions of Python3 - """ - - def __init__(self, six_module_name): - self.name = six_module_name - self.known_modules = {} - - def _add_module(self, mod, *fullnames): - for fullname in fullnames: - self.known_modules[self.name + "." + fullname] = mod - - def _get_module(self, fullname): - return self.known_modules[self.name + "." + fullname] - - def find_module(self, fullname, path=None): - if fullname in self.known_modules: - return self - return None - - def __get_module(self, fullname): - try: - return self.known_modules[fullname] - except KeyError: - raise ImportError("This loader does not know module " + fullname) - - def load_module(self, fullname): - try: - # in case of a reload - return sys.modules[fullname] - except KeyError: - pass - mod = self.__get_module(fullname) - if isinstance(mod, MovedModule): - mod = mod._resolve() - else: - mod.__loader__ = self - sys.modules[fullname] = mod - return mod - - def is_package(self, fullname): - """ - Return true, if the named module is a package. - - We need this method to get correct spec objects with - Python 3.4 (see PEP451) - """ - return hasattr(self.__get_module(fullname), "__path__") - - def get_code(self, fullname): - """Return None - - Required, if is_package is implemented""" - self.__get_module(fullname) # eventually raises ImportError - return None - get_source = get_code # same as get_code - -_importer = _SixMetaPathImporter(__name__) - - -class _MovedItems(_LazyModule): - - """Lazy loading of moved objects""" - __path__ = [] # mark as package - - -_moved_attributes = [ - MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), - MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), - MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), - MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), - MovedAttribute("intern", "__builtin__", "sys"), - MovedAttribute("map", "itertools", "builtins", "imap", "map"), - MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"), - MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"), - MovedAttribute("getoutput", "commands", "subprocess"), - MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"), - MovedAttribute("reduce", "__builtin__", "functools"), - MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), - MovedAttribute("StringIO", "StringIO", "io"), - MovedAttribute("UserDict", "UserDict", "collections"), - MovedAttribute("UserList", "UserList", "collections"), - MovedAttribute("UserString", "UserString", "collections"), - MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), - MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), - MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), - MovedModule("builtins", "__builtin__"), - MovedModule("configparser", "ConfigParser"), - MovedModule("collections_abc", "collections", "collections.abc" if sys.version_info >= (3, 3) else "collections"), - MovedModule("copyreg", "copy_reg"), - MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), - MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"), - MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread" if sys.version_info < (3, 9) else "_thread"), - MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), - MovedModule("http_cookies", "Cookie", "http.cookies"), - MovedModule("html_entities", "htmlentitydefs", "html.entities"), - MovedModule("html_parser", "HTMLParser", "html.parser"), - MovedModule("http_client", "httplib", "http.client"), - MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), - MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"), - MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), - MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"), - MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), - MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), - MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), - MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), - MovedModule("cPickle", "cPickle", "pickle"), - MovedModule("queue", "Queue"), - MovedModule("reprlib", "repr"), - MovedModule("socketserver", "SocketServer"), - MovedModule("_thread", "thread", "_thread"), - MovedModule("tkinter", "Tkinter"), - MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), - MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), - MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), - MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), - MovedModule("tkinter_tix", "Tix", "tkinter.tix"), - MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), - MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), - MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), - MovedModule("tkinter_colorchooser", "tkColorChooser", - "tkinter.colorchooser"), - MovedModule("tkinter_commondialog", "tkCommonDialog", - "tkinter.commondialog"), - MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), - MovedModule("tkinter_font", "tkFont", "tkinter.font"), - MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), - MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", - "tkinter.simpledialog"), - MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), - MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), - MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), - MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), - MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), - MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), -] -# Add windows specific modules. -if sys.platform == "win32": - _moved_attributes += [ - MovedModule("winreg", "_winreg"), - ] - -for attr in _moved_attributes: - setattr(_MovedItems, attr.name, attr) - if isinstance(attr, MovedModule): - _importer._add_module(attr, "moves." + attr.name) -del attr - -_MovedItems._moved_attributes = _moved_attributes - -moves = _MovedItems(__name__ + ".moves") -_importer._add_module(moves, "moves") - - -class Module_six_moves_urllib_parse(_LazyModule): - - """Lazy loading of moved objects in six.moves.urllib_parse""" - - -_urllib_parse_moved_attributes = [ - MovedAttribute("ParseResult", "urlparse", "urllib.parse"), - MovedAttribute("SplitResult", "urlparse", "urllib.parse"), - MovedAttribute("parse_qs", "urlparse", "urllib.parse"), - MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), - MovedAttribute("urldefrag", "urlparse", "urllib.parse"), - MovedAttribute("urljoin", "urlparse", "urllib.parse"), - MovedAttribute("urlparse", "urlparse", "urllib.parse"), - MovedAttribute("urlsplit", "urlparse", "urllib.parse"), - MovedAttribute("urlunparse", "urlparse", "urllib.parse"), - MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), - MovedAttribute("quote", "urllib", "urllib.parse"), - MovedAttribute("quote_plus", "urllib", "urllib.parse"), - MovedAttribute("unquote", "urllib", "urllib.parse"), - MovedAttribute("unquote_plus", "urllib", "urllib.parse"), - MovedAttribute("unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"), - MovedAttribute("urlencode", "urllib", "urllib.parse"), - MovedAttribute("splitquery", "urllib", "urllib.parse"), - MovedAttribute("splittag", "urllib", "urllib.parse"), - MovedAttribute("splituser", "urllib", "urllib.parse"), - MovedAttribute("splitvalue", "urllib", "urllib.parse"), - MovedAttribute("uses_fragment", "urlparse", "urllib.parse"), - MovedAttribute("uses_netloc", "urlparse", "urllib.parse"), - MovedAttribute("uses_params", "urlparse", "urllib.parse"), - MovedAttribute("uses_query", "urlparse", "urllib.parse"), - MovedAttribute("uses_relative", "urlparse", "urllib.parse"), -] -for attr in _urllib_parse_moved_attributes: - setattr(Module_six_moves_urllib_parse, attr.name, attr) -del attr - -Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes - -_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"), - "moves.urllib_parse", "moves.urllib.parse") - - -class Module_six_moves_urllib_error(_LazyModule): - - """Lazy loading of moved objects in six.moves.urllib_error""" - - -_urllib_error_moved_attributes = [ - MovedAttribute("URLError", "urllib2", "urllib.error"), - MovedAttribute("HTTPError", "urllib2", "urllib.error"), - MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), -] -for attr in _urllib_error_moved_attributes: - setattr(Module_six_moves_urllib_error, attr.name, attr) -del attr - -Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes - -_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"), - "moves.urllib_error", "moves.urllib.error") - - -class Module_six_moves_urllib_request(_LazyModule): - - """Lazy loading of moved objects in six.moves.urllib_request""" - - -_urllib_request_moved_attributes = [ - MovedAttribute("urlopen", "urllib2", "urllib.request"), - MovedAttribute("install_opener", "urllib2", "urllib.request"), - MovedAttribute("build_opener", "urllib2", "urllib.request"), - MovedAttribute("pathname2url", "urllib", "urllib.request"), - MovedAttribute("url2pathname", "urllib", "urllib.request"), - MovedAttribute("getproxies", "urllib", "urllib.request"), - MovedAttribute("Request", "urllib2", "urllib.request"), - MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), - MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), - MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), - MovedAttribute("BaseHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), - MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), - MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), - MovedAttribute("FileHandler", "urllib2", "urllib.request"), - MovedAttribute("FTPHandler", "urllib2", "urllib.request"), - MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), - MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), - MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), - MovedAttribute("urlretrieve", "urllib", "urllib.request"), - MovedAttribute("urlcleanup", "urllib", "urllib.request"), - MovedAttribute("URLopener", "urllib", "urllib.request"), - MovedAttribute("FancyURLopener", "urllib", "urllib.request"), - MovedAttribute("proxy_bypass", "urllib", "urllib.request"), - MovedAttribute("parse_http_list", "urllib2", "urllib.request"), - MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"), -] -for attr in _urllib_request_moved_attributes: - setattr(Module_six_moves_urllib_request, attr.name, attr) -del attr - -Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes - -_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"), - "moves.urllib_request", "moves.urllib.request") - - -class Module_six_moves_urllib_response(_LazyModule): - - """Lazy loading of moved objects in six.moves.urllib_response""" - - -_urllib_response_moved_attributes = [ - MovedAttribute("addbase", "urllib", "urllib.response"), - MovedAttribute("addclosehook", "urllib", "urllib.response"), - MovedAttribute("addinfo", "urllib", "urllib.response"), - MovedAttribute("addinfourl", "urllib", "urllib.response"), -] -for attr in _urllib_response_moved_attributes: - setattr(Module_six_moves_urllib_response, attr.name, attr) -del attr - -Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes - -_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"), - "moves.urllib_response", "moves.urllib.response") - - -class Module_six_moves_urllib_robotparser(_LazyModule): - - """Lazy loading of moved objects in six.moves.urllib_robotparser""" - - -_urllib_robotparser_moved_attributes = [ - MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), -] -for attr in _urllib_robotparser_moved_attributes: - setattr(Module_six_moves_urllib_robotparser, attr.name, attr) -del attr - -Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes - -_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"), - "moves.urllib_robotparser", "moves.urllib.robotparser") - - -class Module_six_moves_urllib(types.ModuleType): - - """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" - __path__ = [] # mark as package - parse = _importer._get_module("moves.urllib_parse") - error = _importer._get_module("moves.urllib_error") - request = _importer._get_module("moves.urllib_request") - response = _importer._get_module("moves.urllib_response") - robotparser = _importer._get_module("moves.urllib_robotparser") - - def __dir__(self): - return ['parse', 'error', 'request', 'response', 'robotparser'] - -_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"), - "moves.urllib") - - -def add_move(move): - """Add an item to six.moves.""" - setattr(_MovedItems, move.name, move) - - -def remove_move(name): - """Remove item from six.moves.""" - try: - delattr(_MovedItems, name) - except AttributeError: - try: - del moves.__dict__[name] - except KeyError: - raise AttributeError("no such move, %r" % (name,)) - - -if PY3: - _meth_func = "__func__" - _meth_self = "__self__" - - _func_closure = "__closure__" - _func_code = "__code__" - _func_defaults = "__defaults__" - _func_globals = "__globals__" -else: - _meth_func = "im_func" - _meth_self = "im_self" - - _func_closure = "func_closure" - _func_code = "func_code" - _func_defaults = "func_defaults" - _func_globals = "func_globals" - - -try: - advance_iterator = next -except NameError: - def advance_iterator(it): - return it.next() -next = advance_iterator - - -try: - callable = callable -except NameError: - def callable(obj): - return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) - - -if PY3: - def get_unbound_function(unbound): - return unbound - - create_bound_method = types.MethodType - - def create_unbound_method(func, cls): - return func - - Iterator = object -else: - def get_unbound_function(unbound): - return unbound.im_func - - def create_bound_method(func, obj): - return types.MethodType(func, obj, obj.__class__) - - def create_unbound_method(func, cls): - return types.MethodType(func, None, cls) - - class Iterator(object): - - def next(self): - return type(self).__next__(self) - - callable = callable -_add_doc(get_unbound_function, - """Get the function out of a possibly unbound function""") - - -get_method_function = operator.attrgetter(_meth_func) -get_method_self = operator.attrgetter(_meth_self) -get_function_closure = operator.attrgetter(_func_closure) -get_function_code = operator.attrgetter(_func_code) -get_function_defaults = operator.attrgetter(_func_defaults) -get_function_globals = operator.attrgetter(_func_globals) - - -if PY3: - def iterkeys(d, **kw): - return iter(d.keys(**kw)) - - def itervalues(d, **kw): - return iter(d.values(**kw)) - - def iteritems(d, **kw): - return iter(d.items(**kw)) - - def iterlists(d, **kw): - return iter(d.lists(**kw)) - - viewkeys = operator.methodcaller("keys") - - viewvalues = operator.methodcaller("values") - - viewitems = operator.methodcaller("items") -else: - def iterkeys(d, **kw): - return d.iterkeys(**kw) - - def itervalues(d, **kw): - return d.itervalues(**kw) - - def iteritems(d, **kw): - return d.iteritems(**kw) - - def iterlists(d, **kw): - return d.iterlists(**kw) - - viewkeys = operator.methodcaller("viewkeys") - - viewvalues = operator.methodcaller("viewvalues") - - viewitems = operator.methodcaller("viewitems") - -_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") -_add_doc(itervalues, "Return an iterator over the values of a dictionary.") -_add_doc(iteritems, - "Return an iterator over the (key, value) pairs of a dictionary.") -_add_doc(iterlists, - "Return an iterator over the (key, [values]) pairs of a dictionary.") - - -if PY3: - def b(s): - return s.encode("latin-1") - - def u(s): - return s - unichr = chr - import struct - int2byte = struct.Struct(">B").pack - del struct - byte2int = operator.itemgetter(0) - indexbytes = operator.getitem - iterbytes = iter - import io - StringIO = io.StringIO - BytesIO = io.BytesIO - del io - _assertCountEqual = "assertCountEqual" - if sys.version_info[1] <= 1: - _assertRaisesRegex = "assertRaisesRegexp" - _assertRegex = "assertRegexpMatches" - _assertNotRegex = "assertNotRegexpMatches" - else: - _assertRaisesRegex = "assertRaisesRegex" - _assertRegex = "assertRegex" - _assertNotRegex = "assertNotRegex" -else: - def b(s): - return s - # Workaround for standalone backslash - - def u(s): - return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") - unichr = unichr - int2byte = chr - - def byte2int(bs): - return ord(bs[0]) - - def indexbytes(buf, i): - return ord(buf[i]) - iterbytes = functools.partial(itertools.imap, ord) - import StringIO - StringIO = BytesIO = StringIO.StringIO - _assertCountEqual = "assertItemsEqual" - _assertRaisesRegex = "assertRaisesRegexp" - _assertRegex = "assertRegexpMatches" - _assertNotRegex = "assertNotRegexpMatches" -_add_doc(b, """Byte literal""") -_add_doc(u, """Text literal""") - - -def assertCountEqual(self, *args, **kwargs): - return getattr(self, _assertCountEqual)(*args, **kwargs) - - -def assertRaisesRegex(self, *args, **kwargs): - return getattr(self, _assertRaisesRegex)(*args, **kwargs) - - -def assertRegex(self, *args, **kwargs): - return getattr(self, _assertRegex)(*args, **kwargs) - - -def assertNotRegex(self, *args, **kwargs): - return getattr(self, _assertNotRegex)(*args, **kwargs) - - -if PY3: - exec_ = getattr(moves.builtins, "exec") - - def reraise(tp, value, tb=None): - try: - if value is None: - value = tp() - if value.__traceback__ is not tb: - raise value.with_traceback(tb) - raise value - finally: - value = None - tb = None - -else: - def exec_(_code_, _globs_=None, _locs_=None): - """Execute code in a namespace.""" - if _globs_ is None: - frame = sys._getframe(1) - _globs_ = frame.f_globals - if _locs_ is None: - _locs_ = frame.f_locals - del frame - elif _locs_ is None: - _locs_ = _globs_ - exec("""exec _code_ in _globs_, _locs_""") - - exec_("""def reraise(tp, value, tb=None): - try: - raise tp, value, tb - finally: - tb = None -""") - - -if sys.version_info[:2] > (3,): - exec_("""def raise_from(value, from_value): - try: - raise value from from_value - finally: - value = None -""") -else: - def raise_from(value, from_value): - raise value - - -print_ = getattr(moves.builtins, "print", None) -if print_ is None: - def print_(*args, **kwargs): - """The new-style print function for Python 2.4 and 2.5.""" - fp = kwargs.pop("file", sys.stdout) - if fp is None: - return - - def write(data): - if not isinstance(data, basestring): - data = str(data) - # If the file has an encoding, encode unicode with it. - if (isinstance(fp, file) and - isinstance(data, unicode) and - fp.encoding is not None): - errors = getattr(fp, "errors", None) - if errors is None: - errors = "strict" - data = data.encode(fp.encoding, errors) - fp.write(data) - want_unicode = False - sep = kwargs.pop("sep", None) - if sep is not None: - if isinstance(sep, unicode): - want_unicode = True - elif not isinstance(sep, str): - raise TypeError("sep must be None or a string") - end = kwargs.pop("end", None) - if end is not None: - if isinstance(end, unicode): - want_unicode = True - elif not isinstance(end, str): - raise TypeError("end must be None or a string") - if kwargs: - raise TypeError("invalid keyword arguments to print()") - if not want_unicode: - for arg in args: - if isinstance(arg, unicode): - want_unicode = True - break - if want_unicode: - newline = unicode("\n") - space = unicode(" ") - else: - newline = "\n" - space = " " - if sep is None: - sep = space - if end is None: - end = newline - for i, arg in enumerate(args): - if i: - write(sep) - write(arg) - write(end) -if sys.version_info[:2] < (3, 3): - _print = print_ - - def print_(*args, **kwargs): - fp = kwargs.get("file", sys.stdout) - flush = kwargs.pop("flush", False) - _print(*args, **kwargs) - if flush and fp is not None: - fp.flush() - -_add_doc(reraise, """Reraise an exception.""") - -if sys.version_info[0:2] < (3, 4): - # This does exactly the same what the :func:`py3:functools.update_wrapper` - # function does on Python versions after 3.2. It sets the ``__wrapped__`` - # attribute on ``wrapper`` object and it doesn't raise an error if any of - # the attributes mentioned in ``assigned`` and ``updated`` are missing on - # ``wrapped`` object. - def _update_wrapper(wrapper, wrapped, - assigned=functools.WRAPPER_ASSIGNMENTS, - updated=functools.WRAPPER_UPDATES): - for attr in assigned: - try: - value = getattr(wrapped, attr) - except AttributeError: - continue - else: - setattr(wrapper, attr, value) - for attr in updated: - getattr(wrapper, attr).update(getattr(wrapped, attr, {})) - wrapper.__wrapped__ = wrapped - return wrapper - _update_wrapper.__doc__ = functools.update_wrapper.__doc__ - - def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, - updated=functools.WRAPPER_UPDATES): - return functools.partial(_update_wrapper, wrapped=wrapped, - assigned=assigned, updated=updated) - wraps.__doc__ = functools.wraps.__doc__ - -else: - wraps = functools.wraps - - -def with_metaclass(meta, *bases): - """Create a base class with a metaclass.""" - # This requires a bit of explanation: the basic idea is to make a dummy - # metaclass for one level of class instantiation that replaces itself with - # the actual metaclass. - class metaclass(type): - - def __new__(cls, name, this_bases, d): - if sys.version_info[:2] >= (3, 7): - # This version introduced PEP 560 that requires a bit - # of extra care (we mimic what is done by __build_class__). - resolved_bases = types.resolve_bases(bases) - if resolved_bases is not bases: - d['__orig_bases__'] = bases - else: - resolved_bases = bases - return meta(name, resolved_bases, d) - - @classmethod - def __prepare__(cls, name, this_bases): - return meta.__prepare__(name, bases) - return type.__new__(metaclass, 'temporary_class', (), {}) - - -def add_metaclass(metaclass): - """Class decorator for creating a class with a metaclass.""" - def wrapper(cls): - orig_vars = cls.__dict__.copy() - slots = orig_vars.get('__slots__') - if slots is not None: - if isinstance(slots, str): - slots = [slots] - for slots_var in slots: - orig_vars.pop(slots_var) - orig_vars.pop('__dict__', None) - orig_vars.pop('__weakref__', None) - if hasattr(cls, '__qualname__'): - orig_vars['__qualname__'] = cls.__qualname__ - return metaclass(cls.__name__, cls.__bases__, orig_vars) - return wrapper - - -def ensure_binary(s, encoding='utf-8', errors='strict'): - """Coerce **s** to six.binary_type. - - For Python 2: - - `unicode` -> encoded to `str` - - `str` -> `str` - - For Python 3: - - `str` -> encoded to `bytes` - - `bytes` -> `bytes` - """ - if isinstance(s, binary_type): - return s - if isinstance(s, text_type): - return s.encode(encoding, errors) - raise TypeError("not expecting type '%s'" % type(s)) - - -def ensure_str(s, encoding='utf-8', errors='strict'): - """Coerce *s* to `str`. - - For Python 2: - - `unicode` -> encoded to `str` - - `str` -> `str` - - For Python 3: - - `str` -> `str` - - `bytes` -> decoded to `str` - """ - # Optimization: Fast return for the common case. - if type(s) is str: - return s - if PY2 and isinstance(s, text_type): - return s.encode(encoding, errors) - elif PY3 and isinstance(s, binary_type): - return s.decode(encoding, errors) - elif not isinstance(s, (text_type, binary_type)): - raise TypeError("not expecting type '%s'" % type(s)) - return s - - -def ensure_text(s, encoding='utf-8', errors='strict'): - """Coerce *s* to six.text_type. - - For Python 2: - - `unicode` -> `unicode` - - `str` -> `unicode` - - For Python 3: - - `str` -> `str` - - `bytes` -> decoded to `str` - """ - if isinstance(s, binary_type): - return s.decode(encoding, errors) - elif isinstance(s, text_type): - return s - else: - raise TypeError("not expecting type '%s'" % type(s)) - - -def python_2_unicode_compatible(klass): - """ - A class decorator that defines __unicode__ and __str__ methods under Python 2. - Under Python 3 it does nothing. - - To support Python 2 and 3 with a single code base, define a __str__ method - returning text and apply this decorator to the class. - """ - if PY2: - if '__str__' not in klass.__dict__: - raise ValueError("@python_2_unicode_compatible cannot be applied " - "to %s because it doesn't define __str__()." % - klass.__name__) - klass.__unicode__ = klass.__str__ - klass.__str__ = lambda self: self.__unicode__().encode('utf-8') - return klass - - -# Complete the moves implementation. -# This code is at the end of this module to speed up module loading. -# Turn this module into a package. -__path__ = [] # required for PEP 302 and PEP 451 -__package__ = __name__ # see PEP 366 @ReservedAssignment -if globals().get("__spec__") is not None: - __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable -# Remove other six meta path importers, since they cause problems. This can -# happen if six is removed from sys.modules and then reloaded. (Setuptools does -# this for some reason.) -if sys.meta_path: - for i, importer in enumerate(sys.meta_path): - # Here's some real nastiness: Another "instance" of the six module might - # be floating around. Therefore, we can't use isinstance() to check for - # the six meta path importer, since the other six instance will have - # inserted an importer with different class. - if (type(importer).__name__ == "_SixMetaPathImporter" and - importer.name == __name__): - del sys.meta_path[i] - break - del i, importer -# Finally, add the importer to the meta path import hook. -sys.meta_path.append(_importer) diff --git a/M2Crypto/threading.py b/M2Crypto/threading.py deleted file mode 100644 index f9f2683..0000000 --- a/M2Crypto/threading.py +++ /dev/null @@ -1,25 +0,0 @@ -from __future__ import absolute_import - -""" -M2Crypto threading support, required for multithreaded applications. - -Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" - -# M2Crypto -from M2Crypto import m2 - - -def init(): - # type: () -> None - """ - Initialize threading support. - """ - m2.threading_init() - - -def cleanup(): - # type: () -> None - """ - End and cleanup threading support. - """ - m2.threading_cleanup() diff --git a/M2Crypto/util.py b/M2Crypto/util.py deleted file mode 100644 index 97f5d29..0000000 --- a/M2Crypto/util.py +++ /dev/null @@ -1,89 +0,0 @@ -from __future__ import absolute_import -""" - M2Crypto utility routines. - - NOTHING IN THIS MODULE IS GUARANTEED TO BE STABLE, USED ONLY FOR - INTERNAL PURPOSES OF M2CRYPTO. - - Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - - Portions created by Open Source Applications Foundation (OSAF) are - Copyright (C) 2004 OSAF. All Rights Reserved. -""" - -import binascii -import logging -import sys - -from M2Crypto import m2, six -from typing import Any, Optional, TextIO, Tuple, Union # noqa -# see https://github.com/python/typeshed/issues/222 -AddrType = Union[Tuple[str, int], str] - -log = logging.getLogger('util') - - -class UtilError(Exception): - pass - - -m2.util_init(UtilError) - - -def pkcs5_pad(data, blklen=8): - # type: (str, int) -> str - pad = (8 - (len(data) % 8)) - return data + chr(pad) * pad - - -def pkcs7_pad(data, blklen): - # type: (str, int) -> str - if blklen > 255: - raise ValueError('illegal block size') - pad = (blklen - (len(data) % blklen)) - return data + chr(pad) * pad - - -def bin_to_hex(b): - # type: (bytes) -> str - return six.ensure_text(binascii.b2a_base64(b)[:-1]) - - -def octx_to_num(x): - # type: (bytes) -> int - return int(binascii.hexlify(x), 16) - - -def genparam_callback(p, n, out=sys.stdout): - # type: (int, Any, TextIO) -> None - ch = ['.', '+', '*', '\n'] - out.write(ch[p]) - out.flush() - - -def quiet_genparam_callback(p, n, out): - # type: (Any, Any, Any) -> None - pass - - -def passphrase_callback(v, prompt1='Enter passphrase:', - prompt2='Verify passphrase:'): - # type: (bool, str, str) -> Optional[str] - from getpass import getpass - while 1: - try: - p1 = getpass(prompt1) - if v: - p2 = getpass(prompt2) - if p1 == p2: - break - else: - break - except KeyboardInterrupt: - return None - return p1 - - -def no_passphrase_callback(*args): - # type: (*Any) -> str - return '' diff --git a/SWIG/Makefile b/SWIG/Makefile deleted file mode 100644 index 9a3bd56..0000000 --- a/SWIG/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# $Id$ - -CFLAGS = -DTHREADING -g -INCLUDE = -I/usr/local/include -I. -LIBS = -L/usr/local/lib -lssl -lcrypto -#if PYTHON_VERSION -PYVER = $(PYTHON_VERSION) -#else -PYVER = 2.3 -#endif -PYINCLUDE = -DHAVE_CONFIG_H -I/usr/local/include/python$(PYVER) \ - -I/usr/local/lib/python$(PYVER)/config -PYLIB = /usr/local/lib/python$(PYVER)/config - -all: _m2crypto - -_m2crypto: _m2crypto.i - swig -python -shadow _m2crypto.i - cc -c -fpic $(CFLAGS) $(INCLUDE) $(PYINCLUDE) _m2crypto_wrap.c - ld -Bshareable -o _m2crypto.so _m2crypto_wrap.o $(LIBS) - cp m2crypto.py _m2crypto.so ../M2Crypto - -clean: - rm -f *_wrap* *.o *.so _*.py *.pyc - diff --git a/SWIG/_aes.i b/SWIG/_aes.i deleted file mode 100644 index ea36167..0000000 --- a/SWIG/_aes.i +++ /dev/null @@ -1,90 +0,0 @@ -/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%{ -#include - -#if OPENSSL_VERSION_NUMBER >= 0x0090800fL -#include -#endif - -/* -// 2004-10-10, ngps: -// CTR mode is not included in the default OpenSSL build. -// To use the AES CTR ciphers, link with your own copy of OpenSSL. -*/ -#ifdef HAVE_AES_CTR -extern EVP_CIPHER const *EVP_aes_128_ctr(void); -extern EVP_CIPHER const *EVP_aes_192_ctr(void); -extern EVP_CIPHER const *EVP_aes_256_ctr(void); -#endif -%} - -%apply Pointer NONNULL { AES_KEY * }; - -%constant int AES_BLOCK_SIZE = AES_BLOCK_SIZE; - -%inline %{ -AES_KEY *aes_new(void) { - AES_KEY *key; - - if (!(key = (AES_KEY *)PyMem_Malloc(sizeof(AES_KEY)))) { - PyErr_SetString(PyExc_MemoryError, - "Insufficient memory for AES key."); - return NULL; - } - return key; -} - -void AES_free(AES_KEY *key) { - PyMem_Free((void *)key); -} - -/* -// op == 0: encrypt -// otherwise: decrypt (Python code will supply the value 1.) -*/ -PyObject *AES_set_key(AES_KEY *key, PyObject *value, int bits, int op) { - char *vbuf; - Py_ssize_t vlen; - - if (PyBytes_AsStringAndSize(value, &vbuf, &vlen) == -1) - return NULL; - - if (op == 0) - AES_set_encrypt_key((const unsigned char *)vbuf, bits, key); - else - AES_set_decrypt_key((const unsigned char *)vbuf, bits, key); - Py_RETURN_NONE; -} - -/* -// op == 0: encrypt -// otherwise: decrypt (Python code will supply the value 1.) -*/ -PyObject *AES_crypt(const AES_KEY *key, PyObject *in, int outlen, int op) { - char *buf; - Py_ssize_t len; - unsigned char *out; - PyObject *res; - - if (PyBytes_AsStringAndSize(in, &buf, &len) == -1) - return NULL; - - if (!(out=(unsigned char *)PyMem_Malloc(outlen))) { - PyErr_SetString(PyExc_MemoryError, "AES_crypt"); - return NULL; - } - if (op == 0) - AES_encrypt((const unsigned char *)buf, out, key); - else - AES_decrypt((const unsigned char *)buf, out, key); - res = PyBytes_FromStringAndSize((char*)out, outlen); - PyMem_Free(out); - return res; -} - -int AES_type_check(AES_KEY *key) { - return 1; -} -%} diff --git a/SWIG/_asn1.i b/SWIG/_asn1.i deleted file mode 100644 index b51b33f..0000000 --- a/SWIG/_asn1.i +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ -/* -** Portions created by Open Source Applications Foundation (OSAF) are -** Copyright (C) 2004 OSAF. All Rights Reserved. -*/ -/* $Id$ */ - -%{ -#include -%} - -%apply Pointer NONNULL { BIO * }; -%apply Pointer NONNULL { ASN1_OBJECT * }; -%apply Pointer NONNULL { ASN1_STRING * }; -%apply Pointer NONNULL { ASN1_INTEGER * }; -%apply Pointer NONNULL { ASN1_TIME * }; - -%rename(asn1_object_new) ASN1_OBJECT_new; -extern ASN1_OBJECT *ASN1_OBJECT_new( void ); -%rename(asn1_object_create) ASN1_OBJECT_create; -extern ASN1_OBJECT *ASN1_OBJECT_create( int, unsigned char *, int, const char *, const char *); -%rename(asn1_object_free) ASN1_OBJECT_free; -extern void ASN1_OBJECT_free( ASN1_OBJECT *); -%rename(i2d_asn1_object) i2d_ASN1_OBJECT; -extern int i2d_ASN1_OBJECT( ASN1_OBJECT *, unsigned char **); -%rename(d2i_asn1_object) d2i_ASN1_OBJECT; -extern ASN1_OBJECT *d2i_ASN1_OBJECT( ASN1_OBJECT **, const unsigned char **, long); - -%rename(asn1_bit_string_new) ASN1_BIT_STRING_new; -extern ASN1_BIT_STRING *ASN1_BIT_STRING_new( void ); - -%rename(asn1_string_new) ASN1_STRING_new; -extern ASN1_STRING *ASN1_STRING_new( void ); -%rename(asn1_string_free) ASN1_STRING_free; -extern void ASN1_STRING_free( ASN1_STRING *); - -%typemap(in) (const void *, int) { - if (PyBytes_Check($input)) { - Py_ssize_t len; - - $1 = PyBytes_AsString($input); - len = PyBytes_Size($input); - - if (len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "object too large"); - return NULL; - } - $2 = len; - } - else { - PyErr_SetString(PyExc_TypeError, "expected string"); - return NULL; - } -} - -%rename(asn1_string_set) ASN1_STRING_set; -extern int ASN1_STRING_set( ASN1_STRING *, const void *, int); - -%typemap(in) (const void *, int); - -%rename(asn1_string_print) ASN1_STRING_print; -%threadallow ASN1_STRING_print; -extern int ASN1_STRING_print(BIO *, ASN1_STRING *); -%threadallow ASN1_STRING_print_ex; -%rename(asn1_string_print_ex) ASN1_STRING_print_ex; -extern int ASN1_STRING_print_ex(BIO *, ASN1_STRING *, unsigned long); - -%rename(asn1_time_new) ASN1_TIME_new; -extern ASN1_TIME *ASN1_TIME_new( void ); -%rename(asn1_time_free) ASN1_TIME_free; -extern void ASN1_TIME_free(ASN1_TIME *); -%rename(asn1_time_check) ASN1_TIME_check; -extern int ASN1_TIME_check(ASN1_TIME *); -%rename(asn1_time_set) ASN1_TIME_set; -extern ASN1_TIME *ASN1_TIME_set(ASN1_TIME *, long); -%rename(asn1_time_set_string) ASN1_TIME_set_string; -extern int ASN1_TIME_set_string(ASN1_TIME *, const char *); -%rename(asn1_time_print) ASN1_TIME_print; -%threadallow ASN1_TIME_print; -extern int ASN1_TIME_print(BIO *, ASN1_TIME *); - -%rename(asn1_integer_new) ASN1_INTEGER_new; -extern ASN1_INTEGER *ASN1_INTEGER_new( void ); -%rename(asn1_integer_free) ASN1_INTEGER_free; -extern void ASN1_INTEGER_free( ASN1_INTEGER *); -%rename(asn1_integer_cmp) ASN1_INTEGER_cmp; -extern int ASN1_INTEGER_cmp(ASN1_INTEGER *, ASN1_INTEGER *); - -%constant int ASN1_STRFLGS_ESC_2253 = 1; -%constant int ASN1_STRFLGS_ESC_CTRL = 2; -%constant int ASN1_STRFLGS_ESC_MSB = 4; -%constant int ASN1_STRFLGS_ESC_QUOTE = 8; -%constant int ASN1_STRFLGS_UTF8_CONVERT = 0x10; -%constant int ASN1_STRFLGS_IGNORE_TYPE = 0x20; -%constant int ASN1_STRFLGS_SHOW_TYPE = 0x40; -%constant int ASN1_STRFLGS_DUMP_ALL = 0x80; -%constant int ASN1_STRFLGS_DUMP_UNKNOWN = 0x100; -%constant int ASN1_STRFLGS_DUMP_DER = 0x200; - -%constant int ASN1_STRFLGS_RFC2253 = (ASN1_STRFLGS_ESC_2253 | \ - ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - ASN1_STRFLGS_UTF8_CONVERT | \ - ASN1_STRFLGS_DUMP_UNKNOWN | \ - ASN1_STRFLGS_DUMP_DER); - -%inline %{ -/* ASN1_TIME_set_string () is a macro */ -int asn1_time_type_check(ASN1_TIME *ASN1_TIME) { - return 1; -} - -PyObject *asn1_integer_get(ASN1_INTEGER *asn1) { - BIGNUM *bn; - PyObject *ret; - char *hex; - - bn = ASN1_INTEGER_to_BN(asn1, NULL); - - if (!bn){ - m2_PyErr_Msg(PyExc_RuntimeError); - return NULL; - } - - hex = BN_bn2hex(bn); - - if (!hex){ - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return NULL; - } - - BN_free(bn); - - ret = PyLong_FromString(hex, NULL, 16); - - OPENSSL_free(hex); - - return ret; -} - -int asn1_integer_set(ASN1_INTEGER *asn1, PyObject *value) { - BIGNUM *bn = NULL; - PyObject *fmt, *args, *hex; - -/* Despite all hopes to the contrary, we cannot survive here with - * PyLong_AsLong shims as provided in - * /usr/include/python2.7/longobject.h. - */ - long val = PyLong_AsLong(value); - if (val >= 0) { - return ASN1_INTEGER_set(asn1, val); - } else { - PyErr_Clear(); - } - - if (!PyLong_Check(value)){ - PyErr_SetString(PyExc_TypeError, "expected int or long"); - return 0; - } - - fmt = PyUnicode_FromString("%x"); - - if (!fmt) - return 0; - - args = PyTuple_New(1); - - if (!args){ - Py_DECREF(fmt); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() failed"); - return 0; - } - - Py_INCREF(value); - PyTuple_SET_ITEM(args, 0, value); - hex = PyUnicode_Format(fmt, args); - - if (!hex){ - PyErr_SetString(PyExc_RuntimeError, "PyString_Format() failed"); - Py_DECREF(fmt); - Py_DECREF(args); - return 0; - } - - Py_DECREF(fmt); - Py_DECREF(args); - - if (BN_hex2bn(&bn, PyUnicode_AsUTF8(hex)) <= 0){ - m2_PyErr_Msg(PyExc_RuntimeError); - Py_DECREF(hex); - return 0; - } - - Py_DECREF(hex); - - if (!BN_to_ASN1_INTEGER(bn, asn1)){ - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return 0; - } - - BN_free(bn); - - return 1; -} - -%} diff --git a/SWIG/_bio.i b/SWIG/_bio.i deleted file mode 100644 index 84b76b3..0000000 --- a/SWIG/_bio.i +++ /dev/null @@ -1,545 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. - * - * Portions created by Open Source Applications Foundation (OSAF) are - * Copyright (C) 2004-2005 OSAF. All Rights Reserved. - * Author: Heikki Toivonen - * - * Copyright 2018 Daniel Wozniak. All Rights Reserved.*/ -/* $Id$ */ - -%{ -#include -%} - -%apply Pointer NONNULL { BIO * }; -%apply Pointer NONNULL { BIO_METHOD * }; - -%rename(bio_s_bio) BIO_s_bio; -extern BIO_METHOD *BIO_s_bio(void); -%rename(bio_s_mem) BIO_s_mem; -extern BIO_METHOD *BIO_s_mem(void); -%rename(bio_s_socket) BIO_s_socket; -extern BIO_METHOD *BIO_s_socket(void); -%rename(bio_f_ssl) BIO_f_ssl; -extern BIO_METHOD *BIO_f_ssl(void); -%rename(bio_f_buffer) BIO_f_buffer; -extern BIO_METHOD *BIO_f_buffer(void); -%rename(bio_f_cipher) BIO_f_cipher; -extern BIO_METHOD *BIO_f_cipher(void); - -%rename(bio_new) BIO_new; -extern BIO *BIO_new(BIO_METHOD *); -%rename(bio_new_socket) BIO_new_socket; -extern BIO *BIO_new_socket(int, int); -%rename(bio_new_fd) BIO_new_pyfd; -%rename(bio_new_pyfd) BIO_new_pyfd; -%rename(bio_free_all) BIO_free_all; -%threadallow BIO_free_all; -extern void BIO_free_all(BIO *); -%rename(bio_dup_chain) BIO_dup_chain; -extern BIO *BIO_dup_chain(BIO *); - -%rename(bio_push) BIO_push; -extern BIO *BIO_push(BIO *, BIO *); -%rename(bio_pop) BIO_pop; -extern BIO *BIO_pop(BIO *); - -%rename(bio_eof) BIO_eof; -extern int BIO_eof(BIO *); - -%constant int bio_noclose = BIO_NOCLOSE; -%constant int bio_close = BIO_CLOSE; -%constant int BIO_FLAGS_READ = 0x01; -%constant int BIO_FLAGS_WRITE = 0x02; -%constant int BIO_FLAGS_IO_SPECIAL = 0x04; -%constant int BIO_FLAGS_RWS = (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL); -%constant int BIO_FLAGS_SHOULD_RETRY = 0x08; -%constant int BIO_FLAGS_MEM_RDONLY = 0x200; - -%warnfilter(454) _bio_err; -%inline %{ -static PyObject *_bio_err; - - -void pyfd_init(void); - -void bio_init(PyObject *bio_err) { - Py_INCREF(bio_err); - _bio_err = bio_err; - pyfd_init(); -} - -int bio_free(BIO *bio) { - int ret; - - Py_BEGIN_ALLOW_THREADS - ret = BIO_free(bio); - Py_END_ALLOW_THREADS - if (ret == 0) { - m2_PyErr_Msg(_bio_err); - } - return ret; -} - -BIO * bio_new_file(const char *filename, const char *mode) { - BIO *ret; - - Py_BEGIN_ALLOW_THREADS - ret = BIO_new_file(filename, mode); - Py_END_ALLOW_THREADS - - if (ret == NULL) { - m2_PyErr_Msg(_bio_err); - } - - return ret; -} - -BIO *bio_new_pyfile(PyObject *pyfile, int bio_close) { - FILE *fp = NULL; - BIO *bio = NULL; - - fp = PyFile_AsFile(pyfile); - - bio = BIO_new_fp(fp, bio_close); - - /* returns NULL if error occurred */ - if (bio == NULL) { - /* Find out the name of the file so we can have good error - * message. */ - PyObject *pyname = m2_PyFile_Name(pyfile); - char *name = PyBytes_AsString(pyname); - - if (name == NULL) { - PyErr_Format(_bio_err, - "Opening of the new BIO on file failed!"); - } - else { - PyErr_Format(_bio_err, - "Opening of the new BIO on file %s failed!", name); - } - Py_DECREF(pyname); - } - return bio; -} - -PyObject *bio_read(BIO *bio, int num) { - PyObject *blob; - void *buf; - int r; - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "bio_read"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - r = BIO_read(bio, buf, num); - Py_END_ALLOW_THREADS - if (r < 0) { - PyMem_Free(buf); - if (ERR_peek_error()) { - m2_PyErr_Msg(_bio_err); - return NULL; - } - Py_RETURN_NONE; - } - - blob = PyBytes_FromStringAndSize(buf, r); - - PyMem_Free(buf); - return blob; -} - -PyObject *bio_gets(BIO *bio, int num) { - PyObject *blob; - void *buf; - int r; - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "bio_gets"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - r = BIO_gets(bio, buf, num); - Py_END_ALLOW_THREADS - if (r < 1) { - PyMem_Free(buf); - if (ERR_peek_error()) { - m2_PyErr_Msg(_bio_err); - return NULL; - } - Py_RETURN_NONE; - } - - blob = PyBytes_FromStringAndSize(buf, r); - - PyMem_Free(buf); - return blob; -} - -int bio_write(BIO *bio, PyObject *from) { - const void *fbuf; - int flen = 0, ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return -1; - - Py_BEGIN_ALLOW_THREADS - ret = BIO_write(bio, fbuf, flen); - Py_END_ALLOW_THREADS - if (ret < 0) { - if (ERR_peek_error()) { - m2_PyErr_Msg(_bio_err); - return -1; - } - } - return ret; -} - -/* XXX Casting size_t to int. */ -int bio_ctrl_pending(BIO *bio) { - return (int)BIO_ctrl_pending(bio); -} - -int bio_ctrl_wpending(BIO *bio) { - return (int)BIO_ctrl_wpending(bio); -} - -int bio_ctrl_get_write_guarantee(BIO *a) { - return BIO_ctrl_get_write_guarantee(a); -} - -int bio_reset(BIO *bio) { - return (int)BIO_reset(bio); -} -%} - -%threadallow bio_flush; -%inline %{ -int bio_flush(BIO *bio) { - return (int)BIO_flush(bio); -} - -int bio_seek(BIO *bio, int offset) { - return (int)BIO_seek(bio, offset); -} - -int bio_tell(BIO* bio) { - return BIO_tell(bio); -} - -void bio_set_flags(BIO *bio, int flags) { - BIO_set_flags(bio, flags); -} - -int bio_get_flags(BIO *bio) { - return BIO_get_flags(bio); -} - -/* - * sets the cipher of BIO @param b to c using key @param key and IV @iv. - * @param enc should be set to 1 for encryption and zero to decryption. - * - */ -PyObject *bio_set_cipher(BIO *b, EVP_CIPHER *c, PyObject *key, PyObject *iv, int op) { - const void *kbuf, *ibuf; - Py_ssize_t klen, ilen; - - if ((PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) - || (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1)) - return NULL; - - BIO_set_cipher(b, (const EVP_CIPHER *)c, - (unsigned char *)kbuf, (unsigned char *)ibuf, op); - Py_RETURN_NONE; -} - -int bio_set_mem_eof_return(BIO *b, int v) { - return (int)BIO_set_mem_eof_return(b, v); -} - -int bio_get_fd(BIO *bio) { - return BIO_get_fd(bio, NULL); -} -%} - -%warnfilter(454) methods_fdp; -%threadallow bio_do_handshake; -%inline %{ -int bio_do_handshake(BIO *bio) { - return BIO_do_handshake(bio); -} - -/* macro */ -int bio_make_bio_pair(BIO* b1, BIO* b2) { - return BIO_make_bio_pair(b1, b2); -} - -int bio_set_write_buf_size(BIO* b, size_t size) { - return BIO_set_write_buf_size(b, size); -} - -int bio_should_retry(BIO* a) { - return BIO_should_retry(a); -} - -int bio_should_read(BIO* a) { - return BIO_should_read(a); -} - -int bio_should_write(BIO* a) { - return BIO_should_write(a); -} - -/* Macros for things not defined before 1.1.0 */ -#if OPENSSL_VERSION_NUMBER < 0x10100000L -static BIO_METHOD * -BIO_meth_new( int type, const char *name ) -{ - BIO_METHOD *method = malloc( sizeof(BIO_METHOD) ); - memset( method, 0, sizeof(BIO_METHOD) ); - - method->type = type; - method->name = name; - - return method; -} - -static void -BIO_meth_free( BIO_METHOD *meth ) -{ - if ( meth == NULL ) { - return; - } - - free(meth); -} -#define BIO_meth_set_write(m, f) (m)->bwrite = (f) -#define BIO_meth_set_read(m, f) (m)->bread = (f) -#define BIO_meth_set_puts(m, f) (m)->bputs = (f) -#define BIO_meth_set_gets(m, f) (m)->bgets = (f) -#define BIO_meth_set_ctrl(m, f) (m)->ctrl = (f) -#define BIO_meth_set_create(m, f) (m)->create = (f) -#define BIO_meth_set_destroy(m, f) (m)->destroy = (f) -#define BIO_set_shutdown(b, x) (b)->shutdown = x -#define BIO_get_shutdown(b) (b)->shutdown -#define BIO_set_init(b, x) b->init = x -#define BIO_get_init(b) (b)->init -#define BIO_set_data(b, x) b->ptr = x -#define BIO_clear_flags(b, x) b->flags &= ~(x) -#define BIO_get_data(b) b->ptr -#endif - -/* implment custom BIO_s_pyfd */ - -#ifdef _WIN32 -# define clear_sys_error() SetLastError(0) -/* Linux doesn't use underscored calls yet */ -# define open(p, f, m) _open(p, f, m) -# define read(f, b, n) _read(f, b, n) -# define write(f, b, n) _write(f, b, n) -# define close(f) _close(f) -# define lseek(fd, o, w) _lseek(fd, o, w) -#else -# define clear_sys_error() errno=0 -#endif - -typedef struct pyfd_struct { - int fd; -} BIO_PYFD_CTX; - -/* Setting up methods_fdp */ -static BIO_METHOD *methods_fdp; - -static int pyfd_write(BIO *b, const char *in, int inl) { - int ret, fd; - - if (BIO_get_fd(b, &fd) == -1) { - PyErr_SetString(_bio_err, "BIO has not been initialized."); - return -1; - } - clear_sys_error(); - ret = write(fd, in, inl); - BIO_clear_retry_flags(b); - if (ret <= 0) { - if (BIO_fd_should_retry(ret)) - BIO_set_retry_write(b); - } - return ret; -} - -static int pyfd_read(BIO *b, char *out, int outl) { - int ret = 0, fd; - - if (BIO_get_fd(b, &fd) == -1) { - PyErr_SetString(_bio_err, "BIO has not been initialized."); - return -1; - } - if (out != NULL) { - clear_sys_error(); - ret = read(fd, out, outl); - BIO_clear_retry_flags(b); - if (ret <= 0) { - if (BIO_fd_should_retry(ret)) - BIO_set_retry_read(b); - } - } - return ret; -} - -static int pyfd_puts(BIO *bp, const char *str) { - int n, ret; - - n = strlen(str); - ret = pyfd_write(bp, str, n); - return ret; -} - -static int pyfd_gets(BIO *bp, char *buf, int size) { - int ret = 0; - char *ptr = buf; - char *end = buf + size - 1; - - /* See - https://github.com/openssl/openssl/pull/3442 - We were here just repeating a bug from OpenSSL - */ - while (ptr < end && pyfd_read(bp, ptr, 1) > 0) { - if (*ptr++ == '\n') - break; - } - - ptr[0] = '\0'; - - if (buf[0] != '\0') - ret = strlen(buf); - return ret; -} - -static int pyfd_new(BIO* b) { - BIO_PYFD_CTX* ctx; - - ctx = OPENSSL_zalloc(sizeof(*ctx)); - if (ctx == NULL) - return 0; - - ctx->fd = -1; - - BIO_set_data(b, ctx); - BIO_set_shutdown(b, 0); - BIO_set_init(b, 1); - - return 1; - } - -static int pyfd_free(BIO* b) { - BIO_PYFD_CTX* ctx; - - if (b == 0) - return 0; - - ctx = BIO_get_data(b); - if (ctx == NULL) - return 0; - - if (BIO_get_shutdown(b) && BIO_get_init(b)) - close(ctx->fd); - - BIO_set_data(b, NULL); - BIO_set_shutdown(b, 0); - BIO_set_init(b, 0); - - OPENSSL_free(ctx); - - return 1; -} - -static long pyfd_ctrl(BIO *b, int cmd, long num, void *ptr) { - BIO_PYFD_CTX* ctx; - int *ip; - long ret = 1; - - ctx = BIO_get_data(b); - if (ctx == NULL) - return 0; - - switch (cmd) { - case BIO_CTRL_RESET: - num = 0; - case BIO_C_FILE_SEEK: - ret = (long)lseek(ctx->fd, num, 0); - break; - case BIO_C_FILE_TELL: - case BIO_CTRL_INFO: - ret = (long)lseek(ctx->fd, 0, 1); - break; - case BIO_C_SET_FD: - pyfd_free(b); - if (*((int *)ptr) > -1) { - if (!pyfd_new(b) || !(ctx = BIO_get_data(b))) - return 0; - ctx->fd = *((int *)ptr); - BIO_set_shutdown(b, (int)num); - BIO_set_init(b, 1); - } - break; - case BIO_C_GET_FD: - if (BIO_get_init(b)) { - ip = (int *)ptr; - if (ip != NULL) - *ip = ctx->fd; - ret = ctx->fd; - } else - ret = -1; - break; - case BIO_CTRL_GET_CLOSE: - ret = BIO_get_shutdown(b); - break; - case BIO_CTRL_SET_CLOSE: - BIO_set_shutdown(b, (int)num); - break; - case BIO_CTRL_PENDING: - case BIO_CTRL_WPENDING: - ret = 0; - break; - case BIO_CTRL_DUP: - case BIO_CTRL_FLUSH: - ret = 1; - break; - default: - ret = 0; - break; - } - return ret; -} - -void pyfd_init(void) { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - methods_fdp = BIO_meth_new( - BIO_get_new_index()|BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, - "python file descriptor"); -#else - methods_fdp = BIO_meth_new( - 100 |BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, - "python file descriptor"); -#endif - - BIO_meth_set_write(methods_fdp, pyfd_write); - BIO_meth_set_read(methods_fdp, pyfd_read); - BIO_meth_set_puts(methods_fdp, pyfd_puts); - BIO_meth_set_gets(methods_fdp, pyfd_gets); - BIO_meth_set_ctrl(methods_fdp, pyfd_ctrl); - BIO_meth_set_create(methods_fdp, pyfd_new); - BIO_meth_set_destroy(methods_fdp, pyfd_free); -} - -BIO* BIO_new_pyfd(int fd, int close_flag) { - BIO *ret; - - ret = BIO_new(methods_fdp); - BIO_set_fd(ret, fd, close_flag); - return ret; - } -%} - diff --git a/SWIG/_bn.i b/SWIG/_bn.i deleted file mode 100644 index 18dc154..0000000 --- a/SWIG/_bn.i +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 2005-2006 Open Source Applications Foundation. All rights reserved. */ - -/* We are converting between the Python arbitrarily long integer and - * the BIGNUM arbitrarily long integer by converting to and from - * a string representation of the number (in hexadecimal). - * Direct manipulation would be a possibility, but would require - * tighter integration with the Python and OpenSSL internals. - */ - - -%{ -#include -%} - - -%inline %{ -PyObject *bn_rand(int bits, int top, int bottom) -{ - BIGNUM* rnd; - PyObject *ret; - char *randhex; - - rnd = BN_new(); - if (rnd == NULL) { - m2_PyErr_Msg(PyExc_Exception); - return NULL; - } - - if (!BN_rand(rnd, bits, top, bottom)) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - return NULL; - } - - randhex = BN_bn2hex(rnd); - if (!randhex) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - return NULL; - } - BN_free(rnd); - - ret = PyLong_FromString(randhex, NULL, 16); - OPENSSL_free(randhex); - return ret; -} - - -PyObject *bn_rand_range(PyObject *range) -{ - BIGNUM* rnd; - BIGNUM *rng = NULL; - PyObject *ret, *tuple; - PyObject *format, *rangePyString; - char *randhex; /* PyLong_FromString is unhappy with const */ - const char *rangehex; - - /* Wow, it's a lot of work to convert into a hex string in C! */ - format = PyUnicode_FromString("%x"); - - if (!format) { - PyErr_SetString(PyExc_RuntimeError, "Cannot create Python string '%x'"); - return NULL; - } - tuple = PyTuple_New(1); - if (!tuple) { - Py_DECREF(format); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - Py_INCREF(range); - PyTuple_SET_ITEM(tuple, 0, range); - - rangePyString = PyUnicode_Format(format, tuple); - - if (!rangePyString) { - PyErr_SetString(PyExc_Exception, "String Format failed"); - Py_DECREF(format); - Py_DECREF(tuple); - return NULL; - } - Py_DECREF(format); - Py_DECREF(tuple); - - rangehex = (const char*)PyUnicode_AsUTF8(rangePyString); - - if (!BN_hex2bn(&rng, rangehex)) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - Py_DECREF(rangePyString); - return NULL; - } - - Py_DECREF(rangePyString); - - if (!(rnd = BN_new())) { - PyErr_SetString(PyExc_MemoryError, "bn_rand_range"); - return NULL; - } - - if (!BN_rand_range(rnd, rng)) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - BN_free(rng); - return NULL; - } - - BN_free(rng); - - randhex = BN_bn2hex(rnd); - if (!randhex) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - return NULL; - } - BN_free(rnd); - - ret = PyLong_FromString(randhex, NULL, 16); - OPENSSL_free(randhex); - return ret; -} - -%} diff --git a/SWIG/_dh.i b/SWIG/_dh.i deleted file mode 100644 index 398f418..0000000 --- a/SWIG/_dh.i +++ /dev/null @@ -1,186 +0,0 @@ -/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%{ -#include -#include -#include -#include -#include -%} - -%apply Pointer NONNULL { DH * }; - -%rename(dh_new) DH_new; -extern DH *DH_new(void); -%rename(dh_free) DH_free; -extern void DH_free(DH *); -%rename(dh_size) DH_size; -extern int DH_size(const DH *); -%rename(dh_generate_key) DH_generate_key; -extern int DH_generate_key(DH *); -%rename(dhparams_print) DHparams_print; -%threadallow DHparams_print; -extern int DHparams_print(BIO *, const DH *); - -%constant int dh_check_ok = 0; -%constant int dh_check_p_not_prime = DH_CHECK_P_NOT_PRIME; -%constant int dh_check_p_not_strong = DH_CHECK_P_NOT_STRONG_PRIME; -%constant int dh_check_g_failed = DH_UNABLE_TO_CHECK_GENERATOR; -%constant int dh_check_bad_g = DH_NOT_SUITABLE_GENERATOR; - -%constant DH_GENERATOR_2 = 2; -%constant DH_GENERATOR_5 = 5; - -%warnfilter(454) _dh_err; -%inline %{ -static PyObject *_dh_err; - -void dh_init(PyObject *dh_err) { - Py_INCREF(dh_err); - _dh_err = dh_err; -} - -int dh_type_check(DH *dh) { - /* Our getting here means we passed Swig's type checking, - XXX Still need to check the pointer for sanity? */ - return 1; -} -%} - -%threadallow dh_read_parameters; -%inline %{ -DH *dh_read_parameters(BIO *bio) { - return PEM_read_bio_DHparams(bio, NULL, NULL, NULL); -} - -DH *dh_generate_parameters(int plen, int g, PyObject *pyfunc) { - DH *dh; - BN_GENCB *gencb; - int ret; - - if ((gencb=BN_GENCB_new()) == NULL) { - m2_PyErr_Msg(_dh_err); - return NULL; - } - - if ((dh=DH_new()) == NULL) { - m2_PyErr_Msg(_dh_err); - BN_GENCB_free(gencb); - return NULL; - } - - BN_GENCB_set(gencb, bn_gencb_callback, (void *)pyfunc); - - Py_INCREF(pyfunc); - ret = DH_generate_parameters_ex(dh, plen, g, gencb); - Py_DECREF(pyfunc); - BN_GENCB_free(gencb); - - if (ret) - return dh; - - m2_PyErr_Msg(_dh_err); - DH_free(dh); - return NULL; -} - -/* Note return value shenanigan. */ -int dh_check(DH *dh) { - int err; - - return (DH_check(dh, &err)) ? 0 : err; -} - -PyObject *dh_compute_key(DH *dh, PyObject *pubkey) { - const void *pkbuf; - int pklen = 0, klen; - void *key; - BIGNUM *pk; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(pubkey, &pkbuf, &pklen) == -1) - return NULL; - - if (!(pk = BN_mpi2bn((unsigned char *)pkbuf, pklen, NULL))) { - m2_PyErr_Msg(_dh_err); - return NULL; - } - if (!(key = PyMem_Malloc(DH_size(dh)))) { - BN_free(pk); - PyErr_SetString(PyExc_MemoryError, "dh_compute_key"); - return NULL; - } - if ((klen = DH_compute_key((unsigned char *)key, pk, dh)) == -1) { - BN_free(pk); - PyMem_Free(key); - m2_PyErr_Msg(_dh_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)key, klen); - - BN_free(pk); - PyMem_Free(key); - return ret; -} - -PyObject *dh_get_p(DH *dh) { - const BIGNUM* p = NULL; - DH_get0_pqg(dh, &p, NULL, NULL); - if (!p) { - PyErr_SetString(_dh_err, "'p' is unset"); - return NULL; - } - return bn_to_mpi(p); -} - -PyObject *dh_get_g(DH *dh) { - const BIGNUM* g = NULL; - DH_get0_pqg(dh, NULL, NULL, &g); - if (!g) { - PyErr_SetString(_dh_err, "'g' is unset"); - return NULL; - } - return bn_to_mpi(g); -} - -PyObject *dh_get_pub(DH *dh) { - const BIGNUM* pub_key = NULL; - DH_get0_key(dh, &pub_key, NULL); - if (!pub_key) { - PyErr_SetString(_dh_err, "'pub' is unset"); - return NULL; - } - return bn_to_mpi(pub_key); -} - -PyObject *dh_get_priv(DH *dh) { - const BIGNUM* priv_key = NULL; - DH_get0_key(dh, NULL, &priv_key); - if (!priv_key) { - PyErr_SetString(_dh_err, "'priv' is unset"); - return NULL; - } - return bn_to_mpi(priv_key); -} - -PyObject *dh_set_pg(DH *dh, PyObject *pval, PyObject* gval) { - BIGNUM* p, *g; - - if (!(p = m2_PyObject_AsBIGNUM(pval, _dh_err)) - || !(g = m2_PyObject_AsBIGNUM(gval, _dh_err))) - return NULL; - - if (!DH_set0_pqg(dh, p, NULL, g)) { - PyErr_SetString(_dh_err, - "Cannot set prime number or generator of Z_p for DH."); - BN_free(p); - BN_free(g); - return NULL; - } - - Py_RETURN_NONE; -} -%} - diff --git a/SWIG/_dsa.i b/SWIG/_dsa.i deleted file mode 100644 index 2c15c4f..0000000 --- a/SWIG/_dsa.i +++ /dev/null @@ -1,400 +0,0 @@ -/* Copyright (c) 1999-2000 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%{ -#include -#include -#include -#include - -PyObject *dsa_sig_get_r(DSA_SIG *dsa_sig) { - const BIGNUM* pr; - DSA_SIG_get0(dsa_sig, &pr, NULL); - return bn_to_mpi(pr); -} - -PyObject *dsa_sig_get_s(DSA_SIG *dsa_sig) { - const BIGNUM* qs; - DSA_SIG_get0(dsa_sig, NULL, &qs); - return bn_to_mpi(qs); -} -%} - -%apply Pointer NONNULL { DSA * }; - -%rename(dsa_new) DSA_new; -extern DSA *DSA_new(void); -%rename(dsa_free) DSA_free; -extern void DSA_free(DSA *); -%rename(dsa_size) DSA_size; -extern int DSA_size(const DSA *); /* assert(dsa->q); */ -%rename(dsa_gen_key) DSA_generate_key; -extern int DSA_generate_key(DSA *); - -%warnfilter(454) _dsa_err; -%inline %{ -static PyObject *_dsa_err; - -void dsa_init(PyObject *dsa_err) { - Py_INCREF(dsa_err); - _dsa_err = dsa_err; -} -%} - -%typemap(out) DSA * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - $result = NULL; - } -} -%inline %{ -DSA *dsa_generate_parameters(int bits, PyObject *pyfunc) { - DSA *dsa; - BN_GENCB *gencb; - int ret; - - if ((gencb=BN_GENCB_new()) == NULL) { - m2_PyErr_Msg(_dh_err); - return NULL; - } - - if ((dsa = DSA_new()) == NULL) { - m2_PyErr_Msg(_dsa_err); - BN_GENCB_free(gencb); - return NULL; - } - - BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); - - Py_INCREF(pyfunc); - ret = DSA_generate_parameters_ex(dsa, bits, NULL, 0, NULL, NULL, - gencb); - Py_DECREF(pyfunc); - BN_GENCB_free(gencb); - - if (ret) - return dsa; - - m2_PyErr_Msg(_dsa_err); - DSA_free(dsa); - return NULL; -} - -DSA *dsa_read_params(BIO *f, PyObject *pyfunc) { - DSA *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_DSAparams(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (ret == NULL) { - m2_PyErr_Msg(_dsa_err); - } - - return ret; -} - -DSA *dsa_read_key(BIO *f, PyObject *pyfunc) { - DSA *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_DSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (ret == NULL) { - m2_PyErr_Msg(_dsa_err); - } - - return ret; -} - -DSA *dsa_read_pub_key(BIO *f, PyObject *pyfunc) { - DSA *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_DSA_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (ret == NULL) { - m2_PyErr_Msg(_dsa_err); - } - - return ret; -} -%} -%typemap(out) DSA * ; - -%inline %{ -PyObject *dsa_get_p(DSA *dsa) { - const BIGNUM* p = NULL; - DSA_get0_pqg(dsa, &p, NULL, NULL); - if (!p) { - PyErr_SetString(_dsa_err, "'p' is unset"); - return NULL; - } - return bn_to_mpi(p); -} - -PyObject *dsa_get_q(DSA *dsa) { - const BIGNUM* q = NULL; - DSA_get0_pqg(dsa, NULL, &q, NULL); - if (!q) { - PyErr_SetString(_dsa_err, "'q' is unset"); - return NULL; - } - return bn_to_mpi(q); -} - -PyObject *dsa_get_g(DSA *dsa) { - const BIGNUM* g = NULL; - DSA_get0_pqg(dsa, NULL, NULL, &g); - if (!g) { - PyErr_SetString(_dsa_err, "'g' is unset"); - return NULL; - } - return bn_to_mpi(g); -} - -PyObject *dsa_get_pub(DSA *dsa) { - const BIGNUM* pub_key = NULL; - DSA_get0_key(dsa, &pub_key, NULL); - if (!pub_key) { - PyErr_SetString(_dsa_err, "'pub' is unset"); - return NULL; - } - return bn_to_mpi(pub_key); -} - -PyObject *dsa_get_priv(DSA *dsa) { - const BIGNUM* priv_key = NULL; - DSA_get0_key(dsa, NULL, &priv_key); - if (!priv_key) { - PyErr_SetString(_dsa_err, "'priv' is unset"); - return NULL; - } - return bn_to_mpi(priv_key); -} - -PyObject *dsa_set_pqg(DSA *dsa, PyObject *pval, PyObject* qval, PyObject* gval) { - BIGNUM* p, *q, *g; - - if (!(p = m2_PyObject_AsBIGNUM(pval, _dsa_err)) - || !(q = m2_PyObject_AsBIGNUM(qval, _dsa_err)) - || !(g = m2_PyObject_AsBIGNUM(gval, _dsa_err))) - return NULL; - - if (!DSA_set0_pqg(dsa, p, q, g)) { - PyErr_SetString( - _dsa_err, - "Cannot set prime number, subprime, or generator of subgroup for DSA."); - BN_free(p); - BN_free(q); - BN_free(g); - return NULL; - } - - Py_RETURN_NONE; - } - -PyObject *dsa_set_pub(DSA *dsa, PyObject *value) { - BIGNUM *bn; - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { - m2_PyErr_Msg(_dsa_err); - return NULL; - } - if (!DSA_set0_key(dsa, bn, NULL)) { - BN_free(bn); - PyErr_SetString(_dsa_err, "Cannot set private and public key for DSA."); - } - Py_RETURN_NONE; -} -%} - -%threadallow dsa_write_params_bio; -%inline %{ -int dsa_write_params_bio(DSA* dsa, BIO* f) { - return PEM_write_bio_DSAparams(f, dsa); -} -%} - -%inline %{ -int dsa_write_key_bio(DSA* dsa, BIO* f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_DSAPrivateKey(f, dsa, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%inline %{ -int dsa_write_key_bio_no_cipher(DSA* dsa, BIO* f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_DSAPrivateKey(f, dsa, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%threadallow dsa_write_pub_key_bio; -%inline %{ -int dsa_write_pub_key_bio(DSA* dsa, BIO* f) { - return PEM_write_bio_DSA_PUBKEY(f, dsa); -} -%} - -%inline %{ -PyObject *dsa_sign(DSA *dsa, PyObject *value) { - const void *vbuf; - int vlen = 0; - PyObject *tuple; - DSA_SIG *sig; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sig = DSA_do_sign(vbuf, vlen, dsa))) { - m2_PyErr_Msg(_dsa_err); - return NULL; - } - if (!(tuple = PyTuple_New(2))) { - DSA_SIG_free(sig); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - PyTuple_SET_ITEM(tuple, 0, dsa_sig_get_r(sig)); - PyTuple_SET_ITEM(tuple, 1, dsa_sig_get_s(sig)); - DSA_SIG_free(sig); - return tuple; -} - -int dsa_verify(DSA *dsa, PyObject *value, PyObject *r, PyObject *s) { - const void *vbuf, *rbuf, *sbuf; - int vlen = 0, rlen = 0, slen = 0; - DSA_SIG *sig; - BIGNUM* pr, *ps; - int ret; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) - || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) - return -1; - - if (!(sig = DSA_SIG_new())) { - m2_PyErr_Msg(_dsa_err); - return -1; - } - if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { - m2_PyErr_Msg(_dsa_err); - DSA_SIG_free(sig); - return -1; - } - if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { - m2_PyErr_Msg(_dsa_err); - DSA_SIG_free(sig); - BN_free(pr); - return -1; - } - if (!DSA_SIG_set0(sig, pr, ps)) { - m2_PyErr_Msg(_dsa_err); - DSA_SIG_free(sig); - BN_free(pr); - BN_free(ps); - return -1; - } - - ret = DSA_do_verify(vbuf, vlen, sig, dsa); - DSA_SIG_free(sig); - if (ret == -1) - m2_PyErr_Msg(_dsa_err); - return ret; -} - -PyObject *dsa_sign_asn1(DSA *dsa, PyObject *value) { - const void *vbuf; - int vlen = 0; - void *sigbuf; - unsigned int siglen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sigbuf = PyMem_Malloc(DSA_size(dsa)))) { - PyErr_SetString(PyExc_MemoryError, "dsa_sign_asn1"); - return NULL; - } - if (!DSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, dsa)) { - m2_PyErr_Msg(_dsa_err); - PyMem_Free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize(sigbuf, siglen); - - PyMem_Free(sigbuf); - return ret; -} - -int dsa_verify_asn1(DSA *dsa, PyObject *value, PyObject *sig) { - const void *vbuf; - void *sbuf; - int vlen = 0, slen = 0, ret = 0; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) - == -1)) - return -1; - - if ((ret = DSA_verify(0, vbuf, vlen, sbuf, slen, dsa)) == -1) - m2_PyErr_Msg(_dsa_err); - return ret; -} - -int dsa_check_key(DSA *dsa) { - const BIGNUM* pub_key, *priv_key; - DSA_get0_key(dsa, &pub_key, &priv_key); - return pub_key != NULL && priv_key != NULL; -} - -int dsa_check_pub_key(DSA *dsa) { - const BIGNUM* pub_key; - DSA_get0_key(dsa, &pub_key, NULL); - return pub_key ? 1 : 0; -} - -int dsa_keylen(DSA *dsa) { - const BIGNUM* p; - DSA_get0_pqg(dsa, &p, NULL, NULL); - return BN_num_bits(p); -} - -int dsa_type_check(DSA *dsa) { - return 1; -} -%} - diff --git a/SWIG/_ec.i b/SWIG/_ec.i deleted file mode 100644 index f47d593..0000000 --- a/SWIG/_ec.i +++ /dev/null @@ -1,521 +0,0 @@ -/* Copyright (c) 1999-2000 Ng Pheng Siong. All rights reserved. - Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. All rights reserved. - - Most code originally from _dsa.i, _rsa.i and _dh.i and adjusted for EC use. -*/ - -%include - -#if OPENSSL_VERSION_NUMBER < 0x0090800fL || defined(OPENSSL_NO_EC) -#undef OPENSSL_NO_EC -%constant OPENSSL_NO_EC = 1; -#else -%constant OPENSSL_NO_EC = 0; - -%{ -#include -#include -#include -#include -#include -#include -%} - -%apply Pointer NONNULL { EC_KEY * }; - -%rename(ec_key_new) EC_KEY_new; -extern EC_KEY *EC_KEY_new(void); -%rename(ec_key_free) EC_KEY_free; -extern void EC_KEY_free(EC_KEY *); -%rename(ec_key_size) ECDSA_size; -extern int ECDSA_size(const EC_KEY *); -%rename(ec_key_gen_key) EC_KEY_generate_key; -extern int EC_KEY_generate_key(EC_KEY *); -%rename(ec_key_check_key) EC_KEY_check_key; -extern int EC_KEY_check_key(const EC_KEY *); - -/* Curve identifier constants from OpenSSL */ -%constant int NID_secp112r1 = NID_secp112r1; -%constant int NID_secp112r2 = NID_secp112r2; -%constant int NID_secp128r1 = NID_secp128r1; -%constant int NID_secp128r2 = NID_secp128r2; -%constant int NID_secp160k1 = NID_secp160k1; -%constant int NID_secp160r1 = NID_secp160r1; -%constant int NID_secp160r2 = NID_secp160r2; -%constant int NID_secp192k1 = NID_secp192k1; -%constant int NID_secp224k1 = NID_secp224k1; -%constant int NID_secp224r1 = NID_secp224r1; -%constant int NID_secp256k1 = NID_secp256k1; -%constant int NID_secp384r1 = NID_secp384r1; -%constant int NID_secp521r1 = NID_secp521r1; -%constant int NID_sect113r1 = NID_sect113r1; -%constant int NID_sect113r2 = NID_sect113r2; -%constant int NID_sect131r1 = NID_sect131r1; -%constant int NID_sect131r2 = NID_sect131r2; -%constant int NID_sect163k1 = NID_sect163k1; -%constant int NID_sect163r1 = NID_sect163r1; -%constant int NID_sect163r2 = NID_sect163r2; -%constant int NID_sect193r1 = NID_sect193r1; -%constant int NID_sect193r2 = NID_sect193r2; -%constant int NID_sect233k1 = NID_sect233k1; -%constant int NID_sect233r1 = NID_sect233r1; -%constant int NID_sect239k1 = NID_sect239k1; -%constant int NID_sect283k1 = NID_sect283k1; -%constant int NID_sect283r1 = NID_sect283r1; -%constant int NID_sect409k1 = NID_sect409k1; -%constant int NID_sect409r1 = NID_sect409r1; -%constant int NID_sect571k1 = NID_sect571k1; -%constant int NID_sect571r1 = NID_sect571r1; - -%constant int NID_X9_62_prime192v1 = NID_X9_62_prime192v1; -%constant int NID_X9_62_prime192v2 = NID_X9_62_prime192v2; -%constant int NID_X9_62_prime192v3 = NID_X9_62_prime192v3; -%constant int NID_X9_62_prime239v1 = NID_X9_62_prime239v1; -%constant int NID_X9_62_prime239v2 = NID_X9_62_prime239v2; -%constant int NID_X9_62_prime239v3 = NID_X9_62_prime239v3; -%constant int NID_X9_62_prime256v1 = NID_X9_62_prime256v1; -%constant int NID_X9_62_c2pnb163v1 = NID_X9_62_c2pnb163v1; -%constant int NID_X9_62_c2pnb163v2 = NID_X9_62_c2pnb163v2; -%constant int NID_X9_62_c2pnb163v3 = NID_X9_62_c2pnb163v3; -%constant int NID_X9_62_c2pnb176v1 = NID_X9_62_c2pnb176v1; -%constant int NID_X9_62_c2tnb191v1 = NID_X9_62_c2tnb191v1; -%constant int NID_X9_62_c2tnb191v2 = NID_X9_62_c2tnb191v2; -%constant int NID_X9_62_c2tnb191v3 = NID_X9_62_c2tnb191v3; -%constant int NID_X9_62_c2pnb208w1 = NID_X9_62_c2pnb208w1; -%constant int NID_X9_62_c2tnb239v1 = NID_X9_62_c2tnb239v1; -%constant int NID_X9_62_c2tnb239v2 = NID_X9_62_c2tnb239v2; -%constant int NID_X9_62_c2tnb239v3 = NID_X9_62_c2tnb239v3; -%constant int NID_X9_62_c2pnb272w1 = NID_X9_62_c2pnb272w1; -%constant int NID_X9_62_c2pnb304w1 = NID_X9_62_c2pnb304w1; -%constant int NID_X9_62_c2tnb359v1 = NID_X9_62_c2tnb359v1; -%constant int NID_X9_62_c2pnb368w1 = NID_X9_62_c2pnb368w1; -%constant int NID_X9_62_c2tnb431r1 = NID_X9_62_c2tnb431r1; - -%constant int NID_wap_wsg_idm_ecid_wtls1 = NID_wap_wsg_idm_ecid_wtls1; -%constant int NID_wap_wsg_idm_ecid_wtls3 = NID_wap_wsg_idm_ecid_wtls3; -%constant int NID_wap_wsg_idm_ecid_wtls4 = NID_wap_wsg_idm_ecid_wtls4; -%constant int NID_wap_wsg_idm_ecid_wtls5 = NID_wap_wsg_idm_ecid_wtls5; -%constant int NID_wap_wsg_idm_ecid_wtls6 = NID_wap_wsg_idm_ecid_wtls6; -%constant int NID_wap_wsg_idm_ecid_wtls7 = NID_wap_wsg_idm_ecid_wtls7; -%constant int NID_wap_wsg_idm_ecid_wtls8 = NID_wap_wsg_idm_ecid_wtls8; -%constant int NID_wap_wsg_idm_ecid_wtls9 = NID_wap_wsg_idm_ecid_wtls9; -%constant int NID_wap_wsg_idm_ecid_wtls10 = NID_wap_wsg_idm_ecid_wtls10; -%constant int NID_wap_wsg_idm_ecid_wtls11 = NID_wap_wsg_idm_ecid_wtls11; -%constant int NID_wap_wsg_idm_ecid_wtls12 = NID_wap_wsg_idm_ecid_wtls12; - -%constant int NID_ipsec3 = NID_ipsec3; -%constant int NID_ipsec4 = NID_ipsec4; - - -%warnfilter(454) _ec_err; -%inline %{ -static PyObject *_ec_err; - -void ec_init(PyObject *ec_err) { - Py_INCREF(ec_err); - _ec_err = ec_err; -} - -PyObject *ec_get_builtin_curves(void) { - /* size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t - * nitems); */ - EC_builtin_curve *curves; - Py_ssize_t ret_curves = 0; - size_t num_curves = EC_get_builtin_curves(NULL, 0); - PyObject *ret_tuple = NULL; - PyObject *ret_dict = NULL; - Py_ssize_t i; - const char *comment; - const char *sname; - - if (!(curves = PyMem_Malloc(num_curves * sizeof(EC_builtin_curve)))) { - PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); - return NULL; - } - - ret_curves = (Py_ssize_t)EC_get_builtin_curves(curves, num_curves); - - if (!(ret_tuple = PyTuple_New(ret_curves))) { - PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); - return NULL; - } - - for (i = 0; i < ret_curves; i++) { - if (!(ret_dict = PyDict_New())) { - PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); - return NULL; - } - - comment = curves[i].comment; - sname = OBJ_nid2sn(curves[i].nid); - if (sname == NULL) - sname = ""; - - PyDict_SetItemString(ret_dict, "NID", - PyLong_FromLong((long)curves[i].nid)); - PyDict_SetItemString(ret_dict, "sname", - PyString_FromString(sname)); - PyDict_SetItemString(ret_dict, "comment", - PyString_FromString(comment)); - - PyTuple_SET_ITEM(ret_tuple, i, ret_dict); - - } - - PyMem_Free(curves); - - return ret_tuple; -} - -EC_KEY* ec_key_new_by_curve_name(int nid) -{ - EC_KEY *key; - EC_GROUP *group; - int ret =0; - point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; - int asn1_flag = OPENSSL_EC_NAMED_CURVE; - - /* If I simply do "return EC_KEY_new_by_curve_name(nid);" - * I get large public keys (222 vs 84 bytes for sect233k1 curve). - * I don't know why that is, but 'openssl ecparam -genkey ...' sets - * the ASN.1 flag and the point conversion form, and gets the - * small pub keys. So let's do that too. - */ - key = EC_KEY_new(); - if (!key) { - PyErr_SetString(PyExc_MemoryError, "ec_key_new_by_curve_name"); - return NULL; - } - group = EC_GROUP_new_by_curve_name(nid); - if (!group) { - m2_PyErr_Msg(_ec_err); - EC_KEY_free(key); - return NULL; - } - EC_GROUP_set_asn1_flag(group, asn1_flag); - EC_GROUP_set_point_conversion_form(group, form); - ret = EC_KEY_set_group(key, group); - EC_GROUP_free(group); - if (ret == 0) - { - /* EC_KEY_set_group only returns 0 or 1, and does not set error. */ - PyErr_SetString(_ec_err, "cannot set key's group"); - EC_KEY_free(key); - return NULL; - } - - return key; -} - -PyObject *ec_key_get_public_der(EC_KEY *key) { - char *src=NULL; - int src_len=0; - PyObject *pyo=NULL; - - /* Convert to binary */ - src_len = i2d_EC_PUBKEY( key, (unsigned char**)&src ); - if (src_len < 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - /* Create a PyBuffer containing a copy of the binary, - * to simplify memory deallocation - */ - pyo = PyBytes_FromStringAndSize( src, src_len ); - - OPENSSL_free(src); - - return pyo; -} - -PyObject *ec_key_get_public_key(EC_KEY *key) { - char *src=NULL; - int src_len=0; - PyObject *pyo=NULL; - - /* Convert to binary */ - src_len = i2o_ECPublicKey(key, (unsigned char**)&src); - if (src_len < 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - - pyo = PyBytes_FromStringAndSize( src, src_len ); - - OPENSSL_free(src); - - return pyo; -} - -%} - -%threadallow ec_key_read_pubkey; -%inline %{ -EC_KEY *ec_key_read_pubkey(BIO *f) { - return PEM_read_bio_EC_PUBKEY(f, NULL, NULL, NULL); -} -%} - -%threadallow ec_key_write_pubkey; -%inline %{ -int ec_key_write_pubkey(EC_KEY *key, BIO *f) { - return PEM_write_bio_EC_PUBKEY(f, key ); -} -%} - -%inline %{ -EC_KEY *ec_key_read_bio(BIO *f, PyObject *pyfunc) { - EC_KEY *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_ECPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%inline %{ -int ec_key_write_bio(EC_KEY *key, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_ECPrivateKey(f, key, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%inline %{ -int ec_key_write_bio_no_cipher(EC_KEY *key, BIO *f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_ECPrivateKey(f, key, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -PyObject *ecdsa_sig_get_r(ECDSA_SIG *ecdsa_sig) { - const BIGNUM* pr; - ECDSA_SIG_get0(ecdsa_sig, &pr, NULL); - return bn_to_mpi(pr); -} - -PyObject *ecdsa_sig_get_s(ECDSA_SIG *ecdsa_sig) { - const BIGNUM* ps; - ECDSA_SIG_get0(ecdsa_sig, NULL, &ps); - return bn_to_mpi(ps); -} - -PyObject *ecdsa_sign(EC_KEY *key, PyObject *value) { - const void *vbuf; - int vlen = 0; - PyObject *tuple; - ECDSA_SIG *sig; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sig = ECDSA_do_sign(vbuf, vlen, key))) { - m2_PyErr_Msg(_ec_err); - return NULL; - } - if (!(tuple = PyTuple_New(2))) { - ECDSA_SIG_free(sig); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - PyTuple_SET_ITEM(tuple, 0, ecdsa_sig_get_r(sig)); - PyTuple_SET_ITEM(tuple, 1, ecdsa_sig_get_s(sig)); - ECDSA_SIG_free(sig); - return tuple; -} - -int ecdsa_verify(EC_KEY *key, PyObject *value, PyObject *r, PyObject *s) { - const void *vbuf, *rbuf, *sbuf; - int vlen = 0, rlen = 0, slen = 0; - ECDSA_SIG *sig; - int ret; - BIGNUM* pr, *ps; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) - || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) - return -1; - - if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { - m2_PyErr_Msg(_ec_err); - return -1; - } - if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { - m2_PyErr_Msg(_ec_err); - BN_free(pr); - return -1; - } - - if (!(sig = ECDSA_SIG_new())) { - m2_PyErr_Msg(_ec_err); - BN_free(pr); - BN_free(ps); - return -1; - } - if (!ECDSA_SIG_set0(sig, pr, ps)) { - PyErr_SetString(_ec_err, "Cannot set r and s fields of ECDSA_SIG."); - ECDSA_SIG_free(sig); - BN_free(pr); - BN_free(ps); - return -1; - } - ret = ECDSA_do_verify(vbuf, vlen, sig, key); - ECDSA_SIG_free(sig); - if (ret == -1) - m2_PyErr_Msg(_ec_err); - return ret; -} - - -PyObject *ecdsa_sign_asn1(EC_KEY *key, PyObject *value) { - const void *vbuf; - int vlen = 0; - void *sigbuf; - unsigned int siglen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sigbuf = PyMem_Malloc(ECDSA_size(key)))) { - PyErr_SetString(PyExc_MemoryError, "ecdsa_sign_asn1"); - return NULL; - } - if (!ECDSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, key)) { - m2_PyErr_Msg(_ec_err); - PyMem_Free(sigbuf); - return NULL; - } - ret = PyBytes_FromStringAndSize(sigbuf, siglen); - - PyMem_Free(sigbuf); - return ret; -} - - -int ecdsa_verify_asn1(EC_KEY *key, PyObject *value, PyObject *sig) { - const void *vbuf; - void *sbuf; - int vlen = 0, slen = 0, ret; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) - == -1)) - return -1; - - if ((ret = ECDSA_verify(0, vbuf, vlen, sbuf, slen, key)) == -1) - m2_PyErr_Msg(_ec_err); - return ret; -} - -PyObject *ecdh_compute_key(EC_KEY *keypairA, EC_KEY *pubkeyB) { - int sharedkeylen; - void *sharedkey; - const EC_POINT *pkpointB; - PyObject *ret; - const EC_GROUP* groupA; - - if ((pkpointB = EC_KEY_get0_public_key(pubkeyB)) == NULL) - { - PyErr_SetString(_ec_err, "Cannot get the public key of EC_KEY object."); - return NULL; - } - - groupA = EC_KEY_get0_group(keypairA); - sharedkeylen = (EC_GROUP_get_degree(groupA) + 7)/8; - - if (!(sharedkey = PyMem_Malloc(sharedkeylen))) { - PyErr_SetString(PyExc_MemoryError, "ecdh_compute_key"); - return NULL; - } - if ((sharedkeylen = ECDH_compute_key((unsigned char *)sharedkey, sharedkeylen, pkpointB, keypairA, NULL)) == -1) { - m2_PyErr_Msg(_ec_err); - PyMem_Free(sharedkey); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)sharedkey, sharedkeylen); - - PyMem_Free(sharedkey); - - return ret; -} - - -EC_KEY* ec_key_from_pubkey_der(PyObject *pubkey) { - const void *keypairbuf; - Py_ssize_t keypairbuflen; - const unsigned char *tempBuf; - EC_KEY *keypair; - - if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) - { - return NULL; - } - - tempBuf = (const unsigned char *)keypairbuf; - if ((keypair = d2i_EC_PUBKEY( NULL, &tempBuf, keypairbuflen)) == 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - return keypair; -} - -EC_KEY* ec_key_from_pubkey_params(int nid, PyObject *pubkey) { - const void *keypairbuf; - Py_ssize_t keypairbuflen; - const unsigned char *tempBuf; - EC_KEY *keypair; - - if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) - { - return NULL; - } - - keypair = ec_key_new_by_curve_name(nid); - if (!keypair) { - m2_PyErr_Msg(_ec_err); - return NULL; - } - - tempBuf = (const unsigned char *)keypairbuf; - if ((o2i_ECPublicKey( &keypair, &tempBuf, keypairbuflen)) == 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - return keypair; -} - - -// According to [SEC2] the degree of the group is defined as EC key length -int ec_key_keylen(EC_KEY *key) { - const EC_GROUP *group = EC_KEY_get0_group(key); - return EC_GROUP_get_degree(group); -} - -int ec_key_type_check(EC_KEY *key) { - return 1; -} -%} -#endif // if OpenSSL version with EC support - diff --git a/SWIG/_engine.i b/SWIG/_engine.i deleted file mode 100644 index 4ba93f3..0000000 --- a/SWIG/_engine.i +++ /dev/null @@ -1,208 +0,0 @@ -/* - * -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: syntax=c sts=4 sw=4 - * - * ENGINE functions from engine(3SSL). - * - * Pavel Shramov - * IMEC MSU - */ -%{ -#include -#include -#include -%} - -%apply Pointer NONNULL { ENGINE * }; -%apply Pointer NONNULL { const ENGINE * }; -%apply Pointer NONNULL { const char * }; - -/* - * Functions to load different engines - */ -%rename(engine_load_builtin_engines) ENGINE_load_builtin_engines; -extern void ENGINE_load_builtin_engines(void); - -%rename(engine_load_dynamic) ENGINE_load_dynamic; -extern void ENGINE_load_dynamic(void); - -%rename(engine_load_openssl) ENGINE_load_openssl; -extern void ENGINE_load_openssl(void); - -%rename(engine_cleanup) ENGINE_cleanup; -extern void ENGINE_cleanup(void); - -/* - * Engine allocation functions - */ -%rename(engine_new) ENGINE_new; -extern ENGINE * ENGINE_new(); - -%rename(engine_by_id) ENGINE_by_id; -extern ENGINE * ENGINE_by_id(const char *); - -%rename(engine_free) ENGINE_free; -extern int ENGINE_free(ENGINE *); - -%rename(engine_init) ENGINE_init; -extern int ENGINE_init(ENGINE *); - -%rename(engine_finish) ENGINE_finish; -extern int ENGINE_finish(ENGINE *); - -/* - * Engine id/name functions - */ -%rename(engine_get_id) ENGINE_get_id; -extern const char * ENGINE_get_id(const ENGINE *); - -%rename(engine_get_name) ENGINE_get_name; -extern const char * ENGINE_get_name(const ENGINE *); - -/* - * Engine control functions - * Control argument may be NULL (e.g for LOAD command) - */ -%clear const char *; -%rename(engine_ctrl_cmd_string) ENGINE_ctrl_cmd_string; -extern int ENGINE_ctrl_cmd_string(ENGINE *e, const char *NONNULL, - const char *arg, int cmd_optional); - -%apply Pointer NONNULL { const char * }; - -/* - * UI methods. - * XXX: UI_OpenSSL method is static and UI_destroy_method is not needed. - */ -%rename(ui_openssl) UI_OpenSSL; -extern UI_METHOD * UI_OpenSSL(); - -/* -%rename(ui_destroy_method) UI_destroy_method; -extern void UI_destroy_method(UI_METHOD *ui_method); - */ - -%clear const char *; -%inline %{ - -/* - * Code from engine-pkcs11 1.4.0 in engine-pkcs11.c - * - -99 static char *get_pin(UI_METHOD * ui_method, void *callback_data, char *sc_pin, -100 int maxlen) -101 { -102 UI *ui; -103 struct { -104 const void *password; -105 const char *prompt_info; -106 } *mycb = callback_data; -107 -108 if (mycb->password) { -109 sc_pin = set_pin(mycb->password); -110 return sc_pin; -111 } - - * - * So callback_data need to be always provided and have fixed type. - * UI method still may be NULL. - * - * Following functions allocate and free callback data structure with - * optional password set. - */ - -typedef struct { - char * password; - char * prompt; -} _cbd_t; - -void * engine_pkcs11_data_new(const char *pin) { - _cbd_t * cb = (_cbd_t *) PyMem_Malloc(sizeof(_cbd_t)); - if (!cb) { - PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); - return NULL; - } - cb->password = NULL; - if (pin) { - size_t size = strlen(pin); - cb->password = (char *) PyMem_Malloc(size + 1); - if (!cb->password) { - PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); - PyMem_Free(cb); - return NULL; - } - memcpy(cb->password, pin, size + 1); - } - cb->prompt = NULL; - return cb; -} - -void engine_pkcs11_data_free(void * vcb) { - _cbd_t * cb = (_cbd_t *) vcb; - if (!cb) - return; - if (cb->password) - PyMem_Free(cb->password); - PyMem_Free(cb); -} - -%} -%apply Pointer NONNULL { const char * }; - -/* - * Engine key/cert load functions. - * See above notice about callback_data. - */ -%rename(engine_load_private_key) ENGINE_load_private_key; -extern EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); -%rename(engine_load_public_key) ENGINE_load_public_key; -extern EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); - -/* - * This function may be not implemented in engine. - * pkcs11 engine has this control. - */ -%warnfilter(454) _engine_err; -%inline %{ -static PyObject *_engine_err; - -void engine_init_error(PyObject *engine_err) { - Py_INCREF(engine_err); - _engine_err = engine_err; -} - -X509 * engine_load_certificate(ENGINE *e, const char * slot) { - struct { - const char * slot; - X509 * cert; - } cbd; - cbd.slot = slot; - cbd.cert = NULL; - if (!ENGINE_ctrl_cmd(e, "LOAD_CERT_CTRL", 0, &cbd, NULL, 0)) { - PyErr_SetString(_engine_err, "cannot load certificate"); - return NULL; - } - return cbd.cert; -} -%} - -/* These flags are used to control combinations of algorithm (methods) - * by bitwise "OR"ing. */ -%constant int ENGINE_METHOD_RSA = 0x0001; -%constant int ENGINE_METHOD_DSA = 0x0002; -%constant int ENGINE_METHOD_DH = 0x0004; -%constant int ENGINE_METHOD_RAND = 0x0008; -%constant int ENGINE_METHOD_ECDH = 0x0010; -%constant int ENGINE_METHOD_ECDSA = 0x0020; -%constant int ENGINE_METHOD_CIPHERS = 0x0040; -%constant int ENGINE_METHOD_DIGESTS = 0x0080; -%constant int ENGINE_METHOD_STORE = 0x0100; -/* Obvious all-or-nothing cases. */ -%constant int ENGINE_METHOD_ALL = 0xFFFF; -%constant int ENGINE_METHOD_NONE = 0x0000; - -%rename(engine_set_default) ENGINE_set_default; -extern int ENGINE_set_default(ENGINE *e, unsigned int flags); - diff --git a/SWIG/_evp.i b/SWIG/_evp.i deleted file mode 100644 index 758f11b..0000000 --- a/SWIG/_evp.i +++ /dev/null @@ -1,886 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* -Copyright (c) 1999 Ng Pheng Siong. All rights reserved. - -Portions Copyright (c) 2004-2007 Open Source Applications Foundation. -Author: Heikki Toivonen - -Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. - -*/ - -%include - -%{ -#include -#include -#include -#include -#include -#include - -#if OPENSSL_VERSION_NUMBER < 0x10100000L - -HMAC_CTX *HMAC_CTX_new(void) { - HMAC_CTX *ret = PyMem_Malloc(sizeof(HMAC_CTX)); - HMAC_CTX_init(ret); - return ret; -} -#define HMAC_CTX_reset(ctx) HMAC_CTX_init(ctx) -#define HMAC_CTX_free(ctx) \ - do { \ - HMAC_CTX_cleanup(ctx); \ - PyMem_Free((void *)ctx); \ - } while(0) - -#define EVP_CIPHER_CTX_reset(ctx) EVP_CIPHER_CTX_init(ctx) -#endif -%} - -/* -from openssl/crypto/include/internal/evp_int.h struct evp_md_st -typedef struct evp_md_st EVP_MD; -from openssl/crypto/evp/evp_locl.h evp_md_ctx_st -typedef struct evp_md_ctx_st EVP_MD_CTX; -*/ - -%apply Pointer NONNULL { EVP_MD_CTX * }; -%apply Pointer NONNULL { EVP_MD * }; -%apply Pointer NONNULL { EVP_PKEY * }; -%apply Pointer NONNULL { HMAC_CTX * }; -%apply Pointer NONNULL { EVP_CIPHER_CTX * }; -%apply Pointer NONNULL { EVP_CIPHER * }; -%apply Pointer NONNULL { RSA * }; - -%rename(md5) EVP_md5; -extern const EVP_MD *EVP_md5(void); -%rename(sha1) EVP_sha1; -extern const EVP_MD *EVP_sha1(void); -%rename(ripemd160) EVP_ripemd160; -extern const EVP_MD *EVP_ripemd160(void); - -#if OPENSSL_VERSION_NUMBER >= 0x0090800fL -%rename(sha224) EVP_sha224; -extern const EVP_MD *EVP_sha224(void); -%rename(sha256) EVP_sha256; -extern const EVP_MD *EVP_sha256(void); -%rename(sha384) EVP_sha384; -extern const EVP_MD *EVP_sha384(void); -%rename(sha512) EVP_sha512; -extern const EVP_MD *EVP_sha512(void); -#endif - -%rename(digest_init) EVP_DigestInit; -extern int EVP_DigestInit(EVP_MD_CTX *, const EVP_MD *); - -%rename(des_ecb) EVP_des_ecb; -extern const EVP_CIPHER *EVP_des_ecb(void); -%rename(des_ede_ecb) EVP_des_ede; -extern const EVP_CIPHER *EVP_des_ede(void); -%rename(des_ede3_ecb) EVP_des_ede3; -extern const EVP_CIPHER *EVP_des_ede3(void); -%rename(des_cbc) EVP_des_cbc; -extern const EVP_CIPHER *EVP_des_cbc(void); -%rename(des_ede_cbc) EVP_des_ede_cbc; -extern const EVP_CIPHER *EVP_des_ede_cbc(void); -%rename(des_ede3_cbc) EVP_des_ede3_cbc; -extern const EVP_CIPHER *EVP_des_ede3_cbc(void); -%rename(des_cfb) EVP_des_cfb; -extern const EVP_CIPHER *EVP_des_cfb(void); -%rename(des_ede_cfb) EVP_des_ede_cfb; -extern const EVP_CIPHER *EVP_des_ede_cfb(void); -%rename(des_ede3_cfb) EVP_des_ede3_cfb; -extern const EVP_CIPHER *EVP_des_ede3_cfb(void); -%rename(des_ofb) EVP_des_ofb; -extern const EVP_CIPHER *EVP_des_ofb(void); -%rename(des_ede_ofb) EVP_des_ede_ofb; -extern const EVP_CIPHER *EVP_des_ede_ofb(void); -%rename(des_ede3_ofb) EVP_des_ede3_ofb; -extern const EVP_CIPHER *EVP_des_ede3_ofb(void); -%rename(bf_ecb) EVP_bf_ecb; -extern const EVP_CIPHER *EVP_bf_ecb(void); -%rename(bf_cbc) EVP_bf_cbc; -extern const EVP_CIPHER *EVP_bf_cbc(void); -%rename(bf_cfb) EVP_bf_cfb; -extern const EVP_CIPHER *EVP_bf_cfb(void); -%rename(bf_ofb) EVP_bf_ofb; -extern const EVP_CIPHER *EVP_bf_ofb(void); -/* -%rename(idea_ecb) extern const EVP_CIPHER *EVP_idea_ecb(void); -%rename(idea_cbc) extern const EVP_CIPHER *EVP_idea_cbc(void); -%rename(idea_cfb) extern const EVP_CIPHER *EVP_idea_cfb(void); -%rename(idea_ofb) extern const EVP_CIPHER *EVP_idea_ofb(void); -*/ -%rename(cast5_ecb) EVP_cast5_ecb; -extern const EVP_CIPHER *EVP_cast5_ecb(void); -%rename(cast5_cbc) EVP_cast5_cbc; -extern const EVP_CIPHER *EVP_cast5_cbc(void); -%rename(cast5_cfb) EVP_cast5_cfb; -extern const EVP_CIPHER *EVP_cast5_cfb(void); -%rename(cast5_ofb) EVP_cast5_ofb; -extern const EVP_CIPHER *EVP_cast5_ofb(void); -/* -%rename(rc5_ecb) extern const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); -%rename(rc5_cbc) extern const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); -%rename(rc5_cfb) extern const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); -%rename(rc5_ofb) extern const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); -*/ -#if !defined(OPENSSL_NO_RC4) -%rename(rc4) EVP_rc4; -extern const EVP_CIPHER *EVP_rc4(void); -#endif -#if !defined(OPENSSL_NO_RC2) -%rename(rc2_40_cbc) EVP_rc2_40_cbc; -extern const EVP_CIPHER *EVP_rc2_40_cbc(void); -#endif -%rename(aes_128_ecb) EVP_aes_128_ecb; -extern const EVP_CIPHER *EVP_aes_128_ecb(void); -%rename(aes_128_cbc) EVP_aes_128_cbc; -extern const EVP_CIPHER *EVP_aes_128_cbc(void); -%rename(aes_128_cfb) EVP_aes_128_cfb; -extern const EVP_CIPHER *EVP_aes_128_cfb(void); -%rename(aes_128_ofb) EVP_aes_128_ofb; -extern const EVP_CIPHER *EVP_aes_128_ofb(void); -%rename(aes_128_ctr) EVP_aes_128_ctr; -extern const EVP_CIPHER *EVP_aes_128_ctr(void); -%rename(aes_192_ecb) EVP_aes_192_ecb; -extern const EVP_CIPHER *EVP_aes_192_ecb(void); -%rename(aes_192_cbc) EVP_aes_192_cbc; -extern const EVP_CIPHER *EVP_aes_192_cbc(void); -%rename(aes_192_cfb) EVP_aes_192_cfb; -extern const EVP_CIPHER *EVP_aes_192_cfb(void); -%rename(aes_192_ofb) EVP_aes_192_ofb; -extern const EVP_CIPHER *EVP_aes_192_ofb(void); -%rename(aes_192_ctr) EVP_aes_192_ctr; -extern const EVP_CIPHER *EVP_aes_192_ctr(void); -%rename(aes_256_ecb) EVP_aes_256_ecb; -extern const EVP_CIPHER *EVP_aes_256_ecb(void); -%rename(aes_256_cbc) EVP_aes_256_cbc; -extern const EVP_CIPHER *EVP_aes_256_cbc(void); -%rename(aes_256_cfb) EVP_aes_256_cfb; -extern const EVP_CIPHER *EVP_aes_256_cfb(void); -%rename(aes_256_ofb) EVP_aes_256_ofb; -extern const EVP_CIPHER *EVP_aes_256_ofb(void); -%rename(aes_256_ctr) EVP_aes_256_ctr; -extern EVP_CIPHER const *EVP_aes_256_ctr(void); - -%rename(cipher_set_padding) EVP_CIPHER_CTX_set_padding; -extern int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *, int); - - -%rename(cipher_set_padding) EVP_CIPHER_CTX_set_padding; -extern int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding); -%rename(pkey_free) EVP_PKEY_free; -extern void EVP_PKEY_free(EVP_PKEY *); -%rename(pkey_assign) EVP_PKEY_assign; -extern int EVP_PKEY_assign(EVP_PKEY *, int, char *); -#if OPENSSL_VERSION_NUMBER >= 0x0090800fL && !defined(OPENSSL_NO_EC) -%rename(pkey_assign_ec) EVP_PKEY_assign_EC_KEY; -extern int EVP_PKEY_assign_EC_KEY(EVP_PKEY *, EC_KEY *); -#endif -%rename(pkey_set1_rsa) EVP_PKEY_set1_RSA; -extern int EVP_PKEY_set1_RSA(EVP_PKEY *, RSA *); -%rename(sign_init) EVP_SignInit; -extern int EVP_SignInit(EVP_MD_CTX *, const EVP_MD *); -%rename(verify_init) EVP_VerifyInit; -extern int EVP_VerifyInit(EVP_MD_CTX *, const EVP_MD *); -%rename(digest_sign_init) EVP_DigestSignInit; -extern int EVP_DigestSignInit(EVP_MD_CTX *, EVP_PKEY_CTX **, const EVP_MD *, ENGINE *, EVP_PKEY *); -%rename(digest_verify_init) EVP_DigestVerifyInit; -extern int EVP_DigestVerifyInit(EVP_MD_CTX *, EVP_PKEY_CTX **, const EVP_MD *, ENGINE *, EVP_PKEY *); -%rename(pkey_size) EVP_PKEY_size; -extern int EVP_PKEY_size(EVP_PKEY *); - -%warnfilter(454) _evp_err; -%inline %{ -#define PKCS5_SALT_LEN 8 - -static PyObject *_evp_err; - -void evp_init(PyObject *evp_err) { - Py_INCREF(evp_err); - _evp_err = evp_err; -} -%} - -%typemap(out) RSA * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - $result = NULL; - } -} -%inline %{ -RSA *pkey_get1_rsa(EVP_PKEY *pkey) { - RSA *ret = NULL; - - if ((ret = EVP_PKEY_get1_RSA(pkey)) == NULL) { - /* _evp_err now inherits from PyExc_ValueError, so we should - * keep API intact. - */ - PyErr_Format(_evp_err, "Invalid key in function %s.", __FUNCTION__); - } - - return ret; -} -%} -%typemap(out) RSA * ; - -%inline %{ -PyObject *pkcs5_pbkdf2_hmac_sha1(PyObject *pass, - PyObject *salt, - int iter, - int keylen) { - unsigned char *key; - const void *saltbuf; - const void *passbuf; - PyObject *ret; - int passlen = 0, saltlen = 0; - - if (m2_PyObject_AsReadBufferInt(pass, &passbuf, &passlen) == -1) - return NULL; - if (m2_PyObject_AsReadBufferInt(salt, &saltbuf, &saltlen) == -1) - return NULL; - - key = PyMem_Malloc(keylen); - if (key == NULL) - return PyErr_NoMemory(); - PKCS5_PBKDF2_HMAC_SHA1((const char *)passbuf, passlen, (const unsigned char *)saltbuf, saltlen, iter, - keylen, key); - ret = PyBytes_FromStringAndSize((char*)key, keylen); - OPENSSL_cleanse(key, keylen); - PyMem_Free(key); - return ret; -} - -EVP_MD_CTX *md_ctx_new(void) { - EVP_MD_CTX *ctx; - - if (!(ctx = EVP_MD_CTX_create())) { - PyErr_SetString(PyExc_MemoryError, "md_ctx_new"); - return NULL; - } - return ctx; -} - -void md_ctx_free(EVP_MD_CTX *ctx) { - EVP_MD_CTX_destroy(ctx); -} - -int digest_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - Py_ssize_t len; - - if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) - return -1; - - return EVP_DigestUpdate(ctx, buf, (size_t)len); -} - -PyObject *digest_final(EVP_MD_CTX *ctx) { - void *blob; - int blen; - PyObject *ret; - - if (!(blob = PyMem_Malloc(EVP_MD_CTX_size(ctx)))) { - PyErr_SetString(PyExc_MemoryError, "digest_final"); - return NULL; - } - if (!EVP_DigestFinal(ctx, blob, (unsigned int *)&blen)) { - PyMem_Free(blob); - m2_PyErr_Msg(_evp_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize(blob, blen); - - PyMem_Free(blob); - return ret; -} - -HMAC_CTX *hmac_ctx_new(void) { - HMAC_CTX *ctx; - - if (!(ctx = HMAC_CTX_new())) { - PyErr_SetString(PyExc_MemoryError, "hmac_ctx_new"); - return NULL; - } - return ctx; -} - -void hmac_ctx_free(HMAC_CTX *ctx) { - HMAC_CTX_free(ctx); -} - -PyObject *hmac_init(HMAC_CTX *ctx, PyObject *key, const EVP_MD *md) { - const void *kbuf; - int klen = 0; - - if (m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) - return NULL; - - if (!HMAC_Init_ex(ctx, kbuf, klen, md, NULL)) { - PyErr_SetString(_evp_err, "HMAC_Init failed"); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *hmac_update(HMAC_CTX *ctx, PyObject *blob) { - const void *buf; - Py_ssize_t len; - - if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) - return NULL; - - if (!HMAC_Update(ctx, (const unsigned char *)buf, (size_t)len)) { - PyErr_SetString(_evp_err, "HMAC_Update failed"); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *hmac_final(HMAC_CTX *ctx) { - void *blob; - int blen; - PyObject *ret; - - if (!(blob = PyMem_Malloc(HMAC_size(ctx)))) { - PyErr_SetString(PyExc_MemoryError, "hmac_final"); - return NULL; - } - - if (!HMAC_Final(ctx, blob, (unsigned int *)&blen)) { - PyErr_SetString(_evp_err, "HMAC_Final failed"); - return NULL; - } - - ret = PyBytes_FromStringAndSize(blob, blen); - - PyMem_Free(blob); - return ret; -} - -PyObject *hmac(PyObject *key, PyObject *data, const EVP_MD *md) { - const void *kbuf, *dbuf; - void *blob; - int klen = 0; - unsigned int blen; - Py_ssize_t dlen; - PyObject *ret; - - if ((m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) - || (m2_PyObject_AsReadBuffer(data, &dbuf, &dlen) == -1)) - return NULL; - - if (!(blob = PyMem_Malloc(EVP_MAX_MD_SIZE))) { - PyErr_SetString(PyExc_MemoryError, "hmac"); - return NULL; - } - HMAC(md, kbuf, klen, (const unsigned char *)dbuf, (size_t)dlen, (unsigned char *)blob, &blen); - blob = PyMem_Realloc(blob, blen); - - ret = PyBytes_FromStringAndSize(blob, blen); - - PyMem_Free(blob); - return ret; -} - -EVP_CIPHER_CTX *cipher_ctx_new(void) { - EVP_CIPHER_CTX *ctx; - - if (!(ctx = EVP_CIPHER_CTX_new())) { - PyErr_SetString(PyExc_MemoryError, "cipher_ctx_new"); - return NULL; - } - EVP_CIPHER_CTX_reset(ctx); - return ctx; -} - -void cipher_ctx_free(EVP_CIPHER_CTX *ctx) { - EVP_CIPHER_CTX_free(ctx); -} - -PyObject *bytes_to_key(const EVP_CIPHER *cipher, EVP_MD *md, - PyObject *data, PyObject *salt, - PyObject *iv, /* Not used */ - int iter) { - unsigned char key[EVP_MAX_KEY_LENGTH]; - const void *dbuf, *sbuf; - int dlen = 0, klen; - Py_ssize_t slen; - PyObject *ret; - - if ((m2_PyObject_AsReadBufferInt(data, &dbuf, &dlen) == -1) - || (m2_PyObject_AsReadBuffer(salt, &sbuf, &slen) == -1)) - return NULL; - - assert((slen == 8) || (slen == 0)); - klen = EVP_BytesToKey(cipher, md, (unsigned char *)sbuf, - (unsigned char *)dbuf, dlen, iter, - key, NULL); /* Since we are not returning IV no need to derive it */ - - ret = PyBytes_FromStringAndSize((char*)key, klen); - - return ret; -} - -PyObject *cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - PyObject *key, PyObject *iv, int mode) { - const void *kbuf, *ibuf; - Py_ssize_t klen, ilen; - - if (key == Py_None) - kbuf = NULL; - else if (m2_PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) - return NULL; - - if (iv == Py_None) - ibuf = NULL; - else if (m2_PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1) - return NULL; - - if (!EVP_CipherInit(ctx, cipher, (unsigned char *)kbuf, - (unsigned char *)ibuf, mode)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *cipher_update(EVP_CIPHER_CTX *ctx, PyObject *blob) { - const void *buf; - int len = 0, olen; - void *obuf; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) - return NULL; - - if (!(obuf = PyMem_Malloc(len + EVP_CIPHER_CTX_block_size(ctx) - 1))) { - PyErr_SetString(PyExc_MemoryError, "cipher_update"); - return NULL; - } - if (!EVP_CipherUpdate(ctx, obuf, &olen, (unsigned char *)buf, len)) { - PyMem_Free(obuf); - m2_PyErr_Msg(_evp_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize(obuf, olen); - - PyMem_Free(obuf); - return ret; -} - -PyObject *cipher_final(EVP_CIPHER_CTX *ctx) { - void *obuf; - int olen; - PyObject *ret; - - if (!(obuf = PyMem_Malloc(EVP_CIPHER_CTX_block_size(ctx)))) { - PyErr_SetString(PyExc_MemoryError, "cipher_final"); - return NULL; - } - if (!EVP_CipherFinal(ctx, (unsigned char *)obuf, &olen)) { - PyMem_Free(obuf); - m2_PyErr_Msg(_evp_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize(obuf, olen); - - PyMem_Free(obuf); - return ret; -} - -PyObject *sign_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len; - - if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) - return NULL; - - if (!EVP_SignUpdate(ctx, buf, (Py_ssize_t)len)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *sign_final(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { - PyObject *ret; - unsigned char *sigbuf; - unsigned int siglen = EVP_PKEY_size(pkey); - - sigbuf = (unsigned char*)OPENSSL_malloc(siglen); - if (!sigbuf) { - PyErr_SetString(PyExc_MemoryError, "sign_final"); - return NULL; - } - - if (!EVP_SignFinal(ctx, sigbuf, &siglen, pkey)) { - m2_PyErr_Msg(_evp_err); - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); - - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return ret; -} - -int verify_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len; - - if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) - return -1; - - return EVP_VerifyUpdate(ctx, buf, (Py_ssize_t)len); -} - -int verify_final(EVP_MD_CTX *ctx, PyObject *blob, EVP_PKEY *pkey) { - const void *kbuf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, &kbuf, &len) == -1) - return -1; - - return EVP_VerifyFinal(ctx, (const unsigned char *)kbuf, len, pkey); -} - -int digest_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { - return EVP_DigestSignInit(ctx, NULL, NULL, NULL, pkey); -} - -PyObject *digest_sign_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) - return NULL; - - if (!EVP_DigestSignUpdate(ctx, buf, len)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *digest_sign_final(EVP_MD_CTX *ctx) { - PyObject *ret; - unsigned char *sigbuf; - size_t siglen; - - if (!EVP_DigestSignFinal(ctx, NULL, &siglen)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - - sigbuf = (unsigned char*)OPENSSL_malloc(siglen); - if (!sigbuf) { - PyErr_SetString(PyExc_MemoryError, "digest_sign_final"); - return NULL; - } - - if (!EVP_DigestSignFinal(ctx, sigbuf, &siglen)) { - m2_PyErr_Msg(_evp_err); - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); - - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return ret; -} - -#if OPENSSL_VERSION_NUMBER >= 0x10101000L -PyObject *digest_sign(EVP_MD_CTX *ctx, PyObject *msg) { - PyObject *ret; - const void *msgbuf; - unsigned char *sigbuf; - int msglen = 0; - size_t siglen = 0; - - if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) - return NULL; - - if (!EVP_DigestSign(ctx, NULL, &siglen, msgbuf, msglen)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - - sigbuf = (unsigned char*)OPENSSL_malloc(siglen); - if (!sigbuf) { - PyErr_SetString(PyExc_MemoryError, "digest_sign"); - return NULL; - } - - if (!EVP_DigestSign(ctx, sigbuf, &siglen, msgbuf, msglen)) { - m2_PyErr_Msg(_evp_err); - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); - - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return ret; - -} -#endif - -int digest_verify_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { - return EVP_DigestVerifyInit(ctx, NULL, NULL, NULL, pkey); -} - -int digest_verify_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) - return -1; - - return EVP_DigestVerifyUpdate(ctx, buf, len); -} - -int digest_verify_final(EVP_MD_CTX *ctx, PyObject *blob) { - unsigned char *sigbuf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, (const void **)&sigbuf, &len) == -1) - return -1; - - return EVP_DigestVerifyFinal(ctx, sigbuf, len); -} - -#if OPENSSL_VERSION_NUMBER >= 0x10101000L -int digest_verify(EVP_MD_CTX *ctx, PyObject *sig, PyObject *msg) { - unsigned char *sigbuf; - unsigned char *msgbuf; - int siglen = 0; - int msglen = 0; - - if (m2_PyObject_AsReadBufferInt(sig, (const void **)&sigbuf, &siglen) == -1) - return -1; - - if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) - return -1; - - return EVP_DigestVerify(ctx, sigbuf, siglen, msgbuf, msglen); -} -#endif -%} - -%typemap(out) EVP_MD * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - $result = NULL; - } -} -%inline %{ -const EVP_MD *get_digestbyname(const char* name) { - const EVP_MD *ret = NULL; - - if ((ret = EVP_get_digestbyname(name)) == NULL) { - m2_PyErr_Msg(_evp_err); - } - - return ret; -} -%} -%typemap(out) EVP_MD *; - -%inline %{ -int pkey_write_pem_no_cipher(EVP_PKEY *pkey, BIO *f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%inline %{ -int pkey_write_pem(EVP_PKEY *pkey, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%typemap(out) EVP_PKEY * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - $result = NULL; - } -} -%inline %{ -EVP_PKEY *pkey_new(void) { - EVP_PKEY *ret; - - if ((ret = EVP_PKEY_new()) == NULL) { - PyErr_Format(PyExc_MemoryError, - "Insufficient memory for new key in function %s.", __FUNCTION__); - } - - return ret; -} - -EVP_PKEY *pkey_read_pem(BIO *f, PyObject *pyfunc) { - EVP_PKEY *pk; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - pk = PEM_read_bio_PrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (pk == NULL) { - PyErr_Format(_evp_err, - "Unable to read private key in function %s.", __FUNCTION__); - } - - return pk; -} - -EVP_PKEY *pkey_read_pem_pubkey(BIO *f, PyObject *pyfunc) { - EVP_PKEY *pk; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - pk = PEM_read_bio_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (pk == NULL) { - PyErr_Format(_evp_err, - "Unable to read public key in function %s.", __FUNCTION__); - } - - return pk; -} -%} -%typemap(out) EVP_PKEY * ; - -%inline %{ -int pkey_assign_rsa(EVP_PKEY *pkey, RSA *rsa) { - return EVP_PKEY_assign_RSA(pkey, rsa); -} - -PyObject *pkey_as_der(EVP_PKEY *pkey) { - unsigned char * pp = NULL; - int len; - PyObject * der; - len = i2d_PUBKEY(pkey, &pp); - if (len < 0){ - PyErr_SetString(_evp_err, "EVP_PKEY as DER failed"); - return NULL; - } - - der = PyBytes_FromStringAndSize((char*)pp, len); - - OPENSSL_free(pp); - return der; -} - -PyObject *pkey_get_modulus(EVP_PKEY *pkey) -{ - RSA *rsa; - DSA *dsa; - BIO *bio; - BUF_MEM *bptr; - PyObject *ret; - const BIGNUM* bn; - - switch (EVP_PKEY_base_id(pkey)) { - case EVP_PKEY_RSA: - rsa = EVP_PKEY_get1_RSA(pkey); - - bio = BIO_new(BIO_s_mem()); - if (!bio) { - RSA_free(rsa); - PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); - return NULL; - } - - RSA_get0_key(rsa, &bn, NULL, NULL); - if (!BN_print(bio, bn)) { - m2_PyErr_Msg(PyExc_RuntimeError); - BIO_free(bio); - RSA_free(rsa); - return NULL; - } - BIO_get_mem_ptr(bio, &bptr); - - ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); - - (void)BIO_set_close(bio, BIO_CLOSE); - BIO_free(bio); - RSA_free(rsa); - - return ret; - break; - - case EVP_PKEY_DSA: - dsa = EVP_PKEY_get1_DSA(pkey); - - bio = BIO_new(BIO_s_mem()); - if (!bio) { - DSA_free(dsa); - PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); - return NULL; - } - - DSA_get0_key(dsa, &bn, NULL); - if (!BN_print(bio, bn)) { - m2_PyErr_Msg(PyExc_RuntimeError); - BIO_free(bio); - DSA_free(dsa); - return NULL; - } - BIO_get_mem_ptr(bio, &bptr); - - ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); - - (void)BIO_set_close(bio, BIO_CLOSE); - BIO_free(bio); - DSA_free(dsa); - - return ret; - break; - - default: - PyErr_SetString(_evp_err, "unsupported key type"); - return NULL; - } -} - -%} diff --git a/SWIG/_lib.h b/SWIG/_lib.h deleted file mode 100644 index f1973b4..0000000 --- a/SWIG/_lib.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -#include - -typedef struct _blob { - unsigned char *data; - int len; -} Blob; - -Blob *blob_new(int len, const char *errmsg); -Blob *blob_copy(Blob *from, const char *errmsg); -void blob_free(Blob *blob); - -static int m2_PyObject_AsReadBuffer(PyObject *obj, const void **buffer, - Py_ssize_t *buffer_len); -static int m2_PyObject_AsReadBufferInt(PyObject *obj, const void **buffer, - int *buffer_len); -static int m2_PyString_AsStringAndSizeInt(PyObject *obj, char **s, int *len); - -static BIGNUM* m2_PyObject_AsBIGNUM(PyObject* value, PyObject* _py_exc) ; - -/* Always use these two together, to correctly handle non-memoryview objects. */ -static int m2_PyObject_GetBufferInt(PyObject *obj, Py_buffer *view, int flags); -static void m2_PyBuffer_Release(PyObject *obj, Py_buffer *view); - -int bn_gencb_callback(int p, int n, BN_GENCB *gencb); -int passphrase_callback(char *buf, int num, int v, void *userdata); - -void lib_init(void); - diff --git a/SWIG/_lib.i b/SWIG/_lib.i deleted file mode 100644 index 954e99b..0000000 --- a/SWIG/_lib.i +++ /dev/null @@ -1,777 +0,0 @@ -/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%{ -#include -#include -#include -#include -#include -#include -#include -#include -#include -%} - -/* OpenSSL 1.1 compatibility shim */ -%include _lib11_compat.i - -/* Python 3 compatibility shim */ -%include _py3k_compat.i - -%{ -/* OpenSSL 1.0.2 copmatbility shim */ -#if OPENSSL_VERSION_NUMBER < 0x10002000L -typedef void (*OPENSSL_sk_freefunc)(void *); -typedef void *(*OPENSSL_sk_copyfunc)(const void *); -typedef struct stack_st OPENSSL_STACK; - -# define MIN_NODES 4 -# define sk_deep_copy OPENSSL_sk_deep_copy - -void OPENSSL_sk_free(OPENSSL_STACK *st) -{ - if (st == NULL) - return; - OPENSSL_free(st->data); - OPENSSL_free(st); -} - -OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, - OPENSSL_sk_copyfunc copy_func, - OPENSSL_sk_freefunc free_func) -{ - OPENSSL_STACK *ret; - int i; - - if (sk->num < 0) - return NULL; - - if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) - return NULL; - - /* direct structure assignment */ - *ret = *sk; - - ret->num_alloc = sk->num > MIN_NODES ? (size_t)sk->num : MIN_NODES; - ret->data = OPENSSL_zalloc(sizeof(*ret->data) * ret->num_alloc); - if (ret->data == NULL) { - OPENSSL_free(ret); - return NULL; - } - - for (i = 0; i < ret->num; ++i) { - if (sk->data[i] == NULL) - continue; - if ((ret->data[i] = copy_func(sk->data[i])) == NULL) { - while (--i >= 0) - if (ret->data[i] != NULL) - free_func((void *)ret->data[i]); - OPENSSL_sk_free(ret); - return NULL; - } - } - return ret; -} -#endif /* OpenSSL 1.0.2 copmatbility shim */ - - -/* Blob interface. Deprecated. */ - -Blob *blob_new(int len, const char *errmsg) { - - Blob *blob; - if (!(blob=(Blob *)PyMem_Malloc(sizeof(Blob)))){ - PyErr_SetString(PyExc_MemoryError, errmsg); - return NULL; - } - if (!(blob->data=(unsigned char *)PyMem_Malloc(len))) { - PyMem_Free(blob); - PyErr_SetString(PyExc_MemoryError, errmsg); - return NULL; - } - blob->len=len; - return blob; -} - -Blob *blob_copy(Blob *from, const char *errmsg) { - Blob *blob=blob_new(from->len, errmsg); - if (!blob) { - PyErr_SetString(PyExc_MemoryError, errmsg); - return NULL; - } - memcpy(blob->data, from->data, from->len); - return blob; -} - -void blob_free(Blob *blob) { - PyMem_Free(blob->data); - PyMem_Free(blob); -} - - -/* Python helpers. */ - -%} -%ignore PyObject_CheckBuffer; -%ignore PyObject_GetBuffer; -%ignore PyBuffer_Release; -%ignore m2_PyObject_AsReadBuffer; -%ignore m2_PyObject_AsReadBufferInt; -%ignore m2_PyObject_GetBufferInt; -%ignore m2_PyBuffer_Release; -%ignore m2_PyString_AsStringAndSizeInt; -%{ - -static int -m2_PyObject_AsReadBuffer(PyObject * obj, const void **buffer, - Py_ssize_t * buffer_len) -{ - int ret = 0; - Py_ssize_t len = 0; - Py_buffer view; - - if (PyObject_CheckBuffer(obj)) { - if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) == 0) { - *buffer = view.buf; - len = view.len; - } - } else { - if ((ret = PyObject_AsReadBuffer(obj, buffer, &len)) != 0) - return ret; - } - if (len > INT_MAX) { - m2_PyBuffer_Release(obj, &view); - PyErr_SetString(PyExc_ValueError, "object too large"); - return -1; - } - *buffer_len = len; - m2_PyBuffer_Release(obj, &view); - return 0; -} - -static int -m2_PyObject_AsReadBufferInt(PyObject * obj, const void **buffer, - int *buffer_len) -{ - int ret = 0; - Py_ssize_t len = 0; - - ret = m2_PyObject_AsReadBuffer(obj, buffer, &len); - *buffer_len = len; - return ret; -} - - - -static int m2_PyObject_GetBufferInt(PyObject *obj, Py_buffer *view, int flags) -{ - int ret; - - if (PyObject_CheckBuffer(obj)) - ret = PyObject_GetBuffer(obj, view, flags); - else { - const void *buf; - - ret = PyObject_AsReadBuffer(obj, &buf, &view->len); - if (ret == 0) - view->buf = (void *)buf; - } - if (ret) - return ret; - if (view->len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "object too large"); - m2_PyBuffer_Release(obj, view); - return -1; - } - - return 0; -} - -static BIGNUM* -m2_PyObject_AsBIGNUM(PyObject* value, PyObject* _py_exc) -{ - BIGNUM* bn; - const void* vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { - PyErr_SetString(_py_exc, ERR_reason_error_string(ERR_get_error())); - return NULL; - } - - return bn; -} - -static void m2_PyBuffer_Release(PyObject *obj, Py_buffer *view) -{ - if (PyObject_CheckBuffer(obj)) - PyBuffer_Release(view); - /* else do nothing, view->buf comes from PyObject_AsReadBuffer */ -} - -static int -m2_PyString_AsStringAndSizeInt(PyObject *obj, char **s, int *len) -{ - int ret; - Py_ssize_t len2; - - ret = PyBytes_AsStringAndSize(obj, s, &len2); - - if (ret) - return ret; - if (len2 > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "string too large"); - return -1; - } - *len = len2; - return 0; -} - -/* Works as PyFile_Name, but always returns a new object. */ -PyObject *m2_PyFile_Name(PyObject *pyfile) { - PyObject *out = NULL; -#if PY_MAJOR_VERSION >= 3 - out = PyObject_GetAttrString(pyfile, "name"); -#else - out = PyFile_Name(pyfile); - Py_XINCREF(out); -#endif - return out; -} - -/* Yes, __FUNCTION__ is a non-standard symbol, but it is supported by - * both gcc and MSVC. */ -#define m2_PyErr_Msg(type) m2_PyErr_Msg_Caller(type, (const char*) __FUNCTION__) - -static void m2_PyErr_Msg_Caller(PyObject *err_type, const char* caller) { - const char *err_reason; - const char *data; - int flags; - /* This max size of a (longer than ours) OpenSSL error string is hardcoded - * in OpenSSL's crypto/err/err_prn.c:ERR_print_errors_cb() */ - char err_msg[4096]; - unsigned long err_code = ERR_get_error_line_data(NULL, NULL, &data, &flags); - - if (err_code != 0) { - err_reason = ERR_reason_error_string(err_code); - if (data && (flags & ERR_TXT_STRING)) - snprintf(err_msg, sizeof(err_msg), "%s (%s)", err_reason, data); - else - snprintf(err_msg, sizeof(err_msg), "%s", err_reason); - - PyErr_SetString(err_type, err_msg); - } else { - PyErr_Format(err_type, "Unknown error in function %s.", caller); - } -} - - -/* C callbacks invoked by OpenSSL; these in turn call back into -Python. */ - -int ssl_verify_callback(int ok, X509_STORE_CTX *ctx) { - PyObject *argv, *ret; - PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; - PyObject *_x509=0, *_ssl_ctx=0; - SSL *ssl; - SSL_CTX *ssl_ctx; - X509 *x509; - int errnum, errdepth; - int cret; - int new_style_callback = 0, warning_raised_exception=0; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - ssl = (SSL *)X509_STORE_CTX_get_app_data(ctx); - - gilstate = PyGILState_Ensure(); - - if (PyMethod_Check(ssl_verify_cb_func)) { - PyObject *func; - PyCodeObject *code; - func = PyMethod_Function(ssl_verify_cb_func); - code = (PyCodeObject *) PyFunction_GetCode(func); - if (code && code->co_argcount == 3) { /* XXX Python internals */ - new_style_callback = 1; - } - } else if (PyFunction_Check(ssl_verify_cb_func)) { - PyCodeObject *code = (PyCodeObject *) PyFunction_GetCode(ssl_verify_cb_func); - if (code && code->co_argcount == 2) { /* XXX Python internals */ - new_style_callback = 1; - } - } else { - /* XXX There are lots of other callable types, but we will assume - * XXX that any other type of callable uses the new style callback, - * XXX although this is not entirely safe assumption. - */ - new_style_callback = 1; - } - - if (new_style_callback) { - PyObject *x509mod; - - x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); - _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); - - _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); - _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); - - _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); - - argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); - } else { - if (PyErr_Warn(PyExc_DeprecationWarning, "Old style callback, use cb_func(ok, store) instead")) { - warning_raised_exception = 1; - } - - x509 = X509_STORE_CTX_get_current_cert(ctx); - errnum = X509_STORE_CTX_get_error(ctx); - errdepth = X509_STORE_CTX_get_error_depth(ctx); - - ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); - ssl_ctx = SSL_get_SSL_CTX(ssl); - - _x509 = SWIG_NewPointerObj((void *)x509, SWIGTYPE_p_X509, 0); - _ssl_ctx = SWIG_NewPointerObj((void *)ssl_ctx, SWIGTYPE_p_SSL_CTX, 0); - argv = Py_BuildValue("(OOiii)", _ssl_ctx, _x509, errnum, errdepth, ok); - } - - if (!warning_raised_exception) { - ret = PyEval_CallObject(ssl_verify_cb_func, argv); - } else { - ret = 0; - } - - if (!ret) { - /* Got an exception in PyEval_CallObject(), let's fail verification - * to be safe. - */ - cret = 0; - } else { - /* FIXME This is possibly problematic if ret > MAXINT */ - cret = (int)PyLong_AsLong(ret); - } - Py_XDECREF(ret); - Py_XDECREF(argv); - if (new_style_callback) { - Py_XDECREF(_x509_store_ctx_inst); - Py_XDECREF(_x509_store_ctx_obj); - Py_XDECREF(_x509_store_ctx_swigptr); - Py_XDECREF(_klass); - } else { - Py_XDECREF(_x509); - Py_XDECREF(_ssl_ctx); - } - - PyGILState_Release(gilstate); - - return cret; -} - -int x509_store_verify_callback(int ok, X509_STORE_CTX *ctx) { - PyGILState_STATE gilstate; - PyObject *argv, *ret; - PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; - int cret; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - PyObject *x509mod; - - - gilstate = PyGILState_Ensure(); - - /* Below, handle only what is called 'new style callback' in ssl_verify_callback(). - TODO: does 'old style callback' exist any more? */ - x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); - _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); - _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); - _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); - - _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); - - argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); - - ret = PyEval_CallObject(x509_store_verify_cb_func, argv); - if (!ret) { - /* Got an exception in PyEval_CallObject(), let's fail verification - * to be safe. - */ - cret = 0; - } else { - cret = (int)PyInt_AsLong(ret); - } - - Py_XDECREF(ret); - Py_XDECREF(argv); - Py_XDECREF(_x509_store_ctx_inst); - Py_XDECREF(_x509_store_ctx_obj); - Py_XDECREF(_x509_store_ctx_swigptr); - Py_XDECREF(_klass); - - PyGILState_Release(gilstate); - return cret; -} - -void ssl_info_callback(const SSL *s, int where, int ret) { - PyObject *argv, *retval, *_SSL; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - gilstate = PyGILState_Ensure(); - - _SSL = SWIG_NewPointerObj((void *)s, SWIGTYPE_p_SSL, 0); - argv = Py_BuildValue("(iiO)", where, ret, _SSL); - - retval = PyEval_CallObject(ssl_info_cb_func, argv); - - Py_XDECREF(retval); - Py_XDECREF(argv); - Py_XDECREF(_SSL); - - PyGILState_Release(gilstate); -} - -DH *ssl_set_tmp_dh_callback(SSL *ssl, int is_export, int keylength) { - PyObject *argv, *ret, *_ssl; - DH *dh; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - gilstate = PyGILState_Ensure(); - - _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); - argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); - - ret = PyEval_CallObject(ssl_set_tmp_dh_cb_func, argv); - - if ((SWIG_ConvertPtr(ret, (void **)&dh, SWIGTYPE_p_DH, SWIG_POINTER_EXCEPTION | 0)) == -1) - dh = NULL; - Py_XDECREF(ret); - Py_XDECREF(argv); - Py_XDECREF(_ssl); - - PyGILState_Release(gilstate); - - return dh; -} - -RSA *ssl_set_tmp_rsa_callback(SSL *ssl, int is_export, int keylength) { - PyObject *argv, *ret, *_ssl; - RSA *rsa; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - gilstate = PyGILState_Ensure(); - - _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); - argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); - - ret = PyEval_CallObject(ssl_set_tmp_rsa_cb_func, argv); - - if ((SWIG_ConvertPtr(ret, (void **)&rsa, SWIGTYPE_p_RSA, SWIG_POINTER_EXCEPTION | 0)) == -1) - rsa = NULL; - Py_XDECREF(ret); - Py_XDECREF(argv); - Py_XDECREF(_ssl); - - PyGILState_Release(gilstate); - - return rsa; -} - -/* Universal callback for dh_generate_parameters, - * dsa_generate_parametersm, and rsa_generate_key */ -int bn_gencb_callback(int p, int n, BN_GENCB *gencb) { - PyObject *argv, *ret, *cbfunc; - - cbfunc = (PyObject *)BN_GENCB_get_arg(gencb); - argv = Py_BuildValue("(ii)", p, n); - ret = PyEval_CallObject(cbfunc, argv); - PyErr_Clear(); - Py_DECREF(argv); - Py_XDECREF(ret); - return 1; -} - -int passphrase_callback(char *buf, int num, int v, void *arg) { - int i; - Py_ssize_t len; - char *str; - PyObject *argv, *ret, *cbfunc; - PyGILState_STATE gilstate; - - gilstate = PyGILState_Ensure(); - cbfunc = (PyObject *)arg; - argv = Py_BuildValue("(i)", v); - /* PyEval_CallObject sets exception, if needed. */ - ret = PyEval_CallObject(cbfunc, argv); - Py_DECREF(argv); - if (ret == NULL) { - PyGILState_Release(gilstate); - return -1; - } - - if (!PyBytes_Check(ret)) { - PyErr_SetString(PyExc_RuntimeError, - "Result of callback is not bytes()."); - Py_DECREF(ret); - PyGILState_Release(gilstate); - return -1; - } - if ((len = PyBytes_Size(ret)) > num) - len = num; - str = PyBytes_AsString(ret); - - for (i = 0; i < len; i++) - buf[i] = str[i]; - Py_DECREF(ret); - PyGILState_Release(gilstate); - return len; -} -%} - -%inline %{ - -void lib_init() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L - SSLeay_add_all_algorithms(); - ERR_load_ERR_strings(); -#endif -} - -/* Bignum routines that aren't not numerous enough to -warrant a separate file. */ - -PyObject *bn_to_mpi(const BIGNUM *bn) { - int len = 0; - unsigned char *mpi; - PyObject *pyo; - - len = BN_bn2mpi(bn, NULL); - if (!(mpi=(unsigned char *)PyMem_Malloc(len))) { - m2_PyErr_Msg(PyExc_MemoryError); - return NULL; - } - len=BN_bn2mpi(bn, mpi); - - pyo=PyBytes_FromStringAndSize((const char *)mpi, len); - - PyMem_Free(mpi); - return pyo; -} - -const BIGNUM *mpi_to_bn(PyObject *value) { - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - return BN_mpi2bn(vbuf, vlen, NULL); -} - -PyObject *bn_to_bin(BIGNUM *bn) { - int len = 0; - unsigned char *bin; - PyObject *pyo; - - len = BN_num_bytes(bn); - if (!(bin=(unsigned char *)PyMem_Malloc(len))) { - PyErr_SetString(PyExc_MemoryError, "bn_to_bin"); - return NULL; - } - BN_bn2bin(bn, bin); - - pyo=PyBytes_FromStringAndSize((const char *)bin, len); - - PyMem_Free(bin); - return pyo; -} - -const BIGNUM *bin_to_bn(PyObject *value) { - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - return BN_bin2bn(vbuf, vlen, NULL); -} - -PyObject *bn_to_hex(BIGNUM *bn) { - char *hex; - PyObject *pyo; - Py_ssize_t len = 0; - - hex = BN_bn2hex(bn); - if (!hex) { - m2_PyErr_Msg(PyExc_RuntimeError); - OPENSSL_free(hex); - return NULL; - } - len = strlen(hex); - - pyo=PyBytes_FromStringAndSize(hex, len); - - OPENSSL_free(hex); - return pyo; -} - -BIGNUM *hex_to_bn(PyObject *value) { - const void *vbuf; - Py_ssize_t vlen = 0; - BIGNUM *bn; - Py_buffer view; - - if (PyObject_CheckBuffer(value)) { - if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { - vbuf = view.buf; - vlen = view.len; - } - } - else { - if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) - return NULL; - } - - if ((bn=BN_new())==NULL) { - m2_PyBuffer_Release(value, &view); - PyErr_SetString(PyExc_MemoryError, "hex_to_bn"); - return NULL; - } - if (BN_hex2bn(&bn, (const char *)vbuf) <= 0) { - m2_PyBuffer_Release(value, &view); - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return NULL; - } - m2_PyBuffer_Release(value, &view); - return bn; -} - -BIGNUM *dec_to_bn(PyObject *value) { - const void *vbuf; - Py_ssize_t vlen = 0; - BIGNUM *bn; - Py_buffer view; - - if (PyObject_CheckBuffer(value)) { - if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { - vbuf = view.buf; - vlen = view.len; - } - } - else { - if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) - return NULL; - } - - if ((bn=BN_new())==NULL) { - m2_PyBuffer_Release(value, &view); - PyErr_SetString(PyExc_MemoryError, "dec_to_bn"); - return NULL; - } - if ((BN_dec2bn(&bn, (const char *)vbuf) <= 0)) { - m2_PyBuffer_Release(value, &view); - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return NULL; - } - m2_PyBuffer_Release(value, &view); - return bn; -} -%} - - -/* Various useful typemaps. */ - -%typemap(in) Blob * { - Py_ssize_t len = 0; - - if (!PyBytes_Check($input)) { - PyErr_SetString(PyExc_TypeError, "expected PyString"); - return NULL; - } - len=PyBytes_Size($input); - - if (len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "object too large"); - return NULL; - } - $1=(Blob *)PyMem_Malloc(sizeof(Blob)); - if (!$1) { - PyErr_SetString(PyExc_MemoryError, "malloc Blob"); - return NULL; - } - - $1->data=(unsigned char *)PyBytes_AsString($input); - - $1->len=len; -} - -%typemap(out) Blob * { - if ($1==NULL) { - Py_INCREF(Py_None); - $result=Py_None; - } else { - - $result=PyBytes_FromStringAndSize((const char *)$1->data, $1->len); - - PyMem_Free($1->data); - PyMem_Free($1); - } -} - -%typemap(in) PyObject *pyfunc { - if (!PyCallable_Check($input)) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - $1=$input; -} - -%typemap(in) PyObject *pyblob { - if (!PyBytes_Check($input)) { - - PyErr_SetString(PyExc_TypeError, "expected PyString"); - return NULL; - } - $1=$input; -} - -%typemap(in) PyObject * { - $1=$input; -} - -%typemap(out) PyObject * { - $result=$1; -} - -%typemap(out) int { - $result=PyLong_FromLong($1); - if (PyErr_Occurred()) SWIG_fail; -} - -/* Pointer checks. */ - -%apply Pointer NONNULL { Blob * }; - - -/* A bunch of "straight-thru" functions. */ - -%rename(err_print_errors) ERR_print_errors; -%threadallow ERR_print_errors; -extern void ERR_print_errors(BIO *); -%rename(err_get_error) ERR_get_error; -extern unsigned long ERR_get_error(void); -%rename(err_peek_error) ERR_peek_error; -extern unsigned long ERR_peek_error(void); -%rename(err_lib_error_string) ERR_lib_error_string; -extern const char *ERR_lib_error_string(unsigned long); -%rename(err_func_error_string) ERR_func_error_string; -extern const char *ERR_func_error_string(unsigned long); -%rename(err_reason_error_string) ERR_reason_error_string; -extern const char *ERR_reason_error_string(unsigned long); diff --git a/SWIG/_lib11_compat.i b/SWIG/_lib11_compat.i deleted file mode 100644 index 1ec42dd..0000000 --- a/SWIG/_lib11_compat.i +++ /dev/null @@ -1,458 +0,0 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -%{ -#if OPENSSL_VERSION_NUMBER < 0x10100000L - -#include -#include - -# define OPENSSL_zalloc(num) \ - CRYPTO_zalloc(num, __FILE__, __LINE__) - -static void *CRYPTO_zalloc(size_t num, const char *file, int line) -{ - void *ret = CRYPTO_malloc(num, file, line); - if (ret != NULL) - memset(ret, 0, num); - return ret; -} - -#include - -#ifndef BN_F_BN_GENCB_NEW -# define BN_F_BN_GENCB_NEW 143 -#endif - -# define BN_GENCB_get_arg(gencb) ((gencb)->arg) - -BN_GENCB *BN_GENCB_new(void) -{ - BN_GENCB *ret; - - if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) { - BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE); - return (NULL); - } - - return ret; -} - -void BN_GENCB_free(BN_GENCB *cb) -{ - if (cb == NULL) - return; - OPENSSL_free(cb); -} - - -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) -{ - /* If the fields n and e in r are NULL, the corresponding input - * parameters MUST be non-NULL for n and e. d may be - * left NULL (in case only the public key is used). - */ - if ((r->n == NULL && n == NULL) - || (r->e == NULL && e == NULL)) - return 0; - - if (n != NULL) { - BN_free(r->n); - r->n = n; - } - if (e != NULL) { - BN_free(r->e); - r->e = e; - } - if (d != NULL) { - BN_free(r->d); - r->d = d; - } - - return 1; -} - -int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) -{ - /* If the fields p and q in r are NULL, the corresponding input - * parameters MUST be non-NULL. - */ - if ((r->p == NULL && p == NULL) - || (r->q == NULL && q == NULL)) - return 0; - - if (p != NULL) { - BN_free(r->p); - r->p = p; - } - if (q != NULL) { - BN_free(r->q); - r->q = q; - } - - return 1; -} - -int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) -{ - /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input - * parameters MUST be non-NULL. - */ - if ((r->dmp1 == NULL && dmp1 == NULL) - || (r->dmq1 == NULL && dmq1 == NULL) - || (r->iqmp == NULL && iqmp == NULL)) - return 0; - - if (dmp1 != NULL) { - BN_free(r->dmp1); - r->dmp1 = dmp1; - } - if (dmq1 != NULL) { - BN_free(r->dmq1); - r->dmq1 = dmq1; - } - if (iqmp != NULL) { - BN_free(r->iqmp); - r->iqmp = iqmp; - } - - return 1; -} - -void RSA_get0_key(const RSA *r, - const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) -{ - if (n != NULL) - *n = r->n; - if (e != NULL) - *e = r->e; - if (d != NULL) - *d = r->d; -} - -void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) -{ - if (p != NULL) - *p = r->p; - if (q != NULL) - *q = r->q; -} - -void RSA_get0_crt_params(const RSA *r, - const BIGNUM **dmp1, const BIGNUM **dmq1, - const BIGNUM **iqmp) -{ - if (dmp1 != NULL) - *dmp1 = r->dmp1; - if (dmq1 != NULL) - *dmq1 = r->dmq1; - if (iqmp != NULL) - *iqmp = r->iqmp; -} - -void DSA_get0_pqg(const DSA *d, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) -{ - if (p != NULL) - *p = d->p; - if (q != NULL) - *q = d->q; - if (g != NULL) - *g = d->g; -} - -int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) -{ - /* If the fields p, q and g in d are NULL, the corresponding input - * parameters MUST be non-NULL. - */ - if ((d->p == NULL && p == NULL) - || (d->q == NULL && q == NULL) - || (d->g == NULL && g == NULL)) - return 0; - - if (p != NULL) { - BN_free(d->p); - d->p = p; - } - if (q != NULL) { - BN_free(d->q); - d->q = q; - } - if (g != NULL) { - BN_free(d->g); - d->g = g; - } - - return 1; -} - -void DSA_get0_key(const DSA *d, - const BIGNUM **pub_key, const BIGNUM **priv_key) -{ - if (pub_key != NULL) - *pub_key = d->pub_key; - if (priv_key != NULL) - *priv_key = d->priv_key; -} - -int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) -{ - /* If the field pub_key in d is NULL, the corresponding input - * parameters MUST be non-NULL. The priv_key field may - * be left NULL. - */ - if (d->pub_key == NULL && pub_key == NULL) - return 0; - - if (pub_key != NULL) { - BN_free(d->pub_key); - d->pub_key = pub_key; - } - if (priv_key != NULL) { - BN_free(d->priv_key); - d->priv_key = priv_key; - } - - return 1; -} - -void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) -{ - if (pr != NULL) - *pr = sig->r; - if (ps != NULL) - *ps = sig->s; -} - -int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) -{ - if (r == NULL || s == NULL) - return 0; - BN_clear_free(sig->r); - BN_clear_free(sig->s); - sig->r = r; - sig->s = s; - return 1; -} - -void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) -{ - if (pr != NULL) - *pr = sig->r; - if (ps != NULL) - *ps = sig->s; -} - -int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) -{ - if (r == NULL || s == NULL) - return 0; - BN_clear_free(sig->r); - BN_clear_free(sig->s); - sig->r = r; - sig->s = s; - return 1; -} - -void DH_get0_pqg(const DH *dh, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) -{ - if (p != NULL) - *p = dh->p; - if (q != NULL) - *q = dh->q; - if (g != NULL) - *g = dh->g; -} - -int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) -{ - /* If the fields p and g in d are NULL, the corresponding input - * parameters MUST be non-NULL. q may remain NULL. - */ - if ((dh->p == NULL && p == NULL) - || (dh->g == NULL && g == NULL)) - return 0; - - if (p != NULL) { - BN_free(dh->p); - dh->p = p; - } - if (q != NULL) { - BN_free(dh->q); - dh->q = q; - } - if (g != NULL) { - BN_free(dh->g); - dh->g = g; - } - - if (q != NULL) { - dh->length = BN_num_bits(q); - } - - return 1; -} - -void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) -{ - if (pub_key != NULL) - *pub_key = dh->pub_key; - if (priv_key != NULL) - *priv_key = dh->priv_key; -} - -int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) -{ - /* If the field pub_key in dh is NULL, the corresponding input - * parameters MUST be non-NULL. The priv_key field may - * be left NULL. - */ - if (dh->pub_key == NULL && pub_key == NULL) - return 0; - - if (pub_key != NULL) { - BN_free(dh->pub_key); - dh->pub_key = pub_key; - } - if (priv_key != NULL) { - BN_free(dh->priv_key); - dh->priv_key = priv_key; - } - - return 1; -} - -int DH_set_length(DH *dh, long length) -{ - dh->length = length; - return 1; -} - -const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx) -{ - return ctx->iv; -} - -unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx) -{ - return ctx->iv; -} - -EVP_MD_CTX *EVP_MD_CTX_new(void) -{ - return OPENSSL_zalloc(sizeof(EVP_MD_CTX)); -} - -void EVP_MD_CTX_free(EVP_MD_CTX *ctx) -{ - EVP_MD_CTX_cleanup(ctx); - OPENSSL_free(ctx); -} - -int RSA_size(const RSA* rsa) { - /* BIGNUM* n = NULL; - RSA_get0_key(rsa, n, NULL, NULL); */ - return BN_num_bytes(rsa->n); -} - -RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth) -{ - RSA_METHOD *ret; - - ret = OPENSSL_malloc(sizeof(RSA_METHOD)); - - if (ret != NULL) { - memcpy(ret, meth, sizeof(*meth)); - ret->name = OPENSSL_strdup(meth->name); - if (ret->name == NULL) { - OPENSSL_free(ret); - return NULL; - } - } - - return ret; -} - -int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) -{ - char *tmpname; - - tmpname = OPENSSL_strdup(name); - if (tmpname == NULL) { - return 0; - } - - OPENSSL_free((char *)meth->name); - meth->name = tmpname; - - return 1; -} - -int RSA_meth_set_priv_enc(RSA_METHOD *meth, - int (*priv_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - meth->rsa_priv_enc = priv_enc; - return 1; -} - -int RSA_meth_set_priv_dec(RSA_METHOD *meth, - int (*priv_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - meth->rsa_priv_dec = priv_dec; - return 1; -} - -int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa)) -{ - meth->finish = finish; - return 1; -} - -void RSA_meth_free(RSA_METHOD *meth) -{ - if (meth != NULL) { - OPENSSL_free((char *)meth->name); - OPENSSL_free(meth); - } -} - -int RSA_bits(const RSA *r) -{ - return (BN_num_bits(r->n)); -} - -RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) -{ - if (pkey->type != EVP_PKEY_RSA) { - return NULL; - } - return pkey->pkey.rsa; -} - -int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, - size_t *pderlen) -{ - /* Make sure encoding is valid */ - if (i2d_X509_NAME(nm, NULL) <= 0) - return 0; - if (pder != NULL) - *pder = (unsigned char *)nm->bytes->data; - if (pderlen != NULL) - *pderlen = nm->bytes->length; - return 1; -} - -#endif /* OPENSSL_VERSION_NUMBER */ -%} diff --git a/SWIG/_m2crypto.def b/SWIG/_m2crypto.def deleted file mode 100644 index 3e9d5bc..0000000 --- a/SWIG/_m2crypto.def +++ /dev/null @@ -1,2 +0,0 @@ -EXPORTS -init_m2crypto diff --git a/SWIG/_m2crypto.i b/SWIG/_m2crypto.i deleted file mode 100644 index e300a10..0000000 --- a/SWIG/_m2crypto.i +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved. - * - * Portions created by Open Source Applications Foundation (OSAF) are - * Copyright (C) 2004-2006 OSAF. All Rights Reserved. - * - * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. - * - */ - -%module(threads=1) m2crypto -/* We really don't need threadblock (PyGILState_Ensure() etc.) anywhere. - Disable threadallow as well, only enable it for operations likely to - block. */ -%nothreadblock; -%nothreadallow; - -#if SWIG_VERSION >= 0x030000 -#define __WCHAR_MAX__ __WCHAR_MAX -#define __WCHAR_MIN__ __WCHAR_MIN -#endif -/* https://gitlab.com/m2crypto/m2crypto/issues/246 */ -%ignore WCHAR_MAX; -%ignore WCHAR_MIN; -/* http://swig.10945.n7.nabble.com/SWIG-AsVal-wchar-t-error-td2264.html */ -%{ -int SWIG_AsVal_wchar_t(PyObject *p, wchar_t *c) { return SWIG_OK; } -PyObject *SWIG_From_wchar_t(wchar_t c) { return SWIG_Py_Void(); } -%} - -%{ -#ifdef _WIN32 -#define _WINSOCKAPI_ -#include -#include -#pragma comment(lib, "Ws2_32") -typedef unsigned __int64 uint64_t; -#endif -%} - -%{ -#if defined __GNUC__ && __GNUC__ < 5 -#pragma GCC diagnostic ignored "-Wunused-label" -#pragma GCC diagnostic warning "-Wstrict-prototypes" -#endif - -#include -#include -#include <_lib.h> -#include -#include - -#include "compile.h" - -static PyObject *ssl_verify_cb_func; -static PyObject *ssl_info_cb_func; -static PyObject *ssl_set_tmp_dh_cb_func; -static PyObject *ssl_set_tmp_rsa_cb_func; -static PyObject *x509_store_verify_cb_func; -%} - -%include - -/* Bring in STACK_OF macro definition */ -#ifdef _WIN32 -%include -#endif -%include - -/* Bring in LHASH_OF macro definition */ -/* XXX Can't include lhash.h where LHASH_OF is defined, because it includes - XXX stdio.h etc. which we fail to include. So we have to (re)define - XXX LHASH_OF here instead. -%include -*/ -#if OPENSSL_VERSION_NUMBER >= 0x10000000L -#define LHASH_OF(type) struct lhash_st_##type -#endif - - -%include constraints.i -%include _threads.i -%include _lib.i -%include _bio.i -%include _bn.i -%include _rand.i -%include _evp.i -%include _aes.i -%include _rc4.i -%include _dh.i -%include _rsa.i -%include _dsa.i -%include _ssl.i -%include _x509.i -%include _asn1.i -%include _pkcs7.i -%include _util.i -%include _ec.i -%include _engine.i -%include _objects.i - -#ifdef SWIG_VERSION -%constant int encrypt = 1; -%constant int decrypt = 0; -#endif - diff --git a/SWIG/_m2crypto_wrap.c b/SWIG/_m2crypto_wrap.c deleted file mode 100644 index 6ed5429..0000000 --- a/SWIG/_m2crypto_wrap.c +++ /dev/null @@ -1,34500 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.2 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - - -#ifndef SWIGPYTHON -#define SWIGPYTHON -#endif - -#define SWIG_PYTHON_THREADS -#define SWIG_PYTHON_DIRECTOR_NO_VTABLE -#define SWIGPYTHON_BUILTIN - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if defined(__GNUC__) -# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ -#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) -# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 -#endif - -/* Intel's compiler complains if a variable which was never initialised is - * cast to void, which is a common idiom which we use to indicate that we - * are aware a variable isn't used. So we just silence that warning. - * See: https://github.com/swig/swig/issues/192 for more discussion. - */ -#ifdef __INTEL_COMPILER -# pragma warning disable 592 -#endif - - -#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) -/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ -# include -#endif - -#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) -/* Use debug wrappers with the Python release dll */ -# undef _DEBUG -# include -# define _DEBUG 1 -#else -# include -#endif - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic C API SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. - - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 -#define SWIG_POINTER_NO_NULL 0x4 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return an integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old versions of SWIG, code such as the following was usually written: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - which is the same really, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() -*/ - -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast(r) (r) -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCmp(const char *nb, const char *tb) { - int equiv = 1; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (equiv != 0 && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = SWIG_TypeNameComp(nb, ne, tb, te); - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; -} - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - size_t l = 0; - size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - const unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - unsigned char *u = (unsigned char *) ptr; - const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - char d = *(c++); - unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = (unsigned char)((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = (unsigned char)((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (unsigned char)(d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (unsigned char)(d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - - -/* Compatibility macros for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) -#define PyString_Check(name) PyBytes_Check(name) -#define PyString_FromString(x) PyUnicode_FromString(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) -#define PyString_AsString(str) PyBytes_AsString(str) -#define PyString_Size(str) PyBytes_Size(str) -#define PyString_InternFromString(key) PyUnicode_InternFromString(key) -#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE -#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) -#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) - -#endif - -#ifndef Py_TYPE -# define Py_TYPE(op) ((op)->ob_type) -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - - -/* Warning: This function will allocate a new string in Python 3, - * so please call SWIG_Python_str_DelForPy3(x) to free the space. - */ -SWIGINTERN char* -SWIG_Python_str_AsChar(PyObject *str) -{ -#if PY_VERSION_HEX >= 0x03030000 - return (char *)PyUnicode_AsUTF8(str); -#elif PY_VERSION_HEX >= 0x03000000 - char *newstr = 0; - str = PyUnicode_AsUTF8String(str); - if (str) { - char *cstr; - Py_ssize_t len; - if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) { - newstr = (char *) malloc(len+1); - if (newstr) - memcpy(newstr, cstr, len+1); - } - Py_XDECREF(str); - } - return newstr; -#else - return PyString_AsString(str); -#endif -} - -#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000 -# define SWIG_Python_str_DelForPy3(x) -#else -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) -#endif - - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} - -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user -// interface files check for it. -# define SWIGPY_USE_CAPSULE -# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) - -#if PY_VERSION_HEX < 0x03020000 -#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) -#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) -#define Py_hash_t long -#endif - -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - const char *tmp = SWIG_Python_str_AsChar(old_str); - PyErr_Clear(); - Py_XINCREF(type); - if (tmp) - PyErr_Format(type, "%s %s", tmp, mesg); - else - PyErr_Format(type, "%s", mesg); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} - -SWIGRUNTIME int -SWIG_Python_TypeErrorOccurred(PyObject *obj) -{ - PyObject *error; - if (obj) - return 0; - error = PyErr_Occurred(); - return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); -} - -SWIGRUNTIME void -SWIG_Python_RaiseOrModifyTypeError(const char *message) -{ - if (SWIG_Python_TypeErrorOccurred(NULL)) { - /* Use existing TypeError to preserve stacktrace and enhance with given message */ - PyObject *newvalue; - PyObject *type = NULL, *value = NULL, *traceback = NULL; - PyErr_Fetch(&type, &value, &traceback); -#if PY_VERSION_HEX >= 0x03000000 - newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); -#else - newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); -#endif - Py_XDECREF(value); - PyErr_Restore(type, newvalue, traceback); - } else { - /* Raise TypeError using given message */ - PyErr_SetString(PyExc_TypeError, message); - } -} - -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# define SWIG_PYTHON_USE_GIL -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif - -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - const char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - -#ifdef __cplusplus -} -#endif - - -/* ----------------------------------------------------------------------------- - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ -# error "This version of SWIG only supports Python >= 2.7" -#endif - -#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 -# error "This version of SWIG only supports Python 3 >= 3.2" -#endif - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) - -#ifdef SWIGPYTHON_BUILTIN -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) -#else -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) -#endif - -#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) - -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -#if defined(SWIGPYTHON_BUILTIN) - -SWIGINTERN void -SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { - PyObject *s = PyString_InternFromString(key); - PyList_Append(seq, s); - Py_DECREF(s); -} - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { - PyDict_SetItemString(d, name, obj); - Py_DECREF(obj); - if (public_interface) - SwigPyBuiltin_AddPublicSymbol(public_interface, name); -} - -#else - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, name, obj); - Py_DECREF(obj); -} - -#endif - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -} - -/* Unpack the argument tuple */ - -SWIGINTERN Py_ssize_t -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - if (min <= 1 && max >= 1) { - Py_ssize_t i; - objs[0] = args; - for (i = 1; i < max; ++i) { - objs[i] = 0; - } - return 2; - } - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - Py_ssize_t i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -SWIGINTERN int -SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { - int no_kwargs = 1; - if (kwargs) { - assert(PyDict_Check(kwargs)); - if (PyDict_Size(kwargs) > 0) { - PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); - no_kwargs = 0; - } - } - return no_kwargs; -} - -/* A functor is a function object with one single object argument */ -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) -#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) - -#ifdef __cplusplus -extern "C" { -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* SwigPyClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; - PyTypeObject *pytype; -} SwigPyClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - int fail = data ? data->implicitconv : 0; - if (fail) - PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); - return fail; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { - data->newraw = PyObject_GetAttrString(data->klass, "__new__"); - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); - data->delargs = !(flags & (METH_O)); - } else { - data->delargs = 0; - } - data->implicitconv = 0; - data->pytype = 0; - return data; - } -} - -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData *data) { - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== SwigPyObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -#ifdef SWIGPYTHON_BUILTIN - PyObject *dict; -#endif -} SwigPyObject; - - -#ifdef SWIGPYTHON_BUILTIN - -SWIGRUNTIME PyObject * -SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - - if (!sobj->dict) - sobj->dict = PyDict_New(); - - Py_INCREF(sobj->dict); - return sobj->dict; -} - -#endif - -SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { - PyObject *ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else - res = PyString_Format(ofmt,args); -#endif - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) -{ - return SwigPyObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) -{ - return SwigPyObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_repr(SwigPyObject *v) -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); - if (v->next) { - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -# if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; -# else - PyString_ConcatAndDel(&repr,nrep); -# endif - } - return repr; -} - -/* We need a version taking two PyObject* parameters so it's a valid - * PyCFunction to use in swigobject_methods[]. */ -SWIGRUNTIME PyObject * -SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) -{ - return SwigPyObject_repr((SwigPyObject*)v); -} - -SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -/* Added for Python 3.x, would it also be useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res; - if( op != Py_EQ && op != Py_NE ) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); - return res; -} - - -SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); - -#ifdef SWIGPYTHON_BUILTIN -static swig_type_info *SwigPyObject_stype = 0; -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - SwigPyClientData *cd; - assert(SwigPyObject_stype); - cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; - assert(cd); - assert(cd->pytype); - return cd->pytype; -} -#else -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); - return type; -} -#endif - -SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { -#ifdef SWIGPYTHON_BUILTIN - PyTypeObject *target_tp = SwigPyObject_type(); - if (PyType_IsSubtype(op->ob_type, target_tp)) - return 1; - return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); -#else - return (Py_TYPE(op) == SwigPyObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); -#endif -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - - /* PyObject_CallFunction() has the potential to silently drop - the active exception. In cases of unnamed temporary - variable or where we just finished iterating over a generator - StopIteration will be active right now, and this needs to - remain true upon return from SwigPyObject_dealloc. So save - and restore. */ - - PyObject *type = NULL, *value = NULL, *traceback = NULL; - PyErr_Fetch(&type, &value, &traceback); - - if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - if (!res) - PyErr_WriteUnraisable(destroy); - - PyErr_Restore(type, value, traceback); - - Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (!SwigPyObject_Check(next)) { - PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; - if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { - return NULL; - } else { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } - } - return obj; - } -} - -static PyMethodDef -swigobject_methods[] = { - {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, - {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, - {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, - {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, - {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, - {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, - {0, 0, 0, 0} -}; - -SWIGRUNTIME PyTypeObject* -SwigPyObject_TypeOnce(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ -#else - 0, /*nb_reserved*/ -#endif - (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ -#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#else - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#endif - }; - - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - "SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ -#else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - swigpyobject_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpyobject_type) < 0) - return NULL; - } - return &swigpyobject_type; -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) -{ - SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} SwigPyPacked; - -SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } -} - -SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { - return ((op)->ob_type == SwigPyPacked_TypeOnce()) - || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); -} - -SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) -{ - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_TypeOnce(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - "SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - swigpypacked_type = tmp; - type_init = 1; - if (PyType_Ready(&swigpypacked_type) < 0) - return NULL; - } - return &swigpypacked_type; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -static PyObject *Swig_This_global = NULL; - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - if (Swig_This_global == NULL) - Swig_This_global = SWIG_Python_str_FromChar("this"); - return Swig_This_global; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - PyObject *obj; - - if (SwigPyObject_Check(pyobj)) - return (SwigPyObject *) pyobj; - -#ifdef SWIGPYTHON_BUILTIN - (void)obj; -# ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - pyobj = PyWeakref_GET_OBJECT(pyobj); - if (pyobj && SwigPyObject_Check(pyobj)) - return (SwigPyObject*) pyobj; - } -# endif - return NULL; -#else - - obj = 0; - -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; -#endif -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - int res; - SwigPyObject *sobj; - int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; - - if (!obj) - return SWIG_ERROR; - if (obj == Py_None && !implicit_conv) { - if (ptr) - *ptr = 0; - return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; - } - - res = SWIG_ERROR; - - sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - res = SWIG_OK; - } else { - if (implicit_conv) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; - } - } - } - return res; -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - swig_cast_info *tc; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) - return SWIG_ERROR; - tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - return SWIG_OK; - } -} - -/* Convert a packed pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, without calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) -{ - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { - Py_DECREF(inst); - inst = 0; - } -#endif - } - } else { -#if PY_VERSION_HEX >= 0x03000000 - PyObject *empty_args = PyTuple_New(0); - if (empty_args) { - PyObject *empty_kwargs = PyDict_New(); - if (empty_kwargs) { - inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); - Py_DECREF(empty_kwargs); - if (inst) { - if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { - Py_DECREF(inst); - inst = 0; - } else { - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; - } - } - } - Py_DECREF(empty_args); - } -#else - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } -#endif - } - return inst; -} - -SWIGRUNTIME int -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - return PyDict_SetItem(dict, SWIG_This(), swig_this); - } -#endif - return PyObject_SetAttr(inst, SWIG_This(), swig_this); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { - return NULL; - } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - SwigPyObject_append((PyObject*) sthis, obj[1]); - } else { - if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) - return NULL; - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { - SwigPyClientData *clientdata; - PyObject * robj; - int own; - - if (!ptr) - return SWIG_Py_Void(); - - clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - if (clientdata && clientdata->pytype) { - SwigPyObject *newobj; - if (flags & SWIG_BUILTIN_TP_INIT) { - newobj = (SwigPyObject*) self; - if (newobj->ptr) { - PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); - while (newobj->next) - newobj = (SwigPyObject *) newobj->next; - newobj->next = next_self; - newobj = (SwigPyObject *)next_self; -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif - } - } else { - newobj = PyObject_New(SwigPyObject, clientdata->pytype); -#ifdef SWIGPYTHON_BUILTIN - newobj->dict = 0; -#endif - } - if (newobj) { - newobj->ptr = ptr; - newobj->ty = type; - newobj->own = own; - newobj->next = 0; - return (PyObject*) newobj; - } - return SWIG_Py_Void(); - } - - assert(!(flags & SWIG_BUILTIN_TP_INIT)); - - robj = SwigPyObject_New(ptr, type, own); - if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - Py_DECREF(robj); - robj = inst; - } - return robj; -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -SWIGRUNTIME void -SWIG_Python_DestroyModule(PyObject *obj) -{ - swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - if (data) SwigPyClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); - Swig_This_global = NULL; -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { -#if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); -#else - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); -#endif - PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); - } else { - swig_module_info *swig_module = SWIG_GetModule(0); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCapsule_New((void*) descriptor, NULL, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - const char *tmp = SWIG_Python_str_AsChar(old_str); - const char *errmesg = tmp ? tmp : "Invalid error message"; - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, errmesg); - } else { - PyErr_Format(type, "%s %s", errmesg, mesg); - } - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) -{ - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : ""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - SWIG_Python_str_DelForPy3(cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); -#if SWIG_POINTER_EXCEPTION - if (flags) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } -#endif - } - return result; -} - -#ifdef SWIGPYTHON_BUILTIN -SWIGRUNTIME int -SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { - PyTypeObject *tp = obj->ob_type; - PyObject *descr; - PyObject *encoded_name; - descrsetfunc f; - int res = -1; - -# ifdef Py_USING_UNICODE - if (PyString_Check(name)) { - name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); - if (!name) - return -1; - } else if (!PyUnicode_Check(name)) -# else - if (!PyString_Check(name)) -# endif - { - PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); - return -1; - } else { - Py_INCREF(name); - } - - if (!tp->tp_dict) { - if (PyType_Ready(tp) < 0) - goto done; - } - - descr = _PyType_Lookup(tp, name); - f = NULL; - if (descr != NULL) - f = descr->ob_type->tp_descr_set; - if (!f) { - if (PyString_Check(name)) { - encoded_name = name; - Py_INCREF(name); - } else { - encoded_name = PyUnicode_AsUTF8String(name); - if (!encoded_name) - return -1; - } - PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); - Py_DECREF(encoded_name); - } else { - res = f(descr, obj, value); - } - - done: - Py_DECREF(name); - return res; -} -#endif - - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -SWIGINTERN Py_hash_t -SwigPyObject_hash(PyObject *obj) { - SwigPyObject *sobj = (SwigPyObject *)obj; - void *ptr = sobj->ptr; - return (Py_hash_t)ptr; -} - -SWIGINTERN Py_hash_t -SWIG_PyNumber_AsPyHash(PyObject *obj) { - Py_hash_t result = -1; -#if PY_VERSION_HEX < 0x03020000 - if (PyInt_Check(obj)) - result = PyInt_AsLong(obj); - else if (PyLong_Check(obj)) - result = PyLong_AsLong(obj); -#else - if (PyNumber_Check(obj)) - result = PyNumber_AsSsize_t(obj, NULL); -#endif - else - PyErr_Format(PyExc_TypeError, "Wrong type for hash function"); - return PyErr_Occurred() ? -1 : result; -} - -SWIGINTERN int -SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) { - PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name); - return -1; -} - -SWIGINTERN void -SwigPyBuiltin_BadDealloc(PyObject *obj) { - SwigPyObject *sobj = (SwigPyObject *)obj; - if (sobj->own) { - PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name); - } -} - -typedef struct { - PyCFunction get; - PyCFunction set; -} SwigPyGetSet; - -SWIGINTERN PyObject * -SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) { - SwigPyGetSet *getset; - PyObject *tuple, *result; - if (!closure) - return SWIG_Py_Void(); - getset = (SwigPyGetSet *)closure; - if (!getset->get) - return SWIG_Py_Void(); - tuple = PyTuple_New(0); - assert(tuple); - result = (*getset->get)(obj, tuple); - Py_DECREF(tuple); - return result; -} - -SWIGINTERN PyObject * -SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) { - SwigPyGetSet *getset; - PyObject *result; - if (!closure) - return SWIG_Py_Void(); - getset = (SwigPyGetSet *)closure; - if (!getset->get) - return SWIG_Py_Void(); - result = (*getset->get)(obj, NULL); - return result; -} - -SWIGINTERN int -SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { - SwigPyGetSet *getset; - PyObject *tuple, *result; - if (!closure) { - PyErr_Format(PyExc_TypeError, "Missing getset closure"); - return -1; - } - getset = (SwigPyGetSet *)closure; - if (!getset->set) { - PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); - return -1; - } - tuple = PyTuple_New(1); - assert(tuple); - Py_INCREF(val); - PyTuple_SET_ITEM(tuple, 0, val); - result = (*getset->set)(obj, tuple); - Py_DECREF(tuple); - Py_XDECREF(result); - return result ? 0 : -1; -} - -SWIGINTERN int -SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) { - SwigPyGetSet *getset; - PyObject *result; - if (!closure) { - PyErr_Format(PyExc_TypeError, "Missing getset closure"); - return -1; - } - getset = (SwigPyGetSet *)closure; - if (!getset->set) { - PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); - return -1; - } - result = (*getset->set)(obj, val); - Py_XDECREF(result); - return result ? 0 : -1; -} - -SWIGINTERN void -SwigPyStaticVar_dealloc(PyDescrObject *descr) { - PyObject_GC_UnTrack(descr); - Py_XDECREF(PyDescr_TYPE(descr)); - Py_XDECREF(PyDescr_NAME(descr)); - PyObject_GC_Del(descr); -} - -SWIGINTERN PyObject * -SwigPyStaticVar_repr(PyGetSetDescrObject *descr) { -#if PY_VERSION_HEX >= 0x03000000 - - return PyUnicode_FromFormat("", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); -#else - return PyString_FromFormat("", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); -#endif -} - -SWIGINTERN int -SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) { - PyDescrObject *descr; - descr = (PyDescrObject *)self; - Py_VISIT((PyObject*) PyDescr_TYPE(descr)); - return 0; -} - -SWIGINTERN PyObject * -SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) { - if (descr->d_getset->get != NULL) - return descr->d_getset->get(obj, descr->d_getset->closure); -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); -#else - PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); -#endif - return NULL; -} - -SWIGINTERN int -SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) { - if (descr->d_getset->set != NULL) - return descr->d_getset->set(obj, value, descr->d_getset->closure); -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); -#else - PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); -#endif - return -1; -} - -SWIGINTERN int -SwigPyObjectType_setattro(PyObject *typeobject, PyObject *name, PyObject *value) { - PyObject *attribute; - PyTypeObject *type; - descrsetfunc local_set; - - assert(PyType_Check(typeobject)); - type = (PyTypeObject *)typeobject; - attribute = _PyType_Lookup(type, name); - if (attribute != NULL) { - /* Implement descriptor functionality, if any */ - local_set = attribute->ob_type->tp_descr_set; - if (local_set != NULL) - return local_set(attribute, (PyObject *)type, value); -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name); -#else - PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name)); -#endif - } else { -#if PY_VERSION_HEX >= 0x03000000 - PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name); -#else - PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name)); -#endif - } - - return -1; -} - -SWIGINTERN PyTypeObject* -SwigPyStaticVar_Type(void) { - static PyTypeObject staticvar_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ -#endif - "swig_static_var_getset_descriptor", /* tp_name */ - sizeof(PyGetSetDescrObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)SwigPyStaticVar_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ - 0, /* tp_doc */ - SwigPyStaticVar_traverse, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */ - (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - staticvar_type = tmp; - type_init = 1; - if (PyType_Ready(&staticvar_type) < 0) - return NULL; - } - return &staticvar_type; -} - -SWIGINTERN PyTypeObject* -SwigPyObjectType(void) { - static char swigpyobjecttype_doc[] = "Metaclass for SWIG wrapped types"; - static PyTypeObject swigpyobjecttype_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ -#endif - "SwigPyObjectType", /* tp_name */ - PyType_Type.tp_basicsize, /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - SwigPyObjectType_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ - swigpyobjecttype_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - swigpyobjecttype_type = tmp; - type_init = 1; - swigpyobjecttype_type.tp_base = &PyType_Type; - if (PyType_Ready(&swigpyobjecttype_type) < 0) - return NULL; - } - return &swigpyobjecttype_type; -} - -SWIGINTERN PyGetSetDescrObject * -SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { - - PyGetSetDescrObject *descr; - descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0); - assert(descr); - Py_XINCREF(type); - PyDescr_TYPE(descr) = type; - PyDescr_NAME(descr) = PyString_InternFromString(getset->name); - descr->d_getset = getset; - if (PyDescr_NAME(descr) == NULL) { - Py_DECREF(descr); - descr = NULL; - } - return descr; -} - -SWIGINTERN void -SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { - Py_ssize_t base_count = 0; - PyTypeObject **b; - PyObject *tuple; - Py_ssize_t i; - - if (!bases[0]) { - bases[0] = SwigPyObject_type(); - bases[1] = NULL; - } - type->tp_base = bases[0]; - Py_INCREF((PyObject *)bases[0]); - for (b = bases; *b != NULL; ++b) - ++base_count; - tuple = PyTuple_New(base_count); - for (i = 0; i < base_count; ++i) { - Py_INCREF((PyObject *)bases[i]); - PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); - } - type->tp_bases = tuple; -} - -SWIGINTERN PyObject * -SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { - PyObject *result; - result = (PyObject *)SWIG_Python_GetSwigThis(self); - Py_XINCREF(result); - return result; -} - -SWIGINTERN void -SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) -{ -#if PY_VERSION_HEX >= 0x03000000 - type->ob_base.ob_base.ob_type = metatype; -#else - type->ob_type = metatype; -#endif -} - - -/* Start of callback function macros for use in PyTypeObject */ - -typedef PyObject *(*SwigPyWrapperFunction)(PyObject *, PyObject *); - -#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_unaryfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_unaryfunc_closure(wrapper, a); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_unaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ -SWIGINTERN void \ -wrapper##_destructor_closure(PyObject *a) { \ - SwigPyBuiltin_destructor_closure(wrapper, #wrapper, a); \ -} -SWIGINTERN void -SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrappername, PyObject *a) { - SwigPyObject *sobj; - sobj = (SwigPyObject *)a; - Py_XDECREF(sobj->dict); - if (sobj->own) { - PyObject *o; - PyObject *type = 0, *value = 0, *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - o = wrapper(a, NULL); - if (!o) { - PyObject *deallocname = PyString_FromString(wrappername); - PyErr_WriteUnraisable(deallocname); - Py_DECREF(deallocname); - } - PyErr_Restore(type, value, traceback); - Py_XDECREF(o); - } - if (PyType_IS_GC(a->ob_type)) { - PyObject_GC_Del(a); - } else { - PyObject_Del(a); - } -} - -#define SWIGPY_INQUIRY_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_inquiry_closure(PyObject *a) { \ - return SwigPyBuiltin_inquiry_closure(wrapper, a); \ -} -SWIGINTERN int -SwigPyBuiltin_inquiry_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - PyObject *pyresult; - int result; - pyresult = wrapper(a, NULL); - result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; - Py_XDECREF(pyresult); - return result; -} - -#define SWIGPY_GETITERFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_getiterfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_getiterfunc_closure(wrapper, a); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_getiterfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_binaryfunc_closure(PyObject *a, PyObject *b) { \ - return SwigPyBuiltin_binaryfunc_closure(wrapper, a, b); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { - PyObject *tuple, *result; - tuple = PyTuple_New(1); - assert(tuple); - Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - result = wrapper(a, tuple); - Py_DECREF(tuple); - return result; -} - -typedef ternaryfunc ternarycallfunc; - -#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ternaryfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \ - return SwigPyBuiltin_ternaryfunc_closure(wrapper, a, b, c); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { - PyObject *tuple, *result; - tuple = PyTuple_New(2); - assert(tuple); - Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - Py_INCREF(c); - PyTuple_SET_ITEM(tuple, 1, c); - result = wrapper(a, tuple); - Py_DECREF(tuple); - return result; -} - -#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ternarycallfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \ - return SwigPyBuiltin_ternarycallfunc_closure(wrapper, a, b, c); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ternarycallfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { - (void) c; - return wrapper(a, b); -} - -#define SWIGPY_LENFUNC_CLOSURE(wrapper) \ -SWIGINTERN Py_ssize_t \ -wrapper##_lenfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_lenfunc_closure(wrapper, a); \ -} -SWIGINTERN Py_ssize_t -SwigPyBuiltin_lenfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - PyObject *resultobj; - Py_ssize_t result; - resultobj = wrapper(a, NULL); - result = PyNumber_AsSsize_t(resultobj, NULL); - Py_DECREF(resultobj); - return result; -} - -#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ssizessizeargfunc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \ - return SwigPyBuiltin_ssizessizeargfunc_closure(wrapper, a, b, c); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ssizessizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c) { - PyObject *tuple, *result; - tuple = PyTuple_New(2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); - result = wrapper(a, tuple); - Py_DECREF(tuple); - return result; -} - -#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_ssizessizeobjargproc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \ - return SwigPyBuiltin_ssizessizeobjargproc_closure(wrapper, a, b, c, d); \ -} -SWIGINTERN int -SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { - PyObject *tuple, *resultobj; - int result; - tuple = PyTuple_New(d ? 3 : 2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); - if (d) { - Py_INCREF(d); - PyTuple_SET_ITEM(tuple, 2, d); - } - resultobj = wrapper(a, tuple); - result = resultobj ? 0 : -1; - Py_DECREF(tuple); - Py_XDECREF(resultobj); - return result; -} - -#define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \ - return SwigPyBuiltin_funpack_ssizeargfunc_closure(wrapper, a, b); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_funpack_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) { - PyObject *tuple, *result; - tuple = PyTuple_New(1); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - result = wrapper(a, tuple); - Py_DECREF(tuple); - return result; -} - -#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \ - return SwigPyBuiltin_ssizeargfunc_closure(wrapper, a, b); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) { - PyObject *arg, *result; - arg = _PyLong_FromSsize_t(b); - result = wrapper(a, arg); - Py_DECREF(arg); - return result; -} - -#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_ssizeobjargproc_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \ - return SwigPyBuiltin_ssizeobjargproc_closure(wrapper, a, b, c); \ -} -SWIGINTERN int -SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, PyObject *c) { - PyObject *tuple, *resultobj; - int result; - tuple = PyTuple_New(2); - assert(tuple); - PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); - Py_INCREF(c); - PyTuple_SET_ITEM(tuple, 1, c); - resultobj = wrapper(a, tuple); - result = resultobj ? 0 : -1; - Py_XDECREF(resultobj); - Py_DECREF(tuple); - return result; -} - -#define SWIGPY_OBJOBJPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ - return SwigPyBuiltin_objobjproc_closure(wrapper, a, b); \ -} -SWIGINTERN int -SwigPyBuiltin_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { - int result; - PyObject *pyresult; - PyObject *tuple; - tuple = PyTuple_New(1); - assert(tuple); - Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - pyresult = wrapper(a, tuple); - result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; - Py_XDECREF(pyresult); - Py_DECREF(tuple); - return result; -} - -#define SWIGPY_FUNPACK_OBJOBJPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ - return SwigPyBuiltin_funpack_objobjproc_closure(wrapper, a, b); \ -} -SWIGINTERN int -SwigPyBuiltin_funpack_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { - int result; - PyObject *pyresult; - pyresult = wrapper(a, b); - result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; - Py_XDECREF(pyresult); - return result; -} - -#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ -SWIGINTERN int \ -wrapper##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \ - return SwigPyBuiltin_objobjargproc_closure(wrapper, a, b, c); \ -} -SWIGINTERN int -SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { - PyObject *tuple, *resultobj; - int result; - tuple = PyTuple_New(c ? 2 : 1); - assert(tuple); - Py_INCREF(b); - PyTuple_SET_ITEM(tuple, 0, b); - if (c) { - Py_INCREF(c); - PyTuple_SET_ITEM(tuple, 1, c); - } - resultobj = wrapper(a, tuple); - result = resultobj ? 0 : -1; - Py_XDECREF(resultobj); - Py_DECREF(tuple); - return result; -} - -#define SWIGPY_REPRFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_reprfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_reprfunc_closure(wrapper, a); \ -} -SWIGINTERN PyObject * -SwigPyBuiltin_reprfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ -SWIGINTERN Py_hash_t \ -wrapper##_hashfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_hashfunc_closure(wrapper, a); \ -} -SWIGINTERN Py_hash_t -SwigPyBuiltin_hashfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - PyObject *pyresult; - Py_hash_t result; - pyresult = wrapper(a, NULL); - if (!pyresult) - return -1; - result = SWIG_PyNumber_AsPyHash(pyresult); - Py_DECREF(pyresult); - return result; -} - -#define SWIGPY_ITERNEXTFUNC_CLOSURE(wrapper) \ -SWIGINTERN PyObject * \ -wrapper##_iternextfunc_closure(PyObject *a) { \ - return SwigPyBuiltin_iternextfunc_closure(wrapper, a);\ -} -SWIGINTERN PyObject * -SwigPyBuiltin_iternextfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { - return wrapper(a, NULL); -} - -/* End of callback function macros for use in PyTypeObject */ - -#ifdef __cplusplus -} -#endif - - - - -#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) - -#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else - - - -#ifdef __cplusplus -extern "C" { -#endif - -/* Method creation and docstring support functions */ - -SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); -SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); -SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); - -#ifdef __cplusplus -} -#endif - - - #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) - - -/* -------- TYPES TABLE (BEGIN) -------- */ - -#define SWIGTYPE_p_AES_KEY swig_types[0] -#define SWIGTYPE_p_ASN1_BIT_STRING swig_types[1] -#define SWIGTYPE_p_ASN1_INTEGER swig_types[2] -#define SWIGTYPE_p_ASN1_OBJECT swig_types[3] -#define SWIGTYPE_p_ASN1_STRING swig_types[4] -#define SWIGTYPE_p_ASN1_TIME swig_types[5] -#define SWIGTYPE_p_BIGNUM swig_types[6] -#define SWIGTYPE_p_BIO swig_types[7] -#define SWIGTYPE_p_BIO_METHOD swig_types[8] -#define SWIGTYPE_p_DH swig_types[9] -#define SWIGTYPE_p_DSA swig_types[10] -#define SWIGTYPE_p_ECDSA_SIG swig_types[11] -#define SWIGTYPE_p_EC_KEY swig_types[12] -#define SWIGTYPE_p_ENGINE swig_types[13] -#define SWIGTYPE_p_EVP_CIPHER swig_types[14] -#define SWIGTYPE_p_EVP_CIPHER_CTX swig_types[15] -#define SWIGTYPE_p_EVP_MD swig_types[16] -#define SWIGTYPE_p_EVP_MD_CTX swig_types[17] -#define SWIGTYPE_p_EVP_PKEY swig_types[18] -#define SWIGTYPE_p_FILE swig_types[19] -#define SWIGTYPE_p_HMAC_CTX swig_types[20] -#define SWIGTYPE_p_PKCS7 swig_types[21] -#define SWIGTYPE_p_PyObject swig_types[22] -#define SWIGTYPE_p_RC4_KEY swig_types[23] -#define SWIGTYPE_p_RSA swig_types[24] -#define SWIGTYPE_p_SSL swig_types[25] -#define SWIGTYPE_p_SSL_CIPHER swig_types[26] -#define SWIGTYPE_p_SSL_CTX swig_types[27] -#define SWIGTYPE_p_SSL_METHOD swig_types[28] -#define SWIGTYPE_p_SSL_SESSION swig_types[29] -#define SWIGTYPE_p_SwigPyObject swig_types[30] -#define SWIGTYPE_p_UI_METHOD swig_types[31] -#define SWIGTYPE_p_X509 swig_types[32] -#define SWIGTYPE_p_X509V3_CTX swig_types[33] -#define SWIGTYPE_p_X509_CRL swig_types[34] -#define SWIGTYPE_p_X509_EXTENSION swig_types[35] -#define SWIGTYPE_p_X509_NAME swig_types[36] -#define SWIGTYPE_p_X509_NAME_ENTRY swig_types[37] -#define SWIGTYPE_p_X509_REQ swig_types[38] -#define SWIGTYPE_p_X509_STORE swig_types[39] -#define SWIGTYPE_p_X509_STORE_CTX swig_types[40] -#define SWIGTYPE_p___INTMAX_TYPE__ swig_types[41] -#define SWIGTYPE_p___INT_FAST16_TYPE__ swig_types[42] -#define SWIGTYPE_p___INT_FAST32_TYPE__ swig_types[43] -#define SWIGTYPE_p___INT_FAST64_TYPE__ swig_types[44] -#define SWIGTYPE_p___INT_FAST8_TYPE__ swig_types[45] -#define SWIGTYPE_p___INT_LEAST16_TYPE__ swig_types[46] -#define SWIGTYPE_p___INT_LEAST32_TYPE__ swig_types[47] -#define SWIGTYPE_p___INT_LEAST64_TYPE__ swig_types[48] -#define SWIGTYPE_p___INT_LEAST8_TYPE__ swig_types[49] -#define SWIGTYPE_p___UINTMAX_TYPE__ swig_types[50] -#define SWIGTYPE_p___UINT_FAST16_TYPE__ swig_types[51] -#define SWIGTYPE_p___UINT_FAST32_TYPE__ swig_types[52] -#define SWIGTYPE_p___UINT_FAST64_TYPE__ swig_types[53] -#define SWIGTYPE_p___UINT_FAST8_TYPE__ swig_types[54] -#define SWIGTYPE_p___UINT_LEAST16_TYPE__ swig_types[55] -#define SWIGTYPE_p___UINT_LEAST32_TYPE__ swig_types[56] -#define SWIGTYPE_p___UINT_LEAST64_TYPE__ swig_types[57] -#define SWIGTYPE_p___UINT_LEAST8_TYPE__ swig_types[58] -#define SWIGTYPE_p__cbd_t swig_types[59] -#define SWIGTYPE_p_char swig_types[60] -#define SWIGTYPE_p_f_int_p_X509_STORE_CTX__int swig_types[61] -#define SWIGTYPE_p_f_p_char__void swig_types[62] -#define SWIGTYPE_p_f_p_q_const__char__p_char swig_types[63] -#define SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int swig_types[64] -#define SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int swig_types[65] -#define SWIGTYPE_p_f_p_q_const__void__p_void swig_types[66] -#define SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int swig_types[67] -#define SWIGTYPE_p_f_p_void__void swig_types[68] -#define SWIGTYPE_p_p_ASN1_OBJECT swig_types[69] -#define SWIGTYPE_p_p_EVP_PKEY_CTX swig_types[70] -#define SWIGTYPE_p_p_X509_NAME_ENTRY swig_types[71] -#define SWIGTYPE_p_p_unsigned_char swig_types[72] -#define SWIGTYPE_p_pyfd_struct swig_types[73] -#define SWIGTYPE_p_stack_st swig_types[74] -#define SWIGTYPE_p_stack_st_OPENSSL_BLOCK swig_types[75] -#define SWIGTYPE_p_stack_st_OPENSSL_CSTRING swig_types[76] -#define SWIGTYPE_p_stack_st_OPENSSL_STRING swig_types[77] -#define SWIGTYPE_p_stack_st_SSL_CIPHER swig_types[78] -#define SWIGTYPE_p_stack_st_X509 swig_types[79] -#define SWIGTYPE_p_stack_st_X509_EXTENSION swig_types[80] -#define SWIGTYPE_p_unsigned_char swig_types[81] -#define SWIGTYPE_p_void swig_types[82] -static swig_type_info *swig_types[84]; -static swig_module_info swig_module = {swig_types, 83, 0, 0, 0, 0}; -#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) -#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) - -/* -------- TYPES TABLE (END) -------- */ - -#ifdef SWIG_TypeQuery -# undef SWIG_TypeQuery -#endif -#define SWIG_TypeQuery SWIG_Python_TypeQuery - -/*----------------------------------------------- - @(target):= _m2crypto.so - ------------------------------------------------*/ -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_init PyInit__m2crypto - -#else -# define SWIG_init init_m2crypto - -#endif -#define SWIG_name "_m2crypto" - -#define SWIGVERSION 0x040002 -#define SWIG_VERSION SWIGVERSION - - -#define SWIG_as_voidptr(a) (void *)((const void *)(a)) -#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) - - -#include - - -int SWIG_AsVal_wchar_t(PyObject *p, wchar_t *c) { return SWIG_OK; } -PyObject *SWIG_From_wchar_t(wchar_t c) { return SWIG_Py_Void(); } - - -#ifdef _WIN32 -#define _WINSOCKAPI_ -#include -#include -#pragma comment(lib, "Ws2_32") -typedef unsigned __int64 uint64_t; -#endif - - -#if defined __GNUC__ && __GNUC__ < 5 -#pragma GCC diagnostic ignored "-Wunused-label" -#pragma GCC diagnostic warning "-Wstrict-prototypes" -#endif - -#include -#include -#include <_lib.h> -#include -#include - -#include "compile.h" - -static PyObject *ssl_verify_cb_func; -static PyObject *ssl_info_cb_func; -static PyObject *ssl_set_tmp_dh_cb_func; -static PyObject *ssl_set_tmp_rsa_cb_func; -static PyObject *x509_store_verify_cb_func; - - - #define SWIG_From_long PyInt_FromLong - - -SWIGINTERN swig_type_info* -SWIG_pchar_descriptor(void) -{ - static int init = 0; - static swig_type_info* info = 0; - if (!init) { - info = SWIG_TypeQuery("_p_char"); - init = 1; - } - return info; -} - - -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtrAndSize(const char* carray, size_t size) -{ - if (carray) { - if (size > INT_MAX) { - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - return pchar_descriptor ? - SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); - } else { -#if PY_VERSION_HEX >= 0x03000000 -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); -#else - return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); -#endif -#else - return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); -#endif - } - } else { - return SWIG_Py_Void(); - } -} - - -SWIGINTERNINLINE PyObject * -SWIG_FromCharPtr(const char *cptr) -{ - return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); -} - - -SWIGINTERNINLINE PyObject* - SWIG_From_int (int value) -{ - return PyInt_FromLong((long) value); -} - - -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif - - -SWIGINTERN int -SWIG_AsVal_double (PyObject *obj, double *val) -{ - int res = SWIG_TypeError; - if (PyFloat_Check(obj)) { - if (val) *val = PyFloat_AsDouble(obj); - return SWIG_OK; -#if PY_VERSION_HEX < 0x03000000 - } else if (PyInt_Check(obj)) { - if (val) *val = (double) PyInt_AsLong(obj); - return SWIG_OK; -#endif - } else if (PyLong_Check(obj)) { - double v = PyLong_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - double d = PyFloat_AsDouble(obj); - if (!PyErr_Occurred()) { - if (val) *val = d; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); - } else { - PyErr_Clear(); - } - } - } -#endif - return res; -} - - -#include - - -#include - - -SWIGINTERNINLINE int -SWIG_CanCastAsInteger(double *d, double min, double max) { - double x = *d; - if ((min <= x && x <= max)) { - double fx = floor(x); - double cx = ceil(x); - double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ - if ((errno == EDOM) || (errno == ERANGE)) { - errno = 0; - } else { - double summ, reps, diff; - if (rd < x) { - diff = x - rd; - } else if (rd > x) { - diff = rd - x; - } else { - return 1; - } - summ = rd + x; - reps = diff/summ; - if (reps < 8*DBL_EPSILON) { - *d = rd; - return 1; - } - } - } - return 0; -} - - -SWIGINTERN int -SWIG_AsVal_long (PyObject *obj, long* val) -{ -#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - if (val) *val = PyInt_AsLong(obj); - return SWIG_OK; - } else -#endif - if (PyLong_Check(obj)) { - long v = PyLong_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - long v = PyInt_AsLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { - if (val) *val = (long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -SWIGINTERN int -SWIG_AsVal_int (PyObject * obj, int *val) -{ - long v; - int res = SWIG_AsVal_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v < INT_MIN || v > INT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = (int)(v); - } - } - return res; -} - - -SWIGINTERN int -SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) -{ -#if PY_VERSION_HEX>=0x03000000 -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (PyBytes_Check(obj)) -#else - if (PyUnicode_Check(obj)) -#endif -#else - if (PyString_Check(obj)) -#endif - { - char *cstr; Py_ssize_t len; - int ret = SWIG_OK; -#if PY_VERSION_HEX>=0x03000000 -#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - if (!alloc && cptr) { - /* We can't allow converting without allocation, since the internal - representation of string in Python 3 is UCS-2/UCS-4 but we require - a UTF-8 representation. - TODO(bhy) More detailed explanation */ - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - if (!obj) - return SWIG_TypeError; - if (alloc) - *alloc = SWIG_NEWOBJ; -#endif - if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) - return SWIG_TypeError; -#else - if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) - return SWIG_TypeError; -#endif - if (cptr) { - if (alloc) { - if (*alloc == SWIG_NEWOBJ) { - *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); - *alloc = SWIG_NEWOBJ; - } else { - *cptr = cstr; - *alloc = SWIG_OLDOBJ; - } - } else { -#if PY_VERSION_HEX>=0x03000000 -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - *cptr = PyBytes_AsString(obj); -#else - assert(0); /* Should never reach here with Unicode strings in Python 3 */ -#endif -#else - *cptr = SWIG_Python_str_AsChar(obj); - if (!*cptr) - ret = SWIG_TypeError; -#endif - } - } - if (psize) *psize = len + 1; -#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) - Py_XDECREF(obj); -#endif - return ret; - } else { -#if defined(SWIG_PYTHON_2_UNICODE) -#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) -#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" -#endif -#if PY_VERSION_HEX<0x03000000 - if (PyUnicode_Check(obj)) { - char *cstr; Py_ssize_t len; - if (!alloc && cptr) { - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - if (!obj) - return SWIG_TypeError; - if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { - if (cptr) { - if (alloc) *alloc = SWIG_NEWOBJ; - *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); - } - if (psize) *psize = len + 1; - - Py_XDECREF(obj); - return SWIG_OK; - } else { - Py_XDECREF(obj); - } - } -#endif -#endif - - swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); - if (pchar_descriptor) { - void* vptr = 0; - if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; - } - } - } - return SWIG_TypeError; -} - - - - - -#include -#include - -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L -#define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) -static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; -static long lock_count[CRYPTO_num_locks()]; -static int thread_mode = 0; -#endif - -void threading_locking_callback(int mode, int type, const char *file, int line) { -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L - if (mode & CRYPTO_LOCK) { - PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); - lock_count[type]++; - } else { - PyThread_release_lock(lock_cs[type]); - lock_count[type]--; - } -#endif -} - -unsigned long threading_id_callback(void) { -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L - return (unsigned long)PyThread_get_thread_ident(); -#else - return (unsigned long)0; -#endif -} - - -void threading_init(void) { -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L - int i; - if (!thread_mode) { - for (i=0; i -#include -#include -#include -#include -#include -#include -#include -#include - - -#if OPENSSL_VERSION_NUMBER < 0x10100000L - -#include -#include - -# define OPENSSL_zalloc(num) \ - CRYPTO_zalloc(num, __FILE__, __LINE__) - -static void *CRYPTO_zalloc(size_t num, const char *file, int line) -{ - void *ret = CRYPTO_malloc(num, file, line); - if (ret != NULL) - memset(ret, 0, num); - return ret; -} - -#include - -#ifndef BN_F_BN_GENCB_NEW -# define BN_F_BN_GENCB_NEW 143 -#endif - -# define BN_GENCB_get_arg(gencb) ((gencb)->arg) - -BN_GENCB *BN_GENCB_new(void) -{ - BN_GENCB *ret; - - if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) { - BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE); - return (NULL); - } - - return ret; -} - -void BN_GENCB_free(BN_GENCB *cb) -{ - if (cb == NULL) - return; - OPENSSL_free(cb); -} - - -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) -{ - /* If the fields n and e in r are NULL, the corresponding input - * parameters MUST be non-NULL for n and e. d may be - * left NULL (in case only the public key is used). - */ - if ((r->n == NULL && n == NULL) - || (r->e == NULL && e == NULL)) - return 0; - - if (n != NULL) { - BN_free(r->n); - r->n = n; - } - if (e != NULL) { - BN_free(r->e); - r->e = e; - } - if (d != NULL) { - BN_free(r->d); - r->d = d; - } - - return 1; -} - -int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) -{ - /* If the fields p and q in r are NULL, the corresponding input - * parameters MUST be non-NULL. - */ - if ((r->p == NULL && p == NULL) - || (r->q == NULL && q == NULL)) - return 0; - - if (p != NULL) { - BN_free(r->p); - r->p = p; - } - if (q != NULL) { - BN_free(r->q); - r->q = q; - } - - return 1; -} - -int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) -{ - /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input - * parameters MUST be non-NULL. - */ - if ((r->dmp1 == NULL && dmp1 == NULL) - || (r->dmq1 == NULL && dmq1 == NULL) - || (r->iqmp == NULL && iqmp == NULL)) - return 0; - - if (dmp1 != NULL) { - BN_free(r->dmp1); - r->dmp1 = dmp1; - } - if (dmq1 != NULL) { - BN_free(r->dmq1); - r->dmq1 = dmq1; - } - if (iqmp != NULL) { - BN_free(r->iqmp); - r->iqmp = iqmp; - } - - return 1; -} - -void RSA_get0_key(const RSA *r, - const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) -{ - if (n != NULL) - *n = r->n; - if (e != NULL) - *e = r->e; - if (d != NULL) - *d = r->d; -} - -void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) -{ - if (p != NULL) - *p = r->p; - if (q != NULL) - *q = r->q; -} - -void RSA_get0_crt_params(const RSA *r, - const BIGNUM **dmp1, const BIGNUM **dmq1, - const BIGNUM **iqmp) -{ - if (dmp1 != NULL) - *dmp1 = r->dmp1; - if (dmq1 != NULL) - *dmq1 = r->dmq1; - if (iqmp != NULL) - *iqmp = r->iqmp; -} - -void DSA_get0_pqg(const DSA *d, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) -{ - if (p != NULL) - *p = d->p; - if (q != NULL) - *q = d->q; - if (g != NULL) - *g = d->g; -} - -int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) -{ - /* If the fields p, q and g in d are NULL, the corresponding input - * parameters MUST be non-NULL. - */ - if ((d->p == NULL && p == NULL) - || (d->q == NULL && q == NULL) - || (d->g == NULL && g == NULL)) - return 0; - - if (p != NULL) { - BN_free(d->p); - d->p = p; - } - if (q != NULL) { - BN_free(d->q); - d->q = q; - } - if (g != NULL) { - BN_free(d->g); - d->g = g; - } - - return 1; -} - -void DSA_get0_key(const DSA *d, - const BIGNUM **pub_key, const BIGNUM **priv_key) -{ - if (pub_key != NULL) - *pub_key = d->pub_key; - if (priv_key != NULL) - *priv_key = d->priv_key; -} - -int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) -{ - /* If the field pub_key in d is NULL, the corresponding input - * parameters MUST be non-NULL. The priv_key field may - * be left NULL. - */ - if (d->pub_key == NULL && pub_key == NULL) - return 0; - - if (pub_key != NULL) { - BN_free(d->pub_key); - d->pub_key = pub_key; - } - if (priv_key != NULL) { - BN_free(d->priv_key); - d->priv_key = priv_key; - } - - return 1; -} - -void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) -{ - if (pr != NULL) - *pr = sig->r; - if (ps != NULL) - *ps = sig->s; -} - -int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) -{ - if (r == NULL || s == NULL) - return 0; - BN_clear_free(sig->r); - BN_clear_free(sig->s); - sig->r = r; - sig->s = s; - return 1; -} - -void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) -{ - if (pr != NULL) - *pr = sig->r; - if (ps != NULL) - *ps = sig->s; -} - -int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) -{ - if (r == NULL || s == NULL) - return 0; - BN_clear_free(sig->r); - BN_clear_free(sig->s); - sig->r = r; - sig->s = s; - return 1; -} - -void DH_get0_pqg(const DH *dh, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) -{ - if (p != NULL) - *p = dh->p; - if (q != NULL) - *q = dh->q; - if (g != NULL) - *g = dh->g; -} - -int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) -{ - /* If the fields p and g in d are NULL, the corresponding input - * parameters MUST be non-NULL. q may remain NULL. - */ - if ((dh->p == NULL && p == NULL) - || (dh->g == NULL && g == NULL)) - return 0; - - if (p != NULL) { - BN_free(dh->p); - dh->p = p; - } - if (q != NULL) { - BN_free(dh->q); - dh->q = q; - } - if (g != NULL) { - BN_free(dh->g); - dh->g = g; - } - - if (q != NULL) { - dh->length = BN_num_bits(q); - } - - return 1; -} - -void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) -{ - if (pub_key != NULL) - *pub_key = dh->pub_key; - if (priv_key != NULL) - *priv_key = dh->priv_key; -} - -int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) -{ - /* If the field pub_key in dh is NULL, the corresponding input - * parameters MUST be non-NULL. The priv_key field may - * be left NULL. - */ - if (dh->pub_key == NULL && pub_key == NULL) - return 0; - - if (pub_key != NULL) { - BN_free(dh->pub_key); - dh->pub_key = pub_key; - } - if (priv_key != NULL) { - BN_free(dh->priv_key); - dh->priv_key = priv_key; - } - - return 1; -} - -int DH_set_length(DH *dh, long length) -{ - dh->length = length; - return 1; -} - -const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx) -{ - return ctx->iv; -} - -unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx) -{ - return ctx->iv; -} - -EVP_MD_CTX *EVP_MD_CTX_new(void) -{ - return OPENSSL_zalloc(sizeof(EVP_MD_CTX)); -} - -void EVP_MD_CTX_free(EVP_MD_CTX *ctx) -{ - EVP_MD_CTX_cleanup(ctx); - OPENSSL_free(ctx); -} - -int RSA_size(const RSA* rsa) { - /* BIGNUM* n = NULL; - RSA_get0_key(rsa, n, NULL, NULL); */ - return BN_num_bytes(rsa->n); -} - -RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth) -{ - RSA_METHOD *ret; - - ret = OPENSSL_malloc(sizeof(RSA_METHOD)); - - if (ret != NULL) { - memcpy(ret, meth, sizeof(*meth)); - ret->name = OPENSSL_strdup(meth->name); - if (ret->name == NULL) { - OPENSSL_free(ret); - return NULL; - } - } - - return ret; -} - -int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) -{ - char *tmpname; - - tmpname = OPENSSL_strdup(name); - if (tmpname == NULL) { - return 0; - } - - OPENSSL_free((char *)meth->name); - meth->name = tmpname; - - return 1; -} - -int RSA_meth_set_priv_enc(RSA_METHOD *meth, - int (*priv_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - meth->rsa_priv_enc = priv_enc; - return 1; -} - -int RSA_meth_set_priv_dec(RSA_METHOD *meth, - int (*priv_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)) -{ - meth->rsa_priv_dec = priv_dec; - return 1; -} - -int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa)) -{ - meth->finish = finish; - return 1; -} - -void RSA_meth_free(RSA_METHOD *meth) -{ - if (meth != NULL) { - OPENSSL_free((char *)meth->name); - OPENSSL_free(meth); - } -} - -int RSA_bits(const RSA *r) -{ - return (BN_num_bits(r->n)); -} - -RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) -{ - if (pkey->type != EVP_PKEY_RSA) { - return NULL; - } - return pkey->pkey.rsa; -} - -int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, - size_t *pderlen) -{ - /* Make sure encoding is valid */ - if (i2d_X509_NAME(nm, NULL) <= 0) - return 0; - if (pder != NULL) - *pder = (unsigned char *)nm->bytes->data; - if (pderlen != NULL) - *pderlen = nm->bytes->length; - return 1; -} - -#endif /* OPENSSL_VERSION_NUMBER */ - - -#if PY_MAJOR_VERSION >= 3 - -FILE* PyFile_AsFile(PyObject *pyfile) { - FILE* fp; - int fd; - const char *mode_str = NULL; - PyObject *mode_obj; - - if ((fd = PyObject_AsFileDescriptor(pyfile)) == -1) { - PyErr_SetString(PyExc_BlockingIOError, - "Cannot find file handler for the Python file!"); - return NULL; - } - - if ((mode_obj = PyObject_GetAttrString(pyfile, "mode")) == NULL) { - mode_str = "rb"; - PyErr_Clear(); - } - else { - /* convert to plain string - * note that error checking is embedded in the function - */ - mode_str = PyUnicode_AsUTF8AndSize(mode_obj, NULL); - } - - if((fp = fdopen(fd, mode_str)) == NULL) { - PyErr_SetFromErrno(PyExc_IOError); - } - - Py_XDECREF(mode_obj); - return fp; -} - -#else /* PY2K */ - -#define PyLong_FromLong(x) PyInt_FromLong(x) -#define PyUnicode_AsUTF8(x) PyString_AsString(x) -#define PyUnicode_FromString(x) PyString_FromString(x) -#define PyUnicode_Format(x, y) PyString_Format(x, y) - -#endif /* PY_MAJOR_VERSION */ - - -/* OpenSSL 1.0.2 copmatbility shim */ -#if OPENSSL_VERSION_NUMBER < 0x10002000L -typedef void (*OPENSSL_sk_freefunc)(void *); -typedef void *(*OPENSSL_sk_copyfunc)(const void *); -typedef struct stack_st OPENSSL_STACK; - -# define MIN_NODES 4 -# define sk_deep_copy OPENSSL_sk_deep_copy - -void OPENSSL_sk_free(OPENSSL_STACK *st) -{ - if (st == NULL) - return; - OPENSSL_free(st->data); - OPENSSL_free(st); -} - -OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, - OPENSSL_sk_copyfunc copy_func, - OPENSSL_sk_freefunc free_func) -{ - OPENSSL_STACK *ret; - int i; - - if (sk->num < 0) - return NULL; - - if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) - return NULL; - - /* direct structure assignment */ - *ret = *sk; - - ret->num_alloc = sk->num > MIN_NODES ? (size_t)sk->num : MIN_NODES; - ret->data = OPENSSL_zalloc(sizeof(*ret->data) * ret->num_alloc); - if (ret->data == NULL) { - OPENSSL_free(ret); - return NULL; - } - - for (i = 0; i < ret->num; ++i) { - if (sk->data[i] == NULL) - continue; - if ((ret->data[i] = copy_func(sk->data[i])) == NULL) { - while (--i >= 0) - if (ret->data[i] != NULL) - free_func((void *)ret->data[i]); - OPENSSL_sk_free(ret); - return NULL; - } - } - return ret; -} -#endif /* OpenSSL 1.0.2 copmatbility shim */ - - -/* Blob interface. Deprecated. */ - -Blob *blob_new(int len, const char *errmsg) { - - Blob *blob; - if (!(blob=(Blob *)PyMem_Malloc(sizeof(Blob)))){ - PyErr_SetString(PyExc_MemoryError, errmsg); - return NULL; - } - if (!(blob->data=(unsigned char *)PyMem_Malloc(len))) { - PyMem_Free(blob); - PyErr_SetString(PyExc_MemoryError, errmsg); - return NULL; - } - blob->len=len; - return blob; -} - -Blob *blob_copy(Blob *from, const char *errmsg) { - Blob *blob=blob_new(from->len, errmsg); - if (!blob) { - PyErr_SetString(PyExc_MemoryError, errmsg); - return NULL; - } - memcpy(blob->data, from->data, from->len); - return blob; -} - -void blob_free(Blob *blob) { - PyMem_Free(blob->data); - PyMem_Free(blob); -} - - -/* Python helpers. */ - - - - -static int -m2_PyObject_AsReadBuffer(PyObject * obj, const void **buffer, - Py_ssize_t * buffer_len) -{ - int ret = 0; - Py_ssize_t len = 0; - Py_buffer view; - - if (PyObject_CheckBuffer(obj)) { - if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) == 0) { - *buffer = view.buf; - len = view.len; - } - } else { - if ((ret = PyObject_AsReadBuffer(obj, buffer, &len)) != 0) - return ret; - } - if (len > INT_MAX) { - m2_PyBuffer_Release(obj, &view); - PyErr_SetString(PyExc_ValueError, "object too large"); - return -1; - } - *buffer_len = len; - m2_PyBuffer_Release(obj, &view); - return 0; -} - -static int -m2_PyObject_AsReadBufferInt(PyObject * obj, const void **buffer, - int *buffer_len) -{ - int ret = 0; - Py_ssize_t len = 0; - - ret = m2_PyObject_AsReadBuffer(obj, buffer, &len); - *buffer_len = len; - return ret; -} - - - -static int m2_PyObject_GetBufferInt(PyObject *obj, Py_buffer *view, int flags) -{ - int ret; - - if (PyObject_CheckBuffer(obj)) - ret = PyObject_GetBuffer(obj, view, flags); - else { - const void *buf; - - ret = PyObject_AsReadBuffer(obj, &buf, &view->len); - if (ret == 0) - view->buf = (void *)buf; - } - if (ret) - return ret; - if (view->len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "object too large"); - m2_PyBuffer_Release(obj, view); - return -1; - } - - return 0; -} - -static BIGNUM* -m2_PyObject_AsBIGNUM(PyObject* value, PyObject* _py_exc) -{ - BIGNUM* bn; - const void* vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { - PyErr_SetString(_py_exc, ERR_reason_error_string(ERR_get_error())); - return NULL; - } - - return bn; -} - -static void m2_PyBuffer_Release(PyObject *obj, Py_buffer *view) -{ - if (PyObject_CheckBuffer(obj)) - PyBuffer_Release(view); - /* else do nothing, view->buf comes from PyObject_AsReadBuffer */ -} - -static int -m2_PyString_AsStringAndSizeInt(PyObject *obj, char **s, int *len) -{ - int ret; - Py_ssize_t len2; - - ret = PyBytes_AsStringAndSize(obj, s, &len2); - - if (ret) - return ret; - if (len2 > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "string too large"); - return -1; - } - *len = len2; - return 0; -} - -/* Works as PyFile_Name, but always returns a new object. */ -PyObject *m2_PyFile_Name(PyObject *pyfile) { - PyObject *out = NULL; -#if PY_MAJOR_VERSION >= 3 - out = PyObject_GetAttrString(pyfile, "name"); -#else - out = PyFile_Name(pyfile); - Py_XINCREF(out); -#endif - return out; -} - -/* Yes, __FUNCTION__ is a non-standard symbol, but it is supported by - * both gcc and MSVC. */ -#define m2_PyErr_Msg(type) m2_PyErr_Msg_Caller(type, (const char*) __FUNCTION__) - -static void m2_PyErr_Msg_Caller(PyObject *err_type, const char* caller) { - const char *err_reason; - const char *data; - int flags; - /* This max size of a (longer than ours) OpenSSL error string is hardcoded - * in OpenSSL's crypto/err/err_prn.c:ERR_print_errors_cb() */ - char err_msg[4096]; - unsigned long err_code = ERR_get_error_line_data(NULL, NULL, &data, &flags); - - if (err_code != 0) { - err_reason = ERR_reason_error_string(err_code); - if (data && (flags & ERR_TXT_STRING)) - snprintf(err_msg, sizeof(err_msg), "%s (%s)", err_reason, data); - else - snprintf(err_msg, sizeof(err_msg), "%s", err_reason); - - PyErr_SetString(err_type, err_msg); - } else { - PyErr_Format(err_type, "Unknown error in function %s.", caller); - } -} - - -/* C callbacks invoked by OpenSSL; these in turn call back into -Python. */ - -int ssl_verify_callback(int ok, X509_STORE_CTX *ctx) { - PyObject *argv, *ret; - PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; - PyObject *_x509=0, *_ssl_ctx=0; - SSL *ssl; - SSL_CTX *ssl_ctx; - X509 *x509; - int errnum, errdepth; - int cret; - int new_style_callback = 0, warning_raised_exception=0; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - ssl = (SSL *)X509_STORE_CTX_get_app_data(ctx); - - gilstate = PyGILState_Ensure(); - - if (PyMethod_Check(ssl_verify_cb_func)) { - PyObject *func; - PyCodeObject *code; - func = PyMethod_Function(ssl_verify_cb_func); - code = (PyCodeObject *) PyFunction_GetCode(func); - if (code && code->co_argcount == 3) { /* XXX Python internals */ - new_style_callback = 1; - } - } else if (PyFunction_Check(ssl_verify_cb_func)) { - PyCodeObject *code = (PyCodeObject *) PyFunction_GetCode(ssl_verify_cb_func); - if (code && code->co_argcount == 2) { /* XXX Python internals */ - new_style_callback = 1; - } - } else { - /* XXX There are lots of other callable types, but we will assume - * XXX that any other type of callable uses the new style callback, - * XXX although this is not entirely safe assumption. - */ - new_style_callback = 1; - } - - if (new_style_callback) { - PyObject *x509mod; - - x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); - _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); - - _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); - _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); - - _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); - - argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); - } else { - if (PyErr_Warn(PyExc_DeprecationWarning, "Old style callback, use cb_func(ok, store) instead")) { - warning_raised_exception = 1; - } - - x509 = X509_STORE_CTX_get_current_cert(ctx); - errnum = X509_STORE_CTX_get_error(ctx); - errdepth = X509_STORE_CTX_get_error_depth(ctx); - - ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); - ssl_ctx = SSL_get_SSL_CTX(ssl); - - _x509 = SWIG_NewPointerObj((void *)x509, SWIGTYPE_p_X509, 0); - _ssl_ctx = SWIG_NewPointerObj((void *)ssl_ctx, SWIGTYPE_p_SSL_CTX, 0); - argv = Py_BuildValue("(OOiii)", _ssl_ctx, _x509, errnum, errdepth, ok); - } - - if (!warning_raised_exception) { - ret = PyEval_CallObject(ssl_verify_cb_func, argv); - } else { - ret = 0; - } - - if (!ret) { - /* Got an exception in PyEval_CallObject(), let's fail verification - * to be safe. - */ - cret = 0; - } else { - /* FIXME This is possibly problematic if ret > MAXINT */ - cret = (int)PyLong_AsLong(ret); - } - Py_XDECREF(ret); - Py_XDECREF(argv); - if (new_style_callback) { - Py_XDECREF(_x509_store_ctx_inst); - Py_XDECREF(_x509_store_ctx_obj); - Py_XDECREF(_x509_store_ctx_swigptr); - Py_XDECREF(_klass); - } else { - Py_XDECREF(_x509); - Py_XDECREF(_ssl_ctx); - } - - PyGILState_Release(gilstate); - - return cret; -} - -int x509_store_verify_callback(int ok, X509_STORE_CTX *ctx) { - PyGILState_STATE gilstate; - PyObject *argv, *ret; - PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; - int cret; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - PyObject *x509mod; - - - gilstate = PyGILState_Ensure(); - - /* Below, handle only what is called 'new style callback' in ssl_verify_callback(). - TODO: does 'old style callback' exist any more? */ - x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); - _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); - _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); - _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); - - _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); - - argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); - - ret = PyEval_CallObject(x509_store_verify_cb_func, argv); - if (!ret) { - /* Got an exception in PyEval_CallObject(), let's fail verification - * to be safe. - */ - cret = 0; - } else { - cret = (int)PyInt_AsLong(ret); - } - - Py_XDECREF(ret); - Py_XDECREF(argv); - Py_XDECREF(_x509_store_ctx_inst); - Py_XDECREF(_x509_store_ctx_obj); - Py_XDECREF(_x509_store_ctx_swigptr); - Py_XDECREF(_klass); - - PyGILState_Release(gilstate); - return cret; -} - -void ssl_info_callback(const SSL *s, int where, int ret) { - PyObject *argv, *retval, *_SSL; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - gilstate = PyGILState_Ensure(); - - _SSL = SWIG_NewPointerObj((void *)s, SWIGTYPE_p_SSL, 0); - argv = Py_BuildValue("(iiO)", where, ret, _SSL); - - retval = PyEval_CallObject(ssl_info_cb_func, argv); - - Py_XDECREF(retval); - Py_XDECREF(argv); - Py_XDECREF(_SSL); - - PyGILState_Release(gilstate); -} - -DH *ssl_set_tmp_dh_callback(SSL *ssl, int is_export, int keylength) { - PyObject *argv, *ret, *_ssl; - DH *dh; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - gilstate = PyGILState_Ensure(); - - _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); - argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); - - ret = PyEval_CallObject(ssl_set_tmp_dh_cb_func, argv); - - if ((SWIG_ConvertPtr(ret, (void **)&dh, SWIGTYPE_p_DH, SWIG_POINTER_EXCEPTION | 0)) == -1) - dh = NULL; - Py_XDECREF(ret); - Py_XDECREF(argv); - Py_XDECREF(_ssl); - - PyGILState_Release(gilstate); - - return dh; -} - -RSA *ssl_set_tmp_rsa_callback(SSL *ssl, int is_export, int keylength) { - PyObject *argv, *ret, *_ssl; - RSA *rsa; - PyGILState_STATE gilstate; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - gilstate = PyGILState_Ensure(); - - _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); - argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); - - ret = PyEval_CallObject(ssl_set_tmp_rsa_cb_func, argv); - - if ((SWIG_ConvertPtr(ret, (void **)&rsa, SWIGTYPE_p_RSA, SWIG_POINTER_EXCEPTION | 0)) == -1) - rsa = NULL; - Py_XDECREF(ret); - Py_XDECREF(argv); - Py_XDECREF(_ssl); - - PyGILState_Release(gilstate); - - return rsa; -} - -/* Universal callback for dh_generate_parameters, - * dsa_generate_parametersm, and rsa_generate_key */ -int bn_gencb_callback(int p, int n, BN_GENCB *gencb) { - PyObject *argv, *ret, *cbfunc; - - cbfunc = (PyObject *)BN_GENCB_get_arg(gencb); - argv = Py_BuildValue("(ii)", p, n); - ret = PyEval_CallObject(cbfunc, argv); - PyErr_Clear(); - Py_DECREF(argv); - Py_XDECREF(ret); - return 1; -} - -int passphrase_callback(char *buf, int num, int v, void *arg) { - int i; - Py_ssize_t len; - char *str; - PyObject *argv, *ret, *cbfunc; - PyGILState_STATE gilstate; - - gilstate = PyGILState_Ensure(); - cbfunc = (PyObject *)arg; - argv = Py_BuildValue("(i)", v); - /* PyEval_CallObject sets exception, if needed. */ - ret = PyEval_CallObject(cbfunc, argv); - Py_DECREF(argv); - if (ret == NULL) { - PyGILState_Release(gilstate); - return -1; - } - - if (!PyBytes_Check(ret)) { - PyErr_SetString(PyExc_RuntimeError, - "Result of callback is not bytes()."); - Py_DECREF(ret); - PyGILState_Release(gilstate); - return -1; - } - if ((len = PyBytes_Size(ret)) > num) - len = num; - str = PyBytes_AsString(ret); - - for (i = 0; i < len; i++) - buf[i] = str[i]; - Py_DECREF(ret); - PyGILState_Release(gilstate); - return len; -} - - - -void lib_init() { -#if OPENSSL_VERSION_NUMBER < 0x10100000L - SSLeay_add_all_algorithms(); - ERR_load_ERR_strings(); -#endif -} - -/* Bignum routines that aren't not numerous enough to -warrant a separate file. */ - -PyObject *bn_to_mpi(const BIGNUM *bn) { - int len = 0; - unsigned char *mpi; - PyObject *pyo; - - len = BN_bn2mpi(bn, NULL); - if (!(mpi=(unsigned char *)PyMem_Malloc(len))) { - m2_PyErr_Msg(PyExc_MemoryError); - return NULL; - } - len=BN_bn2mpi(bn, mpi); - - pyo=PyBytes_FromStringAndSize((const char *)mpi, len); - - PyMem_Free(mpi); - return pyo; -} - -const BIGNUM *mpi_to_bn(PyObject *value) { - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - return BN_mpi2bn(vbuf, vlen, NULL); -} - -PyObject *bn_to_bin(BIGNUM *bn) { - int len = 0; - unsigned char *bin; - PyObject *pyo; - - len = BN_num_bytes(bn); - if (!(bin=(unsigned char *)PyMem_Malloc(len))) { - PyErr_SetString(PyExc_MemoryError, "bn_to_bin"); - return NULL; - } - BN_bn2bin(bn, bin); - - pyo=PyBytes_FromStringAndSize((const char *)bin, len); - - PyMem_Free(bin); - return pyo; -} - -const BIGNUM *bin_to_bn(PyObject *value) { - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - return BN_bin2bn(vbuf, vlen, NULL); -} - -PyObject *bn_to_hex(BIGNUM *bn) { - char *hex; - PyObject *pyo; - Py_ssize_t len = 0; - - hex = BN_bn2hex(bn); - if (!hex) { - m2_PyErr_Msg(PyExc_RuntimeError); - OPENSSL_free(hex); - return NULL; - } - len = strlen(hex); - - pyo=PyBytes_FromStringAndSize(hex, len); - - OPENSSL_free(hex); - return pyo; -} - -BIGNUM *hex_to_bn(PyObject *value) { - const void *vbuf; - Py_ssize_t vlen = 0; - BIGNUM *bn; - Py_buffer view; - - if (PyObject_CheckBuffer(value)) { - if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { - vbuf = view.buf; - vlen = view.len; - } - } - else { - if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) - return NULL; - } - - if ((bn=BN_new())==NULL) { - m2_PyBuffer_Release(value, &view); - PyErr_SetString(PyExc_MemoryError, "hex_to_bn"); - return NULL; - } - if (BN_hex2bn(&bn, (const char *)vbuf) <= 0) { - m2_PyBuffer_Release(value, &view); - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return NULL; - } - m2_PyBuffer_Release(value, &view); - return bn; -} - -BIGNUM *dec_to_bn(PyObject *value) { - const void *vbuf; - Py_ssize_t vlen = 0; - BIGNUM *bn; - Py_buffer view; - - if (PyObject_CheckBuffer(value)) { - if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { - vbuf = view.buf; - vlen = view.len; - } - } - else { - if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) - return NULL; - } - - if ((bn=BN_new())==NULL) { - m2_PyBuffer_Release(value, &view); - PyErr_SetString(PyExc_MemoryError, "dec_to_bn"); - return NULL; - } - if ((BN_dec2bn(&bn, (const char *)vbuf) <= 0)) { - m2_PyBuffer_Release(value, &view); - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return NULL; - } - m2_PyBuffer_Release(value, &view); - return bn; -} - - -SWIGINTERNINLINE PyObject* -SWIG_From_unsigned_SS_long (unsigned long value) -{ - return (value > LONG_MAX) ? - PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); -} - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) -{ -#if PY_VERSION_HEX < 0x03000000 - if (PyInt_Check(obj)) { - long v = PyInt_AsLong(obj); - if (v >= 0) { - if (val) *val = v; - return SWIG_OK; - } else { - return SWIG_OverflowError; - } - } else -#endif - if (PyLong_Check(obj)) { - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - return SWIG_OverflowError; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - int dispatch = 0; - unsigned long v = PyLong_AsUnsignedLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_OK); - } else { - PyErr_Clear(); - } - if (!dispatch) { - double d; - int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { - if (val) *val = (unsigned long)(d); - return res; - } - } - } -#endif - return SWIG_TypeError; -} - - -#include - - -static PyObject *_bio_err; - - -void pyfd_init(void); - -void bio_init(PyObject *bio_err) { - Py_INCREF(bio_err); - _bio_err = bio_err; - pyfd_init(); -} - -int bio_free(BIO *bio) { - int ret; - - Py_BEGIN_ALLOW_THREADS - ret = BIO_free(bio); - Py_END_ALLOW_THREADS - if (ret == 0) { - m2_PyErr_Msg(_bio_err); - } - return ret; -} - -BIO * bio_new_file(const char *filename, const char *mode) { - BIO *ret; - - Py_BEGIN_ALLOW_THREADS - ret = BIO_new_file(filename, mode); - Py_END_ALLOW_THREADS - - if (ret == NULL) { - m2_PyErr_Msg(_bio_err); - } - - return ret; -} - -BIO *bio_new_pyfile(PyObject *pyfile, int bio_close) { - FILE *fp = NULL; - BIO *bio = NULL; - - fp = PyFile_AsFile(pyfile); - - bio = BIO_new_fp(fp, bio_close); - - /* returns NULL if error occurred */ - if (bio == NULL) { - /* Find out the name of the file so we can have good error - * message. */ - PyObject *pyname = m2_PyFile_Name(pyfile); - char *name = PyBytes_AsString(pyname); - - if (name == NULL) { - PyErr_Format(_bio_err, - "Opening of the new BIO on file failed!"); - } - else { - PyErr_Format(_bio_err, - "Opening of the new BIO on file %s failed!", name); - } - Py_DECREF(pyname); - } - return bio; -} - -PyObject *bio_read(BIO *bio, int num) { - PyObject *blob; - void *buf; - int r; - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "bio_read"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - r = BIO_read(bio, buf, num); - Py_END_ALLOW_THREADS - if (r < 0) { - PyMem_Free(buf); - if (ERR_peek_error()) { - m2_PyErr_Msg(_bio_err); - return NULL; - } - Py_RETURN_NONE; - } - - blob = PyBytes_FromStringAndSize(buf, r); - - PyMem_Free(buf); - return blob; -} - -PyObject *bio_gets(BIO *bio, int num) { - PyObject *blob; - void *buf; - int r; - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "bio_gets"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - r = BIO_gets(bio, buf, num); - Py_END_ALLOW_THREADS - if (r < 1) { - PyMem_Free(buf); - if (ERR_peek_error()) { - m2_PyErr_Msg(_bio_err); - return NULL; - } - Py_RETURN_NONE; - } - - blob = PyBytes_FromStringAndSize(buf, r); - - PyMem_Free(buf); - return blob; -} - -int bio_write(BIO *bio, PyObject *from) { - const void *fbuf; - int flen = 0, ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return -1; - - Py_BEGIN_ALLOW_THREADS - ret = BIO_write(bio, fbuf, flen); - Py_END_ALLOW_THREADS - if (ret < 0) { - if (ERR_peek_error()) { - m2_PyErr_Msg(_bio_err); - return -1; - } - } - return ret; -} - -/* XXX Casting size_t to int. */ -int bio_ctrl_pending(BIO *bio) { - return (int)BIO_ctrl_pending(bio); -} - -int bio_ctrl_wpending(BIO *bio) { - return (int)BIO_ctrl_wpending(bio); -} - -int bio_ctrl_get_write_guarantee(BIO *a) { - return BIO_ctrl_get_write_guarantee(a); -} - -int bio_reset(BIO *bio) { - return (int)BIO_reset(bio); -} - - -int bio_flush(BIO *bio) { - return (int)BIO_flush(bio); -} - -int bio_seek(BIO *bio, int offset) { - return (int)BIO_seek(bio, offset); -} - -int bio_tell(BIO* bio) { - return BIO_tell(bio); -} - -void bio_set_flags(BIO *bio, int flags) { - BIO_set_flags(bio, flags); -} - -int bio_get_flags(BIO *bio) { - return BIO_get_flags(bio); -} - -/* - * sets the cipher of BIO @param b to c using key @param key and IV @iv. - * @param enc should be set to 1 for encryption and zero to decryption. - * - */ -PyObject *bio_set_cipher(BIO *b, EVP_CIPHER *c, PyObject *key, PyObject *iv, int op) { - const void *kbuf, *ibuf; - Py_ssize_t klen, ilen; - - if ((PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) - || (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1)) - return NULL; - - BIO_set_cipher(b, (const EVP_CIPHER *)c, - (unsigned char *)kbuf, (unsigned char *)ibuf, op); - Py_RETURN_NONE; -} - -int bio_set_mem_eof_return(BIO *b, int v) { - return (int)BIO_set_mem_eof_return(b, v); -} - -int bio_get_fd(BIO *bio) { - return BIO_get_fd(bio, NULL); -} - - -int bio_do_handshake(BIO *bio) { - return BIO_do_handshake(bio); -} - -/* macro */ -int bio_make_bio_pair(BIO* b1, BIO* b2) { - return BIO_make_bio_pair(b1, b2); -} - -int bio_set_write_buf_size(BIO* b, size_t size) { - return BIO_set_write_buf_size(b, size); -} - -int bio_should_retry(BIO* a) { - return BIO_should_retry(a); -} - -int bio_should_read(BIO* a) { - return BIO_should_read(a); -} - -int bio_should_write(BIO* a) { - return BIO_should_write(a); -} - -/* Macros for things not defined before 1.1.0 */ -#if OPENSSL_VERSION_NUMBER < 0x10100000L -static BIO_METHOD * -BIO_meth_new( int type, const char *name ) -{ - BIO_METHOD *method = malloc( sizeof(BIO_METHOD) ); - memset( method, 0, sizeof(BIO_METHOD) ); - - method->type = type; - method->name = name; - - return method; -} - -static void -BIO_meth_free( BIO_METHOD *meth ) -{ - if ( meth == NULL ) { - return; - } - - free(meth); -} -#define BIO_meth_set_write(m, f) (m)->bwrite = (f) -#define BIO_meth_set_read(m, f) (m)->bread = (f) -#define BIO_meth_set_puts(m, f) (m)->bputs = (f) -#define BIO_meth_set_gets(m, f) (m)->bgets = (f) -#define BIO_meth_set_ctrl(m, f) (m)->ctrl = (f) -#define BIO_meth_set_create(m, f) (m)->create = (f) -#define BIO_meth_set_destroy(m, f) (m)->destroy = (f) -#define BIO_set_shutdown(b, x) (b)->shutdown = x -#define BIO_get_shutdown(b) (b)->shutdown -#define BIO_set_init(b, x) b->init = x -#define BIO_get_init(b) (b)->init -#define BIO_set_data(b, x) b->ptr = x -#define BIO_clear_flags(b, x) b->flags &= ~(x) -#define BIO_get_data(b) b->ptr -#endif - -/* implment custom BIO_s_pyfd */ - -#ifdef _WIN32 -# define clear_sys_error() SetLastError(0) -/* Linux doesn't use underscored calls yet */ -# define open(p, f, m) _open(p, f, m) -# define read(f, b, n) _read(f, b, n) -# define write(f, b, n) _write(f, b, n) -# define close(f) _close(f) -# define lseek(fd, o, w) _lseek(fd, o, w) -#else -# define clear_sys_error() errno=0 -#endif - -typedef struct pyfd_struct { - int fd; -} BIO_PYFD_CTX; - -/* Setting up methods_fdp */ -static BIO_METHOD *methods_fdp; - -static int pyfd_write(BIO *b, const char *in, int inl) { - int ret, fd; - - if (BIO_get_fd(b, &fd) == -1) { - PyErr_SetString(_bio_err, "BIO has not been initialized."); - return -1; - } - clear_sys_error(); - ret = write(fd, in, inl); - BIO_clear_retry_flags(b); - if (ret <= 0) { - if (BIO_fd_should_retry(ret)) - BIO_set_retry_write(b); - } - return ret; -} - -static int pyfd_read(BIO *b, char *out, int outl) { - int ret = 0, fd; - - if (BIO_get_fd(b, &fd) == -1) { - PyErr_SetString(_bio_err, "BIO has not been initialized."); - return -1; - } - if (out != NULL) { - clear_sys_error(); - ret = read(fd, out, outl); - BIO_clear_retry_flags(b); - if (ret <= 0) { - if (BIO_fd_should_retry(ret)) - BIO_set_retry_read(b); - } - } - return ret; -} - -static int pyfd_puts(BIO *bp, const char *str) { - int n, ret; - - n = strlen(str); - ret = pyfd_write(bp, str, n); - return ret; -} - -static int pyfd_gets(BIO *bp, char *buf, int size) { - int ret = 0; - char *ptr = buf; - char *end = buf + size - 1; - - /* See - https://github.com/openssl/openssl/pull/3442 - We were here just repeating a bug from OpenSSL - */ - while (ptr < end && pyfd_read(bp, ptr, 1) > 0) { - if (*ptr++ == '\n') - break; - } - - ptr[0] = '\0'; - - if (buf[0] != '\0') - ret = strlen(buf); - return ret; -} - -static int pyfd_new(BIO* b) { - BIO_PYFD_CTX* ctx; - - ctx = OPENSSL_zalloc(sizeof(*ctx)); - if (ctx == NULL) - return 0; - - ctx->fd = -1; - - BIO_set_data(b, ctx); - BIO_set_shutdown(b, 0); - BIO_set_init(b, 1); - - return 1; - } - -static int pyfd_free(BIO* b) { - BIO_PYFD_CTX* ctx; - - if (b == 0) - return 0; - - ctx = BIO_get_data(b); - if (ctx == NULL) - return 0; - - if (BIO_get_shutdown(b) && BIO_get_init(b)) - close(ctx->fd); - - BIO_set_data(b, NULL); - BIO_set_shutdown(b, 0); - BIO_set_init(b, 0); - - OPENSSL_free(ctx); - - return 1; -} - -static long pyfd_ctrl(BIO *b, int cmd, long num, void *ptr) { - BIO_PYFD_CTX* ctx; - int *ip; - long ret = 1; - - ctx = BIO_get_data(b); - if (ctx == NULL) - return 0; - - switch (cmd) { - case BIO_CTRL_RESET: - num = 0; - case BIO_C_FILE_SEEK: - ret = (long)lseek(ctx->fd, num, 0); - break; - case BIO_C_FILE_TELL: - case BIO_CTRL_INFO: - ret = (long)lseek(ctx->fd, 0, 1); - break; - case BIO_C_SET_FD: - pyfd_free(b); - if (*((int *)ptr) > -1) { - if (!pyfd_new(b) || !(ctx = BIO_get_data(b))) - return 0; - ctx->fd = *((int *)ptr); - BIO_set_shutdown(b, (int)num); - BIO_set_init(b, 1); - } - break; - case BIO_C_GET_FD: - if (BIO_get_init(b)) { - ip = (int *)ptr; - if (ip != NULL) - *ip = ctx->fd; - ret = ctx->fd; - } else - ret = -1; - break; - case BIO_CTRL_GET_CLOSE: - ret = BIO_get_shutdown(b); - break; - case BIO_CTRL_SET_CLOSE: - BIO_set_shutdown(b, (int)num); - break; - case BIO_CTRL_PENDING: - case BIO_CTRL_WPENDING: - ret = 0; - break; - case BIO_CTRL_DUP: - case BIO_CTRL_FLUSH: - ret = 1; - break; - default: - ret = 0; - break; - } - return ret; -} - -void pyfd_init(void) { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - methods_fdp = BIO_meth_new( - BIO_get_new_index()|BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, - "python file descriptor"); -#else - methods_fdp = BIO_meth_new( - 100 |BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, - "python file descriptor"); -#endif - - BIO_meth_set_write(methods_fdp, pyfd_write); - BIO_meth_set_read(methods_fdp, pyfd_read); - BIO_meth_set_puts(methods_fdp, pyfd_puts); - BIO_meth_set_gets(methods_fdp, pyfd_gets); - BIO_meth_set_ctrl(methods_fdp, pyfd_ctrl); - BIO_meth_set_create(methods_fdp, pyfd_new); - BIO_meth_set_destroy(methods_fdp, pyfd_free); -} - -BIO* BIO_new_pyfd(int fd, int close_flag) { - BIO *ret; - - ret = BIO_new(methods_fdp); - BIO_set_fd(ret, fd, close_flag); - return ret; - } - - -#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) -# define SWIG_LONG_LONG_AVAILABLE -#endif - - -#ifdef SWIG_LONG_LONG_AVAILABLE -SWIGINTERN int -SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) -{ - int res = SWIG_TypeError; - if (PyLong_Check(obj)) { - unsigned long long v = PyLong_AsUnsignedLongLong(obj); - if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_OK; - } else { - PyErr_Clear(); - res = SWIG_OverflowError; - } - } else { - unsigned long v; - res = SWIG_AsVal_unsigned_SS_long (obj,&v); - if (SWIG_IsOK(res)) { - if (val) *val = v; - return res; - } - } -#ifdef SWIG_PYTHON_CAST_MODE - { - const double mant_max = 1LL << DBL_MANT_DIG; - double d; - res = SWIG_AsVal_double (obj,&d); - if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) - return SWIG_OverflowError; - if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { - if (val) *val = (unsigned long long)(d); - return SWIG_AddCast(res); - } - res = SWIG_TypeError; - } -#endif - return res; -} -#endif - - -SWIGINTERNINLINE int -SWIG_AsVal_size_t (PyObject * obj, size_t *val) -{ - int res = SWIG_TypeError; -#ifdef SWIG_LONG_LONG_AVAILABLE - if (sizeof(size_t) <= sizeof(unsigned long)) { -#endif - unsigned long v; - res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = (size_t)(v); -#ifdef SWIG_LONG_LONG_AVAILABLE - } else if (sizeof(size_t) <= sizeof(unsigned long long)) { - unsigned long long v; - res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); - if (SWIG_IsOK(res) && val) *val = (size_t)(v); - } -#endif - return res; -} - - -#include - - -PyObject *bn_rand(int bits, int top, int bottom) -{ - BIGNUM* rnd; - PyObject *ret; - char *randhex; - - rnd = BN_new(); - if (rnd == NULL) { - m2_PyErr_Msg(PyExc_Exception); - return NULL; - } - - if (!BN_rand(rnd, bits, top, bottom)) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - return NULL; - } - - randhex = BN_bn2hex(rnd); - if (!randhex) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - return NULL; - } - BN_free(rnd); - - ret = PyLong_FromString(randhex, NULL, 16); - OPENSSL_free(randhex); - return ret; -} - - -PyObject *bn_rand_range(PyObject *range) -{ - BIGNUM* rnd; - BIGNUM *rng = NULL; - PyObject *ret, *tuple; - PyObject *format, *rangePyString; - char *randhex; /* PyLong_FromString is unhappy with const */ - const char *rangehex; - - /* Wow, it's a lot of work to convert into a hex string in C! */ - format = PyUnicode_FromString("%x"); - - if (!format) { - PyErr_SetString(PyExc_RuntimeError, "Cannot create Python string '%x'"); - return NULL; - } - tuple = PyTuple_New(1); - if (!tuple) { - Py_DECREF(format); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - Py_INCREF(range); - PyTuple_SET_ITEM(tuple, 0, range); - - rangePyString = PyUnicode_Format(format, tuple); - - if (!rangePyString) { - PyErr_SetString(PyExc_Exception, "String Format failed"); - Py_DECREF(format); - Py_DECREF(tuple); - return NULL; - } - Py_DECREF(format); - Py_DECREF(tuple); - - rangehex = (const char*)PyUnicode_AsUTF8(rangePyString); - - if (!BN_hex2bn(&rng, rangehex)) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - Py_DECREF(rangePyString); - return NULL; - } - - Py_DECREF(rangePyString); - - if (!(rnd = BN_new())) { - PyErr_SetString(PyExc_MemoryError, "bn_rand_range"); - return NULL; - } - - if (!BN_rand_range(rnd, rng)) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - BN_free(rng); - return NULL; - } - - BN_free(rng); - - randhex = BN_bn2hex(rnd); - if (!randhex) { - /*Custom errors?*/ - m2_PyErr_Msg(PyExc_Exception); - BN_free(rnd); - return NULL; - } - BN_free(rnd); - - ret = PyLong_FromString(randhex, NULL, 16); - OPENSSL_free(randhex); - return ret; -} - - - -static PyObject *_rand_err; - -void rand_init(PyObject *rand_err) { - Py_INCREF(rand_err); - _rand_err = rand_err; -} - -PyObject *rand_seed(PyObject *seed) { - const void *buf; - int len = 0; - - m2_PyObject_AsReadBufferInt(seed, &buf, &len); - - RAND_seed(buf, len); - Py_RETURN_NONE; -} - -PyObject *rand_add(PyObject *blob, double entropy) { - const void *buf; - int len = 0; - - m2_PyObject_AsReadBufferInt(blob, &buf, &len); - - RAND_add(buf, len, entropy); - Py_RETURN_NONE; -} - -PyObject *rand_bytes(int n) { - void *blob; - int ret; - PyObject *obj; - - if (!(blob = PyMem_Malloc(n))) { - PyErr_SetString(PyExc_MemoryError, - "Insufficient memory for rand_bytes."); - return NULL; - } - if ((ret = RAND_bytes(blob, n)) == 1) { - obj = PyBytes_FromStringAndSize(blob, n); - PyMem_Free(blob); - return obj; - } else if (ret == 0) { - PyErr_SetString(_rand_err, "Not enough randomness."); - PyMem_Free(blob); - return NULL; - } else if (ret == -1) { - PyErr_SetString(_rand_err, - "Not supported by the current RAND method."); - PyMem_Free(blob); - return NULL; - } else { - PyMem_Free(blob); - m2_PyErr_Msg(_rand_err); - return NULL; - } -} - -PyObject *rand_pseudo_bytes(int n) { - int ret; - unsigned char *blob; - PyObject *tuple; - - if (!(blob=(unsigned char *)PyMem_Malloc(n))) { - PyErr_SetString(PyExc_MemoryError, "Insufficient memory for rand_pseudo_bytes."); - return NULL; - } - if (!(tuple=PyTuple_New(2))) { - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - PyMem_Free(blob); - return NULL; - } - ret = RAND_pseudo_bytes(blob, n); - if (ret == -1) { - PyMem_Free(blob); - Py_DECREF(tuple); - PyErr_SetString(_rand_err, - "Function RAND_pseudo_bytes not supported by the current RAND method."); - return NULL; - } else { - PyTuple_SET_ITEM(tuple, 0, PyBytes_FromStringAndSize((char*)blob, n)); - - PyMem_Free(blob); - PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong((long)ret)); - return tuple; - } -} - -PyObject *rand_file_name(void) { - PyObject *obj; - char *str; - if ((obj = PyBytes_FromStringAndSize(NULL, BUFSIZ))==NULL) { - PyErr_SetString(PyExc_MemoryError, "rand_file_name"); - return NULL; - } - str=PyBytes_AS_STRING(obj); - if (RAND_file_name(str, BUFSIZ)==NULL) { - PyErr_SetString(PyExc_RuntimeError, "rand_file_name"); - return NULL; - } - if (_PyBytes_Resize(&obj, (Py_ssize_t)strlen(str))!=0) - return NULL; /* mem exception set by _PyBytes_Resize */ - return obj; -} - -void rand_screen(void) { -#ifdef _WIN32 - RAND_screen(); -#endif -} - -int rand_win32_event(unsigned int imsg, int wparam, long lparam) { -#ifdef _WIN32 - return RAND_event(imsg, wparam, lparam); -#else - return 0; -#endif -} - - -SWIGINTERN int -SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) -{ - unsigned long v; - int res = SWIG_AsVal_unsigned_SS_long (obj, &v); - if (SWIG_IsOK(res)) { - if ((v > UINT_MAX)) { - return SWIG_OverflowError; - } else { - if (val) *val = (unsigned int)(v); - } - } - return res; -} - - -#include -#include -#include -#include -#include -#include - -#if OPENSSL_VERSION_NUMBER < 0x10100000L - -HMAC_CTX *HMAC_CTX_new(void) { - HMAC_CTX *ret = PyMem_Malloc(sizeof(HMAC_CTX)); - HMAC_CTX_init(ret); - return ret; -} -#define HMAC_CTX_reset(ctx) HMAC_CTX_init(ctx) -#define HMAC_CTX_free(ctx) \ - do { \ - HMAC_CTX_cleanup(ctx); \ - PyMem_Free((void *)ctx); \ - } while(0) - -#define EVP_CIPHER_CTX_reset(ctx) EVP_CIPHER_CTX_init(ctx) -#endif - - -#define PKCS5_SALT_LEN 8 - -static PyObject *_evp_err; - -void evp_init(PyObject *evp_err) { - Py_INCREF(evp_err); - _evp_err = evp_err; -} - - -RSA *pkey_get1_rsa(EVP_PKEY *pkey) { - RSA *ret = NULL; - - if ((ret = EVP_PKEY_get1_RSA(pkey)) == NULL) { - /* _evp_err now inherits from PyExc_ValueError, so we should - * keep API intact. - */ - PyErr_Format(_evp_err, "Invalid key in function %s.", __FUNCTION__); - } - - return ret; -} - - -PyObject *pkcs5_pbkdf2_hmac_sha1(PyObject *pass, - PyObject *salt, - int iter, - int keylen) { - unsigned char *key; - const void *saltbuf; - const void *passbuf; - PyObject *ret; - int passlen = 0, saltlen = 0; - - if (m2_PyObject_AsReadBufferInt(pass, &passbuf, &passlen) == -1) - return NULL; - if (m2_PyObject_AsReadBufferInt(salt, &saltbuf, &saltlen) == -1) - return NULL; - - key = PyMem_Malloc(keylen); - if (key == NULL) - return PyErr_NoMemory(); - PKCS5_PBKDF2_HMAC_SHA1((const char *)passbuf, passlen, (const unsigned char *)saltbuf, saltlen, iter, - keylen, key); - ret = PyBytes_FromStringAndSize((char*)key, keylen); - OPENSSL_cleanse(key, keylen); - PyMem_Free(key); - return ret; -} - -EVP_MD_CTX *md_ctx_new(void) { - EVP_MD_CTX *ctx; - - if (!(ctx = EVP_MD_CTX_create())) { - PyErr_SetString(PyExc_MemoryError, "md_ctx_new"); - return NULL; - } - return ctx; -} - -void md_ctx_free(EVP_MD_CTX *ctx) { - EVP_MD_CTX_destroy(ctx); -} - -int digest_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - Py_ssize_t len; - - if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) - return -1; - - return EVP_DigestUpdate(ctx, buf, (size_t)len); -} - -PyObject *digest_final(EVP_MD_CTX *ctx) { - void *blob; - int blen; - PyObject *ret; - - if (!(blob = PyMem_Malloc(EVP_MD_CTX_size(ctx)))) { - PyErr_SetString(PyExc_MemoryError, "digest_final"); - return NULL; - } - if (!EVP_DigestFinal(ctx, blob, (unsigned int *)&blen)) { - PyMem_Free(blob); - m2_PyErr_Msg(_evp_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize(blob, blen); - - PyMem_Free(blob); - return ret; -} - -HMAC_CTX *hmac_ctx_new(void) { - HMAC_CTX *ctx; - - if (!(ctx = HMAC_CTX_new())) { - PyErr_SetString(PyExc_MemoryError, "hmac_ctx_new"); - return NULL; - } - return ctx; -} - -void hmac_ctx_free(HMAC_CTX *ctx) { - HMAC_CTX_free(ctx); -} - -PyObject *hmac_init(HMAC_CTX *ctx, PyObject *key, const EVP_MD *md) { - const void *kbuf; - int klen = 0; - - if (m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) - return NULL; - - if (!HMAC_Init_ex(ctx, kbuf, klen, md, NULL)) { - PyErr_SetString(_evp_err, "HMAC_Init failed"); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *hmac_update(HMAC_CTX *ctx, PyObject *blob) { - const void *buf; - Py_ssize_t len; - - if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) - return NULL; - - if (!HMAC_Update(ctx, (const unsigned char *)buf, (size_t)len)) { - PyErr_SetString(_evp_err, "HMAC_Update failed"); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *hmac_final(HMAC_CTX *ctx) { - void *blob; - int blen; - PyObject *ret; - - if (!(blob = PyMem_Malloc(HMAC_size(ctx)))) { - PyErr_SetString(PyExc_MemoryError, "hmac_final"); - return NULL; - } - - if (!HMAC_Final(ctx, blob, (unsigned int *)&blen)) { - PyErr_SetString(_evp_err, "HMAC_Final failed"); - return NULL; - } - - ret = PyBytes_FromStringAndSize(blob, blen); - - PyMem_Free(blob); - return ret; -} - -PyObject *hmac(PyObject *key, PyObject *data, const EVP_MD *md) { - const void *kbuf, *dbuf; - void *blob; - int klen = 0; - unsigned int blen; - Py_ssize_t dlen; - PyObject *ret; - - if ((m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) - || (m2_PyObject_AsReadBuffer(data, &dbuf, &dlen) == -1)) - return NULL; - - if (!(blob = PyMem_Malloc(EVP_MAX_MD_SIZE))) { - PyErr_SetString(PyExc_MemoryError, "hmac"); - return NULL; - } - HMAC(md, kbuf, klen, (const unsigned char *)dbuf, (size_t)dlen, (unsigned char *)blob, &blen); - blob = PyMem_Realloc(blob, blen); - - ret = PyBytes_FromStringAndSize(blob, blen); - - PyMem_Free(blob); - return ret; -} - -EVP_CIPHER_CTX *cipher_ctx_new(void) { - EVP_CIPHER_CTX *ctx; - - if (!(ctx = EVP_CIPHER_CTX_new())) { - PyErr_SetString(PyExc_MemoryError, "cipher_ctx_new"); - return NULL; - } - EVP_CIPHER_CTX_reset(ctx); - return ctx; -} - -void cipher_ctx_free(EVP_CIPHER_CTX *ctx) { - EVP_CIPHER_CTX_free(ctx); -} - -PyObject *bytes_to_key(const EVP_CIPHER *cipher, EVP_MD *md, - PyObject *data, PyObject *salt, - PyObject *iv, /* Not used */ - int iter) { - unsigned char key[EVP_MAX_KEY_LENGTH]; - const void *dbuf, *sbuf; - int dlen = 0, klen; - Py_ssize_t slen; - PyObject *ret; - - if ((m2_PyObject_AsReadBufferInt(data, &dbuf, &dlen) == -1) - || (m2_PyObject_AsReadBuffer(salt, &sbuf, &slen) == -1)) - return NULL; - - assert((slen == 8) || (slen == 0)); - klen = EVP_BytesToKey(cipher, md, (unsigned char *)sbuf, - (unsigned char *)dbuf, dlen, iter, - key, NULL); /* Since we are not returning IV no need to derive it */ - - ret = PyBytes_FromStringAndSize((char*)key, klen); - - return ret; -} - -PyObject *cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - PyObject *key, PyObject *iv, int mode) { - const void *kbuf, *ibuf; - Py_ssize_t klen, ilen; - - if (key == Py_None) - kbuf = NULL; - else if (m2_PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) - return NULL; - - if (iv == Py_None) - ibuf = NULL; - else if (m2_PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1) - return NULL; - - if (!EVP_CipherInit(ctx, cipher, (unsigned char *)kbuf, - (unsigned char *)ibuf, mode)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *cipher_update(EVP_CIPHER_CTX *ctx, PyObject *blob) { - const void *buf; - int len = 0, olen; - void *obuf; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) - return NULL; - - if (!(obuf = PyMem_Malloc(len + EVP_CIPHER_CTX_block_size(ctx) - 1))) { - PyErr_SetString(PyExc_MemoryError, "cipher_update"); - return NULL; - } - if (!EVP_CipherUpdate(ctx, obuf, &olen, (unsigned char *)buf, len)) { - PyMem_Free(obuf); - m2_PyErr_Msg(_evp_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize(obuf, olen); - - PyMem_Free(obuf); - return ret; -} - -PyObject *cipher_final(EVP_CIPHER_CTX *ctx) { - void *obuf; - int olen; - PyObject *ret; - - if (!(obuf = PyMem_Malloc(EVP_CIPHER_CTX_block_size(ctx)))) { - PyErr_SetString(PyExc_MemoryError, "cipher_final"); - return NULL; - } - if (!EVP_CipherFinal(ctx, (unsigned char *)obuf, &olen)) { - PyMem_Free(obuf); - m2_PyErr_Msg(_evp_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize(obuf, olen); - - PyMem_Free(obuf); - return ret; -} - -PyObject *sign_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len; - - if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) - return NULL; - - if (!EVP_SignUpdate(ctx, buf, (Py_ssize_t)len)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *sign_final(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { - PyObject *ret; - unsigned char *sigbuf; - unsigned int siglen = EVP_PKEY_size(pkey); - - sigbuf = (unsigned char*)OPENSSL_malloc(siglen); - if (!sigbuf) { - PyErr_SetString(PyExc_MemoryError, "sign_final"); - return NULL; - } - - if (!EVP_SignFinal(ctx, sigbuf, &siglen, pkey)) { - m2_PyErr_Msg(_evp_err); - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); - - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return ret; -} - -int verify_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len; - - if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) - return -1; - - return EVP_VerifyUpdate(ctx, buf, (Py_ssize_t)len); -} - -int verify_final(EVP_MD_CTX *ctx, PyObject *blob, EVP_PKEY *pkey) { - const void *kbuf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, &kbuf, &len) == -1) - return -1; - - return EVP_VerifyFinal(ctx, (const unsigned char *)kbuf, len, pkey); -} - -int digest_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { - return EVP_DigestSignInit(ctx, NULL, NULL, NULL, pkey); -} - -PyObject *digest_sign_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) - return NULL; - - if (!EVP_DigestSignUpdate(ctx, buf, len)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *digest_sign_final(EVP_MD_CTX *ctx) { - PyObject *ret; - unsigned char *sigbuf; - size_t siglen; - - if (!EVP_DigestSignFinal(ctx, NULL, &siglen)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - - sigbuf = (unsigned char*)OPENSSL_malloc(siglen); - if (!sigbuf) { - PyErr_SetString(PyExc_MemoryError, "digest_sign_final"); - return NULL; - } - - if (!EVP_DigestSignFinal(ctx, sigbuf, &siglen)) { - m2_PyErr_Msg(_evp_err); - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); - - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return ret; -} - -#if OPENSSL_VERSION_NUMBER >= 0x10101000L -PyObject *digest_sign(EVP_MD_CTX *ctx, PyObject *msg) { - PyObject *ret; - const void *msgbuf; - unsigned char *sigbuf; - int msglen = 0; - size_t siglen = 0; - - if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) - return NULL; - - if (!EVP_DigestSign(ctx, NULL, &siglen, msgbuf, msglen)) { - m2_PyErr_Msg(_evp_err); - return NULL; - } - - sigbuf = (unsigned char*)OPENSSL_malloc(siglen); - if (!sigbuf) { - PyErr_SetString(PyExc_MemoryError, "digest_sign"); - return NULL; - } - - if (!EVP_DigestSign(ctx, sigbuf, &siglen, msgbuf, msglen)) { - m2_PyErr_Msg(_evp_err); - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); - - OPENSSL_cleanse(sigbuf, siglen); - OPENSSL_free(sigbuf); - return ret; - -} -#endif - -int digest_verify_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { - return EVP_DigestVerifyInit(ctx, NULL, NULL, NULL, pkey); -} - -int digest_verify_update(EVP_MD_CTX *ctx, PyObject *blob) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) - return -1; - - return EVP_DigestVerifyUpdate(ctx, buf, len); -} - -int digest_verify_final(EVP_MD_CTX *ctx, PyObject *blob) { - unsigned char *sigbuf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(blob, (const void **)&sigbuf, &len) == -1) - return -1; - - return EVP_DigestVerifyFinal(ctx, sigbuf, len); -} - -#if OPENSSL_VERSION_NUMBER >= 0x10101000L -int digest_verify(EVP_MD_CTX *ctx, PyObject *sig, PyObject *msg) { - unsigned char *sigbuf; - unsigned char *msgbuf; - int siglen = 0; - int msglen = 0; - - if (m2_PyObject_AsReadBufferInt(sig, (const void **)&sigbuf, &siglen) == -1) - return -1; - - if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) - return -1; - - return EVP_DigestVerify(ctx, sigbuf, siglen, msgbuf, msglen); -} -#endif - - -const EVP_MD *get_digestbyname(const char* name) { - const EVP_MD *ret = NULL; - - if ((ret = EVP_get_digestbyname(name)) == NULL) { - m2_PyErr_Msg(_evp_err); - } - - return ret; -} - - -int pkey_write_pem_no_cipher(EVP_PKEY *pkey, BIO *f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -int pkey_write_pem(EVP_PKEY *pkey, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -EVP_PKEY *pkey_new(void) { - EVP_PKEY *ret; - - if ((ret = EVP_PKEY_new()) == NULL) { - PyErr_Format(PyExc_MemoryError, - "Insufficient memory for new key in function %s.", __FUNCTION__); - } - - return ret; -} - -EVP_PKEY *pkey_read_pem(BIO *f, PyObject *pyfunc) { - EVP_PKEY *pk; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - pk = PEM_read_bio_PrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (pk == NULL) { - PyErr_Format(_evp_err, - "Unable to read private key in function %s.", __FUNCTION__); - } - - return pk; -} - -EVP_PKEY *pkey_read_pem_pubkey(BIO *f, PyObject *pyfunc) { - EVP_PKEY *pk; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - pk = PEM_read_bio_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (pk == NULL) { - PyErr_Format(_evp_err, - "Unable to read public key in function %s.", __FUNCTION__); - } - - return pk; -} - - -int pkey_assign_rsa(EVP_PKEY *pkey, RSA *rsa) { - return EVP_PKEY_assign_RSA(pkey, rsa); -} - -PyObject *pkey_as_der(EVP_PKEY *pkey) { - unsigned char * pp = NULL; - int len; - PyObject * der; - len = i2d_PUBKEY(pkey, &pp); - if (len < 0){ - PyErr_SetString(_evp_err, "EVP_PKEY as DER failed"); - return NULL; - } - - der = PyBytes_FromStringAndSize((char*)pp, len); - - OPENSSL_free(pp); - return der; -} - -PyObject *pkey_get_modulus(EVP_PKEY *pkey) -{ - RSA *rsa; - DSA *dsa; - BIO *bio; - BUF_MEM *bptr; - PyObject *ret; - const BIGNUM* bn; - - switch (EVP_PKEY_base_id(pkey)) { - case EVP_PKEY_RSA: - rsa = EVP_PKEY_get1_RSA(pkey); - - bio = BIO_new(BIO_s_mem()); - if (!bio) { - RSA_free(rsa); - PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); - return NULL; - } - - RSA_get0_key(rsa, &bn, NULL, NULL); - if (!BN_print(bio, bn)) { - m2_PyErr_Msg(PyExc_RuntimeError); - BIO_free(bio); - RSA_free(rsa); - return NULL; - } - BIO_get_mem_ptr(bio, &bptr); - - ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); - - (void)BIO_set_close(bio, BIO_CLOSE); - BIO_free(bio); - RSA_free(rsa); - - return ret; - break; - - case EVP_PKEY_DSA: - dsa = EVP_PKEY_get1_DSA(pkey); - - bio = BIO_new(BIO_s_mem()); - if (!bio) { - DSA_free(dsa); - PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); - return NULL; - } - - DSA_get0_key(dsa, &bn, NULL); - if (!BN_print(bio, bn)) { - m2_PyErr_Msg(PyExc_RuntimeError); - BIO_free(bio); - DSA_free(dsa); - return NULL; - } - BIO_get_mem_ptr(bio, &bptr); - - ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); - - (void)BIO_set_close(bio, BIO_CLOSE); - BIO_free(bio); - DSA_free(dsa); - - return ret; - break; - - default: - PyErr_SetString(_evp_err, "unsupported key type"); - return NULL; - } -} - - - -#include - -#if OPENSSL_VERSION_NUMBER >= 0x0090800fL -#include -#endif - -/* -// 2004-10-10, ngps: -// CTR mode is not included in the default OpenSSL build. -// To use the AES CTR ciphers, link with your own copy of OpenSSL. -*/ -#ifdef HAVE_AES_CTR -extern EVP_CIPHER const *EVP_aes_128_ctr(void); -extern EVP_CIPHER const *EVP_aes_192_ctr(void); -extern EVP_CIPHER const *EVP_aes_256_ctr(void); -#endif - - -AES_KEY *aes_new(void) { - AES_KEY *key; - - if (!(key = (AES_KEY *)PyMem_Malloc(sizeof(AES_KEY)))) { - PyErr_SetString(PyExc_MemoryError, - "Insufficient memory for AES key."); - return NULL; - } - return key; -} - -void AES_free(AES_KEY *key) { - PyMem_Free((void *)key); -} - -/* -// op == 0: encrypt -// otherwise: decrypt (Python code will supply the value 1.) -*/ -PyObject *AES_set_key(AES_KEY *key, PyObject *value, int bits, int op) { - char *vbuf; - Py_ssize_t vlen; - - if (PyBytes_AsStringAndSize(value, &vbuf, &vlen) == -1) - return NULL; - - if (op == 0) - AES_set_encrypt_key((const unsigned char *)vbuf, bits, key); - else - AES_set_decrypt_key((const unsigned char *)vbuf, bits, key); - Py_RETURN_NONE; -} - -/* -// op == 0: encrypt -// otherwise: decrypt (Python code will supply the value 1.) -*/ -PyObject *AES_crypt(const AES_KEY *key, PyObject *in, int outlen, int op) { - char *buf; - Py_ssize_t len; - unsigned char *out; - PyObject *res; - - if (PyBytes_AsStringAndSize(in, &buf, &len) == -1) - return NULL; - - if (!(out=(unsigned char *)PyMem_Malloc(outlen))) { - PyErr_SetString(PyExc_MemoryError, "AES_crypt"); - return NULL; - } - if (op == 0) - AES_encrypt((const unsigned char *)buf, out, key); - else - AES_decrypt((const unsigned char *)buf, out, key); - res = PyBytes_FromStringAndSize((char*)out, outlen); - PyMem_Free(out); - return res; -} - -int AES_type_check(AES_KEY *key) { - return 1; -} - - -#include - - -RC4_KEY *rc4_new(void) { - RC4_KEY *key; - - if (!(key = (RC4_KEY *)PyMem_Malloc(sizeof(RC4_KEY)))) - PyErr_SetString(PyExc_MemoryError, "rc4_new"); - return key; -} - -void rc4_free(RC4_KEY *key) { - PyMem_Free((void *)key); -} - -PyObject *rc4_set_key(RC4_KEY *key, PyObject *value) { - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - RC4_set_key(key, vlen, vbuf); - Py_RETURN_NONE; -} - -PyObject *rc4_update(RC4_KEY *key, PyObject *in) { - PyObject *ret; - const void *buf; - Py_ssize_t len; - void *out; - - if (PyObject_AsReadBuffer(in, &buf, &len) == -1) - return NULL; - - if (!(out = PyMem_Malloc(len))) { - PyErr_SetString(PyExc_MemoryError, "expected a string object"); - return NULL; - } - RC4(key, len, buf, out); - - ret = PyBytes_FromStringAndSize(out, len); - - PyMem_Free(out); - return ret; -} - -int rc4_type_check(RC4_KEY *key) { - return 1; -} - - -#include -#include -#include -#include -#include - - -static PyObject *_dh_err; - -void dh_init(PyObject *dh_err) { - Py_INCREF(dh_err); - _dh_err = dh_err; -} - -int dh_type_check(DH *dh) { - /* Our getting here means we passed Swig's type checking, - XXX Still need to check the pointer for sanity? */ - return 1; -} - - -DH *dh_read_parameters(BIO *bio) { - return PEM_read_bio_DHparams(bio, NULL, NULL, NULL); -} - -DH *dh_generate_parameters(int plen, int g, PyObject *pyfunc) { - DH *dh; - BN_GENCB *gencb; - int ret; - - if ((gencb=BN_GENCB_new()) == NULL) { - m2_PyErr_Msg(_dh_err); - return NULL; - } - - if ((dh=DH_new()) == NULL) { - m2_PyErr_Msg(_dh_err); - BN_GENCB_free(gencb); - return NULL; - } - - BN_GENCB_set(gencb, bn_gencb_callback, (void *)pyfunc); - - Py_INCREF(pyfunc); - ret = DH_generate_parameters_ex(dh, plen, g, gencb); - Py_DECREF(pyfunc); - BN_GENCB_free(gencb); - - if (ret) - return dh; - - m2_PyErr_Msg(_dh_err); - DH_free(dh); - return NULL; -} - -/* Note return value shenanigan. */ -int dh_check(DH *dh) { - int err; - - return (DH_check(dh, &err)) ? 0 : err; -} - -PyObject *dh_compute_key(DH *dh, PyObject *pubkey) { - const void *pkbuf; - int pklen = 0, klen; - void *key; - BIGNUM *pk; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(pubkey, &pkbuf, &pklen) == -1) - return NULL; - - if (!(pk = BN_mpi2bn((unsigned char *)pkbuf, pklen, NULL))) { - m2_PyErr_Msg(_dh_err); - return NULL; - } - if (!(key = PyMem_Malloc(DH_size(dh)))) { - BN_free(pk); - PyErr_SetString(PyExc_MemoryError, "dh_compute_key"); - return NULL; - } - if ((klen = DH_compute_key((unsigned char *)key, pk, dh)) == -1) { - BN_free(pk); - PyMem_Free(key); - m2_PyErr_Msg(_dh_err); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)key, klen); - - BN_free(pk); - PyMem_Free(key); - return ret; -} - -PyObject *dh_get_p(DH *dh) { - const BIGNUM* p = NULL; - DH_get0_pqg(dh, &p, NULL, NULL); - if (!p) { - PyErr_SetString(_dh_err, "'p' is unset"); - return NULL; - } - return bn_to_mpi(p); -} - -PyObject *dh_get_g(DH *dh) { - const BIGNUM* g = NULL; - DH_get0_pqg(dh, NULL, NULL, &g); - if (!g) { - PyErr_SetString(_dh_err, "'g' is unset"); - return NULL; - } - return bn_to_mpi(g); -} - -PyObject *dh_get_pub(DH *dh) { - const BIGNUM* pub_key = NULL; - DH_get0_key(dh, &pub_key, NULL); - if (!pub_key) { - PyErr_SetString(_dh_err, "'pub' is unset"); - return NULL; - } - return bn_to_mpi(pub_key); -} - -PyObject *dh_get_priv(DH *dh) { - const BIGNUM* priv_key = NULL; - DH_get0_key(dh, NULL, &priv_key); - if (!priv_key) { - PyErr_SetString(_dh_err, "'priv' is unset"); - return NULL; - } - return bn_to_mpi(priv_key); -} - -PyObject *dh_set_pg(DH *dh, PyObject *pval, PyObject* gval) { - BIGNUM* p, *g; - - if (!(p = m2_PyObject_AsBIGNUM(pval, _dh_err)) - || !(g = m2_PyObject_AsBIGNUM(gval, _dh_err))) - return NULL; - - if (!DH_set0_pqg(dh, p, NULL, g)) { - PyErr_SetString(_dh_err, - "Cannot set prime number or generator of Z_p for DH."); - BN_free(p); - BN_free(g); - return NULL; - } - - Py_RETURN_NONE; -} - - -#include -#include -#include -#include -#include - - -static PyObject *_rsa_err; - -void rsa_init(PyObject *rsa_err) { - Py_INCREF(rsa_err); - _rsa_err = rsa_err; -} - - -RSA *rsa_read_key(BIO *f, PyObject *pyfunc) { - RSA *rsa; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - rsa = PEM_read_bio_RSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return rsa; -} - - -int rsa_write_key(RSA *rsa, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_RSAPrivateKey(f, rsa, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -int rsa_write_key_no_cipher(RSA *rsa, BIO *f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_RSAPrivateKey(f, rsa, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -RSA *rsa_read_pub_key(BIO *f) { - return PEM_read_bio_RSA_PUBKEY(f, NULL, NULL, NULL); -} - - -int rsa_write_pub_key(RSA *rsa, BIO *f) { - return PEM_write_bio_RSA_PUBKEY(f, rsa); -} - -PyObject *rsa_get_e(RSA *rsa) { - const BIGNUM* e = NULL; - RSA_get0_key(rsa, NULL, &e, NULL); - if (!e) { - PyErr_SetString(_rsa_err, "'e' is unset"); - return NULL; - } - return bn_to_mpi(e); -} - -PyObject *rsa_get_n(RSA *rsa) { - const BIGNUM* n = NULL; - RSA_get0_key(rsa, &n, NULL, NULL); - if (!n) { - PyErr_SetString(_rsa_err, "'n' is unset"); - return NULL; - } - return bn_to_mpi(n); -} - -PyObject *rsa_set_e(RSA *rsa, PyObject *eval) { - const BIGNUM* n_read = NULL; - BIGNUM* n = NULL; - BIGNUM* e; - - if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err))) { - return NULL; - } - - /* n and e must be set at the same time so if e is unset, set it to zero */ - RSA_get0_key(rsa, &n_read, NULL, NULL); - if (!n_read) { - n = BN_new(); - } - - if (RSA_set0_key(rsa, n, e, NULL) != 1) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(e); - BN_free(n); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *rsa_set_n(RSA *rsa, PyObject *nval) { - BIGNUM* n; - const BIGNUM* e_read = NULL; - BIGNUM* e = NULL; - - if (!(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { - return NULL; - } - - /* n and e must be set at the same time so if e is unset, set it to zero */ - RSA_get0_key(rsa, NULL, &e_read, NULL); - if (!e_read) { - e = BN_new(); - } - - if (RSA_set0_key(rsa, n, e, NULL) != 1) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(n); - BN_free(e); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *rsa_set_en(RSA *rsa, PyObject *eval, PyObject* nval) { - BIGNUM* e, *n; - - if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err)) || - !(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { - return NULL; - } - - if (!RSA_set0_key(rsa, n, e, NULL)) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(e); - BN_free(n); - return NULL; - } - Py_RETURN_NONE; -} - -static BIGNUM* PyObject_Bin_AsBIGNUM(PyObject* value) { - BIGNUM* bn; - const void* vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(bn = BN_bin2bn((unsigned char *)vbuf, vlen, NULL))) { - m2_PyErr_Msg(_rsa_err); - return NULL; - } - - return bn; -} - -PyObject *rsa_set_en_bin(RSA *rsa, PyObject *eval, PyObject* nval) { - BIGNUM* e, *n; - - if (!(e = PyObject_Bin_AsBIGNUM(eval)) || - !(n = PyObject_Bin_AsBIGNUM(nval))) { - return NULL; - } - - if (!RSA_set0_key(rsa, e, n, NULL)) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(e); - BN_free(n); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *rsa_private_encrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_private_encrypt"); - return NULL; - } - tlen = RSA_private_encrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -PyObject *rsa_public_decrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen = 0; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - /* OpenSSL docs are confused here: it says we only need buffer - * 'RSA_size()-11', but it is true only for RSA PKCS#1 type 1 - * padding. For other uses we need to use different sizes. */ - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_public_decrypt"); - return NULL; - } - tlen = RSA_public_decrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -PyObject *rsa_public_encrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_public_encrypt"); - return NULL; - } - tlen = RSA_public_encrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -PyObject *rsa_private_decrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_private_decrypt"); - return NULL; - } - tlen = RSA_private_decrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -#if OPENSSL_VERSION_NUMBER >= 0x0090708fL -PyObject *rsa_padding_add_pkcs1_pss(RSA *rsa, PyObject *digest, EVP_MD *hash, int salt_length) { - const void *dbuf; - unsigned char *tbuf; - int dlen, result, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) - return NULL; - - tlen = RSA_size(rsa); - - if (!(tbuf = OPENSSL_malloc(tlen))) { - PyErr_SetString(PyExc_MemoryError, "rsa_padding_add_pkcs1_pss"); - return NULL; - } - result = RSA_padding_add_PKCS1_PSS( - rsa, - tbuf, - (unsigned char *)dbuf, - hash, - salt_length); - - if (result == -1) { - m2_PyErr_Msg(_rsa_err); - OPENSSL_cleanse(tbuf, tlen); - OPENSSL_free(tbuf); - return NULL; - } - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - OPENSSL_cleanse(tbuf, tlen); - OPENSSL_free(tbuf); - return ret; -} - -int rsa_verify_pkcs1_pss(RSA *rsa, PyObject *digest, PyObject *signature, EVP_MD *hash, int salt_length) { - const void *dbuf; - const void *sbuf; - int dlen, slen, ret; - - if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) { - return 0; - } - - if (m2_PyObject_AsReadBufferInt(signature, &sbuf, &slen) == -1) { - return 0; - } - - ret = RSA_verify_PKCS1_PSS( - rsa, - (unsigned char *)dbuf, - hash, - (unsigned char *)sbuf, - salt_length); - - return ret; -} -#endif - -PyObject *rsa_sign(RSA *rsa, PyObject *py_digest_string, int method_type) { - int digest_len = 0; - int buf_len = 0; - int ret = 0; - unsigned int real_buf_len = 0; - char *digest_string = NULL; - unsigned char * sign_buf = NULL; - PyObject *signature; - - ret = m2_PyString_AsStringAndSizeInt(py_digest_string, &digest_string, - &digest_len); - if (ret == -1) { - /* PyString_AsStringAndSize raises the correct exceptions. */ - return NULL; - } - - buf_len = RSA_size(rsa); - sign_buf = (unsigned char *)PyMem_Malloc(buf_len); - ret = RSA_sign(method_type, (const unsigned char *)digest_string, digest_len, - sign_buf, &real_buf_len, rsa); - - if (!ret) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(sign_buf); - return NULL; - } - - signature = PyBytes_FromStringAndSize((const char*) sign_buf, buf_len); - - PyMem_Free(sign_buf); - return signature; -} - -int rsa_verify(RSA *rsa, PyObject *py_verify_string, PyObject* py_sign_string, int method_type){ - int ret = 0; - char * sign_string = NULL; - char * verify_string = NULL; - int verify_len = 0; - int sign_len = 0; - - ret = m2_PyString_AsStringAndSizeInt(py_verify_string, &verify_string, - &verify_len); - if (ret == -1) { - /* PyString_AsStringAndSize raises the correct exceptions. */ - return 0; - } - ret = m2_PyString_AsStringAndSizeInt(py_sign_string, &sign_string, - &sign_len); - if (ret == -1) { - return 0; - } - - ret = RSA_verify(method_type, (unsigned char *) verify_string, - verify_len, (unsigned char *) sign_string, - sign_len, rsa); - if (!ret) { - m2_PyErr_Msg(_rsa_err); - return 0; - } - return ret; -} - -PyObject *rsa_generate_key(int bits, unsigned long e, PyObject *pyfunc) { - RSA *rsa; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - BN_GENCB *gencb; - BIGNUM *e_big; - int ret; - - if ((e_big=BN_new()) == NULL) { - m2_PyErr_Msg(_rsa_err); - return NULL; - } - - if (BN_set_word(e_big, e) == 0) { - m2_PyErr_Msg(_rsa_err); - BN_free(e_big); - return NULL; - } - - if ((gencb=BN_GENCB_new()) == NULL) { - m2_PyErr_Msg(_rsa_err); - BN_free(e_big); - return NULL; - } - - if ((rsa = RSA_new()) == NULL) { - m2_PyErr_Msg(_rsa_err); - BN_free(e_big); - BN_GENCB_free(gencb); - return NULL; - } - - BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); - - Py_INCREF(pyfunc); - ret = RSA_generate_key_ex(rsa, bits, e_big, gencb); - BN_free(e_big); - BN_GENCB_free(gencb); - Py_DECREF(pyfunc); - - if (ret) - return SWIG_NewPointerObj((void *)rsa, SWIGTYPE_p_RSA, 0); - - m2_PyErr_Msg(_rsa_err); - RSA_free(rsa); - return NULL; -} - -int rsa_type_check(RSA *rsa) { - return 1; -} - -int rsa_check_pub_key(RSA *rsa) { - const BIGNUM* n, *e; - RSA_get0_key(rsa, &n, &e, NULL); - return n && e; -} - - -int rsa_write_key_der(RSA *rsa, BIO *bio) { - return i2d_RSAPrivateKey_bio(bio, rsa); -} - - -#include -#include -#include -#include - -PyObject *dsa_sig_get_r(DSA_SIG *dsa_sig) { - const BIGNUM* pr; - DSA_SIG_get0(dsa_sig, &pr, NULL); - return bn_to_mpi(pr); -} - -PyObject *dsa_sig_get_s(DSA_SIG *dsa_sig) { - const BIGNUM* qs; - DSA_SIG_get0(dsa_sig, NULL, &qs); - return bn_to_mpi(qs); -} - - -static PyObject *_dsa_err; - -void dsa_init(PyObject *dsa_err) { - Py_INCREF(dsa_err); - _dsa_err = dsa_err; -} - - -DSA *dsa_generate_parameters(int bits, PyObject *pyfunc) { - DSA *dsa; - BN_GENCB *gencb; - int ret; - - if ((gencb=BN_GENCB_new()) == NULL) { - m2_PyErr_Msg(_dh_err); - return NULL; - } - - if ((dsa = DSA_new()) == NULL) { - m2_PyErr_Msg(_dsa_err); - BN_GENCB_free(gencb); - return NULL; - } - - BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); - - Py_INCREF(pyfunc); - ret = DSA_generate_parameters_ex(dsa, bits, NULL, 0, NULL, NULL, - gencb); - Py_DECREF(pyfunc); - BN_GENCB_free(gencb); - - if (ret) - return dsa; - - m2_PyErr_Msg(_dsa_err); - DSA_free(dsa); - return NULL; -} - -DSA *dsa_read_params(BIO *f, PyObject *pyfunc) { - DSA *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_DSAparams(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (ret == NULL) { - m2_PyErr_Msg(_dsa_err); - } - - return ret; -} - -DSA *dsa_read_key(BIO *f, PyObject *pyfunc) { - DSA *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_DSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (ret == NULL) { - m2_PyErr_Msg(_dsa_err); - } - - return ret; -} - -DSA *dsa_read_pub_key(BIO *f, PyObject *pyfunc) { - DSA *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_DSA_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - - if (ret == NULL) { - m2_PyErr_Msg(_dsa_err); - } - - return ret; -} - - -PyObject *dsa_get_p(DSA *dsa) { - const BIGNUM* p = NULL; - DSA_get0_pqg(dsa, &p, NULL, NULL); - if (!p) { - PyErr_SetString(_dsa_err, "'p' is unset"); - return NULL; - } - return bn_to_mpi(p); -} - -PyObject *dsa_get_q(DSA *dsa) { - const BIGNUM* q = NULL; - DSA_get0_pqg(dsa, NULL, &q, NULL); - if (!q) { - PyErr_SetString(_dsa_err, "'q' is unset"); - return NULL; - } - return bn_to_mpi(q); -} - -PyObject *dsa_get_g(DSA *dsa) { - const BIGNUM* g = NULL; - DSA_get0_pqg(dsa, NULL, NULL, &g); - if (!g) { - PyErr_SetString(_dsa_err, "'g' is unset"); - return NULL; - } - return bn_to_mpi(g); -} - -PyObject *dsa_get_pub(DSA *dsa) { - const BIGNUM* pub_key = NULL; - DSA_get0_key(dsa, &pub_key, NULL); - if (!pub_key) { - PyErr_SetString(_dsa_err, "'pub' is unset"); - return NULL; - } - return bn_to_mpi(pub_key); -} - -PyObject *dsa_get_priv(DSA *dsa) { - const BIGNUM* priv_key = NULL; - DSA_get0_key(dsa, NULL, &priv_key); - if (!priv_key) { - PyErr_SetString(_dsa_err, "'priv' is unset"); - return NULL; - } - return bn_to_mpi(priv_key); -} - -PyObject *dsa_set_pqg(DSA *dsa, PyObject *pval, PyObject* qval, PyObject* gval) { - BIGNUM* p, *q, *g; - - if (!(p = m2_PyObject_AsBIGNUM(pval, _dsa_err)) - || !(q = m2_PyObject_AsBIGNUM(qval, _dsa_err)) - || !(g = m2_PyObject_AsBIGNUM(gval, _dsa_err))) - return NULL; - - if (!DSA_set0_pqg(dsa, p, q, g)) { - PyErr_SetString( - _dsa_err, - "Cannot set prime number, subprime, or generator of subgroup for DSA."); - BN_free(p); - BN_free(q); - BN_free(g); - return NULL; - } - - Py_RETURN_NONE; - } - -PyObject *dsa_set_pub(DSA *dsa, PyObject *value) { - BIGNUM *bn; - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { - m2_PyErr_Msg(_dsa_err); - return NULL; - } - if (!DSA_set0_key(dsa, bn, NULL)) { - BN_free(bn); - PyErr_SetString(_dsa_err, "Cannot set private and public key for DSA."); - } - Py_RETURN_NONE; -} - - -int dsa_write_params_bio(DSA* dsa, BIO* f) { - return PEM_write_bio_DSAparams(f, dsa); -} - - -int dsa_write_key_bio(DSA* dsa, BIO* f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_DSAPrivateKey(f, dsa, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -int dsa_write_key_bio_no_cipher(DSA* dsa, BIO* f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_DSAPrivateKey(f, dsa, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -int dsa_write_pub_key_bio(DSA* dsa, BIO* f) { - return PEM_write_bio_DSA_PUBKEY(f, dsa); -} - - -PyObject *dsa_sign(DSA *dsa, PyObject *value) { - const void *vbuf; - int vlen = 0; - PyObject *tuple; - DSA_SIG *sig; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sig = DSA_do_sign(vbuf, vlen, dsa))) { - m2_PyErr_Msg(_dsa_err); - return NULL; - } - if (!(tuple = PyTuple_New(2))) { - DSA_SIG_free(sig); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - PyTuple_SET_ITEM(tuple, 0, dsa_sig_get_r(sig)); - PyTuple_SET_ITEM(tuple, 1, dsa_sig_get_s(sig)); - DSA_SIG_free(sig); - return tuple; -} - -int dsa_verify(DSA *dsa, PyObject *value, PyObject *r, PyObject *s) { - const void *vbuf, *rbuf, *sbuf; - int vlen = 0, rlen = 0, slen = 0; - DSA_SIG *sig; - BIGNUM* pr, *ps; - int ret; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) - || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) - return -1; - - if (!(sig = DSA_SIG_new())) { - m2_PyErr_Msg(_dsa_err); - return -1; - } - if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { - m2_PyErr_Msg(_dsa_err); - DSA_SIG_free(sig); - return -1; - } - if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { - m2_PyErr_Msg(_dsa_err); - DSA_SIG_free(sig); - BN_free(pr); - return -1; - } - if (!DSA_SIG_set0(sig, pr, ps)) { - m2_PyErr_Msg(_dsa_err); - DSA_SIG_free(sig); - BN_free(pr); - BN_free(ps); - return -1; - } - - ret = DSA_do_verify(vbuf, vlen, sig, dsa); - DSA_SIG_free(sig); - if (ret == -1) - m2_PyErr_Msg(_dsa_err); - return ret; -} - -PyObject *dsa_sign_asn1(DSA *dsa, PyObject *value) { - const void *vbuf; - int vlen = 0; - void *sigbuf; - unsigned int siglen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sigbuf = PyMem_Malloc(DSA_size(dsa)))) { - PyErr_SetString(PyExc_MemoryError, "dsa_sign_asn1"); - return NULL; - } - if (!DSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, dsa)) { - m2_PyErr_Msg(_dsa_err); - PyMem_Free(sigbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize(sigbuf, siglen); - - PyMem_Free(sigbuf); - return ret; -} - -int dsa_verify_asn1(DSA *dsa, PyObject *value, PyObject *sig) { - const void *vbuf; - void *sbuf; - int vlen = 0, slen = 0, ret = 0; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) - == -1)) - return -1; - - if ((ret = DSA_verify(0, vbuf, vlen, sbuf, slen, dsa)) == -1) - m2_PyErr_Msg(_dsa_err); - return ret; -} - -int dsa_check_key(DSA *dsa) { - const BIGNUM* pub_key, *priv_key; - DSA_get0_key(dsa, &pub_key, &priv_key); - return pub_key != NULL && priv_key != NULL; -} - -int dsa_check_pub_key(DSA *dsa) { - const BIGNUM* pub_key; - DSA_get0_key(dsa, &pub_key, NULL); - return pub_key ? 1 : 0; -} - -int dsa_keylen(DSA *dsa) { - const BIGNUM* p; - DSA_get0_pqg(dsa, &p, NULL, NULL); - return BN_num_bits(p); -} - -int dsa_type_check(DSA *dsa) { - return 1; -} - - -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 -#include -#include -#pragma comment(lib, "Ws2_32") -typedef unsigned __int64 uint64_t; -#else -#include -#include -#endif - - -static PyObject *_ssl_err; -static PyObject *_ssl_timeout_err; - -void ssl_init(PyObject *ssl_err, PyObject *ssl_timeout_err) { - SSL_library_init(); - SSL_load_error_strings(); - Py_INCREF(ssl_err); - Py_INCREF(ssl_timeout_err); - _ssl_err = ssl_err; - _ssl_timeout_err = ssl_timeout_err; -} - -const SSL_METHOD *tlsv1_method(void) { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - PyErr_WarnEx(PyExc_DeprecationWarning, - "Function TLSv1_method has been deprecated.", 1); -#endif - return TLSv1_method(); -} - -void ssl_ctx_passphrase_callback(SSL_CTX *ctx, PyObject *pyfunc) { - SSL_CTX_set_default_passwd_cb(ctx, passphrase_callback); - SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *)pyfunc); - Py_INCREF(pyfunc); -} - -int ssl_ctx_use_x509(SSL_CTX *ctx, X509 *x) { - int i; - - if (!(i = SSL_CTX_use_certificate(ctx, x))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; - -} - -int ssl_ctx_use_cert(SSL_CTX *ctx, char *file) { - int i; - - if (!(i = SSL_CTX_use_certificate_file(ctx, file, SSL_FILETYPE_PEM))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - -int ssl_ctx_use_cert_chain(SSL_CTX *ctx, char *file) { - int i; - - if (!(i = SSL_CTX_use_certificate_chain_file(ctx, file))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - - -int ssl_ctx_use_privkey(SSL_CTX *ctx, char *file) { - int i; - - if (!(i = SSL_CTX_use_PrivateKey_file(ctx, file, SSL_FILETYPE_PEM))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - -int ssl_ctx_use_rsa_privkey(SSL_CTX *ctx, RSA *rsakey) { - int i; - - if (!(i = SSL_CTX_use_RSAPrivateKey(ctx, rsakey))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - -int ssl_ctx_use_pkey_privkey(SSL_CTX *ctx, EVP_PKEY *pkey) { - int i; - - if (!(i = SSL_CTX_use_PrivateKey(ctx, pkey))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - - -int ssl_ctx_check_privkey(SSL_CTX *ctx) { - int ret; - - if (!(ret = SSL_CTX_check_private_key(ctx))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return ret; -} - -void ssl_ctx_set_client_CA_list_from_file(SSL_CTX *ctx, const char *ca_file) { - SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(ca_file)); -} - -void ssl_ctx_set_verify_default(SSL_CTX *ctx, int mode) { - SSL_CTX_set_verify(ctx, mode, NULL); -} - -void ssl_ctx_set_verify(SSL_CTX *ctx, int mode, PyObject *pyfunc) { - Py_XDECREF(ssl_verify_cb_func); - Py_INCREF(pyfunc); - ssl_verify_cb_func = pyfunc; - SSL_CTX_set_verify(ctx, mode, ssl_verify_callback); -} - -int ssl_ctx_set_session_id_context(SSL_CTX *ctx, PyObject *sid_ctx) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) - return -1; - - return SSL_CTX_set_session_id_context(ctx, buf, len); -} - -void ssl_ctx_set_info_callback(SSL_CTX *ctx, PyObject *pyfunc) { - Py_XDECREF(ssl_info_cb_func); - Py_INCREF(pyfunc); - ssl_info_cb_func = pyfunc; - SSL_CTX_set_info_callback(ctx, ssl_info_callback); -} - -long ssl_ctx_set_tmp_dh(SSL_CTX *ctx, DH* dh) { - return SSL_CTX_set_tmp_dh(ctx, dh); -} - -void ssl_ctx_set_tmp_dh_callback(SSL_CTX *ctx, PyObject *pyfunc) { - Py_XDECREF(ssl_set_tmp_dh_cb_func); - Py_INCREF(pyfunc); - ssl_set_tmp_dh_cb_func = pyfunc; - SSL_CTX_set_tmp_dh_callback(ctx, ssl_set_tmp_dh_callback); -} - -long ssl_ctx_set_tmp_rsa(SSL_CTX *ctx, RSA* rsa) { - return SSL_CTX_set_tmp_rsa(ctx, rsa); -} - -void ssl_ctx_set_tmp_rsa_callback(SSL_CTX *ctx, PyObject *pyfunc) { - Py_XDECREF(ssl_set_tmp_rsa_cb_func); - Py_INCREF(pyfunc); - ssl_set_tmp_rsa_cb_func = pyfunc; - SSL_CTX_set_tmp_rsa_callback(ctx, ssl_set_tmp_rsa_callback); -} - -int ssl_ctx_load_verify_locations(SSL_CTX *ctx, const char *cafile, const char *capath) { - return SSL_CTX_load_verify_locations(ctx, cafile, capath); -} - -/* SSL_CTX_set_options is a macro. */ -long ssl_ctx_set_options(SSL_CTX *ctx, long op) { - return SSL_CTX_set_options(ctx, op); -} - -int bio_set_ssl(BIO *bio, SSL *ssl, int flag) { - SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); - return BIO_ctrl(bio, BIO_C_SET_SSL, flag, (char *)ssl); -} - -long ssl_set_mode(SSL *ssl, long mode) { - return SSL_set_mode(ssl, mode); -} - -long ssl_get_mode(SSL *ssl) { - return SSL_get_mode(ssl); -} - -int ssl_set_tlsext_host_name(SSL *ssl, const char *name) { - long l; - - if (!(l = SSL_set_tlsext_host_name(ssl, name))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - /* Return an "int" to match the 'typemap(out) int' in _lib.i */ - return 1; -} - -void ssl_set_client_CA_list_from_file(SSL *ssl, const char *ca_file) { - SSL_set_client_CA_list(ssl, SSL_load_client_CA_file(ca_file)); -} - -void ssl_set_client_CA_list_from_context(SSL *ssl, SSL_CTX *ctx) { - SSL_set_client_CA_list(ssl, SSL_CTX_get_client_CA_list(ctx)); -} - -int ssl_set_session_id_context(SSL *ssl, PyObject *sid_ctx) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) - return -1; - - return SSL_set_session_id_context(ssl, buf, len); -} - -int ssl_set_fd(SSL *ssl, int fd) { - int ret; - - if (!(ret = SSL_set_fd(ssl, fd))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return ret; -} - -static void ssl_handle_error(int ssl_err, int ret) { - int err; - - switch (ssl_err) { - case SSL_ERROR_SSL: - PyErr_SetString(_ssl_err, - ERR_reason_error_string(ERR_get_error())); - break; - case SSL_ERROR_SYSCALL: - err = ERR_get_error(); - if (err) - PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); - else if (ret == 0) - PyErr_SetString(_ssl_err, "unexpected eof"); - else if (ret == -1) - PyErr_SetFromErrno(_ssl_err); - else - assert(0); - break; - default: - PyErr_SetString(_ssl_err, "unexpected SSL error"); - } -} - -#ifdef _WIN32 -/* http://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows */ -int gettimeofday(struct timeval *tp, void *tzp) -{ - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); - - SYSTEMTIME system_time; - FILETIME file_time; - uint64_t time; - - GetSystemTime( &system_time ); - SystemTimeToFileTime( &system_time, &file_time ); - time = ((uint64_t)file_time.dwLowDateTime ) ; - time += ((uint64_t)file_time.dwHighDateTime) << 32; - - tp->tv_sec = (long) ((time - EPOCH) / 10000000L); - tp->tv_usec = (long) (system_time.wMilliseconds * 1000); - return 0; -} -#endif - -static int ssl_sleep_with_timeout(SSL *ssl, const struct timeval *start, - double timeout, int ssl_err) { -#ifdef _WIN32 -WSAPOLLFD fd; -#else -struct pollfd fd; -#endif - struct timeval tv; - int ms, tmp; - - assert(timeout > 0); - again: - gettimeofday(&tv, NULL); - /* tv >= start */ - if ((timeout + start->tv_sec - tv.tv_sec) > INT_MAX / 1000) - ms = -1; - else { - int fract; - - ms = ((start->tv_sec + (int)timeout) - tv.tv_sec) * 1000; - fract = (int)((start->tv_usec + (timeout - (int)timeout) * 1000000 - - tv.tv_usec + 999) / 1000); - if (ms > 0 && fract > INT_MAX - ms) - ms = -1; - else { - ms += fract; - if (ms <= 0) - goto timeout; - } - } - switch (ssl_err) { - case SSL_ERROR_WANT_READ: - fd.fd = SSL_get_rfd(ssl); - fd.events = POLLIN; - break; - - case SSL_ERROR_WANT_WRITE: - fd.fd = SSL_get_wfd(ssl); - fd.events = POLLOUT; - break; - - case SSL_ERROR_WANT_X509_LOOKUP: - return 0; /* FIXME: is this correct? */ - - default: - assert(0); - } - if (fd.fd == -1) { - PyErr_SetString(_ssl_err, "timeout on a non-FD SSL"); - return -1; - } - Py_BEGIN_ALLOW_THREADS -#ifdef _WIN32 - tmp = WSAPoll(&fd, 1, ms); -#else - tmp = poll(&fd, 1, ms); -#endif - Py_END_ALLOW_THREADS - switch (tmp) { - case 1: - return 0; - case 0: - goto timeout; - case -1: -#ifdef _WIN32 - if (WSAGetLastError() == EINTR) -#else - if (errno == EINTR) -#endif - goto again; - PyErr_SetFromErrno(_ssl_err); - return -1; - } - return 0; - - timeout: - PyErr_SetString(_ssl_timeout_err, "timed out"); - return -1; -} - -PyObject *ssl_accept(SSL *ssl, double timeout) { - PyObject *obj = NULL; - int r, ssl_err; - struct timeval tv; - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_accept(ssl); - ssl_err = SSL_get_error(ssl, r); - Py_END_ALLOW_THREADS - - - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - obj = PyLong_FromLong((long)1); - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - if (timeout <= 0) { - obj = PyLong_FromLong((long)0); - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - obj = NULL; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - obj = NULL; - break; - } - - - return obj; -} - -PyObject *ssl_connect(SSL *ssl, double timeout) { - PyObject *obj = NULL; - int r, ssl_err; - struct timeval tv; - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_connect(ssl); - ssl_err = SSL_get_error(ssl, r); - Py_END_ALLOW_THREADS - - - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - obj = PyLong_FromLong((long)1); - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - if (timeout <= 0) { - obj = PyLong_FromLong((long)0); - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - obj = NULL; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - obj = NULL; - break; - } - - - return obj; -} - -void ssl_set_shutdown1(SSL *ssl, int mode) { - SSL_set_shutdown(ssl, mode); -} - -PyObject *ssl_read(SSL *ssl, int num, double timeout) { - PyObject *obj = NULL; - void *buf; - int r; - struct timeval tv; - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "ssl_read"); - return NULL; - } - - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_read(ssl, buf, num); - Py_END_ALLOW_THREADS - - if (r >= 0) { - buf = PyMem_Realloc(buf, r); - obj = PyBytes_FromStringAndSize(buf, r); - } else { - int ssl_err; - - ssl_err = SSL_get_error(ssl, r); - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - assert(0); - - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - if (timeout <= 0) { - Py_INCREF(Py_None); - obj = Py_None; - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - obj = NULL; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - obj = NULL; - break; - } - } - PyMem_Free(buf); - - - return obj; -} - -PyObject *ssl_read_nbio(SSL *ssl, int num) { - PyObject *obj = NULL; - void *buf; - int r, err; - - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "ssl_read"); - return NULL; - } - - - Py_BEGIN_ALLOW_THREADS - r = SSL_read(ssl, buf, num); - Py_END_ALLOW_THREADS - - - switch (SSL_get_error(ssl, r)) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - buf = PyMem_Realloc(buf, r); - - obj = PyBytes_FromStringAndSize(buf, r); - - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - Py_INCREF(Py_None); - obj = Py_None; - break; - case SSL_ERROR_SSL: - m2_PyErr_Msg(_ssl_err); - obj = NULL; - break; - case SSL_ERROR_SYSCALL: - err = ERR_get_error(); - if (err) - PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); - else if (r == 0) - PyErr_SetString(_ssl_err, "unexpected eof"); - else if (r == -1) - PyErr_SetFromErrno(_ssl_err); - obj = NULL; - break; - } - PyMem_Free(buf); - - - return obj; -} - -int ssl_write(SSL *ssl, PyObject *blob, double timeout) { - Py_buffer buf; - int r, ssl_err, ret; - struct timeval tv; - - - if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { - return -1; - } - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_write(ssl, buf.buf, buf.len); - ssl_err = SSL_get_error(ssl, r); - Py_END_ALLOW_THREADS - - - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - ret = r; - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - if (timeout <= 0) { - ret = -1; - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - ret = -1; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - default: - ret = -1; - } - - m2_PyBuffer_Release(blob, &buf); - return ret; -} - -int ssl_write_nbio(SSL *ssl, PyObject *blob) { - Py_buffer buf; - int r, err, ret; - - - if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { - return -1; - } - - - Py_BEGIN_ALLOW_THREADS - r = SSL_write(ssl, buf.buf, buf.len); - Py_END_ALLOW_THREADS - - - switch (SSL_get_error(ssl, r)) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - ret = r; - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - ret = -1; - break; - case SSL_ERROR_SSL: - ret = -1; - break; - case SSL_ERROR_SYSCALL: - err = ERR_get_error(); - if (err) - PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); - else if (r == 0) - PyErr_SetString(_ssl_err, "unexpected eof"); - else if (r == -1) - PyErr_SetFromErrno(_ssl_err); - default: - ret = -1; - } - - m2_PyBuffer_Release(blob, &buf); - return ret; -} - -int ssl_cipher_get_bits(SSL_CIPHER *c) { - return SSL_CIPHER_get_bits(c, NULL); -} - -int sk_ssl_cipher_num(STACK_OF(SSL_CIPHER) *stack) { - return sk_SSL_CIPHER_num(stack); -} - -const SSL_CIPHER *sk_ssl_cipher_value(STACK_OF(SSL_CIPHER) *stack, int idx) { - return sk_SSL_CIPHER_value(stack, idx); -} - -STACK_OF(X509) *ssl_get_peer_cert_chain(SSL *ssl) { - return SSL_get_peer_cert_chain(ssl); -} - -int sk_x509_num(STACK_OF(X509) *stack) { - return sk_X509_num(stack); -} - -X509 *sk_x509_value(STACK_OF(X509) *stack, int idx) { - return sk_X509_value(stack, idx); -} - - -void i2d_ssl_session(BIO *bio, SSL_SESSION *sess) { - i2d_SSL_SESSION_bio(bio, sess); -} - - -SSL_SESSION *ssl_session_read_pem(BIO *bio) { - return PEM_read_bio_SSL_SESSION(bio, NULL, NULL, NULL); -} - - -int ssl_session_write_pem(SSL_SESSION *sess, BIO *bio) { - return PEM_write_bio_SSL_SESSION(bio, sess); -} - -int ssl_ctx_set_session_cache_mode(SSL_CTX *ctx, int mode) -{ - return SSL_CTX_set_session_cache_mode(ctx, mode); -} - -int ssl_ctx_get_session_cache_mode(SSL_CTX *ctx) -{ - return SSL_CTX_get_session_cache_mode(ctx); -} - -static long ssl_ctx_set_cache_size(SSL_CTX *ctx, long arg) -{ - return SSL_CTX_sess_set_cache_size(ctx, arg); -} - -int ssl_is_init_finished(SSL *ssl) -{ - return SSL_is_init_finished(ssl); -} - - -#include -#include -#include - -#include - -typedef STACK_OF(X509) SEQ_CERT; - -ASN1_ITEM_TEMPLATE(SEQ_CERT) = - ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, SeqCert, X509) -ASN1_ITEM_TEMPLATE_END(SEQ_CERT) - -IMPLEMENT_ASN1_FUNCTIONS(SEQ_CERT) - - -X509 *x509_read_pem(BIO *bio) { - return PEM_read_bio_X509(bio, NULL, NULL, NULL); -} - - -X509 *d2i_x509(BIO *bio) { - return d2i_X509_bio(bio, NULL); -} - - -static PyObject *_x509_err; - -void x509_init(PyObject *x509_err) { - Py_INCREF(x509_err); - _x509_err = x509_err; -} - - -X509_REQ *d2i_x509_req(BIO *bio) { - return d2i_X509_REQ_bio(bio, NULL); -} - - -X509_REQ *x509_req_read_pem(BIO *bio) { - return PEM_read_bio_X509_REQ(bio, NULL, NULL, NULL); -} - - -PyObject *i2d_x509(X509 *x) { - int len; - PyObject *ret = NULL; - unsigned char *buf = NULL; - len = i2d_X509(x, &buf); - if (len < 0) { - m2_PyErr_Msg(_x509_err); - } - else { - - ret = PyBytes_FromStringAndSize((char*)buf, len); - - OPENSSL_free(buf); - } - return ret; -} - - -int x509_req_write_pem(BIO *bio, X509_REQ *x) { - return PEM_write_bio_X509_REQ(bio, x); -} - - -X509_CRL *x509_crl_read_pem(BIO *bio) { - return PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); -} - - -/* X509_set_version() is a macro. */ -int x509_set_version(X509 *x, long version) { - return X509_set_version(x, version); -} - -/* X509_get_version() is a macro. */ -long x509_get_version(X509 *x) { - return X509_get_version(x); -} - -/* X509_set_notBefore() is a macro. */ -int x509_set_not_before(X509 *x, ASN1_TIME *tm) { - return X509_set_notBefore(x, tm); -} - -/* X509_get_notBefore() is a macro. */ -ASN1_TIME *x509_get_not_before(X509 *x) { - return X509_get_notBefore(x); -} - -/* X509_set_notAfter() is a macro. */ -int x509_set_not_after(X509 *x, ASN1_TIME *tm) { - return X509_set_notAfter(x, tm); -} - -/* X509_get_notAfter() is a macro. */ -ASN1_TIME *x509_get_not_after(X509 *x) { - return X509_get_notAfter(x); -} - -int x509_sign(X509 *x, EVP_PKEY *pkey, EVP_MD *md) { - return X509_sign(x, pkey, md); -} - -/* x509_gmtime_adj() is a macro. */ -ASN1_TIME *x509_gmtime_adj(ASN1_TIME *s, long adj) { - return X509_gmtime_adj(s, adj); -} - -PyObject *x509_name_by_nid(X509_NAME *name, int nid) { - void *buf; - int len, xlen; - PyObject *ret; - - if ((len = X509_NAME_get_text_by_NID(name, nid, NULL, 0)) == -1) { - Py_RETURN_NONE; - } - len++; - if (!(buf = PyMem_Malloc(len))) { - PyErr_SetString(PyExc_MemoryError, "x509_name_by_nid"); - return NULL; - } - xlen = X509_NAME_get_text_by_NID(name, nid, buf, len); - - ret = PyBytes_FromStringAndSize(buf, xlen); - - PyMem_Free(buf); - return ret; -} - -int x509_name_set_by_nid(X509_NAME *name, int nid, PyObject *obj) { - return X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC, (unsigned char *)PyBytes_AsString(obj), -1, -1, 0); -} - -/* x509_name_add_entry_by_txt */ -int x509_name_add_entry_by_txt(X509_NAME *name, char *field, int type, char *bytes, int len, int loc, int set) { - return X509_NAME_add_entry_by_txt(name, field, type, (unsigned char *)bytes, len, loc, set); -} - -PyObject *x509_name_get_der(X509_NAME *name) { - const char* pder=""; - size_t pderlen; - i2d_X509_NAME(name, 0); - if (!X509_NAME_get0_der(name, (const unsigned char **)pder, &pderlen)) { - m2_PyErr_Msg(_x509_err); - return NULL; - } - return PyBytes_FromStringAndSize(pder, pderlen); -} - -/* sk_X509_free() is a macro. */ -void sk_x509_free(STACK_OF(X509) *stack) { - sk_X509_free(stack); -} - -/* sk_X509_push() is a macro. */ -int sk_x509_push(STACK_OF(X509) *stack, X509 *x509) { - return sk_X509_push(stack, x509); -} - -/* sk_X509_pop() is a macro. */ -X509 *sk_x509_pop(STACK_OF(X509) *stack) { - return sk_X509_pop(stack); -} - - -int x509_store_load_locations(X509_STORE *store, const char *file) { - int locations = 0; - - if ((locations = X509_STORE_load_locations(store, file, NULL)) < 1) { - m2_PyErr_Msg(_x509_err); - } - return locations; -} - -int x509_type_check(X509 *x509) { - return 1; -} - -int x509_name_type_check(X509_NAME *name) { - return 1; -} - -X509_NAME *x509_req_get_subject_name(X509_REQ *x) { - return X509_REQ_get_subject_name(x); -} - -long x509_req_get_version(X509_REQ *x) { - return X509_REQ_get_version(x); -} - -int x509_req_set_version(X509_REQ *x, long version) { - return X509_REQ_set_version(x, version); -} - -int x509_req_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts) { - return X509_REQ_add_extensions(req, exts); -} - -X509_NAME_ENTRY *x509_name_entry_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, char *bytes, int len) { - return X509_NAME_ENTRY_create_by_txt( ne, field, type, (unsigned char *)bytes, len); -} - - -X509V3_CTX * -x509v3_set_nconf(void) { - X509V3_CTX * ctx; - CONF *conf = NCONF_new(NULL); - - if (!(ctx=(X509V3_CTX *)PyMem_Malloc(sizeof(X509V3_CTX)))) { - PyErr_SetString(PyExc_MemoryError, "x509v3_set_nconf"); - return NULL; - } - /* X509V3_set_nconf does not generate any error signs at all. */ - X509V3_set_nconf(ctx, conf); - return ctx; -} - - -X509_EXTENSION * -x509v3_ext_conf(void *conf, X509V3_CTX *ctx, char *name, char *value) { - X509_EXTENSION * ext = NULL; - ext = X509V3_EXT_conf(conf, ctx, name, value); - PyMem_Free(ctx); - return ext; -} - - -/* X509_EXTENSION_free() might be a macro, didn't find definition. */ -void x509_extension_free(X509_EXTENSION *ext) { - X509_EXTENSION_free(ext); -} - -PyObject *x509_extension_get_name(X509_EXTENSION *ext) { - PyObject * ext_name; - const char * ext_name_str; - ext_name_str = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext))); - if (!ext_name_str) { - m2_PyErr_Msg(_x509_err); - return NULL; - } - ext_name = PyBytes_FromStringAndSize(ext_name_str, strlen(ext_name_str)); - return ext_name; -} - -/* sk_X509_EXTENSION_new_null is a macro. */ -STACK_OF(X509_EXTENSION) *sk_x509_extension_new_null(void) { - return sk_X509_EXTENSION_new_null(); -} - -/* sk_X509_EXTENSION_free() is a macro. */ -void sk_x509_extension_free(STACK_OF(X509_EXTENSION) *stack) { - sk_X509_EXTENSION_free(stack); -} - -/* sk_X509_EXTENSION_push() is a macro. */ -int sk_x509_extension_push(STACK_OF(X509_EXTENSION) *stack, X509_EXTENSION *x509_ext) { - return sk_X509_EXTENSION_push(stack, x509_ext); -} - -/* sk_X509_EXTENSION_pop() is a macro. */ -X509_EXTENSION *sk_x509_extension_pop(STACK_OF(X509_EXTENSION) *stack) { - return sk_X509_EXTENSION_pop(stack); -} - -/* sk_X509_EXTENSION_num() is a macro. */ -int sk_x509_extension_num(STACK_OF(X509_EXTENSION) *stack) { - return sk_X509_EXTENSION_num(stack); -} - -/* sk_X509_EXTENSION_value() is a macro. */ -X509_EXTENSION *sk_x509_extension_value(STACK_OF(X509_EXTENSION) *stack, int i) { - return sk_X509_EXTENSION_value(stack, i); -} - -/* X509_STORE_CTX_get_app_data is a macro. */ -void *x509_store_ctx_get_app_data(X509_STORE_CTX *ctx) { - return X509_STORE_CTX_get_app_data(ctx); -} - -/* X509_STORE_CTX_get_app_data is a macro. */ -void *x509_store_ctx_get_ex_data(X509_STORE_CTX *ctx, int idx) { - return X509_STORE_CTX_get_ex_data(ctx, idx); -} - -void x509_store_set_verify_cb(X509_STORE *store, PyObject *pyfunc) { - Py_XDECREF(x509_store_verify_cb_func); - Py_INCREF(pyfunc); - x509_store_verify_cb_func = pyfunc; - X509_STORE_set_verify_cb(store, x509_store_verify_callback); -} - - -STACK_OF(X509) * -make_stack_from_der_sequence(PyObject * pyEncodedString){ - STACK_OF(X509) *certs; - Py_ssize_t encoded_string_len; - char *encoded_string; - const unsigned char *tmp_str; - - encoded_string_len = PyBytes_Size(pyEncodedString); - - if (encoded_string_len > INT_MAX) { - PyErr_Format(_x509_err, "object too large"); - return NULL; - } - - encoded_string = PyBytes_AsString(pyEncodedString); - - if (!encoded_string) { - PyErr_SetString(_x509_err, - "Cannot convert Python Bytes to (char *)."); - return NULL; - } - - tmp_str = (unsigned char *)encoded_string; - certs = d2i_SEQ_CERT(NULL, &tmp_str, encoded_string_len); - if (certs == NULL) { - PyErr_SetString(_x509_err, "Generating STACK_OF(X509) failed."); - return NULL; - } - return certs; -} - -/* sk_X509_new_null() is a macro returning "STACK_OF(X509) *". */ -STACK_OF(X509) *sk_x509_new_null(void) { - return sk_X509_new_null(); -} - - -PyObject * -get_der_encoding_stack(STACK_OF(X509) *stack){ - PyObject * encodedString; - - unsigned char * encoding = NULL; - int len; - - len = i2d_SEQ_CERT(stack, &encoding); - if (!encoding) { - m2_PyErr_Msg(_x509_err); - return NULL; - } - - encodedString = PyBytes_FromStringAndSize((const char *)encoding, len); - - if (encoding) - OPENSSL_free(encoding); - - return encodedString; -} - - - -char *x509_name_oneline(X509_NAME *x) { - return X509_NAME_oneline(x, NULL, 0); -} - - -#include - - -/* ASN1_TIME_set_string () is a macro */ -int asn1_time_type_check(ASN1_TIME *ASN1_TIME) { - return 1; -} - -PyObject *asn1_integer_get(ASN1_INTEGER *asn1) { - BIGNUM *bn; - PyObject *ret; - char *hex; - - bn = ASN1_INTEGER_to_BN(asn1, NULL); - - if (!bn){ - m2_PyErr_Msg(PyExc_RuntimeError); - return NULL; - } - - hex = BN_bn2hex(bn); - - if (!hex){ - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return NULL; - } - - BN_free(bn); - - ret = PyLong_FromString(hex, NULL, 16); - - OPENSSL_free(hex); - - return ret; -} - -int asn1_integer_set(ASN1_INTEGER *asn1, PyObject *value) { - BIGNUM *bn = NULL; - PyObject *fmt, *args, *hex; - -/* Despite all hopes to the contrary, we cannot survive here with - * PyLong_AsLong shims as provided in - * /usr/include/python2.7/longobject.h. - */ - long val = PyLong_AsLong(value); - if (val >= 0) { - return ASN1_INTEGER_set(asn1, val); - } else { - PyErr_Clear(); - } - - if (!PyLong_Check(value)){ - PyErr_SetString(PyExc_TypeError, "expected int or long"); - return 0; - } - - fmt = PyUnicode_FromString("%x"); - - if (!fmt) - return 0; - - args = PyTuple_New(1); - - if (!args){ - Py_DECREF(fmt); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() failed"); - return 0; - } - - Py_INCREF(value); - PyTuple_SET_ITEM(args, 0, value); - hex = PyUnicode_Format(fmt, args); - - if (!hex){ - PyErr_SetString(PyExc_RuntimeError, "PyString_Format() failed"); - Py_DECREF(fmt); - Py_DECREF(args); - return 0; - } - - Py_DECREF(fmt); - Py_DECREF(args); - - if (BN_hex2bn(&bn, PyUnicode_AsUTF8(hex)) <= 0){ - m2_PyErr_Msg(PyExc_RuntimeError); - Py_DECREF(hex); - return 0; - } - - Py_DECREF(hex); - - if (!BN_to_ASN1_INTEGER(bn, asn1)){ - m2_PyErr_Msg(PyExc_RuntimeError); - BN_free(bn); - return 0; - } - - BN_free(bn); - - return 1; -} - - - -#include -#include -#include -#include - - -static PyObject *_pkcs7_err, *_smime_err; - -void pkcs7_init(PyObject *pkcs7_err) { - Py_INCREF(pkcs7_err); - _pkcs7_err = pkcs7_err; -} - -void smime_init(PyObject *smime_err) { - Py_INCREF(smime_err); - _smime_err = smime_err; -} - - -PyObject *pkcs7_decrypt(PKCS7 *pkcs7, EVP_PKEY *pkey, X509 *cert, int flags) { - int outlen; - char *outbuf; - BIO *bio; - PyObject *ret; - - if (!(bio=BIO_new(BIO_s_mem()))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); - return NULL; - } - if (!PKCS7_decrypt(pkcs7, pkey, cert, bio, flags)) { - m2_PyErr_Msg(_pkcs7_err); - BIO_free(bio); - return NULL; - } - outlen = BIO_ctrl_pending(bio); - if (!(outbuf=(char *)PyMem_Malloc(outlen))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); - BIO_free(bio); - return NULL; - } - BIO_read(bio, outbuf, outlen); - - ret = PyBytes_FromStringAndSize(outbuf, outlen); - - BIO_free(bio); - PyMem_Free(outbuf); - return ret; -} - - -PKCS7 *pkcs7_encrypt(STACK_OF(X509) *stack, BIO *bio, EVP_CIPHER *cipher, int flags) { - return PKCS7_encrypt(stack, bio, cipher, flags); -} - - - -PKCS7 *pkcs7_sign1(X509 *x509, EVP_PKEY *pkey, STACK_OF(X509) *stack, BIO *bio, EVP_MD *hash, int flags) { - - PKCS7 *p7 = PKCS7_sign(NULL, NULL, stack, bio, flags | PKCS7_STREAM); - if (p7 == NULL) { - return NULL; - } - if (PKCS7_sign_add_signer(p7, x509, pkey, hash, flags) == NULL) { - return NULL; - } - if (PKCS7_final(p7, bio, flags) != 1) { - return NULL; - } - return p7; -} - - -PKCS7 *pkcs7_sign0(X509 *x509, EVP_PKEY *pkey, BIO *bio, EVP_MD *hash, int flags) { - return pkcs7_sign1(x509, pkey, NULL, bio, hash, flags); -} - - -PKCS7 *pkcs7_read_bio(BIO *bio) { - return PEM_read_bio_PKCS7(bio, NULL, NULL, NULL); -} - - -PKCS7 *pkcs7_read_bio_der(BIO *bio) { - return d2i_PKCS7_bio(bio, NULL); -} - - -PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, BIO *data, int flags) { - int res, outlen; - char *outbuf; - BIO *bio; - PyObject *ret; - - if (!(bio=BIO_new(BIO_s_mem()))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - res = PKCS7_verify(pkcs7, stack, store, data, bio, flags); - Py_END_ALLOW_THREADS - if (!res) { - m2_PyErr_Msg(_pkcs7_err); - BIO_free(bio); - return NULL; - } - outlen = BIO_ctrl_pending(bio); - if (!(outbuf=(char *)PyMem_Malloc(outlen))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); - BIO_free(bio); - return NULL; - } - BIO_read(bio, outbuf, outlen); - - ret = PyBytes_FromStringAndSize(outbuf, outlen); - - BIO_free(bio); - PyMem_Free(outbuf); - return ret; -} - -PyObject *pkcs7_verify0(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, int flags) { - return pkcs7_verify1(pkcs7, stack, store, NULL, flags); -} - - -int smime_write_pkcs7_multi(BIO *bio, PKCS7 *pkcs7, BIO *data, int flags) { - return SMIME_write_PKCS7(bio, pkcs7, data, flags | PKCS7_DETACHED); -} - - -int smime_write_pkcs7(BIO *bio, PKCS7 *pkcs7, int flags) { - return SMIME_write_PKCS7(bio, pkcs7, NULL, flags); -} - -PyObject *smime_read_pkcs7(BIO *bio) { - BIO *bcont = NULL; - PKCS7 *p7; - PyObject *tuple, *_p7, *_BIO; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (BIO_method_type(bio) == BIO_TYPE_MEM) { - /* OpenSSL FAQ explains that this is needed for mem BIO to return EOF, - * like file BIO does. Might need to do this for more mem BIOs but - * not sure if that is safe, so starting with just this single place. - */ - BIO_set_mem_eof_return(bio, 0); - } - - Py_BEGIN_ALLOW_THREADS - p7=SMIME_read_PKCS7(bio, &bcont); - Py_END_ALLOW_THREADS - if (!p7) { - m2_PyErr_Msg(_smime_err); - return NULL; - } - if (!(tuple=PyTuple_New(2))) { - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - _p7 = SWIG_NewPointerObj((void *)p7, SWIGTYPE_p_PKCS7, 0); - PyTuple_SET_ITEM(tuple, 0, _p7); - if (!bcont) { - Py_INCREF(Py_None); - PyTuple_SET_ITEM(tuple, 1, Py_None); - } else { - _BIO = SWIG_NewPointerObj((void *)bcont, SWIGTYPE_p_BIO, 0); - PyTuple_SET_ITEM(tuple, 1, _BIO); - } - return tuple; -} - - -int pkcs7_write_bio(PKCS7 *pkcs7, BIO* bio) { - return PEM_write_bio_PKCS7(bio, pkcs7); -} - - -int pkcs7_write_bio_der(PKCS7 *pkcs7, BIO *bio) { - return i2d_PKCS7_bio(bio, pkcs7); -} - -int pkcs7_type_nid(PKCS7 *pkcs7) { - return OBJ_obj2nid(pkcs7->type); -} - -const char *pkcs7_type_sn(PKCS7 *pkcs7) { - return OBJ_nid2sn(OBJ_obj2nid(pkcs7->type)); -} - - -int smime_crlf_copy(BIO *in, BIO *out) { - return SMIME_crlf_copy(in, out, PKCS7_TEXT); -} - -/* return STACK_OF(X509)* */ -STACK_OF(X509) *pkcs7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) { - return PKCS7_get0_signers(p7, certs, flags); -} - - - -#include - - -static PyObject *_util_err; - -void util_init(PyObject *util_err) { - Py_INCREF(util_err); - _util_err = util_err; -} - -PyObject *util_hex_to_string(PyObject *blob) { - PyObject *obj; - const void *buf; - char *ret; - Py_ssize_t len; - - if (PyObject_AsReadBuffer(blob, &buf, &len) == -1) - return NULL; - - ret = hex_to_string((unsigned char *)buf, len); - if (!ret) { - m2_PyErr_Msg(_util_err); - return NULL; - } - - obj = PyBytes_FromString(ret); - - OPENSSL_free(ret); - return obj; -} - -PyObject *util_string_to_hex(PyObject *blob) { - PyObject *obj; - const void *buf; - unsigned char *ret; - Py_ssize_t len0; - long len; - - if (PyObject_AsReadBuffer(blob, &buf, &len0) == -1) - return NULL; - - len = len0; - ret = string_to_hex((char *)buf, &len); - if (ret == NULL) { - m2_PyErr_Msg(_util_err); - return NULL; - } - obj = PyBytes_FromStringAndSize((char*)ret, len); - OPENSSL_free(ret); - return obj; -} - - -#include -#include -#include -#include -#include -#include - - -static PyObject *_ec_err; - -void ec_init(PyObject *ec_err) { - Py_INCREF(ec_err); - _ec_err = ec_err; -} - -PyObject *ec_get_builtin_curves(void) { - /* size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t - * nitems); */ - EC_builtin_curve *curves; - Py_ssize_t ret_curves = 0; - size_t num_curves = EC_get_builtin_curves(NULL, 0); - PyObject *ret_tuple = NULL; - PyObject *ret_dict = NULL; - Py_ssize_t i; - const char *comment; - const char *sname; - - if (!(curves = PyMem_Malloc(num_curves * sizeof(EC_builtin_curve)))) { - PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); - return NULL; - } - - ret_curves = (Py_ssize_t)EC_get_builtin_curves(curves, num_curves); - - if (!(ret_tuple = PyTuple_New(ret_curves))) { - PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); - return NULL; - } - - for (i = 0; i < ret_curves; i++) { - if (!(ret_dict = PyDict_New())) { - PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); - return NULL; - } - - comment = curves[i].comment; - sname = OBJ_nid2sn(curves[i].nid); - if (sname == NULL) - sname = ""; - - PyDict_SetItemString(ret_dict, "NID", - PyLong_FromLong((long)curves[i].nid)); - PyDict_SetItemString(ret_dict, "sname", - PyString_FromString(sname)); - PyDict_SetItemString(ret_dict, "comment", - PyString_FromString(comment)); - - PyTuple_SET_ITEM(ret_tuple, i, ret_dict); - - } - - PyMem_Free(curves); - - return ret_tuple; -} - -EC_KEY* ec_key_new_by_curve_name(int nid) -{ - EC_KEY *key; - EC_GROUP *group; - int ret =0; - point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; - int asn1_flag = OPENSSL_EC_NAMED_CURVE; - - /* If I simply do "return EC_KEY_new_by_curve_name(nid);" - * I get large public keys (222 vs 84 bytes for sect233k1 curve). - * I don't know why that is, but 'openssl ecparam -genkey ...' sets - * the ASN.1 flag and the point conversion form, and gets the - * small pub keys. So let's do that too. - */ - key = EC_KEY_new(); - if (!key) { - PyErr_SetString(PyExc_MemoryError, "ec_key_new_by_curve_name"); - return NULL; - } - group = EC_GROUP_new_by_curve_name(nid); - if (!group) { - m2_PyErr_Msg(_ec_err); - EC_KEY_free(key); - return NULL; - } - EC_GROUP_set_asn1_flag(group, asn1_flag); - EC_GROUP_set_point_conversion_form(group, form); - ret = EC_KEY_set_group(key, group); - EC_GROUP_free(group); - if (ret == 0) - { - /* EC_KEY_set_group only returns 0 or 1, and does not set error. */ - PyErr_SetString(_ec_err, "cannot set key's group"); - EC_KEY_free(key); - return NULL; - } - - return key; -} - -PyObject *ec_key_get_public_der(EC_KEY *key) { - char *src=NULL; - int src_len=0; - PyObject *pyo=NULL; - - /* Convert to binary */ - src_len = i2d_EC_PUBKEY( key, (unsigned char**)&src ); - if (src_len < 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - /* Create a PyBuffer containing a copy of the binary, - * to simplify memory deallocation - */ - pyo = PyBytes_FromStringAndSize( src, src_len ); - - OPENSSL_free(src); - - return pyo; -} - -PyObject *ec_key_get_public_key(EC_KEY *key) { - char *src=NULL; - int src_len=0; - PyObject *pyo=NULL; - - /* Convert to binary */ - src_len = i2o_ECPublicKey(key, (unsigned char**)&src); - if (src_len < 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - - pyo = PyBytes_FromStringAndSize( src, src_len ); - - OPENSSL_free(src); - - return pyo; -} - - - -EC_KEY *ec_key_read_pubkey(BIO *f) { - return PEM_read_bio_EC_PUBKEY(f, NULL, NULL, NULL); -} - - -int ec_key_write_pubkey(EC_KEY *key, BIO *f) { - return PEM_write_bio_EC_PUBKEY(f, key ); -} - - -EC_KEY *ec_key_read_bio(BIO *f, PyObject *pyfunc) { - EC_KEY *ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_read_bio_ECPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -int ec_key_write_bio(EC_KEY *key, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_ECPrivateKey(f, key, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -int ec_key_write_bio_no_cipher(EC_KEY *key, BIO *f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_ECPrivateKey(f, key, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} - - -PyObject *ecdsa_sig_get_r(ECDSA_SIG *ecdsa_sig) { - const BIGNUM* pr; - ECDSA_SIG_get0(ecdsa_sig, &pr, NULL); - return bn_to_mpi(pr); -} - -PyObject *ecdsa_sig_get_s(ECDSA_SIG *ecdsa_sig) { - const BIGNUM* ps; - ECDSA_SIG_get0(ecdsa_sig, NULL, &ps); - return bn_to_mpi(ps); -} - -PyObject *ecdsa_sign(EC_KEY *key, PyObject *value) { - const void *vbuf; - int vlen = 0; - PyObject *tuple; - ECDSA_SIG *sig; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sig = ECDSA_do_sign(vbuf, vlen, key))) { - m2_PyErr_Msg(_ec_err); - return NULL; - } - if (!(tuple = PyTuple_New(2))) { - ECDSA_SIG_free(sig); - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - PyTuple_SET_ITEM(tuple, 0, ecdsa_sig_get_r(sig)); - PyTuple_SET_ITEM(tuple, 1, ecdsa_sig_get_s(sig)); - ECDSA_SIG_free(sig); - return tuple; -} - -int ecdsa_verify(EC_KEY *key, PyObject *value, PyObject *r, PyObject *s) { - const void *vbuf, *rbuf, *sbuf; - int vlen = 0, rlen = 0, slen = 0; - ECDSA_SIG *sig; - int ret; - BIGNUM* pr, *ps; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) - || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) - return -1; - - if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { - m2_PyErr_Msg(_ec_err); - return -1; - } - if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { - m2_PyErr_Msg(_ec_err); - BN_free(pr); - return -1; - } - - if (!(sig = ECDSA_SIG_new())) { - m2_PyErr_Msg(_ec_err); - BN_free(pr); - BN_free(ps); - return -1; - } - if (!ECDSA_SIG_set0(sig, pr, ps)) { - PyErr_SetString(_ec_err, "Cannot set r and s fields of ECDSA_SIG."); - ECDSA_SIG_free(sig); - BN_free(pr); - BN_free(ps); - return -1; - } - ret = ECDSA_do_verify(vbuf, vlen, sig, key); - ECDSA_SIG_free(sig); - if (ret == -1) - m2_PyErr_Msg(_ec_err); - return ret; -} - - -PyObject *ecdsa_sign_asn1(EC_KEY *key, PyObject *value) { - const void *vbuf; - int vlen = 0; - void *sigbuf; - unsigned int siglen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(sigbuf = PyMem_Malloc(ECDSA_size(key)))) { - PyErr_SetString(PyExc_MemoryError, "ecdsa_sign_asn1"); - return NULL; - } - if (!ECDSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, key)) { - m2_PyErr_Msg(_ec_err); - PyMem_Free(sigbuf); - return NULL; - } - ret = PyBytes_FromStringAndSize(sigbuf, siglen); - - PyMem_Free(sigbuf); - return ret; -} - - -int ecdsa_verify_asn1(EC_KEY *key, PyObject *value, PyObject *sig) { - const void *vbuf; - void *sbuf; - int vlen = 0, slen = 0, ret; - - if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) - == -1)) - return -1; - - if ((ret = ECDSA_verify(0, vbuf, vlen, sbuf, slen, key)) == -1) - m2_PyErr_Msg(_ec_err); - return ret; -} - -PyObject *ecdh_compute_key(EC_KEY *keypairA, EC_KEY *pubkeyB) { - int sharedkeylen; - void *sharedkey; - const EC_POINT *pkpointB; - PyObject *ret; - const EC_GROUP* groupA; - - if ((pkpointB = EC_KEY_get0_public_key(pubkeyB)) == NULL) - { - PyErr_SetString(_ec_err, "Cannot get the public key of EC_KEY object."); - return NULL; - } - - groupA = EC_KEY_get0_group(keypairA); - sharedkeylen = (EC_GROUP_get_degree(groupA) + 7)/8; - - if (!(sharedkey = PyMem_Malloc(sharedkeylen))) { - PyErr_SetString(PyExc_MemoryError, "ecdh_compute_key"); - return NULL; - } - if ((sharedkeylen = ECDH_compute_key((unsigned char *)sharedkey, sharedkeylen, pkpointB, keypairA, NULL)) == -1) { - m2_PyErr_Msg(_ec_err); - PyMem_Free(sharedkey); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)sharedkey, sharedkeylen); - - PyMem_Free(sharedkey); - - return ret; -} - - -EC_KEY* ec_key_from_pubkey_der(PyObject *pubkey) { - const void *keypairbuf; - Py_ssize_t keypairbuflen; - const unsigned char *tempBuf; - EC_KEY *keypair; - - if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) - { - return NULL; - } - - tempBuf = (const unsigned char *)keypairbuf; - if ((keypair = d2i_EC_PUBKEY( NULL, &tempBuf, keypairbuflen)) == 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - return keypair; -} - -EC_KEY* ec_key_from_pubkey_params(int nid, PyObject *pubkey) { - const void *keypairbuf; - Py_ssize_t keypairbuflen; - const unsigned char *tempBuf; - EC_KEY *keypair; - - if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) - { - return NULL; - } - - keypair = ec_key_new_by_curve_name(nid); - if (!keypair) { - m2_PyErr_Msg(_ec_err); - return NULL; - } - - tempBuf = (const unsigned char *)keypairbuf; - if ((o2i_ECPublicKey( &keypair, &tempBuf, keypairbuflen)) == 0) - { - m2_PyErr_Msg(_ec_err); - return NULL; - } - return keypair; -} - - -// According to [SEC2] the degree of the group is defined as EC key length -int ec_key_keylen(EC_KEY *key) { - const EC_GROUP *group = EC_KEY_get0_group(key); - return EC_GROUP_get_degree(group); -} - -int ec_key_type_check(EC_KEY *key) { - return 1; -} - - -#include -#include -#include - - - -/* - * Code from engine-pkcs11 1.4.0 in engine-pkcs11.c - * - -99 static char *get_pin(UI_METHOD * ui_method, void *callback_data, char *sc_pin, -100 int maxlen) -101 { -102 UI *ui; -103 struct { -104 const void *password; -105 const char *prompt_info; -106 } *mycb = callback_data; -107 -108 if (mycb->password) { -109 sc_pin = set_pin(mycb->password); -110 return sc_pin; -111 } - - * - * So callback_data need to be always provided and have fixed type. - * UI method still may be NULL. - * - * Following functions allocate and free callback data structure with - * optional password set. - */ - -typedef struct { - char * password; - char * prompt; -} _cbd_t; - -void * engine_pkcs11_data_new(const char *pin) { - _cbd_t * cb = (_cbd_t *) PyMem_Malloc(sizeof(_cbd_t)); - if (!cb) { - PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); - return NULL; - } - cb->password = NULL; - if (pin) { - size_t size = strlen(pin); - cb->password = (char *) PyMem_Malloc(size + 1); - if (!cb->password) { - PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); - PyMem_Free(cb); - return NULL; - } - memcpy(cb->password, pin, size + 1); - } - cb->prompt = NULL; - return cb; -} - -void engine_pkcs11_data_free(void * vcb) { - _cbd_t * cb = (_cbd_t *) vcb; - if (!cb) - return; - if (cb->password) - PyMem_Free(cb->password); - PyMem_Free(cb); -} - - - -static PyObject *_engine_err; - -void engine_init_error(PyObject *engine_err) { - Py_INCREF(engine_err); - _engine_err = engine_err; -} - -X509 * engine_load_certificate(ENGINE *e, const char * slot) { - struct { - const char * slot; - X509 * cert; - } cbd; - cbd.slot = slot; - cbd.cert = NULL; - if (!ENGINE_ctrl_cmd(e, "LOAD_CERT_CTRL", 0, &cbd, NULL, 0)) { - PyErr_SetString(_engine_err, "cannot load certificate"); - return NULL; - } - return cbd.cert; -} - - -#include - - -/* - From the manpage for OBJ_obt2txt (): - BUGS - OBJ_obj2txt() is awkward and messy to use: it doesn’t follow the - convention of other OpenSSL functions where the buffer can be set - to NULL to determine the amount of data that should be written. - Instead buf must point to a valid buffer and buf_len should be set - to a positive value. A buffer length of 80 should be more than - enough to handle any OID encountered in practice. - - The first call to OBJ_obj2txt () therefore passes a non-NULL dummy - buffer. This wart is reportedly removed in OpenSSL 0.9.8b, although - the manpage has not been updated. - - OBJ_obj2txt always prints \0 at the end. But the return value - is the number of "good" bytes written. So memory is allocated for - len + 1 bytes but only len bytes are marshalled to python. -*/ -PyObject *obj_obj2txt(const ASN1_OBJECT *obj, int no_name) -{ - int len; - PyObject *ret; - char *buf; - char dummy[1]; - - len = OBJ_obj2txt(dummy, 1, obj, no_name); - if (len < 0) { - m2_PyErr_Msg(PyExc_RuntimeError); - return NULL; - } else if (len == 0) { - /* XXX: For OpenSSL prior to 0.9.8b. - - Changes between 0.9.8a and 0.9.8b [04 May 2006] - ... - *) Several fixes and enhancements to the OID generation code. The old code - sometimes allowed invalid OIDs (1.X for X >= 40 for example), couldn't - handle numbers larger than ULONG_MAX, truncated printing and had a - non standard OBJ_obj2txt() behaviour. - [Steve Henson] - */ - - len = 80; - } - - buf = PyMem_Malloc(len + 1); - len = OBJ_obj2txt(buf, len + 1, obj, no_name); - - ret = PyBytes_FromStringAndSize(buf, len); - - PyMem_Free(buf); - - return ret; -} - -#ifdef __cplusplus -extern "C" { -#endif -SWIGINTERN PyObject *_wrap_OPENSSL_sk_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_num" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - result = (int)OPENSSL_sk_num((struct stack_st const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_value" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (void *)OPENSSL_sk_value((struct stack_st const *)arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - int arg2 ; - void *arg3 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int res3 ; - PyObject *swig_obj[3] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_set", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_set" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_set" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "OPENSSL_sk_set" "', argument " "3"" of type '" "void const *""'"); - } - result = (void *)OPENSSL_sk_set(arg1,arg2,(void const *)arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_sk_compfunc arg1 = (OPENSSL_sk_compfunc) 0 ; - PyObject *swig_obj[1] ; - OPENSSL_STACK *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_new" "', argument " "1"" of type '" "OPENSSL_sk_compfunc""'"); - } - } - result = (OPENSSL_STACK *)OPENSSL_sk_new(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_new_null(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_new_null", 0, 0, 0)) SWIG_fail; - result = (OPENSSL_STACK *)OPENSSL_sk_new_null(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_new_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_sk_compfunc arg1 = (OPENSSL_sk_compfunc) 0 ; - int arg2 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - OPENSSL_STACK *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_new_reserve", 2, 2, swig_obj)) SWIG_fail; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_new_reserve" "', argument " "1"" of type '" "OPENSSL_sk_compfunc""'"); - } - } - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_new_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (OPENSSL_STACK *)OPENSSL_sk_new_reserve(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_reserve", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_reserve" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)OPENSSL_sk_reserve(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_free" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - OPENSSL_sk_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_pop_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void (*arg2)(void *) = (void (*)(void *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_pop_free", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_pop_free" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_void__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_pop_free" "', argument " "2"" of type '" "void (*)(void *)""'"); - } - } - OPENSSL_sk_pop_free(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_deep_copy(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - OPENSSL_sk_copyfunc arg2 = (OPENSSL_sk_copyfunc) 0 ; - OPENSSL_sk_freefunc arg3 = (OPENSSL_sk_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - OPENSSL_STACK *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_deep_copy", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_deep_copy" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__void__p_void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_deep_copy" "', argument " "2"" of type '" "OPENSSL_sk_copyfunc""'"); - } - } - { - int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_void__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_deep_copy" "', argument " "3"" of type '" "OPENSSL_sk_freefunc""'"); - } - } - result = (OPENSSL_STACK *)OPENSSL_sk_deep_copy((struct stack_st const *)arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_insert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_insert", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_insert" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_insert" "', argument " "2"" of type '" "void const *""'"); - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "OPENSSL_sk_insert" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)OPENSSL_sk_insert(arg1,(void const *)arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_delete(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_delete", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_delete" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_delete" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (void *)OPENSSL_sk_delete(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_delete_ptr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_delete_ptr", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_delete_ptr" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_delete_ptr" "', argument " "2"" of type '" "void const *""'"); - } - result = (void *)OPENSSL_sk_delete_ptr(arg1,(void const *)arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_find(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_find", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_find" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_find" "', argument " "2"" of type '" "void const *""'"); - } - result = (int)OPENSSL_sk_find(arg1,(void const *)arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_find_ex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_find_ex", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_find_ex" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_find_ex" "', argument " "2"" of type '" "void const *""'"); - } - result = (int)OPENSSL_sk_find_ex(arg1,(void const *)arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_push" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_push" "', argument " "2"" of type '" "void const *""'"); - } - result = (int)OPENSSL_sk_push(arg1,(void const *)arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_unshift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_unshift", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_unshift" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_unshift" "', argument " "2"" of type '" "void const *""'"); - } - result = (int)OPENSSL_sk_unshift(arg1,(void const *)arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_shift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - void *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_shift" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - result = (void *)OPENSSL_sk_shift(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - void *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_pop" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - result = (void *)OPENSSL_sk_pop(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_zero(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_zero" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - OPENSSL_sk_zero(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_set_cmp_func(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - OPENSSL_sk_compfunc arg2 = (OPENSSL_sk_compfunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - OPENSSL_sk_compfunc result; - - if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_set_cmp_func" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_set_cmp_func" "', argument " "2"" of type '" "OPENSSL_sk_compfunc""'"); - } - } - result = (OPENSSL_sk_compfunc)OPENSSL_sk_set_cmp_func(arg1,arg2); - resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_dup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - OPENSSL_STACK *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_dup" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - result = (OPENSSL_STACK *)OPENSSL_sk_dup((struct stack_st const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_sort(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_sort" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - OPENSSL_sk_sort(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_OPENSSL_sk_is_sorted(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_is_sorted" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); - } - arg1 = (OPENSSL_STACK *)(argp1); - result = (int)OPENSSL_sk_is_sorted((struct stack_st const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_num" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - result = (int)sk_OPENSSL_STRING_num((struct stack_st_OPENSSL_STRING const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_value" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (char *)sk_OPENSSL_STRING_value((struct stack_st_OPENSSL_STRING const *)arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - sk_OPENSSL_STRING_compfunc arg1 = (sk_OPENSSL_STRING_compfunc) 0 ; - PyObject *swig_obj[1] ; - struct stack_st_OPENSSL_STRING *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_new" "', argument " "1"" of type '" "sk_OPENSSL_STRING_compfunc""'"); - } - } - result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_new(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_new_null(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_new_null", 0, 0, 0)) SWIG_fail; - result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_new_null(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_new_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - sk_OPENSSL_STRING_compfunc arg1 = (sk_OPENSSL_STRING_compfunc) 0 ; - int arg2 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - struct stack_st_OPENSSL_STRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_new_reserve", 2, 2, swig_obj)) SWIG_fail; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_new_reserve" "', argument " "1"" of type '" "sk_OPENSSL_STRING_compfunc""'"); - } - } - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_new_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_new_reserve(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_reserve", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_reserve" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)sk_OPENSSL_STRING_reserve(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - sk_OPENSSL_STRING_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_zero(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_zero" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - sk_OPENSSL_STRING_zero(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_delete(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_delete", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_delete" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_delete" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (char *)sk_OPENSSL_STRING_delete(arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_delete_ptr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_delete_ptr", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_delete_ptr" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_delete_ptr" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - result = (char *)sk_OPENSSL_STRING_delete_ptr(arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_push" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_push" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_STRING_push(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_unshift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_unshift", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_unshift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_unshift" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_STRING_unshift(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_pop" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - result = (char *)sk_OPENSSL_STRING_pop(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_shift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_shift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - result = (char *)sk_OPENSSL_STRING_shift(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_pop_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - sk_OPENSSL_STRING_freefunc arg2 = (sk_OPENSSL_STRING_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_pop_free", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_pop_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_char__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_pop_free" "', argument " "2"" of type '" "sk_OPENSSL_STRING_freefunc""'"); - } - } - sk_OPENSSL_STRING_pop_free(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_insert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_insert", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_insert" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_insert" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sk_OPENSSL_STRING_insert" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)sk_OPENSSL_STRING_insert(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - int arg2 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject *swig_obj[3] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_set", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_set" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_set" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "sk_OPENSSL_STRING_set" "', argument " "3"" of type '" "char *""'"); - } - arg3 = (char *)(buf3); - result = (char *)sk_OPENSSL_STRING_set(arg1,arg2,arg3); - resultobj = SWIG_FromCharPtr((const char *)result); - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_find(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_find", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_find" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_find" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_STRING_find(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_find_ex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_find_ex", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_find_ex" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_find_ex" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_STRING_find_ex(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_sort(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_sort" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - sk_OPENSSL_STRING_sort(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_is_sorted(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_is_sorted" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - result = (int)sk_OPENSSL_STRING_is_sorted((struct stack_st_OPENSSL_STRING const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_dup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - struct stack_st_OPENSSL_STRING *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_dup" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_dup((struct stack_st_OPENSSL_STRING const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_deep_copy(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - sk_OPENSSL_STRING_copyfunc arg2 = (sk_OPENSSL_STRING_copyfunc) 0 ; - sk_OPENSSL_STRING_freefunc arg3 = (sk_OPENSSL_STRING_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - struct stack_st_OPENSSL_STRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_deep_copy", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_deep_copy" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__char__p_char); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_deep_copy" "', argument " "2"" of type '" "sk_OPENSSL_STRING_copyfunc""'"); - } - } - { - int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_char__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_deep_copy" "', argument " "3"" of type '" "sk_OPENSSL_STRING_freefunc""'"); - } - } - result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_deep_copy((struct stack_st_OPENSSL_STRING const *)arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_set_cmp_func(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; - sk_OPENSSL_STRING_compfunc arg2 = (sk_OPENSSL_STRING_compfunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - sk_OPENSSL_STRING_compfunc result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_set_cmp_func" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_set_cmp_func" "', argument " "2"" of type '" "sk_OPENSSL_STRING_compfunc""'"); - } - } - result = (sk_OPENSSL_STRING_compfunc)sk_OPENSSL_STRING_set_cmp_func(arg1,arg2); - resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_num" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - result = (int)sk_OPENSSL_CSTRING_num((struct stack_st_OPENSSL_CSTRING const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_value" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (char *)sk_OPENSSL_CSTRING_value((struct stack_st_OPENSSL_CSTRING const *)arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - sk_OPENSSL_CSTRING_compfunc arg1 = (sk_OPENSSL_CSTRING_compfunc) 0 ; - PyObject *swig_obj[1] ; - struct stack_st_OPENSSL_CSTRING *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_new" "', argument " "1"" of type '" "sk_OPENSSL_CSTRING_compfunc""'"); - } - } - result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_new(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_new_null(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_new_null", 0, 0, 0)) SWIG_fail; - result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_new_null(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_new_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - sk_OPENSSL_CSTRING_compfunc arg1 = (sk_OPENSSL_CSTRING_compfunc) 0 ; - int arg2 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - struct stack_st_OPENSSL_CSTRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_new_reserve", 2, 2, swig_obj)) SWIG_fail; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_new_reserve" "', argument " "1"" of type '" "sk_OPENSSL_CSTRING_compfunc""'"); - } - } - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_new_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_new_reserve(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_reserve", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_reserve" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)sk_OPENSSL_CSTRING_reserve(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - sk_OPENSSL_CSTRING_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_zero(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_zero" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - sk_OPENSSL_CSTRING_zero(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_delete(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_delete", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_delete" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_delete" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (char *)sk_OPENSSL_CSTRING_delete(arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_delete_ptr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_delete_ptr", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_delete_ptr" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_delete_ptr" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (char *)sk_OPENSSL_CSTRING_delete_ptr(arg1,(char const *)arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_push" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_push" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_CSTRING_push(arg1,(char const *)arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_unshift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_unshift", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_unshift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_unshift" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_CSTRING_unshift(arg1,(char const *)arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_pop" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - result = (char *)sk_OPENSSL_CSTRING_pop(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_shift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_shift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - result = (char *)sk_OPENSSL_CSTRING_shift(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_pop_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - sk_OPENSSL_CSTRING_freefunc arg2 = (sk_OPENSSL_CSTRING_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_pop_free", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_pop_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_char__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_pop_free" "', argument " "2"" of type '" "sk_OPENSSL_CSTRING_freefunc""'"); - } - } - sk_OPENSSL_CSTRING_pop_free(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_insert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_insert", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_insert" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_insert" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sk_OPENSSL_CSTRING_insert" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)sk_OPENSSL_CSTRING_insert(arg1,(char const *)arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - int arg2 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject *swig_obj[3] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_set", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_set" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_set" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "sk_OPENSSL_CSTRING_set" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = (char *)(buf3); - result = (char *)sk_OPENSSL_CSTRING_set(arg1,arg2,(char const *)arg3); - resultobj = SWIG_FromCharPtr((const char *)result); - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_find(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_find", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_find" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_find" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_CSTRING_find(arg1,(char const *)arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_find_ex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_find_ex", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_find_ex" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_find_ex" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (int)sk_OPENSSL_CSTRING_find_ex(arg1,(char const *)arg2); - resultobj = SWIG_From_int((int)(result)); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_sort(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_sort" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - sk_OPENSSL_CSTRING_sort(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_is_sorted(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_is_sorted" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - result = (int)sk_OPENSSL_CSTRING_is_sorted((struct stack_st_OPENSSL_CSTRING const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_dup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - struct stack_st_OPENSSL_CSTRING *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_dup" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_dup((struct stack_st_OPENSSL_CSTRING const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_deep_copy(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - sk_OPENSSL_CSTRING_copyfunc arg2 = (sk_OPENSSL_CSTRING_copyfunc) 0 ; - sk_OPENSSL_CSTRING_freefunc arg3 = (sk_OPENSSL_CSTRING_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - struct stack_st_OPENSSL_CSTRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_deep_copy", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_deep_copy" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__char__p_char); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_deep_copy" "', argument " "2"" of type '" "sk_OPENSSL_CSTRING_copyfunc""'"); - } - } - { - int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_char__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_deep_copy" "', argument " "3"" of type '" "sk_OPENSSL_CSTRING_freefunc""'"); - } - } - result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_deep_copy((struct stack_st_OPENSSL_CSTRING const *)arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_set_cmp_func(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; - sk_OPENSSL_CSTRING_compfunc arg2 = (sk_OPENSSL_CSTRING_compfunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - sk_OPENSSL_CSTRING_compfunc result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_set_cmp_func" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); - } - arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_set_cmp_func" "', argument " "2"" of type '" "sk_OPENSSL_CSTRING_compfunc""'"); - } - } - result = (sk_OPENSSL_CSTRING_compfunc)sk_OPENSSL_CSTRING_set_cmp_func(arg1,arg2); - resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_num" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - result = (int)sk_OPENSSL_BLOCK_num((struct stack_st_OPENSSL_BLOCK const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_value" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (void *)sk_OPENSSL_BLOCK_value((struct stack_st_OPENSSL_BLOCK const *)arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - sk_OPENSSL_BLOCK_compfunc arg1 = (sk_OPENSSL_BLOCK_compfunc) 0 ; - PyObject *swig_obj[1] ; - struct stack_st_OPENSSL_BLOCK *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_new" "', argument " "1"" of type '" "sk_OPENSSL_BLOCK_compfunc""'"); - } - } - result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_new(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_new_null(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_new_null", 0, 0, 0)) SWIG_fail; - result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_new_null(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_new_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - sk_OPENSSL_BLOCK_compfunc arg1 = (sk_OPENSSL_BLOCK_compfunc) 0 ; - int arg2 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - struct stack_st_OPENSSL_BLOCK *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_new_reserve", 2, 2, swig_obj)) SWIG_fail; - { - int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_new_reserve" "', argument " "1"" of type '" "sk_OPENSSL_BLOCK_compfunc""'"); - } - } - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_new_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_new_reserve(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_reserve(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_reserve", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_reserve" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_reserve" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)sk_OPENSSL_BLOCK_reserve(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - sk_OPENSSL_BLOCK_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_zero(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_zero" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - sk_OPENSSL_BLOCK_zero(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_delete(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_delete", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_delete" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_delete" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (void *)sk_OPENSSL_BLOCK_delete(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_delete_ptr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_delete_ptr", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_delete_ptr" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_delete_ptr" "', argument " "2"" of type '" "void *""'"); - } - result = (void *)sk_OPENSSL_BLOCK_delete_ptr(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_push" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_push" "', argument " "2"" of type '" "void *""'"); - } - result = (int)sk_OPENSSL_BLOCK_push(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_unshift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_unshift", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_unshift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_unshift" "', argument " "2"" of type '" "void *""'"); - } - result = (int)sk_OPENSSL_BLOCK_unshift(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - void *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_pop" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - result = (void *)sk_OPENSSL_BLOCK_pop(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_shift(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - void *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_shift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - result = (void *)sk_OPENSSL_BLOCK_shift(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_pop_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - sk_OPENSSL_BLOCK_freefunc arg2 = (sk_OPENSSL_BLOCK_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_pop_free", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_pop_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_void__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_pop_free" "', argument " "2"" of type '" "sk_OPENSSL_BLOCK_freefunc""'"); - } - } - sk_OPENSSL_BLOCK_pop_free(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_insert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_insert", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_insert" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_insert" "', argument " "2"" of type '" "void *""'"); - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sk_OPENSSL_BLOCK_insert" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (int)sk_OPENSSL_BLOCK_insert(arg1,arg2,arg3); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - int arg2 ; - void *arg3 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int res3 ; - PyObject *swig_obj[3] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_set", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_set" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_set" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "sk_OPENSSL_BLOCK_set" "', argument " "3"" of type '" "void *""'"); - } - result = (void *)sk_OPENSSL_BLOCK_set(arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_find(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_find", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_find" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_find" "', argument " "2"" of type '" "void *""'"); - } - result = (int)sk_OPENSSL_BLOCK_find(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_find_ex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *arg2 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_find_ex", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_find_ex" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_find_ex" "', argument " "2"" of type '" "void *""'"); - } - result = (int)sk_OPENSSL_BLOCK_find_ex(arg1,arg2); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_sort(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_sort" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - sk_OPENSSL_BLOCK_sort(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_is_sorted(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_is_sorted" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - result = (int)sk_OPENSSL_BLOCK_is_sorted((struct stack_st_OPENSSL_BLOCK const *)arg1); - resultobj = SWIG_From_int((int)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_dup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - struct stack_st_OPENSSL_BLOCK *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_dup" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_dup((struct stack_st_OPENSSL_BLOCK const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_deep_copy(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - sk_OPENSSL_BLOCK_copyfunc arg2 = (sk_OPENSSL_BLOCK_copyfunc) 0 ; - sk_OPENSSL_BLOCK_freefunc arg3 = (sk_OPENSSL_BLOCK_freefunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - struct stack_st_OPENSSL_BLOCK *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_deep_copy", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_deep_copy" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__void__p_void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_deep_copy" "', argument " "2"" of type '" "sk_OPENSSL_BLOCK_copyfunc""'"); - } - } - { - int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_void__void); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_deep_copy" "', argument " "3"" of type '" "sk_OPENSSL_BLOCK_freefunc""'"); - } - } - result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_deep_copy((struct stack_st_OPENSSL_BLOCK const *)arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_set_cmp_func(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; - sk_OPENSSL_BLOCK_compfunc arg2 = (sk_OPENSSL_BLOCK_compfunc) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - sk_OPENSSL_BLOCK_compfunc result; - - if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_set_cmp_func" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); - } - arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_set_cmp_func" "', argument " "2"" of type '" "sk_OPENSSL_BLOCK_compfunc""'"); - } - } - result = (sk_OPENSSL_BLOCK_compfunc)sk_OPENSSL_BLOCK_set_cmp_func(arg1,arg2); - resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_threading_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "threading_init", 0, 0, 0)) SWIG_fail; - threading_init(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_threading_cleanup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "threading_cleanup", 0, 0, 0)) SWIG_fail; - threading_cleanup(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_lib_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "lib_init", 0, 0, 0)) SWIG_fail; - lib_init(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bn_to_mpi(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIGNUM *arg1 = (BIGNUM *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIGNUM, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bn_to_mpi" "', argument " "1"" of type '" "BIGNUM const *""'"); - } - arg1 = (BIGNUM *)(argp1); - result = (PyObject *)bn_to_mpi((BIGNUM const *)arg1); - resultobj = result; - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_mpi_to_bn(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - BIGNUM *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - arg1 = swig_obj[0]; - result = (BIGNUM *)mpi_to_bn(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bn_to_bin(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIGNUM *arg1 = (BIGNUM *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIGNUM, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bn_to_bin" "', argument " "1"" of type '" "BIGNUM *""'"); - } - arg1 = (BIGNUM *)(argp1); - result = (PyObject *)bn_to_bin(arg1); - resultobj = result; - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bin_to_bn(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - BIGNUM *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - arg1 = swig_obj[0]; - result = (BIGNUM *)bin_to_bn(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bn_to_hex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIGNUM *arg1 = (BIGNUM *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIGNUM, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bn_to_hex" "', argument " "1"" of type '" "BIGNUM *""'"); - } - arg1 = (BIGNUM *)(argp1); - result = (PyObject *)bn_to_hex(arg1); - resultobj = result; - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hex_to_bn(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - BIGNUM *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - arg1 = swig_obj[0]; - result = (BIGNUM *)hex_to_bn(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dec_to_bn(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - BIGNUM *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - arg1 = swig_obj[0]; - result = (BIGNUM *)dec_to_bn(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_err_print_errors(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "err_print_errors" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - ERR_print_errors(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_err_get_error(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - unsigned long result; - - if (!SWIG_Python_UnpackTuple(args, "err_get_error", 0, 0, 0)) SWIG_fail; - result = (unsigned long)ERR_get_error(); - resultobj = SWIG_From_unsigned_SS_long((unsigned long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_err_peek_error(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - unsigned long result; - - if (!SWIG_Python_UnpackTuple(args, "err_peek_error", 0, 0, 0)) SWIG_fail; - result = (unsigned long)ERR_peek_error(); - resultobj = SWIG_From_unsigned_SS_long((unsigned long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_err_lib_error_string(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - unsigned long arg1 ; - unsigned long val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_unsigned_SS_long(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "err_lib_error_string" "', argument " "1"" of type '" "unsigned long""'"); - } - arg1 = (unsigned long)(val1); - result = (char *)ERR_lib_error_string(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_err_func_error_string(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - unsigned long arg1 ; - unsigned long val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_unsigned_SS_long(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "err_func_error_string" "', argument " "1"" of type '" "unsigned long""'"); - } - arg1 = (unsigned long)(val1); - result = (char *)ERR_func_error_string(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_err_reason_error_string(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - unsigned long arg1 ; - unsigned long val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_unsigned_SS_long(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "err_reason_error_string" "', argument " "1"" of type '" "unsigned long""'"); - } - arg1 = (unsigned long)(val1); - result = (char *)ERR_reason_error_string(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_s_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_s_bio", 0, 0, 0)) SWIG_fail; - result = (BIO_METHOD *)BIO_s_bio(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_s_mem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_s_mem", 0, 0, 0)) SWIG_fail; - result = (BIO_METHOD *)BIO_s_mem(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_s_socket(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_s_socket", 0, 0, 0)) SWIG_fail; - result = (BIO_METHOD *)BIO_s_socket(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_f_ssl(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_f_ssl", 0, 0, 0)) SWIG_fail; - result = (BIO_METHOD *)BIO_f_ssl(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_f_buffer(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_f_buffer", 0, 0, 0)) SWIG_fail; - result = (BIO_METHOD *)BIO_f_buffer(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_f_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_f_cipher", 0, 0, 0)) SWIG_fail; - result = (BIO_METHOD *)BIO_f_cipher(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO_METHOD *arg1 = (BIO_METHOD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - BIO *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO_METHOD, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_new" "', argument " "1"" of type '" "BIO_METHOD *""'"); - } - arg1 = (BIO_METHOD *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (BIO *)BIO_new(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_new_socket(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - int val1 ; - int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - BIO *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_new_socket", 2, 2, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bio_new_socket" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_socket" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (BIO *)BIO_new_socket(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_free_all(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_free_all" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - BIO_free_all(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_dup_chain(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - BIO *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_dup_chain" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (BIO *)BIO_dup_chain(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - BIO *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_push" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_push" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (BIO *)BIO_push(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - BIO *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_pop" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (BIO *)BIO_pop(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_eof(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_eof" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)BIO_eof(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__bio_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_bio_err""' of type '""PyObject *""'"); - } - _bio_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__bio_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_bio_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_pyfd_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "pyfd_init", 0, 0, 0)) SWIG_fail; - pyfd_init(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - bio_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_free" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_free(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_new_file(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - char *arg2 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - BIO *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_new_file", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_new_file" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_new_file" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (BIO *)bio_new_file((char const *)arg1,(char const *)arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_new_pyfile(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - int arg2 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - BIO *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_new_pyfile", 2, 2, swig_obj)) SWIG_fail; - { - arg1=swig_obj[0]; - } - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_pyfile" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (BIO *)bio_new_pyfile(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_read(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_read", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_read" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_read" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)bio_read(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_gets(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_gets", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_gets" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_gets" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)bio_gets(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_write(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "bio_write", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_write" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_write(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_ctrl_pending(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_ctrl_pending" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_ctrl_pending(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_ctrl_wpending(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_ctrl_wpending" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_ctrl_wpending(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_ctrl_get_write_guarantee(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_ctrl_get_write_guarantee" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_ctrl_get_write_guarantee(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_reset(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_reset" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_reset(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_flush(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_flush" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)bio_flush(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_seek(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "bio_seek", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_seek" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_seek" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_seek(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_tell(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_tell" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_tell(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_set_flags(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "bio_set_flags", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_flags" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_set_flags" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - bio_set_flags(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_get_flags(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_get_flags" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_get_flags(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_set_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - EVP_CIPHER *arg2 = (EVP_CIPHER *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_set_cipher", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_cipher" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_set_cipher" "', argument " "2"" of type '" "EVP_CIPHER *""'"); - } - arg2 = (EVP_CIPHER *)(argp2); - { - arg3=swig_obj[2]; - } - { - arg4=swig_obj[3]; - } - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bio_set_cipher" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)bio_set_cipher(arg1,arg2,arg3,arg4,arg5); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_set_mem_eof_return(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "bio_set_mem_eof_return", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_mem_eof_return" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_set_mem_eof_return" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_set_mem_eof_return(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_get_fd(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_get_fd" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_get_fd(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_do_handshake(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_do_handshake" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)bio_do_handshake(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_make_bio_pair(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "bio_make_bio_pair", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_make_bio_pair" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_make_bio_pair" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_make_bio_pair(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_set_write_buf_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - size_t arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "bio_set_write_buf_size", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_write_buf_size" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_set_write_buf_size" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = (size_t)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_set_write_buf_size(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_should_retry(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_should_retry" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_should_retry(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_should_read(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_should_read" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_should_read(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_should_write(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_should_write" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_should_write(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_BIO_PYFD_CTX_fd_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct pyfd_struct *arg1 = (struct pyfd_struct *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_pyfd_struct, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BIO_PYFD_CTX_fd_set" "', argument " "1"" of type '" "struct pyfd_struct *""'"); - } - arg1 = (struct pyfd_struct *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BIO_PYFD_CTX_fd_set" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - if (arg1) (arg1)->fd = arg2; - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_BIO_PYFD_CTX_fd_get(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct pyfd_struct *arg1 = (struct pyfd_struct *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "BIO_PYFD_CTX_fd_get", 0, 0, 0)) SWIG_fail; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_pyfd_struct, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BIO_PYFD_CTX_fd_get" "', argument " "1"" of type '" "struct pyfd_struct *""'"); - } - arg1 = (struct pyfd_struct *)(argp1); - result = (int) ((arg1)->fd); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int _wrap_new_BIO_PYFD_CTX(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *resultobj = 0; - struct pyfd_struct *result = 0 ; - - if (!SWIG_Python_CheckNoKeywords(kwargs, "new_BIO_PYFD_CTX")) SWIG_fail; - if (!SWIG_Python_UnpackTuple(args, "new_BIO_PYFD_CTX", 0, 0, 0)) SWIG_fail; - result = (struct pyfd_struct *)calloc(1, sizeof(struct pyfd_struct)); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pyfd_struct, SWIG_BUILTIN_INIT | 0 ); - return resultobj == Py_None ? -1 : 0; -fail: - return -1; -} - - -SWIGINTERN PyObject *_wrap_delete_BIO_PYFD_CTX(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct pyfd_struct *arg1 = (struct pyfd_struct *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!SWIG_Python_UnpackTuple(args, "delete_BIO_PYFD_CTX", 0, 0, 0)) SWIG_fail; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_pyfd_struct, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_BIO_PYFD_CTX" "', argument " "1"" of type '" "struct pyfd_struct *""'"); - } - arg1 = (struct pyfd_struct *)(argp1); - free((char *) arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_BIO_PYFD_CTX) /* defines _wrap_delete_BIO_PYFD_CTX_destructor_closure */ - -SWIGINTERN int Swig_var_methods_fdp_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_BIO_METHOD, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""methods_fdp""' of type '""BIO_METHOD *""'"); - } - methods_fdp = (BIO_METHOD *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var_methods_fdp_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(methods_fdp), SWIGTYPE_p_BIO_METHOD, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_pyfd_write(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pyfd_write", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_write" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_write" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_write" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pyfd_write(arg1,(char const *)arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pyfd_read(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pyfd_read", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_read" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_read" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_read" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pyfd_read(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pyfd_puts(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pyfd_puts", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_puts" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_puts" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pyfd_puts(arg1,(char const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pyfd_gets(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pyfd_gets", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_gets" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_gets" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_gets" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pyfd_gets(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pyfd_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_new" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pyfd_new(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pyfd_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_free" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pyfd_free(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pyfd_ctrl(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - int arg2 ; - long arg3 ; - void *arg4 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - long val3 ; - int ecode3 = 0 ; - int res4 ; - PyObject *swig_obj[4] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "pyfd_ctrl", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_ctrl" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pyfd_ctrl" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_ctrl" "', argument " "3"" of type '" "long""'"); - } - arg3 = (long)(val3); - res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pyfd_ctrl" "', argument " "4"" of type '" "void *""'"); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)pyfd_ctrl(arg1,arg2,arg3,arg4); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_new_pyfd(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - int val1 ; - int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - BIO *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_new_pyfd", 2, 2, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bio_new_pyfd" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_pyfd" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (BIO *)BIO_new_pyfd(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bn_rand(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - int arg3 ; - int val1 ; - int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bn_rand", 3, 3, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bn_rand" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bn_rand" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bn_rand" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - result = (PyObject *)bn_rand(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bn_rand_range(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (PyObject *)bn_rand_range(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_file_name__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - size_t arg2 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - size_t val2 ; - int ecode2 = 0 ; - char *result = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rand_file_name" "', argument " "1"" of type '" "char *""'"); - } - arg1 = (char *)(buf1); - ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_file_name" "', argument " "2"" of type '" "size_t""'"); - } - arg2 = (size_t)(val2); - result = (char *)RAND_file_name(arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_load_file(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - long arg2 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rand_load_file", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rand_load_file" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_load_file" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - result = (int)RAND_load_file((char const *)arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_save_file(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rand_save_file" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - result = (int)RAND_write_file((char const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_poll(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rand_poll", 0, 0, 0)) SWIG_fail; - result = (int)RAND_poll(); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_status(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rand_status", 0, 0, 0)) SWIG_fail; - result = (int)RAND_status(); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_cleanup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "rand_cleanup", 0, 0, 0)) SWIG_fail; - RAND_cleanup(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__rand_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_rand_err""' of type '""PyObject *""'"); - } - _rand_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__rand_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_rand_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_rand_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - rand_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_seed(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (PyObject *)rand_seed(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_add(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - double arg2 ; - double val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rand_add", 2, 2, swig_obj)) SWIG_fail; - { - arg1=swig_obj[0]; - } - ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_add" "', argument " "2"" of type '" "double""'"); - } - arg2 = (double)(val2); - result = (PyObject *)rand_add(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_bytes(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rand_bytes" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (PyObject *)rand_bytes(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_pseudo_bytes(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rand_pseudo_bytes" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (PyObject *)rand_pseudo_bytes(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_file_name__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { - PyObject *resultobj = 0; - PyObject *result = 0 ; - - if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; - result = (PyObject *)rand_file_name(); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_file_name(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[3] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "rand_file_name", 0, 2, argv))) SWIG_fail; - --argc; - if (argc == 0) { - return _wrap_rand_file_name__SWIG_1(self, argc, argv); - } - if (argc == 2) { - int _v; - int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_size_t(argv[1], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_rand_file_name__SWIG_0(self, argc, argv); - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'rand_file_name'.\n" - " Possible C/C++ prototypes are:\n" - " RAND_file_name(char *,size_t)\n" - " rand_file_name()\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_rand_screen(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "rand_screen", 0, 0, 0)) SWIG_fail; - rand_screen(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rand_win32_event(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - unsigned int arg1 ; - int arg2 ; - long arg3 ; - unsigned int val1 ; - int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; - long val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rand_win32_event", 3, 3, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_unsigned_SS_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rand_win32_event" "', argument " "1"" of type '" "unsigned int""'"); - } - arg1 = (unsigned int)(val1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_win32_event" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rand_win32_event" "', argument " "3"" of type '" "long""'"); - } - arg3 = (long)(val3); - result = (int)rand_win32_event(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_md5(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "md5", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_md5(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sha1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sha1", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_sha1(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ripemd160(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ripemd160", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_ripemd160(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sha224(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sha224", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_sha224(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sha256(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sha256", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_sha256(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sha384(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sha384", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_sha384(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sha512(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sha512", 0, 0, 0)) SWIG_fail; - result = (EVP_MD *)EVP_sha512(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_MD *arg2 = (EVP_MD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "digest_init", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_init" "', argument " "2"" of type '" "EVP_MD const *""'"); - } - arg2 = (EVP_MD *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_DigestInit(arg1,(EVP_MD const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ecb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede3_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede3_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede3(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede3_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede3_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede3_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede3_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede3_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede3_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_des_ede3_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "des_ede3_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_des_ede3_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bf_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bf_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_bf_ecb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bf_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bf_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_bf_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bf_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bf_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_bf_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bf_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bf_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_bf_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cast5_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cast5_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_cast5_ecb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cast5_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cast5_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_cast5_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cast5_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cast5_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_cast5_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cast5_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cast5_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_cast5_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc4(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rc4", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_rc4(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc2_40_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rc2_40_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_rc2_40_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_128_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_128_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_128_ecb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_128_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_128_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_128_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_128_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_128_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_128_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_128_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_128_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_128_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_128_ctr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_128_ctr", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_128_ctr(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_192_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_192_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_192_ecb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_192_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_192_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_192_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_192_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_192_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_192_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_192_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_192_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_192_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_192_ctr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_192_ctr", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_192_ctr(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_256_ecb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_256_ecb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_256_ecb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_256_cbc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_256_cbc", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_256_cbc(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_256_cfb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_256_cfb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_256_cfb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_256_ofb(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_256_ofb", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_256_ofb(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_256_ctr(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_256_ctr", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER *)EVP_aes_256_ctr(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cipher_set_padding(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "cipher_set_padding", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_set_padding" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); - } - arg1 = (EVP_CIPHER_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cipher_set_padding" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_CIPHER_CTX_set_padding(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_free" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - EVP_PKEY_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_assign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - int arg2 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkey_assign", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_assign" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pkey_assign" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkey_assign" "', argument " "3"" of type '" "char *""'"); - } - arg3 = (char *)(buf3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_PKEY_assign(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_assign_ec(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - EC_KEY *arg2 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkey_assign_ec", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_assign_ec" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_assign_ec" "', argument " "2"" of type '" "EC_KEY *""'"); - } - arg2 = (EC_KEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_PKEY_assign_EC_KEY(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_set1_rsa(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - RSA *arg2 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkey_set1_rsa", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_set1_rsa" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_set1_rsa" "', argument " "2"" of type '" "RSA *""'"); - } - arg2 = (RSA *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_PKEY_set1_RSA(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sign_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_MD *arg2 = (EVP_MD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sign_init", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sign_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sign_init" "', argument " "2"" of type '" "EVP_MD const *""'"); - } - arg2 = (EVP_MD *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_SignInit(arg1,(EVP_MD const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_verify_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_MD *arg2 = (EVP_MD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "verify_init", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "verify_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "verify_init" "', argument " "2"" of type '" "EVP_MD const *""'"); - } - arg2 = (EVP_MD *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_VerifyInit(arg1,(EVP_MD const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_sign_init__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_PKEY_CTX **arg2 = (EVP_PKEY_CTX **) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - ENGINE *arg4 = (ENGINE *) 0 ; - EVP_PKEY *arg5 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - int result; - - if ((nobjs < 5) || (nobjs > 5)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_EVP_PKEY_CTX, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_sign_init" "', argument " "2"" of type '" "EVP_PKEY_CTX **""'"); - } - arg2 = (EVP_PKEY_CTX **)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "digest_sign_init" "', argument " "3"" of type '" "EVP_MD const *""'"); - } - arg3 = (EVP_MD *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "digest_sign_init" "', argument " "4"" of type '" "ENGINE *""'"); - } - arg4 = (ENGINE *)(argp4); - res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "digest_sign_init" "', argument " "5"" of type '" "EVP_PKEY *""'"); - } - arg5 = (EVP_PKEY *)(argp5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg5) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_DigestSignInit(arg1,arg2,(EVP_MD const *)arg3,arg4,arg5); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_verify_init__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_PKEY_CTX **arg2 = (EVP_PKEY_CTX **) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - ENGINE *arg4 = (ENGINE *) 0 ; - EVP_PKEY *arg5 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - int result; - - if ((nobjs < 5) || (nobjs > 5)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_EVP_PKEY_CTX, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_verify_init" "', argument " "2"" of type '" "EVP_PKEY_CTX **""'"); - } - arg2 = (EVP_PKEY_CTX **)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "digest_verify_init" "', argument " "3"" of type '" "EVP_MD const *""'"); - } - arg3 = (EVP_MD *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "digest_verify_init" "', argument " "4"" of type '" "ENGINE *""'"); - } - arg4 = (ENGINE *)(argp4); - res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "digest_verify_init" "', argument " "5"" of type '" "EVP_PKEY *""'"); - } - arg5 = (EVP_PKEY *)(argp5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg5) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_DigestVerifyInit(arg1,arg2,(EVP_MD const *)arg3,arg4,arg5); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_size" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EVP_PKEY_size(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__evp_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_evp_err""' of type '""PyObject *""'"); - } - _evp_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__evp_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_evp_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_evp_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - evp_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_get1_rsa(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - RSA *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_get1_rsa" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (RSA *)pkey_get1_rsa(arg1); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_RSA, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs5_pbkdf2_hmac_sha1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - int arg4 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs5_pbkdf2_hmac_sha1", 4, 4, swig_obj)) SWIG_fail; - { - arg1=swig_obj[0]; - } - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pkcs5_pbkdf2_hmac_sha1" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs5_pbkdf2_hmac_sha1" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - result = (PyObject *)pkcs5_pbkdf2_hmac_sha1(arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_md_ctx_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "md_ctx_new", 0, 0, 0)) SWIG_fail; - result = (EVP_MD_CTX *)md_ctx_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_md_ctx_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "md_ctx_free" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - md_ctx_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "digest_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)digest_update(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)digest_final(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hmac_ctx_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - HMAC_CTX *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "hmac_ctx_new", 0, 0, 0)) SWIG_fail; - result = (HMAC_CTX *)hmac_ctx_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_HMAC_CTX, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hmac_ctx_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_ctx_free" "', argument " "1"" of type '" "HMAC_CTX *""'"); - } - arg1 = (HMAC_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - hmac_ctx_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hmac_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "hmac_init", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_init" "', argument " "1"" of type '" "HMAC_CTX *""'"); - } - arg1 = (HMAC_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "hmac_init" "', argument " "3"" of type '" "EVP_MD const *""'"); - } - arg3 = (EVP_MD *)(argp3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)hmac_init(arg1,arg2,(EVP_MD const *)arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hmac_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "hmac_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_update" "', argument " "1"" of type '" "HMAC_CTX *""'"); - } - arg1 = (HMAC_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)hmac_update(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hmac_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_final" "', argument " "1"" of type '" "HMAC_CTX *""'"); - } - arg1 = (HMAC_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)hmac_final(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_hmac(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "hmac", 3, 3, swig_obj)) SWIG_fail; - { - arg1=swig_obj[0]; - } - { - arg2=swig_obj[1]; - } - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "hmac" "', argument " "3"" of type '" "EVP_MD const *""'"); - } - arg3 = (EVP_MD *)(argp3); - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)hmac(arg1,arg2,(EVP_MD const *)arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cipher_ctx_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER_CTX *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cipher_ctx_new", 0, 0, 0)) SWIG_fail; - result = (EVP_CIPHER_CTX *)cipher_ctx_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cipher_ctx_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_ctx_free" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); - } - arg1 = (EVP_CIPHER_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - cipher_ctx_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bytes_to_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER *arg1 = (EVP_CIPHER *) 0 ; - EVP_MD *arg2 = (EVP_MD *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - PyObject *arg5 = (PyObject *) 0 ; - int arg6 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val6 ; - int ecode6 = 0 ; - PyObject *swig_obj[6] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bytes_to_key", 6, 6, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bytes_to_key" "', argument " "1"" of type '" "EVP_CIPHER const *""'"); - } - arg1 = (EVP_CIPHER *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bytes_to_key" "', argument " "2"" of type '" "EVP_MD *""'"); - } - arg2 = (EVP_MD *)(argp2); - { - arg3=swig_obj[2]; - } - { - arg4=swig_obj[3]; - } - { - arg5=swig_obj[4]; - } - ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "bytes_to_key" "', argument " "6"" of type '" "int""'"); - } - arg6 = (int)(val6); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)bytes_to_key((EVP_CIPHER const *)arg1,arg2,arg3,arg4,arg5,arg6); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cipher_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; - EVP_CIPHER *arg2 = (EVP_CIPHER *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cipher_init", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_init" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); - } - arg1 = (EVP_CIPHER_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "cipher_init" "', argument " "2"" of type '" "EVP_CIPHER const *""'"); - } - arg2 = (EVP_CIPHER *)(argp2); - { - arg3=swig_obj[2]; - } - { - arg4=swig_obj[3]; - } - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "cipher_init" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)cipher_init(arg1,(EVP_CIPHER const *)arg2,arg3,arg4,arg5); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cipher_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "cipher_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_update" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); - } - arg1 = (EVP_CIPHER_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)cipher_update(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_cipher_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_final" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); - } - arg1 = (EVP_CIPHER_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)cipher_final(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sign_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sign_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sign_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)sign_update(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sign_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sign_final", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sign_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sign_final" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)sign_final(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_verify_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "verify_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "verify_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)verify_update(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_verify_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - EVP_PKEY *arg3 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "verify_final", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "verify_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "verify_final" "', argument " "3"" of type '" "EVP_PKEY *""'"); - } - arg3 = (EVP_PKEY *)(argp3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)verify_final(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_sign_init__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int result; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_sign_init" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)digest_sign_init(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_sign_init(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[6] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "digest_sign_init", 0, 5, argv))) SWIG_fail; - --argc; - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_EVP_PKEY, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_digest_sign_init__SWIG_1(self, argc, argv); - } - } - } - if (argc == 5) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_p_EVP_PKEY_CTX, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_EVP_MD, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_ENGINE, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_EVP_PKEY, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_digest_sign_init__SWIG_0(self, argc, argv); - } - } - } - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'digest_sign_init'.\n" - " Possible C/C++ prototypes are:\n" - " EVP_DigestSignInit(EVP_MD_CTX *,EVP_PKEY_CTX **,EVP_MD const *,ENGINE *,EVP_PKEY *)\n" - " digest_sign_init(EVP_MD_CTX *,EVP_PKEY *)\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_digest_sign_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "digest_sign_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)digest_sign_update(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_sign_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)digest_sign_final(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_sign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "digest_sign", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)digest_sign(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_verify_init__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int result; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_verify_init" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)digest_verify_init(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_verify_init(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[6] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "digest_verify_init", 0, 5, argv))) SWIG_fail; - --argc; - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_EVP_PKEY, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_digest_verify_init__SWIG_1(self, argc, argv); - } - } - } - if (argc == 5) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_p_EVP_PKEY_CTX, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_EVP_MD, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_ENGINE, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_EVP_PKEY, 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_digest_verify_init__SWIG_0(self, argc, argv); - } - } - } - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'digest_verify_init'.\n" - " Possible C/C++ prototypes are:\n" - " EVP_DigestVerifyInit(EVP_MD_CTX *,EVP_PKEY_CTX **,EVP_MD const *,ENGINE *,EVP_PKEY *)\n" - " digest_verify_init(EVP_MD_CTX *,EVP_PKEY *)\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_digest_verify_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "digest_verify_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)digest_verify_update(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_verify_final(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "digest_verify_final", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)digest_verify_final(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_digest_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "digest_verify", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); - } - arg1 = (EVP_MD_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)digest_verify(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_get_digestbyname(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - EVP_MD *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_digestbyname" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - result = (EVP_MD *)get_digestbyname((char const *)arg1); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_MD, 0); - else { - resultobj = NULL; - } - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_write_pem_no_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - BIO *arg2 = (BIO *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkey_write_pem_no_cipher", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_write_pem_no_cipher" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_write_pem_no_cipher" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pkey_write_pem_no_cipher(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_write_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - BIO *arg2 = (BIO *) 0 ; - EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkey_write_pem", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_write_pem" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_write_pem" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkey_write_pem" "', argument " "3"" of type '" "EVP_CIPHER *""'"); - } - arg3 = (EVP_CIPHER *)(argp3); - { - if (!PyCallable_Check(swig_obj[3])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pkey_write_pem(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkey_new", 0, 0, 0)) SWIG_fail; - result = (EVP_PKEY *)pkey_new(); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_PKEY, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_read_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - EVP_PKEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkey_read_pem", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_read_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EVP_PKEY *)pkey_read_pem(arg1,arg2); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_PKEY, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_read_pem_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - EVP_PKEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkey_read_pem_pubkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_read_pem_pubkey" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EVP_PKEY *)pkey_read_pem_pubkey(arg1,arg2); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_PKEY, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_assign_rsa(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - RSA *arg2 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkey_assign_rsa", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_assign_rsa" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_assign_rsa" "', argument " "2"" of type '" "RSA *""'"); - } - arg2 = (RSA *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pkey_assign_rsa(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_as_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_as_der" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)pkey_as_der(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkey_get_modulus(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_get_modulus" "', argument " "1"" of type '" "EVP_PKEY *""'"); - } - arg1 = (EVP_PKEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)pkey_get_modulus(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_aes_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - AES_KEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "aes_new", 0, 0, 0)) SWIG_fail; - result = (AES_KEY *)aes_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_AES_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_AES_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - AES_KEY *arg1 = (AES_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_free" "', argument " "1"" of type '" "AES_KEY *""'"); - } - arg1 = (AES_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - AES_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_AES_set_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - AES_KEY *arg1 = (AES_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "AES_set_key", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_set_key" "', argument " "1"" of type '" "AES_KEY *""'"); - } - arg1 = (AES_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AES_set_key" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "AES_set_key" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)AES_set_key(arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_AES_crypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - AES_KEY *arg1 = (AES_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "AES_crypt", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_crypt" "', argument " "1"" of type '" "AES_KEY const *""'"); - } - arg1 = (AES_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AES_crypt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "AES_crypt" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)AES_crypt((AES_KEY const *)arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_AES_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - AES_KEY *arg1 = (AES_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_type_check" "', argument " "1"" of type '" "AES_KEY *""'"); - } - arg1 = (AES_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)AES_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc4_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RC4_KEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rc4_new", 0, 0, 0)) SWIG_fail; - result = (RC4_KEY *)rc4_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RC4_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc4_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RC4_KEY *arg1 = (RC4_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_free" "', argument " "1"" of type '" "RC4_KEY *""'"); - } - arg1 = (RC4_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - rc4_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc4_set_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RC4_KEY *arg1 = (RC4_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rc4_set_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_set_key" "', argument " "1"" of type '" "RC4_KEY *""'"); - } - arg1 = (RC4_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rc4_set_key(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc4_update(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RC4_KEY *arg1 = (RC4_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rc4_update", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_update" "', argument " "1"" of type '" "RC4_KEY *""'"); - } - arg1 = (RC4_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rc4_update(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rc4_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RC4_KEY *arg1 = (RC4_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_type_check" "', argument " "1"" of type '" "RC4_KEY *""'"); - } - arg1 = (RC4_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rc4_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dh_new", 0, 0, 0)) SWIG_fail; - result = (DH *)DH_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DH, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_free" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - DH_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_size" "', argument " "1"" of type '" "DH const *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)DH_size((DH const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_generate_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_generate_key" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)DH_generate_key(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dhparams_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - DH *arg2 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dhparams_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dhparams_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dhparams_print" "', argument " "2"" of type '" "DH const *""'"); - } - arg2 = (DH *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)DHparams_print(arg1,(DH const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__dh_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_dh_err""' of type '""PyObject *""'"); - } - _dh_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__dh_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_dh_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_dh_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - dh_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_type_check" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dh_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_read_parameters(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - DH *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_read_parameters" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (DH *)dh_read_parameters(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DH, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_generate_parameters(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int arg2 ; - PyObject *arg3 = (PyObject *) 0 ; - int val1 ; - int ecode1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[3] ; - DH *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dh_generate_parameters", 3, 3, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "dh_generate_parameters" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "dh_generate_parameters" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - result = (DH *)dh_generate_parameters(arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DH, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_check" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dh_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_compute_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dh_compute_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_compute_key" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dh_compute_key(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_get_p(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_p" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dh_get_p(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_get_g(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_g" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dh_get_g(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_get_pub(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_pub" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dh_get_pub(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_get_priv(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_priv" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dh_get_priv(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dh_set_pg(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DH *arg1 = (DH *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dh_set_pg", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_set_pg" "', argument " "1"" of type '" "DH *""'"); - } - arg1 = (DH *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dh_set_pg(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_size" "', argument " "1"" of type '" "RSA const *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)RSA_size((RSA const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_new", 0, 0, 0)) SWIG_fail; - result = (RSA *)RSA_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RSA, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_free" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - RSA_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_check_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_check_key" "', argument " "1"" of type '" "RSA const *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)RSA_check_key((RSA const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__rsa_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_rsa_err""' of type '""PyObject *""'"); - } - _rsa_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__rsa_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_rsa_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_rsa_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - rsa_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_read_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - RSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_read_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_read_key" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (RSA *)rsa_read_key(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RSA, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_write_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rsa_write_key", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_key" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_key" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rsa_write_key" "', argument " "3"" of type '" "EVP_CIPHER *""'"); - } - arg3 = (EVP_CIPHER *)(argp3); - { - if (!PyCallable_Check(swig_obj[3])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rsa_write_key(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_write_key_no_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rsa_write_key_no_cipher", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_key_no_cipher" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_key_no_cipher" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rsa_write_key_no_cipher(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_read_pub_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - RSA *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_read_pub_key" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (RSA *)rsa_read_pub_key(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RSA, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_write_pub_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rsa_write_pub_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_pub_key" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_pub_key" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)rsa_write_pub_key(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_get_e(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_get_e" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_get_e(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_get_n(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_get_n" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_get_n(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_set_e(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_set_e", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_e" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_set_e(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_set_n(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_set_n", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_n" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_set_n(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_set_en(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_set_en", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_en" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_set_en(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_PyObject_Bin_AsBIGNUM(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - BIGNUM *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (BIGNUM *)PyObject_Bin_AsBIGNUM(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_set_en_bin(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_set_en_bin", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_en_bin" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_set_en_bin(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_private_encrypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_private_encrypt", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_private_encrypt" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_private_encrypt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_private_encrypt(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_public_decrypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_public_decrypt", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_public_decrypt" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_public_decrypt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_public_decrypt(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_public_encrypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_public_encrypt", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_public_encrypt" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_public_encrypt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_public_encrypt(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_private_decrypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_private_decrypt", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_private_decrypt" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_private_decrypt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_private_decrypt(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_padding_add_pkcs1_pss(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_padding_add_pkcs1_pss", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_padding_add_pkcs1_pss" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rsa_padding_add_pkcs1_pss" "', argument " "3"" of type '" "EVP_MD *""'"); - } - arg3 = (EVP_MD *)(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "rsa_padding_add_pkcs1_pss" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_padding_add_pkcs1_pss(arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_verify_pkcs1_pss(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - EVP_MD *arg4 = (EVP_MD *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rsa_verify_pkcs1_pss", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_verify_pkcs1_pss" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "rsa_verify_pkcs1_pss" "', argument " "4"" of type '" "EVP_MD *""'"); - } - arg4 = (EVP_MD *)(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "rsa_verify_pkcs1_pss" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rsa_verify_pkcs1_pss(arg1,arg2,arg3,arg4,arg5); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_sign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_sign", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_sign" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_sign" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_sign(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rsa_verify", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_verify" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "rsa_verify" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rsa_verify(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_generate_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - unsigned long arg2 ; - PyObject *arg3 = (PyObject *) 0 ; - int val1 ; - int ecode1 = 0 ; - unsigned long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "rsa_generate_key", 3, 3, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rsa_generate_key" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - ecode2 = SWIG_AsVal_unsigned_SS_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rsa_generate_key" "', argument " "2"" of type '" "unsigned long""'"); - } - arg2 = (unsigned long)(val2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)rsa_generate_key(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_type_check" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rsa_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_check_pub_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_check_pub_key" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)rsa_check_pub_key(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_rsa_write_key_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - RSA *arg1 = (RSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "rsa_write_key_der", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_key_der" "', argument " "1"" of type '" "RSA *""'"); - } - arg1 = (RSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_key_der" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)rsa_write_key_der(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_new", 0, 0, 0)) SWIG_fail; - result = (DSA *)DSA_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DSA, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_free" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - DSA_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_size" "', argument " "1"" of type '" "DSA const *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)DSA_size((DSA const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_gen_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_gen_key" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)DSA_generate_key(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__dsa_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_dsa_err""' of type '""PyObject *""'"); - } - _dsa_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__dsa_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_dsa_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_dsa_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - dsa_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_generate_parameters(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - PyObject *arg2 = (PyObject *) 0 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[2] ; - DSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_generate_parameters", 2, 2, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "dsa_generate_parameters" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (DSA *)dsa_generate_parameters(arg1,arg2); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_read_params(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - DSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_read_params", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_read_params" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (DSA *)dsa_read_params(arg1,arg2); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_read_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - DSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_read_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_read_key" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (DSA *)dsa_read_key(arg1,arg2); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_read_pub_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - DSA *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_read_pub_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_read_pub_key" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (DSA *)dsa_read_pub_key(arg1,arg2); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_get_p(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_p" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_get_p(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_get_q(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_q" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_get_q(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_get_g(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_g" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_get_g(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_get_pub(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_pub" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_get_pub(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_get_priv(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_priv" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_get_priv(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_set_pqg(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_set_pqg", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_set_pqg" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_set_pqg(arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_set_pub(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_set_pub", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_set_pub" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_set_pub(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_write_params_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dsa_write_params_bio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_params_bio" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_params_bio" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)dsa_write_params_bio(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_write_key_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dsa_write_key_bio", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_key_bio" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_key_bio" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "dsa_write_key_bio" "', argument " "3"" of type '" "EVP_CIPHER *""'"); - } - arg3 = (EVP_CIPHER *)(argp3); - { - if (!PyCallable_Check(swig_obj[3])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_write_key_bio(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_write_key_bio_no_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dsa_write_key_bio_no_cipher", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_key_bio_no_cipher" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_key_bio_no_cipher" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_write_key_bio_no_cipher(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_write_pub_key_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dsa_write_pub_key_bio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_pub_key_bio" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_pub_key_bio" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)dsa_write_pub_key_bio(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_sign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_sign", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_sign" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_sign(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dsa_verify", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_verify" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_verify(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_sign_asn1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "dsa_sign_asn1", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_sign_asn1" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)dsa_sign_asn1(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_verify_asn1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "dsa_verify_asn1", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_verify_asn1" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_verify_asn1(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_check_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_check_key" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_check_key(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_check_pub_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_check_pub_key" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_check_pub_key(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_keylen(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_keylen" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_keylen(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_dsa_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - DSA *arg1 = (DSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_type_check" "', argument " "1"" of type '" "DSA *""'"); - } - arg1 = (DSA *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)dsa_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_ciphers(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - struct stack_st_SSL_CIPHER *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_ciphers" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (struct stack_st_SSL_CIPHER *)SSL_get_ciphers((SSL const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_SSL_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_version(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_version" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)SSL_get_version((SSL const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_error(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_get_error", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_error" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_get_error" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_get_error((SSL const *)arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_state(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_state" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)SSL_state_string((SSL const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_state_v(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_state_v" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)SSL_state_string_long((SSL const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_alert_type(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_type" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (char *)SSL_alert_type_string(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_alert_type_v(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_type_v" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (char *)SSL_alert_type_string_long(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_alert_desc(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_desc" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (char *)SSL_alert_desc_string(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_alert_desc_v(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_desc_v" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (char *)SSL_alert_desc_string_long(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sslv23_method(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sslv23_method", 0, 0, 0)) SWIG_fail; - result = (SSL_METHOD *)SSLv23_method(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_METHOD *arg1 = (SSL_METHOD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL_CTX *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_METHOD, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_new" "', argument " "1"" of type '" "SSL_METHOD *""'"); - } - arg1 = (SSL_METHOD *)(argp1); - result = (SSL_CTX *)SSL_CTX_new(arg1); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_SSL_CTX, 0); - else { - m2_PyErr_Msg(_ssl_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_free" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - SSL_CTX_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_verify_depth(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_verify_depth", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_verify_depth" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_verify_depth" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - SSL_CTX_set_verify_depth(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_get_verify_depth(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_verify_depth" "', argument " "1"" of type '" "SSL_CTX const *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_CTX_get_verify_depth((SSL_CTX const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_get_verify_mode(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_verify_mode" "', argument " "1"" of type '" "SSL_CTX const *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_CTX_get_verify_mode((SSL_CTX const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_cipher_list(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_cipher_list", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_cipher_list" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_cipher_list" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_CTX_set_cipher_list(arg1,(char const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_add_session(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_add_session", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_add_session" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_add_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); - } - arg2 = (SSL_SESSION *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_CTX_add_session(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_remove_session(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_remove_session", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_remove_session" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_remove_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); - } - arg2 = (SSL_SESSION *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_CTX_remove_session(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_session_timeout(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_session_timeout", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_session_timeout" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_session_timeout" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)SSL_CTX_set_timeout(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_get_session_timeout(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_session_timeout" "', argument " "1"" of type '" "SSL_CTX const *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)SSL_CTX_get_timeout((SSL_CTX const *)arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_get_cert_store(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_STORE *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_cert_store" "', argument " "1"" of type '" "SSL_CTX const *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_STORE *)SSL_CTX_get_cert_store((SSL_CTX const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_STORE, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_default_verify_paths(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_default_verify_paths" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_CTX_set_default_verify_paths(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_ex_data_x509_store_ctx_idx(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_get_ex_data_x509_store_ctx_idx", 0, 0, 0)) SWIG_fail; - result = (int)SSL_get_ex_data_X509_STORE_CTX_idx(); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_new_ssl(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - BIO *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "bio_new_ssl", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_new_ssl" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_ssl" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (BIO *)BIO_new_ssl(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_new" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL *)SSL_new(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_free" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - SSL_free(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_dup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_dup" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL *)SSL_dup(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - BIO *arg2 = (BIO *) 0 ; - BIO *arg3 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_bio", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_bio" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_bio" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ssl_set_bio" "', argument " "3"" of type '" "BIO *""'"); - } - arg3 = (BIO *)(argp3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - SSL_set_bio(arg1,arg2,arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_accept_state(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_accept_state" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - SSL_set_accept_state(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_connect_state(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_connect_state" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - SSL_set_connect_state(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_shutdown(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_shutdown" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_get_shutdown((SSL const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_shutdown(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_shutdown", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_shutdown" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_shutdown" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - SSL_set_shutdown(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_shutdown(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_shutdown" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)SSL_shutdown(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_clear(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_clear" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_clear(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_do_handshake(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_do_handshake" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)SSL_do_handshake(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_renegotiate(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_renegotiate" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)SSL_renegotiate(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_pending(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_pending" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_pending((SSL const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_peer_cert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_peer_cert" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509 *)SSL_get_peer_certificate((SSL const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_current_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL_CIPHER *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_current_cipher" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL_CIPHER *)SSL_get_current_cipher((SSL const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_verify_mode(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_verify_mode" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_get_verify_mode((SSL const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_verify_depth(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_verify_depth" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_get_verify_depth((SSL const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_verify_result(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_verify_result" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)SSL_get_verify_result((SSL const *)arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_ssl_ctx(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL_CTX *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_ssl_ctx" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL_CTX *)SSL_get_SSL_CTX((SSL const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_CTX, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_default_session_timeout(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_default_session_timeout" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)SSL_get_default_timeout((SSL const *)arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_cipher_list(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_cipher_list", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_cipher_list" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_cipher_list" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_set_cipher_list(arg1,(char const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_cipher_list(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_get_cipher_list", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_cipher_list" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_get_cipher_list" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)SSL_get_cipher_list((SSL const *)arg1,arg2); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_cipher_get_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CIPHER *arg1 = (SSL_CIPHER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_cipher_get_name" "', argument " "1"" of type '" "SSL_CIPHER const *""'"); - } - arg1 = (SSL_CIPHER *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)SSL_CIPHER_get_name((SSL_CIPHER const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_cipher_get_version(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CIPHER *arg1 = (SSL_CIPHER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_cipher_get_version" "', argument " "1"" of type '" "SSL_CIPHER const *""'"); - } - arg1 = (SSL_CIPHER *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)SSL_CIPHER_get_version((SSL_CIPHER const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_session(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL_SESSION *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_session" "', argument " "1"" of type '" "SSL const *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL_SESSION *)SSL_get_session((SSL const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get1_session(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL_SESSION *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get1_session" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL_SESSION *)SSL_get1_session(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_session(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_session", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_session" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); - } - arg2 = (SSL_SESSION *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)SSL_set_session(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_session_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_free" "', argument " "1"" of type '" "SSL_SESSION *""'"); - } - arg1 = (SSL_SESSION *)(argp1); - SSL_SESSION_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_session_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_session_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_session_print" "', argument " "2"" of type '" "SSL_SESSION const *""'"); - } - arg2 = (SSL_SESSION *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)SSL_SESSION_print(arg1,(SSL_SESSION const *)arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_session_set_timeout(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_session_set_timeout", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_set_timeout" "', argument " "1"" of type '" "SSL_SESSION *""'"); - } - arg1 = (SSL_SESSION *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_session_set_timeout" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - result = (long)SSL_SESSION_set_timeout(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_session_get_timeout(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_get_timeout" "', argument " "1"" of type '" "SSL_SESSION const *""'"); - } - arg1 = (SSL_SESSION *)(argp1); - result = (long)SSL_SESSION_get_timeout((SSL_SESSION const *)arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_accept(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - double arg2 = (double) -1 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_accept", 1, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_accept" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - if (swig_obj[1]) { - ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_accept" "', argument " "2"" of type '" "double""'"); - } - arg2 = (double)(val2); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ssl_accept(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_connect(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - double arg2 = (double) -1 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_connect", 1, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_connect" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - if (swig_obj[1]) { - ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_connect" "', argument " "2"" of type '" "double""'"); - } - arg2 = (double)(val2); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ssl_connect(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_read(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - double arg3 = (double) -1 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - double val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_read", 2, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_read" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_read" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - if (swig_obj[2]) { - ecode3 = SWIG_AsVal_double(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ssl_read" "', argument " "3"" of type '" "double""'"); - } - arg3 = (double)(val3); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ssl_read(arg1,arg2,arg3); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_write(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - double arg3 = (double) -1 ; - void *argp1 = 0 ; - int res1 = 0 ; - double val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_write", 2, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_write" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - arg2=swig_obj[1]; - } - if (swig_obj[2]) { - ecode3 = SWIG_AsVal_double(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ssl_write" "', argument " "3"" of type '" "double""'"); - } - arg3 = (double)(val3); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_write(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__ssl_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_ssl_err""' of type '""PyObject *""'"); - } - _ssl_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__ssl_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_ssl_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN int Swig_var__ssl_timeout_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_ssl_timeout_err""' of type '""PyObject *""'"); - } - _ssl_timeout_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__ssl_timeout_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_ssl_timeout_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_ssl_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_init", 2, 2, swig_obj)) SWIG_fail; - { - arg1=swig_obj[0]; - } - { - arg2=swig_obj[1]; - } - ssl_init(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_tlsv1_method(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "tlsv1_method", 0, 0, 0)) SWIG_fail; - result = (SSL_METHOD *)tlsv1_method(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_passphrase_callback(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_passphrase_callback", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_passphrase_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_passphrase_callback(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_use_x509(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_x509", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_x509" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_x509" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_use_x509(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_use_cert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_cert", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_cert" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_cert" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_use_cert(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_use_cert_chain(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_cert_chain", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_cert_chain" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_cert_chain" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_use_cert_chain(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_use_privkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_privkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_privkey" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_use_privkey(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_use_rsa_privkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - RSA *arg2 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_rsa_privkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_rsa_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_rsa_privkey" "', argument " "2"" of type '" "RSA *""'"); - } - arg2 = (RSA *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_use_rsa_privkey(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_use_pkey_privkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_pkey_privkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_pkey_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_pkey_privkey" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_use_pkey_privkey(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_check_privkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_check_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_check_privkey(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_client_CA_list_from_file(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_client_CA_list_from_file", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_client_CA_list_from_file" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_client_CA_list_from_file" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_set_client_CA_list_from_file(arg1,(char const *)arg2); - resultobj = SWIG_Py_Void(); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_verify_default(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_verify_default", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_verify_default" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_verify_default" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_set_verify_default(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - int arg2 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[3] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_verify", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_verify" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_verify" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_set_verify(arg1,arg2,arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_session_id_context(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_session_id_context", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_session_id_context" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_set_session_id_context(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_info_callback(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_info_callback", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_info_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_set_info_callback(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_dh(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - DH *arg2 = (DH *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_dh", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_dh" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_DH, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_tmp_dh" "', argument " "2"" of type '" "DH *""'"); - } - arg2 = (DH *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)ssl_ctx_set_tmp_dh(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_dh_callback(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_dh_callback", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_dh_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_set_tmp_dh_callback(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_rsa(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - RSA *arg2 = (RSA *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_rsa", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_rsa" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_tmp_rsa" "', argument " "2"" of type '" "RSA *""'"); - } - arg2 = (RSA *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)ssl_ctx_set_tmp_rsa(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_rsa_callback(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_rsa_callback", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_rsa_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_ctx_set_tmp_rsa_callback(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_load_verify_locations(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_load_verify_locations", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_load_verify_locations" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_load_verify_locations" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ssl_ctx_load_verify_locations" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = (char *)(buf3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_load_verify_locations(arg1,(char const *)arg2,(char const *)arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_options(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_options", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_options" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_options" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)ssl_ctx_set_options(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_bio_set_ssl(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - SSL *arg2 = (SSL *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "bio_set_ssl", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_ssl" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_set_ssl" "', argument " "2"" of type '" "SSL *""'"); - } - arg2 = (SSL *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bio_set_ssl" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)bio_set_ssl(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_mode(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_mode", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_mode" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_mode" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)ssl_set_mode(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_mode(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_mode" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)ssl_get_mode(arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_tlsext_host_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_tlsext_host_name", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_tlsext_host_name" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_tlsext_host_name" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_set_tlsext_host_name(arg1,(char const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_client_CA_list_from_file(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_client_CA_list_from_file", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_client_CA_list_from_file" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_client_CA_list_from_file" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_set_client_CA_list_from_file(arg1,(char const *)arg2); - resultobj = SWIG_Py_Void(); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_client_CA_list_from_context(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - SSL_CTX *arg2 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_client_CA_list_from_context", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_client_CA_list_from_context" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_client_CA_list_from_context" "', argument " "2"" of type '" "SSL_CTX *""'"); - } - arg2 = (SSL_CTX *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_set_client_CA_list_from_context(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_session_id_context(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_session_id_context", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_session_id_context" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_set_session_id_context(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_fd(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_fd", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_fd" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_fd" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_set_fd(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_set_shutdown1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_set_shutdown1", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_shutdown1" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_shutdown1" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ssl_set_shutdown1(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_read_nbio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ssl_read_nbio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_read_nbio" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_read_nbio" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ssl_read_nbio(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_write_nbio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_write_nbio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_write_nbio" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_write_nbio(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_cipher_get_bits(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CIPHER *arg1 = (SSL_CIPHER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_cipher_get_bits" "', argument " "1"" of type '" "SSL_CIPHER *""'"); - } - arg1 = (SSL_CIPHER *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_cipher_get_bits(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_ssl_cipher_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_SSL_CIPHER *arg1 = (struct stack_st_SSL_CIPHER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_SSL_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_ssl_cipher_num" "', argument " "1"" of type '" "struct stack_st_SSL_CIPHER *""'"); - } - arg1 = (struct stack_st_SSL_CIPHER *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)sk_ssl_cipher_num(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_ssl_cipher_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_SSL_CIPHER *arg1 = (struct stack_st_SSL_CIPHER *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - SSL_CIPHER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_ssl_cipher_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_SSL_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_ssl_cipher_value" "', argument " "1"" of type '" "struct stack_st_SSL_CIPHER *""'"); - } - arg1 = (struct stack_st_SSL_CIPHER *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_ssl_cipher_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (SSL_CIPHER *)sk_ssl_cipher_value(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_get_peer_cert_chain(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - struct stack_st_X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_peer_cert_chain" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (struct stack_st_X509 *)ssl_get_peer_cert_chain(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_num" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)sk_x509_num(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - X509 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_x509_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_value" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_x509_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509 *)sk_x509_value(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_i2d_ssl_session(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "i2d_ssl_session", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_ssl_session" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_ssl_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); - } - arg2 = (SSL_SESSION *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - i2d_ssl_session(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_session_read_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - SSL_SESSION *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_read_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (SSL_SESSION *)ssl_session_read_pem(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_SSL_SESSION, 0); - else { - m2_PyErr_Msg(_ssl_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_session_write_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_session_write_pem", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_write_pem" "', argument " "1"" of type '" "SSL_SESSION *""'"); - } - arg1 = (SSL_SESSION *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_session_write_pem" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)ssl_session_write_pem(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_session_cache_mode(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_session_cache_mode", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_session_cache_mode" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_session_cache_mode" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_set_session_cache_mode(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_get_session_cache_mode(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_session_cache_mode" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_ctx_get_session_cache_mode(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_ctx_set_cache_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL_CTX *arg1 = (SSL_CTX *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - long result; - - if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_cache_size", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_cache_size" "', argument " "1"" of type '" "SSL_CTX *""'"); - } - arg1 = (SSL_CTX *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_cache_size" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)ssl_ctx_set_cache_size(arg1,arg2); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ssl_is_init_finished(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - SSL *arg1 = (SSL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_is_init_finished" "', argument " "1"" of type '" "SSL *""'"); - } - arg1 = (SSL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ssl_is_init_finished(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_check_ca(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_check_ca" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_check_ca(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_new", 0, 0, 0)) SWIG_fail; - result = (X509 *)X509_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_dup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_dup" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509 *)X509_dup(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_free" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - X509_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_crl_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_CRL *arg1 = (X509_CRL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_CRL, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_crl_free" "', argument " "1"" of type '" "X509_CRL *""'"); - } - arg1 = (X509_CRL *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - X509_CRL_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_crl_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_CRL *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_crl_new", 0, 0, 0)) SWIG_fail; - result = (X509_CRL *)X509_CRL_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_CRL, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_print" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)X509_print(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_crl_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_CRL *arg2 = (X509_CRL *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_crl_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_crl_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_CRL, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_crl_print" "', argument " "2"" of type '" "X509_CRL *""'"); - } - arg2 = (X509_CRL *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)X509_CRL_print(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_serial_number(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - ASN1_INTEGER *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_serial_number" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_INTEGER *)X509_get_serialNumber(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_serial_number(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - ASN1_INTEGER *arg2 = (ASN1_INTEGER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_serial_number", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_serial_number" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_serial_number" "', argument " "2"" of type '" "ASN1_INTEGER *""'"); - } - arg2 = (ASN1_INTEGER *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_set_serialNumber(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - EVP_PKEY *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_pubkey" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EVP_PKEY *)X509_get_pubkey(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_pubkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_pubkey" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_pubkey" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_set_pubkey(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_issuer_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_NAME *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_issuer_name" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_NAME *)X509_get_issuer_name(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_issuer_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - X509_NAME *arg2 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_issuer_name", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_issuer_name" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_issuer_name" "', argument " "2"" of type '" "X509_NAME *""'"); - } - arg2 = (X509_NAME *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_set_issuer_name(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_subject_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_NAME *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_subject_name" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_NAME *)X509_get_subject_name(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_subject_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - X509_NAME *arg2 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_subject_name", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_subject_name" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_subject_name" "', argument " "2"" of type '" "X509_NAME *""'"); - } - arg2 = (X509_NAME *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_set_subject_name(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_cmp_current_time(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_cmp_current_time" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - result = (int)X509_cmp_current_time(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_check_purpose(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_check_purpose", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_check_purpose" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_check_purpose" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_check_purpose" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_check_purpose(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_check_trust(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_check_trust", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_check_trust" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_check_trust" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_check_trust" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_check_trust(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_write_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_write_pem", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_write_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_write_pem" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)PEM_write_bio_X509(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_write_pem_file(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - FILE *arg1 = (FILE *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_write_pem_file", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_FILE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_write_pem_file" "', argument " "1"" of type '" "FILE *""'"); - } - arg1 = (FILE *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_write_pem_file" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)PEM_write_X509(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_verify", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_verify" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_verify" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_verify(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_verify_error(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - long arg1 ; - long val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_long(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "x509_get_verify_error" "', argument " "1"" of type '" "long""'"); - } - arg1 = (long)(val1); - result = (char *)X509_verify_cert_error_string(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_add_ext(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - X509_EXTENSION *arg2 = (X509_EXTENSION *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_add_ext", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_add_ext" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_add_ext" "', argument " "2"" of type '" "X509_EXTENSION *""'"); - } - arg2 = (X509_EXTENSION *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_add_ext" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_add_ext(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_ext_count(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_ext_count" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_get_ext_count(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_ext(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - X509_EXTENSION *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_get_ext", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_ext" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_get_ext" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_EXTENSION *)X509_get_ext(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_ext_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_EXTENSION *arg2 = (X509_EXTENSION *) 0 ; - unsigned long arg3 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - unsigned long val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_ext_print", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_ext_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_ext_print" "', argument " "2"" of type '" "X509_EXTENSION *""'"); - } - arg2 = (X509_EXTENSION *)(argp2); - ecode3 = SWIG_AsVal_unsigned_SS_long(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_ext_print" "', argument " "3"" of type '" "unsigned long""'"); - } - arg3 = (unsigned long)(val3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "x509_ext_print" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)X509V3_EXT_print(arg1,arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_new", 0, 0, 0)) SWIG_fail; - result = (X509_NAME *)X509_NAME_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_free" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - X509_NAME_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_NAME *arg2 = (X509_NAME *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_print", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_print" "', argument " "2"" of type '" "X509_NAME *""'"); - } - arg2 = (X509_NAME *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_print" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)X509_NAME_print(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_get_entry(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - X509_NAME_ENTRY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_get_entry", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_get_entry" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_get_entry" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_NAME_ENTRY *)X509_NAME_get_entry(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_count(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_count" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_entry_count(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_delete_entry(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - X509_NAME_ENTRY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_delete_entry", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_delete_entry" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_delete_entry" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_NAME_ENTRY *)X509_NAME_delete_entry(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_add_entry(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - X509_NAME_ENTRY *arg2 = (X509_NAME_ENTRY *) 0 ; - int arg3 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_add_entry" "', argument " "2"" of type '" "X509_NAME_ENTRY *""'"); - } - arg2 = (X509_NAME_ENTRY *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "x509_name_add_entry" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_add_entry(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_add_entry_by_obj(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - ASN1_OBJECT *arg2 = (ASN1_OBJECT *) 0 ; - int arg3 ; - unsigned char *arg4 = (unsigned char *) 0 ; - int arg5 ; - int arg6 ; - int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - int val6 ; - int ecode6 = 0 ; - int val7 ; - int ecode7 = 0 ; - PyObject *swig_obj[7] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry_by_obj", 7, 7, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry_by_obj" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_add_entry_by_obj" "', argument " "2"" of type '" "ASN1_OBJECT *""'"); - } - arg2 = (ASN1_OBJECT *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry_by_obj" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_add_entry_by_obj" "', argument " "4"" of type '" "unsigned char *""'"); - } - arg4 = (unsigned char *)(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_add_entry_by_obj" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "x509_name_add_entry_by_obj" "', argument " "6"" of type '" "int""'"); - } - arg6 = (int)(val6); - ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "x509_name_add_entry_by_obj" "', argument " "7"" of type '" "int""'"); - } - arg7 = (int)(val7); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_add_entry_by_OBJ(arg1,arg2,arg3,arg4,arg5,arg6,arg7); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_add_entry_by_nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - int arg2 ; - int arg3 ; - unsigned char *arg4 = (unsigned char *) 0 ; - int arg5 ; - int arg6 ; - int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - int val6 ; - int ecode6 = 0 ; - int val7 ; - int ecode7 = 0 ; - PyObject *swig_obj[7] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry_by_nid", 7, 7, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_add_entry_by_nid" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry_by_nid" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_add_entry_by_nid" "', argument " "4"" of type '" "unsigned char *""'"); - } - arg4 = (unsigned char *)(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_add_entry_by_nid" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "x509_name_add_entry_by_nid" "', argument " "6"" of type '" "int""'"); - } - arg6 = (int)(val6); - ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "x509_name_add_entry_by_nid" "', argument " "7"" of type '" "int""'"); - } - arg7 = (int)(val7); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_add_entry_by_NID(arg1,arg2,arg3,arg4,arg5,arg6,arg7); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_print_ex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_NAME *arg2 = (X509_NAME *) 0 ; - int arg3 ; - unsigned long arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - unsigned long val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_print_ex", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_print_ex" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_print_ex" "', argument " "2"" of type '" "X509_NAME *""'"); - } - arg2 = (X509_NAME *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_print_ex" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - ecode4 = SWIG_AsVal_unsigned_SS_long(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "x509_name_print_ex" "', argument " "4"" of type '" "unsigned long""'"); - } - arg4 = (unsigned long)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)X509_NAME_print_ex(arg1,arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_hash(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - unsigned long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_hash" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (unsigned long)X509_NAME_hash_old(arg1); - resultobj = SWIG_From_unsigned_SS_long((unsigned long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_get_index_by_nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - int arg2 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_get_index_by_nid", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_get_index_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_get_index_by_nid" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_get_index_by_nid" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_get_index_by_NID(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_new", 0, 0, 0)) SWIG_fail; - result = (X509_NAME_ENTRY *)X509_NAME_ENTRY_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_free" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); - } - arg1 = (X509_NAME_ENTRY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - X509_NAME_ENTRY_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_create_by_nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY **arg1 = (X509_NAME_ENTRY **) 0 ; - int arg2 ; - int arg3 ; - unsigned char *arg4 = (unsigned char *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - X509_NAME_ENTRY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_create_by_nid", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_create_by_nid" "', argument " "1"" of type '" "X509_NAME_ENTRY **""'"); - } - arg1 = (X509_NAME_ENTRY **)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_entry_create_by_nid" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_entry_create_by_nid" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_entry_create_by_nid" "', argument " "4"" of type '" "unsigned char *""'"); - } - arg4 = (unsigned char *)(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_entry_create_by_nid" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - result = (X509_NAME_ENTRY *)X509_NAME_ENTRY_create_by_NID(arg1,arg2,arg3,arg4,arg5); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_set_object(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; - ASN1_OBJECT *arg2 = (ASN1_OBJECT *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_set_object", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_set_object" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); - } - arg1 = (X509_NAME_ENTRY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_entry_set_object" "', argument " "2"" of type '" "ASN1_OBJECT *""'"); - } - arg2 = (ASN1_OBJECT *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_ENTRY_set_object(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_get_object(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - ASN1_OBJECT *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_get_object" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); - } - arg1 = (X509_NAME_ENTRY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_OBJECT *)X509_NAME_ENTRY_get_object(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_get_data(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - ASN1_STRING *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_get_data" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); - } - arg1 = (X509_NAME_ENTRY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_STRING *)X509_NAME_ENTRY_get_data(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_set_data(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; - int arg2 ; - unsigned char *arg3 = (unsigned char *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_set_data", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_set_data" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); - } - arg1 = (X509_NAME_ENTRY *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_entry_set_data" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (PyString_Check(swig_obj[2])) { - Py_ssize_t len; - - arg3 = (unsigned char *)PyString_AsString(swig_obj[2]); - len = PyString_Size(swig_obj[2]); - - - if (len > INT_MAX) { - PyErr_SetString(_x509_err, "object too large"); - return NULL; - } - arg4 = len; - } else { - PyErr_SetString(PyExc_TypeError, "expected string"); - return NULL; - } - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_NAME_ENTRY_set_data(arg1,arg2,(unsigned char const *)arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_new", 0, 0, 0)) SWIG_fail; - result = (X509_REQ *)X509_REQ_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_REQ, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_free" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - X509_REQ_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_REQ *arg2 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_print" "', argument " "2"" of type '" "X509_REQ *""'"); - } - arg2 = (X509_REQ *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)X509_REQ_print(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_get_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - EVP_PKEY *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_get_pubkey" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EVP_PKEY *)X509_REQ_get_pubkey(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_set_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_set_pubkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_set_pubkey" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_set_pubkey" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_REQ_set_pubkey(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_set_subject_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - X509_NAME *arg2 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_set_subject_name", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_set_subject_name" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_set_subject_name" "', argument " "2"" of type '" "X509_NAME *""'"); - } - arg2 = (X509_NAME *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_REQ_set_subject_name(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_verify", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_verify" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_verify" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_REQ_verify(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_sign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_sign", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_sign" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_sign" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "x509_req_sign" "', argument " "3"" of type '" "EVP_MD const *""'"); - } - arg3 = (EVP_MD *)(argp3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_REQ_sign(arg1,arg2,(EVP_MD const *)arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_i2d_x509_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "i2d_x509_bio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_x509_bio" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_x509_bio" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)i2d_X509_bio(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_i2d_x509_req_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_REQ *arg2 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "i2d_x509_req_bio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_x509_req_bio" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_x509_req_bio" "', argument " "2"" of type '" "X509_REQ *""'"); - } - arg2 = (X509_REQ *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)i2d_X509_REQ_bio(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_store_new", 0, 0, 0)) SWIG_fail; - result = (X509_STORE *)X509_STORE_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_STORE, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE *arg1 = (X509_STORE *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_free" "', argument " "1"" of type '" "X509_STORE *""'"); - } - arg1 = (X509_STORE *)(argp1); - X509_STORE_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_add_cert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE *arg1 = (X509_STORE *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_store_add_cert", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_add_cert" "', argument " "1"" of type '" "X509_STORE *""'"); - } - arg1 = (X509_STORE *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_store_add_cert" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)X509_STORE_add_cert(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_set_verify_cb__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - X509_STORE *arg1 = (X509_STORE *) 0 ; - int (*arg2)(int,X509_STORE_CTX *) = (int (*)(int,X509_STORE_CTX *)) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_set_verify_cb" "', argument " "1"" of type '" "X509_STORE *""'"); - } - arg1 = (X509_STORE *)(argp1); - { - int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_int_p_X509_STORE_CTX__int); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in method '" "x509_store_set_verify_cb" "', argument " "2"" of type '" "int (*)(int,X509_STORE_CTX *)""'"); - } - } - X509_STORE_set_verify_cb(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_get_current_cert(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_current_cert" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - result = (X509 *)X509_STORE_CTX_get_current_cert(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_get_error(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_error" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - result = (int)X509_STORE_CTX_get_error(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_get_error_depth(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_error_depth" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - result = (int)X509_STORE_CTX_get_error_depth(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_free" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - X509_STORE_CTX_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_get1_chain(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - struct stack_st_X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get1_chain" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - result = (struct stack_st_X509 *)X509_STORE_CTX_get1_chain(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_extension_get_critical(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_get_critical" "', argument " "1"" of type '" "X509_EXTENSION *""'"); - } - arg1 = (X509_EXTENSION *)(argp1); - result = (int)X509_EXTENSION_get_critical(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_extension_set_critical(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_extension_set_critical", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_set_critical" "', argument " "1"" of type '" "X509_EXTENSION *""'"); - } - arg1 = (X509_EXTENSION *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_extension_set_critical" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (int)X509_EXTENSION_set_critical(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_set_flags(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE *arg1 = (X509_STORE *) 0 ; - unsigned long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_store_set_flags", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_set_flags" "', argument " "1"" of type '" "X509_STORE *""'"); - } - arg1 = (X509_STORE *)(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_store_set_flags" "', argument " "2"" of type '" "unsigned long""'"); - } - arg2 = (unsigned long)(val2); - result = (int)X509_STORE_set_flags(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_read_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_read_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (X509 *)x509_read_pem(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509, 0); - else { - m2_PyErr_Msg(_x509_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_d2i_x509(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "d2i_x509" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (X509 *)d2i_x509(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509, 0); - else { - m2_PyErr_Msg(_x509_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__x509_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_x509_err""' of type '""PyObject *""'"); - } - _x509_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__x509_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_x509_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_x509_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - x509_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_d2i_x509_req(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_REQ *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "d2i_x509_req" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (X509_REQ *)d2i_x509_req(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_REQ, 0); - else { - m2_PyErr_Msg(_x509_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_read_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_REQ *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_read_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (X509_REQ *)x509_req_read_pem(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_REQ, 0); - else { - m2_PyErr_Msg(_x509_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_i2d_x509(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_x509" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)i2d_x509(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_write_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - X509_REQ *arg2 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_write_pem", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_write_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_write_pem" "', argument " "2"" of type '" "X509_REQ *""'"); - } - arg2 = (X509_REQ *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)x509_req_write_pem(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_crl_read_pem(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_CRL *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_crl_read_pem" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (X509_CRL *)x509_crl_read_pem(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_CRL, 0); - else { - m2_PyErr_Msg(_x509_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_version(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_version", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_version" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_set_version" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_set_version(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_version(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_version" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)x509_get_version(arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_not_before(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - ASN1_TIME *arg2 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_not_before", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_not_before" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_not_before" "', argument " "2"" of type '" "ASN1_TIME *""'"); - } - arg2 = (ASN1_TIME *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_set_not_before(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_not_before(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - ASN1_TIME *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_not_before" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_TIME *)x509_get_not_before(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_set_not_after(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - ASN1_TIME *arg2 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_set_not_after", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_not_after" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_not_after" "', argument " "2"" of type '" "ASN1_TIME *""'"); - } - arg2 = (ASN1_TIME *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_set_not_after(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_get_not_after(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - ASN1_TIME *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_not_after" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_TIME *)x509_get_not_after(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_sign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - EVP_MD *arg3 = (EVP_MD *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_sign", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_sign" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_sign" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "x509_sign" "', argument " "3"" of type '" "EVP_MD *""'"); - } - arg3 = (EVP_MD *)(argp3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_sign(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_gmtime_adj(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - ASN1_TIME *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_gmtime_adj", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_gmtime_adj" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_gmtime_adj" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - result = (ASN1_TIME *)x509_gmtime_adj(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_by_nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_by_nid", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_by_nid" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)x509_name_by_nid(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_set_by_nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - int arg2 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_set_by_nid", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_set_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_set_by_nid" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_name_set_by_nid(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_add_entry_by_txt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char *arg4 = (char *) 0 ; - int arg5 ; - int arg6 ; - int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int val5 ; - int ecode5 = 0 ; - int val6 ; - int ecode6 = 0 ; - int val7 ; - int ecode7 = 0 ; - PyObject *swig_obj[7] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry_by_txt", 7, 7, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry_by_txt" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_add_entry_by_txt" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry_by_txt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_add_entry_by_txt" "', argument " "4"" of type '" "char *""'"); - } - arg4 = (char *)(buf4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_add_entry_by_txt" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "x509_name_add_entry_by_txt" "', argument " "6"" of type '" "int""'"); - } - arg6 = (int)(val6); - ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); - if (!SWIG_IsOK(ecode7)) { - SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "x509_name_add_entry_by_txt" "', argument " "7"" of type '" "int""'"); - } - arg7 = (int)(val7); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_name_add_entry_by_txt(arg1,arg2,arg3,arg4,arg5,arg6,arg7); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_get_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_get_der" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)x509_name_get_der(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_free" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - sk_x509_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_x509_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_push" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_x509_push" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)sk_x509_push(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_pop" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509 *)sk_x509_pop(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_load_locations(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE *arg1 = (X509_STORE *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_store_load_locations", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_load_locations" "', argument " "1"" of type '" "X509_STORE *""'"); - } - arg1 = (X509_STORE *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_store_load_locations" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - result = (int)x509_store_load_locations(arg1,(char const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_type_check" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_type_check" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_name_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_get_subject_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_NAME *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_get_subject_name" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509_NAME *)x509_req_get_subject_name(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_get_version(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - long result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_get_version" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (long)x509_req_get_version(arg1); - resultobj = SWIG_From_long((long)(result)); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_set_version(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_set_version", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_set_version" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_req_set_version" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_req_set_version(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_req_add_extensions(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_REQ *arg1 = (X509_REQ *) 0 ; - struct stack_st_X509_EXTENSION *arg2 = (struct stack_st_X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "x509_req_add_extensions", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_add_extensions" "', argument " "1"" of type '" "X509_REQ *""'"); - } - arg1 = (X509_REQ *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_add_extensions" "', argument " "2"" of type '" "struct stack_st_X509_EXTENSION *""'"); - } - arg2 = (struct stack_st_X509_EXTENSION *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)x509_req_add_extensions(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_entry_create_by_txt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME_ENTRY **arg1 = (X509_NAME_ENTRY **) 0 ; - char *arg2 = (char *) 0 ; - int arg3 ; - char *arg4 = (char *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - X509_NAME_ENTRY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_create_by_txt", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_X509_NAME_ENTRY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_create_by_txt" "', argument " "1"" of type '" "X509_NAME_ENTRY **""'"); - } - arg1 = (X509_NAME_ENTRY **)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_entry_create_by_txt" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_entry_create_by_txt" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_entry_create_by_txt" "', argument " "4"" of type '" "char *""'"); - } - arg4 = (char *)(buf4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_entry_create_by_txt" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - result = (X509_NAME_ENTRY *)x509_name_entry_create_by_txt(arg1,arg2,arg3,arg4,arg5); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509v3_set_nconf(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509V3_CTX *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509v3_set_nconf", 0, 0, 0)) SWIG_fail; - result = (X509V3_CTX *)x509v3_set_nconf(); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509V3_CTX, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509v3_ext_conf(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - void *arg1 = (void *) 0 ; - X509V3_CTX *arg2 = (X509V3_CTX *) 0 ; - char *arg3 = (char *) 0 ; - char *arg4 = (char *) 0 ; - int res1 ; - void *argp2 = 0 ; - int res2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - PyObject *swig_obj[4] ; - X509_EXTENSION *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509v3_ext_conf", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509v3_ext_conf" "', argument " "1"" of type '" "void *""'"); - } - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509V3_CTX, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509v3_ext_conf" "', argument " "2"" of type '" "X509V3_CTX *""'"); - } - arg2 = (X509V3_CTX *)(argp2); - res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "x509v3_ext_conf" "', argument " "3"" of type '" "char *""'"); - } - arg3 = (char *)(buf3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509v3_ext_conf" "', argument " "4"" of type '" "char *""'"); - } - arg4 = (char *)(buf4); - result = (X509_EXTENSION *)x509v3_ext_conf(arg1,arg2,arg3,arg4); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_EXTENSION, 0); - else { - m2_PyErr_Msg(_x509_err); - resultobj = NULL; - } - } - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - return resultobj; -fail: - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_extension_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_free" "', argument " "1"" of type '" "X509_EXTENSION *""'"); - } - arg1 = (X509_EXTENSION *)(argp1); - x509_extension_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_extension_get_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_get_name" "', argument " "1"" of type '" "X509_EXTENSION *""'"); - } - arg1 = (X509_EXTENSION *)(argp1); - result = (PyObject *)x509_extension_get_name(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_extension_new_null(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509_EXTENSION *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_x509_extension_new_null", 0, 0, 0)) SWIG_fail; - result = (struct stack_st_X509_EXTENSION *)sk_x509_extension_new_null(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_extension_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_free" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); - } - arg1 = (struct stack_st_X509_EXTENSION *)(argp1); - sk_x509_extension_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_extension_push(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; - X509_EXTENSION *arg2 = (X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "sk_x509_extension_push", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_push" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); - } - arg1 = (struct stack_st_X509_EXTENSION *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_x509_extension_push" "', argument " "2"" of type '" "X509_EXTENSION *""'"); - } - arg2 = (X509_EXTENSION *)(argp2); - result = (int)sk_x509_extension_push(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_extension_pop(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - X509_EXTENSION *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_pop" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); - } - arg1 = (struct stack_st_X509_EXTENSION *)(argp1); - result = (X509_EXTENSION *)sk_x509_extension_pop(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_extension_num(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_num" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); - } - arg1 = (struct stack_st_X509_EXTENSION *)(argp1); - result = (int)sk_x509_extension_num(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_extension_value(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - X509_EXTENSION *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_x509_extension_value", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_value" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); - } - arg1 = (struct stack_st_X509_EXTENSION *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_x509_extension_value" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (X509_EXTENSION *)sk_x509_extension_value(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_get_app_data(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - void *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_app_data" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - result = (void *)x509_store_ctx_get_app_data(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_ctx_get_ex_data(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - void *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "x509_store_ctx_get_ex_data", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_ex_data" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); - } - arg1 = (X509_STORE_CTX *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_store_ctx_get_ex_data" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - result = (void *)x509_store_ctx_get_ex_data(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_set_verify_cb__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - X509_STORE *arg1 = (X509_STORE *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_set_verify_cb" "', argument " "1"" of type '" "X509_STORE *""'"); - } - arg1 = (X509_STORE *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - x509_store_set_verify_cb(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_store_set_verify_cb(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[3] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "x509_store_set_verify_cb", 0, 2, argv))) SWIG_fail; - --argc; - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_X509_STORE, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *ptr = 0; - int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_int_p_X509_STORE_CTX__int); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_x509_store_set_verify_cb__SWIG_0(self, argc, argv); - } - } - } - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_X509_STORE, 0); - _v = SWIG_CheckState(res); - if (_v) { - _v = (argv[1] != 0); - if (_v) { - return _wrap_x509_store_set_verify_cb__SWIG_1(self, argc, argv); - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'x509_store_set_verify_cb'.\n" - " Possible C/C++ prototypes are:\n" - " X509_STORE_set_verify_cb(X509_STORE *,int (*)(int,X509_STORE_CTX *))\n" - " x509_store_set_verify_cb(X509_STORE *,PyObject *)\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_make_stack_from_der_sequence(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - struct stack_st_X509 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (struct stack_st_X509 *)make_stack_from_der_sequence(arg1); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_stack_st_X509, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_sk_x509_new_null(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "sk_x509_new_null", 0, 0, 0)) SWIG_fail; - result = (struct stack_st_X509 *)sk_x509_new_null(); - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_stack_st_X509, 0); - else { - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_get_der_encoding_stack(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_der_encoding_stack" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)get_der_encoding_stack(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_x509_name_oneline(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509_NAME *arg1 = (X509_NAME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_oneline" "', argument " "1"" of type '" "X509_NAME *""'"); - } - arg1 = (X509_NAME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)x509_name_oneline(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - { - if (result != NULL) - OPENSSL_free(result); - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_object_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_OBJECT *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_object_new", 0, 0, 0)) SWIG_fail; - result = (ASN1_OBJECT *)ASN1_OBJECT_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_object_create(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - unsigned char *arg2 = (unsigned char *) 0 ; - int arg3 ; - char *arg4 = (char *) 0 ; - char *arg5 = (char *) 0 ; - int val1 ; - int ecode1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - int res4 ; - char *buf4 = 0 ; - int alloc4 = 0 ; - int res5 ; - char *buf5 = 0 ; - int alloc5 = 0 ; - PyObject *swig_obj[5] ; - ASN1_OBJECT *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_object_create", 5, 5, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "asn1_object_create" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_object_create" "', argument " "2"" of type '" "unsigned char *""'"); - } - arg2 = (unsigned char *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "asn1_object_create" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "asn1_object_create" "', argument " "4"" of type '" "char const *""'"); - } - arg4 = (char *)(buf4); - res5 = SWIG_AsCharPtrAndSize(swig_obj[4], &buf5, NULL, &alloc5); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "asn1_object_create" "', argument " "5"" of type '" "char const *""'"); - } - arg5 = (char *)(buf5); - result = (ASN1_OBJECT *)ASN1_OBJECT_create(arg1,arg2,arg3,(char const *)arg4,(char const *)arg5); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); - return resultobj; -fail: - if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); - if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_object_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_object_free" "', argument " "1"" of type '" "ASN1_OBJECT *""'"); - } - arg1 = (ASN1_OBJECT *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ASN1_OBJECT_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_i2d_asn1_object(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; - unsigned char **arg2 = (unsigned char **) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "i2d_asn1_object", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_asn1_object" "', argument " "1"" of type '" "ASN1_OBJECT *""'"); - } - arg1 = (ASN1_OBJECT *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_asn1_object" "', argument " "2"" of type '" "unsigned char **""'"); - } - arg2 = (unsigned char **)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)i2d_ASN1_OBJECT(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_d2i_asn1_object(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_OBJECT **arg1 = (ASN1_OBJECT **) 0 ; - unsigned char **arg2 = (unsigned char **) 0 ; - long arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - long val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - ASN1_OBJECT *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "d2i_asn1_object", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "d2i_asn1_object" "', argument " "1"" of type '" "ASN1_OBJECT **""'"); - } - arg1 = (ASN1_OBJECT **)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_char, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "d2i_asn1_object" "', argument " "2"" of type '" "unsigned char const **""'"); - } - arg2 = (unsigned char **)(argp2); - ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "d2i_asn1_object" "', argument " "3"" of type '" "long""'"); - } - arg3 = (long)(val3); - result = (ASN1_OBJECT *)d2i_ASN1_OBJECT(arg1,(unsigned char const **)arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_bit_string_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_BIT_STRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_bit_string_new", 0, 0, 0)) SWIG_fail; - result = (ASN1_BIT_STRING *)ASN1_BIT_STRING_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_BIT_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_string_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_STRING *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_string_new", 0, 0, 0)) SWIG_fail; - result = (ASN1_STRING *)ASN1_STRING_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_STRING, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_string_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_STRING *arg1 = (ASN1_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_free" "', argument " "1"" of type '" "ASN1_STRING *""'"); - } - arg1 = (ASN1_STRING *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ASN1_STRING_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_string_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_STRING *arg1 = (ASN1_STRING *) 0 ; - void *arg2 = (void *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_string_set", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_set" "', argument " "1"" of type '" "ASN1_STRING *""'"); - } - arg1 = (ASN1_STRING *)(argp1); - { - if (PyBytes_Check(swig_obj[1])) { - Py_ssize_t len; - - arg2 = PyBytes_AsString(swig_obj[1]); - len = PyBytes_Size(swig_obj[1]); - - if (len > INT_MAX) { - PyErr_SetString(PyExc_ValueError, "object too large"); - return NULL; - } - arg3 = len; - } - else { - PyErr_SetString(PyExc_TypeError, "expected string"); - return NULL; - } - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ASN1_STRING_set(arg1,(void const *)arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_string_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - ASN1_STRING *arg2 = (ASN1_STRING *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_string_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_string_print" "', argument " "2"" of type '" "ASN1_STRING *""'"); - } - arg2 = (ASN1_STRING *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)ASN1_STRING_print(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_string_print_ex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - ASN1_STRING *arg2 = (ASN1_STRING *) 0 ; - unsigned long arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - unsigned long val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_string_print_ex", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_print_ex" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_string_print_ex" "', argument " "2"" of type '" "ASN1_STRING *""'"); - } - arg2 = (ASN1_STRING *)(argp2); - ecode3 = SWIG_AsVal_unsigned_SS_long(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "asn1_string_print_ex" "', argument " "3"" of type '" "unsigned long""'"); - } - arg3 = (unsigned long)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)ASN1_STRING_print_ex(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_time_new", 0, 0, 0)) SWIG_fail; - result = (ASN1_TIME *)ASN1_TIME_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_free" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ASN1_TIME_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_check" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ASN1_TIME_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - long arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - long val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - ASN1_TIME *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_time_set", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_set" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "asn1_time_set" "', argument " "2"" of type '" "long""'"); - } - arg2 = (long)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_TIME *)ASN1_TIME_set(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_set_string(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_time_set_string", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_set_string" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_time_set_string" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ASN1_TIME_set_string(arg1,(char const *)arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_print(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - ASN1_TIME *arg2 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_time_print", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_print" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_time_print" "', argument " "2"" of type '" "ASN1_TIME *""'"); - } - arg2 = (ASN1_TIME *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)ASN1_TIME_print(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_integer_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_INTEGER *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "asn1_integer_new", 0, 0, 0)) SWIG_fail; - result = (ASN1_INTEGER *)ASN1_INTEGER_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_integer_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_free" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); - } - arg1 = (ASN1_INTEGER *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - ASN1_INTEGER_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_integer_cmp(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; - ASN1_INTEGER *arg2 = (ASN1_INTEGER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_integer_cmp", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_cmp" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); - } - arg1 = (ASN1_INTEGER *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_integer_cmp" "', argument " "2"" of type '" "ASN1_INTEGER *""'"); - } - arg2 = (ASN1_INTEGER *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ASN1_INTEGER_cmp(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_time_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_type_check" "', argument " "1"" of type '" "ASN1_TIME *""'"); - } - arg1 = (ASN1_TIME *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)asn1_time_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_integer_get(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_get" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); - } - arg1 = (ASN1_INTEGER *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)asn1_integer_get(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_asn1_integer_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "asn1_integer_set", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_set" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); - } - arg1 = (ASN1_INTEGER *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)asn1_integer_set(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_new", 0, 0, 0)) SWIG_fail; - result = (PKCS7 *)PKCS7_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PKCS7, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_free" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - PKCS7_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_add_certificate(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - X509 *arg2 = (X509 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_add_certificate", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_add_certificate" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_add_certificate" "', argument " "2"" of type '" "X509 *""'"); - } - arg2 = (X509 *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - PKCS7_add_certificate(arg1,arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__pkcs7_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_pkcs7_err""' of type '""PyObject *""'"); - } - _pkcs7_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__pkcs7_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_pkcs7_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN int Swig_var__smime_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_smime_err""' of type '""PyObject *""'"); - } - _smime_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__smime_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_smime_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - pkcs7_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_smime_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - smime_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_decrypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - X509 *arg3 = (X509 *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_decrypt", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_decrypt" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_decrypt" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_decrypt" "', argument " "3"" of type '" "X509 *""'"); - } - arg3 = (X509 *)(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs7_decrypt" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)pkcs7_decrypt(arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_encrypt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; - BIO *arg2 = (BIO *) 0 ; - EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PKCS7 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_encrypt", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_encrypt" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); - } - arg1 = (struct stack_st_X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_encrypt" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_encrypt" "', argument " "3"" of type '" "EVP_CIPHER *""'"); - } - arg3 = (EVP_CIPHER *)(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs7_encrypt" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (PKCS7 *)pkcs7_encrypt(arg1,arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); - else { - m2_PyErr_Msg(_smime_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_sign1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - struct stack_st_X509 *arg3 = (struct stack_st_X509 *) 0 ; - BIO *arg4 = (BIO *) 0 ; - EVP_MD *arg5 = (EVP_MD *) 0 ; - int arg6 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - void *argp5 = 0 ; - int res5 = 0 ; - int val6 ; - int ecode6 = 0 ; - PyObject *swig_obj[6] ; - PKCS7 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_sign1", 6, 6, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_sign1" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_sign1" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_sign1" "', argument " "3"" of type '" "struct stack_st_X509 *""'"); - } - arg3 = (struct stack_st_X509 *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pkcs7_sign1" "', argument " "4"" of type '" "BIO *""'"); - } - arg4 = (BIO *)(argp4); - res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res5)) { - SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "pkcs7_sign1" "', argument " "5"" of type '" "EVP_MD *""'"); - } - arg5 = (EVP_MD *)(argp5); - ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); - if (!SWIG_IsOK(ecode6)) { - SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "pkcs7_sign1" "', argument " "6"" of type '" "int""'"); - } - arg6 = (int)(val6); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg5) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (PKCS7 *)pkcs7_sign1(arg1,arg2,arg3,arg4,arg5,arg6); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); - else { - m2_PyErr_Msg(_smime_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_sign0(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - X509 *arg1 = (X509 *) 0 ; - EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; - BIO *arg3 = (BIO *) 0 ; - EVP_MD *arg4 = (EVP_MD *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - PKCS7 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_sign0", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_sign0" "', argument " "1"" of type '" "X509 *""'"); - } - arg1 = (X509 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_sign0" "', argument " "2"" of type '" "EVP_PKEY *""'"); - } - arg2 = (EVP_PKEY *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_sign0" "', argument " "3"" of type '" "BIO *""'"); - } - arg3 = (BIO *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_EVP_MD, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pkcs7_sign0" "', argument " "4"" of type '" "EVP_MD *""'"); - } - arg4 = (EVP_MD *)(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "pkcs7_sign0" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (PKCS7 *)pkcs7_sign0(arg1,arg2,arg3,arg4,arg5); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); - else { - m2_PyErr_Msg(_smime_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_read_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PKCS7 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_read_bio" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (PKCS7 *)pkcs7_read_bio(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); - else { - m2_PyErr_Msg(_pkcs7_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_read_bio_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PKCS7 *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_read_bio_der" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (PKCS7 *)pkcs7_read_bio_der(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (result != NULL) - resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); - else { - m2_PyErr_Msg(_pkcs7_err); - resultobj = NULL; - } - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_verify1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - struct stack_st_X509 *arg2 = (struct stack_st_X509 *) 0 ; - X509_STORE *arg3 = (X509_STORE *) 0 ; - BIO *arg4 = (BIO *) 0 ; - int arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - PyObject *swig_obj[5] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_verify1", 5, 5, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_verify1" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_verify1" "', argument " "2"" of type '" "struct stack_st_X509 *""'"); - } - arg2 = (struct stack_st_X509 *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_verify1" "', argument " "3"" of type '" "X509_STORE *""'"); - } - arg3 = (X509_STORE *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pkcs7_verify1" "', argument " "4"" of type '" "BIO *""'"); - } - arg4 = (BIO *)(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "pkcs7_verify1" "', argument " "5"" of type '" "int""'"); - } - arg5 = (int)(val5); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)pkcs7_verify1(arg1,arg2,arg3,arg4,arg5); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_verify0(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - struct stack_st_X509 *arg2 = (struct stack_st_X509 *) 0 ; - X509_STORE *arg3 = (X509_STORE *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_verify0", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_verify0" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_verify0" "', argument " "2"" of type '" "struct stack_st_X509 *""'"); - } - arg2 = (struct stack_st_X509 *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_X509_STORE, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_verify0" "', argument " "3"" of type '" "X509_STORE *""'"); - } - arg3 = (X509_STORE *)(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs7_verify0" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)pkcs7_verify0(arg1,arg2,arg3,arg4); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_smime_write_pkcs7_multi(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PKCS7 *arg2 = (PKCS7 *) 0 ; - BIO *arg3 = (BIO *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "smime_write_pkcs7_multi", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_write_pkcs7_multi" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "smime_write_pkcs7_multi" "', argument " "2"" of type '" "PKCS7 *""'"); - } - arg2 = (PKCS7 *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "smime_write_pkcs7_multi" "', argument " "3"" of type '" "BIO *""'"); - } - arg3 = (BIO *)(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "smime_write_pkcs7_multi" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)smime_write_pkcs7_multi(arg1,arg2,arg3,arg4); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_smime_write_pkcs7(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PKCS7 *arg2 = (PKCS7 *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "smime_write_pkcs7", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_write_pkcs7" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "smime_write_pkcs7" "', argument " "2"" of type '" "PKCS7 *""'"); - } - arg2 = (PKCS7 *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "smime_write_pkcs7" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)smime_write_pkcs7(arg1,arg2,arg3); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_smime_read_pkcs7(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_read_pkcs7" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)smime_read_pkcs7(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_write_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_write_bio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_write_bio" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_write_bio" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)pkcs7_write_bio(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_write_bio_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_write_bio_der", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_write_bio_der" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_write_bio_der" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)pkcs7_write_bio_der(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_type_nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_type_nid" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)pkcs7_type_nid(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_type_sn(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_type_sn" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)pkcs7_type_sn(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_smime_crlf_copy(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "smime_crlf_copy", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_crlf_copy" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "smime_crlf_copy" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)smime_crlf_copy(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_pkcs7_get0_signers(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PKCS7 *arg1 = (PKCS7 *) 0 ; - struct stack_st_X509 *arg2 = (struct stack_st_X509 *) 0 ; - int arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - PyObject *swig_obj[3] ; - struct stack_st_X509 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "pkcs7_get0_signers", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_get0_signers" "', argument " "1"" of type '" "PKCS7 *""'"); - } - arg1 = (PKCS7 *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_get0_signers" "', argument " "2"" of type '" "struct stack_st_X509 *""'"); - } - arg2 = (struct stack_st_X509 *)(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pkcs7_get0_signers" "', argument " "3"" of type '" "int""'"); - } - arg3 = (int)(val3); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (struct stack_st_X509 *)pkcs7_get0_signers(arg1,arg2,arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__util_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_util_err""' of type '""PyObject *""'"); - } - _util_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__util_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_util_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_util_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - util_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_util_hex_to_string(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (PyObject *)util_hex_to_string(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_util_string_to_hex(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (PyObject *)util_string_to_hex(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ec_key_new", 0, 0, 0)) SWIG_fail; - result = (EC_KEY *)EC_KEY_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_free" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - EC_KEY_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_size(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_size" "', argument " "1"" of type '" "EC_KEY const *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ECDSA_size((EC_KEY const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_gen_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_gen_key" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EC_KEY_generate_key(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_check_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_check_key" "', argument " "1"" of type '" "EC_KEY const *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)EC_KEY_check_key((EC_KEY const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int Swig_var__ec_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_ec_err""' of type '""PyObject *""'"); - } - _ec_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__ec_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_ec_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_ec_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - ec_init(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_get_builtin_curves(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ec_get_builtin_curves", 0, 0, 0)) SWIG_fail; - result = (PyObject *)ec_get_builtin_curves(); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_new_by_curve_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - EC_KEY *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ec_key_new_by_curve_name" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (EC_KEY *)ec_key_new_by_curve_name(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_get_public_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_get_public_der" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ec_key_get_public_der(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_get_public_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_get_public_key" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ec_key_get_public_key(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_read_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - EC_KEY *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_read_pubkey" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (EC_KEY *)ec_key_read_pubkey(arg1); - SWIG_PYTHON_THREAD_END_ALLOW; - } - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_write_pubkey(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - BIO *arg2 = (BIO *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ec_key_write_pubkey", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_write_pubkey" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ec_key_write_pubkey" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - SWIG_PYTHON_THREAD_BEGIN_ALLOW; - result = (int)ec_key_write_pubkey(arg1,arg2); - SWIG_PYTHON_THREAD_END_ALLOW; - } - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_read_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - BIO *arg1 = (BIO *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - EC_KEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ec_key_read_bio", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_read_bio" "', argument " "1"" of type '" "BIO *""'"); - } - arg1 = (BIO *)(argp1); - { - if (!PyCallable_Check(swig_obj[1])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EC_KEY *)ec_key_read_bio(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_write_bio(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - BIO *arg2 = (BIO *) 0 ; - EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ec_key_write_bio", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_write_bio" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ec_key_write_bio" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ec_key_write_bio" "', argument " "3"" of type '" "EVP_CIPHER *""'"); - } - arg3 = (EVP_CIPHER *)(argp3); - { - if (!PyCallable_Check(swig_obj[3])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg4) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ec_key_write_bio(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_write_bio_no_cipher(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - BIO *arg2 = (BIO *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ec_key_write_bio_no_cipher", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_write_bio_no_cipher" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ec_key_write_bio_no_cipher" "', argument " "2"" of type '" "BIO *""'"); - } - arg2 = (BIO *)(argp2); - { - if (!PyCallable_Check(swig_obj[2])) { - PyErr_SetString(PyExc_TypeError, "expected PyCallable"); - return NULL; - } - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ec_key_write_bio_no_cipher(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdsa_sig_get_r(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ECDSA_SIG *arg1 = (ECDSA_SIG *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ECDSA_SIG, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sig_get_r" "', argument " "1"" of type '" "ECDSA_SIG *""'"); - } - arg1 = (ECDSA_SIG *)(argp1); - result = (PyObject *)ecdsa_sig_get_r(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdsa_sig_get_s(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ECDSA_SIG *arg1 = (ECDSA_SIG *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - PyObject *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ECDSA_SIG, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sig_get_s" "', argument " "1"" of type '" "ECDSA_SIG *""'"); - } - arg1 = (ECDSA_SIG *)(argp1); - result = (PyObject *)ecdsa_sig_get_s(arg1); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdsa_sign(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ecdsa_sign", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sign" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ecdsa_sign(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdsa_verify(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - PyObject *arg4 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ecdsa_verify", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_verify" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - arg4=swig_obj[3]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ecdsa_verify(arg1,arg2,arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdsa_sign_asn1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ecdsa_sign_asn1", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sign_asn1" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ecdsa_sign_asn1(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdsa_verify_asn1(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - PyObject *arg2 = (PyObject *) 0 ; - PyObject *arg3 = (PyObject *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[3] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "ecdsa_verify_asn1", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_verify_asn1" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - arg2=swig_obj[1]; - } - { - arg3=swig_obj[2]; - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ecdsa_verify_asn1(arg1,arg2,arg3); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ecdh_compute_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - EC_KEY *arg2 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ecdh_compute_key", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdh_compute_key" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ecdh_compute_key" "', argument " "2"" of type '" "EC_KEY *""'"); - } - arg2 = (EC_KEY *)(argp2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)ecdh_compute_key(arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_from_pubkey_der(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - EC_KEY *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - result = (EC_KEY *)ec_key_from_pubkey_der(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_from_pubkey_params(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - PyObject *arg2 = (PyObject *) 0 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[2] ; - EC_KEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ec_key_from_pubkey_params", 2, 2, swig_obj)) SWIG_fail; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ec_key_from_pubkey_params" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - { - arg2=swig_obj[1]; - } - result = (EC_KEY *)ec_key_from_pubkey_params(arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_keylen(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_keylen" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ec_key_keylen(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ec_key_type_check(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - EC_KEY *arg1 = (EC_KEY *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_type_check" "', argument " "1"" of type '" "EC_KEY *""'"); - } - arg1 = (EC_KEY *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ec_key_type_check(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_load_builtin_engines(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "engine_load_builtin_engines", 0, 0, 0)) SWIG_fail; - ENGINE_load_builtin_engines(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_load_dynamic(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "engine_load_dynamic", 0, 0, 0)) SWIG_fail; - ENGINE_load_dynamic(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_load_openssl(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "engine_load_openssl", 0, 0, 0)) SWIG_fail; - ENGINE_load_openssl(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_cleanup(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - - if (!SWIG_Python_UnpackTuple(args, "engine_cleanup", 0, 0, 0)) SWIG_fail; - ENGINE_cleanup(); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "engine_new", 0, 0, 0)) SWIG_fail; - result = (ENGINE *)ENGINE_new(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ENGINE, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_by_id(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - ENGINE *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_by_id" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ENGINE *)ENGINE_by_id((char const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ENGINE, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_free" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ENGINE_free(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_init(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_init" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ENGINE_init(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_finish(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_finish" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ENGINE_finish(arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_get_id(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_get_id" "', argument " "1"" of type '" "ENGINE const *""'"); - } - arg1 = (ENGINE *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)ENGINE_get_id((ENGINE const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_get_name(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_get_name" "', argument " "1"" of type '" "ENGINE const *""'"); - } - arg1 = (ENGINE *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (char *)ENGINE_get_name((ENGINE const *)arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_ctrl_cmd_string(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - char *arg2 = (char *) 0 ; - char *arg3 = (char *) 0 ; - int arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - int res3 ; - char *buf3 = 0 ; - int alloc3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "engine_ctrl_cmd_string", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_ctrl_cmd_string" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_ctrl_cmd_string" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "engine_ctrl_cmd_string" "', argument " "3"" of type '" "char const *""'"); - } - arg3 = (char *)(buf3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "engine_ctrl_cmd_string" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ENGINE_ctrl_cmd_string(arg1,(char const *)arg2,(char const *)arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_ui_openssl(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - UI_METHOD *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "ui_openssl", 0, 0, 0)) SWIG_fail; - result = (UI_METHOD *)UI_OpenSSL(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UI_METHOD, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap__cbd_t_password_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - _cbd_t *arg1 = (_cbd_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_password_set" "', argument " "1"" of type '" "_cbd_t *""'"); - } - arg1 = (_cbd_t *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_cbd_t_password_set" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - if (arg1->password) free((char*)arg1->password); - if (arg2) { - size_t size = strlen((const char *)(arg2)) + 1; - arg1->password = (char *)(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); - } else { - arg1->password = 0; - } - resultobj = SWIG_Py_Void(); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap__cbd_t_password_get(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - _cbd_t *arg1 = (_cbd_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "_cbd_t_password_get", 0, 0, 0)) SWIG_fail; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_password_get" "', argument " "1"" of type '" "_cbd_t *""'"); - } - arg1 = (_cbd_t *)(argp1); - result = (char *) ((arg1)->password); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap__cbd_t_prompt_set(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - _cbd_t *arg1 = (_cbd_t *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_prompt_set" "', argument " "1"" of type '" "_cbd_t *""'"); - } - arg1 = (_cbd_t *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_cbd_t_prompt_set" "', argument " "2"" of type '" "char *""'"); - } - arg2 = (char *)(buf2); - if (arg1->prompt) free((char*)arg1->prompt); - if (arg2) { - size_t size = strlen((const char *)(arg2)) + 1; - arg1->prompt = (char *)(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); - } else { - arg1->prompt = 0; - } - resultobj = SWIG_Py_Void(); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap__cbd_t_prompt_get(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - _cbd_t *arg1 = (_cbd_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "_cbd_t_prompt_get", 0, 0, 0)) SWIG_fail; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_prompt_get" "', argument " "1"" of type '" "_cbd_t *""'"); - } - arg1 = (_cbd_t *)(argp1); - result = (char *) ((arg1)->prompt); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN int _wrap_new__cbd_t(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *resultobj = 0; - _cbd_t *result = 0 ; - - if (!SWIG_Python_CheckNoKeywords(kwargs, "new__cbd_t")) SWIG_fail; - if (!SWIG_Python_UnpackTuple(args, "new__cbd_t", 0, 0, 0)) SWIG_fail; - result = (_cbd_t *)calloc(1, sizeof(_cbd_t)); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__cbd_t, SWIG_BUILTIN_INIT | 0 ); - return resultobj == Py_None ? -1 : 0; -fail: - return -1; -} - - -SWIGINTERN PyObject *_wrap_delete__cbd_t(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - _cbd_t *arg1 = (_cbd_t *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - - if (!SWIG_Python_UnpackTuple(args, "delete__cbd_t", 0, 0, 0)) SWIG_fail; - res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, SWIG_POINTER_DISOWN | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__cbd_t" "', argument " "1"" of type '" "_cbd_t *""'"); - } - arg1 = (_cbd_t *)(argp1); - free((char *) arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete__cbd_t) /* defines _wrap_delete__cbd_t_destructor_closure */ - -SWIGINTERN PyObject *_wrap_engine_pkcs11_data_new(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - void *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_pkcs11_data_new" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - result = (void *)engine_pkcs11_data_new((char const *)arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_pkcs11_data_free(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - void *arg1 = (void *) 0 ; - int res1 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_pkcs11_data_free" "', argument " "1"" of type '" "void *""'"); - } - engine_pkcs11_data_free(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_load_private_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - char *arg2 = (char *) 0 ; - UI_METHOD *arg3 = (UI_METHOD *) 0 ; - void *arg4 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - PyObject *swig_obj[4] ; - EVP_PKEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "engine_load_private_key", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_load_private_key" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_load_private_key" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_UI_METHOD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "engine_load_private_key" "', argument " "3"" of type '" "UI_METHOD *""'"); - } - arg3 = (UI_METHOD *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "engine_load_private_key" "', argument " "4"" of type '" "void *""'"); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EVP_PKEY *)ENGINE_load_private_key(arg1,(char const *)arg2,arg3,arg4); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_load_public_key(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - char *arg2 = (char *) 0 ; - UI_METHOD *arg3 = (UI_METHOD *) 0 ; - void *arg4 = (void *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int res4 ; - PyObject *swig_obj[4] ; - EVP_PKEY *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "engine_load_public_key", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_load_public_key" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_load_public_key" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_UI_METHOD, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "engine_load_public_key" "', argument " "3"" of type '" "UI_METHOD *""'"); - } - arg3 = (UI_METHOD *)(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "engine_load_public_key" "', argument " "4"" of type '" "void *""'"); - } - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (EVP_PKEY *)ENGINE_load_public_key(arg1,(char const *)arg2,arg3,arg4); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN int Swig_var__engine_err_set(PyObject *_val) { - { - void *argp = 0; - int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); - if (!SWIG_IsOK(res)) { - SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_engine_err""' of type '""PyObject *""'"); - } - _engine_err = (PyObject *)(argp); - } - return 0; -fail: - return 1; -} - - -SWIGINTERN PyObject *Swig_var__engine_err_get(void) { - PyObject *pyobj = 0; - PyObject *self = 0; - - (void)self; - pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_engine_err), SWIGTYPE_p_PyObject, 0 ); - return pyobj; -} - - -SWIGINTERN PyObject *_wrap_engine_init_error(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - PyObject *arg1 = (PyObject *) 0 ; - PyObject *swig_obj[1] ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - { - arg1=swig_obj[0]; - } - engine_init_error(arg1); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_load_certificate(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - char *arg2 = (char *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - int res2 ; - char *buf2 = 0 ; - int alloc2 = 0 ; - PyObject *swig_obj[2] ; - X509 *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "engine_load_certificate", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_load_certificate" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_load_certificate" "', argument " "2"" of type '" "char const *""'"); - } - arg2 = (char *)(buf2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - { - if (!arg2) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (X509 *)engine_load_certificate(arg1,(char const *)arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return resultobj; -fail: - if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_engine_set_default(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ENGINE *arg1 = (ENGINE *) 0 ; - unsigned int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - unsigned int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "engine_set_default", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_set_default" "', argument " "1"" of type '" "ENGINE *""'"); - } - arg1 = (ENGINE *)(argp1); - ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "engine_set_default" "', argument " "2"" of type '" "unsigned int""'"); - } - arg2 = (unsigned int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)ENGINE_set_default(arg1,arg2); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_nid2obj(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - ASN1_OBJECT *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "obj_nid2obj" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (ASN1_OBJECT *)OBJ_nid2obj(arg1); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_nid2ln(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "obj_nid2ln" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (char *)OBJ_nid2ln(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_nid2sn(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - int arg1 ; - int val1 ; - int ecode1 = 0 ; - PyObject *swig_obj[1] ; - char *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); - if (!SWIG_IsOK(ecode1)) { - SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "obj_nid2sn" "', argument " "1"" of type '" "int""'"); - } - arg1 = (int)(val1); - result = (char *)OBJ_nid2sn(arg1); - resultobj = SWIG_FromCharPtr((const char *)result); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_obj2nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_obj2nid" "', argument " "1"" of type '" "ASN1_OBJECT const *""'"); - } - arg1 = (ASN1_OBJECT *)(argp1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)OBJ_obj2nid((ASN1_OBJECT const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_ln2nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_ln2nid" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)OBJ_ln2nid((char const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_sn2nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_sn2nid" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)OBJ_sn2nid((char const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_txt2nid(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - PyObject *swig_obj[1] ; - int result; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_txt2nid" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)OBJ_txt2nid((char const *)arg1); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_txt2obj(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int arg2 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - ASN1_OBJECT *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "obj_txt2obj", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_txt2obj" "', argument " "1"" of type '" "char const *""'"); - } - arg1 = (char *)(buf1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "obj_txt2obj" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (ASN1_OBJECT *)OBJ_txt2obj((char const *)arg1,arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap__obj_obj2txt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - char *arg1 = (char *) 0 ; - int arg2 ; - ASN1_OBJECT *arg3 = (ASN1_OBJECT *) 0 ; - int arg4 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; - int val2 ; - int ecode2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - PyObject *swig_obj[4] ; - int result; - - if (!SWIG_Python_UnpackTuple(args, "_obj_obj2txt", 4, 4, swig_obj)) SWIG_fail; - res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_obj_obj2txt" "', argument " "1"" of type '" "char *""'"); - } - arg1 = (char *)(buf1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "_obj_obj2txt" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "_obj_obj2txt" "', argument " "3"" of type '" "ASN1_OBJECT const *""'"); - } - arg3 = (ASN1_OBJECT *)(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_obj_obj2txt" "', argument " "4"" of type '" "int""'"); - } - arg4 = (int)(val4); - { - if (!arg3) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (int)OBJ_obj2txt(arg1,arg2,(ASN1_OBJECT const *)arg3,arg4); - { - resultobj=PyLong_FromLong(result); - if (PyErr_Occurred()) SWIG_fail; - } - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return resultobj; -fail: - if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); - return NULL; -} - - -SWIGINTERN PyObject *_wrap_obj_obj2txt(PyObject *self, PyObject *args) { - PyObject *resultobj = 0; - ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; - int arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - int val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - PyObject *result = 0 ; - - if (!SWIG_Python_UnpackTuple(args, "obj_obj2txt", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_obj2txt" "', argument " "1"" of type '" "ASN1_OBJECT const *""'"); - } - arg1 = (ASN1_OBJECT *)(argp1); - ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "obj_obj2txt" "', argument " "2"" of type '" "int""'"); - } - arg2 = (int)(val2); - { - if (!arg1) { - SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); - } - } - result = (PyObject *)obj_obj2txt((ASN1_OBJECT const *)arg1,arg2); - { - resultobj=result; - } - return resultobj; -fail: - return NULL; -} - - -static PyMethodDef SwigMethods[] = { - { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, - { "OPENSSL_sk_num", _wrap_OPENSSL_sk_num, METH_O, NULL}, - { "OPENSSL_sk_value", _wrap_OPENSSL_sk_value, METH_VARARGS, NULL}, - { "OPENSSL_sk_set", _wrap_OPENSSL_sk_set, METH_VARARGS, NULL}, - { "OPENSSL_sk_new", _wrap_OPENSSL_sk_new, METH_O, NULL}, - { "OPENSSL_sk_new_null", _wrap_OPENSSL_sk_new_null, METH_NOARGS, NULL}, - { "OPENSSL_sk_new_reserve", _wrap_OPENSSL_sk_new_reserve, METH_VARARGS, NULL}, - { "OPENSSL_sk_reserve", _wrap_OPENSSL_sk_reserve, METH_VARARGS, NULL}, - { "OPENSSL_sk_free", _wrap_OPENSSL_sk_free, METH_O, NULL}, - { "OPENSSL_sk_pop_free", _wrap_OPENSSL_sk_pop_free, METH_VARARGS, NULL}, - { "OPENSSL_sk_deep_copy", _wrap_OPENSSL_sk_deep_copy, METH_VARARGS, NULL}, - { "OPENSSL_sk_insert", _wrap_OPENSSL_sk_insert, METH_VARARGS, NULL}, - { "OPENSSL_sk_delete", _wrap_OPENSSL_sk_delete, METH_VARARGS, NULL}, - { "OPENSSL_sk_delete_ptr", _wrap_OPENSSL_sk_delete_ptr, METH_VARARGS, NULL}, - { "OPENSSL_sk_find", _wrap_OPENSSL_sk_find, METH_VARARGS, NULL}, - { "OPENSSL_sk_find_ex", _wrap_OPENSSL_sk_find_ex, METH_VARARGS, NULL}, - { "OPENSSL_sk_push", _wrap_OPENSSL_sk_push, METH_VARARGS, NULL}, - { "OPENSSL_sk_unshift", _wrap_OPENSSL_sk_unshift, METH_VARARGS, NULL}, - { "OPENSSL_sk_shift", _wrap_OPENSSL_sk_shift, METH_O, NULL}, - { "OPENSSL_sk_pop", _wrap_OPENSSL_sk_pop, METH_O, NULL}, - { "OPENSSL_sk_zero", _wrap_OPENSSL_sk_zero, METH_O, NULL}, - { "OPENSSL_sk_set_cmp_func", _wrap_OPENSSL_sk_set_cmp_func, METH_VARARGS, NULL}, - { "OPENSSL_sk_dup", _wrap_OPENSSL_sk_dup, METH_O, NULL}, - { "OPENSSL_sk_sort", _wrap_OPENSSL_sk_sort, METH_O, NULL}, - { "OPENSSL_sk_is_sorted", _wrap_OPENSSL_sk_is_sorted, METH_O, NULL}, - { "sk_OPENSSL_STRING_num", _wrap_sk_OPENSSL_STRING_num, METH_O, NULL}, - { "sk_OPENSSL_STRING_value", _wrap_sk_OPENSSL_STRING_value, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_new", _wrap_sk_OPENSSL_STRING_new, METH_O, NULL}, - { "sk_OPENSSL_STRING_new_null", _wrap_sk_OPENSSL_STRING_new_null, METH_NOARGS, NULL}, - { "sk_OPENSSL_STRING_new_reserve", _wrap_sk_OPENSSL_STRING_new_reserve, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_reserve", _wrap_sk_OPENSSL_STRING_reserve, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_free", _wrap_sk_OPENSSL_STRING_free, METH_O, NULL}, - { "sk_OPENSSL_STRING_zero", _wrap_sk_OPENSSL_STRING_zero, METH_O, NULL}, - { "sk_OPENSSL_STRING_delete", _wrap_sk_OPENSSL_STRING_delete, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_delete_ptr", _wrap_sk_OPENSSL_STRING_delete_ptr, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_push", _wrap_sk_OPENSSL_STRING_push, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_unshift", _wrap_sk_OPENSSL_STRING_unshift, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_pop", _wrap_sk_OPENSSL_STRING_pop, METH_O, NULL}, - { "sk_OPENSSL_STRING_shift", _wrap_sk_OPENSSL_STRING_shift, METH_O, NULL}, - { "sk_OPENSSL_STRING_pop_free", _wrap_sk_OPENSSL_STRING_pop_free, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_insert", _wrap_sk_OPENSSL_STRING_insert, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_set", _wrap_sk_OPENSSL_STRING_set, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_find", _wrap_sk_OPENSSL_STRING_find, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_find_ex", _wrap_sk_OPENSSL_STRING_find_ex, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_sort", _wrap_sk_OPENSSL_STRING_sort, METH_O, NULL}, - { "sk_OPENSSL_STRING_is_sorted", _wrap_sk_OPENSSL_STRING_is_sorted, METH_O, NULL}, - { "sk_OPENSSL_STRING_dup", _wrap_sk_OPENSSL_STRING_dup, METH_O, NULL}, - { "sk_OPENSSL_STRING_deep_copy", _wrap_sk_OPENSSL_STRING_deep_copy, METH_VARARGS, NULL}, - { "sk_OPENSSL_STRING_set_cmp_func", _wrap_sk_OPENSSL_STRING_set_cmp_func, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_num", _wrap_sk_OPENSSL_CSTRING_num, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_value", _wrap_sk_OPENSSL_CSTRING_value, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_new", _wrap_sk_OPENSSL_CSTRING_new, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_new_null", _wrap_sk_OPENSSL_CSTRING_new_null, METH_NOARGS, NULL}, - { "sk_OPENSSL_CSTRING_new_reserve", _wrap_sk_OPENSSL_CSTRING_new_reserve, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_reserve", _wrap_sk_OPENSSL_CSTRING_reserve, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_free", _wrap_sk_OPENSSL_CSTRING_free, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_zero", _wrap_sk_OPENSSL_CSTRING_zero, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_delete", _wrap_sk_OPENSSL_CSTRING_delete, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_delete_ptr", _wrap_sk_OPENSSL_CSTRING_delete_ptr, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_push", _wrap_sk_OPENSSL_CSTRING_push, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_unshift", _wrap_sk_OPENSSL_CSTRING_unshift, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_pop", _wrap_sk_OPENSSL_CSTRING_pop, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_shift", _wrap_sk_OPENSSL_CSTRING_shift, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_pop_free", _wrap_sk_OPENSSL_CSTRING_pop_free, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_insert", _wrap_sk_OPENSSL_CSTRING_insert, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_set", _wrap_sk_OPENSSL_CSTRING_set, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_find", _wrap_sk_OPENSSL_CSTRING_find, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_find_ex", _wrap_sk_OPENSSL_CSTRING_find_ex, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_sort", _wrap_sk_OPENSSL_CSTRING_sort, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_is_sorted", _wrap_sk_OPENSSL_CSTRING_is_sorted, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_dup", _wrap_sk_OPENSSL_CSTRING_dup, METH_O, NULL}, - { "sk_OPENSSL_CSTRING_deep_copy", _wrap_sk_OPENSSL_CSTRING_deep_copy, METH_VARARGS, NULL}, - { "sk_OPENSSL_CSTRING_set_cmp_func", _wrap_sk_OPENSSL_CSTRING_set_cmp_func, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_num", _wrap_sk_OPENSSL_BLOCK_num, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_value", _wrap_sk_OPENSSL_BLOCK_value, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_new", _wrap_sk_OPENSSL_BLOCK_new, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_new_null", _wrap_sk_OPENSSL_BLOCK_new_null, METH_NOARGS, NULL}, - { "sk_OPENSSL_BLOCK_new_reserve", _wrap_sk_OPENSSL_BLOCK_new_reserve, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_reserve", _wrap_sk_OPENSSL_BLOCK_reserve, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_free", _wrap_sk_OPENSSL_BLOCK_free, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_zero", _wrap_sk_OPENSSL_BLOCK_zero, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_delete", _wrap_sk_OPENSSL_BLOCK_delete, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_delete_ptr", _wrap_sk_OPENSSL_BLOCK_delete_ptr, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_push", _wrap_sk_OPENSSL_BLOCK_push, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_unshift", _wrap_sk_OPENSSL_BLOCK_unshift, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_pop", _wrap_sk_OPENSSL_BLOCK_pop, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_shift", _wrap_sk_OPENSSL_BLOCK_shift, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_pop_free", _wrap_sk_OPENSSL_BLOCK_pop_free, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_insert", _wrap_sk_OPENSSL_BLOCK_insert, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_set", _wrap_sk_OPENSSL_BLOCK_set, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_find", _wrap_sk_OPENSSL_BLOCK_find, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_find_ex", _wrap_sk_OPENSSL_BLOCK_find_ex, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_sort", _wrap_sk_OPENSSL_BLOCK_sort, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_is_sorted", _wrap_sk_OPENSSL_BLOCK_is_sorted, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_dup", _wrap_sk_OPENSSL_BLOCK_dup, METH_O, NULL}, - { "sk_OPENSSL_BLOCK_deep_copy", _wrap_sk_OPENSSL_BLOCK_deep_copy, METH_VARARGS, NULL}, - { "sk_OPENSSL_BLOCK_set_cmp_func", _wrap_sk_OPENSSL_BLOCK_set_cmp_func, METH_VARARGS, NULL}, - { "threading_init", _wrap_threading_init, METH_NOARGS, NULL}, - { "threading_cleanup", _wrap_threading_cleanup, METH_NOARGS, NULL}, - { "lib_init", _wrap_lib_init, METH_NOARGS, NULL}, - { "bn_to_mpi", _wrap_bn_to_mpi, METH_O, NULL}, - { "mpi_to_bn", _wrap_mpi_to_bn, METH_O, NULL}, - { "bn_to_bin", _wrap_bn_to_bin, METH_O, NULL}, - { "bin_to_bn", _wrap_bin_to_bn, METH_O, NULL}, - { "bn_to_hex", _wrap_bn_to_hex, METH_O, NULL}, - { "hex_to_bn", _wrap_hex_to_bn, METH_O, NULL}, - { "dec_to_bn", _wrap_dec_to_bn, METH_O, NULL}, - { "err_print_errors", _wrap_err_print_errors, METH_O, NULL}, - { "err_get_error", _wrap_err_get_error, METH_NOARGS, NULL}, - { "err_peek_error", _wrap_err_peek_error, METH_NOARGS, NULL}, - { "err_lib_error_string", _wrap_err_lib_error_string, METH_O, NULL}, - { "err_func_error_string", _wrap_err_func_error_string, METH_O, NULL}, - { "err_reason_error_string", _wrap_err_reason_error_string, METH_O, NULL}, - { "bio_s_bio", _wrap_bio_s_bio, METH_NOARGS, NULL}, - { "bio_s_mem", _wrap_bio_s_mem, METH_NOARGS, NULL}, - { "bio_s_socket", _wrap_bio_s_socket, METH_NOARGS, NULL}, - { "bio_f_ssl", _wrap_bio_f_ssl, METH_NOARGS, NULL}, - { "bio_f_buffer", _wrap_bio_f_buffer, METH_NOARGS, NULL}, - { "bio_f_cipher", _wrap_bio_f_cipher, METH_NOARGS, NULL}, - { "bio_new", _wrap_bio_new, METH_O, NULL}, - { "bio_new_socket", _wrap_bio_new_socket, METH_VARARGS, NULL}, - { "bio_free_all", _wrap_bio_free_all, METH_O, NULL}, - { "bio_dup_chain", _wrap_bio_dup_chain, METH_O, NULL}, - { "bio_push", _wrap_bio_push, METH_VARARGS, NULL}, - { "bio_pop", _wrap_bio_pop, METH_O, NULL}, - { "bio_eof", _wrap_bio_eof, METH_O, NULL}, - { "pyfd_init", _wrap_pyfd_init, METH_NOARGS, NULL}, - { "bio_init", _wrap_bio_init, METH_O, NULL}, - { "bio_free", _wrap_bio_free, METH_O, NULL}, - { "bio_new_file", _wrap_bio_new_file, METH_VARARGS, NULL}, - { "bio_new_pyfile", _wrap_bio_new_pyfile, METH_VARARGS, NULL}, - { "bio_read", _wrap_bio_read, METH_VARARGS, NULL}, - { "bio_gets", _wrap_bio_gets, METH_VARARGS, NULL}, - { "bio_write", _wrap_bio_write, METH_VARARGS, NULL}, - { "bio_ctrl_pending", _wrap_bio_ctrl_pending, METH_O, NULL}, - { "bio_ctrl_wpending", _wrap_bio_ctrl_wpending, METH_O, NULL}, - { "bio_ctrl_get_write_guarantee", _wrap_bio_ctrl_get_write_guarantee, METH_O, NULL}, - { "bio_reset", _wrap_bio_reset, METH_O, NULL}, - { "bio_flush", _wrap_bio_flush, METH_O, NULL}, - { "bio_seek", _wrap_bio_seek, METH_VARARGS, NULL}, - { "bio_tell", _wrap_bio_tell, METH_O, NULL}, - { "bio_set_flags", _wrap_bio_set_flags, METH_VARARGS, NULL}, - { "bio_get_flags", _wrap_bio_get_flags, METH_O, NULL}, - { "bio_set_cipher", _wrap_bio_set_cipher, METH_VARARGS, NULL}, - { "bio_set_mem_eof_return", _wrap_bio_set_mem_eof_return, METH_VARARGS, NULL}, - { "bio_get_fd", _wrap_bio_get_fd, METH_O, NULL}, - { "bio_do_handshake", _wrap_bio_do_handshake, METH_O, NULL}, - { "bio_make_bio_pair", _wrap_bio_make_bio_pair, METH_VARARGS, NULL}, - { "bio_set_write_buf_size", _wrap_bio_set_write_buf_size, METH_VARARGS, NULL}, - { "bio_should_retry", _wrap_bio_should_retry, METH_O, NULL}, - { "bio_should_read", _wrap_bio_should_read, METH_O, NULL}, - { "bio_should_write", _wrap_bio_should_write, METH_O, NULL}, - { "pyfd_write", _wrap_pyfd_write, METH_VARARGS, NULL}, - { "pyfd_read", _wrap_pyfd_read, METH_VARARGS, NULL}, - { "pyfd_puts", _wrap_pyfd_puts, METH_VARARGS, NULL}, - { "pyfd_gets", _wrap_pyfd_gets, METH_VARARGS, NULL}, - { "pyfd_new", _wrap_pyfd_new, METH_O, NULL}, - { "pyfd_free", _wrap_pyfd_free, METH_O, NULL}, - { "pyfd_ctrl", _wrap_pyfd_ctrl, METH_VARARGS, NULL}, - { "bio_new_pyfd", _wrap_bio_new_pyfd, METH_VARARGS, NULL}, - { "bn_rand", _wrap_bn_rand, METH_VARARGS, NULL}, - { "bn_rand_range", _wrap_bn_rand_range, METH_O, NULL}, - { "rand_load_file", _wrap_rand_load_file, METH_VARARGS, NULL}, - { "rand_save_file", _wrap_rand_save_file, METH_O, NULL}, - { "rand_poll", _wrap_rand_poll, METH_NOARGS, NULL}, - { "rand_status", _wrap_rand_status, METH_NOARGS, NULL}, - { "rand_cleanup", _wrap_rand_cleanup, METH_NOARGS, NULL}, - { "rand_init", _wrap_rand_init, METH_O, NULL}, - { "rand_seed", _wrap_rand_seed, METH_O, NULL}, - { "rand_add", _wrap_rand_add, METH_VARARGS, NULL}, - { "rand_bytes", _wrap_rand_bytes, METH_O, NULL}, - { "rand_pseudo_bytes", _wrap_rand_pseudo_bytes, METH_O, NULL}, - { "rand_file_name", _wrap_rand_file_name, METH_VARARGS, NULL}, - { "rand_screen", _wrap_rand_screen, METH_NOARGS, NULL}, - { "rand_win32_event", _wrap_rand_win32_event, METH_VARARGS, NULL}, - { "md5", _wrap_md5, METH_NOARGS, NULL}, - { "sha1", _wrap_sha1, METH_NOARGS, NULL}, - { "ripemd160", _wrap_ripemd160, METH_NOARGS, NULL}, - { "sha224", _wrap_sha224, METH_NOARGS, NULL}, - { "sha256", _wrap_sha256, METH_NOARGS, NULL}, - { "sha384", _wrap_sha384, METH_NOARGS, NULL}, - { "sha512", _wrap_sha512, METH_NOARGS, NULL}, - { "digest_init", _wrap_digest_init, METH_VARARGS, NULL}, - { "des_ecb", _wrap_des_ecb, METH_NOARGS, NULL}, - { "des_ede_ecb", _wrap_des_ede_ecb, METH_NOARGS, NULL}, - { "des_ede3_ecb", _wrap_des_ede3_ecb, METH_NOARGS, NULL}, - { "des_cbc", _wrap_des_cbc, METH_NOARGS, NULL}, - { "des_ede_cbc", _wrap_des_ede_cbc, METH_NOARGS, NULL}, - { "des_ede3_cbc", _wrap_des_ede3_cbc, METH_NOARGS, NULL}, - { "des_cfb", _wrap_des_cfb, METH_NOARGS, NULL}, - { "des_ede_cfb", _wrap_des_ede_cfb, METH_NOARGS, NULL}, - { "des_ede3_cfb", _wrap_des_ede3_cfb, METH_NOARGS, NULL}, - { "des_ofb", _wrap_des_ofb, METH_NOARGS, NULL}, - { "des_ede_ofb", _wrap_des_ede_ofb, METH_NOARGS, NULL}, - { "des_ede3_ofb", _wrap_des_ede3_ofb, METH_NOARGS, NULL}, - { "bf_ecb", _wrap_bf_ecb, METH_NOARGS, NULL}, - { "bf_cbc", _wrap_bf_cbc, METH_NOARGS, NULL}, - { "bf_cfb", _wrap_bf_cfb, METH_NOARGS, NULL}, - { "bf_ofb", _wrap_bf_ofb, METH_NOARGS, NULL}, - { "cast5_ecb", _wrap_cast5_ecb, METH_NOARGS, NULL}, - { "cast5_cbc", _wrap_cast5_cbc, METH_NOARGS, NULL}, - { "cast5_cfb", _wrap_cast5_cfb, METH_NOARGS, NULL}, - { "cast5_ofb", _wrap_cast5_ofb, METH_NOARGS, NULL}, - { "rc4", _wrap_rc4, METH_NOARGS, NULL}, - { "rc2_40_cbc", _wrap_rc2_40_cbc, METH_NOARGS, NULL}, - { "aes_128_ecb", _wrap_aes_128_ecb, METH_NOARGS, NULL}, - { "aes_128_cbc", _wrap_aes_128_cbc, METH_NOARGS, NULL}, - { "aes_128_cfb", _wrap_aes_128_cfb, METH_NOARGS, NULL}, - { "aes_128_ofb", _wrap_aes_128_ofb, METH_NOARGS, NULL}, - { "aes_128_ctr", _wrap_aes_128_ctr, METH_NOARGS, NULL}, - { "aes_192_ecb", _wrap_aes_192_ecb, METH_NOARGS, NULL}, - { "aes_192_cbc", _wrap_aes_192_cbc, METH_NOARGS, NULL}, - { "aes_192_cfb", _wrap_aes_192_cfb, METH_NOARGS, NULL}, - { "aes_192_ofb", _wrap_aes_192_ofb, METH_NOARGS, NULL}, - { "aes_192_ctr", _wrap_aes_192_ctr, METH_NOARGS, NULL}, - { "aes_256_ecb", _wrap_aes_256_ecb, METH_NOARGS, NULL}, - { "aes_256_cbc", _wrap_aes_256_cbc, METH_NOARGS, NULL}, - { "aes_256_cfb", _wrap_aes_256_cfb, METH_NOARGS, NULL}, - { "aes_256_ofb", _wrap_aes_256_ofb, METH_NOARGS, NULL}, - { "aes_256_ctr", _wrap_aes_256_ctr, METH_NOARGS, NULL}, - { "cipher_set_padding", _wrap_cipher_set_padding, METH_VARARGS, NULL}, - { "pkey_free", _wrap_pkey_free, METH_O, NULL}, - { "pkey_assign", _wrap_pkey_assign, METH_VARARGS, NULL}, - { "pkey_assign_ec", _wrap_pkey_assign_ec, METH_VARARGS, NULL}, - { "pkey_set1_rsa", _wrap_pkey_set1_rsa, METH_VARARGS, NULL}, - { "sign_init", _wrap_sign_init, METH_VARARGS, NULL}, - { "verify_init", _wrap_verify_init, METH_VARARGS, NULL}, - { "pkey_size", _wrap_pkey_size, METH_O, NULL}, - { "evp_init", _wrap_evp_init, METH_O, NULL}, - { "pkey_get1_rsa", _wrap_pkey_get1_rsa, METH_O, NULL}, - { "pkcs5_pbkdf2_hmac_sha1", _wrap_pkcs5_pbkdf2_hmac_sha1, METH_VARARGS, NULL}, - { "md_ctx_new", _wrap_md_ctx_new, METH_NOARGS, NULL}, - { "md_ctx_free", _wrap_md_ctx_free, METH_O, NULL}, - { "digest_update", _wrap_digest_update, METH_VARARGS, NULL}, - { "digest_final", _wrap_digest_final, METH_O, NULL}, - { "hmac_ctx_new", _wrap_hmac_ctx_new, METH_NOARGS, NULL}, - { "hmac_ctx_free", _wrap_hmac_ctx_free, METH_O, NULL}, - { "hmac_init", _wrap_hmac_init, METH_VARARGS, NULL}, - { "hmac_update", _wrap_hmac_update, METH_VARARGS, NULL}, - { "hmac_final", _wrap_hmac_final, METH_O, NULL}, - { "hmac", _wrap_hmac, METH_VARARGS, NULL}, - { "cipher_ctx_new", _wrap_cipher_ctx_new, METH_NOARGS, NULL}, - { "cipher_ctx_free", _wrap_cipher_ctx_free, METH_O, NULL}, - { "bytes_to_key", _wrap_bytes_to_key, METH_VARARGS, NULL}, - { "cipher_init", _wrap_cipher_init, METH_VARARGS, NULL}, - { "cipher_update", _wrap_cipher_update, METH_VARARGS, NULL}, - { "cipher_final", _wrap_cipher_final, METH_O, NULL}, - { "sign_update", _wrap_sign_update, METH_VARARGS, NULL}, - { "sign_final", _wrap_sign_final, METH_VARARGS, NULL}, - { "verify_update", _wrap_verify_update, METH_VARARGS, NULL}, - { "verify_final", _wrap_verify_final, METH_VARARGS, NULL}, - { "digest_sign_init", _wrap_digest_sign_init, METH_VARARGS, NULL}, - { "digest_sign_update", _wrap_digest_sign_update, METH_VARARGS, NULL}, - { "digest_sign_final", _wrap_digest_sign_final, METH_O, NULL}, - { "digest_sign", _wrap_digest_sign, METH_VARARGS, NULL}, - { "digest_verify_init", _wrap_digest_verify_init, METH_VARARGS, NULL}, - { "digest_verify_update", _wrap_digest_verify_update, METH_VARARGS, NULL}, - { "digest_verify_final", _wrap_digest_verify_final, METH_VARARGS, NULL}, - { "digest_verify", _wrap_digest_verify, METH_VARARGS, NULL}, - { "get_digestbyname", _wrap_get_digestbyname, METH_O, NULL}, - { "pkey_write_pem_no_cipher", _wrap_pkey_write_pem_no_cipher, METH_VARARGS, NULL}, - { "pkey_write_pem", _wrap_pkey_write_pem, METH_VARARGS, NULL}, - { "pkey_new", _wrap_pkey_new, METH_NOARGS, NULL}, - { "pkey_read_pem", _wrap_pkey_read_pem, METH_VARARGS, NULL}, - { "pkey_read_pem_pubkey", _wrap_pkey_read_pem_pubkey, METH_VARARGS, NULL}, - { "pkey_assign_rsa", _wrap_pkey_assign_rsa, METH_VARARGS, NULL}, - { "pkey_as_der", _wrap_pkey_as_der, METH_O, NULL}, - { "pkey_get_modulus", _wrap_pkey_get_modulus, METH_O, NULL}, - { "aes_new", _wrap_aes_new, METH_NOARGS, NULL}, - { "AES_free", _wrap_AES_free, METH_O, NULL}, - { "AES_set_key", _wrap_AES_set_key, METH_VARARGS, NULL}, - { "AES_crypt", _wrap_AES_crypt, METH_VARARGS, NULL}, - { "AES_type_check", _wrap_AES_type_check, METH_O, NULL}, - { "rc4_new", _wrap_rc4_new, METH_NOARGS, NULL}, - { "rc4_free", _wrap_rc4_free, METH_O, NULL}, - { "rc4_set_key", _wrap_rc4_set_key, METH_VARARGS, NULL}, - { "rc4_update", _wrap_rc4_update, METH_VARARGS, NULL}, - { "rc4_type_check", _wrap_rc4_type_check, METH_O, NULL}, - { "dh_new", _wrap_dh_new, METH_NOARGS, NULL}, - { "dh_free", _wrap_dh_free, METH_O, NULL}, - { "dh_size", _wrap_dh_size, METH_O, NULL}, - { "dh_generate_key", _wrap_dh_generate_key, METH_O, NULL}, - { "dhparams_print", _wrap_dhparams_print, METH_VARARGS, NULL}, - { "dh_init", _wrap_dh_init, METH_O, NULL}, - { "dh_type_check", _wrap_dh_type_check, METH_O, NULL}, - { "dh_read_parameters", _wrap_dh_read_parameters, METH_O, NULL}, - { "dh_generate_parameters", _wrap_dh_generate_parameters, METH_VARARGS, NULL}, - { "dh_check", _wrap_dh_check, METH_O, NULL}, - { "dh_compute_key", _wrap_dh_compute_key, METH_VARARGS, NULL}, - { "dh_get_p", _wrap_dh_get_p, METH_O, NULL}, - { "dh_get_g", _wrap_dh_get_g, METH_O, NULL}, - { "dh_get_pub", _wrap_dh_get_pub, METH_O, NULL}, - { "dh_get_priv", _wrap_dh_get_priv, METH_O, NULL}, - { "dh_set_pg", _wrap_dh_set_pg, METH_VARARGS, NULL}, - { "rsa_size", _wrap_rsa_size, METH_O, NULL}, - { "rsa_new", _wrap_rsa_new, METH_NOARGS, NULL}, - { "rsa_free", _wrap_rsa_free, METH_O, NULL}, - { "rsa_check_key", _wrap_rsa_check_key, METH_O, NULL}, - { "rsa_init", _wrap_rsa_init, METH_O, NULL}, - { "rsa_read_key", _wrap_rsa_read_key, METH_VARARGS, NULL}, - { "rsa_write_key", _wrap_rsa_write_key, METH_VARARGS, NULL}, - { "rsa_write_key_no_cipher", _wrap_rsa_write_key_no_cipher, METH_VARARGS, NULL}, - { "rsa_read_pub_key", _wrap_rsa_read_pub_key, METH_O, NULL}, - { "rsa_write_pub_key", _wrap_rsa_write_pub_key, METH_VARARGS, NULL}, - { "rsa_get_e", _wrap_rsa_get_e, METH_O, NULL}, - { "rsa_get_n", _wrap_rsa_get_n, METH_O, NULL}, - { "rsa_set_e", _wrap_rsa_set_e, METH_VARARGS, NULL}, - { "rsa_set_n", _wrap_rsa_set_n, METH_VARARGS, NULL}, - { "rsa_set_en", _wrap_rsa_set_en, METH_VARARGS, NULL}, - { "PyObject_Bin_AsBIGNUM", _wrap_PyObject_Bin_AsBIGNUM, METH_O, NULL}, - { "rsa_set_en_bin", _wrap_rsa_set_en_bin, METH_VARARGS, NULL}, - { "rsa_private_encrypt", _wrap_rsa_private_encrypt, METH_VARARGS, NULL}, - { "rsa_public_decrypt", _wrap_rsa_public_decrypt, METH_VARARGS, NULL}, - { "rsa_public_encrypt", _wrap_rsa_public_encrypt, METH_VARARGS, NULL}, - { "rsa_private_decrypt", _wrap_rsa_private_decrypt, METH_VARARGS, NULL}, - { "rsa_padding_add_pkcs1_pss", _wrap_rsa_padding_add_pkcs1_pss, METH_VARARGS, NULL}, - { "rsa_verify_pkcs1_pss", _wrap_rsa_verify_pkcs1_pss, METH_VARARGS, NULL}, - { "rsa_sign", _wrap_rsa_sign, METH_VARARGS, NULL}, - { "rsa_verify", _wrap_rsa_verify, METH_VARARGS, NULL}, - { "rsa_generate_key", _wrap_rsa_generate_key, METH_VARARGS, NULL}, - { "rsa_type_check", _wrap_rsa_type_check, METH_O, NULL}, - { "rsa_check_pub_key", _wrap_rsa_check_pub_key, METH_O, NULL}, - { "rsa_write_key_der", _wrap_rsa_write_key_der, METH_VARARGS, NULL}, - { "dsa_new", _wrap_dsa_new, METH_NOARGS, NULL}, - { "dsa_free", _wrap_dsa_free, METH_O, NULL}, - { "dsa_size", _wrap_dsa_size, METH_O, NULL}, - { "dsa_gen_key", _wrap_dsa_gen_key, METH_O, NULL}, - { "dsa_init", _wrap_dsa_init, METH_O, NULL}, - { "dsa_generate_parameters", _wrap_dsa_generate_parameters, METH_VARARGS, NULL}, - { "dsa_read_params", _wrap_dsa_read_params, METH_VARARGS, NULL}, - { "dsa_read_key", _wrap_dsa_read_key, METH_VARARGS, NULL}, - { "dsa_read_pub_key", _wrap_dsa_read_pub_key, METH_VARARGS, NULL}, - { "dsa_get_p", _wrap_dsa_get_p, METH_O, NULL}, - { "dsa_get_q", _wrap_dsa_get_q, METH_O, NULL}, - { "dsa_get_g", _wrap_dsa_get_g, METH_O, NULL}, - { "dsa_get_pub", _wrap_dsa_get_pub, METH_O, NULL}, - { "dsa_get_priv", _wrap_dsa_get_priv, METH_O, NULL}, - { "dsa_set_pqg", _wrap_dsa_set_pqg, METH_VARARGS, NULL}, - { "dsa_set_pub", _wrap_dsa_set_pub, METH_VARARGS, NULL}, - { "dsa_write_params_bio", _wrap_dsa_write_params_bio, METH_VARARGS, NULL}, - { "dsa_write_key_bio", _wrap_dsa_write_key_bio, METH_VARARGS, NULL}, - { "dsa_write_key_bio_no_cipher", _wrap_dsa_write_key_bio_no_cipher, METH_VARARGS, NULL}, - { "dsa_write_pub_key_bio", _wrap_dsa_write_pub_key_bio, METH_VARARGS, NULL}, - { "dsa_sign", _wrap_dsa_sign, METH_VARARGS, NULL}, - { "dsa_verify", _wrap_dsa_verify, METH_VARARGS, NULL}, - { "dsa_sign_asn1", _wrap_dsa_sign_asn1, METH_VARARGS, NULL}, - { "dsa_verify_asn1", _wrap_dsa_verify_asn1, METH_VARARGS, NULL}, - { "dsa_check_key", _wrap_dsa_check_key, METH_O, NULL}, - { "dsa_check_pub_key", _wrap_dsa_check_pub_key, METH_O, NULL}, - { "dsa_keylen", _wrap_dsa_keylen, METH_O, NULL}, - { "dsa_type_check", _wrap_dsa_type_check, METH_O, NULL}, - { "ssl_get_ciphers", _wrap_ssl_get_ciphers, METH_O, NULL}, - { "ssl_get_version", _wrap_ssl_get_version, METH_O, NULL}, - { "ssl_get_error", _wrap_ssl_get_error, METH_VARARGS, NULL}, - { "ssl_get_state", _wrap_ssl_get_state, METH_O, NULL}, - { "ssl_get_state_v", _wrap_ssl_get_state_v, METH_O, NULL}, - { "ssl_get_alert_type", _wrap_ssl_get_alert_type, METH_O, NULL}, - { "ssl_get_alert_type_v", _wrap_ssl_get_alert_type_v, METH_O, NULL}, - { "ssl_get_alert_desc", _wrap_ssl_get_alert_desc, METH_O, NULL}, - { "ssl_get_alert_desc_v", _wrap_ssl_get_alert_desc_v, METH_O, NULL}, - { "sslv23_method", _wrap_sslv23_method, METH_NOARGS, NULL}, - { "ssl_ctx_new", _wrap_ssl_ctx_new, METH_O, NULL}, - { "ssl_ctx_free", _wrap_ssl_ctx_free, METH_O, NULL}, - { "ssl_ctx_set_verify_depth", _wrap_ssl_ctx_set_verify_depth, METH_VARARGS, NULL}, - { "ssl_ctx_get_verify_depth", _wrap_ssl_ctx_get_verify_depth, METH_O, NULL}, - { "ssl_ctx_get_verify_mode", _wrap_ssl_ctx_get_verify_mode, METH_O, NULL}, - { "ssl_ctx_set_cipher_list", _wrap_ssl_ctx_set_cipher_list, METH_VARARGS, NULL}, - { "ssl_ctx_add_session", _wrap_ssl_ctx_add_session, METH_VARARGS, NULL}, - { "ssl_ctx_remove_session", _wrap_ssl_ctx_remove_session, METH_VARARGS, NULL}, - { "ssl_ctx_set_session_timeout", _wrap_ssl_ctx_set_session_timeout, METH_VARARGS, NULL}, - { "ssl_ctx_get_session_timeout", _wrap_ssl_ctx_get_session_timeout, METH_O, NULL}, - { "ssl_ctx_get_cert_store", _wrap_ssl_ctx_get_cert_store, METH_O, NULL}, - { "ssl_ctx_set_default_verify_paths", _wrap_ssl_ctx_set_default_verify_paths, METH_O, NULL}, - { "ssl_get_ex_data_x509_store_ctx_idx", _wrap_ssl_get_ex_data_x509_store_ctx_idx, METH_NOARGS, NULL}, - { "bio_new_ssl", _wrap_bio_new_ssl, METH_VARARGS, NULL}, - { "ssl_new", _wrap_ssl_new, METH_O, NULL}, - { "ssl_free", _wrap_ssl_free, METH_O, NULL}, - { "ssl_dup", _wrap_ssl_dup, METH_O, NULL}, - { "ssl_set_bio", _wrap_ssl_set_bio, METH_VARARGS, NULL}, - { "ssl_set_accept_state", _wrap_ssl_set_accept_state, METH_O, NULL}, - { "ssl_set_connect_state", _wrap_ssl_set_connect_state, METH_O, NULL}, - { "ssl_get_shutdown", _wrap_ssl_get_shutdown, METH_O, NULL}, - { "ssl_set_shutdown", _wrap_ssl_set_shutdown, METH_VARARGS, NULL}, - { "ssl_shutdown", _wrap_ssl_shutdown, METH_O, NULL}, - { "ssl_clear", _wrap_ssl_clear, METH_O, NULL}, - { "ssl_do_handshake", _wrap_ssl_do_handshake, METH_O, NULL}, - { "ssl_renegotiate", _wrap_ssl_renegotiate, METH_O, NULL}, - { "ssl_pending", _wrap_ssl_pending, METH_O, NULL}, - { "ssl_get_peer_cert", _wrap_ssl_get_peer_cert, METH_O, NULL}, - { "ssl_get_current_cipher", _wrap_ssl_get_current_cipher, METH_O, NULL}, - { "ssl_get_verify_mode", _wrap_ssl_get_verify_mode, METH_O, NULL}, - { "ssl_get_verify_depth", _wrap_ssl_get_verify_depth, METH_O, NULL}, - { "ssl_get_verify_result", _wrap_ssl_get_verify_result, METH_O, NULL}, - { "ssl_get_ssl_ctx", _wrap_ssl_get_ssl_ctx, METH_O, NULL}, - { "ssl_get_default_session_timeout", _wrap_ssl_get_default_session_timeout, METH_O, NULL}, - { "ssl_set_cipher_list", _wrap_ssl_set_cipher_list, METH_VARARGS, NULL}, - { "ssl_get_cipher_list", _wrap_ssl_get_cipher_list, METH_VARARGS, NULL}, - { "ssl_cipher_get_name", _wrap_ssl_cipher_get_name, METH_O, NULL}, - { "ssl_cipher_get_version", _wrap_ssl_cipher_get_version, METH_O, NULL}, - { "ssl_get_session", _wrap_ssl_get_session, METH_O, NULL}, - { "ssl_get1_session", _wrap_ssl_get1_session, METH_O, NULL}, - { "ssl_set_session", _wrap_ssl_set_session, METH_VARARGS, NULL}, - { "ssl_session_free", _wrap_ssl_session_free, METH_O, NULL}, - { "ssl_session_print", _wrap_ssl_session_print, METH_VARARGS, NULL}, - { "ssl_session_set_timeout", _wrap_ssl_session_set_timeout, METH_VARARGS, NULL}, - { "ssl_session_get_timeout", _wrap_ssl_session_get_timeout, METH_O, NULL}, - { "ssl_accept", _wrap_ssl_accept, METH_VARARGS, NULL}, - { "ssl_connect", _wrap_ssl_connect, METH_VARARGS, NULL}, - { "ssl_read", _wrap_ssl_read, METH_VARARGS, NULL}, - { "ssl_write", _wrap_ssl_write, METH_VARARGS, NULL}, - { "ssl_init", _wrap_ssl_init, METH_VARARGS, NULL}, - { "tlsv1_method", _wrap_tlsv1_method, METH_NOARGS, NULL}, - { "ssl_ctx_passphrase_callback", _wrap_ssl_ctx_passphrase_callback, METH_VARARGS, NULL}, - { "ssl_ctx_use_x509", _wrap_ssl_ctx_use_x509, METH_VARARGS, NULL}, - { "ssl_ctx_use_cert", _wrap_ssl_ctx_use_cert, METH_VARARGS, NULL}, - { "ssl_ctx_use_cert_chain", _wrap_ssl_ctx_use_cert_chain, METH_VARARGS, NULL}, - { "ssl_ctx_use_privkey", _wrap_ssl_ctx_use_privkey, METH_VARARGS, NULL}, - { "ssl_ctx_use_rsa_privkey", _wrap_ssl_ctx_use_rsa_privkey, METH_VARARGS, NULL}, - { "ssl_ctx_use_pkey_privkey", _wrap_ssl_ctx_use_pkey_privkey, METH_VARARGS, NULL}, - { "ssl_ctx_check_privkey", _wrap_ssl_ctx_check_privkey, METH_O, NULL}, - { "ssl_ctx_set_client_CA_list_from_file", _wrap_ssl_ctx_set_client_CA_list_from_file, METH_VARARGS, NULL}, - { "ssl_ctx_set_verify_default", _wrap_ssl_ctx_set_verify_default, METH_VARARGS, NULL}, - { "ssl_ctx_set_verify", _wrap_ssl_ctx_set_verify, METH_VARARGS, NULL}, - { "ssl_ctx_set_session_id_context", _wrap_ssl_ctx_set_session_id_context, METH_VARARGS, NULL}, - { "ssl_ctx_set_info_callback", _wrap_ssl_ctx_set_info_callback, METH_VARARGS, NULL}, - { "ssl_ctx_set_tmp_dh", _wrap_ssl_ctx_set_tmp_dh, METH_VARARGS, NULL}, - { "ssl_ctx_set_tmp_dh_callback", _wrap_ssl_ctx_set_tmp_dh_callback, METH_VARARGS, NULL}, - { "ssl_ctx_set_tmp_rsa", _wrap_ssl_ctx_set_tmp_rsa, METH_VARARGS, NULL}, - { "ssl_ctx_set_tmp_rsa_callback", _wrap_ssl_ctx_set_tmp_rsa_callback, METH_VARARGS, NULL}, - { "ssl_ctx_load_verify_locations", _wrap_ssl_ctx_load_verify_locations, METH_VARARGS, NULL}, - { "ssl_ctx_set_options", _wrap_ssl_ctx_set_options, METH_VARARGS, NULL}, - { "bio_set_ssl", _wrap_bio_set_ssl, METH_VARARGS, NULL}, - { "ssl_set_mode", _wrap_ssl_set_mode, METH_VARARGS, NULL}, - { "ssl_get_mode", _wrap_ssl_get_mode, METH_O, NULL}, - { "ssl_set_tlsext_host_name", _wrap_ssl_set_tlsext_host_name, METH_VARARGS, NULL}, - { "ssl_set_client_CA_list_from_file", _wrap_ssl_set_client_CA_list_from_file, METH_VARARGS, NULL}, - { "ssl_set_client_CA_list_from_context", _wrap_ssl_set_client_CA_list_from_context, METH_VARARGS, NULL}, - { "ssl_set_session_id_context", _wrap_ssl_set_session_id_context, METH_VARARGS, NULL}, - { "ssl_set_fd", _wrap_ssl_set_fd, METH_VARARGS, NULL}, - { "ssl_set_shutdown1", _wrap_ssl_set_shutdown1, METH_VARARGS, NULL}, - { "ssl_read_nbio", _wrap_ssl_read_nbio, METH_VARARGS, NULL}, - { "ssl_write_nbio", _wrap_ssl_write_nbio, METH_VARARGS, NULL}, - { "ssl_cipher_get_bits", _wrap_ssl_cipher_get_bits, METH_O, NULL}, - { "sk_ssl_cipher_num", _wrap_sk_ssl_cipher_num, METH_O, NULL}, - { "sk_ssl_cipher_value", _wrap_sk_ssl_cipher_value, METH_VARARGS, NULL}, - { "ssl_get_peer_cert_chain", _wrap_ssl_get_peer_cert_chain, METH_O, NULL}, - { "sk_x509_num", _wrap_sk_x509_num, METH_O, NULL}, - { "sk_x509_value", _wrap_sk_x509_value, METH_VARARGS, NULL}, - { "i2d_ssl_session", _wrap_i2d_ssl_session, METH_VARARGS, NULL}, - { "ssl_session_read_pem", _wrap_ssl_session_read_pem, METH_O, NULL}, - { "ssl_session_write_pem", _wrap_ssl_session_write_pem, METH_VARARGS, NULL}, - { "ssl_ctx_set_session_cache_mode", _wrap_ssl_ctx_set_session_cache_mode, METH_VARARGS, NULL}, - { "ssl_ctx_get_session_cache_mode", _wrap_ssl_ctx_get_session_cache_mode, METH_O, NULL}, - { "ssl_ctx_set_cache_size", _wrap_ssl_ctx_set_cache_size, METH_VARARGS, NULL}, - { "ssl_is_init_finished", _wrap_ssl_is_init_finished, METH_O, NULL}, - { "x509_check_ca", _wrap_x509_check_ca, METH_O, NULL}, - { "x509_new", _wrap_x509_new, METH_NOARGS, NULL}, - { "x509_dup", _wrap_x509_dup, METH_O, NULL}, - { "x509_free", _wrap_x509_free, METH_O, NULL}, - { "x509_crl_free", _wrap_x509_crl_free, METH_O, NULL}, - { "x509_crl_new", _wrap_x509_crl_new, METH_NOARGS, NULL}, - { "x509_print", _wrap_x509_print, METH_VARARGS, NULL}, - { "x509_crl_print", _wrap_x509_crl_print, METH_VARARGS, NULL}, - { "x509_get_serial_number", _wrap_x509_get_serial_number, METH_O, NULL}, - { "x509_set_serial_number", _wrap_x509_set_serial_number, METH_VARARGS, NULL}, - { "x509_get_pubkey", _wrap_x509_get_pubkey, METH_O, NULL}, - { "x509_set_pubkey", _wrap_x509_set_pubkey, METH_VARARGS, NULL}, - { "x509_get_issuer_name", _wrap_x509_get_issuer_name, METH_O, NULL}, - { "x509_set_issuer_name", _wrap_x509_set_issuer_name, METH_VARARGS, NULL}, - { "x509_get_subject_name", _wrap_x509_get_subject_name, METH_O, NULL}, - { "x509_set_subject_name", _wrap_x509_set_subject_name, METH_VARARGS, NULL}, - { "x509_cmp_current_time", _wrap_x509_cmp_current_time, METH_O, NULL}, - { "x509_check_purpose", _wrap_x509_check_purpose, METH_VARARGS, NULL}, - { "x509_check_trust", _wrap_x509_check_trust, METH_VARARGS, NULL}, - { "x509_write_pem", _wrap_x509_write_pem, METH_VARARGS, NULL}, - { "x509_write_pem_file", _wrap_x509_write_pem_file, METH_VARARGS, NULL}, - { "x509_verify", _wrap_x509_verify, METH_VARARGS, NULL}, - { "x509_get_verify_error", _wrap_x509_get_verify_error, METH_O, NULL}, - { "x509_add_ext", _wrap_x509_add_ext, METH_VARARGS, NULL}, - { "x509_get_ext_count", _wrap_x509_get_ext_count, METH_O, NULL}, - { "x509_get_ext", _wrap_x509_get_ext, METH_VARARGS, NULL}, - { "x509_ext_print", _wrap_x509_ext_print, METH_VARARGS, NULL}, - { "x509_name_new", _wrap_x509_name_new, METH_NOARGS, NULL}, - { "x509_name_free", _wrap_x509_name_free, METH_O, NULL}, - { "x509_name_print", _wrap_x509_name_print, METH_VARARGS, NULL}, - { "x509_name_get_entry", _wrap_x509_name_get_entry, METH_VARARGS, NULL}, - { "x509_name_entry_count", _wrap_x509_name_entry_count, METH_O, NULL}, - { "x509_name_delete_entry", _wrap_x509_name_delete_entry, METH_VARARGS, NULL}, - { "x509_name_add_entry", _wrap_x509_name_add_entry, METH_VARARGS, NULL}, - { "x509_name_add_entry_by_obj", _wrap_x509_name_add_entry_by_obj, METH_VARARGS, NULL}, - { "x509_name_add_entry_by_nid", _wrap_x509_name_add_entry_by_nid, METH_VARARGS, NULL}, - { "x509_name_print_ex", _wrap_x509_name_print_ex, METH_VARARGS, NULL}, - { "x509_name_hash", _wrap_x509_name_hash, METH_O, NULL}, - { "x509_name_get_index_by_nid", _wrap_x509_name_get_index_by_nid, METH_VARARGS, NULL}, - { "x509_name_entry_new", _wrap_x509_name_entry_new, METH_NOARGS, NULL}, - { "x509_name_entry_free", _wrap_x509_name_entry_free, METH_O, NULL}, - { "x509_name_entry_create_by_nid", _wrap_x509_name_entry_create_by_nid, METH_VARARGS, NULL}, - { "x509_name_entry_set_object", _wrap_x509_name_entry_set_object, METH_VARARGS, NULL}, - { "x509_name_entry_get_object", _wrap_x509_name_entry_get_object, METH_O, NULL}, - { "x509_name_entry_get_data", _wrap_x509_name_entry_get_data, METH_O, NULL}, - { "x509_name_entry_set_data", _wrap_x509_name_entry_set_data, METH_VARARGS, NULL}, - { "x509_req_new", _wrap_x509_req_new, METH_NOARGS, NULL}, - { "x509_req_free", _wrap_x509_req_free, METH_O, NULL}, - { "x509_req_print", _wrap_x509_req_print, METH_VARARGS, NULL}, - { "x509_req_get_pubkey", _wrap_x509_req_get_pubkey, METH_O, NULL}, - { "x509_req_set_pubkey", _wrap_x509_req_set_pubkey, METH_VARARGS, NULL}, - { "x509_req_set_subject_name", _wrap_x509_req_set_subject_name, METH_VARARGS, NULL}, - { "x509_req_verify", _wrap_x509_req_verify, METH_VARARGS, NULL}, - { "x509_req_sign", _wrap_x509_req_sign, METH_VARARGS, NULL}, - { "i2d_x509_bio", _wrap_i2d_x509_bio, METH_VARARGS, NULL}, - { "i2d_x509_req_bio", _wrap_i2d_x509_req_bio, METH_VARARGS, NULL}, - { "x509_store_new", _wrap_x509_store_new, METH_NOARGS, NULL}, - { "x509_store_free", _wrap_x509_store_free, METH_O, NULL}, - { "x509_store_add_cert", _wrap_x509_store_add_cert, METH_VARARGS, NULL}, - { "x509_store_ctx_get_current_cert", _wrap_x509_store_ctx_get_current_cert, METH_O, NULL}, - { "x509_store_ctx_get_error", _wrap_x509_store_ctx_get_error, METH_O, NULL}, - { "x509_store_ctx_get_error_depth", _wrap_x509_store_ctx_get_error_depth, METH_O, NULL}, - { "x509_store_ctx_free", _wrap_x509_store_ctx_free, METH_O, NULL}, - { "x509_store_ctx_get1_chain", _wrap_x509_store_ctx_get1_chain, METH_O, NULL}, - { "x509_extension_get_critical", _wrap_x509_extension_get_critical, METH_O, NULL}, - { "x509_extension_set_critical", _wrap_x509_extension_set_critical, METH_VARARGS, NULL}, - { "x509_store_set_flags", _wrap_x509_store_set_flags, METH_VARARGS, NULL}, - { "x509_read_pem", _wrap_x509_read_pem, METH_O, NULL}, - { "d2i_x509", _wrap_d2i_x509, METH_O, NULL}, - { "x509_init", _wrap_x509_init, METH_O, NULL}, - { "d2i_x509_req", _wrap_d2i_x509_req, METH_O, NULL}, - { "x509_req_read_pem", _wrap_x509_req_read_pem, METH_O, NULL}, - { "i2d_x509", _wrap_i2d_x509, METH_O, NULL}, - { "x509_req_write_pem", _wrap_x509_req_write_pem, METH_VARARGS, NULL}, - { "x509_crl_read_pem", _wrap_x509_crl_read_pem, METH_O, NULL}, - { "x509_set_version", _wrap_x509_set_version, METH_VARARGS, NULL}, - { "x509_get_version", _wrap_x509_get_version, METH_O, NULL}, - { "x509_set_not_before", _wrap_x509_set_not_before, METH_VARARGS, NULL}, - { "x509_get_not_before", _wrap_x509_get_not_before, METH_O, NULL}, - { "x509_set_not_after", _wrap_x509_set_not_after, METH_VARARGS, NULL}, - { "x509_get_not_after", _wrap_x509_get_not_after, METH_O, NULL}, - { "x509_sign", _wrap_x509_sign, METH_VARARGS, NULL}, - { "x509_gmtime_adj", _wrap_x509_gmtime_adj, METH_VARARGS, NULL}, - { "x509_name_by_nid", _wrap_x509_name_by_nid, METH_VARARGS, NULL}, - { "x509_name_set_by_nid", _wrap_x509_name_set_by_nid, METH_VARARGS, NULL}, - { "x509_name_add_entry_by_txt", _wrap_x509_name_add_entry_by_txt, METH_VARARGS, NULL}, - { "x509_name_get_der", _wrap_x509_name_get_der, METH_O, NULL}, - { "sk_x509_free", _wrap_sk_x509_free, METH_O, NULL}, - { "sk_x509_push", _wrap_sk_x509_push, METH_VARARGS, NULL}, - { "sk_x509_pop", _wrap_sk_x509_pop, METH_O, NULL}, - { "x509_store_load_locations", _wrap_x509_store_load_locations, METH_VARARGS, NULL}, - { "x509_type_check", _wrap_x509_type_check, METH_O, NULL}, - { "x509_name_type_check", _wrap_x509_name_type_check, METH_O, NULL}, - { "x509_req_get_subject_name", _wrap_x509_req_get_subject_name, METH_O, NULL}, - { "x509_req_get_version", _wrap_x509_req_get_version, METH_O, NULL}, - { "x509_req_set_version", _wrap_x509_req_set_version, METH_VARARGS, NULL}, - { "x509_req_add_extensions", _wrap_x509_req_add_extensions, METH_VARARGS, NULL}, - { "x509_name_entry_create_by_txt", _wrap_x509_name_entry_create_by_txt, METH_VARARGS, NULL}, - { "x509v3_set_nconf", _wrap_x509v3_set_nconf, METH_NOARGS, NULL}, - { "x509v3_ext_conf", _wrap_x509v3_ext_conf, METH_VARARGS, NULL}, - { "x509_extension_free", _wrap_x509_extension_free, METH_O, NULL}, - { "x509_extension_get_name", _wrap_x509_extension_get_name, METH_O, NULL}, - { "sk_x509_extension_new_null", _wrap_sk_x509_extension_new_null, METH_NOARGS, NULL}, - { "sk_x509_extension_free", _wrap_sk_x509_extension_free, METH_O, NULL}, - { "sk_x509_extension_push", _wrap_sk_x509_extension_push, METH_VARARGS, NULL}, - { "sk_x509_extension_pop", _wrap_sk_x509_extension_pop, METH_O, NULL}, - { "sk_x509_extension_num", _wrap_sk_x509_extension_num, METH_O, NULL}, - { "sk_x509_extension_value", _wrap_sk_x509_extension_value, METH_VARARGS, NULL}, - { "x509_store_ctx_get_app_data", _wrap_x509_store_ctx_get_app_data, METH_O, NULL}, - { "x509_store_ctx_get_ex_data", _wrap_x509_store_ctx_get_ex_data, METH_VARARGS, NULL}, - { "x509_store_set_verify_cb", _wrap_x509_store_set_verify_cb, METH_VARARGS, NULL}, - { "make_stack_from_der_sequence", _wrap_make_stack_from_der_sequence, METH_O, NULL}, - { "sk_x509_new_null", _wrap_sk_x509_new_null, METH_NOARGS, NULL}, - { "get_der_encoding_stack", _wrap_get_der_encoding_stack, METH_O, NULL}, - { "x509_name_oneline", _wrap_x509_name_oneline, METH_O, NULL}, - { "asn1_object_new", _wrap_asn1_object_new, METH_NOARGS, NULL}, - { "asn1_object_create", _wrap_asn1_object_create, METH_VARARGS, NULL}, - { "asn1_object_free", _wrap_asn1_object_free, METH_O, NULL}, - { "i2d_asn1_object", _wrap_i2d_asn1_object, METH_VARARGS, NULL}, - { "d2i_asn1_object", _wrap_d2i_asn1_object, METH_VARARGS, NULL}, - { "asn1_bit_string_new", _wrap_asn1_bit_string_new, METH_NOARGS, NULL}, - { "asn1_string_new", _wrap_asn1_string_new, METH_NOARGS, NULL}, - { "asn1_string_free", _wrap_asn1_string_free, METH_O, NULL}, - { "asn1_string_set", _wrap_asn1_string_set, METH_VARARGS, NULL}, - { "asn1_string_print", _wrap_asn1_string_print, METH_VARARGS, NULL}, - { "asn1_string_print_ex", _wrap_asn1_string_print_ex, METH_VARARGS, NULL}, - { "asn1_time_new", _wrap_asn1_time_new, METH_NOARGS, NULL}, - { "asn1_time_free", _wrap_asn1_time_free, METH_O, NULL}, - { "asn1_time_check", _wrap_asn1_time_check, METH_O, NULL}, - { "asn1_time_set", _wrap_asn1_time_set, METH_VARARGS, NULL}, - { "asn1_time_set_string", _wrap_asn1_time_set_string, METH_VARARGS, NULL}, - { "asn1_time_print", _wrap_asn1_time_print, METH_VARARGS, NULL}, - { "asn1_integer_new", _wrap_asn1_integer_new, METH_NOARGS, NULL}, - { "asn1_integer_free", _wrap_asn1_integer_free, METH_O, NULL}, - { "asn1_integer_cmp", _wrap_asn1_integer_cmp, METH_VARARGS, NULL}, - { "asn1_time_type_check", _wrap_asn1_time_type_check, METH_O, NULL}, - { "asn1_integer_get", _wrap_asn1_integer_get, METH_O, NULL}, - { "asn1_integer_set", _wrap_asn1_integer_set, METH_VARARGS, NULL}, - { "pkcs7_new", _wrap_pkcs7_new, METH_NOARGS, NULL}, - { "pkcs7_free", _wrap_pkcs7_free, METH_O, NULL}, - { "pkcs7_add_certificate", _wrap_pkcs7_add_certificate, METH_VARARGS, NULL}, - { "pkcs7_init", _wrap_pkcs7_init, METH_O, NULL}, - { "smime_init", _wrap_smime_init, METH_O, NULL}, - { "pkcs7_decrypt", _wrap_pkcs7_decrypt, METH_VARARGS, NULL}, - { "pkcs7_encrypt", _wrap_pkcs7_encrypt, METH_VARARGS, NULL}, - { "pkcs7_sign1", _wrap_pkcs7_sign1, METH_VARARGS, NULL}, - { "pkcs7_sign0", _wrap_pkcs7_sign0, METH_VARARGS, NULL}, - { "pkcs7_read_bio", _wrap_pkcs7_read_bio, METH_O, NULL}, - { "pkcs7_read_bio_der", _wrap_pkcs7_read_bio_der, METH_O, NULL}, - { "pkcs7_verify1", _wrap_pkcs7_verify1, METH_VARARGS, NULL}, - { "pkcs7_verify0", _wrap_pkcs7_verify0, METH_VARARGS, NULL}, - { "smime_write_pkcs7_multi", _wrap_smime_write_pkcs7_multi, METH_VARARGS, NULL}, - { "smime_write_pkcs7", _wrap_smime_write_pkcs7, METH_VARARGS, NULL}, - { "smime_read_pkcs7", _wrap_smime_read_pkcs7, METH_O, NULL}, - { "pkcs7_write_bio", _wrap_pkcs7_write_bio, METH_VARARGS, NULL}, - { "pkcs7_write_bio_der", _wrap_pkcs7_write_bio_der, METH_VARARGS, NULL}, - { "pkcs7_type_nid", _wrap_pkcs7_type_nid, METH_O, NULL}, - { "pkcs7_type_sn", _wrap_pkcs7_type_sn, METH_O, NULL}, - { "smime_crlf_copy", _wrap_smime_crlf_copy, METH_VARARGS, NULL}, - { "pkcs7_get0_signers", _wrap_pkcs7_get0_signers, METH_VARARGS, NULL}, - { "util_init", _wrap_util_init, METH_O, NULL}, - { "util_hex_to_string", _wrap_util_hex_to_string, METH_O, NULL}, - { "util_string_to_hex", _wrap_util_string_to_hex, METH_O, NULL}, - { "ec_key_new", _wrap_ec_key_new, METH_NOARGS, NULL}, - { "ec_key_free", _wrap_ec_key_free, METH_O, NULL}, - { "ec_key_size", _wrap_ec_key_size, METH_O, NULL}, - { "ec_key_gen_key", _wrap_ec_key_gen_key, METH_O, NULL}, - { "ec_key_check_key", _wrap_ec_key_check_key, METH_O, NULL}, - { "ec_init", _wrap_ec_init, METH_O, NULL}, - { "ec_get_builtin_curves", _wrap_ec_get_builtin_curves, METH_NOARGS, NULL}, - { "ec_key_new_by_curve_name", _wrap_ec_key_new_by_curve_name, METH_O, NULL}, - { "ec_key_get_public_der", _wrap_ec_key_get_public_der, METH_O, NULL}, - { "ec_key_get_public_key", _wrap_ec_key_get_public_key, METH_O, NULL}, - { "ec_key_read_pubkey", _wrap_ec_key_read_pubkey, METH_O, NULL}, - { "ec_key_write_pubkey", _wrap_ec_key_write_pubkey, METH_VARARGS, NULL}, - { "ec_key_read_bio", _wrap_ec_key_read_bio, METH_VARARGS, NULL}, - { "ec_key_write_bio", _wrap_ec_key_write_bio, METH_VARARGS, NULL}, - { "ec_key_write_bio_no_cipher", _wrap_ec_key_write_bio_no_cipher, METH_VARARGS, NULL}, - { "ecdsa_sig_get_r", _wrap_ecdsa_sig_get_r, METH_O, NULL}, - { "ecdsa_sig_get_s", _wrap_ecdsa_sig_get_s, METH_O, NULL}, - { "ecdsa_sign", _wrap_ecdsa_sign, METH_VARARGS, NULL}, - { "ecdsa_verify", _wrap_ecdsa_verify, METH_VARARGS, NULL}, - { "ecdsa_sign_asn1", _wrap_ecdsa_sign_asn1, METH_VARARGS, NULL}, - { "ecdsa_verify_asn1", _wrap_ecdsa_verify_asn1, METH_VARARGS, NULL}, - { "ecdh_compute_key", _wrap_ecdh_compute_key, METH_VARARGS, NULL}, - { "ec_key_from_pubkey_der", _wrap_ec_key_from_pubkey_der, METH_O, NULL}, - { "ec_key_from_pubkey_params", _wrap_ec_key_from_pubkey_params, METH_VARARGS, NULL}, - { "ec_key_keylen", _wrap_ec_key_keylen, METH_O, NULL}, - { "ec_key_type_check", _wrap_ec_key_type_check, METH_O, NULL}, - { "engine_load_builtin_engines", _wrap_engine_load_builtin_engines, METH_NOARGS, NULL}, - { "engine_load_dynamic", _wrap_engine_load_dynamic, METH_NOARGS, NULL}, - { "engine_load_openssl", _wrap_engine_load_openssl, METH_NOARGS, NULL}, - { "engine_cleanup", _wrap_engine_cleanup, METH_NOARGS, NULL}, - { "engine_new", _wrap_engine_new, METH_NOARGS, NULL}, - { "engine_by_id", _wrap_engine_by_id, METH_O, NULL}, - { "engine_free", _wrap_engine_free, METH_O, NULL}, - { "engine_init", _wrap_engine_init, METH_O, NULL}, - { "engine_finish", _wrap_engine_finish, METH_O, NULL}, - { "engine_get_id", _wrap_engine_get_id, METH_O, NULL}, - { "engine_get_name", _wrap_engine_get_name, METH_O, NULL}, - { "engine_ctrl_cmd_string", _wrap_engine_ctrl_cmd_string, METH_VARARGS, NULL}, - { "ui_openssl", _wrap_ui_openssl, METH_NOARGS, NULL}, - { "engine_pkcs11_data_new", _wrap_engine_pkcs11_data_new, METH_O, NULL}, - { "engine_pkcs11_data_free", _wrap_engine_pkcs11_data_free, METH_O, NULL}, - { "engine_load_private_key", _wrap_engine_load_private_key, METH_VARARGS, NULL}, - { "engine_load_public_key", _wrap_engine_load_public_key, METH_VARARGS, NULL}, - { "engine_init_error", _wrap_engine_init_error, METH_O, NULL}, - { "engine_load_certificate", _wrap_engine_load_certificate, METH_VARARGS, NULL}, - { "engine_set_default", _wrap_engine_set_default, METH_VARARGS, NULL}, - { "obj_nid2obj", _wrap_obj_nid2obj, METH_O, NULL}, - { "obj_nid2ln", _wrap_obj_nid2ln, METH_O, NULL}, - { "obj_nid2sn", _wrap_obj_nid2sn, METH_O, NULL}, - { "obj_obj2nid", _wrap_obj_obj2nid, METH_O, NULL}, - { "obj_ln2nid", _wrap_obj_ln2nid, METH_O, NULL}, - { "obj_sn2nid", _wrap_obj_sn2nid, METH_O, NULL}, - { "obj_txt2nid", _wrap_obj_txt2nid, METH_O, NULL}, - { "obj_txt2obj", _wrap_obj_txt2obj, METH_VARARGS, NULL}, - { "_obj_obj2txt", _wrap__obj_obj2txt, METH_VARARGS, NULL}, - { "obj_obj2txt", _wrap_obj_obj2txt, METH_VARARGS, NULL}, - { NULL, NULL, 0, NULL } -}; - -static PyMethodDef SwigMethods_proxydocs[] = { - { NULL, NULL, 0, NULL } -}; - -static SwigPyGetSet BIO_PYFD_CTX___dict___getset = { SwigPyObject_get___dict__, 0 }; -static SwigPyGetSet BIO_PYFD_CTX_fd_getset = { _wrap_BIO_PYFD_CTX_fd_get, _wrap_BIO_PYFD_CTX_fd_set }; -SWIGINTERN PyGetSetDef SwigPyBuiltin__pyfd_struct_getset[] = { - { (char *)"__dict__", SwigPyBuiltin_FunpackGetterClosure, 0, (char *)"", &BIO_PYFD_CTX___dict___getset }, - { (char *)"fd", SwigPyBuiltin_FunpackGetterClosure, SwigPyBuiltin_FunpackSetterClosure, (char *)"", &BIO_PYFD_CTX_fd_getset }, - { NULL, NULL, NULL, NULL, NULL } /* Sentinel */ -}; - -SWIGINTERN PyObject * -SwigPyBuiltin__pyfd_struct_richcompare(PyObject *self, PyObject *other, int op) { - PyObject *result = NULL; - if (!result) { - if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { - result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); - } else { - result = Py_NotImplemented; - Py_INCREF(result); - } - } - return result; -} - -SWIGINTERN PyMethodDef SwigPyBuiltin__pyfd_struct_methods[] = { - { NULL, NULL, 0, NULL } /* Sentinel */ -}; - -static PyHeapTypeObject SwigPyBuiltin__pyfd_struct_type = { - { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - "m2crypto.BIO_PYFD_CTX", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - _wrap_delete_BIO_PYFD_CTX_destructor_closure, /* tp_dealloc */ - (printfunc) 0, /* tp_print */ - (getattrfunc) 0, /* tp_getattr */ - (setattrfunc) 0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_compare */ -#else - (cmpfunc) 0, /* tp_compare */ -#endif - (reprfunc) 0, /* tp_repr */ - &SwigPyBuiltin__pyfd_struct_type.as_number, /* tp_as_number */ - &SwigPyBuiltin__pyfd_struct_type.as_sequence, /* tp_as_sequence */ - &SwigPyBuiltin__pyfd_struct_type.as_mapping, /* tp_as_mapping */ - SwigPyObject_hash, /* tp_hash */ - (ternaryfunc) 0, /* tp_call */ - (reprfunc) 0, /* tp_str */ - (getattrofunc) 0, /* tp_getattro */ - (setattrofunc) 0, /* tp_setattro */ - &SwigPyBuiltin__pyfd_struct_type.as_buffer, /* tp_as_buffer */ -#if PY_VERSION_HEX >= 0x03000000 - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ -#else - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ -#endif - "::pyfd_struct", /* tp_doc */ - (traverseproc) 0, /* tp_traverse */ - (inquiry) 0, /* tp_clear */ - SwigPyBuiltin__pyfd_struct_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) 0, /* tp_iter */ - (iternextfunc) 0, /* tp_iternext */ - SwigPyBuiltin__pyfd_struct_methods, /* tp_methods */ - 0, /* tp_members */ - SwigPyBuiltin__pyfd_struct_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc) 0, /* tp_descr_get */ - (descrsetfunc) 0, /* tp_descr_set */ - offsetof(SwigPyObject, dict), /* tp_dictoffset */ - _wrap_new_BIO_PYFD_CTX, /* tp_init */ - (allocfunc) 0, /* tp_alloc */ - (newfunc) 0, /* tp_new */ - (freefunc) 0, /* tp_free */ - (inquiry) 0, /* tp_is_gc */ - (PyObject *) 0, /* tp_bases */ - (PyObject *) 0, /* tp_mro */ - (PyObject *) 0, /* tp_cache */ - (PyObject *) 0, /* tp_subclasses */ - (PyObject *) 0, /* tp_weaklist */ - (destructor) 0, /* tp_del */ - (int) 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - (destructor) 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - (vectorcallfunc) 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - (Py_ssize_t) 0, /* tp_allocs */ - (Py_ssize_t) 0, /* tp_frees */ - (Py_ssize_t) 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0, /* tp_next */ -#endif - }, -#if PY_VERSION_HEX >= 0x03050000 - { - (unaryfunc) 0, /* am_await */ - (unaryfunc) 0, /* am_aiter */ - (unaryfunc) 0, /* am_anext */ - }, -#endif - { - (binaryfunc) 0, /* nb_add */ - (binaryfunc) 0, /* nb_subtract */ - (binaryfunc) 0, /* nb_multiply */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc) 0, /* nb_divide */ -#endif - (binaryfunc) 0, /* nb_remainder */ - (binaryfunc) 0, /* nb_divmod */ - (ternaryfunc) 0, /* nb_power */ - (unaryfunc) 0, /* nb_negative */ - (unaryfunc) 0, /* nb_positive */ - (unaryfunc) 0, /* nb_absolute */ - (inquiry) 0, /* nb_nonzero */ - (unaryfunc) 0, /* nb_invert */ - (binaryfunc) 0, /* nb_lshift */ - (binaryfunc) 0, /* nb_rshift */ - (binaryfunc) 0, /* nb_and */ - (binaryfunc) 0, /* nb_xor */ - (binaryfunc) 0, /* nb_or */ -#if PY_VERSION_HEX < 0x03000000 - (coercion) 0, /* nb_coerce */ -#endif - (unaryfunc) 0, /* nb_int */ -#if PY_VERSION_HEX >= 0x03000000 - (void *) 0, /* nb_reserved */ -#else - (unaryfunc) 0, /* nb_long */ -#endif - (unaryfunc) 0, /* nb_float */ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc) 0, /* nb_oct */ - (unaryfunc) 0, /* nb_hex */ -#endif - (binaryfunc) 0, /* nb_inplace_add */ - (binaryfunc) 0, /* nb_inplace_subtract */ - (binaryfunc) 0, /* nb_inplace_multiply */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc) 0, /* nb_inplace_divide */ -#endif - (binaryfunc) 0, /* nb_inplace_remainder */ - (ternaryfunc) 0, /* nb_inplace_power */ - (binaryfunc) 0, /* nb_inplace_lshift */ - (binaryfunc) 0, /* nb_inplace_rshift */ - (binaryfunc) 0, /* nb_inplace_and */ - (binaryfunc) 0, /* nb_inplace_xor */ - (binaryfunc) 0, /* nb_inplace_or */ - (binaryfunc) 0, /* nb_floor_divide */ - (binaryfunc) 0, /* nb_true_divide */ - (binaryfunc) 0, /* nb_inplace_floor_divide */ - (binaryfunc) 0, /* nb_inplace_true_divide */ - (unaryfunc) 0, /* nb_index */ -#if PY_VERSION_HEX >= 0x03050000 - (binaryfunc) 0, /* nb_matrix_multiply */ - (binaryfunc) 0, /* nb_inplace_matrix_multiply */ -#endif - }, - { - (lenfunc) 0, /* mp_length */ - (binaryfunc) 0, /* mp_subscript */ - (objobjargproc) 0, /* mp_ass_subscript */ - }, - { - (lenfunc) 0, /* sq_length */ - (binaryfunc) 0, /* sq_concat */ - (ssizeargfunc) 0, /* sq_repeat */ - (ssizeargfunc) 0, /* sq_item */ -#if PY_VERSION_HEX >= 0x03000000 - (void *) 0, /* was_sq_slice */ -#else - (ssizessizeargfunc) 0, /* sq_slice */ -#endif - (ssizeobjargproc) 0, /* sq_ass_item */ -#if PY_VERSION_HEX >= 0x03000000 - (void *) 0, /* was_sq_ass_slice */ -#else - (ssizessizeobjargproc) 0, /* sq_ass_slice */ -#endif - (objobjproc) 0, /* sq_contains */ - (binaryfunc) 0, /* sq_inplace_concat */ - (ssizeargfunc) 0, /* sq_inplace_repeat */ - }, - { -#if PY_VERSION_HEX < 0x03000000 - (readbufferproc) 0, /* bf_getreadbuffer */ - (writebufferproc) 0, /* bf_getwritebuffer */ - (segcountproc) 0, /* bf_getsegcount */ - (charbufferproc) 0, /* bf_getcharbuffer */ -#endif - (getbufferproc) 0, /* bf_getbuffer */ - (releasebufferproc) 0, /* bf_releasebuffer */ - }, - (PyObject *) 0, /* ht_name */ - (PyObject *) 0, /* ht_slots */ -#if PY_VERSION_HEX >= 0x03030000 - (PyObject *) 0, /* ht_qualname */ - 0, /* ht_cached_keys */ -#endif -}; - -SWIGINTERN SwigPyClientData SwigPyBuiltin__pyfd_struct_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__pyfd_struct_type}; - -static SwigPyGetSet _cbd_t___dict___getset = { SwigPyObject_get___dict__, 0 }; -static SwigPyGetSet _cbd_t_password_getset = { _wrap__cbd_t_password_get, _wrap__cbd_t_password_set }; -static SwigPyGetSet _cbd_t_prompt_getset = { _wrap__cbd_t_prompt_get, _wrap__cbd_t_prompt_set }; -SWIGINTERN PyGetSetDef SwigPyBuiltin___cbd_t_getset[] = { - { (char *)"__dict__", SwigPyBuiltin_FunpackGetterClosure, 0, (char *)"", &_cbd_t___dict___getset }, - { (char *)"password", SwigPyBuiltin_FunpackGetterClosure, SwigPyBuiltin_FunpackSetterClosure, (char *)"", &_cbd_t_password_getset }, - { (char *)"prompt", SwigPyBuiltin_FunpackGetterClosure, SwigPyBuiltin_FunpackSetterClosure, (char *)"", &_cbd_t_prompt_getset }, - { NULL, NULL, NULL, NULL, NULL } /* Sentinel */ -}; - -SWIGINTERN PyObject * -SwigPyBuiltin___cbd_t_richcompare(PyObject *self, PyObject *other, int op) { - PyObject *result = NULL; - if (!result) { - if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { - result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); - } else { - result = Py_NotImplemented; - Py_INCREF(result); - } - } - return result; -} - -SWIGINTERN PyMethodDef SwigPyBuiltin___cbd_t_methods[] = { - { NULL, NULL, 0, NULL } /* Sentinel */ -}; - -static PyHeapTypeObject SwigPyBuiltin___cbd_t_type = { - { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - "m2crypto._cbd_t", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - _wrap_delete__cbd_t_destructor_closure, /* tp_dealloc */ - (printfunc) 0, /* tp_print */ - (getattrfunc) 0, /* tp_getattr */ - (setattrfunc) 0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_compare */ -#else - (cmpfunc) 0, /* tp_compare */ -#endif - (reprfunc) 0, /* tp_repr */ - &SwigPyBuiltin___cbd_t_type.as_number, /* tp_as_number */ - &SwigPyBuiltin___cbd_t_type.as_sequence, /* tp_as_sequence */ - &SwigPyBuiltin___cbd_t_type.as_mapping, /* tp_as_mapping */ - SwigPyObject_hash, /* tp_hash */ - (ternaryfunc) 0, /* tp_call */ - (reprfunc) 0, /* tp_str */ - (getattrofunc) 0, /* tp_getattro */ - (setattrofunc) 0, /* tp_setattro */ - &SwigPyBuiltin___cbd_t_type.as_buffer, /* tp_as_buffer */ -#if PY_VERSION_HEX >= 0x03000000 - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ -#else - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ -#endif - "::_cbd_t", /* tp_doc */ - (traverseproc) 0, /* tp_traverse */ - (inquiry) 0, /* tp_clear */ - SwigPyBuiltin___cbd_t_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) 0, /* tp_iter */ - (iternextfunc) 0, /* tp_iternext */ - SwigPyBuiltin___cbd_t_methods, /* tp_methods */ - 0, /* tp_members */ - SwigPyBuiltin___cbd_t_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc) 0, /* tp_descr_get */ - (descrsetfunc) 0, /* tp_descr_set */ - offsetof(SwigPyObject, dict), /* tp_dictoffset */ - _wrap_new__cbd_t, /* tp_init */ - (allocfunc) 0, /* tp_alloc */ - (newfunc) 0, /* tp_new */ - (freefunc) 0, /* tp_free */ - (inquiry) 0, /* tp_is_gc */ - (PyObject *) 0, /* tp_bases */ - (PyObject *) 0, /* tp_mro */ - (PyObject *) 0, /* tp_cache */ - (PyObject *) 0, /* tp_subclasses */ - (PyObject *) 0, /* tp_weaklist */ - (destructor) 0, /* tp_del */ - (int) 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - (destructor) 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - (vectorcallfunc) 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - (Py_ssize_t) 0, /* tp_allocs */ - (Py_ssize_t) 0, /* tp_frees */ - (Py_ssize_t) 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0, /* tp_next */ -#endif - }, -#if PY_VERSION_HEX >= 0x03050000 - { - (unaryfunc) 0, /* am_await */ - (unaryfunc) 0, /* am_aiter */ - (unaryfunc) 0, /* am_anext */ - }, -#endif - { - (binaryfunc) 0, /* nb_add */ - (binaryfunc) 0, /* nb_subtract */ - (binaryfunc) 0, /* nb_multiply */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc) 0, /* nb_divide */ -#endif - (binaryfunc) 0, /* nb_remainder */ - (binaryfunc) 0, /* nb_divmod */ - (ternaryfunc) 0, /* nb_power */ - (unaryfunc) 0, /* nb_negative */ - (unaryfunc) 0, /* nb_positive */ - (unaryfunc) 0, /* nb_absolute */ - (inquiry) 0, /* nb_nonzero */ - (unaryfunc) 0, /* nb_invert */ - (binaryfunc) 0, /* nb_lshift */ - (binaryfunc) 0, /* nb_rshift */ - (binaryfunc) 0, /* nb_and */ - (binaryfunc) 0, /* nb_xor */ - (binaryfunc) 0, /* nb_or */ -#if PY_VERSION_HEX < 0x03000000 - (coercion) 0, /* nb_coerce */ -#endif - (unaryfunc) 0, /* nb_int */ -#if PY_VERSION_HEX >= 0x03000000 - (void *) 0, /* nb_reserved */ -#else - (unaryfunc) 0, /* nb_long */ -#endif - (unaryfunc) 0, /* nb_float */ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc) 0, /* nb_oct */ - (unaryfunc) 0, /* nb_hex */ -#endif - (binaryfunc) 0, /* nb_inplace_add */ - (binaryfunc) 0, /* nb_inplace_subtract */ - (binaryfunc) 0, /* nb_inplace_multiply */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc) 0, /* nb_inplace_divide */ -#endif - (binaryfunc) 0, /* nb_inplace_remainder */ - (ternaryfunc) 0, /* nb_inplace_power */ - (binaryfunc) 0, /* nb_inplace_lshift */ - (binaryfunc) 0, /* nb_inplace_rshift */ - (binaryfunc) 0, /* nb_inplace_and */ - (binaryfunc) 0, /* nb_inplace_xor */ - (binaryfunc) 0, /* nb_inplace_or */ - (binaryfunc) 0, /* nb_floor_divide */ - (binaryfunc) 0, /* nb_true_divide */ - (binaryfunc) 0, /* nb_inplace_floor_divide */ - (binaryfunc) 0, /* nb_inplace_true_divide */ - (unaryfunc) 0, /* nb_index */ -#if PY_VERSION_HEX >= 0x03050000 - (binaryfunc) 0, /* nb_matrix_multiply */ - (binaryfunc) 0, /* nb_inplace_matrix_multiply */ -#endif - }, - { - (lenfunc) 0, /* mp_length */ - (binaryfunc) 0, /* mp_subscript */ - (objobjargproc) 0, /* mp_ass_subscript */ - }, - { - (lenfunc) 0, /* sq_length */ - (binaryfunc) 0, /* sq_concat */ - (ssizeargfunc) 0, /* sq_repeat */ - (ssizeargfunc) 0, /* sq_item */ -#if PY_VERSION_HEX >= 0x03000000 - (void *) 0, /* was_sq_slice */ -#else - (ssizessizeargfunc) 0, /* sq_slice */ -#endif - (ssizeobjargproc) 0, /* sq_ass_item */ -#if PY_VERSION_HEX >= 0x03000000 - (void *) 0, /* was_sq_ass_slice */ -#else - (ssizessizeobjargproc) 0, /* sq_ass_slice */ -#endif - (objobjproc) 0, /* sq_contains */ - (binaryfunc) 0, /* sq_inplace_concat */ - (ssizeargfunc) 0, /* sq_inplace_repeat */ - }, - { -#if PY_VERSION_HEX < 0x03000000 - (readbufferproc) 0, /* bf_getreadbuffer */ - (writebufferproc) 0, /* bf_getwritebuffer */ - (segcountproc) 0, /* bf_getsegcount */ - (charbufferproc) 0, /* bf_getcharbuffer */ -#endif - (getbufferproc) 0, /* bf_getbuffer */ - (releasebufferproc) 0, /* bf_releasebuffer */ - }, - (PyObject *) 0, /* ht_name */ - (PyObject *) 0, /* ht_slots */ -#if PY_VERSION_HEX >= 0x03030000 - (PyObject *) 0, /* ht_qualname */ - 0, /* ht_cached_keys */ -#endif -}; - -SWIGINTERN SwigPyClientData SwigPyBuiltin___cbd_t_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin___cbd_t_type}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ - -static swig_type_info _swigt__p_AES_KEY = {"_p_AES_KEY", "AES_KEY *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ASN1_BIT_STRING = {"_p_ASN1_BIT_STRING", "ASN1_BIT_STRING *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ASN1_INTEGER = {"_p_ASN1_INTEGER", "ASN1_INTEGER *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ASN1_OBJECT = {"_p_ASN1_OBJECT", "ASN1_OBJECT *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ASN1_STRING = {"_p_ASN1_STRING", "ASN1_STRING *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ASN1_TIME = {"_p_ASN1_TIME", "ASN1_TIME *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_BIGNUM = {"_p_BIGNUM", "BIGNUM *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_BIO = {"_p_BIO", "BIO *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_BIO_METHOD = {"_p_BIO_METHOD", "BIO_METHOD *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_DH = {"_p_DH", "DH *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_DSA = {"_p_DSA", "DSA *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ECDSA_SIG = {"_p_ECDSA_SIG", "ECDSA_SIG *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_EC_KEY = {"_p_EC_KEY", "EC_KEY *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_ENGINE = {"_p_ENGINE", "ENGINE *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_EVP_CIPHER = {"_p_EVP_CIPHER", "EVP_CIPHER *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_EVP_CIPHER_CTX = {"_p_EVP_CIPHER_CTX", "EVP_CIPHER_CTX *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_EVP_MD = {"_p_EVP_MD", "EVP_MD *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_EVP_MD_CTX = {"_p_EVP_MD_CTX", "EVP_MD_CTX *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_EVP_PKEY = {"_p_EVP_PKEY", "EVP_PKEY *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_HMAC_CTX = {"_p_HMAC_CTX", "HMAC_CTX *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_PKCS7 = {"_p_PKCS7", "PKCS7 *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_PyObject = {"_p_PyObject", "PyObject *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_RC4_KEY = {"_p_RC4_KEY", "RC4_KEY *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_RSA = {"_p_RSA", "RSA *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_SSL = {"_p_SSL", "SSL *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_SSL_CIPHER = {"_p_SSL_CIPHER", "SSL_CIPHER *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_SSL_CTX = {"_p_SSL_CTX", "SSL_CTX *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_SSL_METHOD = {"_p_SSL_METHOD", "SSL_METHOD *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_SSL_SESSION = {"_p_SSL_SESSION", "SSL_SESSION *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_SwigPyObject = {"_p_SwigPyObject", "SwigPyObject *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_UI_METHOD = {"_p_UI_METHOD", "UI_METHOD *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509 = {"_p_X509", "X509 *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509V3_CTX = {"_p_X509V3_CTX", "X509V3_CTX *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_CRL = {"_p_X509_CRL", "X509_CRL *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_EXTENSION = {"_p_X509_EXTENSION", "X509_EXTENSION *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_NAME = {"_p_X509_NAME", "X509_NAME *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_NAME_ENTRY = {"_p_X509_NAME_ENTRY", "X509_NAME_ENTRY *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_REQ = {"_p_X509_REQ", "X509_REQ *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_STORE = {"_p_X509_STORE", "X509_STORE *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_X509_STORE_CTX = {"_p_X509_STORE_CTX", "X509_STORE_CTX *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INTMAX_TYPE__ = {"_p___INTMAX_TYPE__", "__INTMAX_TYPE__ *|intmax_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_FAST16_TYPE__ = {"_p___INT_FAST16_TYPE__", "__INT_FAST16_TYPE__ *|int_fast16_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_FAST32_TYPE__ = {"_p___INT_FAST32_TYPE__", "__INT_FAST32_TYPE__ *|int_fast32_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_FAST64_TYPE__ = {"_p___INT_FAST64_TYPE__", "__INT_FAST64_TYPE__ *|int_fast64_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_FAST8_TYPE__ = {"_p___INT_FAST8_TYPE__", "__INT_FAST8_TYPE__ *|int_fast8_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_LEAST16_TYPE__ = {"_p___INT_LEAST16_TYPE__", "__INT_LEAST16_TYPE__ *|int_least16_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_LEAST32_TYPE__ = {"_p___INT_LEAST32_TYPE__", "__INT_LEAST32_TYPE__ *|int_least32_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_LEAST64_TYPE__ = {"_p___INT_LEAST64_TYPE__", "__INT_LEAST64_TYPE__ *|int_least64_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___INT_LEAST8_TYPE__ = {"_p___INT_LEAST8_TYPE__", "__INT_LEAST8_TYPE__ *|int_least8_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINTMAX_TYPE__ = {"_p___UINTMAX_TYPE__", "__UINTMAX_TYPE__ *|uintmax_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_FAST16_TYPE__ = {"_p___UINT_FAST16_TYPE__", "__UINT_FAST16_TYPE__ *|uint_fast16_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_FAST32_TYPE__ = {"_p___UINT_FAST32_TYPE__", "__UINT_FAST32_TYPE__ *|uint_fast32_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_FAST64_TYPE__ = {"_p___UINT_FAST64_TYPE__", "__UINT_FAST64_TYPE__ *|uint_fast64_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_FAST8_TYPE__ = {"_p___UINT_FAST8_TYPE__", "__UINT_FAST8_TYPE__ *|uint_fast8_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_LEAST16_TYPE__ = {"_p___UINT_LEAST16_TYPE__", "__UINT_LEAST16_TYPE__ *|uint_least16_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_LEAST32_TYPE__ = {"_p___UINT_LEAST32_TYPE__", "__UINT_LEAST32_TYPE__ *|uint_least32_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_LEAST64_TYPE__ = {"_p___UINT_LEAST64_TYPE__", "__UINT_LEAST64_TYPE__ *|uint_least64_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p___UINT_LEAST8_TYPE__ = {"_p___UINT_LEAST8_TYPE__", "__UINT_LEAST8_TYPE__ *|uint_least8_t *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p__cbd_t = {"_p__cbd_t", "_cbd_t *", 0, 0, (void*)&SwigPyBuiltin___cbd_t_clientdata, 0}; -static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_int_p_X509_STORE_CTX__int = {"_p_f_int_p_X509_STORE_CTX__int", "int (*)(int,X509_STORE_CTX *)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_char__void = {"_p_f_p_char__void", "void (*)(char *)|sk_OPENSSL_STRING_freefunc|sk_OPENSSL_CSTRING_freefunc", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_q_const__char__p_char = {"_p_f_p_q_const__char__p_char", "char *(*)(char const *)|sk_OPENSSL_STRING_copyfunc|sk_OPENSSL_CSTRING_copyfunc", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int = {"_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int", "int (*)(char const *const *,char const *const *)|sk_OPENSSL_STRING_compfunc|sk_OPENSSL_CSTRING_compfunc", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int = {"_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int", "int (*)(void const *const *,void const *const *)|sk_OPENSSL_BLOCK_compfunc", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_q_const__void__p_void = {"_p_f_p_q_const__void__p_void", "void *(*)(void const *)|OPENSSL_sk_copyfunc|sk_OPENSSL_BLOCK_copyfunc", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_q_const__void_p_q_const__void__int = {"_p_f_p_q_const__void_p_q_const__void__int", "int (*)(void const *,void const *)|OPENSSL_sk_compfunc", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_f_p_void__void = {"_p_f_p_void__void", "OPENSSL_sk_freefunc|sk_OPENSSL_BLOCK_freefunc|void (*)(void *)", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_ASN1_OBJECT = {"_p_p_ASN1_OBJECT", "ASN1_OBJECT **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_EVP_PKEY_CTX = {"_p_p_EVP_PKEY_CTX", "EVP_PKEY_CTX **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_X509_NAME_ENTRY = {"_p_p_X509_NAME_ENTRY", "X509_NAME_ENTRY **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_p_unsigned_char = {"_p_p_unsigned_char", "unsigned char **", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_pyfd_struct = {"_p_pyfd_struct", "BIO_PYFD_CTX *|struct pyfd_struct *|pyfd_struct *", 0, 0, (void*)&SwigPyBuiltin__pyfd_struct_clientdata, 0}; -static swig_type_info _swigt__p_stack_st = {"_p_stack_st", "struct stack_st *|OPENSSL_STACK *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stack_st_OPENSSL_BLOCK = {"_p_stack_st_OPENSSL_BLOCK", "struct stack_st_OPENSSL_BLOCK *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stack_st_OPENSSL_CSTRING = {"_p_stack_st_OPENSSL_CSTRING", "struct stack_st_OPENSSL_CSTRING *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stack_st_OPENSSL_STRING = {"_p_stack_st_OPENSSL_STRING", "struct stack_st_OPENSSL_STRING *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stack_st_SSL_CIPHER = {"_p_stack_st_SSL_CIPHER", "struct stack_st_SSL_CIPHER *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stack_st_X509 = {"_p_stack_st_X509", "struct stack_st_X509 *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_stack_st_X509_EXTENSION = {"_p_stack_st_X509_EXTENSION", "struct stack_st_X509_EXTENSION *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0}; - -static swig_type_info *swig_type_initial[] = { - &_swigt__p_AES_KEY, - &_swigt__p_ASN1_BIT_STRING, - &_swigt__p_ASN1_INTEGER, - &_swigt__p_ASN1_OBJECT, - &_swigt__p_ASN1_STRING, - &_swigt__p_ASN1_TIME, - &_swigt__p_BIGNUM, - &_swigt__p_BIO, - &_swigt__p_BIO_METHOD, - &_swigt__p_DH, - &_swigt__p_DSA, - &_swigt__p_ECDSA_SIG, - &_swigt__p_EC_KEY, - &_swigt__p_ENGINE, - &_swigt__p_EVP_CIPHER, - &_swigt__p_EVP_CIPHER_CTX, - &_swigt__p_EVP_MD, - &_swigt__p_EVP_MD_CTX, - &_swigt__p_EVP_PKEY, - &_swigt__p_FILE, - &_swigt__p_HMAC_CTX, - &_swigt__p_PKCS7, - &_swigt__p_PyObject, - &_swigt__p_RC4_KEY, - &_swigt__p_RSA, - &_swigt__p_SSL, - &_swigt__p_SSL_CIPHER, - &_swigt__p_SSL_CTX, - &_swigt__p_SSL_METHOD, - &_swigt__p_SSL_SESSION, - &_swigt__p_SwigPyObject, - &_swigt__p_UI_METHOD, - &_swigt__p_X509, - &_swigt__p_X509V3_CTX, - &_swigt__p_X509_CRL, - &_swigt__p_X509_EXTENSION, - &_swigt__p_X509_NAME, - &_swigt__p_X509_NAME_ENTRY, - &_swigt__p_X509_REQ, - &_swigt__p_X509_STORE, - &_swigt__p_X509_STORE_CTX, - &_swigt__p___INTMAX_TYPE__, - &_swigt__p___INT_FAST16_TYPE__, - &_swigt__p___INT_FAST32_TYPE__, - &_swigt__p___INT_FAST64_TYPE__, - &_swigt__p___INT_FAST8_TYPE__, - &_swigt__p___INT_LEAST16_TYPE__, - &_swigt__p___INT_LEAST32_TYPE__, - &_swigt__p___INT_LEAST64_TYPE__, - &_swigt__p___INT_LEAST8_TYPE__, - &_swigt__p___UINTMAX_TYPE__, - &_swigt__p___UINT_FAST16_TYPE__, - &_swigt__p___UINT_FAST32_TYPE__, - &_swigt__p___UINT_FAST64_TYPE__, - &_swigt__p___UINT_FAST8_TYPE__, - &_swigt__p___UINT_LEAST16_TYPE__, - &_swigt__p___UINT_LEAST32_TYPE__, - &_swigt__p___UINT_LEAST64_TYPE__, - &_swigt__p___UINT_LEAST8_TYPE__, - &_swigt__p__cbd_t, - &_swigt__p_char, - &_swigt__p_f_int_p_X509_STORE_CTX__int, - &_swigt__p_f_p_char__void, - &_swigt__p_f_p_q_const__char__p_char, - &_swigt__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int, - &_swigt__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int, - &_swigt__p_f_p_q_const__void__p_void, - &_swigt__p_f_p_q_const__void_p_q_const__void__int, - &_swigt__p_f_p_void__void, - &_swigt__p_p_ASN1_OBJECT, - &_swigt__p_p_EVP_PKEY_CTX, - &_swigt__p_p_X509_NAME_ENTRY, - &_swigt__p_p_unsigned_char, - &_swigt__p_pyfd_struct, - &_swigt__p_stack_st, - &_swigt__p_stack_st_OPENSSL_BLOCK, - &_swigt__p_stack_st_OPENSSL_CSTRING, - &_swigt__p_stack_st_OPENSSL_STRING, - &_swigt__p_stack_st_SSL_CIPHER, - &_swigt__p_stack_st_X509, - &_swigt__p_stack_st_X509_EXTENSION, - &_swigt__p_unsigned_char, - &_swigt__p_void, -}; - -static swig_cast_info _swigc__p_AES_KEY[] = { {&_swigt__p_AES_KEY, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ASN1_BIT_STRING[] = { {&_swigt__p_ASN1_BIT_STRING, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ASN1_INTEGER[] = { {&_swigt__p_ASN1_INTEGER, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ASN1_OBJECT[] = { {&_swigt__p_ASN1_OBJECT, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ASN1_STRING[] = { {&_swigt__p_ASN1_STRING, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ASN1_TIME[] = { {&_swigt__p_ASN1_TIME, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_BIGNUM[] = { {&_swigt__p_BIGNUM, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_BIO[] = { {&_swigt__p_BIO, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_BIO_METHOD[] = { {&_swigt__p_BIO_METHOD, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_DH[] = { {&_swigt__p_DH, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_DSA[] = { {&_swigt__p_DSA, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ECDSA_SIG[] = { {&_swigt__p_ECDSA_SIG, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_EC_KEY[] = { {&_swigt__p_EC_KEY, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_ENGINE[] = { {&_swigt__p_ENGINE, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_EVP_CIPHER[] = { {&_swigt__p_EVP_CIPHER, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_EVP_CIPHER_CTX[] = { {&_swigt__p_EVP_CIPHER_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_EVP_MD[] = { {&_swigt__p_EVP_MD, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_EVP_MD_CTX[] = { {&_swigt__p_EVP_MD_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_EVP_PKEY[] = { {&_swigt__p_EVP_PKEY, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_FILE[] = { {&_swigt__p_FILE, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_HMAC_CTX[] = { {&_swigt__p_HMAC_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_PKCS7[] = { {&_swigt__p_PKCS7, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_PyObject[] = { {&_swigt__p_PyObject, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_RC4_KEY[] = { {&_swigt__p_RC4_KEY, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_RSA[] = { {&_swigt__p_RSA, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_SSL[] = { {&_swigt__p_SSL, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_SSL_CIPHER[] = { {&_swigt__p_SSL_CIPHER, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_SSL_CTX[] = { {&_swigt__p_SSL_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_SSL_METHOD[] = { {&_swigt__p_SSL_METHOD, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_SSL_SESSION[] = { {&_swigt__p_SSL_SESSION, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_SwigPyObject[] = { {&_swigt__p_SwigPyObject, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_UI_METHOD[] = { {&_swigt__p_UI_METHOD, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509[] = { {&_swigt__p_X509, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509V3_CTX[] = { {&_swigt__p_X509V3_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_CRL[] = { {&_swigt__p_X509_CRL, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_EXTENSION[] = { {&_swigt__p_X509_EXTENSION, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_NAME[] = { {&_swigt__p_X509_NAME, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_NAME_ENTRY[] = { {&_swigt__p_X509_NAME_ENTRY, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_REQ[] = { {&_swigt__p_X509_REQ, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_STORE[] = { {&_swigt__p_X509_STORE, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_X509_STORE_CTX[] = { {&_swigt__p_X509_STORE_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INTMAX_TYPE__[] = { {&_swigt__p___INTMAX_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_FAST16_TYPE__[] = { {&_swigt__p___INT_FAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_FAST32_TYPE__[] = { {&_swigt__p___INT_FAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_FAST64_TYPE__[] = { {&_swigt__p___INT_FAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_FAST8_TYPE__[] = { {&_swigt__p___INT_FAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_LEAST16_TYPE__[] = { {&_swigt__p___INT_LEAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_LEAST32_TYPE__[] = { {&_swigt__p___INT_LEAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_LEAST64_TYPE__[] = { {&_swigt__p___INT_LEAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___INT_LEAST8_TYPE__[] = { {&_swigt__p___INT_LEAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINTMAX_TYPE__[] = { {&_swigt__p___UINTMAX_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_FAST16_TYPE__[] = { {&_swigt__p___UINT_FAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_FAST32_TYPE__[] = { {&_swigt__p___UINT_FAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_FAST64_TYPE__[] = { {&_swigt__p___UINT_FAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_FAST8_TYPE__[] = { {&_swigt__p___UINT_FAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_LEAST16_TYPE__[] = { {&_swigt__p___UINT_LEAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_LEAST32_TYPE__[] = { {&_swigt__p___UINT_LEAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_LEAST64_TYPE__[] = { {&_swigt__p___UINT_LEAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p___UINT_LEAST8_TYPE__[] = { {&_swigt__p___UINT_LEAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p__cbd_t[] = { {&_swigt__p__cbd_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_int_p_X509_STORE_CTX__int[] = { {&_swigt__p_f_int_p_X509_STORE_CTX__int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_char__void[] = { {&_swigt__p_f_p_char__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_q_const__char__p_char[] = { {&_swigt__p_f_p_q_const__char__p_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int[] = { {&_swigt__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int[] = { {&_swigt__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_q_const__void__p_void[] = { {&_swigt__p_f_p_q_const__void__p_void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_q_const__void_p_q_const__void__int[] = { {&_swigt__p_f_p_q_const__void_p_q_const__void__int, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_f_p_void__void[] = { {&_swigt__p_f_p_void__void, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_ASN1_OBJECT[] = { {&_swigt__p_p_ASN1_OBJECT, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_EVP_PKEY_CTX[] = { {&_swigt__p_p_EVP_PKEY_CTX, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_X509_NAME_ENTRY[] = { {&_swigt__p_p_X509_NAME_ENTRY, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_p_unsigned_char[] = { {&_swigt__p_p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_pyfd_struct[] = { {&_swigt__p_pyfd_struct, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st[] = { {&_swigt__p_stack_st, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st_OPENSSL_BLOCK[] = { {&_swigt__p_stack_st_OPENSSL_BLOCK, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st_OPENSSL_CSTRING[] = { {&_swigt__p_stack_st_OPENSSL_CSTRING, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st_OPENSSL_STRING[] = { {&_swigt__p_stack_st_OPENSSL_STRING, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st_SSL_CIPHER[] = { {&_swigt__p_stack_st_SSL_CIPHER, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st_X509[] = { {&_swigt__p_stack_st_X509, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_stack_st_X509_EXTENSION[] = { {&_swigt__p_stack_st_X509_EXTENSION, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}}; - -static swig_cast_info *swig_cast_initial[] = { - _swigc__p_AES_KEY, - _swigc__p_ASN1_BIT_STRING, - _swigc__p_ASN1_INTEGER, - _swigc__p_ASN1_OBJECT, - _swigc__p_ASN1_STRING, - _swigc__p_ASN1_TIME, - _swigc__p_BIGNUM, - _swigc__p_BIO, - _swigc__p_BIO_METHOD, - _swigc__p_DH, - _swigc__p_DSA, - _swigc__p_ECDSA_SIG, - _swigc__p_EC_KEY, - _swigc__p_ENGINE, - _swigc__p_EVP_CIPHER, - _swigc__p_EVP_CIPHER_CTX, - _swigc__p_EVP_MD, - _swigc__p_EVP_MD_CTX, - _swigc__p_EVP_PKEY, - _swigc__p_FILE, - _swigc__p_HMAC_CTX, - _swigc__p_PKCS7, - _swigc__p_PyObject, - _swigc__p_RC4_KEY, - _swigc__p_RSA, - _swigc__p_SSL, - _swigc__p_SSL_CIPHER, - _swigc__p_SSL_CTX, - _swigc__p_SSL_METHOD, - _swigc__p_SSL_SESSION, - _swigc__p_SwigPyObject, - _swigc__p_UI_METHOD, - _swigc__p_X509, - _swigc__p_X509V3_CTX, - _swigc__p_X509_CRL, - _swigc__p_X509_EXTENSION, - _swigc__p_X509_NAME, - _swigc__p_X509_NAME_ENTRY, - _swigc__p_X509_REQ, - _swigc__p_X509_STORE, - _swigc__p_X509_STORE_CTX, - _swigc__p___INTMAX_TYPE__, - _swigc__p___INT_FAST16_TYPE__, - _swigc__p___INT_FAST32_TYPE__, - _swigc__p___INT_FAST64_TYPE__, - _swigc__p___INT_FAST8_TYPE__, - _swigc__p___INT_LEAST16_TYPE__, - _swigc__p___INT_LEAST32_TYPE__, - _swigc__p___INT_LEAST64_TYPE__, - _swigc__p___INT_LEAST8_TYPE__, - _swigc__p___UINTMAX_TYPE__, - _swigc__p___UINT_FAST16_TYPE__, - _swigc__p___UINT_FAST32_TYPE__, - _swigc__p___UINT_FAST64_TYPE__, - _swigc__p___UINT_FAST8_TYPE__, - _swigc__p___UINT_LEAST16_TYPE__, - _swigc__p___UINT_LEAST32_TYPE__, - _swigc__p___UINT_LEAST64_TYPE__, - _swigc__p___UINT_LEAST8_TYPE__, - _swigc__p__cbd_t, - _swigc__p_char, - _swigc__p_f_int_p_X509_STORE_CTX__int, - _swigc__p_f_p_char__void, - _swigc__p_f_p_q_const__char__p_char, - _swigc__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int, - _swigc__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int, - _swigc__p_f_p_q_const__void__p_void, - _swigc__p_f_p_q_const__void_p_q_const__void__int, - _swigc__p_f_p_void__void, - _swigc__p_p_ASN1_OBJECT, - _swigc__p_p_EVP_PKEY_CTX, - _swigc__p_p_X509_NAME_ENTRY, - _swigc__p_p_unsigned_char, - _swigc__p_pyfd_struct, - _swigc__p_stack_st, - _swigc__p_stack_st_OPENSSL_BLOCK, - _swigc__p_stack_st_OPENSSL_CSTRING, - _swigc__p_stack_st_OPENSSL_STRING, - _swigc__p_stack_st_SSL_CIPHER, - _swigc__p_stack_st_X509, - _swigc__p_stack_st_X509_EXTENSION, - _swigc__p_unsigned_char, - _swigc__p_void, -}; - - -/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ - -static swig_const_info swig_const_table[] = { -{0, 0, 0, 0.0, 0, 0}}; - -#ifdef __cplusplus -} -#endif -static PyTypeObject *builtin_bases[2]; - -/* ----------------------------------------------------------------------------- - * Type initialization: - * This problem is tough by the requirement that no dynamic - * memory is used. Also, since swig_type_info structures store pointers to - * swig_cast_info structures and swig_cast_info structures store pointers back - * to swig_type_info structures, we need some lookup code at initialization. - * The idea is that swig generates all the structures that are needed. - * The runtime then collects these partially filled structures. - * The SWIG_InitializeModule function takes these initial arrays out of - * swig_module, and does all the lookup, filling in the swig_module.types - * array with the correct data and linking the correct swig_cast_info - * structures together. - * - * The generated swig_type_info structures are assigned statically to an initial - * array. We just loop through that array, and handle each type individually. - * First we lookup if this type has been already loaded, and if so, use the - * loaded structure instead of the generated one. Then we have to fill in the - * cast linked list. The cast data is initially stored in something like a - * two-dimensional array. Each row corresponds to a type (there are the same - * number of rows as there are in the swig_type_initial array). Each entry in - * a column is one of the swig_cast_info structures for that type. - * The cast_initial array is actually an array of arrays, because each row has - * a variable number of columns. So to actually build the cast linked list, - * we find the array of casts associated with the type, and loop through it - * adding the casts to the list. The one last trick we need to do is making - * sure the type pointer in the swig_cast_info struct is correct. - * - * First off, we lookup the cast->type name to see if it is already loaded. - * There are three cases to handle: - * 1) If the cast->type has already been loaded AND the type we are adding - * casting info to has not been loaded (it is in this module), THEN we - * replace the cast->type pointer with the type pointer that has already - * been loaded. - * 2) If BOTH types (the one we are adding casting info to, and the - * cast->type) are loaded, THEN the cast info has already been loaded by - * the previous module so we just ignore it. - * 3) Finally, if cast->type has not already been loaded, then we add that - * swig_cast_info to the linked list (because the cast->type) pointer will - * be correct. - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* c-mode */ -#endif -#endif - -#if 0 -#define SWIGRUNTIME_DEBUG -#endif - - -SWIGRUNTIME void -SWIG_InitializeModule(void *clientdata) { - size_t i; - swig_module_info *module_head, *iter; - int init; - - /* check to see if the circular list has been setup, if not, set it up */ - if (swig_module.next==0) { - /* Initialize the swig_module */ - swig_module.type_initial = swig_type_initial; - swig_module.cast_initial = swig_cast_initial; - swig_module.next = &swig_module; - init = 1; - } else { - init = 0; - } - - /* Try and load any already created modules */ - module_head = SWIG_GetModule(clientdata); - if (!module_head) { - /* This is the first module loaded for this interpreter */ - /* so set the swig module into the interpreter */ - SWIG_SetModule(clientdata, &swig_module); - } else { - /* the interpreter has loaded a SWIG module, but has it loaded this one? */ - iter=module_head; - do { - if (iter==&swig_module) { - /* Our module is already in the list, so there's nothing more to do. */ - return; - } - iter=iter->next; - } while (iter!= module_head); - - /* otherwise we must add our module into the list */ - swig_module.next = module_head->next; - module_head->next = &swig_module; - } - - /* When multiple interpreters are used, a module could have already been initialized in - a different interpreter, but not yet have a pointer in this interpreter. - In this case, we do not want to continue adding types... everything should be - set up already */ - if (init == 0) return; - - /* Now work on filling in swig_module.types */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); -#endif - for (i = 0; i < swig_module.size; ++i) { - swig_type_info *type = 0; - swig_type_info *ret; - swig_cast_info *cast; - -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); -#endif - - /* if there is another module already loaded */ - if (swig_module.next != &swig_module) { - type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); - } - if (type) { - /* Overwrite clientdata field */ -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found type %s\n", type->name); -#endif - if (swig_module.type_initial[i]->clientdata) { - type->clientdata = swig_module.type_initial[i]->clientdata; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); -#endif - } - } else { - type = swig_module.type_initial[i]; - } - - /* Insert casting types */ - cast = swig_module.cast_initial[i]; - while (cast->type) { - /* Don't need to add information already in the list */ - ret = 0; -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); -#endif - if (swig_module.next != &swig_module) { - ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); -#ifdef SWIGRUNTIME_DEBUG - if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); -#endif - } - if (ret) { - if (type == swig_module.type_initial[i]) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: skip old type %s\n", ret->name); -#endif - cast->type = ret; - ret = 0; - } else { - /* Check for casting already in the list */ - swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); -#ifdef SWIGRUNTIME_DEBUG - if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); -#endif - if (!ocast) ret = 0; - } - } - - if (!ret) { -#ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); -#endif - if (type->cast) { - type->cast->prev = cast; - cast->next = type->cast; - } - type->cast = cast; - } - cast++; - } - /* Set entry in modules->types array equal to the type */ - swig_module.types[i] = type; - } - swig_module.types[i] = 0; - -#ifdef SWIGRUNTIME_DEBUG - printf("**** SWIG_InitializeModule: Cast List ******\n"); - for (i = 0; i < swig_module.size; ++i) { - int j = 0; - swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); - while (cast->type) { - printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); - cast++; - ++j; - } - printf("---- Total casts: %d\n",j); - } - printf("**** SWIG_InitializeModule: Cast List ******\n"); -#endif -} - -/* This function will propagate the clientdata field of type to -* any new swig_type_info structures that have been added into the list -* of equivalent types. It is like calling -* SWIG_TypeClientData(type, clientdata) a second time. -*/ -SWIGRUNTIME void -SWIG_PropagateClientData(void) { - size_t i; - swig_cast_info *equiv; - static int init_run = 0; - - if (init_run) return; - init_run = 1; - - for (i = 0; i < swig_module.size; i++) { - if (swig_module.types[i]->clientdata) { - equiv = swig_module.types[i]->cast; - while (equiv) { - if (!equiv->converter) { - if (equiv->type && !equiv->type->clientdata) - SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); - } - equiv = equiv->next; - } - } - } -} - -#ifdef __cplusplus -#if 0 -{ - /* c-mode */ -#endif -} -#endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - /* Python-specific SWIG API */ -#define SWIG_newvarlink() SWIG_Python_newvarlink() -#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) -#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) - - /* ----------------------------------------------------------------------------- - * global variable support code. - * ----------------------------------------------------------------------------- */ - - typedef struct swig_globalvar { - char *name; /* Name of global variable */ - PyObject *(*get_attr)(void); /* Return the current value */ - int (*set_attr)(PyObject *); /* Set the value */ - struct swig_globalvar *next; - } swig_globalvar; - - typedef struct swig_varlinkobject { - PyObject_HEAD - swig_globalvar *vars; - } swig_varlinkobject; - - SWIGINTERN PyObject * - swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString(""); -#else - return PyString_FromString(""); -#endif - } - - SWIGINTERN PyObject * - swig_varlink_str(swig_varlinkobject *v) { -#if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); - PyObject *tail; - PyObject *joined; - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - tail = PyUnicode_FromString(var->name); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - if (var->next) { - tail = PyUnicode_InternFromString(", "); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - } - } - tail = PyUnicode_InternFromString(")"); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; -#else - PyObject *str = PyString_FromString("("); - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - PyString_ConcatAndDel(&str,PyString_FromString(var->name)); - if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); - } - PyString_ConcatAndDel(&str,PyString_FromString(")")); -#endif - return str; - } - - SWIGINTERN void - swig_varlink_dealloc(swig_varlinkobject *v) { - swig_globalvar *var = v->vars; - while (var) { - swig_globalvar *n = var->next; - free(var->name); - free(var); - var = n; - } - } - - SWIGINTERN PyObject * - swig_varlink_getattr(swig_varlinkobject *v, char *n) { - PyObject *res = NULL; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->get_attr)(); - break; - } - var = var->next; - } - if (res == NULL && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; - } - - SWIGINTERN int - swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { - int res = 1; - swig_globalvar *var = v->vars; - while (var) { - if (strcmp(var->name,n) == 0) { - res = (*var->set_attr)(p); - break; - } - var = var->next; - } - if (res == 1 && !PyErr_Occurred()) { - PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); - } - return res; - } - - SWIGINTERN PyTypeObject* - swig_varlink_type(void) { - static char varlink__doc__[] = "Swig var link object"; - static PyTypeObject varlink_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp = { -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(NULL, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - "swigvarlink", /* tp_name */ - sizeof(swig_varlinkobject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) swig_varlink_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - (getattrfunc) swig_varlink_getattr, /* tp_getattr */ - (setattrfunc) swig_varlink_setattr, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc) swig_varlink_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) swig_varlink_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - 0, /* tp_flags */ - varlink__doc__, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag */ -#if PY_VERSION_HEX >= 0x03040000 - 0, /* tp_finalize */ -#endif -#if PY_VERSION_HEX >= 0x03080000 - 0, /* tp_vectorcall */ -#endif -#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) - 0, /* tp_print */ -#endif -#ifdef COUNT_ALLOCS - 0, /* tp_allocs */ - 0, /* tp_frees */ - 0, /* tp_maxalloc */ - 0, /* tp_prev */ - 0 /* tp_next */ -#endif - }; - varlink_type = tmp; - type_init = 1; - if (PyType_Ready(&varlink_type) < 0) - return NULL; - } - return &varlink_type; - } - - /* Create a variable linking object for use later */ - SWIGINTERN PyObject * - SWIG_Python_newvarlink(void) { - swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); - if (result) { - result->vars = 0; - } - return ((PyObject*) result); - } - - SWIGINTERN void - SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { - swig_varlinkobject *v = (swig_varlinkobject *) p; - swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); - if (gv) { - size_t size = strlen(name)+1; - gv->name = (char *)malloc(size); - if (gv->name) { - memcpy(gv->name, name, size); - gv->get_attr = get_attr; - gv->set_attr = set_attr; - gv->next = v->vars; - } - } - v->vars = gv; - } - - SWIGINTERN PyObject * - SWIG_globals(void) { - static PyObject *globals = 0; - if (!globals) { - globals = SWIG_newvarlink(); - } - return globals; - } - - /* ----------------------------------------------------------------------------- - * constants/methods manipulation - * ----------------------------------------------------------------------------- */ - - /* Install Constants */ - SWIGINTERN void - SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { - PyObject *obj = 0; - size_t i; - for (i = 0; constants[i].type; ++i) { - switch(constants[i].type) { - case SWIG_PY_POINTER: - obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); - break; - case SWIG_PY_BINARY: - obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); - break; - default: - obj = 0; - break; - } - if (obj) { - PyDict_SetItemString(d, constants[i].name, obj); - Py_DECREF(obj); - } - } - } - - /* -----------------------------------------------------------------------------*/ - /* Fix SwigMethods to carry the callback ptrs when needed */ - /* -----------------------------------------------------------------------------*/ - - SWIGINTERN void - SWIG_Python_FixMethods(PyMethodDef *methods, - swig_const_info *const_table, - swig_type_info **types, - swig_type_info **types_initial) { - size_t i; - for (i = 0; methods[i].ml_name; ++i) { - const char *c = methods[i].ml_doc; - if (!c) continue; - c = strstr(c, "swig_ptr: "); - if (c) { - int j; - swig_const_info *ci = 0; - const char *name = c + 10; - for (j = 0; const_table[j].type; ++j) { - if (strncmp(const_table[j].name, name, - strlen(const_table[j].name)) == 0) { - ci = &(const_table[j]); - break; - } - } - if (ci) { - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; - char *ndoc = (char*)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - memcpy(buff, methods[i].ml_doc, ldoc); - buff += ldoc; - memcpy(buff, "swig_ptr: ", 10); - buff += 10; - SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); - methods[i].ml_doc = ndoc; - } - } - } - } - } - } - - /* ----------------------------------------------------------------------------- - * Method creation and docstring support functions - * ----------------------------------------------------------------------------- */ - - /* ----------------------------------------------------------------------------- - * Function to find the method definition with the correct docstring for the - * proxy module as opposed to the low-level API - * ----------------------------------------------------------------------------- */ - - SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { - /* Find the function in the modified method table */ - size_t offset = 0; - int found = 0; - while (SwigMethods_proxydocs[offset].ml_meth != NULL) { - if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { - found = 1; - break; - } - offset++; - } - /* Use the copy with the modified docstring if available */ - return found ? &SwigMethods_proxydocs[offset] : NULL; - } - - /* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ - - SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - return PyMethod_New(func, NULL, NULL); -#endif - } - - /* ----------------------------------------------------------------------------- - * Wrapper of PyStaticMethod_New() - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ - - SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } - return PyStaticMethod_New(func); - } - -#ifdef __cplusplus -} -#endif - -/* -----------------------------------------------------------------------------* - * Partial Init method - * -----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" -#endif - -SWIGEXPORT -#if PY_VERSION_HEX >= 0x03000000 -PyObject* -#else -void -#endif -SWIG_init(void) { - PyObject *m, *d, *md, *globals; - -#if PY_VERSION_HEX >= 0x03000000 - static struct PyModuleDef SWIG_module = { - PyModuleDef_HEAD_INIT, - SWIG_name, - NULL, - -1, - SwigMethods, - NULL, - NULL, - NULL, - NULL - }; -#endif - -#if defined(SWIGPYTHON_BUILTIN) - static SwigPyClientData SwigPyObject_clientdata = { - 0, 0, 0, 0, 0, 0, 0 - }; - static PyGetSetDef this_getset_def = { - (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL - }; - static SwigPyGetSet thisown_getset_closure = { - SwigPyObject_own, - SwigPyObject_own - }; - static PyGetSetDef thisown_getset_def = { - (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure - }; - PyTypeObject *builtin_pytype; - int builtin_base_count; - swig_type_info *builtin_basetype; - PyObject *tuple; - PyGetSetDescrObject *static_getset; - PyTypeObject *metatype; - PyTypeObject *swigpyobject; - SwigPyClientData *cd; - PyObject *public_interface, *public_symbol; - PyObject *this_descr; - PyObject *thisown_descr; - PyObject *self = 0; - int i; - - (void)builtin_pytype; - (void)builtin_base_count; - (void)builtin_basetype; - (void)tuple; - (void)static_getset; - (void)self; - - /* Metaclass is used to implement static member variables */ - metatype = SwigPyObjectType(); - assert(metatype); -#endif - - (void)globals; - - /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ - SWIG_This(); - SWIG_Python_TypeCache(); - SwigPyPacked_type(); -#ifndef SWIGPYTHON_BUILTIN - SwigPyObject_type(); -#endif - - /* Fix SwigMethods to carry the callback ptrs when needed */ - SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - -#if PY_VERSION_HEX >= 0x03000000 - m = PyModule_Create(&SWIG_module); -#else - m = Py_InitModule(SWIG_name, SwigMethods); -#endif - - md = d = PyModule_GetDict(m); - (void)md; - - SWIG_InitializeModule(0); - -#ifdef SWIGPYTHON_BUILTIN - swigpyobject = SwigPyObject_TypeOnce(); - - SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); - assert(SwigPyObject_stype); - cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; - if (!cd) { - SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; - SwigPyObject_clientdata.pytype = swigpyobject; - } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { - PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); -# if PY_VERSION_HEX >= 0x03000000 - return NULL; -# else - return; -# endif - } - - /* All objects have a 'this' attribute */ - this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); - (void)this_descr; - - /* All objects have a 'thisown' attribute */ - thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); - (void)thisown_descr; - - public_interface = PyList_New(0); - public_symbol = 0; - (void)public_symbol; - - PyDict_SetItemString(md, "__all__", public_interface); - Py_DECREF(public_interface); - for (i = 0; SwigMethods[i].ml_name != NULL; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); - for (i = 0; swig_const_table[i].name != 0; ++i) - SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); -#endif - - SWIG_InstallConstants(d,swig_const_table); - - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_VERSION_NUMBER",SWIG_From_long((long)(0x1010108fL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_VERSION_TEXT",SWIG_FromCharPtr("OpenSSL 1.1.1h 22 Sep 2020")); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SHLIB_VERSION_HISTORY",SWIG_FromCharPtr("")); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SHLIB_VERSION_NUMBER",SWIG_FromCharPtr("1.1")); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_FILE",SWIG_FromCharPtr("/usr/include/openssl/opensslconf.h")); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_LINE",SWIG_From_int((int)(134))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_MIN_API",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_API_COMPAT",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "bio_noclose",SWIG_From_int((int)(BIO_NOCLOSE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "bio_close",SWIG_From_int((int)(BIO_CLOSE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_READ",SWIG_From_int((int)(0x01))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_WRITE",SWIG_From_int((int)(0x02))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_IO_SPECIAL",SWIG_From_int((int)(0x04))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_RWS",SWIG_From_int((int)((BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_SHOULD_RETRY",SWIG_From_int((int)(0x08))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_MEM_RDONLY",SWIG_From_int((int)(0x200))); - globals = SWIG_globals(); - if (!globals) { - PyErr_SetString(PyExc_TypeError, "Failure to create SWIG globals."); -#if PY_VERSION_HEX >= 0x03000000 - return NULL; -#else - return; -#endif - } - PyDict_SetItemString(md, "cvar", globals); - Py_DECREF(globals); - SwigPyBuiltin_AddPublicSymbol(public_interface, "cvar"); - SWIG_addvarlink(globals, "_bio_err", Swig_var__bio_err_get, Swig_var__bio_err_set); - - /* type '::pyfd_struct' */ - builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__pyfd_struct_type; - builtin_pytype->tp_dict = d = PyDict_New(); - SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); - builtin_pytype->tp_new = PyType_GenericNew; - builtin_base_count = 0; - builtin_bases[builtin_base_count] = NULL; - SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); - PyDict_SetItemString(d, "this", this_descr); - PyDict_SetItemString(d, "thisown", thisown_descr); - if (PyType_Ready(builtin_pytype) < 0) { - PyErr_SetString(PyExc_TypeError, "Could not create type 'BIO_PYFD_CTX'."); -#if PY_VERSION_HEX >= 0x03000000 - return NULL; -#else - return; -#endif - } - Py_INCREF(builtin_pytype); - PyModule_AddObject(m, "BIO_PYFD_CTX", (PyObject *)builtin_pytype); - SwigPyBuiltin_AddPublicSymbol(public_interface, "BIO_PYFD_CTX"); - d = md; - SWIG_addvarlink(globals, "methods_fdp", Swig_var_methods_fdp_get, Swig_var_methods_fdp_set); - SWIG_addvarlink(globals, "_rand_err", Swig_var__rand_err_get, Swig_var__rand_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS5_SALT_LEN",SWIG_From_int((int)(8))); - SWIG_addvarlink(globals, "_evp_err", Swig_var__evp_err_get, Swig_var__evp_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "AES_BLOCK_SIZE",SWIG_From_int((int)(AES_BLOCK_SIZE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_NO_RC4",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_ok",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_p_not_prime",SWIG_From_int((int)(DH_CHECK_P_NOT_PRIME))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_p_not_strong",SWIG_From_int((int)(DH_CHECK_P_NOT_STRONG_PRIME))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_g_failed",SWIG_From_int((int)(DH_UNABLE_TO_CHECK_GENERATOR))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_bad_g",SWIG_From_int((int)(DH_NOT_SUITABLE_GENERATOR))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "DH_GENERATOR_2",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "DH_GENERATOR_5",SWIG_From_int((int)(5))); - SWIG_addvarlink(globals, "_dh_err", Swig_var__dh_err_get, Swig_var__dh_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "no_padding",SWIG_From_int((int)(RSA_NO_PADDING))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "pkcs1_padding",SWIG_From_int((int)(RSA_PKCS1_PADDING))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "sslv23_padding",SWIG_From_int((int)(RSA_SSLV23_PADDING))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "pkcs1_oaep_padding",SWIG_From_int((int)(RSA_PKCS1_OAEP_PADDING))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha1",SWIG_From_int((int)(NID_sha1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha224",SWIG_From_int((int)(NID_sha224))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha256",SWIG_From_int((int)(NID_sha256))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha384",SWIG_From_int((int)(NID_sha384))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha512",SWIG_From_int((int)(NID_sha512))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_md5",SWIG_From_int((int)(NID_md5))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_ripemd160",SWIG_From_int((int)(NID_ripemd160))); - SWIG_addvarlink(globals, "_rsa_err", Swig_var__rsa_err_get, Swig_var__rsa_err_set); - SWIG_addvarlink(globals, "_dsa_err", Swig_var__dsa_err_get, Swig_var__dsa_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_none",SWIG_From_int((int)(SSL_ERROR_NONE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_ssl",SWIG_From_int((int)(SSL_ERROR_SSL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_read",SWIG_From_int((int)(SSL_ERROR_WANT_READ))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_write",SWIG_From_int((int)(SSL_ERROR_WANT_WRITE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_x509_lookup",SWIG_From_int((int)(SSL_ERROR_WANT_X509_LOOKUP))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_syscall",SWIG_From_int((int)(SSL_ERROR_SYSCALL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_zero_return",SWIG_From_int((int)(SSL_ERROR_ZERO_RETURN))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_connect",SWIG_From_int((int)(SSL_ERROR_WANT_CONNECT))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_NONE",SWIG_From_int((int)(0x00))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_PEER",SWIG_From_int((int)(0x01))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_FAIL_IF_NO_PEER_CERT",SWIG_From_int((int)(0x02))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_CLIENT_ONCE",SWIG_From_int((int)(0x04))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK_LEAF",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK_CHAIN",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_CONNECT",SWIG_From_int((int)(0x1000))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_ACCEPT",SWIG_From_int((int)(0x2000))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_MASK",SWIG_From_int((int)(0x0FFF))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_INIT",SWIG_From_int((int)((SSL_ST_CONNECT|SSL_ST_ACCEPT)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_BEFORE",SWIG_From_int((int)(0x4000))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_OK",SWIG_From_int((int)(0x03))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_RENEGOTIATE",SWIG_From_int((int)((0x04|SSL_ST_CONNECT|SSL_ST_ACCEPT)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_LOOP",SWIG_From_int((int)(0x01))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_EXIT",SWIG_From_int((int)(0x02))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_READ",SWIG_From_int((int)(0x04))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_WRITE",SWIG_From_int((int)(0x08))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_ALERT",SWIG_From_int((int)(0x4000))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_READ_ALERT",SWIG_From_int((int)((SSL_CB_ALERT|SSL_CB_READ)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_WRITE_ALERT",SWIG_From_int((int)((SSL_CB_ALERT|SSL_CB_WRITE)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_ACCEPT_LOOP",SWIG_From_int((int)((SSL_ST_ACCEPT|SSL_CB_LOOP)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_ACCEPT_EXIT",SWIG_From_int((int)((SSL_ST_ACCEPT|SSL_CB_EXIT)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_CONNECT_LOOP",SWIG_From_int((int)((SSL_ST_CONNECT|SSL_CB_LOOP)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_CONNECT_EXIT",SWIG_From_int((int)((SSL_ST_CONNECT|SSL_CB_EXIT)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_HANDSHAKE_START",SWIG_From_int((int)(0x10))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_HANDSHAKE_DONE",SWIG_From_int((int)(0x20))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SENT_SHUTDOWN",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_RECEIVED_SHUTDOWN",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_OFF",SWIG_From_int((int)(0x000))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_CLIENT",SWIG_From_int((int)(0x001))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_SERVER",SWIG_From_int((int)(0x002))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_BOTH",SWIG_From_int((int)((SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_ALL",SWIG_From_int((int)(0x00000FFFL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_NO_SSLv2",SWIG_From_int((int)(0x01000000L))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_NO_SSLv3",SWIG_From_int((int)(0x02000000L))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_NO_TLSv1",SWIG_From_int((int)(0x04000000L))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS",SWIG_From_int((int)(0x00000800L))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_MODE_ENABLE_PARTIAL_WRITE",SWIG_From_int((int)(SSL_MODE_ENABLE_PARTIAL_WRITE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER",SWIG_From_int((int)(SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_MODE_AUTO_RETRY",SWIG_From_int((int)(SSL_MODE_AUTO_RETRY))); - SWIG_addvarlink(globals, "_ssl_err", Swig_var__ssl_err_get, Swig_var__ssl_err_set); - SWIG_addvarlink(globals, "_ssl_timeout_err", Swig_var__ssl_timeout_err_get, Swig_var__ssl_timeout_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_DEFAULT",SWIG_From_int((int)(-1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_COMPAT",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_SSL_CLIENT",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_SSL_SERVER",SWIG_From_int((int)(3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_EMAIL",SWIG_From_int((int)(4))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_OBJECT_SIGN",SWIG_From_int((int)(5))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_OCSP_SIGN",SWIG_From_int((int)(6))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_OCSP_REQUEST",SWIG_From_int((int)(7))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_DYNAMIC",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_DYNAMIC_NAME",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_TRUSTED",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_REJECTED",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_UNTRUSTED",SWIG_From_int((int)(3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SSL_CLIENT",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SSL_SERVER",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_NS_SSL_SERVER",SWIG_From_int((int)(3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SMIME_SIGN",SWIG_From_int((int)(4))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SMIME_ENCRYPT",SWIG_From_int((int)(5))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_CRL_SIGN",SWIG_From_int((int)(6))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_ANY",SWIG_From_int((int)(7))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_OCSP_HELPER",SWIG_From_int((int)(8))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_UNKNOWN_MASK",SWIG_From_long((long)((0xfL << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_DEFAULT",SWIG_From_long((long)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_ERROR_UNKNOWN",SWIG_From_long((long)((1L << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_PARSE_UNKNOWN",SWIG_From_long((long)((2L << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_DUMP_UNKNOWN",SWIG_From_long((long)((3L << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_commonName",SWIG_From_int((int)(13))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_countryName",SWIG_From_int((int)(14))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_localityName",SWIG_From_int((int)(15))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_stateOrProvinceName",SWIG_From_int((int)(16))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_organizationName",SWIG_From_int((int)(17))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_organizationalUnitName",SWIG_From_int((int)(18))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_serialNumber",SWIG_From_int((int)(105))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_surname",SWIG_From_int((int)(100))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_givenName",SWIG_From_int((int)(99))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_pkcs9_emailAddress",SWIG_From_int((int)(48))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_OK",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_GET_CRL",SWIG_From_int((int)(3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE",SWIG_From_int((int)(4))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE",SWIG_From_int((int)(5))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",SWIG_From_int((int)(6))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_SIGNATURE_FAILURE",SWIG_From_int((int)(7))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CRL_SIGNATURE_FAILURE",SWIG_From_int((int)(8))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_NOT_YET_VALID",SWIG_From_int((int)(9))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_HAS_EXPIRED",SWIG_From_int((int)(10))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CRL_NOT_YET_VALID",SWIG_From_int((int)(11))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CRL_HAS_EXPIRED",SWIG_From_int((int)(12))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD",SWIG_From_int((int)(13))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD",SWIG_From_int((int)(14))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD",SWIG_From_int((int)(15))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD",SWIG_From_int((int)(16))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_OUT_OF_MEM",SWIG_From_int((int)(17))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT",SWIG_From_int((int)(18))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN",SWIG_From_int((int)(19))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY",SWIG_From_int((int)(20))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE",SWIG_From_int((int)(21))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_CHAIN_TOO_LONG",SWIG_From_int((int)(22))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_REVOKED",SWIG_From_int((int)(23))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_INVALID_CA",SWIG_From_int((int)(24))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_PATH_LENGTH_EXCEEDED",SWIG_From_int((int)(25))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_INVALID_PURPOSE",SWIG_From_int((int)(26))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_UNTRUSTED",SWIG_From_int((int)(27))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_REJECTED",SWIG_From_int((int)(28))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_APPLICATION_VERIFICATION",SWIG_From_int((int)(50))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_ALLOW_PROXY_CERTS",SWIG_From_int((int)(X509_V_FLAG_ALLOW_PROXY_CERTS))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CB_ISSUER_CHECK",SWIG_From_int((int)(X509_V_FLAG_CB_ISSUER_CHECK))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CHECK_SS_SIGNATURE",SWIG_From_int((int)(X509_V_FLAG_CHECK_SS_SIGNATURE))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK_ALL",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK_ALL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_EXPLICIT_POLICY",SWIG_From_int((int)(X509_V_FLAG_EXPLICIT_POLICY))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_EXTENDED_CRL_SUPPORT",SWIG_From_int((int)(X509_V_FLAG_EXTENDED_CRL_SUPPORT))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_IGNORE_CRITICAL",SWIG_From_int((int)(X509_V_FLAG_IGNORE_CRITICAL))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_INHIBIT_ANY",SWIG_From_int((int)(X509_V_FLAG_INHIBIT_ANY))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_INHIBIT_MAP",SWIG_From_int((int)(X509_V_FLAG_INHIBIT_MAP))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_NO_ALT_CHAINS",SWIG_From_int((int)(X509_V_FLAG_NO_ALT_CHAINS))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_NOTIFY_POLICY",SWIG_From_int((int)(X509_V_FLAG_NOTIFY_POLICY))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_PARTIAL_CHAIN",SWIG_From_int((int)(X509_V_FLAG_PARTIAL_CHAIN))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_POLICY_CHECK",SWIG_From_int((int)(X509_V_FLAG_POLICY_CHECK))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_TRUSTED_FIRST",SWIG_From_int((int)(X509_V_FLAG_TRUSTED_FIRST))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_USE_DELTAS",SWIG_From_int((int)(X509_V_FLAG_USE_DELTAS))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_X509_STRICT",SWIG_From_int((int)(X509_V_FLAG_X509_STRICT))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_COMPAT",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SEP_COMMA_PLUS",SWIG_From_int((int)((1 << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SEP_CPLUS_SPC",SWIG_From_int((int)((2 << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SEP_MULTILINE",SWIG_From_int((int)((4 << 16)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_DN_REV",SWIG_From_int((int)((1 << 20)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_FN_LN",SWIG_From_int((int)((1 << 21)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SPC_EQ",SWIG_From_int((int)((1 << 23)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_DUMP_UNKNOWN_FIELDS",SWIG_From_int((int)((1 << 24)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_FN_ALIGN",SWIG_From_int((int)((1 << 25)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_ONELINE",SWIG_From_int((int)((ASN1_STRFLGS_RFC2253|ASN1_STRFLGS_ESC_QUOTE|XN_FLAG_SEP_CPLUS_SPC|XN_FLAG_SPC_EQ)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_MULTILINE",SWIG_From_int((int)((ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB|XN_FLAG_SEP_MULTILINE|XN_FLAG_SPC_EQ|XN_FLAG_FN_LN|XN_FLAG_FN_ALIGN)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_RFC2253",SWIG_From_int((int)((ASN1_STRFLGS_RFC2253|XN_FLAG_SEP_COMMA_PLUS|XN_FLAG_DN_REV|XN_FLAG_DUMP_UNKNOWN_FIELDS)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "RSA_3",SWIG_From_int((int)(0x3L))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "RSA_F4",SWIG_From_int((int)(0x10001L))); - SWIG_addvarlink(globals, "_x509_err", Swig_var__x509_err_get, Swig_var__x509_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_2253",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_CTRL",SWIG_From_int((int)(2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_MSB",SWIG_From_int((int)(4))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_QUOTE",SWIG_From_int((int)(8))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_UTF8_CONVERT",SWIG_From_int((int)(0x10))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_IGNORE_TYPE",SWIG_From_int((int)(0x20))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_SHOW_TYPE",SWIG_From_int((int)(0x40))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_DUMP_ALL",SWIG_From_int((int)(0x80))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_DUMP_UNKNOWN",SWIG_From_int((int)(0x100))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_DUMP_DER",SWIG_From_int((int)(0x200))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_RFC2253",SWIG_From_int((int)((ASN1_STRFLGS_ESC_2253|ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB|ASN1_STRFLGS_UTF8_CONVERT|ASN1_STRFLGS_DUMP_UNKNOWN|ASN1_STRFLGS_DUMP_DER)))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_TEXT",SWIG_From_int((int)(0x1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOCERTS",SWIG_From_int((int)(0x2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOSIGS",SWIG_From_int((int)(0x4))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOCHAIN",SWIG_From_int((int)(0x8))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOINTERN",SWIG_From_int((int)(0x10))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOVERIFY",SWIG_From_int((int)(0x20))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_DETACHED",SWIG_From_int((int)(0x40))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_BINARY",SWIG_From_int((int)(0x80))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOATTR",SWIG_From_int((int)(0x100))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_SIGNED",SWIG_From_int((int)(NID_pkcs7_signed))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_ENVELOPED",SWIG_From_int((int)(NID_pkcs7_enveloped))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_SIGNED_ENVELOPED",SWIG_From_int((int)(NID_pkcs7_signedAndEnveloped))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_DATA",SWIG_From_int((int)(NID_pkcs7_data))); - SWIG_addvarlink(globals, "_pkcs7_err", Swig_var__pkcs7_err_get, Swig_var__pkcs7_err_set); - SWIG_addvarlink(globals, "_smime_err", Swig_var__smime_err_get, Swig_var__smime_err_set); - SWIG_addvarlink(globals, "_util_err", Swig_var__util_err_get, Swig_var__util_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_NO_EC",SWIG_From_int((int)(0))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp112r1",SWIG_From_int((int)(NID_secp112r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp112r2",SWIG_From_int((int)(NID_secp112r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp128r1",SWIG_From_int((int)(NID_secp128r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp128r2",SWIG_From_int((int)(NID_secp128r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp160k1",SWIG_From_int((int)(NID_secp160k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp160r1",SWIG_From_int((int)(NID_secp160r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp160r2",SWIG_From_int((int)(NID_secp160r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp192k1",SWIG_From_int((int)(NID_secp192k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp224k1",SWIG_From_int((int)(NID_secp224k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp224r1",SWIG_From_int((int)(NID_secp224r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp256k1",SWIG_From_int((int)(NID_secp256k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp384r1",SWIG_From_int((int)(NID_secp384r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp521r1",SWIG_From_int((int)(NID_secp521r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect113r1",SWIG_From_int((int)(NID_sect113r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect113r2",SWIG_From_int((int)(NID_sect113r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect131r1",SWIG_From_int((int)(NID_sect131r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect131r2",SWIG_From_int((int)(NID_sect131r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect163k1",SWIG_From_int((int)(NID_sect163k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect163r1",SWIG_From_int((int)(NID_sect163r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect163r2",SWIG_From_int((int)(NID_sect163r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect193r1",SWIG_From_int((int)(NID_sect193r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect193r2",SWIG_From_int((int)(NID_sect193r2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect233k1",SWIG_From_int((int)(NID_sect233k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect233r1",SWIG_From_int((int)(NID_sect233r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect239k1",SWIG_From_int((int)(NID_sect239k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect283k1",SWIG_From_int((int)(NID_sect283k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect283r1",SWIG_From_int((int)(NID_sect283r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect409k1",SWIG_From_int((int)(NID_sect409k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect409r1",SWIG_From_int((int)(NID_sect409r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect571k1",SWIG_From_int((int)(NID_sect571k1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect571r1",SWIG_From_int((int)(NID_sect571r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime192v1",SWIG_From_int((int)(NID_X9_62_prime192v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime192v2",SWIG_From_int((int)(NID_X9_62_prime192v2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime192v3",SWIG_From_int((int)(NID_X9_62_prime192v3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime239v1",SWIG_From_int((int)(NID_X9_62_prime239v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime239v2",SWIG_From_int((int)(NID_X9_62_prime239v2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime239v3",SWIG_From_int((int)(NID_X9_62_prime239v3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime256v1",SWIG_From_int((int)(NID_X9_62_prime256v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb163v1",SWIG_From_int((int)(NID_X9_62_c2pnb163v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb163v2",SWIG_From_int((int)(NID_X9_62_c2pnb163v2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb163v3",SWIG_From_int((int)(NID_X9_62_c2pnb163v3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb176v1",SWIG_From_int((int)(NID_X9_62_c2pnb176v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb191v1",SWIG_From_int((int)(NID_X9_62_c2tnb191v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb191v2",SWIG_From_int((int)(NID_X9_62_c2tnb191v2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb191v3",SWIG_From_int((int)(NID_X9_62_c2tnb191v3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb208w1",SWIG_From_int((int)(NID_X9_62_c2pnb208w1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb239v1",SWIG_From_int((int)(NID_X9_62_c2tnb239v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb239v2",SWIG_From_int((int)(NID_X9_62_c2tnb239v2))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb239v3",SWIG_From_int((int)(NID_X9_62_c2tnb239v3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb272w1",SWIG_From_int((int)(NID_X9_62_c2pnb272w1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb304w1",SWIG_From_int((int)(NID_X9_62_c2pnb304w1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb359v1",SWIG_From_int((int)(NID_X9_62_c2tnb359v1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb368w1",SWIG_From_int((int)(NID_X9_62_c2pnb368w1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb431r1",SWIG_From_int((int)(NID_X9_62_c2tnb431r1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls1",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls3",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls4",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls4))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls5",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls5))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls6",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls6))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls7",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls7))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls8",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls8))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls9",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls9))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls10",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls10))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls11",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls11))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls12",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls12))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_ipsec3",SWIG_From_int((int)(NID_ipsec3))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_ipsec4",SWIG_From_int((int)(NID_ipsec4))); - SWIG_addvarlink(globals, "_ec_err", Swig_var__ec_err_get, Swig_var__ec_err_set); - - /* type '::_cbd_t' */ - builtin_pytype = (PyTypeObject *)&SwigPyBuiltin___cbd_t_type; - builtin_pytype->tp_dict = d = PyDict_New(); - SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); - builtin_pytype->tp_new = PyType_GenericNew; - builtin_base_count = 0; - builtin_bases[builtin_base_count] = NULL; - SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); - PyDict_SetItemString(d, "this", this_descr); - PyDict_SetItemString(d, "thisown", thisown_descr); - if (PyType_Ready(builtin_pytype) < 0) { - PyErr_SetString(PyExc_TypeError, "Could not create type '_cbd_t'."); -#if PY_VERSION_HEX >= 0x03000000 - return NULL; -#else - return; -#endif - } - Py_INCREF(builtin_pytype); - PyModule_AddObject(m, "_cbd_t", (PyObject *)builtin_pytype); - SwigPyBuiltin_AddPublicSymbol(public_interface, "_cbd_t"); - d = md; - SWIG_addvarlink(globals, "_engine_err", Swig_var__engine_err_get, Swig_var__engine_err_set); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_RSA",SWIG_From_int((int)(0x0001))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_DSA",SWIG_From_int((int)(0x0002))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_DH",SWIG_From_int((int)(0x0004))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_RAND",SWIG_From_int((int)(0x0008))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_ECDH",SWIG_From_int((int)(0x0010))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_ECDSA",SWIG_From_int((int)(0x0020))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_CIPHERS",SWIG_From_int((int)(0x0040))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_DIGESTS",SWIG_From_int((int)(0x0080))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_STORE",SWIG_From_int((int)(0x0100))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_ALL",SWIG_From_int((int)(0xFFFF))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_NONE",SWIG_From_int((int)(0x0000))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "encrypt",SWIG_From_int((int)(1))); - SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "decrypt",SWIG_From_int((int)(0))); - - /* Initialize threading */ - SWIG_PYTHON_INITIALIZE_THREADS; -#if PY_VERSION_HEX >= 0x03000000 - return m; -#else - return; -#endif -} - diff --git a/SWIG/_objects.i b/SWIG/_objects.i deleted file mode 100644 index b389d7f..0000000 --- a/SWIG/_objects.i +++ /dev/null @@ -1,97 +0,0 @@ -/* - * -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: syntax=c sts=4 sw=4 - * - * ASN1_OBJECT manipulation functions from OBJ_obj2txt(3SSL). - * - * Pavel Shramov - * IMEC MSU - */ -%{ -#include -%} - -%apply Pointer NONNULL { ASN1_OBJECT * }; -%apply Pointer NONNULL { const char * }; - -%rename(obj_nid2obj) OBJ_nid2obj; -extern ASN1_OBJECT * OBJ_nid2obj(int n); -%rename(obj_nid2ln) OBJ_nid2ln; -extern const char * OBJ_nid2ln(int n); -%rename(obj_nid2sn) OBJ_nid2sn; -extern const char * OBJ_nid2sn(int n); - -%rename(obj_obj2nid) OBJ_obj2nid; -extern int OBJ_obj2nid(const ASN1_OBJECT *o); - -%rename(obj_ln2nid) OBJ_ln2nid; -extern int OBJ_ln2nid(const char *ln); -%rename(obj_sn2nid) OBJ_sn2nid; -extern int OBJ_sn2nid(const char *sn); - -%rename(obj_txt2nid) OBJ_txt2nid; -extern int OBJ_txt2nid(const char *s); - -%rename(obj_txt2obj) OBJ_txt2obj; -extern ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); - - -%rename(_obj_obj2txt) OBJ_obj2txt; -extern int OBJ_obj2txt(char *, int, const ASN1_OBJECT *, int); - - -%inline %{ -/* - From the manpage for OBJ_obt2txt (): - BUGS - OBJ_obj2txt() is awkward and messy to use: it doesn’t follow the - convention of other OpenSSL functions where the buffer can be set - to NULL to determine the amount of data that should be written. - Instead buf must point to a valid buffer and buf_len should be set - to a positive value. A buffer length of 80 should be more than - enough to handle any OID encountered in practice. - - The first call to OBJ_obj2txt () therefore passes a non-NULL dummy - buffer. This wart is reportedly removed in OpenSSL 0.9.8b, although - the manpage has not been updated. - - OBJ_obj2txt always prints \0 at the end. But the return value - is the number of "good" bytes written. So memory is allocated for - len + 1 bytes but only len bytes are marshalled to python. -*/ -PyObject *obj_obj2txt(const ASN1_OBJECT *obj, int no_name) -{ - int len; - PyObject *ret; - char *buf; - char dummy[1]; - - len = OBJ_obj2txt(dummy, 1, obj, no_name); - if (len < 0) { - m2_PyErr_Msg(PyExc_RuntimeError); - return NULL; - } else if (len == 0) { - /* XXX: For OpenSSL prior to 0.9.8b. - - Changes between 0.9.8a and 0.9.8b [04 May 2006] - ... - *) Several fixes and enhancements to the OID generation code. The old code - sometimes allowed invalid OIDs (1.X for X >= 40 for example), couldn't - handle numbers larger than ULONG_MAX, truncated printing and had a - non standard OBJ_obj2txt() behaviour. - [Steve Henson] - */ - - len = 80; - } - - buf = PyMem_Malloc(len + 1); - len = OBJ_obj2txt(buf, len + 1, obj, no_name); - - ret = PyBytes_FromStringAndSize(buf, len); - - PyMem_Free(buf); - - return ret; -} -%} diff --git a/SWIG/_pkcs7.i b/SWIG/_pkcs7.i deleted file mode 100644 index d1fddfb..0000000 --- a/SWIG/_pkcs7.i +++ /dev/null @@ -1,284 +0,0 @@ -/* Copyright (c) 2000 Ng Pheng Siong. All rights reserved. - * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. -*/ -/* $Id$ */ - -%{ -#include -#include -#include -#include -%} - -%apply Pointer NONNULL { BIO * }; -%apply Pointer NONNULL { EVP_CIPHER * }; -%apply Pointer NONNULL { EVP_PKEY * }; -%apply Pointer NONNULL { PKCS7 * }; -%apply Pointer NONNULL { STACK_OF(X509) * }; -%apply Pointer NONNULL { X509 * }; - -%rename(pkcs7_new) PKCS7_new; -extern PKCS7 *PKCS7_new(void); -%rename(pkcs7_free) PKCS7_free; -extern void PKCS7_free(PKCS7 *); -%rename(pkcs7_add_certificate) PKCS7_add_certificate; -extern void PKCS7_add_certificate(PKCS7 *, X509 *); - -/* S/MIME operation */ -%constant int PKCS7_TEXT = 0x1; -%constant int PKCS7_NOCERTS = 0x2; -%constant int PKCS7_NOSIGS = 0x4; -%constant int PKCS7_NOCHAIN = 0x8; -%constant int PKCS7_NOINTERN = 0x10; -%constant int PKCS7_NOVERIFY = 0x20; -%constant int PKCS7_DETACHED = 0x40; -%constant int PKCS7_BINARY = 0x80; -%constant int PKCS7_NOATTR = 0x100; - -%constant int PKCS7_SIGNED = NID_pkcs7_signed; -%constant int PKCS7_ENVELOPED = NID_pkcs7_enveloped; -%constant int PKCS7_SIGNED_ENVELOPED = NID_pkcs7_signedAndEnveloped; -%constant int PKCS7_DATA = NID_pkcs7_data; - -%warnfilter(454) _pkcs7_err; -%warnfilter(454) _smime_err; -%inline %{ -static PyObject *_pkcs7_err, *_smime_err; - -void pkcs7_init(PyObject *pkcs7_err) { - Py_INCREF(pkcs7_err); - _pkcs7_err = pkcs7_err; -} - -void smime_init(PyObject *smime_err) { - Py_INCREF(smime_err); - _smime_err = smime_err; -} -%} - -%inline %{ -PyObject *pkcs7_decrypt(PKCS7 *pkcs7, EVP_PKEY *pkey, X509 *cert, int flags) { - int outlen; - char *outbuf; - BIO *bio; - PyObject *ret; - - if (!(bio=BIO_new(BIO_s_mem()))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); - return NULL; - } - if (!PKCS7_decrypt(pkcs7, pkey, cert, bio, flags)) { - m2_PyErr_Msg(_pkcs7_err); - BIO_free(bio); - return NULL; - } - outlen = BIO_ctrl_pending(bio); - if (!(outbuf=(char *)PyMem_Malloc(outlen))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); - BIO_free(bio); - return NULL; - } - BIO_read(bio, outbuf, outlen); - - ret = PyBytes_FromStringAndSize(outbuf, outlen); - - BIO_free(bio); - PyMem_Free(outbuf); - return ret; -} -%} - -%typemap(out) PKCS7 * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_smime_err); - $result = NULL; - } -} -%threadallow pkcs7_encrypt; -%inline %{ -PKCS7 *pkcs7_encrypt(STACK_OF(X509) *stack, BIO *bio, EVP_CIPHER *cipher, int flags) { - return PKCS7_encrypt(stack, bio, cipher, flags); -} - -%} - -%threadallow pkcs7_sign1; -%inline %{ -PKCS7 *pkcs7_sign1(X509 *x509, EVP_PKEY *pkey, STACK_OF(X509) *stack, BIO *bio, EVP_MD *hash, int flags) { - - PKCS7 *p7 = PKCS7_sign(NULL, NULL, stack, bio, flags | PKCS7_STREAM); - if (p7 == NULL) { - return NULL; - } - if (PKCS7_sign_add_signer(p7, x509, pkey, hash, flags) == NULL) { - return NULL; - } - if (PKCS7_final(p7, bio, flags) != 1) { - return NULL; - } - return p7; -} -%} - -%threadallow pkcs7_sign0; -%inline %{ -PKCS7 *pkcs7_sign0(X509 *x509, EVP_PKEY *pkey, BIO *bio, EVP_MD *hash, int flags) { - return pkcs7_sign1(x509, pkey, NULL, bio, hash, flags); -} -%} - -%typemap(out) PKCS7 * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_pkcs7_err); - $result = NULL; - } -} -%threadallow pkcs7_read_bio; -%inline %{ -PKCS7 *pkcs7_read_bio(BIO *bio) { - return PEM_read_bio_PKCS7(bio, NULL, NULL, NULL); -} -%} - -%threadallow pkcs7_read_bio_der; -%inline %{ -PKCS7 *pkcs7_read_bio_der(BIO *bio) { - return d2i_PKCS7_bio(bio, NULL); -} -%} - -%typemap(out) PKCS7 * ; - -%inline %{ -PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, BIO *data, int flags) { - int res, outlen; - char *outbuf; - BIO *bio; - PyObject *ret; - - if (!(bio=BIO_new(BIO_s_mem()))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); - return NULL; - } - Py_BEGIN_ALLOW_THREADS - res = PKCS7_verify(pkcs7, stack, store, data, bio, flags); - Py_END_ALLOW_THREADS - if (!res) { - m2_PyErr_Msg(_pkcs7_err); - BIO_free(bio); - return NULL; - } - outlen = BIO_ctrl_pending(bio); - if (!(outbuf=(char *)PyMem_Malloc(outlen))) { - PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); - BIO_free(bio); - return NULL; - } - BIO_read(bio, outbuf, outlen); - - ret = PyBytes_FromStringAndSize(outbuf, outlen); - - BIO_free(bio); - PyMem_Free(outbuf); - return ret; -} - -PyObject *pkcs7_verify0(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, int flags) { - return pkcs7_verify1(pkcs7, stack, store, NULL, flags); -} -%} - -%threadallow smime_write_pkcs7_multi; -%inline %{ -int smime_write_pkcs7_multi(BIO *bio, PKCS7 *pkcs7, BIO *data, int flags) { - return SMIME_write_PKCS7(bio, pkcs7, data, flags | PKCS7_DETACHED); -} -%} - -%threadallow smime_write_pkcs7; -%inline %{ -int smime_write_pkcs7(BIO *bio, PKCS7 *pkcs7, int flags) { - return SMIME_write_PKCS7(bio, pkcs7, NULL, flags); -} - -PyObject *smime_read_pkcs7(BIO *bio) { - BIO *bcont = NULL; - PKCS7 *p7; - PyObject *tuple, *_p7, *_BIO; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if (BIO_method_type(bio) == BIO_TYPE_MEM) { - /* OpenSSL FAQ explains that this is needed for mem BIO to return EOF, - * like file BIO does. Might need to do this for more mem BIOs but - * not sure if that is safe, so starting with just this single place. - */ - BIO_set_mem_eof_return(bio, 0); - } - - Py_BEGIN_ALLOW_THREADS - p7=SMIME_read_PKCS7(bio, &bcont); - Py_END_ALLOW_THREADS - if (!p7) { - m2_PyErr_Msg(_smime_err); - return NULL; - } - if (!(tuple=PyTuple_New(2))) { - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - return NULL; - } - _p7 = SWIG_NewPointerObj((void *)p7, SWIGTYPE_p_PKCS7, 0); - PyTuple_SET_ITEM(tuple, 0, _p7); - if (!bcont) { - Py_INCREF(Py_None); - PyTuple_SET_ITEM(tuple, 1, Py_None); - } else { - _BIO = SWIG_NewPointerObj((void *)bcont, SWIGTYPE_p_BIO, 0); - PyTuple_SET_ITEM(tuple, 1, _BIO); - } - return tuple; -} -%} - -%threadallow pkcs7_write_bio; -%inline %{ -int pkcs7_write_bio(PKCS7 *pkcs7, BIO* bio) { - return PEM_write_bio_PKCS7(bio, pkcs7); -} -%} - -%threadallow pkcs7_write_bio_der; -%inline %{ -int pkcs7_write_bio_der(PKCS7 *pkcs7, BIO *bio) { - return i2d_PKCS7_bio(bio, pkcs7); -} - -int pkcs7_type_nid(PKCS7 *pkcs7) { - return OBJ_obj2nid(pkcs7->type); -} - -const char *pkcs7_type_sn(PKCS7 *pkcs7) { - return OBJ_nid2sn(OBJ_obj2nid(pkcs7->type)); -} -%} - -%threadallow smime_crlf_copy; -%inline %{ -int smime_crlf_copy(BIO *in, BIO *out) { - return SMIME_crlf_copy(in, out, PKCS7_TEXT); -} - -/* return STACK_OF(X509)* */ -STACK_OF(X509) *pkcs7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) { - return PKCS7_get0_signers(p7, certs, flags); -} - -%} - diff --git a/SWIG/_py3k_compat.i b/SWIG/_py3k_compat.i deleted file mode 100644 index 7c90bb4..0000000 --- a/SWIG/_py3k_compat.i +++ /dev/null @@ -1,43 +0,0 @@ -%{ -#if PY_MAJOR_VERSION >= 3 - -FILE* PyFile_AsFile(PyObject *pyfile) { - FILE* fp; - int fd; - const char *mode_str = NULL; - PyObject *mode_obj; - - if ((fd = PyObject_AsFileDescriptor(pyfile)) == -1) { - PyErr_SetString(PyExc_BlockingIOError, - "Cannot find file handler for the Python file!"); - return NULL; - } - - if ((mode_obj = PyObject_GetAttrString(pyfile, "mode")) == NULL) { - mode_str = "rb"; - PyErr_Clear(); - } - else { - /* convert to plain string - * note that error checking is embedded in the function - */ - mode_str = PyUnicode_AsUTF8AndSize(mode_obj, NULL); - } - - if((fp = fdopen(fd, mode_str)) == NULL) { - PyErr_SetFromErrno(PyExc_IOError); - } - - Py_XDECREF(mode_obj); - return fp; -} - -#else /* PY2K */ - -#define PyLong_FromLong(x) PyInt_FromLong(x) -#define PyUnicode_AsUTF8(x) PyString_AsString(x) -#define PyUnicode_FromString(x) PyString_FromString(x) -#define PyUnicode_Format(x, y) PyString_Format(x, y) - -#endif /* PY_MAJOR_VERSION */ -%} diff --git a/SWIG/_rand.i b/SWIG/_rand.i deleted file mode 100644 index 01ab4ef..0000000 --- a/SWIG/_rand.i +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. - * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. -*/ -/* $Id: _rand.i 721 2010-02-13 06:30:33Z heikki $ */ - -%module _rand - -%rename(rand_file_name) RAND_file_name; -extern const char *RAND_file_name(char *, size_t ); -%rename(rand_load_file) RAND_load_file; -extern int RAND_load_file(const char *, long); -%rename(rand_save_file) RAND_write_file; -extern int RAND_write_file(const char *); -%rename(rand_poll) RAND_poll; -extern int RAND_poll(void); -%rename(rand_status) RAND_status; -extern int RAND_status(void); -%rename(rand_cleanup) RAND_cleanup; -extern void RAND_cleanup(void); - -%warnfilter(454) _rand_err; -%inline %{ -static PyObject *_rand_err; - -void rand_init(PyObject *rand_err) { - Py_INCREF(rand_err); - _rand_err = rand_err; -} - -PyObject *rand_seed(PyObject *seed) { - const void *buf; - int len = 0; - - m2_PyObject_AsReadBufferInt(seed, &buf, &len); - - RAND_seed(buf, len); - Py_RETURN_NONE; -} - -PyObject *rand_add(PyObject *blob, double entropy) { - const void *buf; - int len = 0; - - m2_PyObject_AsReadBufferInt(blob, &buf, &len); - - RAND_add(buf, len, entropy); - Py_RETURN_NONE; -} - -PyObject *rand_bytes(int n) { - void *blob; - int ret; - PyObject *obj; - - if (!(blob = PyMem_Malloc(n))) { - PyErr_SetString(PyExc_MemoryError, - "Insufficient memory for rand_bytes."); - return NULL; - } - if ((ret = RAND_bytes(blob, n)) == 1) { - obj = PyBytes_FromStringAndSize(blob, n); - PyMem_Free(blob); - return obj; - } else if (ret == 0) { - PyErr_SetString(_rand_err, "Not enough randomness."); - PyMem_Free(blob); - return NULL; - } else if (ret == -1) { - PyErr_SetString(_rand_err, - "Not supported by the current RAND method."); - PyMem_Free(blob); - return NULL; - } else { - PyMem_Free(blob); - m2_PyErr_Msg(_rand_err); - return NULL; - } -} - -PyObject *rand_pseudo_bytes(int n) { - int ret; - unsigned char *blob; - PyObject *tuple; - - if (!(blob=(unsigned char *)PyMem_Malloc(n))) { - PyErr_SetString(PyExc_MemoryError, "Insufficient memory for rand_pseudo_bytes."); - return NULL; - } - if (!(tuple=PyTuple_New(2))) { - PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); - PyMem_Free(blob); - return NULL; - } - ret = RAND_pseudo_bytes(blob, n); - if (ret == -1) { - PyMem_Free(blob); - Py_DECREF(tuple); - PyErr_SetString(_rand_err, - "Function RAND_pseudo_bytes not supported by the current RAND method."); - return NULL; - } else { - PyTuple_SET_ITEM(tuple, 0, PyBytes_FromStringAndSize((char*)blob, n)); - - PyMem_Free(blob); - PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong((long)ret)); - return tuple; - } -} - -PyObject *rand_file_name(void) { - PyObject *obj; - char *str; - if ((obj = PyBytes_FromStringAndSize(NULL, BUFSIZ))==NULL) { - PyErr_SetString(PyExc_MemoryError, "rand_file_name"); - return NULL; - } - str=PyBytes_AS_STRING(obj); - if (RAND_file_name(str, BUFSIZ)==NULL) { - PyErr_SetString(PyExc_RuntimeError, "rand_file_name"); - return NULL; - } - if (_PyBytes_Resize(&obj, (Py_ssize_t)strlen(str))!=0) - return NULL; /* mem exception set by _PyBytes_Resize */ - return obj; -} - -void rand_screen(void) { -#ifdef _WIN32 - RAND_screen(); -#endif -} - -int rand_win32_event(unsigned int imsg, int wparam, long lparam) { -#ifdef _WIN32 - return RAND_event(imsg, wparam, lparam); -#else - return 0; -#endif -} -%} - -/* -2004-04-05, ngps: Still missing: - RAND_egd - RAND_egd_bytes - RAND_query_egd_bytes -*/ - - diff --git a/SWIG/_rc4.i b/SWIG/_rc4.i deleted file mode 100644 index eb4747e..0000000 --- a/SWIG/_rc4.i +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%include - -#if defined(OPENSSL_NO_RC4) -#undef OPENSSL_NO_RC4 -%constant OPENSSL_NO_RC4 = 1; -#else -%constant OPENSSL_NO_RC4 = 0; - -%{ -#include -%} - -%apply Pointer NONNULL { RC4_KEY * }; - -%inline %{ -RC4_KEY *rc4_new(void) { - RC4_KEY *key; - - if (!(key = (RC4_KEY *)PyMem_Malloc(sizeof(RC4_KEY)))) - PyErr_SetString(PyExc_MemoryError, "rc4_new"); - return key; -} - -void rc4_free(RC4_KEY *key) { - PyMem_Free((void *)key); -} - -PyObject *rc4_set_key(RC4_KEY *key, PyObject *value) { - const void *vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - RC4_set_key(key, vlen, vbuf); - Py_RETURN_NONE; -} - -PyObject *rc4_update(RC4_KEY *key, PyObject *in) { - PyObject *ret; - const void *buf; - Py_ssize_t len; - void *out; - - if (PyObject_AsReadBuffer(in, &buf, &len) == -1) - return NULL; - - if (!(out = PyMem_Malloc(len))) { - PyErr_SetString(PyExc_MemoryError, "expected a string object"); - return NULL; - } - RC4(key, len, buf, out); - - ret = PyBytes_FromStringAndSize(out, len); - - PyMem_Free(out); - return ret; -} - -int rc4_type_check(RC4_KEY *key) { - return 1; -} -%} - -#endif diff --git a/SWIG/_rsa.i b/SWIG/_rsa.i deleted file mode 100644 index 4ffae01..0000000 --- a/SWIG/_rsa.i +++ /dev/null @@ -1,518 +0,0 @@ -/* Copyright (c) 1999-2000 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%{ -#include -#include -#include -#include -#include -%} - -%apply Pointer NONNULL { RSA * }; -%apply Pointer NONNULL { PyObject *pyfunc }; - -%rename(rsa_size) RSA_size; -extern int RSA_size(const RSA*); -%rename(rsa_new) RSA_new; -extern RSA *RSA_new(void); -%rename(rsa_free) RSA_free; -extern void RSA_free(RSA *); -%rename(rsa_check_key) RSA_check_key; -extern int RSA_check_key(const RSA *); - -%constant int no_padding = RSA_NO_PADDING; -%constant int pkcs1_padding = RSA_PKCS1_PADDING; -%constant int sslv23_padding = RSA_SSLV23_PADDING; -%constant int pkcs1_oaep_padding = RSA_PKCS1_OAEP_PADDING; - -%constant int NID_sha1 = NID_sha1; - -#if OPENSSL_VERSION_NUMBER >= 0x0090800fL -%constant int NID_sha224 = NID_sha224; -%constant int NID_sha256 = NID_sha256; -%constant int NID_sha384 = NID_sha384; -%constant int NID_sha512 = NID_sha512; -#endif - -%constant int NID_md5 = NID_md5; - -%constant int NID_ripemd160 = NID_ripemd160; - -%warnfilter(454) _rsa_err; -%inline %{ -static PyObject *_rsa_err; - -void rsa_init(PyObject *rsa_err) { - Py_INCREF(rsa_err); - _rsa_err = rsa_err; -} -%} - -%inline %{ -RSA *rsa_read_key(BIO *f, PyObject *pyfunc) { - RSA *rsa; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - rsa = PEM_read_bio_RSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return rsa; -} -%} - -%inline %{ -int rsa_write_key(RSA *rsa, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_RSAPrivateKey(f, rsa, cipher, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%inline %{ -int rsa_write_key_no_cipher(RSA *rsa, BIO *f, PyObject *pyfunc) { - int ret; - - Py_INCREF(pyfunc); - Py_BEGIN_ALLOW_THREADS - ret = PEM_write_bio_RSAPrivateKey(f, rsa, NULL, NULL, 0, - passphrase_callback, (void *)pyfunc); - Py_END_ALLOW_THREADS - Py_DECREF(pyfunc); - return ret; -} -%} - -%threadallow rsa_read_pub_key; -%inline %{ -RSA *rsa_read_pub_key(BIO *f) { - return PEM_read_bio_RSA_PUBKEY(f, NULL, NULL, NULL); -} -%} - -%threadallow rsa_write_pub_key; -%inline %{ -int rsa_write_pub_key(RSA *rsa, BIO *f) { - return PEM_write_bio_RSA_PUBKEY(f, rsa); -} - -PyObject *rsa_get_e(RSA *rsa) { - const BIGNUM* e = NULL; - RSA_get0_key(rsa, NULL, &e, NULL); - if (!e) { - PyErr_SetString(_rsa_err, "'e' is unset"); - return NULL; - } - return bn_to_mpi(e); -} - -PyObject *rsa_get_n(RSA *rsa) { - const BIGNUM* n = NULL; - RSA_get0_key(rsa, &n, NULL, NULL); - if (!n) { - PyErr_SetString(_rsa_err, "'n' is unset"); - return NULL; - } - return bn_to_mpi(n); -} - -PyObject *rsa_set_e(RSA *rsa, PyObject *eval) { - const BIGNUM* n_read = NULL; - BIGNUM* n = NULL; - BIGNUM* e; - - if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err))) { - return NULL; - } - - /* n and e must be set at the same time so if e is unset, set it to zero */ - RSA_get0_key(rsa, &n_read, NULL, NULL); - if (!n_read) { - n = BN_new(); - } - - if (RSA_set0_key(rsa, n, e, NULL) != 1) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(e); - BN_free(n); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *rsa_set_n(RSA *rsa, PyObject *nval) { - BIGNUM* n; - const BIGNUM* e_read = NULL; - BIGNUM* e = NULL; - - if (!(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { - return NULL; - } - - /* n and e must be set at the same time so if e is unset, set it to zero */ - RSA_get0_key(rsa, NULL, &e_read, NULL); - if (!e_read) { - e = BN_new(); - } - - if (RSA_set0_key(rsa, n, e, NULL) != 1) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(n); - BN_free(e); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *rsa_set_en(RSA *rsa, PyObject *eval, PyObject* nval) { - BIGNUM* e, *n; - - if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err)) || - !(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { - return NULL; - } - - if (!RSA_set0_key(rsa, n, e, NULL)) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(e); - BN_free(n); - return NULL; - } - Py_RETURN_NONE; -} - -static BIGNUM* PyObject_Bin_AsBIGNUM(PyObject* value) { - BIGNUM* bn; - const void* vbuf; - int vlen = 0; - - if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) - return NULL; - - if (!(bn = BN_bin2bn((unsigned char *)vbuf, vlen, NULL))) { - m2_PyErr_Msg(_rsa_err); - return NULL; - } - - return bn; -} - -PyObject *rsa_set_en_bin(RSA *rsa, PyObject *eval, PyObject* nval) { - BIGNUM* e, *n; - - if (!(e = PyObject_Bin_AsBIGNUM(eval)) || - !(n = PyObject_Bin_AsBIGNUM(nval))) { - return NULL; - } - - if (!RSA_set0_key(rsa, e, n, NULL)) { - PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); - BN_free(e); - BN_free(n); - return NULL; - } - Py_RETURN_NONE; -} - -PyObject *rsa_private_encrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_private_encrypt"); - return NULL; - } - tlen = RSA_private_encrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -PyObject *rsa_public_decrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen = 0; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - /* OpenSSL docs are confused here: it says we only need buffer - * 'RSA_size()-11', but it is true only for RSA PKCS#1 type 1 - * padding. For other uses we need to use different sizes. */ - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_public_decrypt"); - return NULL; - } - tlen = RSA_public_decrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -PyObject *rsa_public_encrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_public_encrypt"); - return NULL; - } - tlen = RSA_public_encrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -PyObject *rsa_private_decrypt(RSA *rsa, PyObject *from, int padding) { - const void *fbuf; - void *tbuf; - int flen = 0, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) - return NULL; - - if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { - PyErr_SetString(PyExc_MemoryError, "rsa_private_decrypt"); - return NULL; - } - tlen = RSA_private_decrypt(flen, (unsigned char *)fbuf, - (unsigned char *)tbuf, rsa, padding); - if (tlen == -1) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(tbuf); - return NULL; - } - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - - PyMem_Free(tbuf); - return ret; -} - -#if OPENSSL_VERSION_NUMBER >= 0x0090708fL -PyObject *rsa_padding_add_pkcs1_pss(RSA *rsa, PyObject *digest, EVP_MD *hash, int salt_length) { - const void *dbuf; - unsigned char *tbuf; - int dlen, result, tlen; - PyObject *ret; - - if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) - return NULL; - - tlen = RSA_size(rsa); - - if (!(tbuf = OPENSSL_malloc(tlen))) { - PyErr_SetString(PyExc_MemoryError, "rsa_padding_add_pkcs1_pss"); - return NULL; - } - result = RSA_padding_add_PKCS1_PSS( - rsa, - tbuf, - (unsigned char *)dbuf, - hash, - salt_length); - - if (result == -1) { - m2_PyErr_Msg(_rsa_err); - OPENSSL_cleanse(tbuf, tlen); - OPENSSL_free(tbuf); - return NULL; - } - ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); - OPENSSL_cleanse(tbuf, tlen); - OPENSSL_free(tbuf); - return ret; -} - -int rsa_verify_pkcs1_pss(RSA *rsa, PyObject *digest, PyObject *signature, EVP_MD *hash, int salt_length) { - const void *dbuf; - const void *sbuf; - int dlen, slen, ret; - - if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) { - return 0; - } - - if (m2_PyObject_AsReadBufferInt(signature, &sbuf, &slen) == -1) { - return 0; - } - - ret = RSA_verify_PKCS1_PSS( - rsa, - (unsigned char *)dbuf, - hash, - (unsigned char *)sbuf, - salt_length); - - return ret; -} -#endif - -PyObject *rsa_sign(RSA *rsa, PyObject *py_digest_string, int method_type) { - int digest_len = 0; - int buf_len = 0; - int ret = 0; - unsigned int real_buf_len = 0; - char *digest_string = NULL; - unsigned char * sign_buf = NULL; - PyObject *signature; - - ret = m2_PyString_AsStringAndSizeInt(py_digest_string, &digest_string, - &digest_len); - if (ret == -1) { - /* PyString_AsStringAndSize raises the correct exceptions. */ - return NULL; - } - - buf_len = RSA_size(rsa); - sign_buf = (unsigned char *)PyMem_Malloc(buf_len); - ret = RSA_sign(method_type, (const unsigned char *)digest_string, digest_len, - sign_buf, &real_buf_len, rsa); - - if (!ret) { - m2_PyErr_Msg(_rsa_err); - PyMem_Free(sign_buf); - return NULL; - } - - signature = PyBytes_FromStringAndSize((const char*) sign_buf, buf_len); - - PyMem_Free(sign_buf); - return signature; -} - -int rsa_verify(RSA *rsa, PyObject *py_verify_string, PyObject* py_sign_string, int method_type){ - int ret = 0; - char * sign_string = NULL; - char * verify_string = NULL; - int verify_len = 0; - int sign_len = 0; - - ret = m2_PyString_AsStringAndSizeInt(py_verify_string, &verify_string, - &verify_len); - if (ret == -1) { - /* PyString_AsStringAndSize raises the correct exceptions. */ - return 0; - } - ret = m2_PyString_AsStringAndSizeInt(py_sign_string, &sign_string, - &sign_len); - if (ret == -1) { - return 0; - } - - ret = RSA_verify(method_type, (unsigned char *) verify_string, - verify_len, (unsigned char *) sign_string, - sign_len, rsa); - if (!ret) { - m2_PyErr_Msg(_rsa_err); - return 0; - } - return ret; -} - -PyObject *rsa_generate_key(int bits, unsigned long e, PyObject *pyfunc) { - RSA *rsa; - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - BN_GENCB *gencb; - BIGNUM *e_big; - int ret; - - if ((e_big=BN_new()) == NULL) { - m2_PyErr_Msg(_rsa_err); - return NULL; - } - - if (BN_set_word(e_big, e) == 0) { - m2_PyErr_Msg(_rsa_err); - BN_free(e_big); - return NULL; - } - - if ((gencb=BN_GENCB_new()) == NULL) { - m2_PyErr_Msg(_rsa_err); - BN_free(e_big); - return NULL; - } - - if ((rsa = RSA_new()) == NULL) { - m2_PyErr_Msg(_rsa_err); - BN_free(e_big); - BN_GENCB_free(gencb); - return NULL; - } - - BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); - - Py_INCREF(pyfunc); - ret = RSA_generate_key_ex(rsa, bits, e_big, gencb); - BN_free(e_big); - BN_GENCB_free(gencb); - Py_DECREF(pyfunc); - - if (ret) - return SWIG_NewPointerObj((void *)rsa, SWIGTYPE_p_RSA, 0); - - m2_PyErr_Msg(_rsa_err); - RSA_free(rsa); - return NULL; -} - -int rsa_type_check(RSA *rsa) { - return 1; -} - -int rsa_check_pub_key(RSA *rsa) { - const BIGNUM* n, *e; - RSA_get0_key(rsa, &n, &e, NULL); - return n && e; -} -%} - -%threadallow rsa_write_key_der; -%inline %{ -int rsa_write_key_der(RSA *rsa, BIO *bio) { - return i2d_RSAPrivateKey_bio(bio, rsa); -} -%} diff --git a/SWIG/_ssl.i b/SWIG/_ssl.i deleted file mode 100644 index 4f723ea..0000000 --- a/SWIG/_ssl.i +++ /dev/null @@ -1,953 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ -/* -** Portions created by Open Source Applications Foundation (OSAF) are -** Copyright (C) 2004-2005 OSAF. All Rights Reserved. -** -** Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. -** -*/ -/* $Id$ */ -%{ -#include -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 -#include -#include -#pragma comment(lib, "Ws2_32") -typedef unsigned __int64 uint64_t; -#else -#include -#include -#endif -%} - -#if OPENSSL_VERSION_NUMBER >= 0x10100005L -%include -#endif - -%apply Pointer NONNULL { SSL_CTX * }; -%apply Pointer NONNULL { SSL * }; -%apply Pointer NONNULL { SSL_CIPHER * }; -%apply Pointer NONNULL { STACK_OF(SSL_CIPHER) * }; -%apply Pointer NONNULL { STACK_OF(X509) * }; -%apply Pointer NONNULL { BIO * }; -%apply Pointer NONNULL { DH * }; -%apply Pointer NONNULL { RSA * }; -%apply Pointer NONNULL { EVP_PKEY *}; -%apply Pointer NONNULL { PyObject *pyfunc }; - -%rename(ssl_get_ciphers) SSL_get_ciphers; -extern STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl); - -%rename(ssl_get_version) SSL_get_version; -extern const char *SSL_get_version(const SSL *); -%rename(ssl_get_error) SSL_get_error; -extern int SSL_get_error(const SSL *, int); -%rename(ssl_get_state) SSL_state_string; -extern const char *SSL_state_string(const SSL *); -%rename(ssl_get_state_v) SSL_state_string_long; -extern const char *SSL_state_string_long(const SSL *); -%rename(ssl_get_alert_type) SSL_alert_type_string; -extern const char *SSL_alert_type_string(int); -%rename(ssl_get_alert_type_v) SSL_alert_type_string_long; -extern const char *SSL_alert_type_string_long(int); -%rename(ssl_get_alert_desc) SSL_alert_desc_string; -extern const char *SSL_alert_desc_string(int); -%rename(ssl_get_alert_desc_v) SSL_alert_desc_string_long; -extern const char *SSL_alert_desc_string_long(int); - -%rename(sslv23_method) SSLv23_method; -extern SSL_METHOD *SSLv23_method(void); -%ignore TLSv1_method; -extern SSL_METHOD *TLSv1_method(void); - -%typemap(out) SSL_CTX * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_ssl_err); - $result = NULL; - } -} -%rename(ssl_ctx_new) SSL_CTX_new; -extern SSL_CTX *SSL_CTX_new(SSL_METHOD *); -%typemap(out) SSL_CTX *; - -%rename(ssl_ctx_free) SSL_CTX_free; -extern void SSL_CTX_free(SSL_CTX *); -%rename(ssl_ctx_set_verify_depth) SSL_CTX_set_verify_depth; -extern void SSL_CTX_set_verify_depth(SSL_CTX *, int); -%rename(ssl_ctx_get_verify_depth) SSL_CTX_get_verify_depth; -extern int SSL_CTX_get_verify_depth(const SSL_CTX *); -%rename(ssl_ctx_get_verify_mode) SSL_CTX_get_verify_mode; -extern int SSL_CTX_get_verify_mode(const SSL_CTX *); -%rename(ssl_ctx_set_cipher_list) SSL_CTX_set_cipher_list; -extern int SSL_CTX_set_cipher_list(SSL_CTX *, const char *); -%rename(ssl_ctx_add_session) SSL_CTX_add_session; -extern int SSL_CTX_add_session(SSL_CTX *, SSL_SESSION *); -%rename(ssl_ctx_remove_session) SSL_CTX_remove_session; -extern int SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *); -%rename(ssl_ctx_set_session_timeout) SSL_CTX_set_timeout; -extern long SSL_CTX_set_timeout(SSL_CTX *, long); -%rename(ssl_ctx_get_session_timeout) SSL_CTX_get_timeout; -extern long SSL_CTX_get_timeout(const SSL_CTX *); -%rename(ssl_ctx_get_cert_store) SSL_CTX_get_cert_store; -extern X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); -%rename(ssl_ctx_set_default_verify_paths) SSL_CTX_set_default_verify_paths; -extern int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); -%rename(ssl_get_ex_data_x509_store_ctx_idx) SSL_get_ex_data_X509_STORE_CTX_idx; -extern int SSL_get_ex_data_X509_STORE_CTX_idx(void); - -%rename(bio_new_ssl) BIO_new_ssl; -extern BIO *BIO_new_ssl(SSL_CTX *, int); - -%rename(ssl_new) SSL_new; -extern SSL *SSL_new(SSL_CTX *); -%rename(ssl_free) SSL_free; -%threadallow SSL_free; -extern void SSL_free(SSL *); -%rename(ssl_dup) SSL_dup; -extern SSL *SSL_dup(SSL *); -%rename(ssl_set_bio) SSL_set_bio; -extern void SSL_set_bio(SSL *, BIO *, BIO *); -%rename(ssl_set_accept_state) SSL_set_accept_state; -extern void SSL_set_accept_state(SSL *); -%rename(ssl_set_connect_state) SSL_set_connect_state; -extern void SSL_set_connect_state(SSL *); -%rename(ssl_get_shutdown) SSL_get_shutdown; -extern int SSL_get_shutdown(const SSL *); -%rename(ssl_set_shutdown) SSL_set_shutdown; -extern void SSL_set_shutdown(SSL *, int); -%rename(ssl_shutdown) SSL_shutdown; -%threadallow SSL_shutdown; -extern int SSL_shutdown(SSL *); -%rename(ssl_clear) SSL_clear; -extern int SSL_clear(SSL *); -%rename(ssl_do_handshake) SSL_do_handshake; -%threadallow SSL_do_handshake; -extern int SSL_do_handshake(SSL *); -%rename(ssl_renegotiate) SSL_renegotiate; -%threadallow SSL_renegotiate; -extern int SSL_renegotiate(SSL *); -%rename(ssl_pending) SSL_pending; -extern int SSL_pending(const SSL *); - -%rename(ssl_get_peer_cert) SSL_get_peer_certificate; -extern X509 *SSL_get_peer_certificate(const SSL *); -%rename(ssl_get_current_cipher) SSL_get_current_cipher; -extern SSL_CIPHER *SSL_get_current_cipher(const SSL *); -%rename(ssl_get_verify_mode) SSL_get_verify_mode; -extern int SSL_get_verify_mode(const SSL *); -%rename(ssl_get_verify_depth) SSL_get_verify_depth; -extern int SSL_get_verify_depth(const SSL *); -%rename(ssl_get_verify_result) SSL_get_verify_result; -extern long SSL_get_verify_result(const SSL *); -%rename(ssl_get_ssl_ctx) SSL_get_SSL_CTX; -extern SSL_CTX *SSL_get_SSL_CTX(const SSL *); -%rename(ssl_get_default_session_timeout) SSL_get_default_timeout; -extern long SSL_get_default_timeout(const SSL *); - -%rename(ssl_set_cipher_list) SSL_set_cipher_list; -extern int SSL_set_cipher_list(SSL *, const char *); -%rename(ssl_get_cipher_list) SSL_get_cipher_list; -extern const char *SSL_get_cipher_list(const SSL *, int); - -%rename(ssl_cipher_get_name) SSL_CIPHER_get_name; -extern const char *SSL_CIPHER_get_name(const SSL_CIPHER *); -%rename(ssl_cipher_get_version) SSL_CIPHER_get_version; -extern char *SSL_CIPHER_get_version(const SSL_CIPHER *); - -%rename(ssl_get_session) SSL_get_session; -extern SSL_SESSION *SSL_get_session(const SSL *); -%rename(ssl_get1_session) SSL_get1_session; -extern SSL_SESSION *SSL_get1_session(SSL *); -%rename(ssl_set_session) SSL_set_session; -extern int SSL_set_session(SSL *, SSL_SESSION *); -%rename(ssl_session_free) SSL_SESSION_free; -extern void SSL_SESSION_free(SSL_SESSION *); -%rename(ssl_session_print) SSL_SESSION_print; -%threadallow SSL_SESSION_print; -extern int SSL_SESSION_print(BIO *, const SSL_SESSION *); -%rename(ssl_session_set_timeout) SSL_SESSION_set_timeout; -extern long SSL_SESSION_set_timeout(SSL_SESSION *, long); -%rename(ssl_session_get_timeout) SSL_SESSION_get_timeout; -extern long SSL_SESSION_get_timeout(const SSL_SESSION *); - -extern PyObject *ssl_accept(SSL *ssl, double timeout = -1); -extern PyObject *ssl_connect(SSL *ssl, double timeout = -1); -extern PyObject *ssl_read(SSL *ssl, int num, double timeout = -1); -extern int ssl_write(SSL *ssl, PyObject *blob, double timeout = -1); - -%constant int ssl_error_none = SSL_ERROR_NONE; -%constant int ssl_error_ssl = SSL_ERROR_SSL; -%constant int ssl_error_want_read = SSL_ERROR_WANT_READ; -%constant int ssl_error_want_write = SSL_ERROR_WANT_WRITE; -%constant int ssl_error_want_x509_lookup = SSL_ERROR_WANT_X509_LOOKUP; -%constant int ssl_error_syscall = SSL_ERROR_SYSCALL; -%constant int ssl_error_zero_return = SSL_ERROR_ZERO_RETURN; -%constant int ssl_error_want_connect = SSL_ERROR_WANT_CONNECT; - -%constant int SSL_VERIFY_NONE = 0x00; -%constant int SSL_VERIFY_PEER = 0x01; -%constant int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 0x02; -%constant int SSL_VERIFY_CLIENT_ONCE = 0x04; - -%constant int VERIFY_CRL_CHECK_LEAF = X509_V_FLAG_CRL_CHECK; -%constant int VERIFY_CRL_CHECK_CHAIN = X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL; - - -%constant int SSL_ST_CONNECT = 0x1000; -%constant int SSL_ST_ACCEPT = 0x2000; -%constant int SSL_ST_MASK = 0x0FFF; -%constant int SSL_ST_INIT = (SSL_ST_CONNECT|SSL_ST_ACCEPT); -%constant int SSL_ST_BEFORE = 0x4000; -%constant int SSL_ST_OK = 0x03; -/* SWIG 3.0.1 complains about the next line -- simplified declaration for now */ -/*%constant int SSL_ST_RENEGOTIATE = (0x04|SSL_ST_INIT);*/ -%constant int SSL_ST_RENEGOTIATE = (0x04|SSL_ST_CONNECT|SSL_ST_ACCEPT); - -%constant int SSL_CB_LOOP = 0x01; -%constant int SSL_CB_EXIT = 0x02; -%constant int SSL_CB_READ = 0x04; -%constant int SSL_CB_WRITE = 0x08; -%constant int SSL_CB_ALERT = 0x4000; /* used in callback */ -%constant int SSL_CB_READ_ALERT = (SSL_CB_ALERT|SSL_CB_READ); -%constant int SSL_CB_WRITE_ALERT = (SSL_CB_ALERT|SSL_CB_WRITE); -%constant int SSL_CB_ACCEPT_LOOP = (SSL_ST_ACCEPT|SSL_CB_LOOP); -%constant int SSL_CB_ACCEPT_EXIT = (SSL_ST_ACCEPT|SSL_CB_EXIT); -%constant int SSL_CB_CONNECT_LOOP = (SSL_ST_CONNECT|SSL_CB_LOOP); -%constant int SSL_CB_CONNECT_EXIT = (SSL_ST_CONNECT|SSL_CB_EXIT); -%constant int SSL_CB_HANDSHAKE_START = 0x10; -%constant int SSL_CB_HANDSHAKE_DONE = 0x20; - -%constant int SSL_SENT_SHUTDOWN = 1; -%constant int SSL_RECEIVED_SHUTDOWN = 2; - -%constant int SSL_SESS_CACHE_OFF = 0x000; -%constant int SSL_SESS_CACHE_CLIENT = 0x001; -%constant int SSL_SESS_CACHE_SERVER = 0x002; -%constant int SSL_SESS_CACHE_BOTH = (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER); - -%constant int SSL_OP_ALL = 0x00000FFFL; - -%constant int SSL_OP_NO_SSLv2 = 0x01000000L; -%constant int SSL_OP_NO_SSLv3 = 0x02000000L; -%constant int SSL_OP_NO_TLSv1 = 0x04000000L; -%constant int SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 0x00000800L; - -%constant int SSL_MODE_ENABLE_PARTIAL_WRITE = SSL_MODE_ENABLE_PARTIAL_WRITE; -%constant int SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER; -%constant int SSL_MODE_AUTO_RETRY = SSL_MODE_AUTO_RETRY; - -%ignore ssl_handle_error; -%ignore ssl_sleep_with_timeout; -%warnfilter(454) _ssl_err; -%warnfilter(454) _ssl_timeout_err; -%inline %{ -static PyObject *_ssl_err; -static PyObject *_ssl_timeout_err; - -void ssl_init(PyObject *ssl_err, PyObject *ssl_timeout_err) { - SSL_library_init(); - SSL_load_error_strings(); - Py_INCREF(ssl_err); - Py_INCREF(ssl_timeout_err); - _ssl_err = ssl_err; - _ssl_timeout_err = ssl_timeout_err; -} - -const SSL_METHOD *tlsv1_method(void) { -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - PyErr_WarnEx(PyExc_DeprecationWarning, - "Function TLSv1_method has been deprecated.", 1); -#endif - return TLSv1_method(); -} - -void ssl_ctx_passphrase_callback(SSL_CTX *ctx, PyObject *pyfunc) { - SSL_CTX_set_default_passwd_cb(ctx, passphrase_callback); - SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *)pyfunc); - Py_INCREF(pyfunc); -} - -int ssl_ctx_use_x509(SSL_CTX *ctx, X509 *x) { - int i; - - if (!(i = SSL_CTX_use_certificate(ctx, x))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; - -} - -int ssl_ctx_use_cert(SSL_CTX *ctx, char *file) { - int i; - - if (!(i = SSL_CTX_use_certificate_file(ctx, file, SSL_FILETYPE_PEM))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - -int ssl_ctx_use_cert_chain(SSL_CTX *ctx, char *file) { - int i; - - if (!(i = SSL_CTX_use_certificate_chain_file(ctx, file))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - - -int ssl_ctx_use_privkey(SSL_CTX *ctx, char *file) { - int i; - - if (!(i = SSL_CTX_use_PrivateKey_file(ctx, file, SSL_FILETYPE_PEM))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - -int ssl_ctx_use_rsa_privkey(SSL_CTX *ctx, RSA *rsakey) { - int i; - - if (!(i = SSL_CTX_use_RSAPrivateKey(ctx, rsakey))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - -int ssl_ctx_use_pkey_privkey(SSL_CTX *ctx, EVP_PKEY *pkey) { - int i; - - if (!(i = SSL_CTX_use_PrivateKey(ctx, pkey))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return i; -} - - -int ssl_ctx_check_privkey(SSL_CTX *ctx) { - int ret; - - if (!(ret = SSL_CTX_check_private_key(ctx))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return ret; -} - -void ssl_ctx_set_client_CA_list_from_file(SSL_CTX *ctx, const char *ca_file) { - SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(ca_file)); -} - -void ssl_ctx_set_verify_default(SSL_CTX *ctx, int mode) { - SSL_CTX_set_verify(ctx, mode, NULL); -} - -void ssl_ctx_set_verify(SSL_CTX *ctx, int mode, PyObject *pyfunc) { - Py_XDECREF(ssl_verify_cb_func); - Py_INCREF(pyfunc); - ssl_verify_cb_func = pyfunc; - SSL_CTX_set_verify(ctx, mode, ssl_verify_callback); -} - -int ssl_ctx_set_session_id_context(SSL_CTX *ctx, PyObject *sid_ctx) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) - return -1; - - return SSL_CTX_set_session_id_context(ctx, buf, len); -} - -void ssl_ctx_set_info_callback(SSL_CTX *ctx, PyObject *pyfunc) { - Py_XDECREF(ssl_info_cb_func); - Py_INCREF(pyfunc); - ssl_info_cb_func = pyfunc; - SSL_CTX_set_info_callback(ctx, ssl_info_callback); -} - -long ssl_ctx_set_tmp_dh(SSL_CTX *ctx, DH* dh) { - return SSL_CTX_set_tmp_dh(ctx, dh); -} - -void ssl_ctx_set_tmp_dh_callback(SSL_CTX *ctx, PyObject *pyfunc) { - Py_XDECREF(ssl_set_tmp_dh_cb_func); - Py_INCREF(pyfunc); - ssl_set_tmp_dh_cb_func = pyfunc; - SSL_CTX_set_tmp_dh_callback(ctx, ssl_set_tmp_dh_callback); -} - -long ssl_ctx_set_tmp_rsa(SSL_CTX *ctx, RSA* rsa) { - return SSL_CTX_set_tmp_rsa(ctx, rsa); -} - -void ssl_ctx_set_tmp_rsa_callback(SSL_CTX *ctx, PyObject *pyfunc) { - Py_XDECREF(ssl_set_tmp_rsa_cb_func); - Py_INCREF(pyfunc); - ssl_set_tmp_rsa_cb_func = pyfunc; - SSL_CTX_set_tmp_rsa_callback(ctx, ssl_set_tmp_rsa_callback); -} - -int ssl_ctx_load_verify_locations(SSL_CTX *ctx, const char *cafile, const char *capath) { - return SSL_CTX_load_verify_locations(ctx, cafile, capath); -} - -/* SSL_CTX_set_options is a macro. */ -long ssl_ctx_set_options(SSL_CTX *ctx, long op) { - return SSL_CTX_set_options(ctx, op); -} - -int bio_set_ssl(BIO *bio, SSL *ssl, int flag) { - SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); - return BIO_ctrl(bio, BIO_C_SET_SSL, flag, (char *)ssl); -} - -long ssl_set_mode(SSL *ssl, long mode) { - return SSL_set_mode(ssl, mode); -} - -long ssl_get_mode(SSL *ssl) { - return SSL_get_mode(ssl); -} - -int ssl_set_tlsext_host_name(SSL *ssl, const char *name) { - long l; - - if (!(l = SSL_set_tlsext_host_name(ssl, name))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - /* Return an "int" to match the 'typemap(out) int' in _lib.i */ - return 1; -} - -void ssl_set_client_CA_list_from_file(SSL *ssl, const char *ca_file) { - SSL_set_client_CA_list(ssl, SSL_load_client_CA_file(ca_file)); -} - -void ssl_set_client_CA_list_from_context(SSL *ssl, SSL_CTX *ctx) { - SSL_set_client_CA_list(ssl, SSL_CTX_get_client_CA_list(ctx)); -} - -int ssl_set_session_id_context(SSL *ssl, PyObject *sid_ctx) { - const void *buf; - int len = 0; - - if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) - return -1; - - return SSL_set_session_id_context(ssl, buf, len); -} - -int ssl_set_fd(SSL *ssl, int fd) { - int ret; - - if (!(ret = SSL_set_fd(ssl, fd))) { - m2_PyErr_Msg(_ssl_err); - return -1; - } - return ret; -} - -static void ssl_handle_error(int ssl_err, int ret) { - int err; - - switch (ssl_err) { - case SSL_ERROR_SSL: - PyErr_SetString(_ssl_err, - ERR_reason_error_string(ERR_get_error())); - break; - case SSL_ERROR_SYSCALL: - err = ERR_get_error(); - if (err) - PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); - else if (ret == 0) - PyErr_SetString(_ssl_err, "unexpected eof"); - else if (ret == -1) - PyErr_SetFromErrno(_ssl_err); - else - assert(0); - break; - default: - PyErr_SetString(_ssl_err, "unexpected SSL error"); - } -} - -#ifdef _WIN32 -/* http://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows */ -int gettimeofday(struct timeval *tp, void *tzp) -{ - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); - - SYSTEMTIME system_time; - FILETIME file_time; - uint64_t time; - - GetSystemTime( &system_time ); - SystemTimeToFileTime( &system_time, &file_time ); - time = ((uint64_t)file_time.dwLowDateTime ) ; - time += ((uint64_t)file_time.dwHighDateTime) << 32; - - tp->tv_sec = (long) ((time - EPOCH) / 10000000L); - tp->tv_usec = (long) (system_time.wMilliseconds * 1000); - return 0; -} -#endif - -static int ssl_sleep_with_timeout(SSL *ssl, const struct timeval *start, - double timeout, int ssl_err) { -#ifdef _WIN32 -WSAPOLLFD fd; -#else -struct pollfd fd; -#endif - struct timeval tv; - int ms, tmp; - - assert(timeout > 0); - again: - gettimeofday(&tv, NULL); - /* tv >= start */ - if ((timeout + start->tv_sec - tv.tv_sec) > INT_MAX / 1000) - ms = -1; - else { - int fract; - - ms = ((start->tv_sec + (int)timeout) - tv.tv_sec) * 1000; - fract = (int)((start->tv_usec + (timeout - (int)timeout) * 1000000 - - tv.tv_usec + 999) / 1000); - if (ms > 0 && fract > INT_MAX - ms) - ms = -1; - else { - ms += fract; - if (ms <= 0) - goto timeout; - } - } - switch (ssl_err) { - case SSL_ERROR_WANT_READ: - fd.fd = SSL_get_rfd(ssl); - fd.events = POLLIN; - break; - - case SSL_ERROR_WANT_WRITE: - fd.fd = SSL_get_wfd(ssl); - fd.events = POLLOUT; - break; - - case SSL_ERROR_WANT_X509_LOOKUP: - return 0; /* FIXME: is this correct? */ - - default: - assert(0); - } - if (fd.fd == -1) { - PyErr_SetString(_ssl_err, "timeout on a non-FD SSL"); - return -1; - } - Py_BEGIN_ALLOW_THREADS -#ifdef _WIN32 - tmp = WSAPoll(&fd, 1, ms); -#else - tmp = poll(&fd, 1, ms); -#endif - Py_END_ALLOW_THREADS - switch (tmp) { - case 1: - return 0; - case 0: - goto timeout; - case -1: -#ifdef _WIN32 - if (WSAGetLastError() == EINTR) -#else - if (errno == EINTR) -#endif - goto again; - PyErr_SetFromErrno(_ssl_err); - return -1; - } - return 0; - - timeout: - PyErr_SetString(_ssl_timeout_err, "timed out"); - return -1; -} - -PyObject *ssl_accept(SSL *ssl, double timeout) { - PyObject *obj = NULL; - int r, ssl_err; - struct timeval tv; - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_accept(ssl); - ssl_err = SSL_get_error(ssl, r); - Py_END_ALLOW_THREADS - - - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - obj = PyLong_FromLong((long)1); - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - if (timeout <= 0) { - obj = PyLong_FromLong((long)0); - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - obj = NULL; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - obj = NULL; - break; - } - - - return obj; -} - -PyObject *ssl_connect(SSL *ssl, double timeout) { - PyObject *obj = NULL; - int r, ssl_err; - struct timeval tv; - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_connect(ssl); - ssl_err = SSL_get_error(ssl, r); - Py_END_ALLOW_THREADS - - - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - obj = PyLong_FromLong((long)1); - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - if (timeout <= 0) { - obj = PyLong_FromLong((long)0); - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - obj = NULL; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - obj = NULL; - break; - } - - - return obj; -} - -void ssl_set_shutdown1(SSL *ssl, int mode) { - SSL_set_shutdown(ssl, mode); -} - -PyObject *ssl_read(SSL *ssl, int num, double timeout) { - PyObject *obj = NULL; - void *buf; - int r; - struct timeval tv; - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "ssl_read"); - return NULL; - } - - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_read(ssl, buf, num); - Py_END_ALLOW_THREADS - - if (r >= 0) { - buf = PyMem_Realloc(buf, r); - obj = PyBytes_FromStringAndSize(buf, r); - } else { - int ssl_err; - - ssl_err = SSL_get_error(ssl, r); - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - assert(0); - - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - if (timeout <= 0) { - Py_INCREF(Py_None); - obj = Py_None; - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - obj = NULL; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - obj = NULL; - break; - } - } - PyMem_Free(buf); - - - return obj; -} - -PyObject *ssl_read_nbio(SSL *ssl, int num) { - PyObject *obj = NULL; - void *buf; - int r, err; - - - if (!(buf = PyMem_Malloc(num))) { - PyErr_SetString(PyExc_MemoryError, "ssl_read"); - return NULL; - } - - - Py_BEGIN_ALLOW_THREADS - r = SSL_read(ssl, buf, num); - Py_END_ALLOW_THREADS - - - switch (SSL_get_error(ssl, r)) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - buf = PyMem_Realloc(buf, r); - - obj = PyBytes_FromStringAndSize(buf, r); - - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - Py_INCREF(Py_None); - obj = Py_None; - break; - case SSL_ERROR_SSL: - m2_PyErr_Msg(_ssl_err); - obj = NULL; - break; - case SSL_ERROR_SYSCALL: - err = ERR_get_error(); - if (err) - PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); - else if (r == 0) - PyErr_SetString(_ssl_err, "unexpected eof"); - else if (r == -1) - PyErr_SetFromErrno(_ssl_err); - obj = NULL; - break; - } - PyMem_Free(buf); - - - return obj; -} - -int ssl_write(SSL *ssl, PyObject *blob, double timeout) { - Py_buffer buf; - int r, ssl_err, ret; - struct timeval tv; - - - if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { - return -1; - } - - if (timeout > 0) - gettimeofday(&tv, NULL); - again: - Py_BEGIN_ALLOW_THREADS - r = SSL_write(ssl, buf.buf, buf.len); - ssl_err = SSL_get_error(ssl, r); - Py_END_ALLOW_THREADS - - - switch (ssl_err) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - ret = r; - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - if (timeout <= 0) { - ret = -1; - break; - } - if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) - goto again; - ret = -1; - break; - case SSL_ERROR_SSL: - case SSL_ERROR_SYSCALL: - ssl_handle_error(ssl_err, r); - default: - ret = -1; - } - - m2_PyBuffer_Release(blob, &buf); - return ret; -} - -int ssl_write_nbio(SSL *ssl, PyObject *blob) { - Py_buffer buf; - int r, err, ret; - - - if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { - return -1; - } - - - Py_BEGIN_ALLOW_THREADS - r = SSL_write(ssl, buf.buf, buf.len); - Py_END_ALLOW_THREADS - - - switch (SSL_get_error(ssl, r)) { - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - ret = r; - break; - case SSL_ERROR_WANT_WRITE: - case SSL_ERROR_WANT_READ: - case SSL_ERROR_WANT_X509_LOOKUP: - ret = -1; - break; - case SSL_ERROR_SSL: - ret = -1; - break; - case SSL_ERROR_SYSCALL: - err = ERR_get_error(); - if (err) - PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); - else if (r == 0) - PyErr_SetString(_ssl_err, "unexpected eof"); - else if (r == -1) - PyErr_SetFromErrno(_ssl_err); - default: - ret = -1; - } - - m2_PyBuffer_Release(blob, &buf); - return ret; -} - -int ssl_cipher_get_bits(SSL_CIPHER *c) { - return SSL_CIPHER_get_bits(c, NULL); -} - -int sk_ssl_cipher_num(STACK_OF(SSL_CIPHER) *stack) { - return sk_SSL_CIPHER_num(stack); -} - -const SSL_CIPHER *sk_ssl_cipher_value(STACK_OF(SSL_CIPHER) *stack, int idx) { - return sk_SSL_CIPHER_value(stack, idx); -} - -STACK_OF(X509) *ssl_get_peer_cert_chain(SSL *ssl) { - return SSL_get_peer_cert_chain(ssl); -} - -int sk_x509_num(STACK_OF(X509) *stack) { - return sk_X509_num(stack); -} - -X509 *sk_x509_value(STACK_OF(X509) *stack, int idx) { - return sk_X509_value(stack, idx); -} -%} - -%threadallow i2d_ssl_session; -%inline %{ -void i2d_ssl_session(BIO *bio, SSL_SESSION *sess) { - i2d_SSL_SESSION_bio(bio, sess); -} -%} - -%typemap(out) SSL_SESSION * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_ssl_err); - $result = NULL; - } -} -%threadallow ssl_session_read_pem; -%inline %{ -SSL_SESSION *ssl_session_read_pem(BIO *bio) { - return PEM_read_bio_SSL_SESSION(bio, NULL, NULL, NULL); -} -%} -%typemap(out) SSL_SESSION * ; - -%threadallow ssl_session_write_pem; -%inline %{ -int ssl_session_write_pem(SSL_SESSION *sess, BIO *bio) { - return PEM_write_bio_SSL_SESSION(bio, sess); -} - -int ssl_ctx_set_session_cache_mode(SSL_CTX *ctx, int mode) -{ - return SSL_CTX_set_session_cache_mode(ctx, mode); -} - -int ssl_ctx_get_session_cache_mode(SSL_CTX *ctx) -{ - return SSL_CTX_get_session_cache_mode(ctx); -} - -static long ssl_ctx_set_cache_size(SSL_CTX *ctx, long arg) -{ - return SSL_CTX_sess_set_cache_size(ctx, arg); -} - -int ssl_is_init_finished(SSL *ssl) -{ - return SSL_is_init_finished(ssl); -} -%} - diff --git a/SWIG/_threads.i b/SWIG/_threads.i deleted file mode 100644 index 69adb9f..0000000 --- a/SWIG/_threads.i +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ -/* $Id$ */ - -%{ -#include -#include - -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L -#define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) -static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; -static long lock_count[CRYPTO_num_locks()]; -static int thread_mode = 0; -#endif - -void threading_locking_callback(int mode, int type, const char *file, int line) { -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L - if (mode & CRYPTO_LOCK) { - PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); - lock_count[type]++; - } else { - PyThread_release_lock(lock_cs[type]); - lock_count[type]--; - } -#endif -} - -unsigned long threading_id_callback(void) { -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L - return (unsigned long)PyThread_get_thread_ident(); -#else - return (unsigned long)0; -#endif -} -%} - -%inline %{ -void threading_init(void) { -#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L - int i; - if (!thread_mode) { - for (i=0; i -%} - -%warnfilter(454) _util_err; -%inline %{ -static PyObject *_util_err; - -void util_init(PyObject *util_err) { - Py_INCREF(util_err); - _util_err = util_err; -} - -PyObject *util_hex_to_string(PyObject *blob) { - PyObject *obj; - const void *buf; - char *ret; - Py_ssize_t len; - - if (PyObject_AsReadBuffer(blob, &buf, &len) == -1) - return NULL; - - ret = hex_to_string((unsigned char *)buf, len); - if (!ret) { - m2_PyErr_Msg(_util_err); - return NULL; - } - - obj = PyBytes_FromString(ret); - - OPENSSL_free(ret); - return obj; -} - -PyObject *util_string_to_hex(PyObject *blob) { - PyObject *obj; - const void *buf; - unsigned char *ret; - Py_ssize_t len0; - long len; - - if (PyObject_AsReadBuffer(blob, &buf, &len0) == -1) - return NULL; - - len = len0; - ret = string_to_hex((char *)buf, &len); - if (ret == NULL) { - m2_PyErr_Msg(_util_err); - return NULL; - } - obj = PyBytes_FromStringAndSize((char*)ret, len); - OPENSSL_free(ret); - return obj; -} -%} diff --git a/SWIG/_x509.i b/SWIG/_x509.i deleted file mode 100644 index b6334df..0000000 --- a/SWIG/_x509.i +++ /dev/null @@ -1,851 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ -/* -** Portions created by Open Source Applications Foundation (OSAF) are -** Copyright (C) 2004-2005 OSAF. All Rights Reserved. -** -** Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. -** -*/ -/* $Id$ */ - -%{ -#include -#include -#include - -#include - -typedef STACK_OF(X509) SEQ_CERT; - -ASN1_ITEM_TEMPLATE(SEQ_CERT) = - ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, SeqCert, X509) -ASN1_ITEM_TEMPLATE_END(SEQ_CERT) - -IMPLEMENT_ASN1_FUNCTIONS(SEQ_CERT) -%} - -%apply Pointer NONNULL { BIO * }; -%apply Pointer NONNULL { X509 * }; -%apply Pointer NONNULL { X509_CRL * }; -%apply Pointer NONNULL { X509_REQ * }; -%apply Pointer NONNULL { X509_NAME * }; -%apply Pointer NONNULL { X509_NAME_ENTRY * }; -%apply Pointer NONNULL { EVP_PKEY * }; - -#if OPENSSL_VERSION_NUMBER >= 0x0090800fL -%rename(x509_check_ca) X509_check_ca; -extern int X509_check_ca(X509 *); -#endif - -%rename(x509_new) X509_new; -extern X509 *X509_new( void ); -%rename(x509_dup) X509_dup; -extern X509 *X509_dup(X509 *); -%rename(x509_free) X509_free; -extern void X509_free(X509 *); -%rename(x509_crl_free) X509_CRL_free; -extern void X509_CRL_free(X509_CRL *); -%rename(x509_crl_new) X509_CRL_new; -extern X509_CRL * X509_CRL_new(); - -%rename(x509_print) X509_print; -%threadallow X509_print; -extern int X509_print(BIO *, X509 *); -%rename(x509_crl_print) X509_CRL_print; -%threadallow X509_CRL_print; -extern int X509_CRL_print(BIO *, X509_CRL *); - -%rename(x509_get_serial_number) X509_get_serialNumber; -extern ASN1_INTEGER *X509_get_serialNumber(X509 *); -%rename(x509_set_serial_number) X509_set_serialNumber; -extern int X509_set_serialNumber(X509 *, ASN1_INTEGER *); -%rename(x509_get_pubkey) X509_get_pubkey; -extern EVP_PKEY *X509_get_pubkey(X509 *); -%rename(x509_set_pubkey) X509_set_pubkey; -extern int X509_set_pubkey(X509 *, EVP_PKEY *); -%rename(x509_get_issuer_name) X509_get_issuer_name; -extern X509_NAME *X509_get_issuer_name(X509 *); -%rename(x509_set_issuer_name) X509_set_issuer_name; -extern int X509_set_issuer_name(X509 *, X509_NAME *); -%rename(x509_get_subject_name) X509_get_subject_name; -extern X509_NAME *X509_get_subject_name(X509 *); -%rename(x509_set_subject_name) X509_set_subject_name; -extern int X509_set_subject_name(X509 *, X509_NAME *); -%rename(x509_cmp_current_time) X509_cmp_current_time; -extern int X509_cmp_current_time(ASN1_TIME *); - - -/* From x509.h */ -/* standard trust ids */ -%constant int X509_TRUST_DEFAULT = -1; -%constant int X509_TRUST_COMPAT = 1; -%constant int X509_TRUST_SSL_CLIENT = 2; -%constant int X509_TRUST_SSL_SERVER = 3; -%constant int X509_TRUST_EMAIL = 4; -%constant int X509_TRUST_OBJECT_SIGN = 5; -%constant int X509_TRUST_OCSP_SIGN = 6; -%constant int X509_TRUST_OCSP_REQUEST = 7; - -/* trust_flags values */ -%constant int X509_TRUST_DYNAMIC = 1; -%constant int X509_TRUST_DYNAMIC_NAME = 2; - -/* check_trust return codes */ -%constant int X509_TRUST_TRUSTED = 1; -%constant int X509_TRUST_REJECTED = 2; -%constant int X509_TRUST_UNTRUSTED = 3; - -/* From x509v3.h */ -%constant int X509_PURPOSE_SSL_CLIENT = 1; -%constant int X509_PURPOSE_SSL_SERVER = 2; -%constant int X509_PURPOSE_NS_SSL_SERVER = 3; -%constant int X509_PURPOSE_SMIME_SIGN = 4; -%constant int X509_PURPOSE_SMIME_ENCRYPT = 5; -%constant int X509_PURPOSE_CRL_SIGN = 6; -%constant int X509_PURPOSE_ANY = 7; -%constant int X509_PURPOSE_OCSP_HELPER = 8; - -%rename(x509_check_purpose) X509_check_purpose; -extern int X509_check_purpose(X509 *, int, int); -%rename(x509_check_trust) X509_check_trust; -extern int X509_check_trust(X509 *, int, int); - -%rename(x509_write_pem) PEM_write_bio_X509; -%threadallow PEM_write_bio_X509; -extern int PEM_write_bio_X509(BIO *, X509 *); -%rename(x509_write_pem_file) PEM_write_X509; -extern int PEM_write_X509(FILE *, X509 *); - -%rename(x509_verify) X509_verify; -extern int X509_verify(X509 *a, EVP_PKEY *r); -%rename(x509_get_verify_error) X509_verify_cert_error_string; -extern const char *X509_verify_cert_error_string(long); - -%constant long X509V3_EXT_UNKNOWN_MASK = (0xfL << 16); -%constant long X509V3_EXT_DEFAULT = 0; -%constant long X509V3_EXT_ERROR_UNKNOWN = (1L << 16); -%constant long X509V3_EXT_PARSE_UNKNOWN = (2L << 16); -%constant long X509V3_EXT_DUMP_UNKNOWN = (3L << 16); - -%rename(x509_add_ext) X509_add_ext; -extern int X509_add_ext(X509 *, X509_EXTENSION *, int); -%rename(x509_get_ext_count) X509_get_ext_count; -extern int X509_get_ext_count(X509 *); -%rename(x509_get_ext) X509_get_ext; -extern X509_EXTENSION *X509_get_ext(X509 *, int); -%rename(x509_ext_print) X509V3_EXT_print; -%threadallow X509V3_EXT_print; -extern int X509V3_EXT_print(BIO *, X509_EXTENSION *, unsigned long, int); - -%rename(x509_name_new) X509_NAME_new; -extern X509_NAME *X509_NAME_new( void ); -%rename(x509_name_free) X509_NAME_free; -extern void X509_NAME_free(X509_NAME *); -%rename(x509_name_print) X509_NAME_print; -%threadallow X509_NAME_print; -extern int X509_NAME_print(BIO *, X509_NAME *, int); -%rename(x509_name_get_entry) X509_NAME_get_entry; -extern X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *, int); -%rename(x509_name_entry_count) X509_NAME_entry_count; -extern int X509_NAME_entry_count(X509_NAME *); -%rename(x509_name_delete_entry) X509_NAME_delete_entry; -extern X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *, int); -%rename(x509_name_add_entry) X509_NAME_add_entry; -extern int X509_NAME_add_entry(X509_NAME *, X509_NAME_ENTRY *, int, int); -%rename(x509_name_add_entry_by_obj) X509_NAME_add_entry_by_OBJ; -extern int X509_NAME_add_entry_by_OBJ(X509_NAME *, ASN1_OBJECT *, int, unsigned char *, int, int, int ); -%rename(x509_name_add_entry_by_nid) X509_NAME_add_entry_by_NID; -extern int X509_NAME_add_entry_by_NID(X509_NAME *, int, int, unsigned char *, int, int, int ); -%rename(x509_name_print_ex) X509_NAME_print_ex; -%threadallow X509_NAME_print_ex; -extern int X509_NAME_print_ex(BIO *, X509_NAME *, int, unsigned long); - -#if OPENSSL_VERSION_NUMBER >= 0x10000000L -%rename(x509_name_hash) X509_NAME_hash_old; -extern unsigned long X509_NAME_hash_old(X509_NAME *); -#else -%rename(x509_name_hash) X509_NAME_hash; -extern unsigned long X509_NAME_hash(X509_NAME *); -#endif - -%rename(x509_name_get_index_by_nid) X509_NAME_get_index_by_NID; -extern int X509_NAME_get_index_by_NID(X509_NAME *, int, int); - -%rename(x509_name_entry_new) X509_NAME_ENTRY_new; -extern X509_NAME_ENTRY *X509_NAME_ENTRY_new( void ); -%rename(x509_name_entry_free) X509_NAME_ENTRY_free; -extern void X509_NAME_ENTRY_free( X509_NAME_ENTRY *); -/*XXX This is probably bogus:*/ -%rename(x509_name_entry_create_by_nid) X509_NAME_ENTRY_create_by_NID; -extern X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID( X509_NAME_ENTRY **, int, int, unsigned char *, int); -%rename(x509_name_entry_set_object) X509_NAME_ENTRY_set_object; -extern int X509_NAME_ENTRY_set_object( X509_NAME_ENTRY *, ASN1_OBJECT *); -%rename(x509_name_entry_get_object) X509_NAME_ENTRY_get_object; -extern ASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *); -%rename(x509_name_entry_get_data) X509_NAME_ENTRY_get_data; -extern ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *); - -%typemap(in) (const unsigned char *, int) { -#if PY_MAJOR_VERSION >= 3 - if (PyBytes_Check($input)) { - Py_ssize_t len; - - $1 = PyBytes_AsString($input); - len = PyBytes_Size($input); -#else - if (PyString_Check($input)) { - Py_ssize_t len; - - $1 = (unsigned char *)PyString_AsString($input); - len = PyString_Size($input); -#endif // PY_MAJOR_VERSION >= 3 - - if (len > INT_MAX) { - PyErr_SetString(_x509_err, "object too large"); - return NULL; - } - $2 = len; - } else { - PyErr_SetString(PyExc_TypeError, "expected string"); - return NULL; - } -} -%rename(x509_name_entry_set_data) X509_NAME_ENTRY_set_data; -extern int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *, int, const unsigned char *, int); -%typemap(in) (const unsigned char *, int); - -%rename(x509_req_new) X509_REQ_new; -extern X509_REQ * X509_REQ_new(); -%rename(x509_req_free) X509_REQ_free; -extern void X509_REQ_free(X509_REQ *); -%rename(x509_req_print) X509_REQ_print; -%threadallow X509_REQ_print; -extern int X509_REQ_print(BIO *, X509_REQ *); - -%rename(x509_req_get_pubkey) X509_REQ_get_pubkey; -extern EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *); -%rename(x509_req_set_pubkey) X509_REQ_set_pubkey; -extern int X509_REQ_set_pubkey(X509_REQ *, EVP_PKEY *); -%rename(x509_req_set_subject_name) X509_REQ_set_subject_name; -extern int X509_REQ_set_subject_name(X509_REQ *, X509_NAME *); - -%rename(x509_req_verify) X509_REQ_verify; -extern int X509_REQ_verify(X509_REQ *, EVP_PKEY *); -%rename(x509_req_sign) X509_REQ_sign; -extern int X509_REQ_sign(X509_REQ *, EVP_PKEY *, const EVP_MD *); - -%rename(i2d_x509_bio) i2d_X509_bio; -%threadallow i2d_X509_bio; -extern int i2d_X509_bio(BIO *, X509 *); -%rename(i2d_x509_req_bio) i2d_X509_REQ_bio; -%threadallow i2d_X509_REQ_bio; -extern int i2d_X509_REQ_bio(BIO *, X509_REQ *); - -%rename(x509_store_new) X509_STORE_new; -extern X509_STORE *X509_STORE_new(void); -%rename(x509_store_free) X509_STORE_free; -extern void X509_STORE_free(X509_STORE *); -%rename(x509_store_add_cert) X509_STORE_add_cert; -extern int X509_STORE_add_cert(X509_STORE *, X509 *); -%rename(x509_store_set_verify_cb) X509_STORE_set_verify_cb; -extern void X509_STORE_set_verify_cb(X509_STORE *st, - int (*verify_cb)(int ok, X509_STORE_CTX *ctx)); - -%rename(x509_store_ctx_get_current_cert) X509_STORE_CTX_get_current_cert; -extern X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *); -%rename(x509_store_ctx_get_error) X509_STORE_CTX_get_error; -extern int X509_STORE_CTX_get_error(X509_STORE_CTX *); -%rename(x509_store_ctx_get_error_depth) X509_STORE_CTX_get_error_depth; -extern int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *); -%rename(x509_store_ctx_free) X509_STORE_CTX_free; -extern void X509_STORE_CTX_free(X509_STORE_CTX *); -%rename(x509_store_ctx_get1_chain) X509_STORE_CTX_get1_chain; -extern STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *); - -%rename(x509_extension_get_critical) X509_EXTENSION_get_critical; -extern int X509_EXTENSION_get_critical(X509_EXTENSION *); -%rename(x509_extension_set_critical) X509_EXTENSION_set_critical; -extern int X509_EXTENSION_set_critical(X509_EXTENSION *, int); - - -%rename(x509_store_set_flags) X509_STORE_set_flags; -extern int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); - - -%typemap(out) X509 * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_x509_err); - $result = NULL; - } -} - - -/* Functions using m2_PyErr_Msg and thus using internal Python C API are - * not thread safe, so if we want to have %threadallow here, error - * handling must be done outside of these internal functions. */ -%threadallow x509_read_pem; -%inline %{ -X509 *x509_read_pem(BIO *bio) { - return PEM_read_bio_X509(bio, NULL, NULL, NULL); -} -%} - -%threadallow d2i_x509; -%inline %{ -X509 *d2i_x509(BIO *bio) { - return d2i_X509_bio(bio, NULL); -} -%} -%typemap(out) X509 *; - -%constant int NID_commonName = 13; -%constant int NID_countryName = 14; -%constant int NID_localityName = 15; -%constant int NID_stateOrProvinceName = 16; -%constant int NID_organizationName = 17; -%constant int NID_organizationalUnitName = 18; -%constant int NID_serialNumber = 105; -%constant int NID_surname = 100; -%constant int NID_givenName = 99; -%constant int NID_pkcs9_emailAddress = 48; - -/* Cribbed from x509_vfy.h. */ -%constant int X509_V_OK = 0; -%constant int X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2; -%constant int X509_V_ERR_UNABLE_TO_GET_CRL = 3; -%constant int X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4; -%constant int X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5; -%constant int X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6; -%constant int X509_V_ERR_CERT_SIGNATURE_FAILURE = 7; -%constant int X509_V_ERR_CRL_SIGNATURE_FAILURE = 8; -%constant int X509_V_ERR_CERT_NOT_YET_VALID = 9; -%constant int X509_V_ERR_CERT_HAS_EXPIRED = 10; -%constant int X509_V_ERR_CRL_NOT_YET_VALID = 11; -%constant int X509_V_ERR_CRL_HAS_EXPIRED = 12; -%constant int X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13; -%constant int X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14; -%constant int X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = 15; -%constant int X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16; -%constant int X509_V_ERR_OUT_OF_MEM = 17; -%constant int X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18; -%constant int X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19; -%constant int X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20; -%constant int X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21; -%constant int X509_V_ERR_CERT_CHAIN_TOO_LONG = 22; -%constant int X509_V_ERR_CERT_REVOKED = 23; -%constant int X509_V_ERR_INVALID_CA = 24; -%constant int X509_V_ERR_PATH_LENGTH_EXCEEDED = 25; -%constant int X509_V_ERR_INVALID_PURPOSE = 26; -%constant int X509_V_ERR_CERT_UNTRUSTED = 27; -%constant int X509_V_ERR_CERT_REJECTED = 28; -%constant int X509_V_ERR_APPLICATION_VERIFICATION = 50; - -/* See man page of X509_VERIFY_PARAM_set_flags for definition of all these flags */ - -#ifdef X509_V_FLAG_ALLOW_PROXY_CERTS -%constant int VERIFY_ALLOW_PROXY_CERTS = X509_V_FLAG_ALLOW_PROXY_CERTS; -#endif -#ifdef X509_V_FLAG_CB_ISSUER_CHECK -%constant int VERIFY_CB_ISSUER_CHECK = X509_V_FLAG_CB_ISSUER_CHECK; -#endif -#ifdef X509_V_FLAG_CHECK_SS_SIGNATURE -%constant int VERIFY_CHECK_SS_SIGNATURE = X509_V_FLAG_CHECK_SS_SIGNATURE; -#endif -/* note: X509_V_FLAG_CRL_CHECK is already defined in _ssl.i as VERIFY_CRL_CHECK_LEAF -However I add it here for consistency */ -#ifdef X509_V_FLAG_CRL_CHECK -%constant int VERIFY_CRL_CHECK = X509_V_FLAG_CRL_CHECK; -#endif -#ifdef X509_V_FLAG_CRL_CHECK_ALL -%constant int VERIFY_CRL_CHECK_ALL = X509_V_FLAG_CRL_CHECK_ALL; -#endif -#ifdef X509_V_FLAG_EXPLICIT_POLICY -%constant int VERIFY_EXPLICIT_POLICY = X509_V_FLAG_EXPLICIT_POLICY; -#endif -#ifdef X509_V_FLAG_EXTENDED_CRL_SUPPORT -%constant int VERIFY_EXTENDED_CRL_SUPPORT = X509_V_FLAG_EXTENDED_CRL_SUPPORT; -#endif -#ifdef X509_V_FLAG_IGNORE_CRITICAL -%constant int VERIFY_IGNORE_CRITICAL = X509_V_FLAG_IGNORE_CRITICAL; -#endif -#ifdef X509_V_FLAG_INHIBIT_ANY -%constant int VERIFY_INHIBIT_ANY = X509_V_FLAG_INHIBIT_ANY; -#endif -#ifdef X509_V_FLAG_INHIBIT_MAP -%constant int VERIFY_INHIBIT_MAP = X509_V_FLAG_INHIBIT_MAP; -#endif -#ifdef X509_V_FLAG_NO_ALT_CHAINS -%constant int VERIFY_NO_ALT_CHAINS = X509_V_FLAG_NO_ALT_CHAINS; -#endif -#ifdef X509_V_FLAG_NO_CHECK_TIME -%constant int VERIFY_NO_CHECK_TIME = X509_V_FLAG_NO_CHECK_TIME; -#endif -#ifdef X509_V_FLAG_NOTIFY_POLICY -%constant int VERIFY_NOTIFY_POLICY = X509_V_FLAG_NOTIFY_POLICY; -#endif -#ifdef X509_V_FLAG_PARTIAL_CHAIN -%constant int VERIFY_PARTIAL_CHAIN = X509_V_FLAG_PARTIAL_CHAIN; -#endif -#ifdef X509_V_FLAG_POLICY_CHECK -%constant int VERIFY_POLICY_CHECK = X509_V_FLAG_POLICY_CHECK; -#endif -#ifdef X509_V_FLAG_TRUSTED_FIRST -%constant int VERIFY_TRUSTED_FIRST = X509_V_FLAG_TRUSTED_FIRST; -#endif -#ifdef X509_V_FLAG_USE_DELTAS -%constant int VERIFY_USE_DELTAS = X509_V_FLAG_USE_DELTAS; -#endif -#ifdef X509_V_FLAG_X509_STRICT -%constant int VERIFY_X509_STRICT = X509_V_FLAG_X509_STRICT; -#endif - - - -/* x509.h */ -%constant int XN_FLAG_COMPAT = 0; -%constant int XN_FLAG_SEP_COMMA_PLUS = (1 << 16); -%constant int XN_FLAG_SEP_CPLUS_SPC = (2 << 16); -%constant int XN_FLAG_SEP_MULTILINE = (4 << 16); -%constant int XN_FLAG_DN_REV = (1 << 20); -%constant int XN_FLAG_FN_LN = (1 << 21); -%constant int XN_FLAG_SPC_EQ = (1 << 23); -%constant int XN_FLAG_DUMP_UNKNOWN_FIELDS = (1 << 24); -%constant int XN_FLAG_FN_ALIGN = (1 << 25); -%constant int XN_FLAG_ONELINE =(ASN1_STRFLGS_RFC2253 | \ - ASN1_STRFLGS_ESC_QUOTE | \ - XN_FLAG_SEP_CPLUS_SPC | \ - XN_FLAG_SPC_EQ); -%constant int XN_FLAG_MULTILINE = (ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - XN_FLAG_SEP_MULTILINE | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_LN | \ - XN_FLAG_FN_ALIGN); -%constant int XN_FLAG_RFC2253 = (ASN1_STRFLGS_RFC2253 | \ - XN_FLAG_SEP_COMMA_PLUS | \ - XN_FLAG_DN_REV | \ - XN_FLAG_DUMP_UNKNOWN_FIELDS); - -/* Cribbed from rsa.h. */ -%constant int RSA_3 = 0x3L; -%constant int RSA_F4 = 0x10001L; - -%warnfilter(454) _x509_err; -%inline %{ -static PyObject *_x509_err; - -void x509_init(PyObject *x509_err) { - Py_INCREF(x509_err); - _x509_err = x509_err; -} -%} - -%typemap(out) X509_REQ * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_x509_err); - $result = NULL; - } -} -%threadallow d2i_x509_req; -%inline %{ -X509_REQ *d2i_x509_req(BIO *bio) { - return d2i_X509_REQ_bio(bio, NULL); -} -%} - -%threadallow x509_req_read_pem; -%inline %{ -X509_REQ *x509_req_read_pem(BIO *bio) { - return PEM_read_bio_X509_REQ(bio, NULL, NULL, NULL); -} -%} - -%typemap(out) X509_REQ *; - -%inline %{ -PyObject *i2d_x509(X509 *x) { - int len; - PyObject *ret = NULL; - unsigned char *buf = NULL; - len = i2d_X509(x, &buf); - if (len < 0) { - m2_PyErr_Msg(_x509_err); - } - else { - - ret = PyBytes_FromStringAndSize((char*)buf, len); - - OPENSSL_free(buf); - } - return ret; -} -%} - -%threadallow x509_req_write_pem; -%inline %{ -int x509_req_write_pem(BIO *bio, X509_REQ *x) { - return PEM_write_bio_X509_REQ(bio, x); -} -%} - -%typemap(out) X509_CRL * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_x509_err); - $result = NULL; - } -} -%threadallow x509_crl_read_pem; -%inline %{ -X509_CRL *x509_crl_read_pem(BIO *bio) { - return PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); -} -%} -%typemap(out) X509_CRL * ; - -%inline %{ -/* X509_set_version() is a macro. */ -int x509_set_version(X509 *x, long version) { - return X509_set_version(x, version); -} - -/* X509_get_version() is a macro. */ -long x509_get_version(X509 *x) { - return X509_get_version(x); -} - -/* X509_set_notBefore() is a macro. */ -int x509_set_not_before(X509 *x, ASN1_TIME *tm) { - return X509_set_notBefore(x, tm); -} - -/* X509_get_notBefore() is a macro. */ -ASN1_TIME *x509_get_not_before(X509 *x) { - return X509_get_notBefore(x); -} - -/* X509_set_notAfter() is a macro. */ -int x509_set_not_after(X509 *x, ASN1_TIME *tm) { - return X509_set_notAfter(x, tm); -} - -/* X509_get_notAfter() is a macro. */ -ASN1_TIME *x509_get_not_after(X509 *x) { - return X509_get_notAfter(x); -} - -int x509_sign(X509 *x, EVP_PKEY *pkey, EVP_MD *md) { - return X509_sign(x, pkey, md); -} - -/* x509_gmtime_adj() is a macro. */ -ASN1_TIME *x509_gmtime_adj(ASN1_TIME *s, long adj) { - return X509_gmtime_adj(s, adj); -} - -PyObject *x509_name_by_nid(X509_NAME *name, int nid) { - void *buf; - int len, xlen; - PyObject *ret; - - if ((len = X509_NAME_get_text_by_NID(name, nid, NULL, 0)) == -1) { - Py_RETURN_NONE; - } - len++; - if (!(buf = PyMem_Malloc(len))) { - PyErr_SetString(PyExc_MemoryError, "x509_name_by_nid"); - return NULL; - } - xlen = X509_NAME_get_text_by_NID(name, nid, buf, len); - - ret = PyBytes_FromStringAndSize(buf, xlen); - - PyMem_Free(buf); - return ret; -} - -int x509_name_set_by_nid(X509_NAME *name, int nid, PyObject *obj) { - return X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC, (unsigned char *)PyBytes_AsString(obj), -1, -1, 0); -} - -/* x509_name_add_entry_by_txt */ -int x509_name_add_entry_by_txt(X509_NAME *name, char *field, int type, char *bytes, int len, int loc, int set) { - return X509_NAME_add_entry_by_txt(name, field, type, (unsigned char *)bytes, len, loc, set); -} - -PyObject *x509_name_get_der(X509_NAME *name) { - const char* pder=""; - size_t pderlen; - i2d_X509_NAME(name, 0); - if (!X509_NAME_get0_der(name, (const unsigned char **)pder, &pderlen)) { - m2_PyErr_Msg(_x509_err); - return NULL; - } - return PyBytes_FromStringAndSize(pder, pderlen); -} - -/* sk_X509_free() is a macro. */ -void sk_x509_free(STACK_OF(X509) *stack) { - sk_X509_free(stack); -} - -/* sk_X509_push() is a macro. */ -int sk_x509_push(STACK_OF(X509) *stack, X509 *x509) { - return sk_X509_push(stack, x509); -} - -/* sk_X509_pop() is a macro. */ -X509 *sk_x509_pop(STACK_OF(X509) *stack) { - return sk_X509_pop(stack); -} -%} - -%inline %{ -int x509_store_load_locations(X509_STORE *store, const char *file) { - int locations = 0; - - if ((locations = X509_STORE_load_locations(store, file, NULL)) < 1) { - m2_PyErr_Msg(_x509_err); - } - return locations; -} - -int x509_type_check(X509 *x509) { - return 1; -} - -int x509_name_type_check(X509_NAME *name) { - return 1; -} - -X509_NAME *x509_req_get_subject_name(X509_REQ *x) { - return X509_REQ_get_subject_name(x); -} - -long x509_req_get_version(X509_REQ *x) { - return X509_REQ_get_version(x); -} - -int x509_req_set_version(X509_REQ *x, long version) { - return X509_REQ_set_version(x, version); -} - -int x509_req_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts) { - return X509_REQ_add_extensions(req, exts); -} - -X509_NAME_ENTRY *x509_name_entry_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, char *bytes, int len) { - return X509_NAME_ENTRY_create_by_txt( ne, field, type, (unsigned char *)bytes, len); -} -%} - -%typemap(out) X509V3_CTX * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - $result = NULL; - } -} -%inline %{ -X509V3_CTX * -x509v3_set_nconf(void) { - X509V3_CTX * ctx; - CONF *conf = NCONF_new(NULL); - - if (!(ctx=(X509V3_CTX *)PyMem_Malloc(sizeof(X509V3_CTX)))) { - PyErr_SetString(PyExc_MemoryError, "x509v3_set_nconf"); - return NULL; - } - /* X509V3_set_nconf does not generate any error signs at all. */ - X509V3_set_nconf(ctx, conf); - return ctx; -} -%} -%typemap(out) X509V3_CTX * ; - -%typemap(out) X509_EXTENSION * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - m2_PyErr_Msg(_x509_err); - $result = NULL; - } -} -%inline %{ -X509_EXTENSION * -x509v3_ext_conf(void *conf, X509V3_CTX *ctx, char *name, char *value) { - X509_EXTENSION * ext = NULL; - ext = X509V3_EXT_conf(conf, ctx, name, value); - PyMem_Free(ctx); - return ext; -} -%} -%typemap(out) X509_EXTENSION * ; - -%inline %{ -/* X509_EXTENSION_free() might be a macro, didn't find definition. */ -void x509_extension_free(X509_EXTENSION *ext) { - X509_EXTENSION_free(ext); -} - -PyObject *x509_extension_get_name(X509_EXTENSION *ext) { - PyObject * ext_name; - const char * ext_name_str; - ext_name_str = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext))); - if (!ext_name_str) { - m2_PyErr_Msg(_x509_err); - return NULL; - } - ext_name = PyBytes_FromStringAndSize(ext_name_str, strlen(ext_name_str)); - return ext_name; -} - -/* sk_X509_EXTENSION_new_null is a macro. */ -STACK_OF(X509_EXTENSION) *sk_x509_extension_new_null(void) { - return sk_X509_EXTENSION_new_null(); -} - -/* sk_X509_EXTENSION_free() is a macro. */ -void sk_x509_extension_free(STACK_OF(X509_EXTENSION) *stack) { - sk_X509_EXTENSION_free(stack); -} - -/* sk_X509_EXTENSION_push() is a macro. */ -int sk_x509_extension_push(STACK_OF(X509_EXTENSION) *stack, X509_EXTENSION *x509_ext) { - return sk_X509_EXTENSION_push(stack, x509_ext); -} - -/* sk_X509_EXTENSION_pop() is a macro. */ -X509_EXTENSION *sk_x509_extension_pop(STACK_OF(X509_EXTENSION) *stack) { - return sk_X509_EXTENSION_pop(stack); -} - -/* sk_X509_EXTENSION_num() is a macro. */ -int sk_x509_extension_num(STACK_OF(X509_EXTENSION) *stack) { - return sk_X509_EXTENSION_num(stack); -} - -/* sk_X509_EXTENSION_value() is a macro. */ -X509_EXTENSION *sk_x509_extension_value(STACK_OF(X509_EXTENSION) *stack, int i) { - return sk_X509_EXTENSION_value(stack, i); -} - -/* X509_STORE_CTX_get_app_data is a macro. */ -void *x509_store_ctx_get_app_data(X509_STORE_CTX *ctx) { - return X509_STORE_CTX_get_app_data(ctx); -} - -/* X509_STORE_CTX_get_app_data is a macro. */ -void *x509_store_ctx_get_ex_data(X509_STORE_CTX *ctx, int idx) { - return X509_STORE_CTX_get_ex_data(ctx, idx); -} - -void x509_store_set_verify_cb(X509_STORE *store, PyObject *pyfunc) { - Py_XDECREF(x509_store_verify_cb_func); - Py_INCREF(pyfunc); - x509_store_verify_cb_func = pyfunc; - X509_STORE_set_verify_cb(store, x509_store_verify_callback); -} -%} - -%typemap(out) STACK_OF(X509) * { - PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ - - if ($1 != NULL) - $result = SWIG_NewPointerObj($1, $1_descriptor, 0); - else { - $result = NULL; - } -} - -%inline %{ -STACK_OF(X509) * -make_stack_from_der_sequence(PyObject * pyEncodedString){ - STACK_OF(X509) *certs; - Py_ssize_t encoded_string_len; - char *encoded_string; - const unsigned char *tmp_str; - - encoded_string_len = PyBytes_Size(pyEncodedString); - - if (encoded_string_len > INT_MAX) { - PyErr_Format(_x509_err, "object too large"); - return NULL; - } - - encoded_string = PyBytes_AsString(pyEncodedString); - - if (!encoded_string) { - PyErr_SetString(_x509_err, - "Cannot convert Python Bytes to (char *)."); - return NULL; - } - - tmp_str = (unsigned char *)encoded_string; - certs = d2i_SEQ_CERT(NULL, &tmp_str, encoded_string_len); - if (certs == NULL) { - PyErr_SetString(_x509_err, "Generating STACK_OF(X509) failed."); - return NULL; - } - return certs; -} - -/* sk_X509_new_null() is a macro returning "STACK_OF(X509) *". */ -STACK_OF(X509) *sk_x509_new_null(void) { - return sk_X509_new_null(); -} -%} - -%typemap(out) STACK_OF(X509) *; - -%inline %{ -PyObject * -get_der_encoding_stack(STACK_OF(X509) *stack){ - PyObject * encodedString; - - unsigned char * encoding = NULL; - int len; - - len = i2d_SEQ_CERT(stack, &encoding); - if (!encoding) { - m2_PyErr_Msg(_x509_err); - return NULL; - } - - encodedString = PyBytes_FromStringAndSize((const char *)encoding, len); - - if (encoding) - OPENSSL_free(encoding); - - return encodedString; -} - -%} - -/* Free malloc'ed return value for x509_name_oneline */ -%typemap(ret) char * { - if ($1 != NULL) - OPENSSL_free($1); -} -%inline %{ -char *x509_name_oneline(X509_NAME *x) { - return X509_NAME_oneline(x, NULL, 0); -} -%} -%typemap(ret) char *; diff --git a/SWIG/libcrypto-compat.h b/SWIG/libcrypto-compat.h deleted file mode 100644 index 7c4c913..0000000 --- a/SWIG/libcrypto-compat.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef LIBCRYPTO_COMPAT_H -#define LIBCRYPTO_COMPAT_H - -#if OPENSSL_VERSION_NUMBER < 0x10100000L - -#include -#include -#include -#include -#include -#include - -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); -int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); -int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); -void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); -void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); -void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp); - -void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); -int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key); -int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); - -void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); -int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); - -void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); -int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); - -void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); -int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); -int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); -int DH_set_length(DH *dh, long length); - -const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); -unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); -EVP_MD_CTX *EVP_MD_CTX_new(void); -void EVP_MD_CTX_free(EVP_MD_CTX *ctx); -#define EVP_CIPHER_impl_ctx_size(e) e->ctx_size -#define EVP_CIPHER_CTX_get_cipher_data(ctx) ctx->cipher_data - -int RSA_size(const RSA* rsa); -RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); -int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); -#define RSA_meth_get_finish(meth) meth->finish -int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc) (int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); -int RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec) (int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); -int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa)); -void RSA_meth_free(RSA_METHOD *meth); - -int RSA_bits(const RSA *r); - -RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey); - -int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, - size_t *pderlen); - -#endif /* OPENSSL_VERSION_NUMBER */ - -#endif /* LIBCRYPTO_COMPAT_H */ diff --git a/SWIG/py3k_compat.h b/SWIG/py3k_compat.h deleted file mode 100644 index 2e914a5..0000000 --- a/SWIG/py3k_compat.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef PY3K_COMPAT_H -#define PY3K_COMPAT_H - -#if PY_MAJOR_VERSION >= 3 - -FILE* PyFile_AsFile(PyObject *p); -PyObject* PyFile_Name(PyObject *p); - -#else /* PY2K */ - -/* Concerning PyBytes* functions: - * - * Python 3’s str() type is equivalent to Python 2’s unicode(); the - * C functions are called PyUnicode_* for both. The old 8-bit string - * type has become bytes(), with C functions called PyBytes_*. Python - * 2.6 and later provide a compatibility header, bytesobject.h, mapping - * PyBytes names to PyString ones. For best compatibility with Python 3, - * PyUnicode should be used for textual data and PyBytes for binary - * data. It’s also important to remember that PyBytes and PyUnicode in - * Python 3 are not interchangeable like PyString and PyUnicode are in - * Python 2. The following example shows best practices with regards to - * PyUnicode, PyString, and PyBytes. - * - * From https://docs.python.org/2.7/howto/cporting.html - */ - -PyObject* PyLong_FromLong(long x); -const char* PyUnicode_AsUTF8(PyObject *unicode); - -#endif /* PY_MAJOR_VERSION */ - -#endif /* PY3K_COMPAT_H */ diff --git a/setup.py b/setup.py index 42eb589..38b5117 100644 --- a/setup.py +++ b/setup.py @@ -214,8 +214,8 @@ class _M2CryptoBuildExt(build_ext.build_ext): # distutils would be in the run phase, when extension name and path are # known. self.swig_opts.extend(['-outdir', - os.path.join(os.getcwd(), 'M2Crypto')]) - self.include_dirs.append(os.path.join(os.getcwd(), 'SWIG')) + os.path.join(os.getcwd(), 'src', 'M2Crypto')]) + self.include_dirs.append(os.path.join(os.getcwd(), 'src', 'SWIG')) if sys.platform == 'cygwin' and self.openssl is not None: # Cygwin SHOULD work (there's code in distutils), but @@ -272,7 +272,7 @@ else: x_comp_args.update(['-DTHREADING', '-Wno-deprecated-declarations']) m2crypto = setuptools.Extension(name='M2Crypto._m2crypto', - sources=['SWIG/_m2crypto.i'], + sources=['src/SWIG/_m2crypto.i'], extra_compile_args=list(x_comp_args), # Uncomment to build Universal Mac binaries # extra_link_args = @@ -294,9 +294,9 @@ class Clean(clean): def run(self): clean.run(self) garbage_list = [ - os.path.join('M2Crypto', '*.so'), - os.path.join('M2Crypto', '*.pyd'), - os.path.join('M2Crypto', '*.dll') + os.path.join('src', 'M2Crypto', '*.so'), + os.path.join('src', 'M2Crypto', '*.pyd'), + os.path.join('src', 'M2Crypto', '*.dll') ] for p in garbage_list: for f in glob.glob(p): @@ -305,7 +305,7 @@ class Clean(clean): def __get_version(): # noqa - with open('M2Crypto/__init__.py') as init_file: + with open('src/M2Crypto/__init__.py') as init_file: for line in init_file: if line.startswith('__version__ ='): # Originally string.whitespace, but it is deprecated @@ -352,11 +352,14 @@ setuptools.setup( 'Programming Language :: Python :: 3.8', ], keywords='cryptography openssl', - packages=setuptools.find_packages(exclude=['contrib', 'docs', 'tests']), + packages=setuptools.find_packages('src', exclude=['contrib', 'docs', 'tests']), + package_dir={'': 'src'}, ext_modules=[m2crypto], test_suite='tests.alltests.suite', install_requires=requires_list, package_data=package_data, + zip_safe=False, + include_package_data=True, cmdclass={ 'build_ext': _M2CryptoBuildExt, 'build': _M2CryptoBuild, diff --git a/src/M2Crypto/ASN1.py b/src/M2Crypto/ASN1.py new file mode 100644 index 0000000..37fd7a0 --- /dev/null +++ b/src/M2Crypto/ASN1.py @@ -0,0 +1,252 @@ +from __future__ import absolute_import + +""" +M2Crypto wrapper for OpenSSL ASN1 API. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + +Portions created by Open Source Applications Foundation (OSAF) are +Copyright (C) 2005 OSAF. All Rights Reserved. +""" + +import datetime +import time + +from M2Crypto import BIO, m2, six +from typing import Optional # noqa + +MBSTRING_FLAG = 0x1000 +MBSTRING_ASC = MBSTRING_FLAG | 1 +MBSTRING_BMP = MBSTRING_FLAG | 2 + + +class ASN1_Integer(object): + + m2_asn1_integer_free = m2.asn1_integer_free + + def __init__(self, asn1int, _pyfree=0): + # type: (ASN1_Integer, int) -> None + self.asn1int = asn1int + self._pyfree = _pyfree + + def __cmp__(self, other): + # type: (ASN1_Integer) -> int + if not isinstance(other, ASN1_Integer): + raise TypeError( + "Comparisons supported only between ANS1_Integer objects") + + return m2.asn1_integer_cmp(self.asn1int, other.asn1int) + + def __del__(self): + # type: () -> None + if self._pyfree: + self.m2_asn1_integer_free(self.asn1int) + + def __int__(self): + # type: () -> int + return m2.asn1_integer_get(self.asn1int) + + +class ASN1_String(object): + + m2_asn1_string_free = m2.asn1_string_free + + def __init__(self, asn1str, _pyfree=0): + # type: (ASN1_String, int) -> None + self.asn1str = asn1str + self._pyfree = _pyfree + + def __bytes__(self): + # type: () -> bytes + buf = BIO.MemoryBuffer() + m2.asn1_string_print(buf.bio_ptr(), self.asn1str) + return buf.read_all() + + def __str__(self): + # type: () -> str + return six.ensure_text(self.__bytes__()) + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_asn1_string_free(self.asn1str) + + def _ptr(self): + return self.asn1str + + def as_text(self, flags=0): + # type: (int) -> str + """Output an ASN1_STRING structure according to the set flags. + + :param flags: determine the format of the output by using + predetermined constants, see ASN1_STRING_print_ex(3) + manpage for their meaning. + :return: output an ASN1_STRING structure. + """ + buf = BIO.MemoryBuffer() + m2.asn1_string_print_ex(buf.bio_ptr(), self.asn1str, flags) + return six.ensure_text(buf.read_all()) + + +class ASN1_Object(object): + + m2_asn1_object_free = m2.asn1_object_free + + def __init__(self, asn1obj, _pyfree=0): + # type: (ASN1_Object, int) -> None + self.asn1obj = asn1obj + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if self._pyfree: + self.m2_asn1_object_free(self.asn1obj) + + def _ptr(self): + return self.asn1obj + + +class _UTC(datetime.tzinfo): + def tzname(self, dt): + # type: (Optional[datetime.datetime]) -> str + return "UTC" + + def dst(self, dt): + # type: (Optional[datetime.datetime]) -> datetime.timedelta + return datetime.timedelta(0) + + def utcoffset(self, dt): + # type: (Optional[datetime.datetime]) -> datetime.timedelta + return datetime.timedelta(0) + + def __repr__(self): + return "" % self.tzname(None) + + +UTC = _UTC() # type: _UTC + + +class LocalTimezone(datetime.tzinfo): + """Localtimezone from datetime manual.""" + + def __init__(self): + # type: () -> None + self._stdoffset = datetime.timedelta(seconds=-time.timezone) + if time.daylight: + self._dstoffset = datetime.timedelta(seconds=-time.altzone) + else: + self._dstoffset = self._stdoffset + self._dstdiff = self._dstoffset - self._stdoffset + + def utcoffset(self, dt): + # type: (datetime.datetime) -> datetime.timedelta + if self._isdst(dt): + return self._dstoffset + else: + return self._stdoffset + + def dst(self, dt): + # type: (datetime.datetime) -> datetime.timedelta + if self._isdst(dt): + return self._dstdiff + else: + return datetime.timedelta(0) + + def tzname(self, dt): + # type: (datetime.datetime) -> str + return time.tzname[self._isdst(dt).real] + + def _isdst(self, dt): + # type: (datetime.datetime) -> bool + tt = (dt.year, dt.month, dt.day, + dt.hour, dt.minute, dt.second, + dt.weekday(), 0, -1) + stamp = time.mktime(tt) + tt = time.localtime(stamp) + return tt.tm_isdst > 0 + + +class ASN1_TIME(object): + _ssl_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec"] + m2_asn1_time_free = m2.asn1_time_free + + def __init__(self, asn1_time=None, _pyfree=0, asn1_utctime=None): + # type: (Optional[ASN1_TIME], Optional[int], Optional[ASN1_TIME]) -> None + # handle old keyword parameter + if asn1_time is None: + asn1_time = asn1_utctime + if asn1_time is not None: + assert m2.asn1_time_type_check(asn1_time), \ + "'asn1_time' type error'" + self.asn1_time = asn1_time + self._pyfree = _pyfree + else: + self.asn1_time = m2.asn1_time_new() + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_asn1_time_free(self.asn1_time) + + def __str__(self): + # type: () -> str + assert m2.asn1_time_type_check(self.asn1_time), \ + "'asn1_time' type error'" + buf = BIO.MemoryBuffer() + m2.asn1_time_print(buf.bio_ptr(), self.asn1_time) + return six.ensure_text(buf.read_all()) + + def _ptr(self): + assert m2.asn1_time_type_check(self.asn1_time), \ + "'asn1_time' type error'" + return self.asn1_time + + def set_string(self, string): + # type: (bytes) -> int + """Set time from UTC string.""" + assert m2.asn1_time_type_check(self.asn1_time), \ + "'asn1_time' type error'" + return m2.asn1_time_set_string(self.asn1_time, string) + + def set_time(self, time): + # type: (int) -> ASN1_TIME + """Set time from seconds since epoch (int).""" + assert m2.asn1_time_type_check(self.asn1_time), \ + "'asn1_time' type error'" + return m2.asn1_time_set(self.asn1_time, time) + + def get_datetime(self): + # type: () -> ASN1_TIME + date = str(self) + + timezone = None + if ' ' not in date: + raise ValueError("Invalid date: %s" % date) + month, rest = date.split(' ', 1) + if month not in self._ssl_months: + raise ValueError("Invalid date %s: Invalid month: %s" % + (date, month)) + if rest.endswith(' GMT'): + timezone = UTC + rest = rest[:-4] + if '.' in rest: + dt = datetime.datetime.strptime(rest, "%d %H:%M:%S.%f %Y") + else: + dt = datetime.datetime.strptime(rest, "%d %H:%M:%S %Y") + dt = dt.replace(month=self._ssl_months.index(month) + 1) + if timezone: + dt = dt.replace(tzinfo=UTC) + return dt + + def set_datetime(self, date): + # type: (datetime.datetime) -> ASN1_TIME + local = LocalTimezone() + if date.tzinfo is None: + date = date.replace(tzinfo=local) + date = date.astimezone(local) + return self.set_time(int(time.mktime(date.timetuple()))) + + +ASN1_UTCTIME = ASN1_TIME diff --git a/src/M2Crypto/AuthCookie.py b/src/M2Crypto/AuthCookie.py new file mode 100644 index 0000000..ff6df2b --- /dev/null +++ b/src/M2Crypto/AuthCookie.py @@ -0,0 +1,168 @@ +from __future__ import absolute_import + +"""Secure Authenticator Cookies + +Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" + +import logging +import re +import time + +from M2Crypto import Rand, m2, six, util +from M2Crypto.six.moves.http_cookies import SimpleCookie + +from typing import re as type_re, AnyStr, Optional, Union # noqa + +_MIX_FORMAT = 'exp=%f&data=%s&digest=' +_MIX_RE = re.compile(r'exp=(\d+\.\d+)&data=(.+)&digest=(\S*)') + +log = logging.getLogger(__name__) + + +def mix(expiry, data, format=_MIX_FORMAT): + # type: (float, AnyStr, str) -> AnyStr + return format % (expiry, data) + + +def unmix(dough, regex=_MIX_RE): + # type: (AnyStr, type_re) -> object + mo = regex.match(dough) + if mo: + return float(mo.group(1)), mo.group(2) + else: + return None + + +def unmix3(dough, regex=_MIX_RE): + # type: (AnyStr, type_re) -> Optional[tuple[float, AnyStr, AnyStr]] + mo = regex.match(dough) + if mo: + return float(mo.group(1)), mo.group(2), mo.group(3) + else: + return None + + +_TOKEN = '_M2AUTH_' # type: str + + +class AuthCookieJar(object): + + _keylen = 20 # type: int + + def __init__(self): + # type: () -> None + self._key = Rand.rand_bytes(self._keylen) + + def _hmac(self, key, data): + # type: (bytes, str) -> str + return util.bin_to_hex(m2.hmac(key, six.ensure_binary(data), m2.sha1())) + + def makeCookie(self, expiry, data): + # type: (float, str) -> AuthCookie + """ + Make a cookie + + :param expiry: expiration time (float in seconds) + :param data: cookie content + :return: AuthCookie object + """ + if not isinstance(expiry, (six.integer_types, float)): + raise ValueError('Expiration time must be number, not "%s' % expiry) + dough = mix(expiry, data) + return AuthCookie(expiry, data, dough, self._hmac(self._key, dough)) + + def isGoodCookie(self, cookie): + # type: (AuthCookie) -> Union[bool, int] + assert isinstance(cookie, AuthCookie) + if cookie.isExpired(): + return 0 + c = self.makeCookie(cookie._expiry, cookie._data) + return (c._expiry == cookie._expiry) \ + and (c._data == cookie._data) \ + and (c._mac == cookie._mac) \ + and (c.output() == cookie.output()) + + def isGoodCookieString(self, cookie_str, _debug=False): + # type: (Union[dict, bytes], bool) -> Union[bool, int] + c = SimpleCookie() + c.load(cookie_str) + if _TOKEN not in c: + log.debug('_TOKEN not in c (keys = %s)', dir(c)) + return 0 + undough = unmix3(c[_TOKEN].value) + if undough is None: + log.debug('undough is None') + return 0 + exp, data, mac = undough + c2 = self.makeCookie(exp, data) + if _debug and (c2._mac == mac): + log.error('cookie_str = %s', cookie_str) + log.error('c2.isExpired = %s', c2.isExpired()) + log.error('mac = %s', mac) + log.error('c2._mac = %s', c2._mac) + log.error('c2._mac == mac: %s', str(c2._mac == mac)) + return (not c2.isExpired()) and (c2._mac == mac) + + +class AuthCookie(object): + + def __init__(self, expiry, data, dough, mac): + # type: (float, str, str, str) -> None + """ + Create new authentication cookie + + :param expiry: expiration time (in seconds) + :param data: cookie payload (as a string) + :param dough: expiry & data concatenated to URL compliant + string + :param mac: SHA1-based HMAC of dough and random key + """ + self._expiry = expiry + self._data = data + self._mac = mac + self._cookie = SimpleCookie() + self._cookie[_TOKEN] = '%s%s' % (dough, mac) + self._name = '%s%s' % (dough, mac) # WebKit only. + + def expiry(self): + # type: () -> float + """Return the cookie's expiry time.""" + return self._expiry + + def data(self): + # type: () -> str + """Return the data portion of the cookie.""" + return self._data + + def mac(self): + # type: () -> str + """Return the cookie's MAC.""" + return self._mac + + def output(self, header="Set-Cookie:"): + # type: (Optional[str]) -> str + """Return the cookie's output in "Set-Cookie" format.""" + return self._cookie.output(header=header) + + def value(self): + # type: () -> str + """Return the cookie's output minus the "Set-Cookie: " portion. + """ + return self._cookie[_TOKEN].value + + def isExpired(self): + # type: () -> bool + """Return 1 if the cookie has expired, 0 otherwise.""" + return isinstance(self._expiry, (float, six.integer_types)) and \ + (time.time() > self._expiry) + + # Following two methods are for WebKit only. + # I may wish to push them to WKAuthCookie, but they are part + # of the API now. Oh well. + def name(self): + # type: () -> str + return self._name + + def headerValue(self): + # type: () -> str + return self.value() diff --git a/src/M2Crypto/BIO.py b/src/M2Crypto/BIO.py new file mode 100644 index 0000000..090064b --- /dev/null +++ b/src/M2Crypto/BIO.py @@ -0,0 +1,390 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL BIO API. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" + +import io +import logging +from typing import Any, AnyStr, Callable, Iterable, Optional, Union # noqa + +from M2Crypto import m2, six + +log = logging.getLogger('BIO') + + +class BIOError(ValueError): + pass + + +m2.bio_init(BIOError) + + +class BIO(object): + """Abstract object interface to the BIO API.""" + + m2_bio_free = m2.bio_free + + def __init__(self, bio=None, _pyfree=0, _close_cb=None): + # type: (Optional[BIO], int, Optional[Callable]) -> None + self.bio = bio + self._pyfree = _pyfree + self._close_cb = _close_cb + self.closed = 0 + self.write_closed = 0 + + def __del__(self): + if self._pyfree: + self.m2_bio_free(self.bio) + + def _ptr(self): + return self.bio + + # Deprecated. + bio_ptr = _ptr + + def fileno(self): + # type: () -> int + return m2.bio_get_fd(self.bio) + + def readable(self): + # type: () -> bool + return not self.closed + + def read(self, size=None): + # type: (int) -> Union[bytes, bytearray] + if not self.readable(): + raise IOError('cannot read') + if size is None: + buf = bytearray() + while 1: + data = m2.bio_read(self.bio, 4096) + if not data: + break + buf += data + return buf + elif size == 0: + return b'' + elif size < 0: + raise ValueError('read count is negative') + else: + return bytes(m2.bio_read(self.bio, size)) + + def readline(self, size=4096): + # type: (int) -> bytes + if not self.readable(): + raise IOError('cannot read') + buf = m2.bio_gets(self.bio, size) + buf = '' if buf is None else buf + return six.ensure_binary(buf) + + def readlines(self, sizehint='ignored'): + # type: (Union[AnyStr, int]) -> Iterable[bytes] + if not self.readable(): + raise IOError('cannot read') + lines = [] + while 1: + buf = m2.bio_gets(self.bio, 4096) + if buf is None: + break + lines.append(six.ensure_binary(buf)) + return lines + + def writeable(self): + # type: () -> bool + return (not self.closed) and (not self.write_closed) + + def write(self, data): + # type: (AnyStr) -> int + """Write data to BIO. + + :return: either data written, or [0, -1] for nothing written, + -2 not implemented + """ + if not self.writeable(): + raise IOError('cannot write') + if isinstance(data, six.text_type): + data = data.encode('utf8') + return m2.bio_write(self.bio, data) + + def write_close(self): + # type: () -> None + self.write_closed = 1 + + def flush(self): + # type: () -> None + """Flush the buffers. + + :return: 1 for success, and 0 or -1 for failure + """ + m2.bio_flush(self.bio) + + def reset(self): + # type: () -> int + """Set the bio to its initial state. + + :return: 1 for success, and 0 or -1 for failure + """ + return m2.bio_reset(self.bio) + + def close(self): + # type: () -> None + self.closed = 1 + if self._close_cb: + self._close_cb() + + def should_retry(self): + # type: () -> int + """ + Can the call be attempted again, or was there an error + ie do_handshake + + """ + return m2.bio_should_retry(self.bio) + + def should_read(self): + # type: () -> int + """Should we read more data?""" + + return m2.bio_should_read(self.bio) + + def should_write(self): + # type: () -> int + """Should we write more data?""" + return m2.bio_should_write(self.bio) + + def tell(self): + """Return the current offset.""" + return m2.bio_tell(self.bio) + + def seek(self, off): + """Seek to the specified absolute offset.""" + return m2.bio_seek(self.bio, off) + + def __enter__(self): + return self + + def __exit__(self, *args): + # type: (*Any) -> int + self.close() + + +class MemoryBuffer(BIO): + """Object interface to BIO_s_mem. + + Empirical testing suggests that this class performs less well than + cStringIO, because cStringIO is implemented in C, whereas this class + is implemented in Python. Thus, the recommended practice is to use + cStringIO for regular work and convert said cStringIO object to + a MemoryBuffer object only when necessary. + """ + + def __init__(self, data=None): + # type: (Optional[bytes]) -> None + super(MemoryBuffer, self).__init__(self) + if data is not None and not isinstance(data, bytes): + raise TypeError( + "data must be bytes or None, not %s" % (type(data).__name__, )) + self.bio = m2.bio_new(m2.bio_s_mem()) + self._pyfree = 1 + if data is not None: + m2.bio_write(self.bio, data) + + def __len__(self): + # type: () -> int + return m2.bio_ctrl_pending(self.bio) + + def read(self, size=0): + # type: (int) -> bytes + if not self.readable(): + raise IOError('cannot read') + if size: + return m2.bio_read(self.bio, size) + else: + return m2.bio_read(self.bio, m2.bio_ctrl_pending(self.bio)) + + # Backwards-compatibility. + getvalue = read_all = read + + def write_close(self): + # type: () -> None + super(MemoryBuffer, self).write_close() + m2.bio_set_mem_eof_return(self.bio, 0) + + close = write_close + + +class File(BIO): + """Object interface to BIO_s_pyfd. + + This class interfaces Python to OpenSSL functions that expect BIO. For + general file manipulation in Python, use Python's builtin file object. + """ + + def __init__(self, pyfile, close_pyfile=1, mode='rb'): + # type: (Union[io.BytesIO, AnyStr], int, AnyStr) -> None + super(File, self).__init__(self, _pyfree=1) + + if isinstance(pyfile, six.string_types): + pyfile = open(pyfile, mode) + + # This is for downward compatibility, but I don't think, that it is + # good practice to have two handles for the same file. Whats about + # concurrent write access? Last write, last wins? Especially since Py3 + # has its own buffer management. See: + # + # https://docs.python.org/3.3/c-api/file.html + # + pyfile.flush() + self.fname = pyfile.name + self.pyfile = pyfile + # Be wary of https://github.com/openssl/openssl/pull/1925 + # BIO_new_fd is NEVER to be used before OpenSSL 1.1.1 + if hasattr(m2, "bio_new_pyfd"): + self.bio = m2.bio_new_pyfd(pyfile.fileno(), m2.bio_noclose) + else: + self.bio = m2.bio_new_pyfile(pyfile, m2.bio_noclose) + + self.close_pyfile = close_pyfile + self.closed = False + + def flush(self): + # type: () -> None + super(File, self).flush() + self.pyfile.flush() + + def close(self): + # type: () -> None + self.flush() + super(File, self).close() + if self.close_pyfile: + self.pyfile.close() + + def reset(self): + # type: () -> int + """Set the bio to its initial state. + + :return: 0 for success, and -1 for failure + """ + return super(File, self).reset() + + def __del__(self): + if not self.closed: + m2.bio_free(self.bio) + + +def openfile(filename, mode='rb'): + # type: (AnyStr, AnyStr) -> File + try: + f = open(filename, mode) + except IOError as ex: + raise BIOError(ex.args) + + return File(f) + + +class IOBuffer(BIO): + """Object interface to BIO_f_buffer. + + Its principal function is to be BIO_push()'ed on top of a BIO_f_ssl, so + that makefile() of said underlying SSL socket works. + """ + + m2_bio_pop = m2.bio_pop + m2_bio_free = m2.bio_free + + def __init__(self, under_bio, mode='rwb', _pyfree=1): + # type: (BIO, str, int) -> None + super(IOBuffer, self).__init__(self, _pyfree=_pyfree) + self.io = m2.bio_new(m2.bio_f_buffer()) + self.bio = m2.bio_push(self.io, under_bio._ptr()) + # This reference keeps the underlying BIO alive while we're not closed. + self._under_bio = under_bio + if 'w' in mode: + self.write_closed = 0 + else: + self.write_closed = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_bio_pop(self.bio) + self.m2_bio_free(self.io) + + def close(self): + # type: () -> None + BIO.close(self) + + +class CipherStream(BIO): + """Object interface to BIO_f_cipher.""" + + SALT_LEN = m2.PKCS5_SALT_LEN + + m2_bio_pop = m2.bio_pop + m2_bio_free = m2.bio_free + + def __init__(self, obio): + # type: (BIO) -> None + super(CipherStream, self).__init__(self, _pyfree=1) + self.obio = obio + self.bio = m2.bio_new(m2.bio_f_cipher()) + self.closed = 0 + + def __del__(self): + # type: () -> None + if not getattr(self, 'closed', 1): + self.close() + + def close(self): + # type: () -> None + self.m2_bio_pop(self.bio) + self.m2_bio_free(self.bio) + self.closed = 1 + + def write_close(self): + # type: () -> None + self.obio.write_close() + + def set_cipher(self, algo, key, iv, op): + # type: (str, AnyStr, AnyStr, int) -> None + cipher = getattr(m2, algo, None) + if cipher is None: + raise ValueError('unknown cipher', algo) + else: + if not isinstance(key, bytes): + key = key.encode('utf8') + if not isinstance(iv, bytes): + iv = iv.encode('utf8') + m2.bio_set_cipher(self.bio, cipher(), key, iv, int(op)) + m2.bio_push(self.bio, self.obio._ptr()) + + +class SSLBio(BIO): + """Object interface to BIO_f_ssl.""" + + def __init__(self, _pyfree=1): + # type: (int) -> None + super(SSLBio, self).__init__(self, _pyfree=_pyfree) + self.bio = m2.bio_new(m2.bio_f_ssl()) + self.closed = 0 + + def set_ssl(self, conn, close_flag=m2.bio_noclose): + ## type: (Connection, int) -> None + """ + Sets the bio to the SSL pointer which is + contained in the connection object. + """ + self._pyfree = 0 + m2.bio_set_ssl(self.bio, conn.ssl, close_flag) + if close_flag == m2.bio_noclose: + conn.set_ssl_close_flag(m2.bio_close) + + def do_handshake(self): + # type: () -> int + """Do the handshake. + + Return 1 if the handshake completes + Return 0 or a negative number if there is a problem + """ + return m2.bio_do_handshake(self.bio) diff --git a/src/M2Crypto/BN.py b/src/M2Crypto/BN.py new file mode 100644 index 0000000..0d8c3b2 --- /dev/null +++ b/src/M2Crypto/BN.py @@ -0,0 +1,57 @@ +from __future__ import absolute_import + +""" +M2Crypto wrapper for OpenSSL BN (BIGNUM) API. + +Copyright (c) 2005 Open Source Applications Foundation. All rights reserved. +""" + +from M2Crypto import m2 +from typing import Optional # noqa + + +def rand(bits, top=-1, bottom=0): + # type: (int, int, int) -> Optional[int] + """ + Generate cryptographically strong random number. + + :param bits: Length of random number in bits. + :param top: If -1, the most significant bit can be 0. If 0, the most + significant bit is 1, and if 1, the two most significant + bits will be 1. + :param bottom: If bottom is true, the number will be odd. + """ + return m2.bn_rand(bits, top, bottom) + + +def rand_range(range): + # type: (int) -> int + """ + Generate a random number in a range. + + :param range: Upper limit for range. + :return: A random number in the range [0, range) + """ + return m2.bn_rand_range(range) + + +def randfname(length): + # type: (int) -> str + """ + Return a random filename, which is simply a string where all + the characters are from the set [a-zA-Z0-9]. + + :param length: Length of filename to return. + :return: random filename string + """ + import warnings + warnings.warn( + "Don't use BN.randfname(), use tempfile methods instead.", + DeprecationWarning, stacklevel=2) + letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890' + lettersLen = len(letters) + fname = [] # type: list + for x in range(length): + fname += [letters[m2.bn_rand_range(lettersLen)]] + + return ''.join(fname) diff --git a/src/M2Crypto/DH.py b/src/M2Crypto/DH.py new file mode 100644 index 0000000..38ea0d5 --- /dev/null +++ b/src/M2Crypto/DH.py @@ -0,0 +1,113 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL DH API. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +from M2Crypto import BIO, m2 +from M2Crypto.util import genparam_callback +from typing import AnyStr, Callable, Optional # noqa + + +class DHError(Exception): + pass + + +m2.dh_init(DHError) + + +class DH(object): + """Object interface to the Diffie-Hellman key exchange protocol. + """ + + m2_dh_free = m2.dh_free + + def __init__(self, dh, _pyfree=0): + # type: (bytes, int) -> None + assert m2.dh_type_check(dh) + self.dh = dh + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_dh_free(self.dh) + + def __len__(self): + # type: () -> int + assert m2.dh_type_check(self.dh), "'dh' type error" + return int(m2.dh_size(self.dh)) + + def __getattr__(self, name): + # type: (str) -> bytes + if name in ('p', 'g', 'pub', 'priv'): + method = getattr(m2, 'dh_get_%s' % (name,)) + assert m2.dh_type_check(self.dh), "'dh' type error" + return method(self.dh) + else: + raise AttributeError + + def __setattr__(self, name, value): + # type: (str, bytes) -> bytes + if name in ('p', 'g'): + raise DHError('set (p, g) via set_params()') + elif name in ('pub', 'priv'): + raise DHError('generate (pub, priv) via gen_key()') + else: + self.__dict__[name] = value + + def _ptr(self): + return self.dh + + def check_params(self): + # type: () -> int + assert m2.dh_type_check(self.dh), "'dh' type error" + return m2.dh_check(self.dh) + + def gen_key(self): + # type: () -> None + assert m2.dh_type_check(self.dh), "'dh' type error" + m2.dh_generate_key(self.dh) + + def compute_key(self, pubkey): + # type: (bytes) -> bytes + assert m2.dh_type_check(self.dh), "'dh' type error" + return m2.dh_compute_key(self.dh, pubkey) + + def print_params(self, bio): + # type: (BIO.BIO) -> int + assert m2.dh_type_check(self.dh), "'dh' type error" + return m2.dhparams_print(bio._ptr(), self.dh) + + +def gen_params(plen, g, callback=genparam_callback): + # type: (int, int, Optional[Callable]) -> DH + dh_parms = m2.dh_generate_parameters(plen, g, callback) + dh_obj = DH(dh_parms, 1) + return dh_obj + + +def load_params(file): + # type: (AnyStr) -> DH + with BIO.openfile(file) as bio: + return load_params_bio(bio) + + +def load_params_bio(bio): + # type: (BIO.BIO) -> DH + return DH(m2.dh_read_parameters(bio._ptr()), 1) + + +def set_params(p, g): + # type: (bytes, bytes) -> DH + dh = m2.dh_new() + m2.dh_set_pg(dh, p, g) + return DH(dh, 1) + + +# def free_params(cptr): +# m2.dh_free(cptr) + + +DH_GENERATOR_2 = m2.DH_GENERATOR_2 +DH_GENERATOR_5 = m2.DH_GENERATOR_5 diff --git a/src/M2Crypto/DSA.py b/src/M2Crypto/DSA.py new file mode 100644 index 0000000..d4f2073 --- /dev/null +++ b/src/M2Crypto/DSA.py @@ -0,0 +1,448 @@ +from __future__ import absolute_import, print_function + +""" + M2Crypto wrapper for OpenSSL DSA API. + + Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. + + Portions created by Open Source Applications Foundation (OSAF) are + Copyright (C) 2004 OSAF. All Rights Reserved. +""" + +from M2Crypto import BIO, m2, util +from typing import Any, AnyStr, Callable, Tuple # noqa + + +class DSAError(Exception): + pass + + +m2.dsa_init(DSAError) + + +class DSA(object): + + """ + This class is a context supporting DSA key and parameter + values, signing and verifying. + + Simple example:: + + from M2Crypto import EVP, DSA, util + + message = 'Kilroy was here!' + md = EVP.MessageDigest('sha1') + md.update(message) + digest = md.final() + + dsa = DSA.gen_params(1024) + dsa.gen_key() + r, s = dsa.sign(digest) + good = dsa.verify(digest, r, s) + if good: + print(' ** success **') + else: + print(' ** verification failed **') + """ + + m2_dsa_free = m2.dsa_free + + def __init__(self, dsa, _pyfree=0): + # type: (bytes, int) -> None + """ + Use one of the factory functions to create an instance. + :param dsa: binary representation of OpenSSL DSA type + """ + assert m2.dsa_type_check(dsa), "'dsa' type error" + self.dsa = dsa + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_dsa_free(self.dsa) + + def __len__(self): + # type: () -> int + """ + Return the key length. + + :return: the DSA key length in bits + """ + assert m2.dsa_type_check(self.dsa), "'dsa' type error" + return m2.dsa_keylen(self.dsa) + + def __getattr__(self, name): + # type: (str) -> bytes + """ + Return specified DSA parameters and key values. + + :param name: name of variable to be returned. Must be + one of 'p', 'q', 'g', 'pub', 'priv'. + :return: value of specified variable (a "byte string") + """ + if name in ['p', 'q', 'g', 'pub', 'priv']: + method = getattr(m2, 'dsa_get_%s' % (name,)) + assert m2.dsa_type_check(self.dsa), "'dsa' type error" + return method(self.dsa) + else: + raise AttributeError + + def __setattr__(self, name, value): + # type: (str, bytes) -> None + if name in ['p', 'q', 'g']: + raise DSAError('set (p, q, g) via set_params()') + elif name in ['pub', 'priv']: + raise DSAError('generate (pub, priv) via gen_key()') + else: + self.__dict__[name] = value + + def set_params(self, p, q, g): + # type: (bytes, bytes, bytes) -> None + """ + Set new parameters. + + :param p: MPI binary representation ... format that consists of + the number's length in bytes represented as a 4-byte + big-endian number, and the number itself in big-endian + format, where the most significant bit signals + a negative number (the representation of numbers with + the MSB set is prefixed with null byte). + :param q: ditto + :param g: ditto + + @warning: This does not change the private key, so it may be + unsafe to use this method. It is better to use + gen_params function to create a new DSA object. + """ + m2.dsa_set_pqg(self.dsa, p, q, g) + + def gen_key(self): + # type: () -> None + """ + Generate a key pair. + """ + assert m2.dsa_type_check(self.dsa), "'dsa' type error" + m2.dsa_gen_key(self.dsa) + + def save_params(self, filename): + # type: (AnyStr) -> int + """ + Save the DSA parameters to a file. + + :param filename: Save the DSA parameters to this file. + :return: 1 (true) if successful + """ + with BIO.openfile(filename, 'wb') as bio: + ret = m2.dsa_write_params_bio(self.dsa, bio._ptr()) + + return ret + + def save_params_bio(self, bio): + # type: (BIO.BIO) -> int + """ + Save DSA parameters to a BIO object. + + :param bio: Save DSA parameters to this object. + :return: 1 (true) if successful + """ + return m2.dsa_write_params_bio(self.dsa, bio._ptr()) + + def save_key(self, filename, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (AnyStr, str, Callable) -> int + """ + Save the DSA key pair to a file. + + :param filename: Save the DSA key pair to this file. + :param cipher: name of symmetric key algorithm and mode + to encrypt the private key. + :return: 1 (true) if successful + """ + with BIO.openfile(filename, 'wb') as bio: + ret = self.save_key_bio(bio, cipher, callback) + + return ret + + def save_key_bio(self, bio, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (BIO.BIO, str, Callable) -> int + """ + Save DSA key pair to a BIO object. + + :param bio: Save DSA parameters to this object. + :param cipher: name of symmetric key algorithm and mode + to encrypt the private key. + :return: 1 (true) if successful + """ + if cipher is None: + return m2.dsa_write_key_bio_no_cipher(self.dsa, + bio._ptr(), callback) + else: + ciph = getattr(m2, cipher, None) + if ciph is None: + raise DSAError('no such cipher: %s' % cipher) + else: + ciph = ciph() + return m2.dsa_write_key_bio(self.dsa, bio._ptr(), ciph, callback) + + def save_pub_key(self, filename): + # type: (AnyStr) -> int + """ + Save the DSA public key (with parameters) to a file. + + :param filename: Save DSA public key (with parameters) + to this file. + :return: 1 (true) if successful + """ + with BIO.openfile(filename, 'wb') as bio: + ret = self.save_pub_key_bio(bio) + + return ret + + def save_pub_key_bio(self, bio): + # type: (BIO.BIO) -> int + """ + Save DSA public key (with parameters) to a BIO object. + + :param bio: Save DSA public key (with parameters) + to this object. + :return: 1 (true) if successful + """ + return m2.dsa_write_pub_key_bio(self.dsa, bio._ptr()) + + def sign(self, digest): + # type: (bytes) -> Tuple[bytes, bytes] + """ + Sign the digest. + + :param digest: SHA-1 hash of message (same as output + from MessageDigest, a "byte string") + :return: DSA signature, a tuple of two values, r and s, + both "byte strings". + """ + assert self.check_key(), 'key is not initialised' + return m2.dsa_sign(self.dsa, digest) + + def verify(self, digest, r, s): + # type: (bytes, bytes, bytes) -> int + """ + Verify a newly calculated digest against the signature + values r and s. + + :param digest: SHA-1 hash of message (same as output + from MessageDigest, a "byte string") + :param r: r value of the signature, a "byte string" + :param s: s value of the signature, a "byte string" + :return: 1 (true) if verify succeeded, 0 if failed + """ + assert self.check_key(), 'key is not initialised' + return m2.dsa_verify(self.dsa, digest, r, s) + + def sign_asn1(self, digest): + assert self.check_key(), 'key is not initialised' + return m2.dsa_sign_asn1(self.dsa, digest) + + def verify_asn1(self, digest, blob): + assert self.check_key(), 'key is not initialised' + return m2.dsa_verify_asn1(self.dsa, digest, blob) + + def check_key(self): + """ + Check to be sure the DSA object has a valid private key. + + :return: 1 (true) if a valid private key + """ + assert m2.dsa_type_check(self.dsa), "'dsa' type error" + return m2.dsa_check_key(self.dsa) + + +class DSA_pub(DSA): + + """ + This class is a DSA context that only supports a public key + and verification. It does NOT support a private key or + signing. + + """ + + def sign(self, *argv): + # type: (*Any) -> None + raise DSAError('DSA_pub object has no private key') + + sign_asn1 = sign + + def check_key(self): + # type: () -> int + """ + :return: does DSA_pub contain a pub key? + """ + return m2.dsa_check_pub_key(self.dsa) + + save_key = DSA.save_pub_key + + save_key_bio = DSA.save_pub_key_bio + +# -------------------------------------------------------------- +# factories and other functions + + +def gen_params(bits, callback=util.genparam_callback): + # type: (int, Callable) -> DSA + """ + Factory function that generates DSA parameters and + instantiates a DSA object from the output. + + :param bits: The length of the prime to be generated. If + 'bits' < 512, it is set to 512. + :param callback: A Python callback object that will be + invoked during parameter generation; it usual + purpose is to provide visual feedback. + :return: instance of DSA. + """ + dsa = m2.dsa_generate_parameters(bits, callback) + return DSA(dsa, 1) + + +def set_params(p, q, g): + # type: (bytes, bytes, bytes) -> DSA + """ + Factory function that instantiates a DSA object with DSA + parameters. + + :param p: value of p, a "byte string" + :param q: value of q, a "byte string" + :param g: value of g, a "byte string" + :return: instance of DSA. + """ + dsa = m2.dsa_new() + m2.dsa_set_pqg(dsa, p, q, g) + return DSA(dsa, 1) + + +def load_params(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> DSA + """ + Factory function that instantiates a DSA object with DSA + parameters from a file. + + :param file: Names the file (a path) that contains the PEM + representation of the DSA parameters. + :param callback: A Python callback object that will be + invoked if the DSA parameters file is + passphrase-protected. + :return: instance of DSA. + """ + with BIO.openfile(file) as bio: + ret = load_params_bio(bio, callback) + + return ret + + +def load_params_bio(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> DSA + """ + Factory function that instantiates a DSA object with DSA + parameters from a M2Crypto.BIO object. + + :param bio: Contains the PEM representation of the DSA + parameters. + :param callback: A Python callback object that will be + invoked if the DSA parameters file is + passphrase-protected. + :return: instance of DSA. + """ + dsa = m2.dsa_read_params(bio._ptr(), callback) + return DSA(dsa, 1) + + +def load_key(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> DSA + """ + Factory function that instantiates a DSA object from a + PEM encoded DSA key pair. + + :param file: Names the file (a path) that contains the PEM + representation of the DSA key pair. + :param callback: A Python callback object that will be + invoked if the DSA key pair is + passphrase-protected. + :return: instance of DSA. + """ + with BIO.openfile(file) as bio: + ret = load_key_bio(bio, callback) + + return ret + + +def load_key_bio(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> DSA + """ + Factory function that instantiates a DSA object from a + PEM encoded DSA key pair. + + :param bio: Contains the PEM representation of the DSA + key pair. + :param callback: A Python callback object that will be + invoked if the DSA key pair is + passphrase-protected. + :return: instance of DSA. + """ + dsa = m2.dsa_read_key(bio._ptr(), callback) + return DSA(dsa, 1) + + +def pub_key_from_params(p, q, g, pub): + # type: (bytes, bytes, bytes, bytes) -> DSA_pub + """ + Factory function that instantiates a DSA_pub object using + the parameters and public key specified. + + :param p: value of p + :param q: value of q + :param g: value of g + :param pub: value of the public key + :return: instance of DSA_pub. + """ + dsa = m2.dsa_new() + m2.dsa_set_pqg(dsa, p, q, g) + m2.dsa_set_pub(dsa, pub) + return DSA_pub(dsa, 1) + + +def load_pub_key(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> DSA_pub + """ + Factory function that instantiates a DSA_pub object using + a DSA public key contained in PEM file. The PEM file + must contain the parameters in addition to the public key. + + :param file: Names the file (a path) that contains the PEM + representation of the DSA public key. + :param callback: A Python callback object that will be + invoked should the DSA public key be + passphrase-protected. + :return: instance of DSA_pub. + """ + with BIO.openfile(file) as bio: + ret = load_pub_key_bio(bio, callback) + + return ret + + +def load_pub_key_bio(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> DSA_pub + """ + Factory function that instantiates a DSA_pub object using + a DSA public key contained in PEM format. The PEM + must contain the parameters in addition to the public key. + + :param bio: Contains the PEM representation of the DSA + public key (with params). + :param callback: A Python callback object that will be + invoked should the DSA public key be + passphrase-protected. + :return: instance of DSA_pub. + """ + dsapub = m2.dsa_read_pub_key(bio._ptr(), callback) + return DSA_pub(dsapub, 1) diff --git a/src/M2Crypto/EC.py b/src/M2Crypto/EC.py new file mode 100644 index 0000000..522092a --- /dev/null +++ b/src/M2Crypto/EC.py @@ -0,0 +1,460 @@ +from __future__ import absolute_import + +""" +M2Crypto wrapper for OpenSSL ECDH/ECDSA API. + +@requires: OpenSSL 0.9.8 or newer + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. + +Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. +All rights reserved.""" + +from M2Crypto import BIO, Err, EVP, m2, util +from typing import AnyStr, Callable, Dict, Optional, Tuple, Union # noqa +from M2Crypto.EVP import PKey + +EC_Key = bytes + + +class ECError(Exception): + pass + + +m2.ec_init(ECError) + +# Curve identifier constants +NID_secp112r1 = m2.NID_secp112r1 # type: int +NID_secp112r2 = m2.NID_secp112r2 # type: int +NID_secp128r1 = m2.NID_secp128r1 # type: int +NID_secp128r2 = m2.NID_secp128r2 # type: int +NID_secp160k1 = m2.NID_secp160k1 # type: int +NID_secp160r1 = m2.NID_secp160r1 # type: int +NID_secp160r2 = m2.NID_secp160r2 # type: int +NID_secp192k1 = m2.NID_secp192k1 # type: int +NID_secp224k1 = m2.NID_secp224k1 # type: int +NID_secp224r1 = m2.NID_secp224r1 # type: int +NID_secp256k1 = m2.NID_secp256k1 # type: int +NID_secp384r1 = m2.NID_secp384r1 # type: int +NID_secp521r1 = m2.NID_secp521r1 # type: int +NID_sect113r1 = m2.NID_sect113r1 # type: int +NID_sect113r2 = m2.NID_sect113r2 # type: int +NID_sect131r1 = m2.NID_sect131r1 # type: int +NID_sect131r2 = m2.NID_sect131r2 # type: int +NID_sect163k1 = m2.NID_sect163k1 # type: int +NID_sect163r1 = m2.NID_sect163r1 # type: int +NID_sect163r2 = m2.NID_sect163r2 # type: int +NID_sect193r1 = m2.NID_sect193r1 # type: int +NID_sect193r2 = m2.NID_sect193r2 # type: int +# default for secg.org TLS test server +NID_sect233k1 = m2.NID_sect233k1 # type: int +NID_sect233r1 = m2.NID_sect233r1 # type: int +NID_sect239k1 = m2.NID_sect239k1 # type: int +NID_sect283k1 = m2.NID_sect283k1 # type: int +NID_sect283r1 = m2.NID_sect283r1 # type: int +NID_sect409k1 = m2.NID_sect409k1 # type: int +NID_sect409r1 = m2.NID_sect409r1 # type: int +NID_sect571k1 = m2.NID_sect571k1 # type: int +NID_sect571r1 = m2.NID_sect571r1 # type: int + +NID_prime192v1 = m2.NID_X9_62_prime192v1 # type: int +NID_prime192v2 = m2.NID_X9_62_prime192v2 # type: int +NID_prime192v3 = m2.NID_X9_62_prime192v3 # type: int +NID_prime239v1 = m2.NID_X9_62_prime239v1 # type: int +NID_prime239v2 = m2.NID_X9_62_prime239v2 # type: int +NID_prime239v3 = m2.NID_X9_62_prime239v3 # type: int +NID_prime256v1 = m2.NID_X9_62_prime256v1 # type: int +NID_c2pnb163v1 = m2.NID_X9_62_c2pnb163v1 # type: int +NID_c2pnb163v2 = m2.NID_X9_62_c2pnb163v2 # type: int +NID_c2pnb163v3 = m2.NID_X9_62_c2pnb163v3 # type: int +NID_c2pnb176v1 = m2.NID_X9_62_c2pnb176v1 # type: int +NID_c2tnb191v1 = m2.NID_X9_62_c2tnb191v1 # type: int +NID_c2tnb191v2 = m2.NID_X9_62_c2tnb191v2 # type: int +NID_c2tnb191v3 = m2.NID_X9_62_c2tnb191v3 # type: int +NID_c2pnb208w1 = m2.NID_X9_62_c2pnb208w1 # type: int +NID_c2tnb239v1 = m2.NID_X9_62_c2tnb239v1 # type: int +NID_c2tnb239v2 = m2.NID_X9_62_c2tnb239v2 # type: int +NID_c2tnb239v3 = m2.NID_X9_62_c2tnb239v3 # type: int +NID_c2pnb272w1 = m2.NID_X9_62_c2pnb272w1 # type: int +NID_c2pnb304w1 = m2.NID_X9_62_c2pnb304w1 # type: int +NID_c2tnb359v1 = m2.NID_X9_62_c2tnb359v1 # type: int +NID_c2pnb368w1 = m2.NID_X9_62_c2pnb368w1 # type: int +NID_c2tnb431r1 = m2.NID_X9_62_c2tnb431r1 # type: int + +# To preserve compatibility with older names +NID_X9_62_prime192v1 = NID_prime192v1 # type: int +NID_X9_62_prime192v2 = NID_prime192v2 # type: int +NID_X9_62_prime192v3 = NID_prime192v3 # type: int +NID_X9_62_prime239v1 = NID_prime239v1 # type: int +NID_X9_62_prime239v2 = NID_prime239v2 # type: int +NID_X9_62_prime239v3 = NID_prime239v3 # type: int +NID_X9_62_prime256v1 = NID_prime256v1 # type: int +NID_X9_62_c2pnb163v1 = NID_c2pnb163v1 # type: int +NID_X9_62_c2pnb163v2 = NID_c2pnb163v2 # type: int +NID_X9_62_c2pnb163v3 = NID_c2pnb163v3 # type: int +NID_X9_62_c2pnb176v1 = NID_c2pnb176v1 # type: int +NID_X9_62_c2tnb191v1 = NID_c2tnb191v1 # type: int +NID_X9_62_c2tnb191v2 = NID_c2tnb191v2 # type: int +NID_X9_62_c2tnb191v3 = NID_c2tnb191v3 # type: int +NID_X9_62_c2pnb208w1 = NID_c2pnb208w1 # type: int +NID_X9_62_c2tnb239v1 = NID_c2tnb239v1 # type: int +NID_X9_62_c2tnb239v2 = NID_c2tnb239v2 # type: int +NID_X9_62_c2tnb239v3 = NID_c2tnb239v3 # type: int +NID_X9_62_c2pnb272w1 = NID_c2pnb272w1 # type: int +NID_X9_62_c2pnb304w1 = NID_c2pnb304w1 # type: int +NID_X9_62_c2tnb359v1 = NID_c2tnb359v1 # type: int +NID_X9_62_c2pnb368w1 = NID_c2pnb368w1 # type: int +NID_X9_62_c2tnb431r1 = NID_c2tnb431r1 # type: int + +NID_wap_wsg_idm_ecid_wtls1 = m2.NID_wap_wsg_idm_ecid_wtls1 # type: int +NID_wap_wsg_idm_ecid_wtls3 = m2.NID_wap_wsg_idm_ecid_wtls3 # type: int +NID_wap_wsg_idm_ecid_wtls4 = m2.NID_wap_wsg_idm_ecid_wtls4 # type: int +NID_wap_wsg_idm_ecid_wtls5 = m2.NID_wap_wsg_idm_ecid_wtls5 # type: int +NID_wap_wsg_idm_ecid_wtls6 = m2.NID_wap_wsg_idm_ecid_wtls6 # type: int +NID_wap_wsg_idm_ecid_wtls7 = m2.NID_wap_wsg_idm_ecid_wtls7 # type: int +NID_wap_wsg_idm_ecid_wtls8 = m2.NID_wap_wsg_idm_ecid_wtls8 # type: int +NID_wap_wsg_idm_ecid_wtls9 = m2.NID_wap_wsg_idm_ecid_wtls9 # type: int +NID_wap_wsg_idm_ecid_wtls10 = m2.NID_wap_wsg_idm_ecid_wtls10 # type: int +NID_wap_wsg_idm_ecid_wtls11 = m2.NID_wap_wsg_idm_ecid_wtls11 # type: int +NID_wap_wsg_idm_ecid_wtls12 = m2.NID_wap_wsg_idm_ecid_wtls12 # type: int + +# The following two curves, according to OpenSSL, have a +# "Questionable extension field!" and are not supported by +# the OpenSSL inverse function. ECError: no inverse. +# As such they cannot be used for signing. They might, +# however, be usable for encryption but that has not +# been tested. Until thir usefulness can be established, +# they are not supported at this time. +# NID_ipsec3 = m2.NID_ipsec3 +# NID_ipsec4 = m2.NID_ipsec4 + + +class EC(object): + + """ + Object interface to a EC key pair. + """ + + m2_ec_key_free = m2.ec_key_free + + def __init__(self, ec, _pyfree=0): + # type: (EC, int) -> None + assert m2.ec_key_type_check(ec), "'ec' type error" + self.ec = ec + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_ec_key_free(self.ec) + + def __len__(self): + # type: () -> int + assert m2.ec_key_type_check(self.ec), "'ec' type error" + return m2.ec_key_keylen(self.ec) + + def gen_key(self): + # type: () -> int + """ + Generates the key pair from its parameters. Use:: + + keypair = EC.gen_params(curve) + keypair.gen_key() + + to create an EC key pair. + """ + assert m2.ec_key_type_check(self.ec), "'ec' type error" + m2.ec_key_gen_key(self.ec) + + def pub(self): + # type: () -> EC_pub + # Don't let python free + return EC_pub(self.ec, 0) + + def sign_dsa(self, digest): + # type: (bytes) -> Tuple[bytes, bytes] + """ + Sign the given digest using ECDSA. Returns a tuple (r,s), the two + ECDSA signature parameters. + """ + assert self._check_key_type(), "'ec' type error" + return m2.ecdsa_sign(self.ec, digest) + + def verify_dsa(self, digest, r, s): + # type: (bytes, bytes, bytes) -> int + """ + Verify the given digest using ECDSA. r and s are the ECDSA + signature parameters. + """ + assert self._check_key_type(), "'ec' type error" + return m2.ecdsa_verify(self.ec, digest, r, s) + + def sign_dsa_asn1(self, digest): + # type: (bytes) -> bytes + assert self._check_key_type(), "'ec' type error" + return m2.ecdsa_sign_asn1(self.ec, digest) + + def verify_dsa_asn1(self, digest, blob): + assert self._check_key_type(), "'ec' type error" + return m2.ecdsa_verify_asn1(self.ec, digest, blob) + + def compute_dh_key(self, pub_key): + # type: (EC) -> Optional[bytes] + """ + Compute the ECDH shared key of this key pair and the given public + key object. They must both use the same curve. Returns the + shared key in binary as a buffer object. No Key Derivation Function is + applied. + """ + assert self.check_key(), 'key is not initialised' + return m2.ecdh_compute_key(self.ec, pub_key.ec) + + def save_key_bio(self, bio, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (BIO.BIO, Optional[str], Callable) -> int + """ + Save the key pair to an M2Crypto.BIO.BIO object in PEM format. + + :param bio: M2Crypto.BIO.BIO object to save key to. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is 'aes_128_cbc'. If cipher is None, then + the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + if cipher is None: + return m2.ec_key_write_bio_no_cipher(self.ec, bio._ptr(), callback) + else: + ciph = getattr(m2, cipher, None) + if ciph is None: + raise ValueError('not such cipher %s' % cipher) + return m2.ec_key_write_bio(self.ec, bio._ptr(), ciph(), callback) + + def save_key(self, file, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (AnyStr, Optional[str], Callable) -> int + """ + Save the key pair to a file in PEM format. + + :param file: Name of filename to save key to. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is 'aes_128_cbc'. If cipher is None, then + the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + with BIO.openfile(file, 'wb') as bio: + return self.save_key_bio(bio, cipher, callback) + + def save_pub_key_bio(self, bio): + # type: (BIO.BIO) -> int + """ + Save the public key to an M2Crypto.BIO.BIO object in PEM format. + + :param bio: M2Crypto.BIO.BIO object to save key to. + """ + return m2.ec_key_write_pubkey(self.ec, bio._ptr()) + + def save_pub_key(self, file): + # type: (AnyStr) -> int + """ + Save the public key to a filename in PEM format. + + :param file: Name of filename to save key to. + """ + with BIO.openfile(file, 'wb') as bio: + return m2.ec_key_write_pubkey(self.ec, bio._ptr()) + + def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): + """ + Returns the key(pair) as a string in PEM format. + If no password is passed and the cipher is set + it exits with error + """ + with BIO.MemoryBuffer() as bio: + self.save_key_bio(bio, cipher, callback) + return bio.read() + + def _check_key_type(self): + # type: () -> int + return m2.ec_key_type_check(self.ec) + + def check_key(self): + # type: () -> int + assert m2.ec_key_type_check(self.ec), "'ec' type error" + return m2.ec_key_check_key(self.ec) + + +class EC_pub(EC): + + """ + Object interface to an EC public key. + ((don't like this implementation inheritance)) + """ + def __init__(self, ec, _pyfree=0): + # type: (EC, int) -> None + EC.__init__(self, ec, _pyfree) + self.der = None # type: Optional[bytes] + + def get_der(self): + # type: () -> bytes + """ + Returns the public key in DER format as a buffer object. + """ + assert self.check_key(), 'key is not initialised' + if self.der is None: + self.der = m2.ec_key_get_public_der(self.ec) + return self.der + + def get_key(self): + # type: () -> bytes + """ + Returns the public key as a byte string. + """ + assert self.check_key(), 'key is not initialised' + return m2.ec_key_get_public_key(self.ec) + + save_key = EC.save_pub_key + + save_key_bio = EC.save_pub_key_bio + + +def gen_params(curve): + # type: (int) -> EC + """ + Factory function that generates EC parameters and + instantiates a EC object from the output. + + :param curve: This is the OpenSSL nid of the curve to use. + """ + assert curve in [x['NID'] for x in m2.ec_get_builtin_curves()], \ + 'Elliptic curve %s is not available on this system.' % \ + m2.obj_nid2sn(curve) + return EC(m2.ec_key_new_by_curve_name(curve), 1) + + +def load_key(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> EC + """ + Factory function that instantiates a EC object. + + :param file: Names the filename that contains the PEM representation + of the EC key pair. + + :param callback: Python callback object that will be invoked + if the EC key pair is passphrase-protected. + """ + with BIO.openfile(file) as bio: + return load_key_bio(bio, callback) + + +def load_key_string(string, callback=util.passphrase_callback): + # type: (str, Callable) -> EC + """ + Load an EC key pair from a string. + + :param string: String containing EC key pair in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to unlock the + key. The default is util.passphrase_callback. + + :return: M2Crypto.EC.EC object. + """ + with BIO.MemoryBuffer(string) as bio: + return load_key_bio(bio, callback) + + +def load_key_bio(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> EC + """ + Factory function that instantiates a EC object. + + :param bio: M2Crypto.BIO object that contains the PEM + representation of the EC key pair. + + :param callback: Python callback object that will be invoked + if the EC key pair is passphrase-protected. + """ + return EC(m2.ec_key_read_bio(bio._ptr(), callback), 1) + + +def load_pub_key(file): + # type: (AnyStr) -> EC_pub + """ + Load an EC public key from filename. + + :param file: Name of filename containing EC public key in PEM + format. + + :return: M2Crypto.EC.EC_pub object. + """ + with BIO.openfile(file) as bio: + return load_pub_key_bio(bio) + + +def load_key_string_pubkey(string, callback=util.passphrase_callback): + # type: (str, Callable) -> PKey + """ + Load an M2Crypto.EC.PKey from a public key as a string. + + :param string: String containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EC.PKey object. + """ + with BIO.MemoryBuffer(string) as bio: + return EVP.load_key_bio_pubkey(bio, callback) + + +def load_pub_key_bio(bio): + # type: (BIO.BIO) -> EC_pub + """ + Load an EC public key from an M2Crypto.BIO.BIO object. + + :param bio: M2Crypto.BIO.BIO object containing EC public key in PEM + format. + + :return: M2Crypto.EC.EC_pub object. + """ + ec = m2.ec_key_read_pubkey(bio._ptr()) + if ec is None: + ec_error() + return EC_pub(ec, 1) + + +def ec_error(): + # type: () -> ECError + raise ECError(Err.get_error_message()) + + +def pub_key_from_der(der): + # type: (bytes) -> EC_pub + """ + Create EC_pub from DER. + """ + return EC_pub(m2.ec_key_from_pubkey_der(der), 1) + + +def pub_key_from_params(curve, bytes): + # type: (bytes, bytes) -> EC_pub + """ + Create EC_pub from curve name and octet string. + """ + return EC_pub(m2.ec_key_from_pubkey_params(curve, bytes), 1) + + +def get_builtin_curves(): + # type: () -> Tuple[Dict[str, Union[int, str]]] + return m2.ec_get_builtin_curves() diff --git a/src/M2Crypto/EVP.py b/src/M2Crypto/EVP.py new file mode 100644 index 0000000..c48b670 --- /dev/null +++ b/src/M2Crypto/EVP.py @@ -0,0 +1,582 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL EVP API. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + +Portions Copyright (c) 2004-2007 Open Source Applications Foundation. +Author: Heikki Toivonen +""" + +import logging +from M2Crypto import BIO, Err, RSA, m2, util +from typing import AnyStr, Optional, Callable # noqa + +log = logging.getLogger('EVP') + + +class EVPError(ValueError): + pass + + +m2.evp_init(EVPError) + + +def pbkdf2(password, salt, iter, keylen): + # type: (bytes, bytes, int, int) -> bytes + """ + Derive a key from password using PBKDF2 algorithm specified in RFC 2898. + + :param password: Derive the key from this password. + :param salt: Salt. + :param iter: Number of iterations to perform. + :param keylen: Length of key to produce. + :return: Key. + """ + return m2.pkcs5_pbkdf2_hmac_sha1(password, salt, iter, keylen) + + +class MessageDigest(object): + """ + Message Digest + """ + m2_md_ctx_free = m2.md_ctx_free + + def __init__(self, algo): + # type: (str) -> None + md = getattr(m2, algo, None) # type: Optional[Callable] + if md is None: + # if the digest algorithm isn't found as an attribute of the m2 + # module, try to look up the digest using get_digestbyname() + self.md = m2.get_digestbyname(algo) + else: + self.md = md() + self.ctx = m2.md_ctx_new() + m2.digest_init(self.ctx, self.md) + + def __del__(self): + # type: () -> None + if getattr(self, 'ctx', None): + self.m2_md_ctx_free(self.ctx) + + def update(self, data): + # type: (bytes) -> int + """ + Add data to be digested. + + :return: -1 for Python error, 1 for success, 0 for OpenSSL failure. + """ + return m2.digest_update(self.ctx, data) + + def final(self): + return m2.digest_final(self.ctx) + + # Deprecated. + digest = final + + +class HMAC(object): + + m2_hmac_ctx_free = m2.hmac_ctx_free + + def __init__(self, key, algo='sha1'): + # type: (bytes, str) -> None + md = getattr(m2, algo, None) + if md is None: + raise ValueError('unknown algorithm', algo) + self.md = md() + self.ctx = m2.hmac_ctx_new() + m2.hmac_init(self.ctx, key, self.md) + + def __del__(self): + # type: () -> None + if getattr(self, 'ctx', None): + self.m2_hmac_ctx_free(self.ctx) + + def reset(self, key): + # type: (bytes) -> None + m2.hmac_init(self.ctx, key, self.md) + + def update(self, data): + # type: (bytes) -> None + m2.hmac_update(self.ctx, data) + + def final(self): + # type: () -> bytes + return m2.hmac_final(self.ctx) + + digest = final + + +def hmac(key, data, algo='sha1'): + # type: (bytes, bytes, str) -> bytes + md = getattr(m2, algo, None) + if md is None: + raise ValueError('unknown algorithm', algo) + return m2.hmac(key, data, md()) + + +class Cipher(object): + + m2_cipher_ctx_free = m2.cipher_ctx_free + + def __init__(self, alg, key, iv, op, key_as_bytes=0, d='md5', + salt=b'12345678', i=1, padding=1): + # type: (str, bytes, bytes, object, int, str, bytes, int, int) -> None + cipher = getattr(m2, alg, None) + if cipher is None: + raise ValueError('unknown cipher', alg) + self.cipher = cipher() + if key_as_bytes: + kmd = getattr(m2, d, None) + if kmd is None: + raise ValueError('unknown message digest', d) + key = m2.bytes_to_key(self.cipher, kmd(), key, salt, iv, i) + self.ctx = m2.cipher_ctx_new() + m2.cipher_init(self.ctx, self.cipher, key, iv, op) + self.set_padding(padding) + del key + + def __del__(self): + # type: () -> None + if getattr(self, 'ctx', None): + self.m2_cipher_ctx_free(self.ctx) + + def update(self, data): + # type: (bytes) -> bytes + return m2.cipher_update(self.ctx, data) + + def final(self): + # type: () -> bytes + return m2.cipher_final(self.ctx) + + def set_padding(self, padding=1): + # type: (int) -> int + """ + Actually always return 1 + """ + return m2.cipher_set_padding(self.ctx, padding) + + +class PKey(object): + """ + Public Key + """ + + m2_pkey_free = m2.pkey_free + m2_md_ctx_free = m2.md_ctx_free + + def __init__(self, pkey=None, _pyfree=0, md='sha1'): + # type: (Optional[bytes], int, str) -> None + if pkey is not None: + self.pkey = pkey # type: bytes + self._pyfree = _pyfree + else: + self.pkey = m2.pkey_new() + self._pyfree = 1 + self._set_context(md) + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_pkey_free(self.pkey) + if getattr(self, 'ctx', None): + self.m2_md_ctx_free(self.ctx) + + def _ptr(self): + return self.pkey + + def _set_context(self, md): + # type: (str) -> None + if not md: + self.md = None + else: + mda = getattr(m2, md, None) # type: Optional[Callable] + if mda is None: + raise ValueError('unknown message digest', md) + self.md = mda() + self.ctx = m2.md_ctx_new() ## type: Context + + def reset_context(self, md='sha1'): + # type: (str) -> None + """ + Reset internal message digest context. + + :param md: The message digest algorithm. + """ + self._set_context(md) + + def sign_init(self): + # type: () -> None + """ + Initialise signing operation with self. + """ + m2.sign_init(self.ctx, self.md) + + def sign_update(self, data): + # type: (bytes) -> None + """ + Feed data to signing operation. + + :param data: Data to be signed. + """ + m2.sign_update(self.ctx, data) + + def sign_final(self): + # type: () -> bytes + """ + Return signature. + + :return: The signature. + """ + return m2.sign_final(self.ctx, self.pkey) + + # Deprecated + update = sign_update + final = sign_final + + def verify_init(self): + # type: () -> None + """ + Initialise signature verification operation with self. + """ + m2.verify_init(self.ctx, self.md) + + def verify_update(self, data): + # type: (bytes) -> int + """ + Feed data to verification operation. + + :param data: Data to be verified. + :return: -1 on Python error, 1 for success, 0 for OpenSSL error + """ + return m2.verify_update(self.ctx, data) + + def verify_final(self, sign): + # type: (bytes) -> int + """ + Return result of verification. + + :param sign: Signature to use for verification + :return: Result of verification: 1 for success, 0 for failure, -1 on + other error. + """ + return m2.verify_final(self.ctx, sign, self.pkey) + + def digest_sign_init(self): + # type: () -> None + """ + Initialise digest signing operation with self. + """ + if self.md is None: + m2.digest_sign_init(self.ctx, self.pkey) + else: + m2.digest_sign_init(self.ctx, None, self.md, None, self.pkey) + + def digest_sign_update(self, data): + # type: (bytes) -> None + """ + Feed data to digest signing operation. + + :param data: Data to be signed. + """ + m2.digest_sign_update(self.ctx, data) + + def digest_sign_final(self): + # type: () -> bytes + """ + Return signature. + + :return: The signature. + """ + return m2.digest_sign_final(self.ctx) + + def digest_sign(self, data): + # type: () -> bytes + """ + Return signature. + + :return: The signature. + """ + + if m2.OPENSSL_VERSION_NUMBER < 0x10101000: + raise NotImplemented('This method requires OpenSSL version ' + + '1.1.1 or greater.') + + return m2.digest_sign(self.ctx, data) + + def digest_verify_init(self): + # type: () -> None + """ + Initialise verification operation with self. + """ + if self.md is None: + m2.digest_verify_init(self.ctx, self.pkey) + else: + m2.digest_verify_init(self.ctx, None, self.md, None, self.pkey) + + def digest_verify_update(self, data): + # type: (bytes) -> int + """ + Feed data to verification operation. + + :param data: Data to be verified. + :return: -1 on Python error, 1 for success, 0 for OpenSSL error + """ + return m2.digest_verify_update(self.ctx, data) + + def digest_verify_final(self, sign): + # type: (bytes) -> int + """ + Feed data to digest verification operation. + + :param sign: Signature to use for verification + :return: Result of verification: 1 for success, 0 for failure, -1 on + other error. + """ + return m2.digest_verify_final(self.ctx, sign) + + def digest_verify(self, sign, data): + # type: (bytes) -> int + """ + Return result of verification. + + :param sign: Signature to use for verification + :param data: Data to be verified. + :return: Result of verification: 1 for success, 0 for failure, -1 on + other error. + """ + + if m2.OPENSSL_VERSION_NUMBER < 0x10101000: + raise NotImplemented('This method requires OpenSSL version ' + + '1.1.1 or greater.') + + return m2.digest_verify(self.ctx, sign, data) + + def assign_rsa(self, rsa, capture=1): + # type: (RSA.RSA, int) -> int + """ + Assign the RSA key pair to self. + + :param rsa: M2Crypto.RSA.RSA object to be assigned to self. + + :param capture: If true (default), this PKey object will own the RSA + object, meaning that once the PKey object gets + deleted it is no longer safe to use the RSA object. + + :return: Return 1 for success and 0 for failure. + """ + if capture: + ret = m2.pkey_assign_rsa(self.pkey, rsa.rsa) + if ret: + rsa._pyfree = 0 + else: + ret = m2.pkey_set1_rsa(self.pkey, rsa.rsa) + return ret + + def get_rsa(self): + # type: () -> RSA.RSA_pub + """ + Return the underlying RSA key if that is what the EVP + instance is holding. + """ + rsa_ptr = m2.pkey_get1_rsa(self.pkey) + + rsa = RSA.RSA_pub(rsa_ptr, 1) + return rsa + + def save_key(self, file, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (AnyStr, Optional[str], Callable) -> int + """ + Save the key pair to a file in PEM format. + + :param file: Name of file to save key to. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is 'aes_128_cbc'. If cipher is None, then + the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + with BIO.openfile(file, 'wb') as bio: + return self.save_key_bio(bio, cipher, callback) + + def save_key_bio(self, bio, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (BIO.BIO, Optional[str], Callable) -> int + """ + Save the key pair to the M2Crypto.BIO object 'bio' in PEM format. + + :param bio: M2Crypto.BIO object to save key to. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is 'aes_128_cbc'. If cipher is None, then + the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + if cipher is None: + return m2.pkey_write_pem_no_cipher(self.pkey, bio._ptr(), callback) + else: + proto = getattr(m2, cipher, None) + if proto is None: + raise ValueError('no such cipher %s' % cipher) + return m2.pkey_write_pem(self.pkey, bio._ptr(), proto(), callback) + + def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): + # type: (Optional[str], Callable) -> bytes + """ + Return key in PEM format in a string. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is ``'aes_128_cbc'``. If cipher is None, + then the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + bio = BIO.MemoryBuffer() + self.save_key_bio(bio, cipher, callback) + return bio.read_all() + + def as_der(self): + # type: () -> bytes + """ + Return key in DER format in a string + """ + buf = m2.pkey_as_der(self.pkey) + bio = BIO.MemoryBuffer(buf) + return bio.read_all() + + def size(self): + # type: () -> int + """ + Return the size of the key in bytes. + """ + return m2.pkey_size(self.pkey) + + def get_modulus(self): + # type: () -> Optional[bytes] + """ + Return the modulus in hex format. + """ + return m2.pkey_get_modulus(self.pkey) + + +def load_key(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> PKey + """ + Load an M2Crypto.EVP.PKey from file. + + :param file: Name of file containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EVP.PKey object. + """ + with BIO.openfile(file, 'r') as bio: + cptr = m2.pkey_read_pem(bio.bio, callback) + + return PKey(cptr, 1) + + +def load_key_pubkey(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> PKey + """ + Load an M2Crypto.EVP.PKey from a public key as a file. + + :param file: Name of file containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EVP.PKey object. + """ + + with BIO.openfile(file, 'r') as bio: + cptr = m2.pkey_read_pem_pubkey(bio._ptr(), callback) + if cptr is None: + raise EVPError(Err.get_error()) + return PKey(cptr, 1) + + +def load_key_bio(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> PKey + """ + Load an M2Crypto.EVP.PKey from an M2Crypto.BIO object. + + :param bio: M2Crypto.BIO object containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EVP.PKey object. + """ + cptr = m2.pkey_read_pem(bio._ptr(), callback) + return PKey(cptr, 1) + + +def load_key_bio_pubkey(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> PKey + """ + Load an M2Crypto.EVP.PKey from a public key as a M2Crypto.BIO object. + + :param bio: M2Crypto.BIO object containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EVP.PKey object. + """ + cptr = m2.pkey_read_pem_pubkey(bio._ptr(), callback) + if cptr is None: + raise EVPError(Err.get_error()) + return PKey(cptr, 1) + + +def load_key_string(string, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> PKey + """ + Load an M2Crypto.EVP.PKey from a string. + + :param string: String containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EVP.PKey object. + """ + bio = BIO.MemoryBuffer(string) + return load_key_bio(bio, callback) + + +def load_key_string_pubkey(string, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> PKey + """ + Load an M2Crypto.EVP.PKey from a public key as a string. + + :param string: String containing the key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect the + key. + + :return: M2Crypto.EVP.PKey object. + """ + bio = BIO.MemoryBuffer(string) + return load_key_bio_pubkey(bio, callback) diff --git a/src/M2Crypto/Engine.py b/src/M2Crypto/Engine.py new file mode 100644 index 0000000..46b76a4 --- /dev/null +++ b/src/M2Crypto/Engine.py @@ -0,0 +1,150 @@ +# vim: sts=4 sw=4 et +from __future__ import absolute_import + +""" +M2Crypto wrapper for OpenSSL ENGINE API. + +Pavel Shramov +IMEC MSU +""" + +from M2Crypto import EVP, Err, X509, m2, six +from typing import AnyStr, Callable, Optional # noqa + + +class EngineError(Exception): + pass + + +m2.engine_init_error(EngineError) + + +class Engine(object): + """Wrapper for ENGINE object.""" + + m2_engine_free = m2.engine_free + + def __init__(self, id=None, _ptr=None, _pyfree=1): + # type: (Optional[bytes], Optional[bytes], int) -> None + """Create new Engine from ENGINE pointer or obtain by id""" + if not _ptr and not id: + raise ValueError("No engine id specified") + self._ptr = _ptr + if not self._ptr: + self._ptr = m2.engine_by_id(id) + if not self._ptr: + raise ValueError("Unknown engine: %s" % id) + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_engine_free(self._ptr) + + def init(self): + # type: () -> int + """Obtain a functional reference to the engine. + + :return: 0 on error, non-zero on success.""" + return m2.engine_init(self._ptr) + + def finish(self): + # type: () -> int + """Release a functional and structural reference to the engine.""" + return m2.engine_finish(self._ptr) + + def ctrl_cmd_string(self, cmd, arg, optional=0): + # type: (AnyStr, Optional[AnyStr], int) -> None + """Call ENGINE_ctrl_cmd_string""" + cmd = six.ensure_str(cmd) + if arg is not None: + arg = six.ensure_str(arg) + if not m2.engine_ctrl_cmd_string(self._ptr, cmd, arg, optional): + raise EngineError(Err.get_error()) + + def get_name(self): + # type: () -> bytes + """Return engine name""" + return m2.engine_get_name(self._ptr) + + def get_id(self): + # type: () -> bytes + """Return engine id""" + return m2.engine_get_id(self._ptr) + + def set_default(self, methods=m2.ENGINE_METHOD_ALL): + # type: (int) -> int + """ + Use this engine as default for methods specified in argument + + :param methods: Possible values are bitwise OR of m2.ENGINE_METHOD_* + """ + return m2.engine_set_default(self._ptr, methods) + + def _engine_load_key(self, func, name, pin=None): + # type: (Callable, bytes, Optional[bytes]) -> EVP.PKey + """Helper function for loading keys""" + ui = m2.ui_openssl() + cbd = m2.engine_pkcs11_data_new(pin) + try: + kptr = func(self._ptr, name, ui, cbd) + if not kptr: + raise EngineError(Err.get_error()) + key = EVP.PKey(kptr, _pyfree=1) + finally: + m2.engine_pkcs11_data_free(cbd) + return key + + def load_private_key(self, name, pin=None): + # type: (bytes, Optional[bytes]) -> X509.X509 + """Load private key with engine methods (e.g from smartcard). + If pin is not set it will be asked + """ + return self._engine_load_key(m2.engine_load_private_key, name, pin) + + def load_public_key(self, name, pin=None): + # type: (bytes, Optional[bytes]) -> EVP.PKey + """Load public key with engine methods (e.g from smartcard).""" + return self._engine_load_key(m2.engine_load_public_key, name, pin) + + def load_certificate(self, name): + # type: (bytes) -> X509.X509 + """Load certificate from engine (e.g from smartcard). + NOTE: This function may be not implemented by engine!""" + cptr = m2.engine_load_certificate(self._ptr, name) + if not cptr: + raise EngineError("Certificate or card not found") + return X509.X509(cptr, _pyfree=1) + + +def load_dynamic_engine(id, sopath): + # type: (bytes, AnyStr) -> Engine + """Load and return dymanic engine from sopath and assign id to it""" + if isinstance(sopath, six.text_type): + sopath = sopath.encode('utf8') + m2.engine_load_dynamic() + e = Engine('dynamic') + e.ctrl_cmd_string('SO_PATH', sopath) + e.ctrl_cmd_string('ID', id) + e.ctrl_cmd_string('LIST_ADD', '1') + e.ctrl_cmd_string('LOAD', None) + return e + + +def load_dynamic(): + # type: () -> None + """Load dynamic engine""" + m2.engine_load_dynamic() + + +def load_openssl(): + # type: () -> None + """Load openssl engine""" + m2.engine_load_openssl() + + +def cleanup(): + # type: () -> None + """If you load any engines, you need to clean up after your application + is finished with the engines.""" + m2.engine_cleanup() diff --git a/src/M2Crypto/Err.py b/src/M2Crypto/Err.py new file mode 100644 index 0000000..dd55991 --- /dev/null +++ b/src/M2Crypto/Err.py @@ -0,0 +1,76 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL Error API. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +from M2Crypto import BIO, m2, util, six # noqa +from typing import Optional # noqa + + +def get_error(): + # type: () -> Optional[str] + err = BIO.MemoryBuffer() + m2.err_print_errors(err.bio_ptr()) + err_msg = err.read() + if err_msg: + return six.ensure_text(err_msg) + + +def get_error_code(): + # type: () -> int + return m2.err_get_error() + + +def peek_error_code(): + # type: () -> int + return m2.err_peek_error() + + +def get_error_lib(err): + # type: (Optional[int]) -> str + err_str = m2.err_lib_error_string(err) + return six.ensure_text(err_str) if err_str else '' + + +def get_error_func(err): + # type: (Optional[int]) -> str + err_str = m2.err_func_error_string(err) + return six.ensure_text(err_str) if err_str else '' + + +def get_error_reason(err): + # type: (Optional[int]) -> str + err_str = m2.err_reason_error_string(err) + return six.ensure_text(err_str) if err_str else '' + + +def get_error_message(): + # type: () -> str + return six.ensure_text(get_error_reason(get_error_code())) + + +def get_x509_verify_error(err): + # type: (Optional[int]) -> str + err_str = m2.x509_get_verify_error(err) + return six.ensure_text(err_str) if err_str else '' + + +class SSLError(Exception): + def __init__(self, err, client_addr): + # type: (int, util.AddrType) -> None + self.err = err + self.client_addr = client_addr + + def __str__(self): + # type: () -> str + if not isinstance(self.client_addr, six.text_type): + s = self.client_addr.decode('utf8') + else: + s = self.client_addr + return "%s: %s: %s" % (get_error_func(self.err), s, + get_error_reason(self.err)) + + +class M2CryptoError(Exception): + pass diff --git a/src/M2Crypto/RC4.py b/src/M2Crypto/RC4.py new file mode 100644 index 0000000..26e1079 --- /dev/null +++ b/src/M2Crypto/RC4.py @@ -0,0 +1,36 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL RC4 API. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +from M2Crypto.m2 import rc4_free, rc4_new, rc4_set_key, rc4_update + + +class RC4(object): + """Object interface to the stream cipher RC4.""" + + rc4_free = rc4_free + + def __init__(self, key=None): + # type: (bytes) -> None + self.cipher = rc4_new() + if key: + rc4_set_key(self.cipher, key) + + def __del__(self): + # type: () -> None + if getattr(self, 'cipher', None): + self.rc4_free(self.cipher) + + def set_key(self, key): + # type: (bytes) -> None + rc4_set_key(self.cipher, key) + + def update(self, data): + # type: (bytes) -> bytes + return rc4_update(self.cipher, data) + + def final(self): + # type: () -> str + return '' diff --git a/src/M2Crypto/RSA.py b/src/M2Crypto/RSA.py new file mode 100644 index 0000000..d6e5c64 --- /dev/null +++ b/src/M2Crypto/RSA.py @@ -0,0 +1,466 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL RSA API. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" + +import sys + +from M2Crypto import BIO, Err, m2, util +from typing import Any, AnyStr, Callable, IO, Optional, Tuple # noqa + + +class RSAError(Exception): + pass + + +m2.rsa_init(RSAError) + +no_padding = m2.no_padding +pkcs1_padding = m2.pkcs1_padding +sslv23_padding = m2.sslv23_padding +pkcs1_oaep_padding = m2.pkcs1_oaep_padding + + +class RSA(object): + """ + RSA Key Pair. + """ + + m2_rsa_free = m2.rsa_free + + def __init__(self, rsa, _pyfree=0): + # type: (bytes, int) -> None + """ + :param rsa: binary representation of OpenSSL RSA type + """ + assert m2.rsa_type_check(rsa), "'rsa' type error" + self.rsa = rsa + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_rsa_free(self.rsa) + + def __len__(self): + # type: () -> int + return int(m2.rsa_size(self.rsa) << 3) + + def __getattr__(self, name): + # type: (str) -> bytes + if name == 'e': + return m2.rsa_get_e(self.rsa) + elif name == 'n': + return m2.rsa_get_n(self.rsa) + else: + raise AttributeError + + def pub(self): + # type: () -> Tuple[bytes, bytes] + assert self.check_key(), 'key is not initialised' + return m2.rsa_get_e(self.rsa), m2.rsa_get_n(self.rsa) + + def public_encrypt(self, data, padding): + # type: (bytes, int) -> bytes + assert self.check_key(), 'key is not initialised' + return m2.rsa_public_encrypt(self.rsa, data, padding) + + def public_decrypt(self, data, padding): + # type: (bytes, int) -> bytes + assert self.check_key(), 'key is not initialised' + return m2.rsa_public_decrypt(self.rsa, data, padding) + + def private_encrypt(self, data, padding): + # type: (bytes, int) -> bytes + assert self.check_key(), 'key is not initialised' + return m2.rsa_private_encrypt(self.rsa, data, padding) + + def private_decrypt(self, data, padding): + # type: (bytes, int) -> bytes + assert self.check_key(), 'key is not initialised' + return m2.rsa_private_decrypt(self.rsa, data, padding) + + def save_key_bio(self, bio, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (BIO.BIO, Optional[str], Callable) -> int + """ + Save the key pair to an M2Crypto.BIO.BIO object in PEM format. + + :param bio: M2Crypto.BIO.BIO object to save key to. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is 'aes_128_cbc'. If cipher is None, then + the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + if cipher is None: + return m2.rsa_write_key_no_cipher(self.rsa, bio._ptr(), callback) + else: + ciph = getattr(m2, cipher, None) + if ciph is None: + raise RSAError('not such cipher %s' % cipher) + else: + ciph = ciph() + return m2.rsa_write_key(self.rsa, bio._ptr(), ciph, callback) + + def save_key(self, file, cipher='aes_128_cbc', + callback=util.passphrase_callback): + # type: (AnyStr, Optional[str], Callable) -> int + """ + Save the key pair to a file in PEM format. + + :param file: Name of file to save key to. + + :param cipher: Symmetric cipher to protect the key. The default + cipher is 'aes_128_cbc'. If cipher is None, then + the key is saved in the clear. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to protect + the key. The default is + util.passphrase_callback. + """ + with BIO.openfile(file, 'wb') as bio: + return self.save_key_bio(bio, cipher, callback) + + save_pem = save_key + + def as_pem(self, cipher='aes_128_cbc', callback=util.passphrase_callback): + # type: (Optional[str], Callable) -> bytes + """ + Returns the key(pair) as a string in PEM format. + """ + bio = BIO.MemoryBuffer() + self.save_key_bio(bio, cipher, callback) + return bio.read() + + def save_key_der_bio(self, bio): + # type: (BIO.BIO) -> int + """ + Save the key pair to an M2Crypto.BIO.BIO object in DER format. + + :param bio: M2Crypto.BIO.BIO object to save key to. + """ + return m2.rsa_write_key_der(self.rsa, bio._ptr()) + + def save_key_der(self, file): + # type: (AnyStr) -> int + """ + Save the key pair to a file in DER format. + + :param file: Filename to save key to + """ + with BIO.openfile(file, 'wb') as bio: + return self.save_key_der_bio(bio) + + def save_pub_key_bio(self, bio): + # type: (BIO.BIO) -> int + """ + Save the public key to an M2Crypto.BIO.BIO object in PEM format. + + :param bio: M2Crypto.BIO.BIO object to save key to. + """ + return m2.rsa_write_pub_key(self.rsa, bio._ptr()) + + def save_pub_key(self, file): + # type: (AnyStr) -> int + """ + Save the public key to a file in PEM format. + + :param file: Name of file to save key to. + """ + with BIO.openfile(file, 'wb') as bio: + return m2.rsa_write_pub_key(self.rsa, bio._ptr()) + + def check_key(self): + # type: () -> int + """ + Validate RSA keys. + + It checks that p and q are in fact prime, and that n = p*q. + + :return: returns 1 if rsa is a valid RSA key, and 0 otherwise. + -1 is returned if an error occurs while checking the key. + If the key is invalid or an error occurred, the reason + code can be obtained using ERR_get_error(3). + """ + return m2.rsa_check_key(self.rsa) + + def sign_rsassa_pss(self, digest, algo='sha1', salt_length=20): + # type: (bytes, str, int) -> bytes + """ + Signs a digest with the private key using RSASSA-PSS + + :param digest: A digest created by using the digest method + + :param salt_length: The length of the salt to use + + :param algo: The hash algorithm to use + Legal values like 'sha1','sha224', 'sha256', + 'ripemd160', and 'md5'. + + :return: a string which is the signature + """ + hash = getattr(m2, algo, None) + + if hash is None: + raise RSAError('not such hash algorithm %s' % algo) + + signature = m2.rsa_padding_add_pkcs1_pss(self.rsa, digest, hash(), salt_length) + + return self.private_encrypt(signature, m2.no_padding) + + def verify_rsassa_pss(self, data, signature, algo='sha1', salt_length=20): + # type: (bytes, bytes, str, int) -> int + """ + Verifies the signature RSASSA-PSS + + :param data: Data that has been signed + + :param signature: The signature signed with RSASSA-PSS + + :param salt_length: The length of the salt that was used + + :param algo: The hash algorithm to use + Legal values are for example 'sha1','sha224', + 'sha256', 'ripemd160', and 'md5'. + + :return: 1 or 0, depending on whether the signature was + verified or not. + """ + hash = getattr(m2, algo, None) + + if hash is None: + raise RSAError('not such hash algorithm %s' % algo) + + plain_signature = self.public_decrypt(signature, m2.no_padding) + + return m2.rsa_verify_pkcs1_pss(self.rsa, data, plain_signature, hash(), salt_length) + + def sign(self, digest, algo='sha1'): + # type: (bytes, str) -> bytes + """ + Signs a digest with the private key + + :param digest: A digest created by using the digest method + + :param algo: The method that created the digest. + Legal values like 'sha1','sha224', 'sha256', + 'ripemd160', and 'md5'. + + :return: a string which is the signature + """ + digest_type = getattr(m2, 'NID_' + algo, None) + if digest_type is None: + raise ValueError('unknown algorithm', algo) + + return m2.rsa_sign(self.rsa, digest, digest_type) + + def verify(self, data, signature, algo='sha1'): + # type: (bytes, bytes, str) -> int + """ + Verifies the signature with the public key + + :param data: Data that has been signed + + :param signature: The signature signed with the private key + + :param algo: The method use to create digest from the data + before it was signed. Legal values like + 'sha1','sha224', 'sha256', 'ripemd160', and 'md5'. + + :return: 1 or 0, depending on whether the signature was + verified or not. + """ + digest_type = getattr(m2, 'NID_' + algo, None) + if digest_type is None: + raise ValueError('unknown algorithm', algo) + + return m2.rsa_verify(self.rsa, data, signature, digest_type) + + +class RSA_pub(RSA): + + """ + Object interface to an RSA public key. + """ + + def __setattr__(self, name, value): + # type: (str, bytes) -> None + if name in ['e', 'n']: + raise RSAError('use factory function new_pub_key() to set (e, n)') + else: + self.__dict__[name] = value + + def private_encrypt(self, *argv): + # type: (*Any) -> None + raise RSAError('RSA_pub object has no private key') + + def private_decrypt(self, *argv): + # type: (*Any) -> None + raise RSAError('RSA_pub object has no private key') + + def save_key(self, file, *args, **kw): + # type: (AnyStr, *Any, **Any) -> int + """ + Save public key to file. + """ + return self.save_pub_key(file) + + def save_key_bio(self, bio, *args, **kw): + # type: (BIO.BIO, *Any, **Any) -> int + """ + Save public key to BIO. + """ + return self.save_pub_key_bio(bio) + + # save_key_der + + # save_key_der_bio + + def check_key(self): + # type: () -> int + return m2.rsa_check_pub_key(self.rsa) + + +def rsa_error(): + # type: () -> None + raise RSAError(Err.get_error_message()) + + +def keygen_callback(p, n, out=sys.stdout): + # type: (int, Any, IO[str]) -> None + """ + Default callback for gen_key(). + """ + ch = ['.', '+', '*', '\n'] + out.write(ch[p]) + out.flush() + + +def gen_key(bits, e, callback=keygen_callback): + # type: (int, int, Callable) -> RSA + """ + Generate an RSA key pair. + + :param bits: Key length, in bits. + + :param e: The RSA public exponent. + + :param callback: A Python callable object that is invoked + during key generation; its usual purpose is to + provide visual feedback. The default callback is + keygen_callback. + + :return: M2Crypto.RSA.RSA object. + """ + return RSA(m2.rsa_generate_key(bits, e, callback), 1) + + +def load_key(file, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> RSA + """ + Load an RSA key pair from file. + + :param file: Name of file containing RSA public key in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to unlock the + key. The default is util.passphrase_callback. + + :return: M2Crypto.RSA.RSA object. + """ + with BIO.openfile(file) as bio: + return load_key_bio(bio, callback) + + +def load_key_bio(bio, callback=util.passphrase_callback): + # type: (BIO.BIO, Callable) -> RSA + """ + Load an RSA key pair from an M2Crypto.BIO.BIO object. + + :param bio: M2Crypto.BIO.BIO object containing RSA key pair in PEM + format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to unlock the + key. The default is util.passphrase_callback. + + :return: M2Crypto.RSA.RSA object. + """ + rsa = m2.rsa_read_key(bio._ptr(), callback) + if rsa is None: + rsa_error() + return RSA(rsa, 1) + + +def load_key_string(string, callback=util.passphrase_callback): + # type: (AnyStr, Callable) -> RSA + """ + Load an RSA key pair from a string. + + :param string: String containing RSA key pair in PEM format. + + :param callback: A Python callable object that is invoked + to acquire a passphrase with which to unlock the + key. The default is util.passphrase_callback. + + :return: M2Crypto.RSA.RSA object. + """ + bio = BIO.MemoryBuffer(string) + return load_key_bio(bio, callback) + + +def load_pub_key(file): + # type: (AnyStr) -> RSA_pub + """ + Load an RSA public key from file. + + :param file: Name of file containing RSA public key in PEM format. + + :return: M2Crypto.RSA.RSA_pub object. + """ + with BIO.openfile(file) as bio: + return load_pub_key_bio(bio) + + +def load_pub_key_bio(bio): + # type: (BIO.BIO) -> RSA_pub + """ + Load an RSA public key from an M2Crypto.BIO.BIO object. + + :param bio: M2Crypto.BIO.BIO object containing RSA public key in PEM + format. + + :return: M2Crypto.RSA.RSA_pub object. + """ + rsa = m2.rsa_read_pub_key(bio._ptr()) + if rsa is None: + rsa_error() + return RSA_pub(rsa, 1) + + +def new_pub_key(e_n): + # type: (Tuple[bytes, bytes]) -> RSA_pub + """ + Instantiate an RSA_pub object from an (e, n) tuple. + + :param e: The RSA public exponent; it is a string in OpenSSL's MPINT + format - 4-byte big-endian bit-count followed by the + appropriate number of bits. + + :param n: The RSA composite of primes; it is a string in OpenSSL's + MPINT format - 4-byte big-endian bit-count followed by the + appropriate number of bits. + + :return: M2Crypto.RSA.RSA_pub object. + """ + (e, n) = e_n + rsa = m2.rsa_new() + m2.rsa_set_en(rsa, e, n) + return RSA_pub(rsa, 1) diff --git a/src/M2Crypto/Rand.py b/src/M2Crypto/Rand.py new file mode 100644 index 0000000..a178b1b --- /dev/null +++ b/src/M2Crypto/Rand.py @@ -0,0 +1,146 @@ +"""M2Crypto wrapper for OpenSSL PRNG. Requires OpenSSL 0.9.5 and above. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. +Copyright (c) 2014-2017 Matej Cepl. All rights reserved. + +See LICENCE for the license information. +""" +from __future__ import absolute_import + +from M2Crypto import m2, six +from typing import AnyStr, Tuple # noqa + + +__all__ = ['rand_seed', 'rand_add', 'load_file', 'save_file', 'rand_bytes', + 'rand_pseudo_bytes', 'rand_file_name', 'rand_status'] + + +class RandError(ValueError): + pass + +m2.rand_init(RandError) + + +def rand_add(blob, entropy): + # type: (bytes, float) -> None + """ + Mixes blob into the PRNG state. + + :param blob: added data + :param entropy: (the lower bound of) an estimate of how much randomness + is contained in blob, measured in bytes. + + Thus, if the data at buf are unpredictable to an adversary, this + increases the uncertainty about the state and makes the PRNG output less + predictable. Suitable input comes from user interaction (random key + presses, mouse movements) and certain hardware events. + + Details about sources of randomness and how to estimate their entropy + can be found in the literature, e.g. RFC 1750. + """ + m2.rand_add(blob, entropy) # pylint: disable=no-member + + +def rand_seed(seed): + # type: (bytes) -> None + """ + Equivalent to rand_add() when len(seed) == entropy. + + :param seed: added data (see description at rand_add) + """ + m2.rand_seed(seed) # pylint: disable=no-member + + +def rand_status(): + # type: () -> int + """ + Check whether there is enough entropy in PRNG. + + :return: 1 if the PRNG has been seeded with enough + data, 0 otherwise. + """ + return m2.rand_status() # pylint: disable=no-member + + +def rand_file_name(): + # type: () -> str + """ + Generate a default path for the random seed file. + + :return: string with the filename. + The seed file is $RANDFILE if that environment variable + is set, $HOME/.rnd otherwise. If $HOME is not set either, + an error occurs. + """ + return six.ensure_text(m2.rand_file_name()) # pylint: disable=no-member + + +def load_file(filename, max_bytes): + # type: (AnyStr, int) -> int + """ + Read a number of bytes from file filename and adds them to the PRNG. + + If max_bytes is non-negative, up to to max_bytes are read; starting with + OpenSSL 0.9.5, if max_bytes is -1, the complete file is read. + + :param filename: + :param max_bytes: + :return: the number of bytes read. + """ + return m2.rand_load_file(six.ensure_str(filename), max_bytes) # pylint: disable=no-member + + +def save_file(filename): + # type: (AnyStr) -> int + """ + Write a number of random bytes (currently 1024) to file. + + The file then can be used to initialize the PRNG by calling load_file() in + a later session. + + :param filename: + :return: returns the number of bytes written, and -1 if the bytes + written were generated without appropriate seed. + """ + return m2.rand_save_file(filename) # pylint: disable=no-member + + +def rand_bytes(num): + # type: (int) -> bytes + """ + Return n cryptographically strong pseudo-random bytes. + + An error occurs if the PRNG has not been seeded with enough randomness + to ensure an unpredictable byte sequence. + + :param num: number of bytes to be returned + :return: random bytes + """ + return m2.rand_bytes(num) # pylint: disable=no-member + + +def rand_pseudo_bytes(num): + # type: (int) -> Tuple[bytes, int] + """ + Return num pseudo-random bytes into buf. + + Pseudo-random byte sequences generated by this method will be unique + if they are of sufficient length, but are not necessarily + unpredictable. They can be used for non-cryptographic purposes and for + certain purposes in cryptographic protocols, but usually not for key + generation etc. + + Output of the function is mixed into the entropy pool before + retrieving the new pseudo-random bytes unless disabled at compile + time (see FAQ). + + :param num: number of bytes to be returned + :return: random bytes + """ + import warnings + if m2.OPENSSL_VERSION_NUMBER >= 0x10100000: + warnings.warn('The underlying OpenSSL method has been ' + + 'deprecated. Use Rand.rand_bytes instead.', + DeprecationWarning) + + return m2.rand_pseudo_bytes(num) # pylint: disable=no-member diff --git a/src/M2Crypto/SMIME.py b/src/M2Crypto/SMIME.py new file mode 100644 index 0000000..1b7564a --- /dev/null +++ b/src/M2Crypto/SMIME.py @@ -0,0 +1,291 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL S/MIME API. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +from M2Crypto import BIO, EVP, Err, X509, m2, util +from typing import AnyStr, Callable, Optional # noqa + +PKCS7_TEXT = m2.PKCS7_TEXT # type: int +PKCS7_NOCERTS = m2.PKCS7_NOCERTS # type: int +PKCS7_NOSIGS = m2.PKCS7_NOSIGS # type: int +PKCS7_NOCHAIN = m2.PKCS7_NOCHAIN # type: int +PKCS7_NOINTERN = m2.PKCS7_NOINTERN # type: int +PKCS7_NOVERIFY = m2.PKCS7_NOVERIFY # type: int +PKCS7_DETACHED = m2.PKCS7_DETACHED # type: int +PKCS7_BINARY = m2.PKCS7_BINARY # type: int +PKCS7_NOATTR = m2.PKCS7_NOATTR # type: int + +PKCS7_SIGNED = m2.PKCS7_SIGNED # type: int +PKCS7_ENVELOPED = m2.PKCS7_ENVELOPED # type: int +PKCS7_SIGNED_ENVELOPED = m2.PKCS7_SIGNED_ENVELOPED # Deprecated +PKCS7_DATA = m2.PKCS7_DATA # type: int + + +class PKCS7_Error(Exception): + pass + + +m2.pkcs7_init(PKCS7_Error) + + +class PKCS7(object): + + m2_pkcs7_free = m2.pkcs7_free + + def __init__(self, pkcs7=None, _pyfree=0): + # type: (Optional[bytes], int) -> None + """PKCS7 object. + + :param pkcs7: binary representation of + the OpenSSL type PKCS7 + """ + if pkcs7 is not None: + self.pkcs7 = pkcs7 + self._pyfree = _pyfree + else: + self.pkcs7 = m2.pkcs7_new() + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_pkcs7_free(self.pkcs7) + + def _ptr(self): + return self.pkcs7 + + def type(self, text_name=0): + # type: (int) -> int + if text_name: + return m2.pkcs7_type_sn(self.pkcs7) + else: + return m2.pkcs7_type_nid(self.pkcs7) + + def write(self, bio): + # type: (BIO.BIO) -> int + return m2.pkcs7_write_bio(self.pkcs7, bio._ptr()) + + def write_der(self, bio): + # type: (BIO.BIO) -> int + return m2.pkcs7_write_bio_der(self.pkcs7, bio._ptr()) + + def get0_signers(self, certs, flags=0): + # type: (X509.X509_Stack, int) -> X509.X509_Stack + return X509.X509_Stack(m2.pkcs7_get0_signers(self.pkcs7, + certs.stack, flags), 1) + + +def load_pkcs7(p7file): + # type: (AnyStr) -> PKCS7 + with BIO.openfile(p7file, 'r') as bio: + p7_ptr = m2.pkcs7_read_bio(bio.bio) + + return PKCS7(p7_ptr, 1) + + +def load_pkcs7_der(p7file): + # type: (AnyStr) -> PKCS7 + with BIO.openfile(p7file, 'rb') as bio: + p7_ptr = m2.pkcs7_read_bio_der(bio.bio) + + return PKCS7(p7_ptr, 1) + + +def load_pkcs7_bio(p7_bio): + # type: (BIO.BIO) -> PKCS7 + p7_ptr = m2.pkcs7_read_bio(p7_bio._ptr()) + return PKCS7(p7_ptr, 1) + + +def load_pkcs7_bio_der(p7_bio): + # type: (BIO.BIO) -> PKCS7 + p7_ptr = m2.pkcs7_read_bio_der(p7_bio._ptr()) + return PKCS7(p7_ptr, 1) + + +def smime_load_pkcs7(p7file): + # type: (AnyStr) -> PKCS7 + bio = m2.bio_new_file(p7file, 'r') + + try: + p7_ptr, bio_ptr = m2.smime_read_pkcs7(bio) + finally: + m2.bio_free(bio) + + if bio_ptr is None: + return PKCS7(p7_ptr, 1), None + else: + return PKCS7(p7_ptr, 1), BIO.BIO(bio_ptr, 1) + + +def smime_load_pkcs7_bio(p7_bio): + # type: (BIO.BIO) -> PKCS7 + p7_ptr, bio_ptr = m2.smime_read_pkcs7(p7_bio._ptr()) + if p7_ptr is None: + raise SMIME_Error(Err.get_error()) + if bio_ptr is None: + return PKCS7(p7_ptr, 1), None + else: + return PKCS7(p7_ptr, 1), BIO.BIO(bio_ptr, 1) + + +class Cipher(object): + """Object interface to EVP_CIPHER without all the frills of + M2Crypto.EVP.Cipher. + """ + + def __init__(self, algo): + # type: (str) -> None + cipher = getattr(m2, algo, None) + if cipher is None: + raise ValueError('unknown cipher', algo) + self.cipher = cipher() + + def _ptr(self): + return self.cipher + + +class SMIME_Error(Exception): + pass + +m2.smime_init(SMIME_Error) + + +# FIXME class has no __init__ method +class SMIME(object): + def load_key(self, keyfile, certfile=None, + callback=util.passphrase_callback): + # type: (AnyStr, Optional[AnyStr], Callable) -> None + if certfile is None: + certfile = keyfile + self.pkey = EVP.load_key(keyfile, callback) + self.x509 = X509.load_cert(certfile) + + def load_key_bio(self, keybio, certbio=None, + callback=util.passphrase_callback): + # type: (BIO.BIO, Optional[BIO.BIO], Callable) -> None + if certbio is None: + certbio = keybio + self.pkey = EVP.load_key_bio(keybio, callback) + self.x509 = X509.load_cert_bio(certbio) + + def set_x509_stack(self, stack): + # type: (X509.X509_Stack) -> None + assert isinstance(stack, X509.X509_Stack) + self.x509_stack = stack + + def set_x509_store(self, store): + # type: (X509.X509_Store) -> None + assert isinstance(store, X509.X509_Store) + self.x509_store = store + + def set_cipher(self, cipher): + # type: (Cipher) -> None + assert isinstance(cipher, Cipher) + self.cipher = cipher + + def unset_key(self): + # type: () -> None + del self.pkey + del self.x509 + + def unset_x509_stack(self): + # type: () -> None + del self.x509_stack + + def unset_x509_store(self): + # type: () -> None + del self.x509_store + + def unset_cipher(self): + # type: () -> None + del self.cipher + + def encrypt(self, data_bio, flags=0): + # type: (BIO.BIO, int) -> PKCS7 + if not hasattr(self, 'cipher'): + raise SMIME_Error('no cipher: use set_cipher()') + if not hasattr(self, 'x509_stack'): + raise SMIME_Error('no recipient certs: use set_x509_stack()') + + pkcs7 = m2.pkcs7_encrypt(self.x509_stack._ptr(), data_bio._ptr(), + self.cipher._ptr(), flags) + + return PKCS7(pkcs7, 1) + + def decrypt(self, pkcs7, flags=0): + # type: (PKCS7, int) -> Optional[bytes] + if not hasattr(self, 'pkey'): + raise SMIME_Error('no private key: use load_key()') + if not hasattr(self, 'x509'): + raise SMIME_Error('no certificate: load_key() used incorrectly?') + blob = m2.pkcs7_decrypt(pkcs7._ptr(), self.pkey._ptr(), + self.x509._ptr(), flags) + return blob + + def sign(self, data_bio, flags=0, algo='sha1'): + # type: (BIO.BIO, int, Optional[str]) -> PKCS7 + if not hasattr(self, 'pkey'): + raise SMIME_Error('no private key: use load_key()') + + hash = getattr(m2, algo, None) + + if hash is None: + raise SMIME_Error('no such hash algorithm %s' % algo) + + if hasattr(self, 'x509_stack'): + pkcs7 = m2.pkcs7_sign1(self.x509._ptr(), self.pkey._ptr(), + self.x509_stack._ptr(), + data_bio._ptr(), hash(), flags) + return PKCS7(pkcs7, 1) + else: + pkcs7 = m2.pkcs7_sign0(self.x509._ptr(), self.pkey._ptr(), + data_bio._ptr(), hash(), flags) + return PKCS7(pkcs7, 1) + + def verify(self, pkcs7, data_bio=None, flags=0): + # type: (PKCS7, BIO.BIO, int) -> Optional[bytes] + if not hasattr(self, 'x509_stack'): + raise SMIME_Error('no signer certs: use set_x509_stack()') + if not hasattr(self, 'x509_store'): + raise SMIME_Error('no x509 cert store: use set_x509_store()') + assert isinstance(pkcs7, PKCS7), 'pkcs7 not an instance of PKCS7' + p7 = pkcs7._ptr() + if data_bio is None: + blob = m2.pkcs7_verify0(p7, self.x509_stack._ptr(), + self.x509_store._ptr(), flags) + else: + blob = m2.pkcs7_verify1(p7, self.x509_stack._ptr(), + self.x509_store._ptr(), + data_bio._ptr(), flags) + return blob + + def write(self, out_bio, pkcs7, data_bio=None, flags=0): + # type: (BIO.BIO, PKCS7, Optional[BIO.BIO], int) -> int + assert isinstance(pkcs7, PKCS7) + if data_bio is None: + return m2.smime_write_pkcs7(out_bio._ptr(), pkcs7._ptr(), flags) + else: + return m2.smime_write_pkcs7_multi(out_bio._ptr(), pkcs7._ptr(), + data_bio._ptr(), flags) + + +def text_crlf(text): + # type: (bytes) -> bytes + bio_in = BIO.MemoryBuffer(text) + bio_out = BIO.MemoryBuffer() + if m2.smime_crlf_copy(bio_in._ptr(), bio_out._ptr()): + return bio_out.read() + else: + raise SMIME_Error(Err.get_error()) + + +def text_crlf_bio(bio_in): + # type: (BIO.BIO) -> BIO.BIO + bio_out = BIO.MemoryBuffer() + if m2.smime_crlf_copy(bio_in._ptr(), bio_out._ptr()): + return bio_out + else: + raise SMIME_Error(Err.get_error()) diff --git a/src/M2Crypto/SSL/Checker.py b/src/M2Crypto/SSL/Checker.py new file mode 100644 index 0000000..46d397a --- /dev/null +++ b/src/M2Crypto/SSL/Checker.py @@ -0,0 +1,296 @@ +""" +SSL peer certificate checking routines + +Copyright (c) 2004-2007 Open Source Applications Foundation. +All rights reserved. + +Copyright 2008 Heikki Toivonen. All rights reserved. +""" + +__all__ = ['SSLVerificationError', 'NoCertificate', 'WrongCertificate', + 'WrongHost', 'Checker'] + +import re +import socket + +from M2Crypto import X509, m2, six # noqa +from typing import AnyStr, Optional # noqa + + +class SSLVerificationError(Exception): + pass + + +class NoCertificate(SSLVerificationError): + pass + + +class WrongCertificate(SSLVerificationError): + pass + + +class WrongHost(SSLVerificationError): + def __init__(self, expectedHost, actualHost, fieldName='commonName'): + # type: (str, AnyStr, str) -> None + """ + This exception will be raised if the certificate returned by the + peer was issued for a different host than we tried to connect to. + This could be due to a server misconfiguration or an active attack. + + :param expectedHost: The name of the host we expected to find in the + certificate. + :param actualHost: The name of the host we actually found in the + certificate. + :param fieldName: The field name where we noticed the error. This + should be either 'commonName' or 'subjectAltName'. + """ + if fieldName not in ('commonName', 'subjectAltName'): + raise ValueError( + 'Unknown fieldName, should be either commonName ' + + 'or subjectAltName') + + SSLVerificationError.__init__(self) + self.expectedHost = expectedHost + self.actualHost = actualHost + self.fieldName = fieldName + + def __str__(self): + # type: () -> str + s = 'Peer certificate %s does not match host, expected %s, got %s' \ + % (self.fieldName, self.expectedHost, self.actualHost) + return six.ensure_text(s) + + +class Checker(object): + + numericIpMatch = re.compile('^[0-9]+(\.[0-9]+)*$') + + def __init__(self, host=None, peerCertHash=None, peerCertDigest='sha1'): + # type: (Optional[str], Optional[bytes], str) -> None + self.host = host + if peerCertHash is not None: + peerCertHash = six.ensure_binary(peerCertHash) + self.fingerprint = peerCertHash + self.digest = peerCertDigest # type: str + + def __call__(self, peerCert, host=None): + # type: (X509.X509, Optional[str]) -> bool + if peerCert is None: + raise NoCertificate('peer did not return certificate') + + if host is not None: + self.host = host # type: str + + if self.fingerprint: + if self.digest not in ('sha1', 'md5'): + raise ValueError('unsupported digest "%s"' % self.digest) + + if self.digest == 'sha1': + expected_len = 40 + elif self.digest == 'md5': + expected_len = 32 + else: + raise ValueError('Unexpected digest {0}'.format(self.digest)) + + if len(self.fingerprint) != expected_len: + raise WrongCertificate( + ('peer certificate fingerprint length does not match\n' + + 'fingerprint: {0}\nexpected = {1}\n' + + 'observed = {2}').format(self.fingerprint, + expected_len, + len(self.fingerprint))) + + expected_fingerprint = six.ensure_text(self.fingerprint) + observed_fingerprint = peerCert.get_fingerprint(md=self.digest) + if observed_fingerprint != expected_fingerprint: + raise WrongCertificate( + ('peer certificate fingerprint does not match\n' + + 'expected = {0},\n' + + 'observed = {1}').format(expected_fingerprint, + observed_fingerprint)) + + if self.host: + hostValidationPassed = False + self.useSubjectAltNameOnly = False + + # subjectAltName=DNS:somehost[, ...]* + try: + subjectAltName = peerCert.get_ext('subjectAltName').get_value() + if self._splitSubjectAltName(self.host, subjectAltName): + hostValidationPassed = True + elif self.useSubjectAltNameOnly: + raise WrongHost(expectedHost=self.host, + actualHost=subjectAltName, + fieldName='subjectAltName') + except LookupError: + pass + + # commonName=somehost[, ...]* + if not hostValidationPassed: + hasCommonName = False + commonNames = '' + for entry in peerCert.get_subject().get_entries_by_nid( + m2.NID_commonName): + hasCommonName = True + commonName = entry.get_data().as_text() + if not commonNames: + commonNames = commonName + else: + commonNames += ',' + commonName + if self._match(self.host, commonName): + hostValidationPassed = True + break + + if not hasCommonName: + raise WrongCertificate('no commonName in peer certificate') + + if not hostValidationPassed: + raise WrongHost(expectedHost=self.host, + actualHost=commonNames, + fieldName='commonName') + + return True + + def _splitSubjectAltName(self, host, subjectAltName): + # type: (AnyStr, AnyStr) -> bool + """ + >>> check = Checker() + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:my.example.com') + True + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:*.example.com') + True + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:m*.example.com') + True + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:m*ample.com') + False + >>> check.useSubjectAltNameOnly + True + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:m*ample.com, othername:') + False + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:m*ample.com, DNS:my.example.org') + False + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:m*ample.com, DNS:my.example.com') + True + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='DNS:my.example.com, DNS:my.example.org') + True + >>> check.useSubjectAltNameOnly + True + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='') + False + >>> check._splitSubjectAltName(host='my.example.com', + ... subjectAltName='othername:') + False + >>> check.useSubjectAltNameOnly + False + """ + self.useSubjectAltNameOnly = False + for certHost in subjectAltName.split(','): + certHost = certHost.lower().strip() + if certHost[:4] == 'dns:': + self.useSubjectAltNameOnly = True + if self._match(host, certHost[4:]): + return True + elif certHost[:11] == 'ip address:': + self.useSubjectAltNameOnly = True + if self._matchIPAddress(host, certHost[11:]): + return True + return False + + def _match(self, host, certHost): + # type: (str, str) -> bool + """ + >>> check = Checker() + >>> check._match(host='my.example.com', certHost='my.example.com') + True + >>> check._match(host='my.example.com', certHost='*.example.com') + True + >>> check._match(host='my.example.com', certHost='m*.example.com') + True + >>> check._match(host='my.example.com', certHost='m*.EXAMPLE.com') + True + >>> check._match(host='my.example.com', certHost='m*ample.com') + False + >>> check._match(host='my.example.com', certHost='*.*.com') + False + >>> check._match(host='1.2.3.4', certHost='1.2.3.4') + True + >>> check._match(host='1.2.3.4', certHost='*.2.3.4') + False + >>> check._match(host='1234', certHost='1234') + True + """ + # XXX See RFC 2818 and 3280 for matching rules, this is may not + # XXX yet be complete. + + host = host.lower() + certHost = certHost.lower() + + if host == certHost: + return True + + if certHost.count('*') > 1: + # Not sure about this, but being conservative + return False + + if self.numericIpMatch.match(host) or \ + self.numericIpMatch.match(certHost.replace('*', '')): + # Not sure if * allowed in numeric IP, but think not. + return False + + if certHost.find('\\') > -1: + # Not sure about this, maybe some encoding might have these. + # But being conservative for now, because regex below relies + # on this. + return False + + # Massage certHost so that it can be used in regex + certHost = certHost.replace('.', '\.') + certHost = certHost.replace('*', '[^\.]*') + if re.compile('^%s$' % certHost).match(host): + return True + + return False + + def _matchIPAddress(self, host, certHost): + # type: (AnyStr, AnyStr) -> bool + """ + >>> check = Checker() + >>> check._matchIPAddress(host='my.example.com', + ... certHost='my.example.com') + False + >>> check._matchIPAddress(host='1.2.3.4', certHost='1.2.3.4') + True + >>> check._matchIPAddress(host='1.2.3.4', certHost='*.2.3.4') + False + >>> check._matchIPAddress(host='1.2.3.4', certHost='1.2.3.40') + False + >>> check._matchIPAddress(host='::1', certHost='::1') + True + >>> check._matchIPAddress(host='::1', certHost='0:0:0:0:0:0:0:1') + True + >>> check._matchIPAddress(host='::1', certHost='::2') + False + """ + try: + canonical = socket.getaddrinfo(host, 0, 0, socket.SOCK_STREAM, 0, + socket.AI_NUMERICHOST) + certCanonical = socket.getaddrinfo(certHost, 0, 0, + socket.SOCK_STREAM, 0, + socket.AI_NUMERICHOST) + except: + return False + return canonical == certCanonical + + +if __name__ == '__main__': + import doctest + doctest.testmod() diff --git a/src/M2Crypto/SSL/Cipher.py b/src/M2Crypto/SSL/Cipher.py new file mode 100644 index 0000000..06f2dbf --- /dev/null +++ b/src/M2Crypto/SSL/Cipher.py @@ -0,0 +1,59 @@ +"""SSL Ciphers + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +__all__ = ['Cipher', 'Cipher_Stack'] + +from M2Crypto import m2, six +from typing import Iterable # noqa + + +class Cipher(object): + def __init__(self, cipher): + # type: (str) -> None + self.cipher = cipher + + def __len__(self): + # type: () -> int + return m2.ssl_cipher_get_bits(self.cipher) + + def __repr__(self): + # type: () -> str + return "%s-%s" % (self.name(), len(self)) + + def __str__(self): + # type: () -> str + return "%s-%s" % (self.name(), len(self)) + + def version(self): + # type: () -> int + return m2.ssl_cipher_get_version(self.cipher) + + def name(self): + # type: () -> str + return six.ensure_text(m2.ssl_cipher_get_name(self.cipher)) + + +class Cipher_Stack(object): + def __init__(self, stack): + # type: (bytes) -> None + """ + :param stack: binary of the C-type STACK_OF(SSL_CIPHER) + """ + self.stack = stack + + def __len__(self): + # type: () -> int + return m2.sk_ssl_cipher_num(self.stack) + + def __getitem__(self, idx): + # type: (int) -> Cipher + if not 0 <= idx < m2.sk_ssl_cipher_num(self.stack): + raise IndexError('index out of range') + v = m2.sk_ssl_cipher_value(self.stack, idx) + return Cipher(v) + + def __iter__(self): + # type: () -> Iterable + for i in six.moves.range(m2.sk_ssl_cipher_num(self.stack)): + yield self[i] diff --git a/src/M2Crypto/SSL/Connection.py b/src/M2Crypto/SSL/Connection.py new file mode 100644 index 0000000..c5693c9 --- /dev/null +++ b/src/M2Crypto/SSL/Connection.py @@ -0,0 +1,712 @@ +from __future__ import absolute_import + +"""SSL Connection aka socket + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + +Portions created by Open Source Applications Foundation (OSAF) are +Copyright (C) 2004-2007 OSAF. All Rights Reserved. + +Copyright 2008 Heikki Toivonen. All rights reserved. +""" + +import logging +import socket +import io + +from M2Crypto import BIO, Err, X509, m2, six, util # noqa +from M2Crypto.SSL import Checker, Context, timeout # noqa +from M2Crypto.SSL import SSLError +from M2Crypto.SSL.Cipher import Cipher, Cipher_Stack +from M2Crypto.SSL.Session import Session +from typing import Any, AnyStr, Callable, Optional, Tuple, Union # noqa + +__all__ = ['Connection', + 'timeout', # XXX Not really, but for documentation purposes + ] + +log = logging.getLogger(__name__) + + +def _serverPostConnectionCheck(*args, **kw): + # type: (*Any, **Any) -> int + return 1 + + +class Connection(object): + """An SSL connection.""" + + serverPostConnectionCheck = _serverPostConnectionCheck + + m2_bio_free = m2.bio_free + m2_ssl_free = m2.ssl_free + m2_bio_noclose = m2.bio_noclose + + def __init__(self, ctx, sock=None, family=socket.AF_INET): + # type: (Context, socket.socket, int) -> None + """ + + :param ctx: SSL.Context + :param sock: socket to be used + :param family: socket family + """ + # The Checker needs to be an instance attribute + # and not a class attribute for thread safety reason + self.clientPostConnectionCheck = Checker.Checker() + + self._bio_freed = False + self.ctx = ctx + self.ssl = m2.ssl_new(self.ctx.ctx) # type: bytes + if sock is not None: + self.socket = sock + else: + self.socket = socket.socket(family, socket.SOCK_STREAM) + self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self._fileno = self.socket.fileno() + + self._timeout = self.socket.gettimeout() + if self._timeout is None: + self._timeout = -1.0 + + self.ssl_close_flag = m2.bio_noclose + + if self.ctx.post_connection_check is not None: + self.set_post_connection_check_callback( + self.ctx.post_connection_check) + + self.host = None + + def _free_bio(self): + """ + Free the sslbio and sockbio, and close the socket. + """ + # Do not do it twice + if not self._bio_freed: + if getattr(self, 'sslbio', None): + self.m2_bio_free(self.sslbio) + if getattr(self, 'sockbio', None): + self.m2_bio_free(self.sockbio) + if self.ssl_close_flag == self.m2_bio_noclose and \ + getattr(self, 'ssl', None): + self.m2_ssl_free(self.ssl) + self.socket.close() + self._bio_freed = True + + + def __del__(self): + # type: () -> None + # Notice that M2Crypto doesn't automatically shuts down the + # connection here. You have to call self.close() in your + # program, M2Crypto won't do it automatically for you. + self._free_bio() + + def close(self, freeBio=False): + """ + if freeBio is true, call _free_bio + """ + # type: () -> None + m2.ssl_shutdown(self.ssl) + if freeBio: + self._free_bio() + + def clear(self): + # type: () -> int + """ + If there were errors in this connection, call clear() rather + than close() to end it, so that bad sessions will be cleared + from cache. + """ + return m2.ssl_clear(self.ssl) + + def set_shutdown(self, mode): + # type: (int) -> None + """Sets the shutdown state of the Connection to mode. + + The shutdown state of an ssl connection is a bitmask of (use + m2.SSL_* constants): + + 0 No shutdown setting, yet. + + SSL_SENT_SHUTDOWN + A "close notify" shutdown alert was sent to the peer, the + connection is being considered closed and the session is + closed and correct. + + SSL_RECEIVED_SHUTDOWN + A shutdown alert was received form the peer, either a normal + "close notify" or a fatal error. + + SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN can be set at the + same time. + + :param mode: set the mode bitmask. + """ + m2.ssl_set_shutdown1(self.ssl, mode) + + def get_shutdown(self): + # type: () -> None + """Get the current shutdown mode of the Connection.""" + return m2.ssl_get_shutdown(self.ssl) + + def bind(self, addr): + # type: (util.AddrType) -> None + self.socket.bind(addr) + + def listen(self, qlen=5): + # type: (int) -> None + self.socket.listen(qlen) + + def ssl_get_error(self, ret): + # type: (int) -> int + return m2.ssl_get_error(self.ssl, ret) + + def set_bio(self, readbio, writebio): + # type: (BIO.BIO, BIO.BIO) -> None + """Explicitly set read and write bios + + Connects the BIOs for the read and write operations of the + TLS/SSL (encrypted) side of ssl. + + The SSL engine inherits the behaviour of both BIO objects, + respectively. If a BIO is non-blocking, the Connection will also + have non-blocking behaviour. + + If there was already a BIO connected to Connection, BIO_free() + will be called (for both the reading and writing side, if + different). + + :param readbio: BIO for reading + :param writebio: BIO for writing. + """ + m2.ssl_set_bio(self.ssl, readbio._ptr(), writebio._ptr()) + + def set_client_CA_list_from_file(self, cafile): + # type: (AnyStr) -> None + """Set the acceptable client CA list. + + If the client returns a certificate, it must have been issued by + one of the CAs listed in cafile. + + Makes sense only for servers. + + :param cafile: Filename from which to load the CA list. + + :return: 0 A failure while manipulating the STACK_OF(X509_NAME) + object occurred or the X509_NAME could not be + extracted from cacert. Check the error stack to find + out the reason. + + 1 The operation succeeded. + """ + m2.ssl_set_client_CA_list_from_file(self.ssl, cafile) + + def set_client_CA_list_from_context(self): + # type: () -> None + """ + Set the acceptable client CA list. If the client + returns a certificate, it must have been issued by + one of the CAs listed in context. + + Makes sense only for servers. + """ + m2.ssl_set_client_CA_list_from_context(self.ssl, self.ctx.ctx) + + def setup_addr(self, addr): + # type: (util.AddrType) -> None + self.addr = addr + + def set_ssl_close_flag(self, flag): + # type: (int) -> None + """ + By default, SSL struct will be freed in __del__. Call with + m2.bio_close to override this default. + + :param flag: either m2.bio_close or m2.bio_noclose + """ + if flag not in (m2.bio_close, m2.bio_noclose): + raise ValueError("flag must be m2.bio_close or m2.bio_noclose") + self.ssl_close_flag = flag + + def setup_ssl(self): + # type: () -> None + # Make a BIO_s_socket. + self.sockbio = m2.bio_new_socket(self.socket.fileno(), 0) + # Link SSL struct with the BIO_socket. + m2.ssl_set_bio(self.ssl, self.sockbio, self.sockbio) + # Make a BIO_f_ssl. + self.sslbio = m2.bio_new(m2.bio_f_ssl()) + # Link BIO_f_ssl with the SSL struct. + m2.bio_set_ssl(self.sslbio, self.ssl, m2.bio_noclose) + + def _setup_ssl(self, addr): + # type: (util.AddrType) -> None + """Deprecated""" + self.setup_addr(addr) + self.setup_ssl() + + def set_accept_state(self): + # type: () -> None + """Sets Connection to work in the server mode.""" + m2.ssl_set_accept_state(self.ssl) + + def accept_ssl(self): + # type: () -> Optional[int] + """Waits for a TLS/SSL client to initiate the TLS/SSL handshake. + + The communication channel must already have been set and + assigned to the ssl by setting an underlying BIO. + + :return: 0 The TLS/SSL handshake was not successful but was shut + down controlled and by the specifications of the + TLS/SSL protocol. Call get_error() with the return + value ret to find out the reason. + + 1 The TLS/SSL handshake was successfully completed, + a TLS/SSL connection has been established. + + <0 The TLS/SSL handshake was not successful because + a fatal error occurred either at the protocol level + or a connection failure occurred. The shutdown was + not clean. It can also occur of action is need to + continue the operation for non-blocking BIOs. Call + get_error() with the return value ret to find + out the reason. + """ + return m2.ssl_accept(self.ssl, self._timeout) + + def accept(self): + # type: () -> Tuple[Connection, util.AddrType] + """Accept an SSL connection. + + The return value is a pair (ssl, addr) where ssl is a new SSL + connection object and addr is the address bound to the other end + of the SSL connection. + + :return: tuple of Connection and addr. Address can take very + various forms (see socket documentation), for IPv4 it + is tuple(str, int), for IPv6 a tuple of four (host, + port, flowinfo, scopeid), where the last two are + optional ints. + """ + sock, addr = self.socket.accept() + ssl = Connection(self.ctx, sock) + ssl.addr = addr + ssl.setup_ssl() + ssl.set_accept_state() + ssl.accept_ssl() + check = getattr(self, 'postConnectionCheck', + self.serverPostConnectionCheck) + if check is not None: + if not check(ssl.get_peer_cert(), ssl.addr[0]): + raise Checker.SSLVerificationError( + 'post connection check failed') + return ssl, addr + + def set_connect_state(self): + # type: () -> None + """Sets Connection to work in the client mode.""" + m2.ssl_set_connect_state(self.ssl) + + def connect_ssl(self): + # type: () -> Optional[int] + return m2.ssl_connect(self.ssl, self._timeout) + + def connect(self, addr): + # type: (util.AddrType) -> int + """Overloading socket.connect() + + :param addr: addresses have various depending on their type + + :return:status of ssl_connect() + """ + self.socket.connect(addr) + self.addr = addr + self.setup_ssl() + self.set_connect_state() + ret = self.connect_ssl() + check = getattr(self, 'postConnectionCheck', + self.clientPostConnectionCheck) + if check is not None: + if not check(self.get_peer_cert(), + self.host if self.host else self.addr[0]): + raise Checker.SSLVerificationError( + 'post connection check failed') + return ret + + def shutdown(self, how): + # type: (int) -> None + m2.ssl_set_shutdown(self.ssl, how) + + def renegotiate(self): + # type: () -> int + """Renegotiate this connection's SSL parameters.""" + return m2.ssl_renegotiate(self.ssl) + + def pending(self): + # type: () -> int + """Return the numbers of octets that can be read from the connection.""" + return m2.ssl_pending(self.ssl) + + def _write_bio(self, data): + # type: (bytes) -> int + return m2.ssl_write(self.ssl, data, self._timeout) + + def _write_nbio(self, data): + # type: (bytes) -> int + return m2.ssl_write_nbio(self.ssl, data) + + def _read_bio(self, size=1024): + # type: (int) -> bytes + if size <= 0: + raise ValueError('size <= 0') + return m2.ssl_read(self.ssl, size, self._timeout) + + def _read_nbio(self, size=1024): + # type: (int) -> bytes + if size <= 0: + raise ValueError('size <= 0') + return m2.ssl_read_nbio(self.ssl, size) + + def write(self, data): + # type: (bytes) -> int + if self._timeout != 0.0: + return self._write_bio(data) + return self._write_nbio(data) + sendall = send = write + + def _decref_socketios(self): + pass + + def recv_into(self, buff, nbytes=0): + # type: (Union[bytearray, memoryview], int) -> int + """ + A version of recv() that stores its data into a buffer rather + than creating a new string. Receive up to buffersize bytes from + the socket. If buffersize is not specified (or 0), receive up + to the size available in the given buffer. + + If buff is bytearray, it will have after return length of the + actually returned number of bytes. If buff is memoryview, then + the size of buff won't change (it cannot), but all bytes after + the number of returned bytes will be NULL. + + :param buffer: a buffer for the received bytes + :param nbytes: maximum number of bytes to read + :return: number of bytes read + + See recv() for documentation about the flags. + """ + n = len(buff) if nbytes == 0 else nbytes + + if n <= 0: + raise ValueError('size <= 0') + + # buff_bytes are actual bytes returned + buff_bytes = m2.ssl_read(self.ssl, n, self._timeout) + buflen = len(buff_bytes) + + # memoryview type has been added in 2.7 + if isinstance(buff, memoryview): + buff[:buflen] = buff_bytes + buff[buflen:] = b'\x00' * (len(buff) - buflen) + else: + buff[:] = buff_bytes + + return buflen + + def read(self, size=1024): + # type: (int) -> bytes + if self._timeout != 0.0: + return self._read_bio(size) + return self._read_nbio(size) + recv = read + + def setblocking(self, mode): + # type: (int) -> None + """Set this connection's underlying socket to _mode_. + + Set blocking or non-blocking mode of the socket: if flag is 0, + the socket is set to non-blocking, else to blocking mode. + Initially all sockets are in blocking mode. In non-blocking mode, + if a recv() call doesn't find any data, or if a send() call can't + immediately dispose of the data, a error exception is raised; + in blocking mode, the calls block until they can proceed. + s.setblocking(0) is equivalent to s.settimeout(0.0); + s.setblocking(1) is equivalent to s.settimeout(None). + + :param mode: new mode to be set + """ + self.socket.setblocking(mode) + if mode: + self._timeout = -1.0 + else: + self._timeout = 0.0 + + def settimeout(self, timeout): + # type: (float) -> None + """Set this connection's underlying socket's timeout to _timeout_.""" + self.socket.settimeout(timeout) + self._timeout = timeout + if self._timeout is None: + self._timeout = -1.0 + + def fileno(self): + # type: () -> int + return self.socket.fileno() + + def getsockopt(self, level, optname, buflen=None): + # type: (int, int, Optional[int]) -> Union[int, bytes] + """Get the value of the given socket option. + + :param level: level at which the option resides. + To manipulate options at the sockets API level, level is + specified as socket.SOL_SOCKET. To manipulate options at + any other level the protocol number of the appropriate + protocol controlling the option is supplied. For example, + to indicate that an option is to be interpreted by the + TCP protocol, level should be set to the protocol number + of socket.SOL_TCP; see getprotoent(3). + + :param optname: The value of the given socket option is + described in the Unix man page getsockopt(2)). The needed + symbolic constants (SO_* etc.) are defined in the socket + module. + + :param buflen: If it is absent, an integer option is assumed + and its integer value is returned by the function. If + buflen is present, it specifies the maximum length of the + buffer used to receive the option in, and this buffer is + returned as a bytes object. + + :return: Either integer or bytes value of the option. It is up + to the caller to decode the contents of the buffer (see + the optional built-in module struct for a way to decode + C structures encoded as byte strings). + """ + return self.socket.getsockopt(level, optname, buflen) + + def setsockopt(self, level, optname, value=None): + # type: (int, int, Union[int, bytes, None]) -> Optional[bytes] + """Set the value of the given socket option. + + :param level: same as with getsockopt() above + + :param optname: same as with getsockopt() above + + :param value: an integer or a string representing a buffer. In + the latter case it is up to the caller to ensure + that the string contains the proper bits (see the + optional built-in module struct for a way to + encode C structures as strings). + + :return: None for success or the error handler for failure. + """ + return self.socket.setsockopt(level, optname, value) + + def get_context(self): + # type: () -> Context + """Return the Context object associated with this connection.""" + return m2.ssl_get_ssl_ctx(self.ssl) + + def get_state(self): + # type: () -> bytes + """Return the SSL state of this connection. + + During its use, an SSL objects passes several states. The state + is internally maintained. Querying the state information is not + very informative before or when a connection has been + established. It however can be of significant interest during + the handshake. + + :return: 6 letter string indicating the current state of the SSL + object ssl. + """ + return m2.ssl_get_state(self.ssl) + + def verify_ok(self): + # type: () -> bool + return (m2.ssl_get_verify_result(self.ssl) == m2.X509_V_OK) + + def get_verify_mode(self): + # type: () -> int + """Return the peer certificate verification mode.""" + return m2.ssl_get_verify_mode(self.ssl) + + def get_verify_depth(self): + # type: () -> int + """Return the peer certificate verification depth.""" + return m2.ssl_get_verify_depth(self.ssl) + + def get_verify_result(self): + # type: () -> int + """Return the peer certificate verification result.""" + return m2.ssl_get_verify_result(self.ssl) + + def get_peer_cert(self): + # type: () -> X509.X509 + """Return the peer certificate. + + If the peer did not provide a certificate, return None. + """ + c = m2.ssl_get_peer_cert(self.ssl) + if c is None: + return None + # Need to free the pointer coz OpenSSL doesn't. + return X509.X509(c, 1) + + def get_peer_cert_chain(self): + # type: () -> Optional[X509.X509_Stack] + """Return the peer certificate chain; if the peer did not provide + a certificate chain, return None. + + :warning: The returned chain will be valid only for as long as the + connection object is alive. Once the connection object + gets freed, the chain will be freed as well. + """ + c = m2.ssl_get_peer_cert_chain(self.ssl) + if c is None: + return None + # No need to free the pointer coz OpenSSL does. + return X509.X509_Stack(c) + + def get_cipher(self): + # type: () -> Optional[Cipher] + """Return an M2Crypto.SSL.Cipher object for this connection; if the + connection has not been initialised with a cipher suite, return None. + """ + c = m2.ssl_get_current_cipher(self.ssl) + if c is None: + return None + return Cipher(c) + + def get_ciphers(self): + # type: () -> Optional[Cipher_Stack] + """Return an M2Crypto.SSL.Cipher_Stack object for this + connection; if the connection has not been initialised with + cipher suites, return None. + """ + c = m2.ssl_get_ciphers(self.ssl) + if c is None: + return None + return Cipher_Stack(c) + + def get_cipher_list(self, idx=0): + # type: (int) -> str + """Return the cipher suites for this connection as a string object.""" + return six.ensure_text(m2.ssl_get_cipher_list(self.ssl, idx)) + + def set_cipher_list(self, cipher_list): + # type: (str) -> int + """Set the cipher suites for this connection.""" + return m2.ssl_set_cipher_list(self.ssl, cipher_list) + + def makefile(self, mode='rb', bufsize=-1): + # type: (AnyStr, int) -> Union[io.BufferedRWPair,io.BufferedReader] + if six.PY3: + raw = socket.SocketIO(self, mode) + if 'rw' in mode: + return io.BufferedRWPair(raw, raw) + return io.BufferedReader(raw, io.DEFAULT_BUFFER_SIZE) + else: + return socket._fileobject(self, mode, bufsize) + + def getsockname(self): + # type: () -> util.AddrType + """Return the socket's own address. + + This is useful to find out the port number of an IPv4/v6 socket, + for instance. (The format of the address returned depends + on the address family -- see above.) + + :return:socket's address as addr type + """ + return self.socket.getsockname() + + def getpeername(self): + # type: () -> util.AddrType + """Return the remote address to which the socket is connected. + + This is useful to find out the port number of a remote IPv4/v6 socket, + for instance. + On some systems this function is not supported. + + :return: + """ + return self.socket.getpeername() + + def set_session_id_ctx(self, id): + # type: (bytes) -> int + ret = m2.ssl_set_session_id_context(self.ssl, id) + if not ret: + raise SSLError(Err.get_error_message()) + + def get_session(self): + # type: () -> Session + sess = m2.ssl_get_session(self.ssl) + return Session(sess) + + def set_session(self, session): + # type: (Session) -> None + m2.ssl_set_session(self.ssl, session._ptr()) + + def get_default_session_timeout(self): + # type: () -> int + return m2.ssl_get_default_session_timeout(self.ssl) + + def get_socket_read_timeout(self): + # type: () -> timeout + return timeout.struct_to_timeout( + self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_RCVTIMEO, + timeout.struct_size())) + + @staticmethod + def _hexdump(s): + assert isinstance(s, six.binary_type) + return ":".join("{0:02x}".format(ord(c) if six.PY2 else c) for c in s) + + def get_socket_write_timeout(self): + # type: () -> timeout + binstr = self.socket.getsockopt( + socket.SOL_SOCKET, socket.SO_SNDTIMEO, timeout.struct_size()) + timeo = timeout.struct_to_timeout(binstr) + # print("Debug: get_socket_write_timeout: " + # "get sockopt value: %s -> ret timeout(sec=%r, microsec=%r)" % + # (self._hexdump(binstr), timeo.sec, timeo.microsec)) + return timeo + + def set_socket_read_timeout(self, timeo): + # type: (timeout) -> None + assert isinstance(timeo, timeout.timeout) + self.socket.setsockopt( + socket.SOL_SOCKET, socket.SO_RCVTIMEO, timeo.pack()) + + def set_socket_write_timeout(self, timeo): + # type: (timeout) -> None + assert isinstance(timeo, timeout.timeout) + binstr = timeo.pack() + # print("Debug: set_socket_write_timeout: " + # "input timeout(sec=%r, microsec=%r) -> set sockopt value: %s" % + # (timeo.sec, timeo.microsec, self._hexdump(binstr))) + self.socket.setsockopt( + socket.SOL_SOCKET, socket.SO_SNDTIMEO, binstr) + + def get_version(self): + # type: () -> str + """Return the TLS/SSL protocol version for this connection.""" + return six.ensure_text(m2.ssl_get_version(self.ssl)) + + def set_post_connection_check_callback(self, postConnectionCheck): # noqa + # type: (Callable) -> None + self.postConnectionCheck = postConnectionCheck + + def set_tlsext_host_name(self, name): + # type: (bytes) -> None + """Set the requested hostname for the SNI (Server Name Indication) + extension. + """ + m2.ssl_set_tlsext_host_name(self.ssl, name) + + def set1_host(self, name): + # type: (bytes) -> None + """Set the requested hostname to check in the server certificate.""" + self.host = name diff --git a/src/M2Crypto/SSL/Context.py b/src/M2Crypto/SSL/Context.py new file mode 100644 index 0000000..d7cb7bc --- /dev/null +++ b/src/M2Crypto/SSL/Context.py @@ -0,0 +1,445 @@ +from __future__ import absolute_import + +"""SSL Context + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" + +from M2Crypto import BIO, Err, RSA, X509, m2, util # noqa +from M2Crypto.SSL import cb # noqa +from M2Crypto.SSL.Session import Session # noqa +from weakref import WeakValueDictionary +from typing import Any, AnyStr, Callable, Optional, Union # noqa + +__all__ = ['ctxmap', 'Context', 'map'] + + +class _ctxmap(object): + singleton = None # type: Optional[_ctxmap] + + def __init__(self): + # type: () -> None + """Simple WeakReffed list. + """ + self._ctxmap = WeakValueDictionary() + + def __getitem__(self, key): + # type: (int) -> Any + return self._ctxmap[key] + + def __setitem__(self, key, value): + # type: (int, Any) -> None + self._ctxmap[key] = value + + def __delitem__(self, key): + # type: (int) -> None + del self._ctxmap[key] + + +def ctxmap(): + # type: () -> _ctxmap + if _ctxmap.singleton is None: + _ctxmap.singleton = _ctxmap() + return _ctxmap.singleton +# deprecated!!! +map = ctxmap + + +class Context(object): + + """'Context' for SSL connections.""" + + m2_ssl_ctx_free = m2.ssl_ctx_free + + def __init__(self, protocol='tls', weak_crypto=None, + post_connection_check=None): + # type: (str, Optional[int], Optional[Callable]) -> None + proto = getattr(m2, protocol + '_method', None) + if proto is None: + # default is 'sslv23' for older versions of OpenSSL + if protocol == 'tls': + proto = getattr(m2, 'sslv23_method') + else: + raise ValueError("no such protocol '%s'" % protocol) + self.ctx = m2.ssl_ctx_new(proto()) + self.allow_unknown_ca = 0 # type: Union[int, bool] + self.post_connection_check = post_connection_check + ctxmap()[int(self.ctx)] = self + m2.ssl_ctx_set_cache_size(self.ctx, 128) + if weak_crypto is None and protocol in ('sslv23', 'tls'): + self.set_options(m2.SSL_OP_ALL | m2.SSL_OP_NO_SSLv2 | + m2.SSL_OP_NO_SSLv3) + + def __del__(self): + # type: () -> None + if getattr(self, 'ctx', None): + self.m2_ssl_ctx_free(self.ctx) + + def close(self): + # type: () -> None + del ctxmap()[int(self.ctx)] + + def load_cert(self, certfile, keyfile=None, + callback=util.passphrase_callback): + # type: (AnyStr, Optional[AnyStr], Callable) -> None + """Load certificate and private key into the context. + + :param certfile: File that contains the PEM-encoded certificate. + :param keyfile: File that contains the PEM-encoded private key. + Default value of None indicates that the private key + is to be found in 'certfile'. + :param callback: Callable object to be invoked if the private key is + passphrase-protected. Default callback provides a + simple terminal-style input for the passphrase. + """ + m2.ssl_ctx_passphrase_callback(self.ctx, callback) + m2.ssl_ctx_use_cert(self.ctx, certfile) + if not keyfile: + keyfile = certfile + m2.ssl_ctx_use_privkey(self.ctx, keyfile) + if not m2.ssl_ctx_check_privkey(self.ctx): + raise ValueError('public/private key mismatch') + + def load_cert_chain(self, certchainfile, keyfile=None, + callback=util.passphrase_callback): + # type: (AnyStr, Optional[AnyStr], Callable) -> None + """Load certificate chain and private key into the context. + + :param certchainfile: File object containing the PEM-encoded + certificate chain. + :param keyfile: File object containing the PEM-encoded private + key. Default value of None indicates that the + private key is to be found in 'certchainfile'. + :param callback: Callable object to be invoked if the private key + is passphrase-protected. Default callback + provides a simple terminal-style input for the + passphrase. + """ + m2.ssl_ctx_passphrase_callback(self.ctx, callback) + m2.ssl_ctx_use_cert_chain(self.ctx, certchainfile) + if not keyfile: + keyfile = certchainfile + m2.ssl_ctx_use_privkey(self.ctx, keyfile) + if not m2.ssl_ctx_check_privkey(self.ctx): + raise ValueError('public/private key mismatch') + + def set_client_CA_list_from_file(self, cafile): + # type: (AnyStr) -> None + """Load CA certs into the context. These CA certs are sent to the + peer during *SSLv3 certificate request*. + + :param cafile: File object containing one or more PEM-encoded CA + certificates concatenated together. + """ + m2.ssl_ctx_set_client_CA_list_from_file(self.ctx, cafile) + + # Deprecated. + load_client_CA = load_client_ca = set_client_CA_list_from_file + + def load_verify_locations(self, cafile=None, capath=None): + # type: (Optional[AnyStr], Optional[AnyStr]) -> int + """Load CA certs into the context. + + These CA certs are used during verification of the peer's + certificate. + + :param cafile: File containing one or more PEM-encoded CA + certificates concatenated together. + + :param capath: Directory containing PEM-encoded CA certificates + (one certificate per file). + + :return: 0 if the operation failed because CAfile and CApath are NULL + or the processing at one of the locations specified failed. + Check the error stack to find out the reason. + + 1 The operation succeeded. + """ + if cafile is None and capath is None: + raise ValueError("cafile and capath can not both be None.") + return m2.ssl_ctx_load_verify_locations(self.ctx, cafile, capath) + + # Deprecated. + load_verify_info = load_verify_locations + + def set_session_id_ctx(self, id): + # type: (bytes) -> None + """Sets the session id for the SSL.Context w/in a session can be reused. + + :param id: Sessions are generated within a certain context. When + exporting/importing sessions with + i2d_SSL_SESSION/d2i_SSL_SESSION it would be possible, + to re-import a session generated from another context + (e.g. another application), which might lead to + malfunctions. Therefore each application must set its + own session id context sid_ctx which is used to + distinguish the contexts and is stored in exported + sessions. The sid_ctx can be any kind of binary data + with a given length, it is therefore possible to use + e.g. the name of the application and/or the hostname + and/or service name. + """ + ret = m2.ssl_ctx_set_session_id_context(self.ctx, id) + if not ret: + raise Err.SSLError(Err.get_error_code(), '') + + def set_default_verify_paths(self): + # type: () -> int + """ + Specifies that the default locations from which CA certs are + loaded should be used. + + There is one default directory and one default file. The default + CA certificates directory is called "certs" in the default + OpenSSL directory. Alternatively the SSL_CERT_DIR environment + variable can be defined to override this location. The default + CA certificates file is called "cert.pem" in the default OpenSSL + directory. Alternatively the SSL_CERT_FILE environment variable + can be defined to override this location. + + @return 0 if the operation failed. A missing default location is + still treated as a success. No error code is set. + + 1 The operation succeeded. + """ + ret = m2.ssl_ctx_set_default_verify_paths(self.ctx) + if not ret: + raise ValueError('Cannot use default SSL certificate store!') + + def set_allow_unknown_ca(self, ok): + # type: (Union[int, bool]) -> None + """Set the context to accept/reject a peer certificate if the + certificate's CA is unknown. + + :param ok: True to accept, False to reject. + """ + self.allow_unknown_ca = ok + + def get_allow_unknown_ca(self): + # type: () -> Union[int, bool] + """Get the context's setting that accepts/rejects a peer + certificate if the certificate's CA is unknown. + + FIXME 2Bconverted to bool + """ + return self.allow_unknown_ca + + def set_verify(self, mode, depth, callback=None): + # type: (int, int, Optional[Callable]) -> None + """ + Set verify options. Most applications will need to call this + method with the right options to make a secure SSL connection. + + :param mode: The verification mode to use. Typically at least + SSL.verify_peer is used. Clients would also typically + add SSL.verify_fail_if_no_peer_cert. + :param depth: The maximum allowed depth of the certificate chain + returned by the peer. + :param callback: Callable that can be used to specify custom + verification checks. + """ + if callback is None: + m2.ssl_ctx_set_verify_default(self.ctx, mode) + else: + m2.ssl_ctx_set_verify(self.ctx, mode, callback) + m2.ssl_ctx_set_verify_depth(self.ctx, depth) + + def get_verify_mode(self): + # type: () -> int + return m2.ssl_ctx_get_verify_mode(self.ctx) + + def get_verify_depth(self): + # type: () -> int + """Returns the verification mode currently set in the SSL Context.""" + return m2.ssl_ctx_get_verify_depth(self.ctx) + + def set_tmp_dh(self, dhpfile): + # type: (AnyStr) -> int + """Load ephemeral DH parameters into the context. + + :param dhpfile: Filename of the file containing the PEM-encoded + DH parameters. + """ + f = BIO.openfile(dhpfile) + dhp = m2.dh_read_parameters(f.bio_ptr()) + return m2.ssl_ctx_set_tmp_dh(self.ctx, dhp) + + def set_tmp_dh_callback(self, callback=None): + # type: (Optional[Callable]) -> None + """Sets the callback function for SSL.Context. + + :param callback: Callable to be used when a DH parameters are required. + """ + if callback is not None: + m2.ssl_ctx_set_tmp_dh_callback(self.ctx, callback) + + def set_tmp_rsa(self, rsa): + # type: (RSA.RSA) -> int + """Load ephemeral RSA key into the context. + + :param rsa: RSA.RSA instance. + """ + if isinstance(rsa, RSA.RSA): + return m2.ssl_ctx_set_tmp_rsa(self.ctx, rsa.rsa) + else: + raise TypeError("Expected an instance of RSA.RSA, got %s." % rsa) + + def set_tmp_rsa_callback(self, callback=None): + # type: (Optional[Callable]) -> None + """Sets the callback function to be used when + a temporary/ephemeral RSA key is required. + """ + if callback is not None: + m2.ssl_ctx_set_tmp_rsa_callback(self.ctx, callback) + + def set_info_callback(self, callback=cb.ssl_info_callback): + # type: (Callable) -> None + """Set a callback function to get state information. + + It can be used to get state information about the SSL + connections that are created from this context. + + :param callback: Callback function. The default prints + information to stderr. + """ + m2.ssl_ctx_set_info_callback(self.ctx, callback) + + def set_cipher_list(self, cipher_list): + # type: (str) -> int + """Sets the list of available ciphers. + + :param cipher_list: The format of the string is described in + ciphers(1). + :return: 1 if any cipher could be selected and 0 on complete + failure. + """ + return m2.ssl_ctx_set_cipher_list(self.ctx, cipher_list) + + def add_session(self, session): + # type: (Session) -> int + """Add the session to the context. + + :param session: the session to be added. + + :return: 0 The operation failed. It was tried to add the same + (identical) session twice. + + 1 The operation succeeded. + """ + return m2.ssl_ctx_add_session(self.ctx, session._ptr()) + + def remove_session(self, session): + # type: (Session) -> int + """Remove the session from the context. + + :param session: the session to be removed. + + :return: 0 The operation failed. The session was not found in + the cache. + + 1 The operation succeeded. + """ + return m2.ssl_ctx_remove_session(self.ctx, session._ptr()) + + def get_session_timeout(self): + # type: () -> int + """Get current session timeout. + + Whenever a new session is created, it is assigned a maximum + lifetime. This lifetime is specified by storing the creation + time of the session and the timeout value valid at this time. If + the actual time is later than creation time plus timeout, the + session is not reused. + + Due to this realization, all sessions behave according to the + timeout value valid at the time of the session negotiation. + Changes of the timeout value do not affect already established + sessions. + + Expired sessions are removed from the internal session cache, + whenever SSL_CTX_flush_sessions(3) is called, either directly by + the application or automatically (see + SSL_CTX_set_session_cache_mode(3)) + + The default value for session timeout is decided on a per + protocol basis, see SSL_get_default_timeout(3). All currently + supported protocols have the same default timeout value of 300 + seconds. + + SSL_CTX_set_timeout() returns the previously set timeout value. + + :return: the currently set timeout value. + """ + return m2.ssl_ctx_get_session_timeout(self.ctx) + + def set_session_timeout(self, timeout): + # type: (int) -> int + """Set new session timeout. + + See self.get_session_timeout() for explanation of the session + timeouts. + + :param timeout: new timeout value. + + :return: the previously set timeout value. + """ + return m2.ssl_ctx_set_session_timeout(self.ctx, timeout) + + def set_session_cache_mode(self, mode): + # type: (int) -> int + """Enables/disables session caching. + + The mode is set by using m2.SSL_SESS_CACHE_* constants. + + :param mode: new mode value. + + :return: the previously set cache mode value. + """ + return m2.ssl_ctx_set_session_cache_mode(self.ctx, mode) + + def get_session_cache_mode(self): + # type: () -> int + """Gets the current session caching. + + The mode is set to m2.SSL_SESS_CACHE_* constants. + + :return: the previously set cache mode value. + """ + return m2.ssl_ctx_get_session_cache_mode(self.ctx) + + def set_options(self, op): + # type: (int) -> int + """Adds the options set via bitmask in options to the Context. + + !!! Options already set before are not cleared! + + The behaviour of the SSL library can be changed by setting + several options. The options are coded as bitmasks and can be + combined by a logical or operation (|). + + SSL.Context.set_options() and SSL.set_options() affect the + (external) protocol behaviour of the SSL library. The (internal) + behaviour of the API can be changed by using the similar + SSL.Context.set_mode() and SSL.set_mode() functions. + + During a handshake, the option settings of the SSL object are + used. When a new SSL object is created from a context using + SSL(), the current option setting is copied. Changes to ctx + do not affect already created SSL objects. SSL.clear() does not + affect the settings. + + :param op: bitmask of additional options specified in + SSL_CTX_set_options(3) manpage. + + :return: the new options bitmask after adding options. + """ + return m2.ssl_ctx_set_options(self.ctx, op) + + def get_cert_store(self): + # type: () -> X509.X509 + """ + Get the certificate store associated with this context. + + :warning: The store is NOT refcounted, and as such can not be relied + to be valid once the context goes away or is changed. + """ + return X509.X509_Store(m2.ssl_ctx_get_cert_store(self.ctx)) diff --git a/src/M2Crypto/SSL/SSLServer.py b/src/M2Crypto/SSL/SSLServer.py new file mode 100644 index 0000000..a44c9c7 --- /dev/null +++ b/src/M2Crypto/SSL/SSLServer.py @@ -0,0 +1,65 @@ +from __future__ import absolute_import, print_function + +"""SSLServer + +Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" + + +# M2Crypto +from M2Crypto.SSL import SSLError +from M2Crypto.SSL.Connection import Connection +from M2Crypto.SSL.Context import Context # noqa +# from M2Crypto import six # noqa +from M2Crypto import util # noqa +from M2Crypto.six.moves.socketserver import (BaseRequestHandler, BaseServer, + TCPServer, ThreadingMixIn) +import os +if os.name != 'nt': + from M2Crypto.six.moves.socketserver import ForkingMixIn +from socket import socket # noqa +from typing import Union # noqa + +__all__ = ['SSLServer', 'ForkingSSLServer', 'ThreadingSSLServer'] + + +class SSLServer(TCPServer): + def __init__(self, server_address, RequestHandlerClass, ssl_context, # noqa + bind_and_activate=True): + # type: (util.AddrType, BaseRequestHandler, Context, bool) -> None + """ + Superclass says: Constructor. May be extended, do not override. + This class says: Ho-hum. + """ + BaseServer.__init__(self, server_address, RequestHandlerClass) + self.ssl_ctx = ssl_context + self.socket = Connection(self.ssl_ctx) + if bind_and_activate: + self.server_bind() + self.server_activate() + + def handle_request(self): + # type: () -> None + request = None + client_address = None + try: + request, client_address = self.get_request() + if self.verify_request(request, client_address): + self.process_request(request, client_address) + except SSLError: + self.handle_error(request, client_address) + + def handle_error(self, request, client_address): + # type: (Union[socket, Connection], util.AddrType) -> None + print('-' * 40) + import traceback + traceback.print_exc() + print('-' * 40) + + +class ThreadingSSLServer(ThreadingMixIn, SSLServer): + pass + + +if os.name != 'nt': + class ForkingSSLServer(ForkingMixIn, SSLServer): + pass diff --git a/src/M2Crypto/SSL/Session.py b/src/M2Crypto/SSL/Session.py new file mode 100644 index 0000000..c364d4e --- /dev/null +++ b/src/M2Crypto/SSL/Session.py @@ -0,0 +1,69 @@ +"""SSL Session + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +__all__ = ['Session', 'load_session'] + +from M2Crypto import BIO, Err, m2 +from M2Crypto.SSL import SSLError +from typing import AnyStr # noqa + + +class Session(object): + + m2_ssl_session_free = m2.ssl_session_free + + def __init__(self, session, _pyfree=0): + # type: (bytes, int) -> None + assert session is not None + self.session = session + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_ssl_session_free(self.session) + + def _ptr(self): + # type: () -> bytes + return self.session + + def as_text(self): + # type: () -> bytes + buf = BIO.MemoryBuffer() + m2.ssl_session_print(buf.bio_ptr(), self.session) + return buf.read_all() + + def as_der(self): + # type: () -> bytes + buf = BIO.MemoryBuffer() + m2.i2d_ssl_session(buf.bio_ptr(), self.session) + return buf.read_all() + + def write_bio(self, bio): + # type: (BIO.BIO) -> int + return m2.ssl_session_write_bio(bio.bio_ptr(), self.session) + + def get_time(self): + # type: () -> int + return m2.ssl_session_get_time(self.session) + + def set_time(self, t): + # type: (int) -> int + return m2.ssl_session_set_time(self.session, t) + + def get_timeout(self): + # type: () -> int + return m2.ssl_session_get_timeout(self.session) + + def set_timeout(self, t): + # type: (int) -> int + return m2.ssl_session_set_timeout(self.session, t) + + +def load_session(pemfile): + # type: (AnyStr) -> Session + with BIO.openfile(pemfile) as f: + cptr = m2.ssl_session_read_pem(f.bio_ptr()) + + return Session(cptr, 1) diff --git a/src/M2Crypto/SSL/TwistedProtocolWrapper.py b/src/M2Crypto/SSL/TwistedProtocolWrapper.py new file mode 100644 index 0000000..5e94503 --- /dev/null +++ b/src/M2Crypto/SSL/TwistedProtocolWrapper.py @@ -0,0 +1,490 @@ +""" +Make Twisted use M2Crypto for SSL + +Copyright (c) 2004-2007 Open Source Applications Foundation. +All rights reserved. + +FIXME THIS HAS NOT BEEN FINISHED. NEITHER PEP484 NOR PORT PYTHON3 HAS +BEEN FINISHED. THE FURTHER WORK WILL BE DONE WHEN THE STATUS OF TWISTED +IN THE PYTHON 3 (AND ASYNCIO) WORLD WILL BE CLEAR. +""" + +__all__ = ['connectSSL', 'connectTCP', 'listenSSL', 'listenTCP', + 'TLSProtocolWrapper'] + +import logging + +from functools import partial + +import twisted.internet.reactor +import twisted.protocols.policies as policies + +from M2Crypto import BIO, X509, m2, util +from M2Crypto.SSL.Checker import Checker, SSLVerificationError + +from twisted.internet.interfaces import ITLSTransport +from twisted.protocols.policies import ProtocolWrapper +from typing import AnyStr, Callable, Iterable, Optional # noqa +from zope.interface import implementer + +log = logging.getLogger(__name__) + + +def _alwaysSucceedsPostConnectionCheck(peerX509, expectedHost): + return 1 + + +def connectSSL(host, port, factory, contextFactory, timeout=30, + bindAddress=None, + reactor=twisted.internet.reactor, + postConnectionCheck=Checker()): + # type: (str, int, object, object, int, Optional[str], twisted.internet.reactor, Checker) -> reactor.connectTCP + """ + A convenience function to start an SSL/TLS connection using Twisted. + + See IReactorSSL interface in Twisted. + """ + wrappingFactory = policies.WrappingFactory(factory) + wrappingFactory.protocol = lambda factory, wrappedProtocol: \ + TLSProtocolWrapper(factory, + wrappedProtocol, + startPassThrough=0, + client=1, + contextFactory=contextFactory, + postConnectionCheck=postConnectionCheck) + return reactor.connectTCP(host, port, wrappingFactory, timeout, bindAddress) + + +def connectTCP(host, port, factory, timeout=30, bindAddress=None, + reactor=twisted.internet.reactor, + postConnectionCheck=Checker()): + # type: (str, int, object, int, Optional[util.AddrType], object, Callable) -> object + """ + A convenience function to start a TCP connection using Twisted. + + NOTE: You must call startTLS(ctx) to go into SSL/TLS mode. + + See IReactorTCP interface in Twisted. + """ + wrappingFactory = policies.WrappingFactory(factory) + wrappingFactory.protocol = lambda factory, wrappedProtocol: \ + TLSProtocolWrapper(factory, + wrappedProtocol, + startPassThrough=1, + client=1, + contextFactory=None, + postConnectionCheck=postConnectionCheck) + return reactor.connectTCP(host, port, wrappingFactory, timeout, bindAddress) + + +def listenSSL(port, factory, contextFactory, backlog=5, interface='', + reactor=twisted.internet.reactor, + postConnectionCheck=_alwaysSucceedsPostConnectionCheck): + """ + A convenience function to listen for SSL/TLS connections using Twisted. + + See IReactorSSL interface in Twisted. + """ + wrappingFactory = policies.WrappingFactory(factory) + wrappingFactory.protocol = lambda factory, wrappedProtocol: \ + TLSProtocolWrapper(factory, + wrappedProtocol, + startPassThrough=0, + client=0, + contextFactory=contextFactory, + postConnectionCheck=postConnectionCheck) + return reactor.listenTCP(port, wrappingFactory, backlog, interface) + + +def listenTCP(port, factory, backlog=5, interface='', + reactor=twisted.internet.reactor, + postConnectionCheck=None): + """ + A convenience function to listen for TCP connections using Twisted. + + NOTE: You must call startTLS(ctx) to go into SSL/TLS mode. + + See IReactorTCP interface in Twisted. + """ + wrappingFactory = policies.WrappingFactory(factory) + wrappingFactory.protocol = lambda factory, wrappedProtocol: \ + TLSProtocolWrapper(factory, + wrappedProtocol, + startPassThrough=1, + client=0, + contextFactory=None, + postConnectionCheck=postConnectionCheck) + return reactor.listenTCP(port, wrappingFactory, backlog, interface) + + +class _BioProxy(object): + """ + The purpose of this class is to eliminate the __del__ method from + TLSProtocolWrapper, and thus letting it be garbage collected. + """ + + m2_bio_free_all = m2.bio_free_all + + def __init__(self, bio): + self.bio = bio + + def _ptr(self): + return self.bio + + def __del__(self): + if self.bio is not None: + self.m2_bio_free_all(self.bio) + + +class _SSLProxy(object): + """ + The purpose of this class is to eliminate the __del__ method from + TLSProtocolWrapper, and thus letting it be garbage collected. + """ + + m2_ssl_free = m2.ssl_free + + def __init__(self, ssl): + self.ssl = ssl + + def _ptr(self): + return self.ssl + + def __del__(self): + if self.ssl is not None: + self.m2_ssl_free(self.ssl) + + +@implementer(ITLSTransport) +class TLSProtocolWrapper(ProtocolWrapper): + """ + A SSL/TLS protocol wrapper to be used with Twisted. Typically + you would not use this class directly. Use connectTCP, + connectSSL, listenTCP, listenSSL functions defined above, + which will hook in this class. + """ + + def __init__(self, factory, wrappedProtocol, startPassThrough, client, + contextFactory, postConnectionCheck): + # type: (policies.WrappingFactory, object, int, int, object, Checker) -> None + """ + :param factory: + :param wrappedProtocol: + :param startPassThrough: If true we won't encrypt at all. Need to + call startTLS() later to switch to SSL/TLS. + :param client: True if this should be a client protocol. + :param contextFactory: Factory that creates SSL.Context objects. + The called function is getContext(). + :param postConnectionCheck: The post connection check callback that + will be called just after connection has + been established but before any real data + has been exchanged. The first argument to + this function is an X509 object, the second + is the expected host name string. + """ + # ProtocolWrapper.__init__(self, factory, wrappedProtocol) + # XXX: Twisted 2.0 has a new addition where the wrappingFactory is + # set as the factory of the wrappedProtocol. This is an issue + # as the wrap should be transparent. What we want is + # the factory of the wrappedProtocol to be the wrappedFactory and + # not the outer wrappingFactory. This is how it was implemented in + # Twisted 1.3 + self.factory = factory + self.wrappedProtocol = wrappedProtocol + + # wrappedProtocol == client/server instance + # factory.wrappedFactory == client/server factory + + self.data = b'' # Clear text to encrypt and send + self.encrypted = b'' # Encrypted data we need to decrypt and pass on + self.tlsStarted = 0 # SSL/TLS mode or pass through + self.checked = 0 # Post connection check done or not + self.isClient = client + self.helloDone = 0 # True when hello has been sent + if postConnectionCheck is None: + self.postConnectionCheck = _alwaysSucceedsPostConnectionCheck + else: + self.postConnectionCheck = postConnectionCheck + + if not startPassThrough: + self.startTLS(contextFactory.getContext()) + + def clear(self): + """ + Clear this instance, after which it is ready for reuse. + """ + if getattr(self, 'tlsStarted', 0): + self.sslBio = None + self.ssl = None + self.internalBio = None + self.networkBio = None + self.data = b'' + self.encrypted = b'' + self.tlsStarted = 0 + self.checked = 0 + self.isClient = 1 + self.helloDone = 0 + # We can reuse self.ctx and it will be deleted automatically + # when this instance dies + + def startTLS(self, ctx): + """ + Start SSL/TLS. If this is not called, this instance just passes data + through untouched. + """ + # NOTE: This method signature must match the startTLS() method Twisted + # expects transports to have. This will be called automatically + # by Twisted in STARTTLS situations, for example with SMTP. + if self.tlsStarted: + raise Exception('TLS already started') + + self.ctx = ctx + + self.internalBio = m2.bio_new(m2.bio_s_bio()) + m2.bio_set_write_buf_size(self.internalBio, 0) + self.networkBio = _BioProxy(m2.bio_new(m2.bio_s_bio())) + m2.bio_set_write_buf_size(self.networkBio._ptr(), 0) + m2.bio_make_bio_pair(self.internalBio, self.networkBio._ptr()) + + self.sslBio = _BioProxy(m2.bio_new(m2.bio_f_ssl())) + + self.ssl = _SSLProxy(m2.ssl_new(self.ctx.ctx)) + + if self.isClient: + m2.ssl_set_connect_state(self.ssl._ptr()) + else: + m2.ssl_set_accept_state(self.ssl._ptr()) + + m2.ssl_set_bio(self.ssl._ptr(), self.internalBio, self.internalBio) + m2.bio_set_ssl(self.sslBio._ptr(), self.ssl._ptr(), m2.bio_noclose) + + # Need this for writes that are larger than BIO pair buffers + mode = m2.ssl_get_mode(self.ssl._ptr()) + m2.ssl_set_mode(self.ssl._ptr(), + mode | + m2.SSL_MODE_ENABLE_PARTIAL_WRITE | + m2.SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER) + + self.tlsStarted = 1 + + def write(self, data): + # type: (bytes) -> None + if not self.tlsStarted: + ProtocolWrapper.write(self, data) + return + + try: + encryptedData = self._encrypt(data) + ProtocolWrapper.write(self, encryptedData) + self.helloDone = 1 + except BIO.BIOError as e: + # See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS + # for the error codes returned by SSL_get_verify_result. + e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0]) + raise e + + def writeSequence(self, data): + # type: (Iterable[bytes]) -> None + if not self.tlsStarted: + ProtocolWrapper.writeSequence(self, b''.join(data)) + return + + self.write(b''.join(data)) + + def loseConnection(self): + # XXX Do we need to do m2.ssl_shutdown(self.ssl._ptr())? + ProtocolWrapper.loseConnection(self) + + def connectionMade(self): + ProtocolWrapper.connectionMade(self) + if self.tlsStarted and self.isClient and not self.helloDone: + self._clientHello() + + def dataReceived(self, data): + # type: (bytes) -> None + if not self.tlsStarted: + ProtocolWrapper.dataReceived(self, data) + return + + self.encrypted += data + + try: + while 1: + decryptedData = self._decrypt() + + self._check() + + encryptedData = self._encrypt() + ProtocolWrapper.write(self, encryptedData) + + ProtocolWrapper.dataReceived(self, decryptedData) + + if decryptedData == b'' and encryptedData == b'': + break + except BIO.BIOError as e: + # See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS + # for the error codes returned by SSL_get_verify_result. + e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0]) + raise e + + def connectionLost(self, reason): + # type: (AnyStr) -> None + self.clear() + ProtocolWrapper.connectionLost(self, reason) + + def _check(self): + if not self.checked and m2.ssl_is_init_finished(self.ssl._ptr()): + x509 = m2.ssl_get_peer_cert(self.ssl._ptr()) + if x509 is not None: + x509 = X509.X509(x509, 1) + if self.isClient: + host = self.transport.addr[0] + else: + host = self.transport.getPeer().host + if not self.postConnectionCheck(x509, host): + raise SSLVerificationError('post connection check') + self.checked = 1 + + def _clientHello(self): + try: + # We rely on OpenSSL implicitly starting with client hello + # when we haven't yet established an SSL connection + encryptedData = self._encrypt(clientHello=1) + ProtocolWrapper.write(self, encryptedData) + self.helloDone = 1 + except BIO.BIOError as e: + # See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS + # for the error codes returned by SSL_get_verify_result. + e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0]) + raise e + + # Optimizations to reduce attribute accesses + + @property + def _get_wr_guar_ssl(self): + # type: () -> Callable[[], int] + """Return max. length of data can be written to the BIO. + + Writes larger than this value will return a value from + BIO_write() less than the amount requested or if the buffer is + full request a retry. + """ + return partial(m2.bio_ctrl_get_write_guarantee, + self.sslBio._ptr()) + + @property + def _get_wr_guar_net(self): + # type: () -> Callable[[], int] + return partial(m2.bio_ctrl_get_write_guarantee, + self.networkBio._ptr()) + + @property + def _shoud_retry_ssl(self): + # type: () -> Callable[[], int] + # BIO_should_retry() is true if the call that produced this + # condition should then be retried at a later time. + return partial(m2.bio_should_retry, self.sslBio._ptr()) + + @property + def _shoud_retry_net(self): + # type: () -> Callable[[], int] + return partial(m2.bio_should_retry, self.networkBio._ptr()) + + @property + def _ctrl_pend_ssl(self): + # type: () -> Callable[[], int] + # size_t BIO_ctrl_pending(BIO *b); + # BIO_ctrl_pending() return the number of pending characters in + # the BIOs read and write buffers. + return partial(m2.bio_ctrl_pending, self.sslBio._ptr()) + + @property + def _ctrl_pend_net(self): + # type: () -> Callable[[], int] + return partial(m2.bio_ctrl_pending, self.networkBio._ptr()) + + @property + def _write_ssl(self): + # type: () -> Callable[[bytes], int] + # All these functions return either the amount of data + # successfully read or written (if the return value is + # positive) or that no data was successfully read or written + # if the result is 0 or -1. If the return value is -2 then + # the operation is not implemented in the specific BIO type. + return partial(m2.bio_write, self.sslBio._ptr()) + + @property + def _write_net(self): + # type: () -> Callable[[bytes], int] + return partial(m2.bio_write, self.networkBio._ptr()) + + @property + def _read_ssl(self): + # type: () -> Callable[[int], Optional[bytes]] + return partial(m2.bio_read, self.sslBio._ptr()) + + @property + def _read_net(self): + # type: () -> Callable[[int], Optional[bytes]] + return partial(m2.bio_read, self.networkBio._ptr()) + + def _encrypt(self, data=b'', clientHello=0): + # type: (bytes, int) -> bytes + """ + :param data: + :param clientHello: + :return: + """ + encryptedData = b'' + self.data += data + + while 1: + if (self._get_wr_guar_ssl() > 0 and self.data != b'') or clientHello: + r = self._write_ssl(self.data) + if r <= 0: + if not self._shoud_retry_ssl(): + raise IOError( + ('Data left to be written to {}, ' + + 'but cannot retry SSL connection!').format(self.sslBio)) + else: + assert self.checked + self.data = self.data[r:] + + pending = self._ctrl_pend_net() + if pending: + d = self._read_net(pending) + if d is not None: # This is strange, but d can be None + encryptedData += d + else: + assert(self._shoud_retry_net()) + else: + break + return encryptedData + + def _decrypt(self, data=b''): + # type: (bytes) -> bytes + self.encrypted += data + decryptedData = b'' + + while 1: + if self._get_wr_guar_ssl() > 0 and self.encrypted != b'': + r = self._write_net(self.encrypted) + if r <= 0: + if not self._shoud_retry_net(): + raise IOError( + ('Data left to be written to {}, ' + + 'but cannot retry SSL connection!').format(self.networkBio)) + else: + self.encrypted = self.encrypted[r:] + + pending = self._ctrl_pend_ssl() + if pending: + d = self._read_ssl(pending) + if d is not None: # This is strange, but d can be None + decryptedData += d + else: + assert(self._shoud_retry_ssl()) + else: + break + + return decryptedData diff --git a/src/M2Crypto/SSL/__init__.py b/src/M2Crypto/SSL/__init__.py new file mode 100644 index 0000000..33bf1b9 --- /dev/null +++ b/src/M2Crypto/SSL/__init__.py @@ -0,0 +1,44 @@ +from __future__ import absolute_import + +"""M2Crypto SSL services. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" + +import socket, os + +# M2Crypto +from M2Crypto import _m2crypto as m2 + + +class SSLError(Exception): + pass + + +class SSLTimeoutError(SSLError, socket.timeout): + pass + +m2.ssl_init(SSLError, SSLTimeoutError) + +# M2Crypto.SSL +from M2Crypto.SSL.Cipher import Cipher, Cipher_Stack +from M2Crypto.SSL.Connection import Connection +from M2Crypto.SSL.Context import Context +from M2Crypto.SSL.SSLServer import SSLServer, ThreadingSSLServer +if os.name != 'nt': + from M2Crypto.SSL.SSLServer import ForkingSSLServer +from M2Crypto.SSL.ssl_dispatcher import ssl_dispatcher +from M2Crypto.SSL.timeout import timeout, struct_to_timeout, struct_size + +verify_none = m2.SSL_VERIFY_NONE # type: int +verify_peer = m2.SSL_VERIFY_PEER # type: int +verify_fail_if_no_peer_cert = m2.SSL_VERIFY_FAIL_IF_NO_PEER_CERT # type: int +verify_client_once = m2.SSL_VERIFY_CLIENT_ONCE # type: int +verify_crl_check_chain = m2.VERIFY_CRL_CHECK_CHAIN # type: int +verify_crl_check_leaf = m2.VERIFY_CRL_CHECK_LEAF # type: int + +SSL_SENT_SHUTDOWN = m2.SSL_SENT_SHUTDOWN # type: int +SSL_RECEIVED_SHUTDOWN = m2.SSL_RECEIVED_SHUTDOWN # type: int + +op_all = m2.SSL_OP_ALL # type: int +op_no_sslv2 = m2.SSL_OP_NO_SSLv2 # type: int + diff --git a/src/M2Crypto/SSL/cb.py b/src/M2Crypto/SSL/cb.py new file mode 100644 index 0000000..47f102e --- /dev/null +++ b/src/M2Crypto/SSL/cb.py @@ -0,0 +1,96 @@ +from __future__ import absolute_import + +"""SSL callbacks + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +import sys + +from M2Crypto import m2 +from typing import Any # noqa + +__all__ = ['unknown_issuer', 'ssl_verify_callback_stub', 'ssl_verify_callback', + 'ssl_verify_callback_allow_unknown_ca', 'ssl_info_callback'] + + +def ssl_verify_callback_stub(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok): + # Deprecated + return ok + + +unknown_issuer = [ + m2.X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, + m2.X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, + m2.X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE, + m2.X509_V_ERR_CERT_UNTRUSTED, +] + + +def ssl_verify_callback(ssl_ctx_ptr, x509_ptr, errnum, errdepth, ok): + # type: (bytes, bytes, int, int, int) -> int + # Deprecated + + from M2Crypto.SSL.Context import Context + ssl_ctx = Context.ctxmap()[int(ssl_ctx_ptr)] + if errnum in unknown_issuer: + if ssl_ctx.get_allow_unknown_ca(): + sys.stderr.write("policy: %s: permitted...\n" % + (m2.x509_get_verify_error(errnum))) + sys.stderr.flush() + ok = 1 + # CRL checking goes here... + if ok: + if ssl_ctx.get_verify_depth() >= errdepth: + ok = 1 + else: + ok = 0 + return ok + + +def ssl_verify_callback_allow_unknown_ca(ok, store): + # type: (int, Any) -> int + errnum = store.get_error() + if errnum in unknown_issuer: + ok = 1 + return ok + + +# Cribbed from OpenSSL's apps/s_cb.c. +def ssl_info_callback(where, ret, ssl_ptr): + # type: (int, int, bytes) -> None + + w = where & ~m2.SSL_ST_MASK + if w & m2.SSL_ST_CONNECT: + state = "SSL connect" + elif w & m2.SSL_ST_ACCEPT: + state = "SSL accept" + else: + state = "SSL state unknown" + + if where & m2.SSL_CB_LOOP: + sys.stderr.write("LOOP: %s: %s\n" % + (state, m2.ssl_get_state_v(ssl_ptr))) + sys.stderr.flush() + return + + if where & m2.SSL_CB_EXIT: + if not ret: + sys.stderr.write("FAILED: %s: %s\n" % + (state, m2.ssl_get_state_v(ssl_ptr))) + sys.stderr.flush() + else: + sys.stderr.write("INFO: %s: %s\n" % + (state, m2.ssl_get_state_v(ssl_ptr))) + sys.stderr.flush() + return + + if where & m2.SSL_CB_ALERT: + if where & m2.SSL_CB_READ: + w = 'read' + else: + w = 'write' + sys.stderr.write("ALERT: %s: %s: %s\n" % + (w, m2.ssl_get_alert_type_v(ret), + m2.ssl_get_alert_desc_v(ret))) + sys.stderr.flush() + return diff --git a/src/M2Crypto/SSL/ssl_dispatcher.py b/src/M2Crypto/SSL/ssl_dispatcher.py new file mode 100644 index 0000000..73a4b82 --- /dev/null +++ b/src/M2Crypto/SSL/ssl_dispatcher.py @@ -0,0 +1,43 @@ +from __future__ import absolute_import + +"""SSL dispatcher + +Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved.""" + +# Python +import asyncore +import socket + +# M2Crypto +from M2Crypto import util # noqa +from M2Crypto.SSL.Connection import Connection +from M2Crypto.SSL.Context import Context # noqa + +__all__ = ['ssl_dispatcher'] + + +class ssl_dispatcher(asyncore.dispatcher): + + def create_socket(self, ssl_context): + # type: (Context) -> None + self.family_and_type = socket.AF_INET, socket.SOCK_STREAM + self.ssl_ctx = ssl_context + self.socket = Connection(self.ssl_ctx) + # self.socket.setblocking(0) + self.add_channel() + + def connect(self, addr): + # type: (util.AddrType) -> None + self.socket.setblocking(1) + self.socket.connect(addr) + self.socket.setblocking(0) + + def recv(self, buffer_size=4096): + # type: (int) -> bytes + """Receive data over SSL.""" + return self.socket.recv(buffer_size) + + def send(self, buffer): + # type: (bytes) -> int + """Send data over SSL.""" + return self.socket.send(buffer) diff --git a/src/M2Crypto/SSL/timeout.py b/src/M2Crypto/SSL/timeout.py new file mode 100644 index 0000000..42b0291 --- /dev/null +++ b/src/M2Crypto/SSL/timeout.py @@ -0,0 +1,50 @@ +"""Support for SSL socket timeouts. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved. + +Copyright 2008 Heikki Toivonen. All rights reserved. +""" + +__all__ = ['DEFAULT_TIMEOUT', 'timeout', 'struct_to_timeout', 'struct_size'] + +import sys +import struct + +DEFAULT_TIMEOUT = 600 # type: int + + +class timeout(object): + + def __init__(self, sec=DEFAULT_TIMEOUT, microsec=0): + # type: (int, int) -> None + self.sec = sec + self.microsec = microsec + + def pack(self): + if sys.platform == 'win32': + millisec = int(self.sec * 1000 + round(float(self.microsec) / 1000)) + binstr = struct.pack('l', millisec) + else: + binstr = struct.pack('ll', self.sec, self.microsec) + return binstr + + +def struct_to_timeout(binstr): + # type: (bytes) -> timeout + if sys.platform == 'win32': + millisec = struct.unpack('l', binstr)[0] + # On py3, int/int performs exact division and returns float. We want + # the whole number portion of the exact division result: + sec = int(millisec / 1000) + microsec = (millisec % 1000) * 1000 + else: + (sec, microsec) = struct.unpack('ll', binstr) + return timeout(sec, microsec) + + +def struct_size(): + # type: () -> int + if sys.platform == 'win32': + return struct.calcsize('l') + else: + return struct.calcsize('ll') diff --git a/src/M2Crypto/X509.py b/src/M2Crypto/X509.py new file mode 100644 index 0000000..b27af13 --- /dev/null +++ b/src/M2Crypto/X509.py @@ -0,0 +1,1443 @@ +from __future__ import absolute_import + +"""M2Crypto wrapper for OpenSSL X509 API. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + +Portions created by Open Source Applications Foundation (OSAF) are +Copyright (C) 2004-2007 OSAF. All Rights Reserved. +Author: Heikki Toivonen +""" + +import binascii +import logging + +from M2Crypto import ASN1, BIO, EVP, m2, six # noqa +from typing import AnyStr, List, Optional # noqa + +FORMAT_DER = 0 +FORMAT_PEM = 1 + +if hasattr(m2, "VERIFY_ALLOW_PROXY_CERTS"): + verify_allow_proxy_certs = m2.VERIFY_ALLOW_PROXY_CERTS +if hasattr(m2, "VERIFY_CB_ISSUER_CHECK"): + verify_cb_issuer_check = m2.VERIFY_CB_ISSUER_CHECK +if hasattr(m2, "VERIFY_CHECK_SS_SIGNATURE"): + verify_check_ss_signature = m2.VERIFY_CHECK_SS_SIGNATURE +if hasattr(m2, "VERIFY_CRL_CHECK"): + verify_crl_check = m2.VERIFY_CRL_CHECK +if hasattr(m2, "VERIFY_CRL_CHECK_ALL"): + verify_crl_check_all = m2.VERIFY_CRL_CHECK_ALL +if hasattr(m2, "VERIFY_EXPLICIT_POLICY"): + verify_explicit_policy = m2.VERIFY_EXPLICIT_POLICY +if hasattr(m2, "VERIFY_EXTENDED_CRL_SUPPORT"): + verify_extended_crl_support = m2.VERIFY_EXTENDED_CRL_SUPPORT +if hasattr(m2, "VERIFY_IGNORE_CRITICAL"): + verify_ignore_critical = m2.VERIFY_IGNORE_CRITICAL +if hasattr(m2, "VERIFY_INHIBIT_ANY"): + verify_inhibit_any = m2.VERIFY_INHIBIT_ANY +if hasattr(m2, "VERIFY_INHIBIT_MAP"): + verify_inhibit_map = m2.VERIFY_INHIBIT_MAP +if hasattr(m2, "VERIFY_NO_ALT_CHAINS"): + verify_no_alt_chains = m2.VERIFY_NO_ALT_CHAINS +if hasattr(m2, "VERIFY_NO_CHECK_TIME"): + verify_no_check_time = m2.VERIFY_NO_CHECK_TIME +if hasattr(m2, "VERIFY_NOTIFY_POLICY"): + verify_notify_policy = m2.VERIFY_NOTIFY_POLICY +if hasattr(m2, "VERIFY_PARTIAL_CHAIN"): + verify_partial_chain = m2.VERIFY_PARTIAL_CHAIN +if hasattr(m2, "VERIFY_POLICY_CHECK"): + verify_policy_check = m2.VERIFY_POLICY_CHECK +if hasattr(m2, "VERIFY_TRUSTED_FIRST"): + verify_trusted_first = m2.VERIFY_TRUSTED_FIRST +if hasattr(m2, "VERIFY_USE_DELTAS"): + verify_use_deltas = m2.VERIFY_USE_DELTAS +if hasattr(m2, "VERIFY_X509_STRICT"): + verify_x509_strict = m2.VERIFY_X509_STRICT + +log = logging.getLogger(__name__) + + +class X509Error(ValueError): + pass + + +m2.x509_init(X509Error) + +V_OK = m2.X509_V_OK # type: int + + +def x509_store_default_cb(ok, ctx): + # type: (int, X509_Store_Context) -> int + return ok + + +def new_extension(name, value, critical=0, _pyfree=1): + # type: (str, bytes, int, int) -> X509_Extension + """ + Create new X509_Extension instance. + """ + if name == 'subjectKeyIdentifier' and \ + value.strip('0123456789abcdefABCDEF:') != '': + raise ValueError('value must be precomputed hash') + ctx = m2.x509v3_set_nconf() + x509_ext_ptr = m2.x509v3_ext_conf(None, ctx, name, value) + if x509_ext_ptr is None: + raise X509Error( + "Cannot create X509_Extension with name '%s' and value '%s'" % + (name, value)) + x509_ext = X509_Extension(x509_ext_ptr, _pyfree) + x509_ext.set_critical(critical) + return x509_ext + + +class X509_Extension(object): + """ + X509 Extension + """ + + m2_x509_extension_free = m2.x509_extension_free + + def __init__(self, x509_ext_ptr=None, _pyfree=1): + # type: (Optional[bytes], int) -> None + self.x509_ext = x509_ext_ptr + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0) and self.x509_ext: + self.m2_x509_extension_free(self.x509_ext) + + def _ptr(self): + # type: () -> bytes + return self.x509_ext + + def set_critical(self, critical=1): + # type: (int) -> int + """ + Mark this extension critical or noncritical. By default an + extension is not critical. + + :param critical: Nonzero sets this extension as critical. + Calling this method without arguments will + set this extension to critical. + :return: 1 for success, 0 for failure + """ + return m2.x509_extension_set_critical(self.x509_ext, critical) + + def get_critical(self): + # type: () -> int + """ + Return whether or not this is a critical extension. + + :return: Nonzero if this is a critical extension. + """ + return m2.x509_extension_get_critical(self.x509_ext) + + def get_name(self): + # type: () -> str + """ + Get the extension name, for example 'subjectAltName'. + """ + return six.ensure_text(m2.x509_extension_get_name(self.x509_ext)) + + def get_value(self, flag=0, indent=0): + # type: (int, int) -> str + """ + Get the extension value, for example 'DNS:www.example.com'. + + :param flag: Flag to control what and how to print. + :param indent: How many spaces to print before actual value. + """ + buf = BIO.MemoryBuffer() + m2.x509_ext_print(buf.bio_ptr(), self.x509_ext, flag, indent) + return six.ensure_text(buf.read_all()) + + +class X509_Extension_Stack(object): + """ + X509 Extension Stack + + :warning: Do not modify the underlying OpenSSL stack + except through this interface, or use any OpenSSL + functions that do so indirectly. Doing so will get the + OpenSSL stack and the internal pystack of this class out + of sync, leading to python memory leaks, exceptions or + even python crashes! + """ + + m2_sk_x509_extension_free = m2.sk_x509_extension_free + + def __init__(self, stack=None, _pyfree=0): + # type: (Optional[bytes], int) -> None + if stack is not None: + self.stack = stack + self._pyfree = _pyfree + num = m2.sk_x509_extension_num(self.stack) + for i in range(num): + self.pystack.append(X509_Extension( + m2.sk_x509_extension_value(self.stack, i), + _pyfree=_pyfree)) + else: + self.stack = m2.sk_x509_extension_new_null() + self._pyfree = 1 + self.pystack = [] # This must be kept in sync with self.stack + + def __del__(self): + # type: () -> None + # see BIO.py - unbalanced __init__ / __del__ + if getattr(self, '_pyfree', 0): + self.m2_sk_x509_extension_free(self.stack) + + def __len__(self): + # type: () -> int + assert m2.sk_x509_extension_num(self.stack) == len(self.pystack) + return len(self.pystack) + + def __getitem__(self, idx): + # type: (int) -> X509_Extension + return self.pystack[idx] + + def __iter__(self): + return iter(self.pystack) + + def _ptr(self): + # type: () -> bytes + return self.stack + + def push(self, x509_ext): + # type: (X509_Extension) -> int + """ + Push X509_Extension object onto the stack. + + :param x509_ext: X509_Extension object to be pushed onto the stack. + :return: The number of extensions on the stack. + """ + self.pystack.append(x509_ext) + ret = m2.sk_x509_extension_push(self.stack, x509_ext._ptr()) + assert ret == len(self.pystack) + return ret + + def pop(self): + # type: () -> X509_Extension + """ + Pop X509_Extension object from the stack. + + :return: X509_Extension popped + """ + x509_ext_ptr = m2.sk_x509_extension_pop(self.stack) + if x509_ext_ptr is None: + assert len(self.pystack) == 0 + return None + return self.pystack.pop() + + +class X509_Name_Entry(object): + """ + X509 Name Entry + """ + + m2_x509_name_entry_free = m2.x509_name_entry_free + + def __init__(self, x509_name_entry, _pyfree=0): + # type: (bytes, int) -> None + """ + :param x509_name_entry: this should be OpenSSL X509_NAME_ENTRY binary + :param _pyfree: + """ + self.x509_name_entry = x509_name_entry + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_x509_name_entry_free(self.x509_name_entry) + + def _ptr(self): + # type: () -> bytes + return self.x509_name_entry + + def set_object(self, asn1obj): + # type: (ASN1.ASN1_Object) -> int + """ + Sets the field name to asn1obj + + :param asn1obj: + :return: 0 on failure, 1 on success + """ + return m2.x509_name_entry_set_object(self.x509_name_entry, + asn1obj._ptr()) + + def set_data(self, data, type=ASN1.MBSTRING_ASC): + # type: (bytes, int) -> int + """ + Sets the field name to asn1obj + + :param data: data in a binary form to be set + :return: 0 on failure, 1 on success + """ + return m2.x509_name_entry_set_data(self.x509_name_entry, type, data) + + def get_object(self): + # type: () -> ASN1.ASN1_Object + return ASN1.ASN1_Object( + m2.x509_name_entry_get_object(self.x509_name_entry)) + + def get_data(self): + # type: () -> ASN1.ASN1_String + return ASN1.ASN1_String( + m2.x509_name_entry_get_data(self.x509_name_entry)) + + def create_by_txt(self, field, type, entry, len): + return m2.x509_name_entry_create_by_txt(self.x509_name_entry._ptr(), + field, type, entry, len) + + +class X509_Name(object): + """ + X509 Name + """ + + nid = {'C': m2.NID_countryName, + 'SP': m2.NID_stateOrProvinceName, + 'ST': m2.NID_stateOrProvinceName, + 'stateOrProvinceName': m2.NID_stateOrProvinceName, + 'L': m2.NID_localityName, + 'localityName': m2.NID_localityName, + 'O': m2.NID_organizationName, + 'organizationName': m2.NID_organizationName, + 'OU': m2.NID_organizationalUnitName, + 'organizationUnitName': m2.NID_organizationalUnitName, + 'CN': m2.NID_commonName, + 'commonName': m2.NID_commonName, + 'Email': m2.NID_pkcs9_emailAddress, + 'emailAddress': m2.NID_pkcs9_emailAddress, + 'serialNumber': m2.NID_serialNumber, + 'SN': m2.NID_surname, + 'surname': m2.NID_surname, + 'GN': m2.NID_givenName, + 'givenName': m2.NID_givenName + } + + m2_x509_name_free = m2.x509_name_free + + def __init__(self, x509_name=None, _pyfree=0): + # type: (bytes, int) -> None + """ + :param x509_name: this should be OpenSSL X509_NAME binary + :param _pyfree: + """ + if x509_name is not None: + assert m2.x509_name_type_check(x509_name), "'x509_name' type error" + self.x509_name = x509_name + self._pyfree = _pyfree + else: + self.x509_name = m2.x509_name_new() + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_x509_name_free(self.x509_name) + + def __str__(self): + # type: () -> bytes + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + return m2.x509_name_oneline(self.x509_name) + + def __getattr__(self, attr): + # type: (str) -> str + if attr in self.nid: + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + return six.ensure_text(m2.x509_name_by_nid(self.x509_name, self.nid[attr])) + + if attr in self.__dict__: + return self.__dict__[attr] + + raise AttributeError(self, attr) + + def __setattr__(self, attr, value): + # type: (str, AnyStr) -> int + """ + :return: 1 for success of 0 if an error occurred. + """ + if attr in self.nid: + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + return m2.x509_name_set_by_nid(self.x509_name, self.nid[attr], + six.ensure_binary(value)) + + self.__dict__[attr] = value + + def __len__(self): + # type: () -> int + return m2.x509_name_entry_count(self.x509_name) + + def __getitem__(self, idx): + # type: (int) -> X509_Name_Entry + if not 0 <= idx < self.entry_count(): + raise IndexError("index out of range") + return X509_Name_Entry(m2.x509_name_get_entry(self.x509_name, idx)) + + def __iter__(self): + for i in range(self.entry_count()): + yield self[i] + + def _ptr(self): + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + return self.x509_name + + def add_entry_by_txt(self, field, type, entry, len, loc, set): + # entry_type: (str, int, bytes, int, int, int) -> int + """ + Add X509_Name field whose name is identified by its name. + + :param field: name of the entry + :param type: use MBSTRING_ASC or MBSTRING_UTF8 + (or standard ASN1 type like V_ASN1_IA5STRING) + :param entry: value + :param len: buf_len of the entry + (-1 and the length is computed automagically) + + The ``loc`` and ``set`` parameters determine where a new entry + should be added. + For almost all applications loc can be set to -1 and set to 0. + This adds a new entry to the end of name as a single valued + RelativeDistinguishedName (RDN). + + :param loc: determines the index where the new entry is + inserted: if it is -1 it is appended. + :param set: determines how the new type is added. If it is zero + a new RDN is created. + If set is -1 or 1 it is added to the previous or next RDN + structure respectively. This will then be a multivalued + RDN: since multivalues RDNs are very seldom used set is + almost always set to zero. + + :return: 1 for success of 0 if an error occurred. + """ + return m2.x509_name_add_entry_by_txt(self.x509_name, + six.ensure_str(field), type, + six.ensure_str(entry), len, loc, set) + + def entry_count(self): + # type: () -> int + return m2.x509_name_entry_count(self.x509_name) + + def get_entries_by_nid(self, nid): + # type: (int) -> List[X509_Name_Entry] + """ + Retrieve the next index matching nid. + + :param nid: name of the entry (as m2.NID* constants) + + :return: list of X509_Name_Entry items + """ + ret = [] + lastpos = -1 + + while True: + lastpos = m2.x509_name_get_index_by_nid(self.x509_name, nid, + lastpos) + if lastpos == -1: + break + + ret.append(self[lastpos]) + + return ret + + def as_text(self, indent=0, flags=m2.XN_FLAG_COMPAT): + # type: (int, int) -> str + """ + as_text returns the name as a string. + + :param indent: Each line in multiline format is indented + by this many spaces. + :param flags: Flags that control how the output should be formatted. + """ + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + buf = BIO.MemoryBuffer() + m2.x509_name_print_ex(buf.bio_ptr(), self.x509_name, indent, flags) + return six.ensure_text(buf.read_all()) + + def as_der(self): + # type: () -> bytes + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + return m2.x509_name_get_der(self.x509_name) + + def as_hash(self): + # type: () -> int + assert m2.x509_name_type_check(self.x509_name), \ + "'x509_name' type error" + return m2.x509_name_hash(self.x509_name) + + +class X509(object): + """ + X.509 Certificate + """ + + m2_x509_free = m2.x509_free + + def __init__(self, x509=None, _pyfree=0): + # type: (Optional[bytes], int) -> None + """ + :param x509: binary representation of + the underlying OpenSSL X509 object. + :param _pyfree: + """ + if x509 is not None: + assert m2.x509_type_check(x509), "'x509' type error" + self.x509 = x509 + self._pyfree = _pyfree + else: + self.x509 = m2.x509_new() + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_x509_free(self.x509) + + def _ptr(self): + # type: () -> bytes + assert m2.x509_type_check(self.x509), "'x509' type error" + return self.x509 + + def as_text(self): + # type: () -> str + assert m2.x509_type_check(self.x509), "'x509' type error" + buf = BIO.MemoryBuffer() + m2.x509_print(buf.bio_ptr(), self.x509) + return six.ensure_text(buf.read_all()) + + def as_der(self): + # type: () -> bytes + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.i2d_x509(self.x509) + + def as_pem(self): + # type: () -> bytes + buf = BIO.MemoryBuffer() + m2.x509_write_pem(buf.bio_ptr(), self.x509) + return buf.read_all() + + def save_pem(self, filename): + # type: (AnyStr) -> int + """ + :param filename: name of the file to be loaded + :return: 1 for success or 0 for failure + """ + with BIO.openfile(filename, 'wb') as bio: + return m2.x509_write_pem(bio.bio_ptr(), self.x509) + + def save(self, filename, format=FORMAT_PEM): + # type: (AnyStr, int) -> int + """ + Saves X.509 certificate to a file. Default output + format is PEM. + + :param filename: Name of the file the cert will be saved to. + + :param format: Controls what output format is used to save the cert. + Either FORMAT_PEM or FORMAT_DER to save in PEM or + DER format. Raises a ValueError if an unknow + format is used. + + :return: 1 for success or 0 for failure + """ + with BIO.openfile(filename, 'wb') as bio: + if format == FORMAT_PEM: + return m2.x509_write_pem(bio.bio_ptr(), self.x509) + elif format == FORMAT_DER: + return m2.i2d_x509_bio(bio.bio_ptr(), self.x509) + else: + raise ValueError( + "Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER") + + def set_version(self, version): + # type: (int) -> int + """ + Set version of the certificate. + + :param version: Version number. + :return: Returns 0 on failure. + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_version(self.x509, version) + + def set_not_before(self, asn1_time): + # type: (ASN1.ASN1_TIME) -> int + """ + :return: 1 on success, 0 on failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_not_before(self.x509, asn1_time._ptr()) + + def set_not_after(self, asn1_time): + # type: (ASN1.ASN1_TIME) -> int + """ + :return: 1 on success, 0 on failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_not_after(self.x509, asn1_time._ptr()) + + def set_subject_name(self, name): + # type: (X509_Name) -> int + """ + :return: 1 on success, 0 on failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_subject_name(self.x509, name.x509_name) + + def set_issuer_name(self, name): + # type: (X509_Name) -> int + """ + :return: 1 on success, 0 on failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_issuer_name(self.x509, name.x509_name) + + def get_version(self): + # type: () -> int + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_get_version(self.x509) + + def get_serial_number(self): + # type: () -> ASN1.ASN1_Integer + assert m2.x509_type_check(self.x509), "'x509' type error" + asn1_integer = m2.x509_get_serial_number(self.x509) + return m2.asn1_integer_get(asn1_integer) + + def set_serial_number(self, serial): + # type: (ASN1.ASN1_Integer) -> int + """ + Set serial number. + + :param serial: Serial number. + + :return 1 for success and 0 for failure. + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + # This "magically" changes serial since asn1_integer + # is C pointer to x509's internal serial number. + asn1_integer = m2.x509_get_serial_number(self.x509) + return m2.asn1_integer_set(asn1_integer, serial) + # XXX Or should I do this? + # asn1_integer = m2.asn1_integer_new() + # m2.asn1_integer_set(asn1_integer, serial) + # return m2.x509_set_serial_number(self.x509, asn1_integer) + + def get_not_before(self): + # type: () -> ASN1.ASN1_TIME + assert m2.x509_type_check(self.x509), "'x509' type error" + return ASN1.ASN1_TIME(m2.x509_get_not_before(self.x509)) + + def get_not_after(self): + # type: () -> ASN1.ASN1_TIME + assert m2.x509_type_check(self.x509), "'x509' type error" + out = ASN1.ASN1_TIME(m2.x509_get_not_after(self.x509)) + if 'Bad time value' in str(out): + raise X509Error( + '''M2Crypto cannot handle dates after year 2050. + See RFC 5280 4.1.2.5 for more information. + ''') + return out + + def get_pubkey(self): + # type: () -> EVP.PKey + assert m2.x509_type_check(self.x509), "'x509' type error" + return EVP.PKey(m2.x509_get_pubkey(self.x509), _pyfree=1) + + def set_pubkey(self, pkey): + # type: (EVP.PKey) -> int + """ + Set the public key for the certificate + + :param pkey: Public key + + :return 1 for success and 0 for failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_pubkey(self.x509, pkey.pkey) + + def get_issuer(self): + # type: () -> X509_Name + assert m2.x509_type_check(self.x509), "'x509' type error" + return X509_Name(m2.x509_get_issuer_name(self.x509)) + + def set_issuer(self, name): + # type: (X509_Name) -> int + """ + Set issuer name. + + :param name: subjectName field. + + :return 1 for success and 0 for failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_issuer_name(self.x509, name.x509_name) + + def get_subject(self): + # type: () -> X509_Name + assert m2.x509_type_check(self.x509), "'x509' type error" + return X509_Name(m2.x509_get_subject_name(self.x509)) + + def set_subject(self, name): + # type: (X509_Name) -> int + """ + Set subject name. + + :param name: subjectName field. + + :return 1 for success and 0 for failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_set_subject_name(self.x509, name.x509_name) + + def add_ext(self, ext): + # type: (X509_Extension) -> int + """ + Add X509 extension to this certificate. + + :param ext: Extension + + :return 1 for success and 0 for failure + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + return m2.x509_add_ext(self.x509, ext.x509_ext, -1) + + def get_ext(self, name): + # type: (str) -> X509_Extension + """ + Get X509 extension by name. + + :param name: Name of the extension + + :return: X509_Extension + """ + # Optimizations to reduce attribute accesses + m2x509_get_ext = m2.x509_get_ext + m2x509_extension_get_name = m2.x509_extension_get_name + x509 = self.x509 + + name = six.ensure_binary(name) + for i in range(m2.x509_get_ext_count(x509)): + ext_ptr = m2x509_get_ext(x509, i) + if m2x509_extension_get_name(ext_ptr) == name: + return X509_Extension(ext_ptr, _pyfree=0) + + raise LookupError + + def get_ext_at(self, index): + # type: (int) -> X509_Extension + """ + Get X509 extension by index. + + :param index: Name of the extension + + :return: X509_Extension + """ + if index < 0 or index >= self.get_ext_count(): + raise IndexError + + return X509_Extension(m2.x509_get_ext(self.x509, index), + _pyfree=0) + + def get_ext_count(self): + # type: () -> int + """ + Get X509 extension count. + """ + return m2.x509_get_ext_count(self.x509) + + def sign(self, pkey, md): + # type: (EVP.PKey, str) -> int + """ + Sign the certificate. + + :param pkey: Public key + + :param md: Message digest algorithm to use for signing, + for example 'sha1'. + + :return int + """ + assert m2.x509_type_check(self.x509), "'x509' type error" + mda = getattr(m2, md, None) + if mda is None: + raise ValueError('unknown message digest', md) + return m2.x509_sign(self.x509, pkey.pkey, mda()) + + def verify(self, pkey=None): + # type: (Optional[EVP.PKey]) -> int + assert m2.x509_type_check(self.x509), "'x509' type error" + if pkey: + return m2.x509_verify(self.x509, pkey.pkey) + else: + return m2.x509_verify(self.x509, self.get_pubkey().pkey) + + def check_ca(self): + # type: () -> int + """ + Check if the certificate is a Certificate Authority (CA) certificate. + + :return: 0 if the certificate is not CA, nonzero otherwise. + + :requires: OpenSSL 0.9.8 or newer + """ + return m2.x509_check_ca(self.x509) + + def check_purpose(self, id, ca): + # type: (int, int) -> int + """ + Check if the certificate's purpose matches the asked purpose. + + :param id: Purpose id. See X509_PURPOSE_* constants. + + :param ca: 1 if the certificate should be CA, 0 otherwise. + + :return: 0 if the certificate purpose does not match, nonzero + otherwise. + """ + return m2.x509_check_purpose(self.x509, id, ca) + + def get_fingerprint(self, md='md5'): + # type: (str) -> str + """ + Get the fingerprint of the certificate. + + :param md: Message digest algorithm to use. + + :return: String containing the fingerprint in hex format. + """ + der = self.as_der() + md = EVP.MessageDigest(md) + md.update(der) + digest = md.final() + return six.ensure_text(binascii.hexlify(digest).upper()) + + +def load_cert(file, format=FORMAT_PEM): + # type: (AnyStr, int) -> X509 + """ + Load certificate from file. + + :param file: Name of file containing certificate in either DER or + PEM format. + + :param format: Describes the format of the file to be loaded, + either PEM or DER. + + :return: M2Crypto.X509.X509 object. + """ + with BIO.openfile(file) as bio: + if format == FORMAT_PEM: + return load_cert_bio(bio) + elif format == FORMAT_DER: + cptr = m2.d2i_x509(bio._ptr()) + return X509(cptr, _pyfree=1) + else: + raise ValueError( + "Unknown format. Must be either FORMAT_DER or FORMAT_PEM") + + +def load_cert_bio(bio, format=FORMAT_PEM): + # type: (BIO.BIO, int) -> X509 + """ + Load certificate from a bio. + + :param bio: BIO pointing at a certificate in either DER or PEM format. + + :param format: Describes the format of the cert to be loaded, + either PEM or DER (via constants FORMAT_PEM + and FORMAT_FORMAT_DER) + + :return: M2Crypto.X509.X509 object. + """ + if format == FORMAT_PEM: + cptr = m2.x509_read_pem(bio._ptr()) + elif format == FORMAT_DER: + cptr = m2.d2i_x509(bio._ptr()) + else: + raise ValueError( + "Unknown format. Must be either FORMAT_DER or FORMAT_PEM") + return X509(cptr, _pyfree=1) + + +def load_cert_string(string, format=FORMAT_PEM): + # type: (AnyStr, int) -> X509 + """ + Load certificate from a string. + + :param string: String containing a certificate in either DER or PEM format. + + :param format: Describes the format of the cert to be loaded, + either PEM or DER (via constants FORMAT_PEM + and FORMAT_FORMAT_DER) + + :return: M2Crypto.X509.X509 object. + """ + string = six.ensure_binary(string) + bio = BIO.MemoryBuffer(string) + return load_cert_bio(bio, format) + + +def load_cert_der_string(string): + # type: (AnyStr) -> X509 + """ + Load certificate from a string. + + :param string: String containing a certificate in DER format. + + :return: M2Crypto.X509.X509 object. + """ + string = six.ensure_binary(string) + bio = BIO.MemoryBuffer(string) + cptr = m2.d2i_x509(bio._ptr()) + return X509(cptr, _pyfree=1) + + +class X509_Store_Context(object): + """ + X509 Store Context + """ + + m2_x509_store_ctx_free = m2.x509_store_ctx_free + + def __init__(self, x509_store_ctx, _pyfree=0): + # type: (bytes, int) -> None + """ + + :param x509_store_ctx: binary data for + OpenSSL X509_STORE_CTX type + """ + self.ctx = x509_store_ctx + self._pyfree = _pyfree + + def __del__(self): + # type: () -> None + # see BIO.py - unbalanced __init__ / __del__ + if not hasattr(self, '_pyfree'): + pass # print("OOPS") + elif self._pyfree: + self.m2_x509_store_ctx_free(self.ctx) + + def _ptr(self): + return self.ctx + + def get_current_cert(self): + # type: () -> X509 + """ + Get current X.509 certificate. + + :warning: The returned certificate is NOT refcounted, so you can not + rely on it being valid once the store context goes + away or is modified. + """ + return X509(m2.x509_store_ctx_get_current_cert(self.ctx), _pyfree=0) + + def get_error(self): + # type: () -> int + """ + Get error code. + """ + return m2.x509_store_ctx_get_error(self.ctx) + + def get_error_depth(self): + # type: () -> int + """ + Get error depth. + """ + return m2.x509_store_ctx_get_error_depth(self.ctx) + + def get1_chain(self): + # type: () -> X509_Stack + """ + Get certificate chain. + + :return: Reference counted (i.e. safe to use even after the store + context goes away) stack of certificates in the chain. + """ + return X509_Stack(m2.x509_store_ctx_get1_chain(self.ctx), 1, 1) + + +class X509_Store(object): + """ + X509 Store + """ + + m2_x509_store_free = m2.x509_store_free + + def __init__(self, store=None, _pyfree=0): + # type: (Optional[bytes], int) -> None + """ + :param store: binary data for OpenSSL X509_STORE_CTX type. + """ + if store is not None: + self.store = store + self._pyfree = _pyfree + else: + self.store = m2.x509_store_new() + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_x509_store_free(self.store) + + def _ptr(self): + return self.store + + def load_info(self, file): + # type: (AnyStr) -> int + """ + :param file: filename + + :return: 1 on success, 0 on failure + """ + ret = m2.x509_store_load_locations(self.store, file) + return ret + + load_locations = load_info + + def add_x509(self, x509): + # type: (X509) -> int + assert isinstance(x509, X509) + return m2.x509_store_add_cert(self.store, x509._ptr()) + + def set_verify_cb(self, callback=None): + # type: (Optional[callable]) -> None + """ + Set callback which will be called when the store is verified. + Wrapper over OpenSSL X509_STORE_set_verify_cb(). + + :param callback: Callable to specify verification options. + Type of the callable must be: + (int, X509_Store_Context) -> int. + If None: set the standard options. + + :note: compile-time or run-time errors in the callback would result + in mysterious errors during verification, which could be hard + to trace. + + :note: Python exceptions raised in callbacks do not propagate to + verify() call. + + :return: None + """ + if callback is None: + return self.set_verify_cb(x509_store_default_cb) + + if not callable(callback): + raise X509Error("set_verify(): callback is not callable") + return m2.x509_store_set_verify_cb(self.store, callback) + + add_cert = add_x509 + + def set_flags(self, flags): + # type: (int) -> int + """ + Set the verification flags for the X509Store + Wrapper over OpenSSL X509_STORE_set_flags() + + :param flags: `VERIFICATION FLAGS` section of the + X509_VERIFY_PARAM_set_flags man page has + a complete description of values the flags + parameter can take. + Their M2Crypto equivalent is transformed following + the pattern: "X509_V_FLAG_XYZ" -> lowercase("VERIFY_XYZ") + """ + return m2.x509_store_set_flags(self.store, flags) + + +class X509_Stack(object): + """ + X509 Stack + + :warning: Do not modify the underlying OpenSSL stack + except through this interface, or use any OpenSSL + functions that do so indirectly. Doing so will get the + OpenSSL stack and the internal pystack of this class out + of sync, leading to python memory leaks, exceptions or + even python crashes! + """ + + m2_sk_x509_free = m2.sk_x509_free + + def __init__(self, stack=None, _pyfree=0, _pyfree_x509=0): + # type: (bytes, int, int) -> None + if stack is not None: + self.stack = stack + self._pyfree = _pyfree + self.pystack = [] # This must be kept in sync with self.stack + num = m2.sk_x509_num(self.stack) + for i in range(num): + self.pystack.append(X509(m2.sk_x509_value(self.stack, i), + _pyfree=_pyfree_x509)) + else: + self.stack = m2.sk_x509_new_null() + self._pyfree = 1 + self.pystack = [] # This must be kept in sync with self.stack + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_sk_x509_free(self.stack) + + def __len__(self): + # type: () -> int + assert m2.sk_x509_num(self.stack) == len(self.pystack) + return len(self.pystack) + + def __getitem__(self, idx): + # type: (int) -> X509 + return self.pystack[idx] + + def __iter__(self): + return iter(self.pystack) + + def _ptr(self): + return self.stack + + def push(self, x509): + # type: (X509) -> int + """ + push an X509 certificate onto the stack. + + :param x509: X509 object. + + :return: The number of X509 objects currently on the stack. + """ + assert isinstance(x509, X509) + self.pystack.append(x509) + ret = m2.sk_x509_push(self.stack, x509._ptr()) + assert ret == len(self.pystack) + return ret + + def pop(self): + # type: () -> X509 + """ + pop a certificate from the stack. + + :return: X509 object that was popped, or None if there is + nothing to pop. + """ + x509_ptr = m2.sk_x509_pop(self.stack) + if x509_ptr is None: + assert len(self.pystack) == 0 + return None + return self.pystack.pop() + + def as_der(self): + # type: () -> bytes + """ + Return the stack as a DER encoded string + """ + return m2.get_der_encoding_stack(self.stack) + + +def new_stack_from_der(der_string): + # type: (bytes) -> X509_Stack + """ + Create a new X509_Stack from DER string. + + :return: X509_Stack + """ + der_string = six.ensure_binary(der_string) + stack_ptr = m2.make_stack_from_der_sequence(der_string) + return X509_Stack(stack_ptr, 1, 1) + + +class Request(object): + """ + X509 Certificate Request. + """ + + m2_x509_req_free = m2.x509_req_free + + def __init__(self, req=None, _pyfree=0): + # type: (Optional[int], int) -> None + if req is not None: + self.req = req + self._pyfree = _pyfree + else: + self.req = m2.x509_req_new() + m2.x509_req_set_version(self.req, 0) + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_x509_req_free(self.req) + + def as_text(self): + # type: () -> str + buf = BIO.MemoryBuffer() + m2.x509_req_print(buf.bio_ptr(), self.req) + return six.ensure_text(buf.read_all()) + + def as_pem(self): + # type: () -> bytes + buf = BIO.MemoryBuffer() + m2.x509_req_write_pem(buf.bio_ptr(), self.req) + return buf.read_all() + + def as_der(self): + # type: () -> bytes + buf = BIO.MemoryBuffer() + m2.i2d_x509_req_bio(buf.bio_ptr(), self.req) + return buf.read_all() + + def save_pem(self, filename): + # type: (AnyStr) -> int + with BIO.openfile(filename, 'wb') as bio: + return m2.x509_req_write_pem(bio.bio_ptr(), self.req) + + def save(self, filename, format=FORMAT_PEM): + # type: (AnyStr, int) -> int + """ + Saves X.509 certificate request to a file. Default output + format is PEM. + + :param filename: Name of the file the request will be saved to. + + :param format: Controls what output format is used to save the + request. Either FORMAT_PEM or FORMAT_DER to save + in PEM or DER format. Raises ValueError if an + unknown format is used. + + :return: 1 for success, 0 for failure. + The error code can be obtained by ERR_get_error. + """ + with BIO.openfile(filename, 'wb') as bio: + if format == FORMAT_PEM: + return m2.x509_req_write_pem(bio.bio_ptr(), self.req) + elif format == FORMAT_DER: + return m2.i2d_x509_req_bio(bio.bio_ptr(), self.req) + else: + raise ValueError( + "Unknown filetype. Must be either FORMAT_DER or FORMAT_PEM") + + def get_pubkey(self): + # type: () -> EVP.PKey + """ + Get the public key for the request. + + :return: Public key from the request. + """ + return EVP.PKey(m2.x509_req_get_pubkey(self.req), _pyfree=1) + + def set_pubkey(self, pkey): + # type: (EVP.PKey) -> int + """ + Set the public key for the request. + + :param pkey: Public key + + :return: Return 1 for success and 0 for failure. + """ + return m2.x509_req_set_pubkey(self.req, pkey.pkey) + + def get_version(self): + # type: () -> int + """ + Get version. + + :return: Returns version. + """ + return m2.x509_req_get_version(self.req) + + def set_version(self, version): + # type: (int) -> int + """ + Set version. + + :param version: Version number. + :return: Returns 0 on failure. + """ + return m2.x509_req_set_version(self.req, version) + + def get_subject(self): + # type: () -> X509_Name + return X509_Name(m2.x509_req_get_subject_name(self.req)) + + def set_subject_name(self, name): + # type: (X509_Name) -> int + """ + Set subject name. + + :param name: subjectName field. + :return: 1 for success and 0 for failure + """ + return m2.x509_req_set_subject_name(self.req, name.x509_name) + + set_subject = set_subject_name + + def add_extensions(self, ext_stack): + # type: (X509_Extension_Stack) -> int + """ + Add X509 extensions to this request. + + :param ext_stack: Stack of extensions to add. + :return: 1 for success and 0 for failure + """ + return m2.x509_req_add_extensions(self.req, ext_stack._ptr()) + + def verify(self, pkey): + # type: (EVP.PKey) -> int + """ + + :param pkey: PKey to be verified + :return: 1 for success and 0 for failure + """ + return m2.x509_req_verify(self.req, pkey.pkey) + + def sign(self, pkey, md): + # type: (EVP.PKey, str) -> int + """ + + :param pkey: PKey to be signed + :param md: used algorigthm + :return: 1 for success and 0 for failure + """ + mda = getattr(m2, md, None) + if mda is None: + raise ValueError('unknown message digest', md) + return m2.x509_req_sign(self.req, pkey.pkey, mda()) + + +def load_request(file, format=FORMAT_PEM): + # type: (AnyStr, int) -> Request + """ + Load certificate request from file. + + :param file: Name of file containing certificate request in + either PEM or DER format. + :param format: Describes the format of the file to be loaded, + either PEM or DER. (using constants FORMAT_PEM + and FORMAT_DER) + :return: Request object. + """ + with BIO.openfile(file) as f: + if format == FORMAT_PEM: + cptr = m2.x509_req_read_pem(f.bio_ptr()) + elif format == FORMAT_DER: + cptr = m2.d2i_x509_req(f.bio_ptr()) + else: + raise ValueError( + "Unknown filetype. Must be either FORMAT_PEM or FORMAT_DER") + + return Request(cptr, 1) + + +def load_request_bio(bio, format=FORMAT_PEM): + # type: (BIO.BIO, int) -> Request + """ + Load certificate request from a bio. + + :param bio: BIO pointing at a certificate request in + either DER or PEM format. + :param format: Describes the format of the request to be loaded, + either PEM or DER. (using constants FORMAT_PEM + and FORMAT_DER) + :return: M2Crypto.X509.Request object. + """ + if format == FORMAT_PEM: + cptr = m2.x509_req_read_pem(bio._ptr()) + elif format == FORMAT_DER: + cptr = m2.d2i_x509_req(bio._ptr()) + else: + raise ValueError( + "Unknown format. Must be either FORMAT_DER or FORMAT_PEM") + + return Request(cptr, _pyfree=1) + + +def load_request_string(string, format=FORMAT_PEM): + # type: (AnyStr, int) -> Request + """ + Load certificate request from a string. + + :param string: String containing a certificate request in + either DER or PEM format. + :param format: Describes the format of the request to be loaded, + either PEM or DER. (using constants FORMAT_PEM + and FORMAT_DER) + + :return: M2Crypto.X509.Request object. + """ + string = six.ensure_binary(string) + bio = BIO.MemoryBuffer(string) + return load_request_bio(bio, format) + + +def load_request_der_string(string): + # type: (AnyStr) -> Request + """ + Load certificate request from a string. + + :param string: String containing a certificate request in DER format. + :return: M2Crypto.X509.Request object. + """ + string = six.ensure_binary(string) + bio = BIO.MemoryBuffer(string) + return load_request_bio(bio, FORMAT_DER) + + +class CRL(object): + """ + X509 Certificate Revocation List + """ + + m2_x509_crl_free = m2.x509_crl_free + + def __init__(self, crl=None, _pyfree=0): + # type: (Optional[bytes], int) -> None + """ + + :param crl: binary representation of + the underlying OpenSSL X509_CRL object. + """ + if crl is not None: + self.crl = crl + self._pyfree = _pyfree + else: + self.crl = m2.x509_crl_new() + self._pyfree = 1 + + def __del__(self): + # type: () -> None + if getattr(self, '_pyfree', 0): + self.m2_x509_crl_free(self.crl) + + def as_text(self): + # type: () -> str + """ + Return CRL in PEM format in a string. + + :return: String containing the CRL in PEM format. + """ + buf = BIO.MemoryBuffer() + m2.x509_crl_print(buf.bio_ptr(), self.crl) + return six.ensure_text(buf.read_all()) + + +def load_crl(file): + # type: (AnyStr) -> CRL + """ + Load CRL from file. + + :param file: Name of file containing CRL in PEM format. + + :return: M2Crypto.X509.CRL object. + """ + with BIO.openfile(file) as f: + cptr = m2.x509_crl_read_pem(f.bio_ptr()) + + return CRL(cptr, 1) diff --git a/src/M2Crypto/__init__.py b/src/M2Crypto/__init__.py new file mode 100644 index 0000000..4fc489f --- /dev/null +++ b/src/M2Crypto/__init__.py @@ -0,0 +1,41 @@ +from __future__ import absolute_import + +""" +M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, +DH, EC, HMACs, message digests, symmetric ciphers (including AES); SSL +functionality to implement clients and servers; HTTPS extensions to +Python's httplib, urllib, and xmlrpclib; unforgeable HMAC'ing AuthCookies +for web session management; FTP/TLS client and server; S/MIME; ZServerSSL: +A HTTPS server for Zope and ZSmime: An S/MIME messenger for Zope. +M2Crypto can also be used to provide SSL for Twisted. Smartcards supported +through the Engine interface. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + +Portions created by Open Source Applications Foundation (OSAF) are +Copyright (C) 2004-2007 OSAF. All Rights Reserved. + +Copyright 2008-2011 Heikki Toivonen. All rights reserved. +""" +# noqa +from distutils.version import StrictVersion +__version__ = '0.37.1' +version = __version__ # type: str +version_info = StrictVersion(__version__).version + +from M2Crypto import (ASN1, AuthCookie, BIO, BN, DH, DSA, EVP, Engine, Err, + RSA, Rand, SMIME, SSL, X509, m2crypto, ftpslib, + httpslib, m2, m2urllib, m2xmlrpclib, threading, + util) + +if m2.OPENSSL_VERSION_NUMBER >= 0x90800F and m2.OPENSSL_NO_EC == 0: + from M2Crypto import EC +if m2.OPENSSL_NO_RC4 == 0: + from M2Crypto import RC4 +# Backwards compatibility. +urllib2 = m2urllib + +encrypt = 1 +decrypt = 0 + +m2crypto.lib_init() diff --git a/src/M2Crypto/callback.py b/src/M2Crypto/callback.py new file mode 100644 index 0000000..c6f54d8 --- /dev/null +++ b/src/M2Crypto/callback.py @@ -0,0 +1,11 @@ +from __future__ import absolute_import + +"""Deprecated, use the util module instead. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +import warnings + +warnings.warn('Use the util module instead', DeprecationWarning) + +from M2Crypto.util import genparam_callback, passphrase_callback diff --git a/src/M2Crypto/ftpslib.py b/src/M2Crypto/ftpslib.py new file mode 100644 index 0000000..e996981 --- /dev/null +++ b/src/M2Crypto/ftpslib.py @@ -0,0 +1,91 @@ +from __future__ import absolute_import + +"""M2Crypto client-side FTP/TLS. + +This implementation complies with draft-murray-auth-ftp-ssl-07.txt. + +Example: + +>>> from M2Crypto import ftpslib +>>> f = ftpslib.FTP_TLS() +>>> f.connect('', 9021) +'220 spinnaker.dyndns.org M2Crypto (Medusa) FTP/TLS server v0.07 ready.' +>>> f.auth_tls() +>>> f.set_pasv(0) +>>> f.login('ftp', 'ngps@') +'230 Ok.' +>>> f.retrlines('LIST') +-rw-rw-r-- 1 0 198 2326 Jul 3 1996 apache_pb.gif +drwxrwxr-x 7 0 198 1536 Oct 10 2000 manual +drwxrwxr-x 2 0 198 512 Oct 31 2000 modpy +drwxrwxr-x 2 0 198 512 Oct 31 2000 bobo +drwxr-xr-x 2 0 198 14336 May 28 15:54 postgresql +drwxr-xr-x 4 100 198 512 May 16 17:19 home +drwxr-xr-x 7 100 100 3584 Sep 23 2000 openacs +drwxr-xr-x 10 0 0 512 Aug 5 2000 python1.5 +-rw-r--r-- 1 100 198 326 Jul 29 03:29 index.html +drwxr-xr-x 12 0 0 512 May 31 17:08 python2.1 +'226 Transfer complete' +>>> f.quit() +'221 Goodbye.' +>>> + + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +# We want to import whole stdlib ftplib objects, because our users want +# to use them. +from ftplib import * # noqa + +# M2Crypto +from M2Crypto import SSL + + +class FTP_TLS(FTP): + + """Python OO interface to client-side FTP/TLS.""" + + def __init__(self, host=None, ssl_ctx=None): + """Initialise the client. If 'host' is supplied, connect to it.""" + if ssl_ctx is not None: + self.ssl_ctx = ssl_ctx + else: + self.ssl_ctx = SSL.Context() + FTP.__init__(self, host) + self.prot = 0 + + def auth_tls(self): + """Secure the control connection per AUTH TLS, aka AUTH TLS-C.""" + self.voidcmd('AUTH TLS') + s = SSL.Connection(self.ssl_ctx, self.sock) + s.setup_ssl() + s.set_connect_state() + s.connect_ssl() + self.sock = s + self.file = self.sock.makefile() + + def auth_ssl(self): + """Secure the control connection per AUTH SSL, aka AUTH TLS-P.""" + raise NotImplementedError + + def prot_p(self): + """Set up secure data connection.""" + self.voidcmd('PBSZ 0') + self.voidcmd('PROT P') + self.prot = 1 + + def prot_c(self): + """Set up data connection in the clear.""" + self.voidcmd('PROT C') + self.prot = 0 + + def ntransfercmd(self, cmd, rest=None): + """Initiate a data transfer.""" + conn, size = FTP.ntransfercmd(self, cmd, rest) + if self.prot: + conn = SSL.Connection(self.ssl_ctx, conn) + conn.setup_ssl() + conn.set_connect_state() + conn.set_session(self.sock.get_session()) + conn.connect_ssl() + return conn, size diff --git a/src/M2Crypto/httpslib.py b/src/M2Crypto/httpslib.py new file mode 100644 index 0000000..0deee64 --- /dev/null +++ b/src/M2Crypto/httpslib.py @@ -0,0 +1,268 @@ +from __future__ import absolute_import + +import warnings + +"""M2Crypto support for Python's httplib. + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved.""" + +import base64 +import socket + +from M2Crypto import SSL, six +from M2Crypto.six.moves.urllib_parse import urlsplit, urlunsplit +from M2Crypto.six.moves.http_client import * # noqa +# This is not imported with just '*' +from M2Crypto.six.moves.http_client import HTTPS_PORT +from typing import Any, AnyStr, Callable, Dict, Optional # noqa + + +class HTTPSConnection(HTTPConnection): + + """ + This class allows communication via SSL using M2Crypto. + """ + + default_port = HTTPS_PORT + + def __init__(self, host, port=None, strict=None, **ssl): + # type: (str, Optional[int], Optional[bool], **Any) -> None + """ + Represents one transaction with an HTTP server over the SSL + connection. + + :param host: host name + :param port: port number + :param strict: if switched on, it raises BadStatusLine to be + raised if the status line can't be parsed as + a valid HTTP/1.0 or 1.1 status line. + :param ssl: dict with all remaining named real parameters of the + function. Specifically, ``ssl_context`` is expected + to be included with SSL.Context; if it is not + default ``'sslv23'`` is substituted). + """ + self.session = None # type: bytes + self.host = host + self.port = port + keys = set(ssl.keys()) - set(('key_file', 'cert_file', 'ssl_context')) + if keys: + raise ValueError('unknown keyword argument: %s', keys) + try: + self.ssl_ctx = ssl['ssl_context'] + assert isinstance(self.ssl_ctx, SSL.Context), self.ssl_ctx + except KeyError: + self.ssl_ctx = SSL.Context() + HTTPConnection.__init__(self, host, port, strict) + + def connect(self): + # type: () -> None + error = None + # We ignore the returned sockaddr because SSL.Connection.connect needs + # a host name. + for (family, _, _, _, _) in \ + socket.getaddrinfo(self.host, self.port, 0, + socket.SOCK_STREAM): + sock = None + try: + sock = SSL.Connection(self.ssl_ctx, family=family) + + # set SNI server name since we know it at this point + sock.set_tlsext_host_name(self.host) + + if self.session is not None: + sock.set_session(self.session) + sock.connect((self.host, self.port)) + + self.sock = sock + sock = None + return + except socket.error as e: + # Other exception are probably SSL-related, in that case we + # abort and the exception is forwarded to the caller. + error = e + finally: + if sock is not None: + sock.close() + + if error is None: + raise AssertionError("Empty list returned by getaddrinfo") + raise error + + def close(self): + # type: () -> None + # This kludges around line 545 of httplib.py, + # which closes the connection in this object; + # the connection remains open in the response + # object. + # + # M2Crypto doesn't close-here-keep-open-there, + # so, in effect, we don't close until the whole + # business is over and gc kicks in. + # + # XXX Long-running callers beware leakage. + # + # XXX 05-Jan-2002: This module works with Python 2.2, + # XXX but I've not investigated if the above conditions + # XXX remain. + pass + + def get_session(self): + # type: () -> SSL.Session.Session + return self.sock.get_session() + + def set_session(self, session): + # type: (SSL.Session.Session) -> None + self.session = session + + +class ProxyHTTPSConnection(HTTPSConnection): + """ + An HTTPS Connection that uses a proxy and the CONNECT request. + + When the connection is initiated, CONNECT is first sent to the proxy (along + with authorization headers, if supplied). If successful, an SSL connection + will be established over the socket through the proxy and to the target + host. + + Finally, the actual request is sent over the SSL connection tunneling + through the proxy. + """ + + _ports = {'http': 80, 'https': 443} + _AUTH_HEADER = "Proxy-Authorization" + _UA_HEADER = "User-Agent" + + def __init__(self, host, port=None, strict=None, username=None, + password=None, **ssl): + # type: (str, Optional[int], Optional[bool], Optional[AnyStr], Optional[AnyStr], **Any) -> None + """ + Create the ProxyHTTPSConnection object. + + :param host: host name of the proxy server + :param port: port number of the proxy server + :param strict: if switched on, it raises BadStatusLine to be + raised if the status line can't be parsed as + a valid HTTP/1.0 or 1.1 status line. + :param username: username on the proxy server, when required + Username can be ``str``, but preferred type + is ``bytes``. M2Crypto does some conversion to + ``bytes`` when necessary, but it's better when + the user of the library does it on its own. + :param password: password on the proxy server, when required + The same as with ``username``, ``str`` is accepted, + but ``bytes`` are preferred. + :param ssl: dict with all remaining named real parameters of the + function. Specifically, ``ssl_context`` is expected + to be included with SSL.Context; if it is not + default ``'sslv23'`` is substituted). + """ + HTTPSConnection.__init__(self, host, port, strict, **ssl) + + self._username = username.encode('utf8') \ + if isinstance(username, six.string_types) else username + self._password = password.encode('utf8') \ + if isinstance(password, six.string_types) else password + self._proxy_auth = None # type: str + self._proxy_UA = None # type: str + + def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): + # type: (AnyStr, AnyStr, int, int) -> None + """ + putrequest is called before connect, so can interpret url and get + real host/port to be used to make CONNECT request to proxy + """ + proto, netloc, path, query, fragment = urlsplit(url) + if not proto: + raise ValueError("unknown URL type: %s" % url) + + # get host & port + try: + username_password, host_port = netloc.split('@') + except ValueError: + host_port = netloc + + try: + host, port_s = host_port.split(':') + port = int(port_s) + except ValueError: + host = host_port + # try to get port from proto + try: + port = self._ports[proto] + except KeyError: + raise ValueError("unknown protocol for: %s" % url) + + self._real_host = host # type: str + self._real_port = port # type: int + rest = urlunsplit(('', '', path, query, fragment)) + HTTPSConnection.putrequest(self, method, rest, skip_host, + skip_accept_encoding) + + def putheader(self, header, value): + # type: (AnyStr, AnyStr) -> None + # Store the auth header if passed in. + if header.lower() == self._UA_HEADER.lower(): + self._proxy_UA = value + if header.lower() == self._AUTH_HEADER.lower(): + self._proxy_auth = value + else: + HTTPSConnection.putheader(self, header, value) + + def endheaders(self, *args, **kwargs): + # type: (*Any, **Any) -> None + # We've recieved all of hte headers. Use the supplied username + # and password for authorization, possibly overriding the authstring + # supplied in the headers. + if not self._proxy_auth: + self._proxy_auth = self._encode_auth() + + HTTPSConnection.endheaders(self, *args, **kwargs) + + def connect(self): + # type: () -> None + HTTPConnection.connect(self) + + # send proxy CONNECT request + self.sock.sendall(self._get_connect_msg()) + response = HTTPResponse(self.sock) + response.begin() + + code = response.status + if code != 200: + # proxy returned and error, abort connection, and raise exception + self.close() + raise socket.error("Proxy connection failed: %d" % code) + + self._start_ssl() + + def _get_connect_msg(self): + # type: () -> bytes + """ Return an HTTP CONNECT request to send to the proxy. """ + msg = "CONNECT %s:%d HTTP/1.1\r\n" % (self._real_host, self._real_port) + msg = msg + "Host: %s:%d\r\n" % (self._real_host, self._real_port) + if self._proxy_UA: + msg = msg + "%s: %s\r\n" % (self._UA_HEADER, self._proxy_UA) + if self._proxy_auth: + msg = msg + "%s: %s\r\n" % (self._AUTH_HEADER, self._proxy_auth) + msg = msg + "\r\n" + return six.ensure_binary(msg) + + def _start_ssl(self): + # type: () -> None + """ Make this connection's socket SSL-aware. """ + self.sock = SSL.Connection(self.ssl_ctx, self.sock) + self.sock.setup_ssl() + self.sock.set_connect_state() + self.sock.connect_ssl() + + def _encode_auth(self): + # type: () -> Optional[bytes] + """ Encode the username and password for use in the auth header. """ + if not (self._username and self._password): + return None + # Authenticated proxy + userpass = "%s:%s" % (self._username, self._password) + with warnings.catch_warnings(): + warnings.simplefilter("ignore", DeprecationWarning) + enc_userpass = base64.encodestring(userpass).replace("\n", "") + return six.ensure_binary("Basic %s" % enc_userpass) diff --git a/src/M2Crypto/m2.py b/src/M2Crypto/m2.py new file mode 100644 index 0000000..81e4315 --- /dev/null +++ b/src/M2Crypto/m2.py @@ -0,0 +1,31 @@ +from __future__ import absolute_import + +"""M2Crypto low level OpenSSL wrapper functions. + +m2 is the low level wrapper for OpenSSL functions. Typically you would not +need to use these directly, since these will be called by the higher level +objects you should try to use instead. + +Naming conventions: All functions wrapped by m2 are all lower case, +words separated by underscores. + +Examples: + +OpenSSL M2Crypto + +X509_get_version m2.x509_get_version +X509_get_notBefore m2.x509_get_not_before +X509_REQ_verify m2.x509_req_verify + +Exceptions to naming rules: + +XXX TDB + +Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + +Portions created by Open Source Applications Foundation (OSAF) are +Copyright (C) 2004 OSAF. All Rights Reserved. +""" + +from M2Crypto.m2crypto import * +lib_init() diff --git a/src/M2Crypto/m2crypto.py b/src/M2Crypto/m2crypto.py new file mode 100644 index 0000000..1323547 --- /dev/null +++ b/src/M2Crypto/m2crypto.py @@ -0,0 +1,67 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 4.0.2 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +from sys import version_info as _swig_python_version_info +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") + +# Pull in all the attributes from the low-level C/C++ module +if __package__ or "." in __name__: + from ._m2crypto import * +else: + from _m2crypto import * + +try: + import builtins as __builtin__ +except ImportError: + import __builtin__ + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) + else: + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr + + +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr + + +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper + + +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + + + + + + diff --git a/src/M2Crypto/m2urllib.py b/src/M2Crypto/m2urllib.py new file mode 100644 index 0000000..06641b2 --- /dev/null +++ b/src/M2Crypto/m2urllib.py @@ -0,0 +1,120 @@ +from __future__ import absolute_import, print_function + +"""M2Crypto enhancement to Python's urllib for handling +'https' url's. + +FIXME: it is questionable whether we need this old-style module at all. urllib +(not urllib2) is in Python 3 support just as a legacy API. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +import base64 +import warnings + +from M2Crypto import SSL, httpslib, six + +from M2Crypto.six.moves.urllib_response import addinfourl +from typing import AnyStr, Optional # noqa + +# six.moves doesn't support star imports +if six.PY3: + from urllib.request import * # noqa for other modules to import + from urllib.parse import * # noqa for other modules to import + from urllib.error import * # noqa for other modules to import +else: + from urllib import * # noqa + + +def open_https(self, url, data=None, ssl_context=None): + # type: (URLOpener, AnyStr, Optional[bytes], Optional[SSL.Context]) -> addinfourl + """ + Open URL over the SSL connection. + + :param url: URL to be opened + :param data: data for the POST request + :param ssl_context: SSL.Context to be used + :return: + """ + if six.PY3: + warnings.warn('URLOpener has been deprecated in Py3k', DeprecationWarning) + + if ssl_context is not None and isinstance(ssl_context, SSL.Context): + self.ctx = ssl_context + else: + self.ctx = SSL.Context() + user_passwd = None + if isinstance(url, six.string_types): + try: # python 2 + # http://pydoc.org/2.5.1/urllib.html + host, selector = splithost(url) + if host: + user_passwd, host = splituser(host) + host = unquote(host) + realhost = host + except NameError: # python 3 has no splithost + # https://docs.python.org/3/library/urllib.parse.html + parsed = urlparse(url) + host = parsed.hostname + if parsed.port: + host += ":{0}".format(parsed.port) + user_passwd = parsed.password + if parsed.password: + user_passwd += ":{0}".format(parsed.password) + selector = parsed.path + else: + host, selector = url + urltype, rest = splittype(selector) + url = rest + user_passwd = None + if urltype.lower() != 'http': + realhost = None + else: + try: # python 2 + realhost, rest = splithost(rest) + if realhost: + user_passwd, realhost = splituser(realhost) + if user_passwd: + selector = "%s://%s%s" % (urltype, realhost, rest) + except NameError: # python 3 has no splithost + parsed = urlparse(rest) + host = parsed.hostname + if parsed.port: + host += ":{0}".format(parsed.port) + user_passwd = parsed.username + if parsed.password: + user_passwd += ":{0}".format(parsed.password) + # print("proxy via http:", host, selector) + if not host: + raise IOError('http error', 'no host given') + if user_passwd: + if six.PY3: + auth = base64.encodebytes(user_passwd).strip() + else: + auth = base64.encodestring(user_passwd).strip() + else: + auth = None + # Start here! + h = httpslib.HTTPSConnection(host=host, ssl_context=self.ctx) + # h.set_debuglevel(1) + # Stop here! + if data is not None: + h.putrequest('POST', selector) + h.putheader('Content-type', 'application/x-www-form-urlencoded') + h.putheader('Content-length', '%d' % len(data)) + else: + h.putrequest('GET', selector) + if auth: + h.putheader('Authorization', 'Basic %s' % auth) + for args in self.addheaders: + h.putheader(*args) # for python3 - used to use apply + h.endheaders() + if data is not None: + h.send(data + '\r\n') + # Here again! + resp = h.getresponse() + fp = resp.fp + return addinfourl(fp, resp.msg, "https:" + url) + # Stop again. + +# Minor brain surgery. +URLopener.open_https = open_https diff --git a/src/M2Crypto/m2urllib2.py b/src/M2Crypto/m2urllib2.py new file mode 100644 index 0000000..1849051 --- /dev/null +++ b/src/M2Crypto/m2urllib2.py @@ -0,0 +1,185 @@ +from __future__ import absolute_import + +""" +M2Crypto enhancement to Python's urllib2 for handling +'https' url's. + +Code from urllib2 is Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +Python Software Foundation; All Rights Reserved + +Summary of changes: + - Use an HTTPSProxyConnection if the request is going through a proxy. + - Add the SSL context to the https connection when performing https_open. + - Add the M2Crypto HTTPSHandler when building a default opener. +""" + +import socket + +from M2Crypto import SSL, httpslib, six + +from M2Crypto.six.moves.urllib_parse import urldefrag, urlparse as url_parse +from M2Crypto.six.moves.urllib_response import addinfourl +from typing import Optional # noqa + +# six.moves doesn't support star imports +if six.PY3: + from urllib.request import * # noqa other modules want to import + from urllib.error import * # noqa other modules want to import +else: + from urllib2 import * # noqa + + +try: + mother_class = socket._fileobject +except AttributeError: + mother_class = socket.SocketIO + + +class _closing_fileobject(mother_class): # noqa + """socket._fileobject that propagates self.close() to the socket. + + Python 2.5 provides this as socket._fileobject(sock, close=True). + """ + +# for python 3 +try: + AbstractHTTPHandler +except NameError: + # somehow this won't get imported by the import * above + import urllib.request + AbstractHTTPHandler = urllib.request.AbstractHTTPHandler + + +class HTTPSHandler(AbstractHTTPHandler): + def __init__(self, ssl_context=None): + # type: (SSL.Context) -> None + AbstractHTTPHandler.__init__(self) + + if ssl_context is not None: + assert isinstance(ssl_context, SSL.Context), ssl_context + self.ctx = ssl_context + else: + self.ctx = SSL.Context() + + # Copied from urllib2, so we can set the ssl context. + def https_open(self, req): + # type: (Request) -> addinfourl + """Return an addinfourl object for the request, using http_class. + + http_class must implement the HTTPConnection API from httplib. + The addinfourl return value is a file-like object. It also + has methods and attributes including: + + - info(): return a mimetools.Message object for the headers + + - geturl(): return the original request URL + + - code: HTTP status code + """ + # https://docs.python.org/3.3/library/urllib.request.html#urllib.request.Request.get_host + try: # up to python-3.2 + host = req.get_host() + except AttributeError: # from python-3.3 + host = req.host + if not host: + raise URLError('no host given') + + # Our change: Check to see if we're using a proxy. + # Then create an appropriate ssl-aware connection. + full_url = req.get_full_url() + target_host = url_parse(full_url)[1] + + if target_host != host: + request_uri = urldefrag(full_url)[0] + h = httpslib.ProxyHTTPSConnection(host=host, ssl_context=self.ctx) + else: + try: # up to python-3.2 + request_uri = req.get_selector() + except AttributeError: # from python-3.3 + request_uri = req.selector + h = httpslib.HTTPSConnection(host=host, ssl_context=self.ctx) + # End our change + h.set_debuglevel(self._debuglevel) + + headers = dict(req.headers) + headers.update(req.unredirected_hdrs) + # We want to make an HTTP/1.1 request, but the addinfourl + # class isn't prepared to deal with a persistent connection. + # It will try to read all remaining data from the socket, + # which will block while the server waits for the next request. + # So make sure the connection gets closed after the (only) + # request. + headers["Connection"] = "close" + try: + h.request(req.get_method(), request_uri, req.data, headers) + r = h.getresponse() + except socket.error as err: # XXX what error? + raise URLError(err) + + # Pick apart the HTTPResponse object to get the addinfourl + # object initialized properly. + + # Wrap the HTTPResponse object in socket's file object adapter + # for Windows. That adapter calls recv(), so delegate recv() + # to read(). This weird wrapping allows the returned object to + # have readline() and readlines() methods. + r.recv = r.read + if six.PY2: + fp = socket._fileobject(r, close=True) + else: + r._decref_socketios = lambda: None + r.ssl = h.sock.ssl + r._timeout = -1.0 + r.recv_into = r.readinto + fp = socket.SocketIO(r, 'rb') + + resp = addinfourl(fp, r.msg, req.get_full_url()) + resp.code = r.status + resp.msg = r.reason + return resp + + https_request = AbstractHTTPHandler.do_request_ + + +# Copied from urllib2 with modifications for ssl +def build_opener(ssl_context=None, *handlers): + # type: (Optional[SSL.Context], *object) -> OpenerDirector + """Create an opener object from a list of handlers. + + The opener will use several default handlers, including support + for HTTP and FTP. + + If any of the handlers passed as arguments are subclasses of the + default handlers, the default handlers will not be used. + """ + + def isclass(obj): + return isinstance(obj, type) or hasattr(obj, "__bases__") + + opener = OpenerDirector() + default_classes = [ProxyHandler, UnknownHandler, HTTPHandler, + HTTPDefaultErrorHandler, HTTPRedirectHandler, + FTPHandler, FileHandler, HTTPErrorProcessor] + skip = [] + for klass in default_classes: + for check in handlers: + if isclass(check): + if issubclass(check, klass): + skip.append(klass) + elif isinstance(check, klass): + skip.append(klass) + for klass in skip: + default_classes.remove(klass) + + for klass in default_classes: + opener.add_handler(klass()) + + # Add the HTTPS handler with ssl_context + if HTTPSHandler not in skip: + opener.add_handler(HTTPSHandler(ssl_context)) + + for h in handlers: + if isclass(h): + h = h() + opener.add_handler(h) + return opener diff --git a/src/M2Crypto/m2xmlrpclib.py b/src/M2Crypto/m2xmlrpclib.py new file mode 100644 index 0000000..8d8aa3e --- /dev/null +++ b/src/M2Crypto/m2xmlrpclib.py @@ -0,0 +1,78 @@ +from __future__ import absolute_import + +"""M2Crypto enhancement to xmlrpclib. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +import base64 + +import M2Crypto + +from M2Crypto import SSL, httpslib, m2urllib, six +from typing import Any, AnyStr, Callable, Optional # noqa + +from M2Crypto.six.moves.xmlrpc_client import ProtocolError, Transport +# six.moves doesn't support star imports +if six.PY3: + from xmlrpc.client import * # noqa +else: + from xmlrpclib import * # noqa + +__version__ = M2Crypto.__version__ + + +class SSL_Transport(Transport): + + user_agent = "M2Crypto_XMLRPC/%s - %s" % (__version__, + Transport.user_agent) + + def __init__(self, ssl_context=None, *args, **kw): + # type: (Optional[SSL.Context], *Any, **Any) -> None + Transport.__init__(self, *args, **kw) + if ssl_context is None: + self.ssl_ctx = SSL.Context() + else: + self.ssl_ctx = ssl_context + + def request(self, host, handler, request_body, verbose=0): + # type: (AnyStr, Callable, bytes, int) -> object + # Handle username and password. + user_passwd, host_port = m2urllib.splituser(host) + _host, _port = m2urllib.splitport(host_port) + h = httpslib.HTTPSConnection(_host, int(_port), + ssl_context=self.ssl_ctx) + if verbose: + h.set_debuglevel(1) + + # What follows is as in xmlrpclib.Transport. (Except the authz bit.) + h.putrequest("POST", handler) + + # required by HTTP/1.1 + h.putheader("Host", _host) + + # required by XML-RPC + h.putheader("User-Agent", self.user_agent) + h.putheader("Content-Type", "text/xml") + h.putheader("Content-Length", str(len(request_body))) + + # Authorisation. + if user_passwd is not None: + auth = base64.encodestring(user_passwd).strip() + h.putheader('Authorization', 'Basic %s' % auth) + + h.endheaders() + + if request_body: + h.send(request_body) + + response = h.getresponse() + + if response.status != 200: + raise ProtocolError( + host + handler, + response.status, response.reason, + response.getheaders() + ) + + self.verbose = verbose + return self.parse_response(response) diff --git a/src/M2Crypto/six.py b/src/M2Crypto/six.py new file mode 100644 index 0000000..83f6978 --- /dev/null +++ b/src/M2Crypto/six.py @@ -0,0 +1,982 @@ +# Copyright (c) 2010-2020 Benjamin Peterson +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +"""Utilities for writing code that runs on Python 2 and 3""" + +from __future__ import absolute_import + +import functools +import itertools +import operator +import sys +import types + +__author__ = "Benjamin Peterson " +__version__ = "1.15.0" + + +# Useful for very coarse version differentiation. +PY2 = sys.version_info[0] == 2 +PY3 = sys.version_info[0] == 3 +PY34 = sys.version_info[0:2] >= (3, 4) + +if PY3: + string_types = str, + integer_types = int, + class_types = type, + text_type = str + binary_type = bytes + + MAXSIZE = sys.maxsize +else: + string_types = basestring, + integer_types = (int, long) + class_types = (type, types.ClassType) + text_type = unicode + binary_type = str + + if sys.platform.startswith("java"): + # Jython always uses 32 bits. + MAXSIZE = int((1 << 31) - 1) + else: + # It's possible to have sizeof(long) != sizeof(Py_ssize_t). + class X(object): + + def __len__(self): + return 1 << 31 + try: + len(X()) + except OverflowError: + # 32-bit + MAXSIZE = int((1 << 31) - 1) + else: + # 64-bit + MAXSIZE = int((1 << 63) - 1) + del X + + +def _add_doc(func, doc): + """Add documentation to a function.""" + func.__doc__ = doc + + +def _import_module(name): + """Import module, returning the module after the last dot.""" + __import__(name) + return sys.modules[name] + + +class _LazyDescr(object): + + def __init__(self, name): + self.name = name + + def __get__(self, obj, tp): + result = self._resolve() + setattr(obj, self.name, result) # Invokes __set__. + try: + # This is a bit ugly, but it avoids running this again by + # removing this descriptor. + delattr(obj.__class__, self.name) + except AttributeError: + pass + return result + + +class MovedModule(_LazyDescr): + + def __init__(self, name, old, new=None): + super(MovedModule, self).__init__(name) + if PY3: + if new is None: + new = name + self.mod = new + else: + self.mod = old + + def _resolve(self): + return _import_module(self.mod) + + def __getattr__(self, attr): + _module = self._resolve() + value = getattr(_module, attr) + setattr(self, attr, value) + return value + + +class _LazyModule(types.ModuleType): + + def __init__(self, name): + super(_LazyModule, self).__init__(name) + self.__doc__ = self.__class__.__doc__ + + def __dir__(self): + attrs = ["__doc__", "__name__"] + attrs += [attr.name for attr in self._moved_attributes] + return attrs + + # Subclasses should override this + _moved_attributes = [] + + +class MovedAttribute(_LazyDescr): + + def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): + super(MovedAttribute, self).__init__(name) + if PY3: + if new_mod is None: + new_mod = name + self.mod = new_mod + if new_attr is None: + if old_attr is None: + new_attr = name + else: + new_attr = old_attr + self.attr = new_attr + else: + self.mod = old_mod + if old_attr is None: + old_attr = name + self.attr = old_attr + + def _resolve(self): + module = _import_module(self.mod) + return getattr(module, self.attr) + + +class _SixMetaPathImporter(object): + + """ + A meta path importer to import six.moves and its submodules. + + This class implements a PEP302 finder and loader. It should be compatible + with Python 2.5 and all existing versions of Python3 + """ + + def __init__(self, six_module_name): + self.name = six_module_name + self.known_modules = {} + + def _add_module(self, mod, *fullnames): + for fullname in fullnames: + self.known_modules[self.name + "." + fullname] = mod + + def _get_module(self, fullname): + return self.known_modules[self.name + "." + fullname] + + def find_module(self, fullname, path=None): + if fullname in self.known_modules: + return self + return None + + def __get_module(self, fullname): + try: + return self.known_modules[fullname] + except KeyError: + raise ImportError("This loader does not know module " + fullname) + + def load_module(self, fullname): + try: + # in case of a reload + return sys.modules[fullname] + except KeyError: + pass + mod = self.__get_module(fullname) + if isinstance(mod, MovedModule): + mod = mod._resolve() + else: + mod.__loader__ = self + sys.modules[fullname] = mod + return mod + + def is_package(self, fullname): + """ + Return true, if the named module is a package. + + We need this method to get correct spec objects with + Python 3.4 (see PEP451) + """ + return hasattr(self.__get_module(fullname), "__path__") + + def get_code(self, fullname): + """Return None + + Required, if is_package is implemented""" + self.__get_module(fullname) # eventually raises ImportError + return None + get_source = get_code # same as get_code + +_importer = _SixMetaPathImporter(__name__) + + +class _MovedItems(_LazyModule): + + """Lazy loading of moved objects""" + __path__ = [] # mark as package + + +_moved_attributes = [ + MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), + MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), + MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), + MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), + MovedAttribute("intern", "__builtin__", "sys"), + MovedAttribute("map", "itertools", "builtins", "imap", "map"), + MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"), + MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"), + MovedAttribute("getoutput", "commands", "subprocess"), + MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), + MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"), + MovedAttribute("reduce", "__builtin__", "functools"), + MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), + MovedAttribute("StringIO", "StringIO", "io"), + MovedAttribute("UserDict", "UserDict", "collections"), + MovedAttribute("UserList", "UserList", "collections"), + MovedAttribute("UserString", "UserString", "collections"), + MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), + MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), + MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), + MovedModule("builtins", "__builtin__"), + MovedModule("configparser", "ConfigParser"), + MovedModule("collections_abc", "collections", "collections.abc" if sys.version_info >= (3, 3) else "collections"), + MovedModule("copyreg", "copy_reg"), + MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), + MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"), + MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread" if sys.version_info < (3, 9) else "_thread"), + MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), + MovedModule("http_cookies", "Cookie", "http.cookies"), + MovedModule("html_entities", "htmlentitydefs", "html.entities"), + MovedModule("html_parser", "HTMLParser", "html.parser"), + MovedModule("http_client", "httplib", "http.client"), + MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), + MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"), + MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), + MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"), + MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), + MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), + MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), + MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), + MovedModule("cPickle", "cPickle", "pickle"), + MovedModule("queue", "Queue"), + MovedModule("reprlib", "repr"), + MovedModule("socketserver", "SocketServer"), + MovedModule("_thread", "thread", "_thread"), + MovedModule("tkinter", "Tkinter"), + MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), + MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), + MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), + MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), + MovedModule("tkinter_tix", "Tix", "tkinter.tix"), + MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), + MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), + MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), + MovedModule("tkinter_colorchooser", "tkColorChooser", + "tkinter.colorchooser"), + MovedModule("tkinter_commondialog", "tkCommonDialog", + "tkinter.commondialog"), + MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), + MovedModule("tkinter_font", "tkFont", "tkinter.font"), + MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), + MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", + "tkinter.simpledialog"), + MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), + MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), + MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), + MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), + MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), + MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), +] +# Add windows specific modules. +if sys.platform == "win32": + _moved_attributes += [ + MovedModule("winreg", "_winreg"), + ] + +for attr in _moved_attributes: + setattr(_MovedItems, attr.name, attr) + if isinstance(attr, MovedModule): + _importer._add_module(attr, "moves." + attr.name) +del attr + +_MovedItems._moved_attributes = _moved_attributes + +moves = _MovedItems(__name__ + ".moves") +_importer._add_module(moves, "moves") + + +class Module_six_moves_urllib_parse(_LazyModule): + + """Lazy loading of moved objects in six.moves.urllib_parse""" + + +_urllib_parse_moved_attributes = [ + MovedAttribute("ParseResult", "urlparse", "urllib.parse"), + MovedAttribute("SplitResult", "urlparse", "urllib.parse"), + MovedAttribute("parse_qs", "urlparse", "urllib.parse"), + MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), + MovedAttribute("urldefrag", "urlparse", "urllib.parse"), + MovedAttribute("urljoin", "urlparse", "urllib.parse"), + MovedAttribute("urlparse", "urlparse", "urllib.parse"), + MovedAttribute("urlsplit", "urlparse", "urllib.parse"), + MovedAttribute("urlunparse", "urlparse", "urllib.parse"), + MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), + MovedAttribute("quote", "urllib", "urllib.parse"), + MovedAttribute("quote_plus", "urllib", "urllib.parse"), + MovedAttribute("unquote", "urllib", "urllib.parse"), + MovedAttribute("unquote_plus", "urllib", "urllib.parse"), + MovedAttribute("unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"), + MovedAttribute("urlencode", "urllib", "urllib.parse"), + MovedAttribute("splitquery", "urllib", "urllib.parse"), + MovedAttribute("splittag", "urllib", "urllib.parse"), + MovedAttribute("splituser", "urllib", "urllib.parse"), + MovedAttribute("splitvalue", "urllib", "urllib.parse"), + MovedAttribute("uses_fragment", "urlparse", "urllib.parse"), + MovedAttribute("uses_netloc", "urlparse", "urllib.parse"), + MovedAttribute("uses_params", "urlparse", "urllib.parse"), + MovedAttribute("uses_query", "urlparse", "urllib.parse"), + MovedAttribute("uses_relative", "urlparse", "urllib.parse"), +] +for attr in _urllib_parse_moved_attributes: + setattr(Module_six_moves_urllib_parse, attr.name, attr) +del attr + +Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes + +_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"), + "moves.urllib_parse", "moves.urllib.parse") + + +class Module_six_moves_urllib_error(_LazyModule): + + """Lazy loading of moved objects in six.moves.urllib_error""" + + +_urllib_error_moved_attributes = [ + MovedAttribute("URLError", "urllib2", "urllib.error"), + MovedAttribute("HTTPError", "urllib2", "urllib.error"), + MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), +] +for attr in _urllib_error_moved_attributes: + setattr(Module_six_moves_urllib_error, attr.name, attr) +del attr + +Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes + +_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"), + "moves.urllib_error", "moves.urllib.error") + + +class Module_six_moves_urllib_request(_LazyModule): + + """Lazy loading of moved objects in six.moves.urllib_request""" + + +_urllib_request_moved_attributes = [ + MovedAttribute("urlopen", "urllib2", "urllib.request"), + MovedAttribute("install_opener", "urllib2", "urllib.request"), + MovedAttribute("build_opener", "urllib2", "urllib.request"), + MovedAttribute("pathname2url", "urllib", "urllib.request"), + MovedAttribute("url2pathname", "urllib", "urllib.request"), + MovedAttribute("getproxies", "urllib", "urllib.request"), + MovedAttribute("Request", "urllib2", "urllib.request"), + MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), + MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), + MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), + MovedAttribute("BaseHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), + MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), + MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), + MovedAttribute("FileHandler", "urllib2", "urllib.request"), + MovedAttribute("FTPHandler", "urllib2", "urllib.request"), + MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), + MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), + MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), + MovedAttribute("urlretrieve", "urllib", "urllib.request"), + MovedAttribute("urlcleanup", "urllib", "urllib.request"), + MovedAttribute("URLopener", "urllib", "urllib.request"), + MovedAttribute("FancyURLopener", "urllib", "urllib.request"), + MovedAttribute("proxy_bypass", "urllib", "urllib.request"), + MovedAttribute("parse_http_list", "urllib2", "urllib.request"), + MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"), +] +for attr in _urllib_request_moved_attributes: + setattr(Module_six_moves_urllib_request, attr.name, attr) +del attr + +Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes + +_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"), + "moves.urllib_request", "moves.urllib.request") + + +class Module_six_moves_urllib_response(_LazyModule): + + """Lazy loading of moved objects in six.moves.urllib_response""" + + +_urllib_response_moved_attributes = [ + MovedAttribute("addbase", "urllib", "urllib.response"), + MovedAttribute("addclosehook", "urllib", "urllib.response"), + MovedAttribute("addinfo", "urllib", "urllib.response"), + MovedAttribute("addinfourl", "urllib", "urllib.response"), +] +for attr in _urllib_response_moved_attributes: + setattr(Module_six_moves_urllib_response, attr.name, attr) +del attr + +Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes + +_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"), + "moves.urllib_response", "moves.urllib.response") + + +class Module_six_moves_urllib_robotparser(_LazyModule): + + """Lazy loading of moved objects in six.moves.urllib_robotparser""" + + +_urllib_robotparser_moved_attributes = [ + MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), +] +for attr in _urllib_robotparser_moved_attributes: + setattr(Module_six_moves_urllib_robotparser, attr.name, attr) +del attr + +Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes + +_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"), + "moves.urllib_robotparser", "moves.urllib.robotparser") + + +class Module_six_moves_urllib(types.ModuleType): + + """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" + __path__ = [] # mark as package + parse = _importer._get_module("moves.urllib_parse") + error = _importer._get_module("moves.urllib_error") + request = _importer._get_module("moves.urllib_request") + response = _importer._get_module("moves.urllib_response") + robotparser = _importer._get_module("moves.urllib_robotparser") + + def __dir__(self): + return ['parse', 'error', 'request', 'response', 'robotparser'] + +_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"), + "moves.urllib") + + +def add_move(move): + """Add an item to six.moves.""" + setattr(_MovedItems, move.name, move) + + +def remove_move(name): + """Remove item from six.moves.""" + try: + delattr(_MovedItems, name) + except AttributeError: + try: + del moves.__dict__[name] + except KeyError: + raise AttributeError("no such move, %r" % (name,)) + + +if PY3: + _meth_func = "__func__" + _meth_self = "__self__" + + _func_closure = "__closure__" + _func_code = "__code__" + _func_defaults = "__defaults__" + _func_globals = "__globals__" +else: + _meth_func = "im_func" + _meth_self = "im_self" + + _func_closure = "func_closure" + _func_code = "func_code" + _func_defaults = "func_defaults" + _func_globals = "func_globals" + + +try: + advance_iterator = next +except NameError: + def advance_iterator(it): + return it.next() +next = advance_iterator + + +try: + callable = callable +except NameError: + def callable(obj): + return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) + + +if PY3: + def get_unbound_function(unbound): + return unbound + + create_bound_method = types.MethodType + + def create_unbound_method(func, cls): + return func + + Iterator = object +else: + def get_unbound_function(unbound): + return unbound.im_func + + def create_bound_method(func, obj): + return types.MethodType(func, obj, obj.__class__) + + def create_unbound_method(func, cls): + return types.MethodType(func, None, cls) + + class Iterator(object): + + def next(self): + return type(self).__next__(self) + + callable = callable +_add_doc(get_unbound_function, + """Get the function out of a possibly unbound function""") + + +get_method_function = operator.attrgetter(_meth_func) +get_method_self = operator.attrgetter(_meth_self) +get_function_closure = operator.attrgetter(_func_closure) +get_function_code = operator.attrgetter(_func_code) +get_function_defaults = operator.attrgetter(_func_defaults) +get_function_globals = operator.attrgetter(_func_globals) + + +if PY3: + def iterkeys(d, **kw): + return iter(d.keys(**kw)) + + def itervalues(d, **kw): + return iter(d.values(**kw)) + + def iteritems(d, **kw): + return iter(d.items(**kw)) + + def iterlists(d, **kw): + return iter(d.lists(**kw)) + + viewkeys = operator.methodcaller("keys") + + viewvalues = operator.methodcaller("values") + + viewitems = operator.methodcaller("items") +else: + def iterkeys(d, **kw): + return d.iterkeys(**kw) + + def itervalues(d, **kw): + return d.itervalues(**kw) + + def iteritems(d, **kw): + return d.iteritems(**kw) + + def iterlists(d, **kw): + return d.iterlists(**kw) + + viewkeys = operator.methodcaller("viewkeys") + + viewvalues = operator.methodcaller("viewvalues") + + viewitems = operator.methodcaller("viewitems") + +_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") +_add_doc(itervalues, "Return an iterator over the values of a dictionary.") +_add_doc(iteritems, + "Return an iterator over the (key, value) pairs of a dictionary.") +_add_doc(iterlists, + "Return an iterator over the (key, [values]) pairs of a dictionary.") + + +if PY3: + def b(s): + return s.encode("latin-1") + + def u(s): + return s + unichr = chr + import struct + int2byte = struct.Struct(">B").pack + del struct + byte2int = operator.itemgetter(0) + indexbytes = operator.getitem + iterbytes = iter + import io + StringIO = io.StringIO + BytesIO = io.BytesIO + del io + _assertCountEqual = "assertCountEqual" + if sys.version_info[1] <= 1: + _assertRaisesRegex = "assertRaisesRegexp" + _assertRegex = "assertRegexpMatches" + _assertNotRegex = "assertNotRegexpMatches" + else: + _assertRaisesRegex = "assertRaisesRegex" + _assertRegex = "assertRegex" + _assertNotRegex = "assertNotRegex" +else: + def b(s): + return s + # Workaround for standalone backslash + + def u(s): + return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") + unichr = unichr + int2byte = chr + + def byte2int(bs): + return ord(bs[0]) + + def indexbytes(buf, i): + return ord(buf[i]) + iterbytes = functools.partial(itertools.imap, ord) + import StringIO + StringIO = BytesIO = StringIO.StringIO + _assertCountEqual = "assertItemsEqual" + _assertRaisesRegex = "assertRaisesRegexp" + _assertRegex = "assertRegexpMatches" + _assertNotRegex = "assertNotRegexpMatches" +_add_doc(b, """Byte literal""") +_add_doc(u, """Text literal""") + + +def assertCountEqual(self, *args, **kwargs): + return getattr(self, _assertCountEqual)(*args, **kwargs) + + +def assertRaisesRegex(self, *args, **kwargs): + return getattr(self, _assertRaisesRegex)(*args, **kwargs) + + +def assertRegex(self, *args, **kwargs): + return getattr(self, _assertRegex)(*args, **kwargs) + + +def assertNotRegex(self, *args, **kwargs): + return getattr(self, _assertNotRegex)(*args, **kwargs) + + +if PY3: + exec_ = getattr(moves.builtins, "exec") + + def reraise(tp, value, tb=None): + try: + if value is None: + value = tp() + if value.__traceback__ is not tb: + raise value.with_traceback(tb) + raise value + finally: + value = None + tb = None + +else: + def exec_(_code_, _globs_=None, _locs_=None): + """Execute code in a namespace.""" + if _globs_ is None: + frame = sys._getframe(1) + _globs_ = frame.f_globals + if _locs_ is None: + _locs_ = frame.f_locals + del frame + elif _locs_ is None: + _locs_ = _globs_ + exec("""exec _code_ in _globs_, _locs_""") + + exec_("""def reraise(tp, value, tb=None): + try: + raise tp, value, tb + finally: + tb = None +""") + + +if sys.version_info[:2] > (3,): + exec_("""def raise_from(value, from_value): + try: + raise value from from_value + finally: + value = None +""") +else: + def raise_from(value, from_value): + raise value + + +print_ = getattr(moves.builtins, "print", None) +if print_ is None: + def print_(*args, **kwargs): + """The new-style print function for Python 2.4 and 2.5.""" + fp = kwargs.pop("file", sys.stdout) + if fp is None: + return + + def write(data): + if not isinstance(data, basestring): + data = str(data) + # If the file has an encoding, encode unicode with it. + if (isinstance(fp, file) and + isinstance(data, unicode) and + fp.encoding is not None): + errors = getattr(fp, "errors", None) + if errors is None: + errors = "strict" + data = data.encode(fp.encoding, errors) + fp.write(data) + want_unicode = False + sep = kwargs.pop("sep", None) + if sep is not None: + if isinstance(sep, unicode): + want_unicode = True + elif not isinstance(sep, str): + raise TypeError("sep must be None or a string") + end = kwargs.pop("end", None) + if end is not None: + if isinstance(end, unicode): + want_unicode = True + elif not isinstance(end, str): + raise TypeError("end must be None or a string") + if kwargs: + raise TypeError("invalid keyword arguments to print()") + if not want_unicode: + for arg in args: + if isinstance(arg, unicode): + want_unicode = True + break + if want_unicode: + newline = unicode("\n") + space = unicode(" ") + else: + newline = "\n" + space = " " + if sep is None: + sep = space + if end is None: + end = newline + for i, arg in enumerate(args): + if i: + write(sep) + write(arg) + write(end) +if sys.version_info[:2] < (3, 3): + _print = print_ + + def print_(*args, **kwargs): + fp = kwargs.get("file", sys.stdout) + flush = kwargs.pop("flush", False) + _print(*args, **kwargs) + if flush and fp is not None: + fp.flush() + +_add_doc(reraise, """Reraise an exception.""") + +if sys.version_info[0:2] < (3, 4): + # This does exactly the same what the :func:`py3:functools.update_wrapper` + # function does on Python versions after 3.2. It sets the ``__wrapped__`` + # attribute on ``wrapper`` object and it doesn't raise an error if any of + # the attributes mentioned in ``assigned`` and ``updated`` are missing on + # ``wrapped`` object. + def _update_wrapper(wrapper, wrapped, + assigned=functools.WRAPPER_ASSIGNMENTS, + updated=functools.WRAPPER_UPDATES): + for attr in assigned: + try: + value = getattr(wrapped, attr) + except AttributeError: + continue + else: + setattr(wrapper, attr, value) + for attr in updated: + getattr(wrapper, attr).update(getattr(wrapped, attr, {})) + wrapper.__wrapped__ = wrapped + return wrapper + _update_wrapper.__doc__ = functools.update_wrapper.__doc__ + + def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, + updated=functools.WRAPPER_UPDATES): + return functools.partial(_update_wrapper, wrapped=wrapped, + assigned=assigned, updated=updated) + wraps.__doc__ = functools.wraps.__doc__ + +else: + wraps = functools.wraps + + +def with_metaclass(meta, *bases): + """Create a base class with a metaclass.""" + # This requires a bit of explanation: the basic idea is to make a dummy + # metaclass for one level of class instantiation that replaces itself with + # the actual metaclass. + class metaclass(type): + + def __new__(cls, name, this_bases, d): + if sys.version_info[:2] >= (3, 7): + # This version introduced PEP 560 that requires a bit + # of extra care (we mimic what is done by __build_class__). + resolved_bases = types.resolve_bases(bases) + if resolved_bases is not bases: + d['__orig_bases__'] = bases + else: + resolved_bases = bases + return meta(name, resolved_bases, d) + + @classmethod + def __prepare__(cls, name, this_bases): + return meta.__prepare__(name, bases) + return type.__new__(metaclass, 'temporary_class', (), {}) + + +def add_metaclass(metaclass): + """Class decorator for creating a class with a metaclass.""" + def wrapper(cls): + orig_vars = cls.__dict__.copy() + slots = orig_vars.get('__slots__') + if slots is not None: + if isinstance(slots, str): + slots = [slots] + for slots_var in slots: + orig_vars.pop(slots_var) + orig_vars.pop('__dict__', None) + orig_vars.pop('__weakref__', None) + if hasattr(cls, '__qualname__'): + orig_vars['__qualname__'] = cls.__qualname__ + return metaclass(cls.__name__, cls.__bases__, orig_vars) + return wrapper + + +def ensure_binary(s, encoding='utf-8', errors='strict'): + """Coerce **s** to six.binary_type. + + For Python 2: + - `unicode` -> encoded to `str` + - `str` -> `str` + + For Python 3: + - `str` -> encoded to `bytes` + - `bytes` -> `bytes` + """ + if isinstance(s, binary_type): + return s + if isinstance(s, text_type): + return s.encode(encoding, errors) + raise TypeError("not expecting type '%s'" % type(s)) + + +def ensure_str(s, encoding='utf-8', errors='strict'): + """Coerce *s* to `str`. + + For Python 2: + - `unicode` -> encoded to `str` + - `str` -> `str` + + For Python 3: + - `str` -> `str` + - `bytes` -> decoded to `str` + """ + # Optimization: Fast return for the common case. + if type(s) is str: + return s + if PY2 and isinstance(s, text_type): + return s.encode(encoding, errors) + elif PY3 and isinstance(s, binary_type): + return s.decode(encoding, errors) + elif not isinstance(s, (text_type, binary_type)): + raise TypeError("not expecting type '%s'" % type(s)) + return s + + +def ensure_text(s, encoding='utf-8', errors='strict'): + """Coerce *s* to six.text_type. + + For Python 2: + - `unicode` -> `unicode` + - `str` -> `unicode` + + For Python 3: + - `str` -> `str` + - `bytes` -> decoded to `str` + """ + if isinstance(s, binary_type): + return s.decode(encoding, errors) + elif isinstance(s, text_type): + return s + else: + raise TypeError("not expecting type '%s'" % type(s)) + + +def python_2_unicode_compatible(klass): + """ + A class decorator that defines __unicode__ and __str__ methods under Python 2. + Under Python 3 it does nothing. + + To support Python 2 and 3 with a single code base, define a __str__ method + returning text and apply this decorator to the class. + """ + if PY2: + if '__str__' not in klass.__dict__: + raise ValueError("@python_2_unicode_compatible cannot be applied " + "to %s because it doesn't define __str__()." % + klass.__name__) + klass.__unicode__ = klass.__str__ + klass.__str__ = lambda self: self.__unicode__().encode('utf-8') + return klass + + +# Complete the moves implementation. +# This code is at the end of this module to speed up module loading. +# Turn this module into a package. +__path__ = [] # required for PEP 302 and PEP 451 +__package__ = __name__ # see PEP 366 @ReservedAssignment +if globals().get("__spec__") is not None: + __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable +# Remove other six meta path importers, since they cause problems. This can +# happen if six is removed from sys.modules and then reloaded. (Setuptools does +# this for some reason.) +if sys.meta_path: + for i, importer in enumerate(sys.meta_path): + # Here's some real nastiness: Another "instance" of the six module might + # be floating around. Therefore, we can't use isinstance() to check for + # the six meta path importer, since the other six instance will have + # inserted an importer with different class. + if (type(importer).__name__ == "_SixMetaPathImporter" and + importer.name == __name__): + del sys.meta_path[i] + break + del i, importer +# Finally, add the importer to the meta path import hook. +sys.meta_path.append(_importer) diff --git a/src/M2Crypto/threading.py b/src/M2Crypto/threading.py new file mode 100644 index 0000000..f9f2683 --- /dev/null +++ b/src/M2Crypto/threading.py @@ -0,0 +1,25 @@ +from __future__ import absolute_import + +""" +M2Crypto threading support, required for multithreaded applications. + +Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.""" + +# M2Crypto +from M2Crypto import m2 + + +def init(): + # type: () -> None + """ + Initialize threading support. + """ + m2.threading_init() + + +def cleanup(): + # type: () -> None + """ + End and cleanup threading support. + """ + m2.threading_cleanup() diff --git a/src/M2Crypto/util.py b/src/M2Crypto/util.py new file mode 100644 index 0000000..97f5d29 --- /dev/null +++ b/src/M2Crypto/util.py @@ -0,0 +1,89 @@ +from __future__ import absolute_import +""" + M2Crypto utility routines. + + NOTHING IN THIS MODULE IS GUARANTEED TO BE STABLE, USED ONLY FOR + INTERNAL PURPOSES OF M2CRYPTO. + + Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + + Portions created by Open Source Applications Foundation (OSAF) are + Copyright (C) 2004 OSAF. All Rights Reserved. +""" + +import binascii +import logging +import sys + +from M2Crypto import m2, six +from typing import Any, Optional, TextIO, Tuple, Union # noqa +# see https://github.com/python/typeshed/issues/222 +AddrType = Union[Tuple[str, int], str] + +log = logging.getLogger('util') + + +class UtilError(Exception): + pass + + +m2.util_init(UtilError) + + +def pkcs5_pad(data, blklen=8): + # type: (str, int) -> str + pad = (8 - (len(data) % 8)) + return data + chr(pad) * pad + + +def pkcs7_pad(data, blklen): + # type: (str, int) -> str + if blklen > 255: + raise ValueError('illegal block size') + pad = (blklen - (len(data) % blklen)) + return data + chr(pad) * pad + + +def bin_to_hex(b): + # type: (bytes) -> str + return six.ensure_text(binascii.b2a_base64(b)[:-1]) + + +def octx_to_num(x): + # type: (bytes) -> int + return int(binascii.hexlify(x), 16) + + +def genparam_callback(p, n, out=sys.stdout): + # type: (int, Any, TextIO) -> None + ch = ['.', '+', '*', '\n'] + out.write(ch[p]) + out.flush() + + +def quiet_genparam_callback(p, n, out): + # type: (Any, Any, Any) -> None + pass + + +def passphrase_callback(v, prompt1='Enter passphrase:', + prompt2='Verify passphrase:'): + # type: (bool, str, str) -> Optional[str] + from getpass import getpass + while 1: + try: + p1 = getpass(prompt1) + if v: + p2 = getpass(prompt2) + if p1 == p2: + break + else: + break + except KeyboardInterrupt: + return None + return p1 + + +def no_passphrase_callback(*args): + # type: (*Any) -> str + return '' diff --git a/src/SWIG/Makefile b/src/SWIG/Makefile new file mode 100644 index 0000000..9a3bd56 --- /dev/null +++ b/src/SWIG/Makefile @@ -0,0 +1,25 @@ +# $Id$ + +CFLAGS = -DTHREADING -g +INCLUDE = -I/usr/local/include -I. +LIBS = -L/usr/local/lib -lssl -lcrypto +#if PYTHON_VERSION +PYVER = $(PYTHON_VERSION) +#else +PYVER = 2.3 +#endif +PYINCLUDE = -DHAVE_CONFIG_H -I/usr/local/include/python$(PYVER) \ + -I/usr/local/lib/python$(PYVER)/config +PYLIB = /usr/local/lib/python$(PYVER)/config + +all: _m2crypto + +_m2crypto: _m2crypto.i + swig -python -shadow _m2crypto.i + cc -c -fpic $(CFLAGS) $(INCLUDE) $(PYINCLUDE) _m2crypto_wrap.c + ld -Bshareable -o _m2crypto.so _m2crypto_wrap.o $(LIBS) + cp m2crypto.py _m2crypto.so ../M2Crypto + +clean: + rm -f *_wrap* *.o *.so _*.py *.pyc + diff --git a/src/SWIG/_aes.i b/src/SWIG/_aes.i new file mode 100644 index 0000000..ea36167 --- /dev/null +++ b/src/SWIG/_aes.i @@ -0,0 +1,90 @@ +/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%{ +#include + +#if OPENSSL_VERSION_NUMBER >= 0x0090800fL +#include +#endif + +/* +// 2004-10-10, ngps: +// CTR mode is not included in the default OpenSSL build. +// To use the AES CTR ciphers, link with your own copy of OpenSSL. +*/ +#ifdef HAVE_AES_CTR +extern EVP_CIPHER const *EVP_aes_128_ctr(void); +extern EVP_CIPHER const *EVP_aes_192_ctr(void); +extern EVP_CIPHER const *EVP_aes_256_ctr(void); +#endif +%} + +%apply Pointer NONNULL { AES_KEY * }; + +%constant int AES_BLOCK_SIZE = AES_BLOCK_SIZE; + +%inline %{ +AES_KEY *aes_new(void) { + AES_KEY *key; + + if (!(key = (AES_KEY *)PyMem_Malloc(sizeof(AES_KEY)))) { + PyErr_SetString(PyExc_MemoryError, + "Insufficient memory for AES key."); + return NULL; + } + return key; +} + +void AES_free(AES_KEY *key) { + PyMem_Free((void *)key); +} + +/* +// op == 0: encrypt +// otherwise: decrypt (Python code will supply the value 1.) +*/ +PyObject *AES_set_key(AES_KEY *key, PyObject *value, int bits, int op) { + char *vbuf; + Py_ssize_t vlen; + + if (PyBytes_AsStringAndSize(value, &vbuf, &vlen) == -1) + return NULL; + + if (op == 0) + AES_set_encrypt_key((const unsigned char *)vbuf, bits, key); + else + AES_set_decrypt_key((const unsigned char *)vbuf, bits, key); + Py_RETURN_NONE; +} + +/* +// op == 0: encrypt +// otherwise: decrypt (Python code will supply the value 1.) +*/ +PyObject *AES_crypt(const AES_KEY *key, PyObject *in, int outlen, int op) { + char *buf; + Py_ssize_t len; + unsigned char *out; + PyObject *res; + + if (PyBytes_AsStringAndSize(in, &buf, &len) == -1) + return NULL; + + if (!(out=(unsigned char *)PyMem_Malloc(outlen))) { + PyErr_SetString(PyExc_MemoryError, "AES_crypt"); + return NULL; + } + if (op == 0) + AES_encrypt((const unsigned char *)buf, out, key); + else + AES_decrypt((const unsigned char *)buf, out, key); + res = PyBytes_FromStringAndSize((char*)out, outlen); + PyMem_Free(out); + return res; +} + +int AES_type_check(AES_KEY *key) { + return 1; +} +%} diff --git a/src/SWIG/_asn1.i b/src/SWIG/_asn1.i new file mode 100644 index 0000000..b51b33f --- /dev/null +++ b/src/SWIG/_asn1.i @@ -0,0 +1,209 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ +/* +** Portions created by Open Source Applications Foundation (OSAF) are +** Copyright (C) 2004 OSAF. All Rights Reserved. +*/ +/* $Id$ */ + +%{ +#include +%} + +%apply Pointer NONNULL { BIO * }; +%apply Pointer NONNULL { ASN1_OBJECT * }; +%apply Pointer NONNULL { ASN1_STRING * }; +%apply Pointer NONNULL { ASN1_INTEGER * }; +%apply Pointer NONNULL { ASN1_TIME * }; + +%rename(asn1_object_new) ASN1_OBJECT_new; +extern ASN1_OBJECT *ASN1_OBJECT_new( void ); +%rename(asn1_object_create) ASN1_OBJECT_create; +extern ASN1_OBJECT *ASN1_OBJECT_create( int, unsigned char *, int, const char *, const char *); +%rename(asn1_object_free) ASN1_OBJECT_free; +extern void ASN1_OBJECT_free( ASN1_OBJECT *); +%rename(i2d_asn1_object) i2d_ASN1_OBJECT; +extern int i2d_ASN1_OBJECT( ASN1_OBJECT *, unsigned char **); +%rename(d2i_asn1_object) d2i_ASN1_OBJECT; +extern ASN1_OBJECT *d2i_ASN1_OBJECT( ASN1_OBJECT **, const unsigned char **, long); + +%rename(asn1_bit_string_new) ASN1_BIT_STRING_new; +extern ASN1_BIT_STRING *ASN1_BIT_STRING_new( void ); + +%rename(asn1_string_new) ASN1_STRING_new; +extern ASN1_STRING *ASN1_STRING_new( void ); +%rename(asn1_string_free) ASN1_STRING_free; +extern void ASN1_STRING_free( ASN1_STRING *); + +%typemap(in) (const void *, int) { + if (PyBytes_Check($input)) { + Py_ssize_t len; + + $1 = PyBytes_AsString($input); + len = PyBytes_Size($input); + + if (len > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "object too large"); + return NULL; + } + $2 = len; + } + else { + PyErr_SetString(PyExc_TypeError, "expected string"); + return NULL; + } +} + +%rename(asn1_string_set) ASN1_STRING_set; +extern int ASN1_STRING_set( ASN1_STRING *, const void *, int); + +%typemap(in) (const void *, int); + +%rename(asn1_string_print) ASN1_STRING_print; +%threadallow ASN1_STRING_print; +extern int ASN1_STRING_print(BIO *, ASN1_STRING *); +%threadallow ASN1_STRING_print_ex; +%rename(asn1_string_print_ex) ASN1_STRING_print_ex; +extern int ASN1_STRING_print_ex(BIO *, ASN1_STRING *, unsigned long); + +%rename(asn1_time_new) ASN1_TIME_new; +extern ASN1_TIME *ASN1_TIME_new( void ); +%rename(asn1_time_free) ASN1_TIME_free; +extern void ASN1_TIME_free(ASN1_TIME *); +%rename(asn1_time_check) ASN1_TIME_check; +extern int ASN1_TIME_check(ASN1_TIME *); +%rename(asn1_time_set) ASN1_TIME_set; +extern ASN1_TIME *ASN1_TIME_set(ASN1_TIME *, long); +%rename(asn1_time_set_string) ASN1_TIME_set_string; +extern int ASN1_TIME_set_string(ASN1_TIME *, const char *); +%rename(asn1_time_print) ASN1_TIME_print; +%threadallow ASN1_TIME_print; +extern int ASN1_TIME_print(BIO *, ASN1_TIME *); + +%rename(asn1_integer_new) ASN1_INTEGER_new; +extern ASN1_INTEGER *ASN1_INTEGER_new( void ); +%rename(asn1_integer_free) ASN1_INTEGER_free; +extern void ASN1_INTEGER_free( ASN1_INTEGER *); +%rename(asn1_integer_cmp) ASN1_INTEGER_cmp; +extern int ASN1_INTEGER_cmp(ASN1_INTEGER *, ASN1_INTEGER *); + +%constant int ASN1_STRFLGS_ESC_2253 = 1; +%constant int ASN1_STRFLGS_ESC_CTRL = 2; +%constant int ASN1_STRFLGS_ESC_MSB = 4; +%constant int ASN1_STRFLGS_ESC_QUOTE = 8; +%constant int ASN1_STRFLGS_UTF8_CONVERT = 0x10; +%constant int ASN1_STRFLGS_IGNORE_TYPE = 0x20; +%constant int ASN1_STRFLGS_SHOW_TYPE = 0x40; +%constant int ASN1_STRFLGS_DUMP_ALL = 0x80; +%constant int ASN1_STRFLGS_DUMP_UNKNOWN = 0x100; +%constant int ASN1_STRFLGS_DUMP_DER = 0x200; + +%constant int ASN1_STRFLGS_RFC2253 = (ASN1_STRFLGS_ESC_2253 | \ + ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + ASN1_STRFLGS_UTF8_CONVERT | \ + ASN1_STRFLGS_DUMP_UNKNOWN | \ + ASN1_STRFLGS_DUMP_DER); + +%inline %{ +/* ASN1_TIME_set_string () is a macro */ +int asn1_time_type_check(ASN1_TIME *ASN1_TIME) { + return 1; +} + +PyObject *asn1_integer_get(ASN1_INTEGER *asn1) { + BIGNUM *bn; + PyObject *ret; + char *hex; + + bn = ASN1_INTEGER_to_BN(asn1, NULL); + + if (!bn){ + m2_PyErr_Msg(PyExc_RuntimeError); + return NULL; + } + + hex = BN_bn2hex(bn); + + if (!hex){ + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return NULL; + } + + BN_free(bn); + + ret = PyLong_FromString(hex, NULL, 16); + + OPENSSL_free(hex); + + return ret; +} + +int asn1_integer_set(ASN1_INTEGER *asn1, PyObject *value) { + BIGNUM *bn = NULL; + PyObject *fmt, *args, *hex; + +/* Despite all hopes to the contrary, we cannot survive here with + * PyLong_AsLong shims as provided in + * /usr/include/python2.7/longobject.h. + */ + long val = PyLong_AsLong(value); + if (val >= 0) { + return ASN1_INTEGER_set(asn1, val); + } else { + PyErr_Clear(); + } + + if (!PyLong_Check(value)){ + PyErr_SetString(PyExc_TypeError, "expected int or long"); + return 0; + } + + fmt = PyUnicode_FromString("%x"); + + if (!fmt) + return 0; + + args = PyTuple_New(1); + + if (!args){ + Py_DECREF(fmt); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() failed"); + return 0; + } + + Py_INCREF(value); + PyTuple_SET_ITEM(args, 0, value); + hex = PyUnicode_Format(fmt, args); + + if (!hex){ + PyErr_SetString(PyExc_RuntimeError, "PyString_Format() failed"); + Py_DECREF(fmt); + Py_DECREF(args); + return 0; + } + + Py_DECREF(fmt); + Py_DECREF(args); + + if (BN_hex2bn(&bn, PyUnicode_AsUTF8(hex)) <= 0){ + m2_PyErr_Msg(PyExc_RuntimeError); + Py_DECREF(hex); + return 0; + } + + Py_DECREF(hex); + + if (!BN_to_ASN1_INTEGER(bn, asn1)){ + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return 0; + } + + BN_free(bn); + + return 1; +} + +%} diff --git a/src/SWIG/_bio.i b/src/SWIG/_bio.i new file mode 100644 index 0000000..84b76b3 --- /dev/null +++ b/src/SWIG/_bio.i @@ -0,0 +1,545 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. + * + * Portions created by Open Source Applications Foundation (OSAF) are + * Copyright (C) 2004-2005 OSAF. All Rights Reserved. + * Author: Heikki Toivonen + * + * Copyright 2018 Daniel Wozniak. All Rights Reserved.*/ +/* $Id$ */ + +%{ +#include +%} + +%apply Pointer NONNULL { BIO * }; +%apply Pointer NONNULL { BIO_METHOD * }; + +%rename(bio_s_bio) BIO_s_bio; +extern BIO_METHOD *BIO_s_bio(void); +%rename(bio_s_mem) BIO_s_mem; +extern BIO_METHOD *BIO_s_mem(void); +%rename(bio_s_socket) BIO_s_socket; +extern BIO_METHOD *BIO_s_socket(void); +%rename(bio_f_ssl) BIO_f_ssl; +extern BIO_METHOD *BIO_f_ssl(void); +%rename(bio_f_buffer) BIO_f_buffer; +extern BIO_METHOD *BIO_f_buffer(void); +%rename(bio_f_cipher) BIO_f_cipher; +extern BIO_METHOD *BIO_f_cipher(void); + +%rename(bio_new) BIO_new; +extern BIO *BIO_new(BIO_METHOD *); +%rename(bio_new_socket) BIO_new_socket; +extern BIO *BIO_new_socket(int, int); +%rename(bio_new_fd) BIO_new_pyfd; +%rename(bio_new_pyfd) BIO_new_pyfd; +%rename(bio_free_all) BIO_free_all; +%threadallow BIO_free_all; +extern void BIO_free_all(BIO *); +%rename(bio_dup_chain) BIO_dup_chain; +extern BIO *BIO_dup_chain(BIO *); + +%rename(bio_push) BIO_push; +extern BIO *BIO_push(BIO *, BIO *); +%rename(bio_pop) BIO_pop; +extern BIO *BIO_pop(BIO *); + +%rename(bio_eof) BIO_eof; +extern int BIO_eof(BIO *); + +%constant int bio_noclose = BIO_NOCLOSE; +%constant int bio_close = BIO_CLOSE; +%constant int BIO_FLAGS_READ = 0x01; +%constant int BIO_FLAGS_WRITE = 0x02; +%constant int BIO_FLAGS_IO_SPECIAL = 0x04; +%constant int BIO_FLAGS_RWS = (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL); +%constant int BIO_FLAGS_SHOULD_RETRY = 0x08; +%constant int BIO_FLAGS_MEM_RDONLY = 0x200; + +%warnfilter(454) _bio_err; +%inline %{ +static PyObject *_bio_err; + + +void pyfd_init(void); + +void bio_init(PyObject *bio_err) { + Py_INCREF(bio_err); + _bio_err = bio_err; + pyfd_init(); +} + +int bio_free(BIO *bio) { + int ret; + + Py_BEGIN_ALLOW_THREADS + ret = BIO_free(bio); + Py_END_ALLOW_THREADS + if (ret == 0) { + m2_PyErr_Msg(_bio_err); + } + return ret; +} + +BIO * bio_new_file(const char *filename, const char *mode) { + BIO *ret; + + Py_BEGIN_ALLOW_THREADS + ret = BIO_new_file(filename, mode); + Py_END_ALLOW_THREADS + + if (ret == NULL) { + m2_PyErr_Msg(_bio_err); + } + + return ret; +} + +BIO *bio_new_pyfile(PyObject *pyfile, int bio_close) { + FILE *fp = NULL; + BIO *bio = NULL; + + fp = PyFile_AsFile(pyfile); + + bio = BIO_new_fp(fp, bio_close); + + /* returns NULL if error occurred */ + if (bio == NULL) { + /* Find out the name of the file so we can have good error + * message. */ + PyObject *pyname = m2_PyFile_Name(pyfile); + char *name = PyBytes_AsString(pyname); + + if (name == NULL) { + PyErr_Format(_bio_err, + "Opening of the new BIO on file failed!"); + } + else { + PyErr_Format(_bio_err, + "Opening of the new BIO on file %s failed!", name); + } + Py_DECREF(pyname); + } + return bio; +} + +PyObject *bio_read(BIO *bio, int num) { + PyObject *blob; + void *buf; + int r; + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "bio_read"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + r = BIO_read(bio, buf, num); + Py_END_ALLOW_THREADS + if (r < 0) { + PyMem_Free(buf); + if (ERR_peek_error()) { + m2_PyErr_Msg(_bio_err); + return NULL; + } + Py_RETURN_NONE; + } + + blob = PyBytes_FromStringAndSize(buf, r); + + PyMem_Free(buf); + return blob; +} + +PyObject *bio_gets(BIO *bio, int num) { + PyObject *blob; + void *buf; + int r; + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "bio_gets"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + r = BIO_gets(bio, buf, num); + Py_END_ALLOW_THREADS + if (r < 1) { + PyMem_Free(buf); + if (ERR_peek_error()) { + m2_PyErr_Msg(_bio_err); + return NULL; + } + Py_RETURN_NONE; + } + + blob = PyBytes_FromStringAndSize(buf, r); + + PyMem_Free(buf); + return blob; +} + +int bio_write(BIO *bio, PyObject *from) { + const void *fbuf; + int flen = 0, ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return -1; + + Py_BEGIN_ALLOW_THREADS + ret = BIO_write(bio, fbuf, flen); + Py_END_ALLOW_THREADS + if (ret < 0) { + if (ERR_peek_error()) { + m2_PyErr_Msg(_bio_err); + return -1; + } + } + return ret; +} + +/* XXX Casting size_t to int. */ +int bio_ctrl_pending(BIO *bio) { + return (int)BIO_ctrl_pending(bio); +} + +int bio_ctrl_wpending(BIO *bio) { + return (int)BIO_ctrl_wpending(bio); +} + +int bio_ctrl_get_write_guarantee(BIO *a) { + return BIO_ctrl_get_write_guarantee(a); +} + +int bio_reset(BIO *bio) { + return (int)BIO_reset(bio); +} +%} + +%threadallow bio_flush; +%inline %{ +int bio_flush(BIO *bio) { + return (int)BIO_flush(bio); +} + +int bio_seek(BIO *bio, int offset) { + return (int)BIO_seek(bio, offset); +} + +int bio_tell(BIO* bio) { + return BIO_tell(bio); +} + +void bio_set_flags(BIO *bio, int flags) { + BIO_set_flags(bio, flags); +} + +int bio_get_flags(BIO *bio) { + return BIO_get_flags(bio); +} + +/* + * sets the cipher of BIO @param b to c using key @param key and IV @iv. + * @param enc should be set to 1 for encryption and zero to decryption. + * + */ +PyObject *bio_set_cipher(BIO *b, EVP_CIPHER *c, PyObject *key, PyObject *iv, int op) { + const void *kbuf, *ibuf; + Py_ssize_t klen, ilen; + + if ((PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) + || (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1)) + return NULL; + + BIO_set_cipher(b, (const EVP_CIPHER *)c, + (unsigned char *)kbuf, (unsigned char *)ibuf, op); + Py_RETURN_NONE; +} + +int bio_set_mem_eof_return(BIO *b, int v) { + return (int)BIO_set_mem_eof_return(b, v); +} + +int bio_get_fd(BIO *bio) { + return BIO_get_fd(bio, NULL); +} +%} + +%warnfilter(454) methods_fdp; +%threadallow bio_do_handshake; +%inline %{ +int bio_do_handshake(BIO *bio) { + return BIO_do_handshake(bio); +} + +/* macro */ +int bio_make_bio_pair(BIO* b1, BIO* b2) { + return BIO_make_bio_pair(b1, b2); +} + +int bio_set_write_buf_size(BIO* b, size_t size) { + return BIO_set_write_buf_size(b, size); +} + +int bio_should_retry(BIO* a) { + return BIO_should_retry(a); +} + +int bio_should_read(BIO* a) { + return BIO_should_read(a); +} + +int bio_should_write(BIO* a) { + return BIO_should_write(a); +} + +/* Macros for things not defined before 1.1.0 */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L +static BIO_METHOD * +BIO_meth_new( int type, const char *name ) +{ + BIO_METHOD *method = malloc( sizeof(BIO_METHOD) ); + memset( method, 0, sizeof(BIO_METHOD) ); + + method->type = type; + method->name = name; + + return method; +} + +static void +BIO_meth_free( BIO_METHOD *meth ) +{ + if ( meth == NULL ) { + return; + } + + free(meth); +} +#define BIO_meth_set_write(m, f) (m)->bwrite = (f) +#define BIO_meth_set_read(m, f) (m)->bread = (f) +#define BIO_meth_set_puts(m, f) (m)->bputs = (f) +#define BIO_meth_set_gets(m, f) (m)->bgets = (f) +#define BIO_meth_set_ctrl(m, f) (m)->ctrl = (f) +#define BIO_meth_set_create(m, f) (m)->create = (f) +#define BIO_meth_set_destroy(m, f) (m)->destroy = (f) +#define BIO_set_shutdown(b, x) (b)->shutdown = x +#define BIO_get_shutdown(b) (b)->shutdown +#define BIO_set_init(b, x) b->init = x +#define BIO_get_init(b) (b)->init +#define BIO_set_data(b, x) b->ptr = x +#define BIO_clear_flags(b, x) b->flags &= ~(x) +#define BIO_get_data(b) b->ptr +#endif + +/* implment custom BIO_s_pyfd */ + +#ifdef _WIN32 +# define clear_sys_error() SetLastError(0) +/* Linux doesn't use underscored calls yet */ +# define open(p, f, m) _open(p, f, m) +# define read(f, b, n) _read(f, b, n) +# define write(f, b, n) _write(f, b, n) +# define close(f) _close(f) +# define lseek(fd, o, w) _lseek(fd, o, w) +#else +# define clear_sys_error() errno=0 +#endif + +typedef struct pyfd_struct { + int fd; +} BIO_PYFD_CTX; + +/* Setting up methods_fdp */ +static BIO_METHOD *methods_fdp; + +static int pyfd_write(BIO *b, const char *in, int inl) { + int ret, fd; + + if (BIO_get_fd(b, &fd) == -1) { + PyErr_SetString(_bio_err, "BIO has not been initialized."); + return -1; + } + clear_sys_error(); + ret = write(fd, in, inl); + BIO_clear_retry_flags(b); + if (ret <= 0) { + if (BIO_fd_should_retry(ret)) + BIO_set_retry_write(b); + } + return ret; +} + +static int pyfd_read(BIO *b, char *out, int outl) { + int ret = 0, fd; + + if (BIO_get_fd(b, &fd) == -1) { + PyErr_SetString(_bio_err, "BIO has not been initialized."); + return -1; + } + if (out != NULL) { + clear_sys_error(); + ret = read(fd, out, outl); + BIO_clear_retry_flags(b); + if (ret <= 0) { + if (BIO_fd_should_retry(ret)) + BIO_set_retry_read(b); + } + } + return ret; +} + +static int pyfd_puts(BIO *bp, const char *str) { + int n, ret; + + n = strlen(str); + ret = pyfd_write(bp, str, n); + return ret; +} + +static int pyfd_gets(BIO *bp, char *buf, int size) { + int ret = 0; + char *ptr = buf; + char *end = buf + size - 1; + + /* See + https://github.com/openssl/openssl/pull/3442 + We were here just repeating a bug from OpenSSL + */ + while (ptr < end && pyfd_read(bp, ptr, 1) > 0) { + if (*ptr++ == '\n') + break; + } + + ptr[0] = '\0'; + + if (buf[0] != '\0') + ret = strlen(buf); + return ret; +} + +static int pyfd_new(BIO* b) { + BIO_PYFD_CTX* ctx; + + ctx = OPENSSL_zalloc(sizeof(*ctx)); + if (ctx == NULL) + return 0; + + ctx->fd = -1; + + BIO_set_data(b, ctx); + BIO_set_shutdown(b, 0); + BIO_set_init(b, 1); + + return 1; + } + +static int pyfd_free(BIO* b) { + BIO_PYFD_CTX* ctx; + + if (b == 0) + return 0; + + ctx = BIO_get_data(b); + if (ctx == NULL) + return 0; + + if (BIO_get_shutdown(b) && BIO_get_init(b)) + close(ctx->fd); + + BIO_set_data(b, NULL); + BIO_set_shutdown(b, 0); + BIO_set_init(b, 0); + + OPENSSL_free(ctx); + + return 1; +} + +static long pyfd_ctrl(BIO *b, int cmd, long num, void *ptr) { + BIO_PYFD_CTX* ctx; + int *ip; + long ret = 1; + + ctx = BIO_get_data(b); + if (ctx == NULL) + return 0; + + switch (cmd) { + case BIO_CTRL_RESET: + num = 0; + case BIO_C_FILE_SEEK: + ret = (long)lseek(ctx->fd, num, 0); + break; + case BIO_C_FILE_TELL: + case BIO_CTRL_INFO: + ret = (long)lseek(ctx->fd, 0, 1); + break; + case BIO_C_SET_FD: + pyfd_free(b); + if (*((int *)ptr) > -1) { + if (!pyfd_new(b) || !(ctx = BIO_get_data(b))) + return 0; + ctx->fd = *((int *)ptr); + BIO_set_shutdown(b, (int)num); + BIO_set_init(b, 1); + } + break; + case BIO_C_GET_FD: + if (BIO_get_init(b)) { + ip = (int *)ptr; + if (ip != NULL) + *ip = ctx->fd; + ret = ctx->fd; + } else + ret = -1; + break; + case BIO_CTRL_GET_CLOSE: + ret = BIO_get_shutdown(b); + break; + case BIO_CTRL_SET_CLOSE: + BIO_set_shutdown(b, (int)num); + break; + case BIO_CTRL_PENDING: + case BIO_CTRL_WPENDING: + ret = 0; + break; + case BIO_CTRL_DUP: + case BIO_CTRL_FLUSH: + ret = 1; + break; + default: + ret = 0; + break; + } + return ret; +} + +void pyfd_init(void) { +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + methods_fdp = BIO_meth_new( + BIO_get_new_index()|BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, + "python file descriptor"); +#else + methods_fdp = BIO_meth_new( + 100 |BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, + "python file descriptor"); +#endif + + BIO_meth_set_write(methods_fdp, pyfd_write); + BIO_meth_set_read(methods_fdp, pyfd_read); + BIO_meth_set_puts(methods_fdp, pyfd_puts); + BIO_meth_set_gets(methods_fdp, pyfd_gets); + BIO_meth_set_ctrl(methods_fdp, pyfd_ctrl); + BIO_meth_set_create(methods_fdp, pyfd_new); + BIO_meth_set_destroy(methods_fdp, pyfd_free); +} + +BIO* BIO_new_pyfd(int fd, int close_flag) { + BIO *ret; + + ret = BIO_new(methods_fdp); + BIO_set_fd(ret, fd, close_flag); + return ret; + } +%} + diff --git a/src/SWIG/_bn.i b/src/SWIG/_bn.i new file mode 100644 index 0000000..18dc154 --- /dev/null +++ b/src/SWIG/_bn.i @@ -0,0 +1,128 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 2005-2006 Open Source Applications Foundation. All rights reserved. */ + +/* We are converting between the Python arbitrarily long integer and + * the BIGNUM arbitrarily long integer by converting to and from + * a string representation of the number (in hexadecimal). + * Direct manipulation would be a possibility, but would require + * tighter integration with the Python and OpenSSL internals. + */ + + +%{ +#include +%} + + +%inline %{ +PyObject *bn_rand(int bits, int top, int bottom) +{ + BIGNUM* rnd; + PyObject *ret; + char *randhex; + + rnd = BN_new(); + if (rnd == NULL) { + m2_PyErr_Msg(PyExc_Exception); + return NULL; + } + + if (!BN_rand(rnd, bits, top, bottom)) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + return NULL; + } + + randhex = BN_bn2hex(rnd); + if (!randhex) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + return NULL; + } + BN_free(rnd); + + ret = PyLong_FromString(randhex, NULL, 16); + OPENSSL_free(randhex); + return ret; +} + + +PyObject *bn_rand_range(PyObject *range) +{ + BIGNUM* rnd; + BIGNUM *rng = NULL; + PyObject *ret, *tuple; + PyObject *format, *rangePyString; + char *randhex; /* PyLong_FromString is unhappy with const */ + const char *rangehex; + + /* Wow, it's a lot of work to convert into a hex string in C! */ + format = PyUnicode_FromString("%x"); + + if (!format) { + PyErr_SetString(PyExc_RuntimeError, "Cannot create Python string '%x'"); + return NULL; + } + tuple = PyTuple_New(1); + if (!tuple) { + Py_DECREF(format); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + Py_INCREF(range); + PyTuple_SET_ITEM(tuple, 0, range); + + rangePyString = PyUnicode_Format(format, tuple); + + if (!rangePyString) { + PyErr_SetString(PyExc_Exception, "String Format failed"); + Py_DECREF(format); + Py_DECREF(tuple); + return NULL; + } + Py_DECREF(format); + Py_DECREF(tuple); + + rangehex = (const char*)PyUnicode_AsUTF8(rangePyString); + + if (!BN_hex2bn(&rng, rangehex)) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + Py_DECREF(rangePyString); + return NULL; + } + + Py_DECREF(rangePyString); + + if (!(rnd = BN_new())) { + PyErr_SetString(PyExc_MemoryError, "bn_rand_range"); + return NULL; + } + + if (!BN_rand_range(rnd, rng)) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + BN_free(rng); + return NULL; + } + + BN_free(rng); + + randhex = BN_bn2hex(rnd); + if (!randhex) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + return NULL; + } + BN_free(rnd); + + ret = PyLong_FromString(randhex, NULL, 16); + OPENSSL_free(randhex); + return ret; +} + +%} diff --git a/src/SWIG/_dh.i b/src/SWIG/_dh.i new file mode 100644 index 0000000..398f418 --- /dev/null +++ b/src/SWIG/_dh.i @@ -0,0 +1,186 @@ +/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%{ +#include +#include +#include +#include +#include +%} + +%apply Pointer NONNULL { DH * }; + +%rename(dh_new) DH_new; +extern DH *DH_new(void); +%rename(dh_free) DH_free; +extern void DH_free(DH *); +%rename(dh_size) DH_size; +extern int DH_size(const DH *); +%rename(dh_generate_key) DH_generate_key; +extern int DH_generate_key(DH *); +%rename(dhparams_print) DHparams_print; +%threadallow DHparams_print; +extern int DHparams_print(BIO *, const DH *); + +%constant int dh_check_ok = 0; +%constant int dh_check_p_not_prime = DH_CHECK_P_NOT_PRIME; +%constant int dh_check_p_not_strong = DH_CHECK_P_NOT_STRONG_PRIME; +%constant int dh_check_g_failed = DH_UNABLE_TO_CHECK_GENERATOR; +%constant int dh_check_bad_g = DH_NOT_SUITABLE_GENERATOR; + +%constant DH_GENERATOR_2 = 2; +%constant DH_GENERATOR_5 = 5; + +%warnfilter(454) _dh_err; +%inline %{ +static PyObject *_dh_err; + +void dh_init(PyObject *dh_err) { + Py_INCREF(dh_err); + _dh_err = dh_err; +} + +int dh_type_check(DH *dh) { + /* Our getting here means we passed Swig's type checking, + XXX Still need to check the pointer for sanity? */ + return 1; +} +%} + +%threadallow dh_read_parameters; +%inline %{ +DH *dh_read_parameters(BIO *bio) { + return PEM_read_bio_DHparams(bio, NULL, NULL, NULL); +} + +DH *dh_generate_parameters(int plen, int g, PyObject *pyfunc) { + DH *dh; + BN_GENCB *gencb; + int ret; + + if ((gencb=BN_GENCB_new()) == NULL) { + m2_PyErr_Msg(_dh_err); + return NULL; + } + + if ((dh=DH_new()) == NULL) { + m2_PyErr_Msg(_dh_err); + BN_GENCB_free(gencb); + return NULL; + } + + BN_GENCB_set(gencb, bn_gencb_callback, (void *)pyfunc); + + Py_INCREF(pyfunc); + ret = DH_generate_parameters_ex(dh, plen, g, gencb); + Py_DECREF(pyfunc); + BN_GENCB_free(gencb); + + if (ret) + return dh; + + m2_PyErr_Msg(_dh_err); + DH_free(dh); + return NULL; +} + +/* Note return value shenanigan. */ +int dh_check(DH *dh) { + int err; + + return (DH_check(dh, &err)) ? 0 : err; +} + +PyObject *dh_compute_key(DH *dh, PyObject *pubkey) { + const void *pkbuf; + int pklen = 0, klen; + void *key; + BIGNUM *pk; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(pubkey, &pkbuf, &pklen) == -1) + return NULL; + + if (!(pk = BN_mpi2bn((unsigned char *)pkbuf, pklen, NULL))) { + m2_PyErr_Msg(_dh_err); + return NULL; + } + if (!(key = PyMem_Malloc(DH_size(dh)))) { + BN_free(pk); + PyErr_SetString(PyExc_MemoryError, "dh_compute_key"); + return NULL; + } + if ((klen = DH_compute_key((unsigned char *)key, pk, dh)) == -1) { + BN_free(pk); + PyMem_Free(key); + m2_PyErr_Msg(_dh_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)key, klen); + + BN_free(pk); + PyMem_Free(key); + return ret; +} + +PyObject *dh_get_p(DH *dh) { + const BIGNUM* p = NULL; + DH_get0_pqg(dh, &p, NULL, NULL); + if (!p) { + PyErr_SetString(_dh_err, "'p' is unset"); + return NULL; + } + return bn_to_mpi(p); +} + +PyObject *dh_get_g(DH *dh) { + const BIGNUM* g = NULL; + DH_get0_pqg(dh, NULL, NULL, &g); + if (!g) { + PyErr_SetString(_dh_err, "'g' is unset"); + return NULL; + } + return bn_to_mpi(g); +} + +PyObject *dh_get_pub(DH *dh) { + const BIGNUM* pub_key = NULL; + DH_get0_key(dh, &pub_key, NULL); + if (!pub_key) { + PyErr_SetString(_dh_err, "'pub' is unset"); + return NULL; + } + return bn_to_mpi(pub_key); +} + +PyObject *dh_get_priv(DH *dh) { + const BIGNUM* priv_key = NULL; + DH_get0_key(dh, NULL, &priv_key); + if (!priv_key) { + PyErr_SetString(_dh_err, "'priv' is unset"); + return NULL; + } + return bn_to_mpi(priv_key); +} + +PyObject *dh_set_pg(DH *dh, PyObject *pval, PyObject* gval) { + BIGNUM* p, *g; + + if (!(p = m2_PyObject_AsBIGNUM(pval, _dh_err)) + || !(g = m2_PyObject_AsBIGNUM(gval, _dh_err))) + return NULL; + + if (!DH_set0_pqg(dh, p, NULL, g)) { + PyErr_SetString(_dh_err, + "Cannot set prime number or generator of Z_p for DH."); + BN_free(p); + BN_free(g); + return NULL; + } + + Py_RETURN_NONE; +} +%} + diff --git a/src/SWIG/_dsa.i b/src/SWIG/_dsa.i new file mode 100644 index 0000000..2c15c4f --- /dev/null +++ b/src/SWIG/_dsa.i @@ -0,0 +1,400 @@ +/* Copyright (c) 1999-2000 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%{ +#include +#include +#include +#include + +PyObject *dsa_sig_get_r(DSA_SIG *dsa_sig) { + const BIGNUM* pr; + DSA_SIG_get0(dsa_sig, &pr, NULL); + return bn_to_mpi(pr); +} + +PyObject *dsa_sig_get_s(DSA_SIG *dsa_sig) { + const BIGNUM* qs; + DSA_SIG_get0(dsa_sig, NULL, &qs); + return bn_to_mpi(qs); +} +%} + +%apply Pointer NONNULL { DSA * }; + +%rename(dsa_new) DSA_new; +extern DSA *DSA_new(void); +%rename(dsa_free) DSA_free; +extern void DSA_free(DSA *); +%rename(dsa_size) DSA_size; +extern int DSA_size(const DSA *); /* assert(dsa->q); */ +%rename(dsa_gen_key) DSA_generate_key; +extern int DSA_generate_key(DSA *); + +%warnfilter(454) _dsa_err; +%inline %{ +static PyObject *_dsa_err; + +void dsa_init(PyObject *dsa_err) { + Py_INCREF(dsa_err); + _dsa_err = dsa_err; +} +%} + +%typemap(out) DSA * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + $result = NULL; + } +} +%inline %{ +DSA *dsa_generate_parameters(int bits, PyObject *pyfunc) { + DSA *dsa; + BN_GENCB *gencb; + int ret; + + if ((gencb=BN_GENCB_new()) == NULL) { + m2_PyErr_Msg(_dh_err); + return NULL; + } + + if ((dsa = DSA_new()) == NULL) { + m2_PyErr_Msg(_dsa_err); + BN_GENCB_free(gencb); + return NULL; + } + + BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); + + Py_INCREF(pyfunc); + ret = DSA_generate_parameters_ex(dsa, bits, NULL, 0, NULL, NULL, + gencb); + Py_DECREF(pyfunc); + BN_GENCB_free(gencb); + + if (ret) + return dsa; + + m2_PyErr_Msg(_dsa_err); + DSA_free(dsa); + return NULL; +} + +DSA *dsa_read_params(BIO *f, PyObject *pyfunc) { + DSA *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_DSAparams(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (ret == NULL) { + m2_PyErr_Msg(_dsa_err); + } + + return ret; +} + +DSA *dsa_read_key(BIO *f, PyObject *pyfunc) { + DSA *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_DSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (ret == NULL) { + m2_PyErr_Msg(_dsa_err); + } + + return ret; +} + +DSA *dsa_read_pub_key(BIO *f, PyObject *pyfunc) { + DSA *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_DSA_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (ret == NULL) { + m2_PyErr_Msg(_dsa_err); + } + + return ret; +} +%} +%typemap(out) DSA * ; + +%inline %{ +PyObject *dsa_get_p(DSA *dsa) { + const BIGNUM* p = NULL; + DSA_get0_pqg(dsa, &p, NULL, NULL); + if (!p) { + PyErr_SetString(_dsa_err, "'p' is unset"); + return NULL; + } + return bn_to_mpi(p); +} + +PyObject *dsa_get_q(DSA *dsa) { + const BIGNUM* q = NULL; + DSA_get0_pqg(dsa, NULL, &q, NULL); + if (!q) { + PyErr_SetString(_dsa_err, "'q' is unset"); + return NULL; + } + return bn_to_mpi(q); +} + +PyObject *dsa_get_g(DSA *dsa) { + const BIGNUM* g = NULL; + DSA_get0_pqg(dsa, NULL, NULL, &g); + if (!g) { + PyErr_SetString(_dsa_err, "'g' is unset"); + return NULL; + } + return bn_to_mpi(g); +} + +PyObject *dsa_get_pub(DSA *dsa) { + const BIGNUM* pub_key = NULL; + DSA_get0_key(dsa, &pub_key, NULL); + if (!pub_key) { + PyErr_SetString(_dsa_err, "'pub' is unset"); + return NULL; + } + return bn_to_mpi(pub_key); +} + +PyObject *dsa_get_priv(DSA *dsa) { + const BIGNUM* priv_key = NULL; + DSA_get0_key(dsa, NULL, &priv_key); + if (!priv_key) { + PyErr_SetString(_dsa_err, "'priv' is unset"); + return NULL; + } + return bn_to_mpi(priv_key); +} + +PyObject *dsa_set_pqg(DSA *dsa, PyObject *pval, PyObject* qval, PyObject* gval) { + BIGNUM* p, *q, *g; + + if (!(p = m2_PyObject_AsBIGNUM(pval, _dsa_err)) + || !(q = m2_PyObject_AsBIGNUM(qval, _dsa_err)) + || !(g = m2_PyObject_AsBIGNUM(gval, _dsa_err))) + return NULL; + + if (!DSA_set0_pqg(dsa, p, q, g)) { + PyErr_SetString( + _dsa_err, + "Cannot set prime number, subprime, or generator of subgroup for DSA."); + BN_free(p); + BN_free(q); + BN_free(g); + return NULL; + } + + Py_RETURN_NONE; + } + +PyObject *dsa_set_pub(DSA *dsa, PyObject *value) { + BIGNUM *bn; + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { + m2_PyErr_Msg(_dsa_err); + return NULL; + } + if (!DSA_set0_key(dsa, bn, NULL)) { + BN_free(bn); + PyErr_SetString(_dsa_err, "Cannot set private and public key for DSA."); + } + Py_RETURN_NONE; +} +%} + +%threadallow dsa_write_params_bio; +%inline %{ +int dsa_write_params_bio(DSA* dsa, BIO* f) { + return PEM_write_bio_DSAparams(f, dsa); +} +%} + +%inline %{ +int dsa_write_key_bio(DSA* dsa, BIO* f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_DSAPrivateKey(f, dsa, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%inline %{ +int dsa_write_key_bio_no_cipher(DSA* dsa, BIO* f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_DSAPrivateKey(f, dsa, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%threadallow dsa_write_pub_key_bio; +%inline %{ +int dsa_write_pub_key_bio(DSA* dsa, BIO* f) { + return PEM_write_bio_DSA_PUBKEY(f, dsa); +} +%} + +%inline %{ +PyObject *dsa_sign(DSA *dsa, PyObject *value) { + const void *vbuf; + int vlen = 0; + PyObject *tuple; + DSA_SIG *sig; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sig = DSA_do_sign(vbuf, vlen, dsa))) { + m2_PyErr_Msg(_dsa_err); + return NULL; + } + if (!(tuple = PyTuple_New(2))) { + DSA_SIG_free(sig); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + PyTuple_SET_ITEM(tuple, 0, dsa_sig_get_r(sig)); + PyTuple_SET_ITEM(tuple, 1, dsa_sig_get_s(sig)); + DSA_SIG_free(sig); + return tuple; +} + +int dsa_verify(DSA *dsa, PyObject *value, PyObject *r, PyObject *s) { + const void *vbuf, *rbuf, *sbuf; + int vlen = 0, rlen = 0, slen = 0; + DSA_SIG *sig; + BIGNUM* pr, *ps; + int ret; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) + || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) + return -1; + + if (!(sig = DSA_SIG_new())) { + m2_PyErr_Msg(_dsa_err); + return -1; + } + if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { + m2_PyErr_Msg(_dsa_err); + DSA_SIG_free(sig); + return -1; + } + if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { + m2_PyErr_Msg(_dsa_err); + DSA_SIG_free(sig); + BN_free(pr); + return -1; + } + if (!DSA_SIG_set0(sig, pr, ps)) { + m2_PyErr_Msg(_dsa_err); + DSA_SIG_free(sig); + BN_free(pr); + BN_free(ps); + return -1; + } + + ret = DSA_do_verify(vbuf, vlen, sig, dsa); + DSA_SIG_free(sig); + if (ret == -1) + m2_PyErr_Msg(_dsa_err); + return ret; +} + +PyObject *dsa_sign_asn1(DSA *dsa, PyObject *value) { + const void *vbuf; + int vlen = 0; + void *sigbuf; + unsigned int siglen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sigbuf = PyMem_Malloc(DSA_size(dsa)))) { + PyErr_SetString(PyExc_MemoryError, "dsa_sign_asn1"); + return NULL; + } + if (!DSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, dsa)) { + m2_PyErr_Msg(_dsa_err); + PyMem_Free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize(sigbuf, siglen); + + PyMem_Free(sigbuf); + return ret; +} + +int dsa_verify_asn1(DSA *dsa, PyObject *value, PyObject *sig) { + const void *vbuf; + void *sbuf; + int vlen = 0, slen = 0, ret = 0; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) + == -1)) + return -1; + + if ((ret = DSA_verify(0, vbuf, vlen, sbuf, slen, dsa)) == -1) + m2_PyErr_Msg(_dsa_err); + return ret; +} + +int dsa_check_key(DSA *dsa) { + const BIGNUM* pub_key, *priv_key; + DSA_get0_key(dsa, &pub_key, &priv_key); + return pub_key != NULL && priv_key != NULL; +} + +int dsa_check_pub_key(DSA *dsa) { + const BIGNUM* pub_key; + DSA_get0_key(dsa, &pub_key, NULL); + return pub_key ? 1 : 0; +} + +int dsa_keylen(DSA *dsa) { + const BIGNUM* p; + DSA_get0_pqg(dsa, &p, NULL, NULL); + return BN_num_bits(p); +} + +int dsa_type_check(DSA *dsa) { + return 1; +} +%} + diff --git a/src/SWIG/_ec.i b/src/SWIG/_ec.i new file mode 100644 index 0000000..f47d593 --- /dev/null +++ b/src/SWIG/_ec.i @@ -0,0 +1,521 @@ +/* Copyright (c) 1999-2000 Ng Pheng Siong. All rights reserved. + Portions copyright (c) 2005-2006 Vrije Universiteit Amsterdam. All rights reserved. + + Most code originally from _dsa.i, _rsa.i and _dh.i and adjusted for EC use. +*/ + +%include + +#if OPENSSL_VERSION_NUMBER < 0x0090800fL || defined(OPENSSL_NO_EC) +#undef OPENSSL_NO_EC +%constant OPENSSL_NO_EC = 1; +#else +%constant OPENSSL_NO_EC = 0; + +%{ +#include +#include +#include +#include +#include +#include +%} + +%apply Pointer NONNULL { EC_KEY * }; + +%rename(ec_key_new) EC_KEY_new; +extern EC_KEY *EC_KEY_new(void); +%rename(ec_key_free) EC_KEY_free; +extern void EC_KEY_free(EC_KEY *); +%rename(ec_key_size) ECDSA_size; +extern int ECDSA_size(const EC_KEY *); +%rename(ec_key_gen_key) EC_KEY_generate_key; +extern int EC_KEY_generate_key(EC_KEY *); +%rename(ec_key_check_key) EC_KEY_check_key; +extern int EC_KEY_check_key(const EC_KEY *); + +/* Curve identifier constants from OpenSSL */ +%constant int NID_secp112r1 = NID_secp112r1; +%constant int NID_secp112r2 = NID_secp112r2; +%constant int NID_secp128r1 = NID_secp128r1; +%constant int NID_secp128r2 = NID_secp128r2; +%constant int NID_secp160k1 = NID_secp160k1; +%constant int NID_secp160r1 = NID_secp160r1; +%constant int NID_secp160r2 = NID_secp160r2; +%constant int NID_secp192k1 = NID_secp192k1; +%constant int NID_secp224k1 = NID_secp224k1; +%constant int NID_secp224r1 = NID_secp224r1; +%constant int NID_secp256k1 = NID_secp256k1; +%constant int NID_secp384r1 = NID_secp384r1; +%constant int NID_secp521r1 = NID_secp521r1; +%constant int NID_sect113r1 = NID_sect113r1; +%constant int NID_sect113r2 = NID_sect113r2; +%constant int NID_sect131r1 = NID_sect131r1; +%constant int NID_sect131r2 = NID_sect131r2; +%constant int NID_sect163k1 = NID_sect163k1; +%constant int NID_sect163r1 = NID_sect163r1; +%constant int NID_sect163r2 = NID_sect163r2; +%constant int NID_sect193r1 = NID_sect193r1; +%constant int NID_sect193r2 = NID_sect193r2; +%constant int NID_sect233k1 = NID_sect233k1; +%constant int NID_sect233r1 = NID_sect233r1; +%constant int NID_sect239k1 = NID_sect239k1; +%constant int NID_sect283k1 = NID_sect283k1; +%constant int NID_sect283r1 = NID_sect283r1; +%constant int NID_sect409k1 = NID_sect409k1; +%constant int NID_sect409r1 = NID_sect409r1; +%constant int NID_sect571k1 = NID_sect571k1; +%constant int NID_sect571r1 = NID_sect571r1; + +%constant int NID_X9_62_prime192v1 = NID_X9_62_prime192v1; +%constant int NID_X9_62_prime192v2 = NID_X9_62_prime192v2; +%constant int NID_X9_62_prime192v3 = NID_X9_62_prime192v3; +%constant int NID_X9_62_prime239v1 = NID_X9_62_prime239v1; +%constant int NID_X9_62_prime239v2 = NID_X9_62_prime239v2; +%constant int NID_X9_62_prime239v3 = NID_X9_62_prime239v3; +%constant int NID_X9_62_prime256v1 = NID_X9_62_prime256v1; +%constant int NID_X9_62_c2pnb163v1 = NID_X9_62_c2pnb163v1; +%constant int NID_X9_62_c2pnb163v2 = NID_X9_62_c2pnb163v2; +%constant int NID_X9_62_c2pnb163v3 = NID_X9_62_c2pnb163v3; +%constant int NID_X9_62_c2pnb176v1 = NID_X9_62_c2pnb176v1; +%constant int NID_X9_62_c2tnb191v1 = NID_X9_62_c2tnb191v1; +%constant int NID_X9_62_c2tnb191v2 = NID_X9_62_c2tnb191v2; +%constant int NID_X9_62_c2tnb191v3 = NID_X9_62_c2tnb191v3; +%constant int NID_X9_62_c2pnb208w1 = NID_X9_62_c2pnb208w1; +%constant int NID_X9_62_c2tnb239v1 = NID_X9_62_c2tnb239v1; +%constant int NID_X9_62_c2tnb239v2 = NID_X9_62_c2tnb239v2; +%constant int NID_X9_62_c2tnb239v3 = NID_X9_62_c2tnb239v3; +%constant int NID_X9_62_c2pnb272w1 = NID_X9_62_c2pnb272w1; +%constant int NID_X9_62_c2pnb304w1 = NID_X9_62_c2pnb304w1; +%constant int NID_X9_62_c2tnb359v1 = NID_X9_62_c2tnb359v1; +%constant int NID_X9_62_c2pnb368w1 = NID_X9_62_c2pnb368w1; +%constant int NID_X9_62_c2tnb431r1 = NID_X9_62_c2tnb431r1; + +%constant int NID_wap_wsg_idm_ecid_wtls1 = NID_wap_wsg_idm_ecid_wtls1; +%constant int NID_wap_wsg_idm_ecid_wtls3 = NID_wap_wsg_idm_ecid_wtls3; +%constant int NID_wap_wsg_idm_ecid_wtls4 = NID_wap_wsg_idm_ecid_wtls4; +%constant int NID_wap_wsg_idm_ecid_wtls5 = NID_wap_wsg_idm_ecid_wtls5; +%constant int NID_wap_wsg_idm_ecid_wtls6 = NID_wap_wsg_idm_ecid_wtls6; +%constant int NID_wap_wsg_idm_ecid_wtls7 = NID_wap_wsg_idm_ecid_wtls7; +%constant int NID_wap_wsg_idm_ecid_wtls8 = NID_wap_wsg_idm_ecid_wtls8; +%constant int NID_wap_wsg_idm_ecid_wtls9 = NID_wap_wsg_idm_ecid_wtls9; +%constant int NID_wap_wsg_idm_ecid_wtls10 = NID_wap_wsg_idm_ecid_wtls10; +%constant int NID_wap_wsg_idm_ecid_wtls11 = NID_wap_wsg_idm_ecid_wtls11; +%constant int NID_wap_wsg_idm_ecid_wtls12 = NID_wap_wsg_idm_ecid_wtls12; + +%constant int NID_ipsec3 = NID_ipsec3; +%constant int NID_ipsec4 = NID_ipsec4; + + +%warnfilter(454) _ec_err; +%inline %{ +static PyObject *_ec_err; + +void ec_init(PyObject *ec_err) { + Py_INCREF(ec_err); + _ec_err = ec_err; +} + +PyObject *ec_get_builtin_curves(void) { + /* size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t + * nitems); */ + EC_builtin_curve *curves; + Py_ssize_t ret_curves = 0; + size_t num_curves = EC_get_builtin_curves(NULL, 0); + PyObject *ret_tuple = NULL; + PyObject *ret_dict = NULL; + Py_ssize_t i; + const char *comment; + const char *sname; + + if (!(curves = PyMem_Malloc(num_curves * sizeof(EC_builtin_curve)))) { + PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); + return NULL; + } + + ret_curves = (Py_ssize_t)EC_get_builtin_curves(curves, num_curves); + + if (!(ret_tuple = PyTuple_New(ret_curves))) { + PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); + return NULL; + } + + for (i = 0; i < ret_curves; i++) { + if (!(ret_dict = PyDict_New())) { + PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); + return NULL; + } + + comment = curves[i].comment; + sname = OBJ_nid2sn(curves[i].nid); + if (sname == NULL) + sname = ""; + + PyDict_SetItemString(ret_dict, "NID", + PyLong_FromLong((long)curves[i].nid)); + PyDict_SetItemString(ret_dict, "sname", + PyString_FromString(sname)); + PyDict_SetItemString(ret_dict, "comment", + PyString_FromString(comment)); + + PyTuple_SET_ITEM(ret_tuple, i, ret_dict); + + } + + PyMem_Free(curves); + + return ret_tuple; +} + +EC_KEY* ec_key_new_by_curve_name(int nid) +{ + EC_KEY *key; + EC_GROUP *group; + int ret =0; + point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; + int asn1_flag = OPENSSL_EC_NAMED_CURVE; + + /* If I simply do "return EC_KEY_new_by_curve_name(nid);" + * I get large public keys (222 vs 84 bytes for sect233k1 curve). + * I don't know why that is, but 'openssl ecparam -genkey ...' sets + * the ASN.1 flag and the point conversion form, and gets the + * small pub keys. So let's do that too. + */ + key = EC_KEY_new(); + if (!key) { + PyErr_SetString(PyExc_MemoryError, "ec_key_new_by_curve_name"); + return NULL; + } + group = EC_GROUP_new_by_curve_name(nid); + if (!group) { + m2_PyErr_Msg(_ec_err); + EC_KEY_free(key); + return NULL; + } + EC_GROUP_set_asn1_flag(group, asn1_flag); + EC_GROUP_set_point_conversion_form(group, form); + ret = EC_KEY_set_group(key, group); + EC_GROUP_free(group); + if (ret == 0) + { + /* EC_KEY_set_group only returns 0 or 1, and does not set error. */ + PyErr_SetString(_ec_err, "cannot set key's group"); + EC_KEY_free(key); + return NULL; + } + + return key; +} + +PyObject *ec_key_get_public_der(EC_KEY *key) { + char *src=NULL; + int src_len=0; + PyObject *pyo=NULL; + + /* Convert to binary */ + src_len = i2d_EC_PUBKEY( key, (unsigned char**)&src ); + if (src_len < 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + /* Create a PyBuffer containing a copy of the binary, + * to simplify memory deallocation + */ + pyo = PyBytes_FromStringAndSize( src, src_len ); + + OPENSSL_free(src); + + return pyo; +} + +PyObject *ec_key_get_public_key(EC_KEY *key) { + char *src=NULL; + int src_len=0; + PyObject *pyo=NULL; + + /* Convert to binary */ + src_len = i2o_ECPublicKey(key, (unsigned char**)&src); + if (src_len < 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + + pyo = PyBytes_FromStringAndSize( src, src_len ); + + OPENSSL_free(src); + + return pyo; +} + +%} + +%threadallow ec_key_read_pubkey; +%inline %{ +EC_KEY *ec_key_read_pubkey(BIO *f) { + return PEM_read_bio_EC_PUBKEY(f, NULL, NULL, NULL); +} +%} + +%threadallow ec_key_write_pubkey; +%inline %{ +int ec_key_write_pubkey(EC_KEY *key, BIO *f) { + return PEM_write_bio_EC_PUBKEY(f, key ); +} +%} + +%inline %{ +EC_KEY *ec_key_read_bio(BIO *f, PyObject *pyfunc) { + EC_KEY *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_ECPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%inline %{ +int ec_key_write_bio(EC_KEY *key, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_ECPrivateKey(f, key, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%inline %{ +int ec_key_write_bio_no_cipher(EC_KEY *key, BIO *f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_ECPrivateKey(f, key, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +PyObject *ecdsa_sig_get_r(ECDSA_SIG *ecdsa_sig) { + const BIGNUM* pr; + ECDSA_SIG_get0(ecdsa_sig, &pr, NULL); + return bn_to_mpi(pr); +} + +PyObject *ecdsa_sig_get_s(ECDSA_SIG *ecdsa_sig) { + const BIGNUM* ps; + ECDSA_SIG_get0(ecdsa_sig, NULL, &ps); + return bn_to_mpi(ps); +} + +PyObject *ecdsa_sign(EC_KEY *key, PyObject *value) { + const void *vbuf; + int vlen = 0; + PyObject *tuple; + ECDSA_SIG *sig; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sig = ECDSA_do_sign(vbuf, vlen, key))) { + m2_PyErr_Msg(_ec_err); + return NULL; + } + if (!(tuple = PyTuple_New(2))) { + ECDSA_SIG_free(sig); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + PyTuple_SET_ITEM(tuple, 0, ecdsa_sig_get_r(sig)); + PyTuple_SET_ITEM(tuple, 1, ecdsa_sig_get_s(sig)); + ECDSA_SIG_free(sig); + return tuple; +} + +int ecdsa_verify(EC_KEY *key, PyObject *value, PyObject *r, PyObject *s) { + const void *vbuf, *rbuf, *sbuf; + int vlen = 0, rlen = 0, slen = 0; + ECDSA_SIG *sig; + int ret; + BIGNUM* pr, *ps; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) + || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) + return -1; + + if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { + m2_PyErr_Msg(_ec_err); + return -1; + } + if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { + m2_PyErr_Msg(_ec_err); + BN_free(pr); + return -1; + } + + if (!(sig = ECDSA_SIG_new())) { + m2_PyErr_Msg(_ec_err); + BN_free(pr); + BN_free(ps); + return -1; + } + if (!ECDSA_SIG_set0(sig, pr, ps)) { + PyErr_SetString(_ec_err, "Cannot set r and s fields of ECDSA_SIG."); + ECDSA_SIG_free(sig); + BN_free(pr); + BN_free(ps); + return -1; + } + ret = ECDSA_do_verify(vbuf, vlen, sig, key); + ECDSA_SIG_free(sig); + if (ret == -1) + m2_PyErr_Msg(_ec_err); + return ret; +} + + +PyObject *ecdsa_sign_asn1(EC_KEY *key, PyObject *value) { + const void *vbuf; + int vlen = 0; + void *sigbuf; + unsigned int siglen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sigbuf = PyMem_Malloc(ECDSA_size(key)))) { + PyErr_SetString(PyExc_MemoryError, "ecdsa_sign_asn1"); + return NULL; + } + if (!ECDSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, key)) { + m2_PyErr_Msg(_ec_err); + PyMem_Free(sigbuf); + return NULL; + } + ret = PyBytes_FromStringAndSize(sigbuf, siglen); + + PyMem_Free(sigbuf); + return ret; +} + + +int ecdsa_verify_asn1(EC_KEY *key, PyObject *value, PyObject *sig) { + const void *vbuf; + void *sbuf; + int vlen = 0, slen = 0, ret; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) + == -1)) + return -1; + + if ((ret = ECDSA_verify(0, vbuf, vlen, sbuf, slen, key)) == -1) + m2_PyErr_Msg(_ec_err); + return ret; +} + +PyObject *ecdh_compute_key(EC_KEY *keypairA, EC_KEY *pubkeyB) { + int sharedkeylen; + void *sharedkey; + const EC_POINT *pkpointB; + PyObject *ret; + const EC_GROUP* groupA; + + if ((pkpointB = EC_KEY_get0_public_key(pubkeyB)) == NULL) + { + PyErr_SetString(_ec_err, "Cannot get the public key of EC_KEY object."); + return NULL; + } + + groupA = EC_KEY_get0_group(keypairA); + sharedkeylen = (EC_GROUP_get_degree(groupA) + 7)/8; + + if (!(sharedkey = PyMem_Malloc(sharedkeylen))) { + PyErr_SetString(PyExc_MemoryError, "ecdh_compute_key"); + return NULL; + } + if ((sharedkeylen = ECDH_compute_key((unsigned char *)sharedkey, sharedkeylen, pkpointB, keypairA, NULL)) == -1) { + m2_PyErr_Msg(_ec_err); + PyMem_Free(sharedkey); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)sharedkey, sharedkeylen); + + PyMem_Free(sharedkey); + + return ret; +} + + +EC_KEY* ec_key_from_pubkey_der(PyObject *pubkey) { + const void *keypairbuf; + Py_ssize_t keypairbuflen; + const unsigned char *tempBuf; + EC_KEY *keypair; + + if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) + { + return NULL; + } + + tempBuf = (const unsigned char *)keypairbuf; + if ((keypair = d2i_EC_PUBKEY( NULL, &tempBuf, keypairbuflen)) == 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + return keypair; +} + +EC_KEY* ec_key_from_pubkey_params(int nid, PyObject *pubkey) { + const void *keypairbuf; + Py_ssize_t keypairbuflen; + const unsigned char *tempBuf; + EC_KEY *keypair; + + if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) + { + return NULL; + } + + keypair = ec_key_new_by_curve_name(nid); + if (!keypair) { + m2_PyErr_Msg(_ec_err); + return NULL; + } + + tempBuf = (const unsigned char *)keypairbuf; + if ((o2i_ECPublicKey( &keypair, &tempBuf, keypairbuflen)) == 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + return keypair; +} + + +// According to [SEC2] the degree of the group is defined as EC key length +int ec_key_keylen(EC_KEY *key) { + const EC_GROUP *group = EC_KEY_get0_group(key); + return EC_GROUP_get_degree(group); +} + +int ec_key_type_check(EC_KEY *key) { + return 1; +} +%} +#endif // if OpenSSL version with EC support + diff --git a/src/SWIG/_engine.i b/src/SWIG/_engine.i new file mode 100644 index 0000000..4ba93f3 --- /dev/null +++ b/src/SWIG/_engine.i @@ -0,0 +1,208 @@ +/* + * -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: syntax=c sts=4 sw=4 + * + * ENGINE functions from engine(3SSL). + * + * Pavel Shramov + * IMEC MSU + */ +%{ +#include +#include +#include +%} + +%apply Pointer NONNULL { ENGINE * }; +%apply Pointer NONNULL { const ENGINE * }; +%apply Pointer NONNULL { const char * }; + +/* + * Functions to load different engines + */ +%rename(engine_load_builtin_engines) ENGINE_load_builtin_engines; +extern void ENGINE_load_builtin_engines(void); + +%rename(engine_load_dynamic) ENGINE_load_dynamic; +extern void ENGINE_load_dynamic(void); + +%rename(engine_load_openssl) ENGINE_load_openssl; +extern void ENGINE_load_openssl(void); + +%rename(engine_cleanup) ENGINE_cleanup; +extern void ENGINE_cleanup(void); + +/* + * Engine allocation functions + */ +%rename(engine_new) ENGINE_new; +extern ENGINE * ENGINE_new(); + +%rename(engine_by_id) ENGINE_by_id; +extern ENGINE * ENGINE_by_id(const char *); + +%rename(engine_free) ENGINE_free; +extern int ENGINE_free(ENGINE *); + +%rename(engine_init) ENGINE_init; +extern int ENGINE_init(ENGINE *); + +%rename(engine_finish) ENGINE_finish; +extern int ENGINE_finish(ENGINE *); + +/* + * Engine id/name functions + */ +%rename(engine_get_id) ENGINE_get_id; +extern const char * ENGINE_get_id(const ENGINE *); + +%rename(engine_get_name) ENGINE_get_name; +extern const char * ENGINE_get_name(const ENGINE *); + +/* + * Engine control functions + * Control argument may be NULL (e.g for LOAD command) + */ +%clear const char *; +%rename(engine_ctrl_cmd_string) ENGINE_ctrl_cmd_string; +extern int ENGINE_ctrl_cmd_string(ENGINE *e, const char *NONNULL, + const char *arg, int cmd_optional); + +%apply Pointer NONNULL { const char * }; + +/* + * UI methods. + * XXX: UI_OpenSSL method is static and UI_destroy_method is not needed. + */ +%rename(ui_openssl) UI_OpenSSL; +extern UI_METHOD * UI_OpenSSL(); + +/* +%rename(ui_destroy_method) UI_destroy_method; +extern void UI_destroy_method(UI_METHOD *ui_method); + */ + +%clear const char *; +%inline %{ + +/* + * Code from engine-pkcs11 1.4.0 in engine-pkcs11.c + * + +99 static char *get_pin(UI_METHOD * ui_method, void *callback_data, char *sc_pin, +100 int maxlen) +101 { +102 UI *ui; +103 struct { +104 const void *password; +105 const char *prompt_info; +106 } *mycb = callback_data; +107 +108 if (mycb->password) { +109 sc_pin = set_pin(mycb->password); +110 return sc_pin; +111 } + + * + * So callback_data need to be always provided and have fixed type. + * UI method still may be NULL. + * + * Following functions allocate and free callback data structure with + * optional password set. + */ + +typedef struct { + char * password; + char * prompt; +} _cbd_t; + +void * engine_pkcs11_data_new(const char *pin) { + _cbd_t * cb = (_cbd_t *) PyMem_Malloc(sizeof(_cbd_t)); + if (!cb) { + PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); + return NULL; + } + cb->password = NULL; + if (pin) { + size_t size = strlen(pin); + cb->password = (char *) PyMem_Malloc(size + 1); + if (!cb->password) { + PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); + PyMem_Free(cb); + return NULL; + } + memcpy(cb->password, pin, size + 1); + } + cb->prompt = NULL; + return cb; +} + +void engine_pkcs11_data_free(void * vcb) { + _cbd_t * cb = (_cbd_t *) vcb; + if (!cb) + return; + if (cb->password) + PyMem_Free(cb->password); + PyMem_Free(cb); +} + +%} +%apply Pointer NONNULL { const char * }; + +/* + * Engine key/cert load functions. + * See above notice about callback_data. + */ +%rename(engine_load_private_key) ENGINE_load_private_key; +extern EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); +%rename(engine_load_public_key) ENGINE_load_public_key; +extern EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, + UI_METHOD *ui_method, void *callback_data); + +/* + * This function may be not implemented in engine. + * pkcs11 engine has this control. + */ +%warnfilter(454) _engine_err; +%inline %{ +static PyObject *_engine_err; + +void engine_init_error(PyObject *engine_err) { + Py_INCREF(engine_err); + _engine_err = engine_err; +} + +X509 * engine_load_certificate(ENGINE *e, const char * slot) { + struct { + const char * slot; + X509 * cert; + } cbd; + cbd.slot = slot; + cbd.cert = NULL; + if (!ENGINE_ctrl_cmd(e, "LOAD_CERT_CTRL", 0, &cbd, NULL, 0)) { + PyErr_SetString(_engine_err, "cannot load certificate"); + return NULL; + } + return cbd.cert; +} +%} + +/* These flags are used to control combinations of algorithm (methods) + * by bitwise "OR"ing. */ +%constant int ENGINE_METHOD_RSA = 0x0001; +%constant int ENGINE_METHOD_DSA = 0x0002; +%constant int ENGINE_METHOD_DH = 0x0004; +%constant int ENGINE_METHOD_RAND = 0x0008; +%constant int ENGINE_METHOD_ECDH = 0x0010; +%constant int ENGINE_METHOD_ECDSA = 0x0020; +%constant int ENGINE_METHOD_CIPHERS = 0x0040; +%constant int ENGINE_METHOD_DIGESTS = 0x0080; +%constant int ENGINE_METHOD_STORE = 0x0100; +/* Obvious all-or-nothing cases. */ +%constant int ENGINE_METHOD_ALL = 0xFFFF; +%constant int ENGINE_METHOD_NONE = 0x0000; + +%rename(engine_set_default) ENGINE_set_default; +extern int ENGINE_set_default(ENGINE *e, unsigned int flags); + diff --git a/src/SWIG/_evp.i b/src/SWIG/_evp.i new file mode 100644 index 0000000..758f11b --- /dev/null +++ b/src/SWIG/_evp.i @@ -0,0 +1,886 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +Copyright (c) 1999 Ng Pheng Siong. All rights reserved. + +Portions Copyright (c) 2004-2007 Open Source Applications Foundation. +Author: Heikki Toivonen + +Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. + +*/ + +%include + +%{ +#include +#include +#include +#include +#include +#include + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + +HMAC_CTX *HMAC_CTX_new(void) { + HMAC_CTX *ret = PyMem_Malloc(sizeof(HMAC_CTX)); + HMAC_CTX_init(ret); + return ret; +} +#define HMAC_CTX_reset(ctx) HMAC_CTX_init(ctx) +#define HMAC_CTX_free(ctx) \ + do { \ + HMAC_CTX_cleanup(ctx); \ + PyMem_Free((void *)ctx); \ + } while(0) + +#define EVP_CIPHER_CTX_reset(ctx) EVP_CIPHER_CTX_init(ctx) +#endif +%} + +/* +from openssl/crypto/include/internal/evp_int.h struct evp_md_st +typedef struct evp_md_st EVP_MD; +from openssl/crypto/evp/evp_locl.h evp_md_ctx_st +typedef struct evp_md_ctx_st EVP_MD_CTX; +*/ + +%apply Pointer NONNULL { EVP_MD_CTX * }; +%apply Pointer NONNULL { EVP_MD * }; +%apply Pointer NONNULL { EVP_PKEY * }; +%apply Pointer NONNULL { HMAC_CTX * }; +%apply Pointer NONNULL { EVP_CIPHER_CTX * }; +%apply Pointer NONNULL { EVP_CIPHER * }; +%apply Pointer NONNULL { RSA * }; + +%rename(md5) EVP_md5; +extern const EVP_MD *EVP_md5(void); +%rename(sha1) EVP_sha1; +extern const EVP_MD *EVP_sha1(void); +%rename(ripemd160) EVP_ripemd160; +extern const EVP_MD *EVP_ripemd160(void); + +#if OPENSSL_VERSION_NUMBER >= 0x0090800fL +%rename(sha224) EVP_sha224; +extern const EVP_MD *EVP_sha224(void); +%rename(sha256) EVP_sha256; +extern const EVP_MD *EVP_sha256(void); +%rename(sha384) EVP_sha384; +extern const EVP_MD *EVP_sha384(void); +%rename(sha512) EVP_sha512; +extern const EVP_MD *EVP_sha512(void); +#endif + +%rename(digest_init) EVP_DigestInit; +extern int EVP_DigestInit(EVP_MD_CTX *, const EVP_MD *); + +%rename(des_ecb) EVP_des_ecb; +extern const EVP_CIPHER *EVP_des_ecb(void); +%rename(des_ede_ecb) EVP_des_ede; +extern const EVP_CIPHER *EVP_des_ede(void); +%rename(des_ede3_ecb) EVP_des_ede3; +extern const EVP_CIPHER *EVP_des_ede3(void); +%rename(des_cbc) EVP_des_cbc; +extern const EVP_CIPHER *EVP_des_cbc(void); +%rename(des_ede_cbc) EVP_des_ede_cbc; +extern const EVP_CIPHER *EVP_des_ede_cbc(void); +%rename(des_ede3_cbc) EVP_des_ede3_cbc; +extern const EVP_CIPHER *EVP_des_ede3_cbc(void); +%rename(des_cfb) EVP_des_cfb; +extern const EVP_CIPHER *EVP_des_cfb(void); +%rename(des_ede_cfb) EVP_des_ede_cfb; +extern const EVP_CIPHER *EVP_des_ede_cfb(void); +%rename(des_ede3_cfb) EVP_des_ede3_cfb; +extern const EVP_CIPHER *EVP_des_ede3_cfb(void); +%rename(des_ofb) EVP_des_ofb; +extern const EVP_CIPHER *EVP_des_ofb(void); +%rename(des_ede_ofb) EVP_des_ede_ofb; +extern const EVP_CIPHER *EVP_des_ede_ofb(void); +%rename(des_ede3_ofb) EVP_des_ede3_ofb; +extern const EVP_CIPHER *EVP_des_ede3_ofb(void); +%rename(bf_ecb) EVP_bf_ecb; +extern const EVP_CIPHER *EVP_bf_ecb(void); +%rename(bf_cbc) EVP_bf_cbc; +extern const EVP_CIPHER *EVP_bf_cbc(void); +%rename(bf_cfb) EVP_bf_cfb; +extern const EVP_CIPHER *EVP_bf_cfb(void); +%rename(bf_ofb) EVP_bf_ofb; +extern const EVP_CIPHER *EVP_bf_ofb(void); +/* +%rename(idea_ecb) extern const EVP_CIPHER *EVP_idea_ecb(void); +%rename(idea_cbc) extern const EVP_CIPHER *EVP_idea_cbc(void); +%rename(idea_cfb) extern const EVP_CIPHER *EVP_idea_cfb(void); +%rename(idea_ofb) extern const EVP_CIPHER *EVP_idea_ofb(void); +*/ +%rename(cast5_ecb) EVP_cast5_ecb; +extern const EVP_CIPHER *EVP_cast5_ecb(void); +%rename(cast5_cbc) EVP_cast5_cbc; +extern const EVP_CIPHER *EVP_cast5_cbc(void); +%rename(cast5_cfb) EVP_cast5_cfb; +extern const EVP_CIPHER *EVP_cast5_cfb(void); +%rename(cast5_ofb) EVP_cast5_ofb; +extern const EVP_CIPHER *EVP_cast5_ofb(void); +/* +%rename(rc5_ecb) extern const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); +%rename(rc5_cbc) extern const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); +%rename(rc5_cfb) extern const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); +%rename(rc5_ofb) extern const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); +*/ +#if !defined(OPENSSL_NO_RC4) +%rename(rc4) EVP_rc4; +extern const EVP_CIPHER *EVP_rc4(void); +#endif +#if !defined(OPENSSL_NO_RC2) +%rename(rc2_40_cbc) EVP_rc2_40_cbc; +extern const EVP_CIPHER *EVP_rc2_40_cbc(void); +#endif +%rename(aes_128_ecb) EVP_aes_128_ecb; +extern const EVP_CIPHER *EVP_aes_128_ecb(void); +%rename(aes_128_cbc) EVP_aes_128_cbc; +extern const EVP_CIPHER *EVP_aes_128_cbc(void); +%rename(aes_128_cfb) EVP_aes_128_cfb; +extern const EVP_CIPHER *EVP_aes_128_cfb(void); +%rename(aes_128_ofb) EVP_aes_128_ofb; +extern const EVP_CIPHER *EVP_aes_128_ofb(void); +%rename(aes_128_ctr) EVP_aes_128_ctr; +extern const EVP_CIPHER *EVP_aes_128_ctr(void); +%rename(aes_192_ecb) EVP_aes_192_ecb; +extern const EVP_CIPHER *EVP_aes_192_ecb(void); +%rename(aes_192_cbc) EVP_aes_192_cbc; +extern const EVP_CIPHER *EVP_aes_192_cbc(void); +%rename(aes_192_cfb) EVP_aes_192_cfb; +extern const EVP_CIPHER *EVP_aes_192_cfb(void); +%rename(aes_192_ofb) EVP_aes_192_ofb; +extern const EVP_CIPHER *EVP_aes_192_ofb(void); +%rename(aes_192_ctr) EVP_aes_192_ctr; +extern const EVP_CIPHER *EVP_aes_192_ctr(void); +%rename(aes_256_ecb) EVP_aes_256_ecb; +extern const EVP_CIPHER *EVP_aes_256_ecb(void); +%rename(aes_256_cbc) EVP_aes_256_cbc; +extern const EVP_CIPHER *EVP_aes_256_cbc(void); +%rename(aes_256_cfb) EVP_aes_256_cfb; +extern const EVP_CIPHER *EVP_aes_256_cfb(void); +%rename(aes_256_ofb) EVP_aes_256_ofb; +extern const EVP_CIPHER *EVP_aes_256_ofb(void); +%rename(aes_256_ctr) EVP_aes_256_ctr; +extern EVP_CIPHER const *EVP_aes_256_ctr(void); + +%rename(cipher_set_padding) EVP_CIPHER_CTX_set_padding; +extern int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *, int); + + +%rename(cipher_set_padding) EVP_CIPHER_CTX_set_padding; +extern int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *x, int padding); +%rename(pkey_free) EVP_PKEY_free; +extern void EVP_PKEY_free(EVP_PKEY *); +%rename(pkey_assign) EVP_PKEY_assign; +extern int EVP_PKEY_assign(EVP_PKEY *, int, char *); +#if OPENSSL_VERSION_NUMBER >= 0x0090800fL && !defined(OPENSSL_NO_EC) +%rename(pkey_assign_ec) EVP_PKEY_assign_EC_KEY; +extern int EVP_PKEY_assign_EC_KEY(EVP_PKEY *, EC_KEY *); +#endif +%rename(pkey_set1_rsa) EVP_PKEY_set1_RSA; +extern int EVP_PKEY_set1_RSA(EVP_PKEY *, RSA *); +%rename(sign_init) EVP_SignInit; +extern int EVP_SignInit(EVP_MD_CTX *, const EVP_MD *); +%rename(verify_init) EVP_VerifyInit; +extern int EVP_VerifyInit(EVP_MD_CTX *, const EVP_MD *); +%rename(digest_sign_init) EVP_DigestSignInit; +extern int EVP_DigestSignInit(EVP_MD_CTX *, EVP_PKEY_CTX **, const EVP_MD *, ENGINE *, EVP_PKEY *); +%rename(digest_verify_init) EVP_DigestVerifyInit; +extern int EVP_DigestVerifyInit(EVP_MD_CTX *, EVP_PKEY_CTX **, const EVP_MD *, ENGINE *, EVP_PKEY *); +%rename(pkey_size) EVP_PKEY_size; +extern int EVP_PKEY_size(EVP_PKEY *); + +%warnfilter(454) _evp_err; +%inline %{ +#define PKCS5_SALT_LEN 8 + +static PyObject *_evp_err; + +void evp_init(PyObject *evp_err) { + Py_INCREF(evp_err); + _evp_err = evp_err; +} +%} + +%typemap(out) RSA * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + $result = NULL; + } +} +%inline %{ +RSA *pkey_get1_rsa(EVP_PKEY *pkey) { + RSA *ret = NULL; + + if ((ret = EVP_PKEY_get1_RSA(pkey)) == NULL) { + /* _evp_err now inherits from PyExc_ValueError, so we should + * keep API intact. + */ + PyErr_Format(_evp_err, "Invalid key in function %s.", __FUNCTION__); + } + + return ret; +} +%} +%typemap(out) RSA * ; + +%inline %{ +PyObject *pkcs5_pbkdf2_hmac_sha1(PyObject *pass, + PyObject *salt, + int iter, + int keylen) { + unsigned char *key; + const void *saltbuf; + const void *passbuf; + PyObject *ret; + int passlen = 0, saltlen = 0; + + if (m2_PyObject_AsReadBufferInt(pass, &passbuf, &passlen) == -1) + return NULL; + if (m2_PyObject_AsReadBufferInt(salt, &saltbuf, &saltlen) == -1) + return NULL; + + key = PyMem_Malloc(keylen); + if (key == NULL) + return PyErr_NoMemory(); + PKCS5_PBKDF2_HMAC_SHA1((const char *)passbuf, passlen, (const unsigned char *)saltbuf, saltlen, iter, + keylen, key); + ret = PyBytes_FromStringAndSize((char*)key, keylen); + OPENSSL_cleanse(key, keylen); + PyMem_Free(key); + return ret; +} + +EVP_MD_CTX *md_ctx_new(void) { + EVP_MD_CTX *ctx; + + if (!(ctx = EVP_MD_CTX_create())) { + PyErr_SetString(PyExc_MemoryError, "md_ctx_new"); + return NULL; + } + return ctx; +} + +void md_ctx_free(EVP_MD_CTX *ctx) { + EVP_MD_CTX_destroy(ctx); +} + +int digest_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + Py_ssize_t len; + + if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) + return -1; + + return EVP_DigestUpdate(ctx, buf, (size_t)len); +} + +PyObject *digest_final(EVP_MD_CTX *ctx) { + void *blob; + int blen; + PyObject *ret; + + if (!(blob = PyMem_Malloc(EVP_MD_CTX_size(ctx)))) { + PyErr_SetString(PyExc_MemoryError, "digest_final"); + return NULL; + } + if (!EVP_DigestFinal(ctx, blob, (unsigned int *)&blen)) { + PyMem_Free(blob); + m2_PyErr_Msg(_evp_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize(blob, blen); + + PyMem_Free(blob); + return ret; +} + +HMAC_CTX *hmac_ctx_new(void) { + HMAC_CTX *ctx; + + if (!(ctx = HMAC_CTX_new())) { + PyErr_SetString(PyExc_MemoryError, "hmac_ctx_new"); + return NULL; + } + return ctx; +} + +void hmac_ctx_free(HMAC_CTX *ctx) { + HMAC_CTX_free(ctx); +} + +PyObject *hmac_init(HMAC_CTX *ctx, PyObject *key, const EVP_MD *md) { + const void *kbuf; + int klen = 0; + + if (m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) + return NULL; + + if (!HMAC_Init_ex(ctx, kbuf, klen, md, NULL)) { + PyErr_SetString(_evp_err, "HMAC_Init failed"); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *hmac_update(HMAC_CTX *ctx, PyObject *blob) { + const void *buf; + Py_ssize_t len; + + if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) + return NULL; + + if (!HMAC_Update(ctx, (const unsigned char *)buf, (size_t)len)) { + PyErr_SetString(_evp_err, "HMAC_Update failed"); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *hmac_final(HMAC_CTX *ctx) { + void *blob; + int blen; + PyObject *ret; + + if (!(blob = PyMem_Malloc(HMAC_size(ctx)))) { + PyErr_SetString(PyExc_MemoryError, "hmac_final"); + return NULL; + } + + if (!HMAC_Final(ctx, blob, (unsigned int *)&blen)) { + PyErr_SetString(_evp_err, "HMAC_Final failed"); + return NULL; + } + + ret = PyBytes_FromStringAndSize(blob, blen); + + PyMem_Free(blob); + return ret; +} + +PyObject *hmac(PyObject *key, PyObject *data, const EVP_MD *md) { + const void *kbuf, *dbuf; + void *blob; + int klen = 0; + unsigned int blen; + Py_ssize_t dlen; + PyObject *ret; + + if ((m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) + || (m2_PyObject_AsReadBuffer(data, &dbuf, &dlen) == -1)) + return NULL; + + if (!(blob = PyMem_Malloc(EVP_MAX_MD_SIZE))) { + PyErr_SetString(PyExc_MemoryError, "hmac"); + return NULL; + } + HMAC(md, kbuf, klen, (const unsigned char *)dbuf, (size_t)dlen, (unsigned char *)blob, &blen); + blob = PyMem_Realloc(blob, blen); + + ret = PyBytes_FromStringAndSize(blob, blen); + + PyMem_Free(blob); + return ret; +} + +EVP_CIPHER_CTX *cipher_ctx_new(void) { + EVP_CIPHER_CTX *ctx; + + if (!(ctx = EVP_CIPHER_CTX_new())) { + PyErr_SetString(PyExc_MemoryError, "cipher_ctx_new"); + return NULL; + } + EVP_CIPHER_CTX_reset(ctx); + return ctx; +} + +void cipher_ctx_free(EVP_CIPHER_CTX *ctx) { + EVP_CIPHER_CTX_free(ctx); +} + +PyObject *bytes_to_key(const EVP_CIPHER *cipher, EVP_MD *md, + PyObject *data, PyObject *salt, + PyObject *iv, /* Not used */ + int iter) { + unsigned char key[EVP_MAX_KEY_LENGTH]; + const void *dbuf, *sbuf; + int dlen = 0, klen; + Py_ssize_t slen; + PyObject *ret; + + if ((m2_PyObject_AsReadBufferInt(data, &dbuf, &dlen) == -1) + || (m2_PyObject_AsReadBuffer(salt, &sbuf, &slen) == -1)) + return NULL; + + assert((slen == 8) || (slen == 0)); + klen = EVP_BytesToKey(cipher, md, (unsigned char *)sbuf, + (unsigned char *)dbuf, dlen, iter, + key, NULL); /* Since we are not returning IV no need to derive it */ + + ret = PyBytes_FromStringAndSize((char*)key, klen); + + return ret; +} + +PyObject *cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + PyObject *key, PyObject *iv, int mode) { + const void *kbuf, *ibuf; + Py_ssize_t klen, ilen; + + if (key == Py_None) + kbuf = NULL; + else if (m2_PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) + return NULL; + + if (iv == Py_None) + ibuf = NULL; + else if (m2_PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1) + return NULL; + + if (!EVP_CipherInit(ctx, cipher, (unsigned char *)kbuf, + (unsigned char *)ibuf, mode)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *cipher_update(EVP_CIPHER_CTX *ctx, PyObject *blob) { + const void *buf; + int len = 0, olen; + void *obuf; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) + return NULL; + + if (!(obuf = PyMem_Malloc(len + EVP_CIPHER_CTX_block_size(ctx) - 1))) { + PyErr_SetString(PyExc_MemoryError, "cipher_update"); + return NULL; + } + if (!EVP_CipherUpdate(ctx, obuf, &olen, (unsigned char *)buf, len)) { + PyMem_Free(obuf); + m2_PyErr_Msg(_evp_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize(obuf, olen); + + PyMem_Free(obuf); + return ret; +} + +PyObject *cipher_final(EVP_CIPHER_CTX *ctx) { + void *obuf; + int olen; + PyObject *ret; + + if (!(obuf = PyMem_Malloc(EVP_CIPHER_CTX_block_size(ctx)))) { + PyErr_SetString(PyExc_MemoryError, "cipher_final"); + return NULL; + } + if (!EVP_CipherFinal(ctx, (unsigned char *)obuf, &olen)) { + PyMem_Free(obuf); + m2_PyErr_Msg(_evp_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize(obuf, olen); + + PyMem_Free(obuf); + return ret; +} + +PyObject *sign_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len; + + if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) + return NULL; + + if (!EVP_SignUpdate(ctx, buf, (Py_ssize_t)len)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *sign_final(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { + PyObject *ret; + unsigned char *sigbuf; + unsigned int siglen = EVP_PKEY_size(pkey); + + sigbuf = (unsigned char*)OPENSSL_malloc(siglen); + if (!sigbuf) { + PyErr_SetString(PyExc_MemoryError, "sign_final"); + return NULL; + } + + if (!EVP_SignFinal(ctx, sigbuf, &siglen, pkey)) { + m2_PyErr_Msg(_evp_err); + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); + + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return ret; +} + +int verify_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len; + + if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) + return -1; + + return EVP_VerifyUpdate(ctx, buf, (Py_ssize_t)len); +} + +int verify_final(EVP_MD_CTX *ctx, PyObject *blob, EVP_PKEY *pkey) { + const void *kbuf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, &kbuf, &len) == -1) + return -1; + + return EVP_VerifyFinal(ctx, (const unsigned char *)kbuf, len, pkey); +} + +int digest_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { + return EVP_DigestSignInit(ctx, NULL, NULL, NULL, pkey); +} + +PyObject *digest_sign_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) + return NULL; + + if (!EVP_DigestSignUpdate(ctx, buf, len)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *digest_sign_final(EVP_MD_CTX *ctx) { + PyObject *ret; + unsigned char *sigbuf; + size_t siglen; + + if (!EVP_DigestSignFinal(ctx, NULL, &siglen)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + + sigbuf = (unsigned char*)OPENSSL_malloc(siglen); + if (!sigbuf) { + PyErr_SetString(PyExc_MemoryError, "digest_sign_final"); + return NULL; + } + + if (!EVP_DigestSignFinal(ctx, sigbuf, &siglen)) { + m2_PyErr_Msg(_evp_err); + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); + + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return ret; +} + +#if OPENSSL_VERSION_NUMBER >= 0x10101000L +PyObject *digest_sign(EVP_MD_CTX *ctx, PyObject *msg) { + PyObject *ret; + const void *msgbuf; + unsigned char *sigbuf; + int msglen = 0; + size_t siglen = 0; + + if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) + return NULL; + + if (!EVP_DigestSign(ctx, NULL, &siglen, msgbuf, msglen)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + + sigbuf = (unsigned char*)OPENSSL_malloc(siglen); + if (!sigbuf) { + PyErr_SetString(PyExc_MemoryError, "digest_sign"); + return NULL; + } + + if (!EVP_DigestSign(ctx, sigbuf, &siglen, msgbuf, msglen)) { + m2_PyErr_Msg(_evp_err); + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); + + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return ret; + +} +#endif + +int digest_verify_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { + return EVP_DigestVerifyInit(ctx, NULL, NULL, NULL, pkey); +} + +int digest_verify_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) + return -1; + + return EVP_DigestVerifyUpdate(ctx, buf, len); +} + +int digest_verify_final(EVP_MD_CTX *ctx, PyObject *blob) { + unsigned char *sigbuf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, (const void **)&sigbuf, &len) == -1) + return -1; + + return EVP_DigestVerifyFinal(ctx, sigbuf, len); +} + +#if OPENSSL_VERSION_NUMBER >= 0x10101000L +int digest_verify(EVP_MD_CTX *ctx, PyObject *sig, PyObject *msg) { + unsigned char *sigbuf; + unsigned char *msgbuf; + int siglen = 0; + int msglen = 0; + + if (m2_PyObject_AsReadBufferInt(sig, (const void **)&sigbuf, &siglen) == -1) + return -1; + + if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) + return -1; + + return EVP_DigestVerify(ctx, sigbuf, siglen, msgbuf, msglen); +} +#endif +%} + +%typemap(out) EVP_MD * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + $result = NULL; + } +} +%inline %{ +const EVP_MD *get_digestbyname(const char* name) { + const EVP_MD *ret = NULL; + + if ((ret = EVP_get_digestbyname(name)) == NULL) { + m2_PyErr_Msg(_evp_err); + } + + return ret; +} +%} +%typemap(out) EVP_MD *; + +%inline %{ +int pkey_write_pem_no_cipher(EVP_PKEY *pkey, BIO *f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%inline %{ +int pkey_write_pem(EVP_PKEY *pkey, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%typemap(out) EVP_PKEY * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + $result = NULL; + } +} +%inline %{ +EVP_PKEY *pkey_new(void) { + EVP_PKEY *ret; + + if ((ret = EVP_PKEY_new()) == NULL) { + PyErr_Format(PyExc_MemoryError, + "Insufficient memory for new key in function %s.", __FUNCTION__); + } + + return ret; +} + +EVP_PKEY *pkey_read_pem(BIO *f, PyObject *pyfunc) { + EVP_PKEY *pk; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + pk = PEM_read_bio_PrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (pk == NULL) { + PyErr_Format(_evp_err, + "Unable to read private key in function %s.", __FUNCTION__); + } + + return pk; +} + +EVP_PKEY *pkey_read_pem_pubkey(BIO *f, PyObject *pyfunc) { + EVP_PKEY *pk; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + pk = PEM_read_bio_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (pk == NULL) { + PyErr_Format(_evp_err, + "Unable to read public key in function %s.", __FUNCTION__); + } + + return pk; +} +%} +%typemap(out) EVP_PKEY * ; + +%inline %{ +int pkey_assign_rsa(EVP_PKEY *pkey, RSA *rsa) { + return EVP_PKEY_assign_RSA(pkey, rsa); +} + +PyObject *pkey_as_der(EVP_PKEY *pkey) { + unsigned char * pp = NULL; + int len; + PyObject * der; + len = i2d_PUBKEY(pkey, &pp); + if (len < 0){ + PyErr_SetString(_evp_err, "EVP_PKEY as DER failed"); + return NULL; + } + + der = PyBytes_FromStringAndSize((char*)pp, len); + + OPENSSL_free(pp); + return der; +} + +PyObject *pkey_get_modulus(EVP_PKEY *pkey) +{ + RSA *rsa; + DSA *dsa; + BIO *bio; + BUF_MEM *bptr; + PyObject *ret; + const BIGNUM* bn; + + switch (EVP_PKEY_base_id(pkey)) { + case EVP_PKEY_RSA: + rsa = EVP_PKEY_get1_RSA(pkey); + + bio = BIO_new(BIO_s_mem()); + if (!bio) { + RSA_free(rsa); + PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); + return NULL; + } + + RSA_get0_key(rsa, &bn, NULL, NULL); + if (!BN_print(bio, bn)) { + m2_PyErr_Msg(PyExc_RuntimeError); + BIO_free(bio); + RSA_free(rsa); + return NULL; + } + BIO_get_mem_ptr(bio, &bptr); + + ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); + + (void)BIO_set_close(bio, BIO_CLOSE); + BIO_free(bio); + RSA_free(rsa); + + return ret; + break; + + case EVP_PKEY_DSA: + dsa = EVP_PKEY_get1_DSA(pkey); + + bio = BIO_new(BIO_s_mem()); + if (!bio) { + DSA_free(dsa); + PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); + return NULL; + } + + DSA_get0_key(dsa, &bn, NULL); + if (!BN_print(bio, bn)) { + m2_PyErr_Msg(PyExc_RuntimeError); + BIO_free(bio); + DSA_free(dsa); + return NULL; + } + BIO_get_mem_ptr(bio, &bptr); + + ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); + + (void)BIO_set_close(bio, BIO_CLOSE); + BIO_free(bio); + DSA_free(dsa); + + return ret; + break; + + default: + PyErr_SetString(_evp_err, "unsupported key type"); + return NULL; + } +} + +%} diff --git a/src/SWIG/_lib.h b/src/SWIG/_lib.h new file mode 100644 index 0000000..f1973b4 --- /dev/null +++ b/src/SWIG/_lib.h @@ -0,0 +1,31 @@ +/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +#include + +typedef struct _blob { + unsigned char *data; + int len; +} Blob; + +Blob *blob_new(int len, const char *errmsg); +Blob *blob_copy(Blob *from, const char *errmsg); +void blob_free(Blob *blob); + +static int m2_PyObject_AsReadBuffer(PyObject *obj, const void **buffer, + Py_ssize_t *buffer_len); +static int m2_PyObject_AsReadBufferInt(PyObject *obj, const void **buffer, + int *buffer_len); +static int m2_PyString_AsStringAndSizeInt(PyObject *obj, char **s, int *len); + +static BIGNUM* m2_PyObject_AsBIGNUM(PyObject* value, PyObject* _py_exc) ; + +/* Always use these two together, to correctly handle non-memoryview objects. */ +static int m2_PyObject_GetBufferInt(PyObject *obj, Py_buffer *view, int flags); +static void m2_PyBuffer_Release(PyObject *obj, Py_buffer *view); + +int bn_gencb_callback(int p, int n, BN_GENCB *gencb); +int passphrase_callback(char *buf, int num, int v, void *userdata); + +void lib_init(void); + diff --git a/src/SWIG/_lib.i b/src/SWIG/_lib.i new file mode 100644 index 0000000..954e99b --- /dev/null +++ b/src/SWIG/_lib.i @@ -0,0 +1,777 @@ +/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%{ +#include +#include +#include +#include +#include +#include +#include +#include +#include +%} + +/* OpenSSL 1.1 compatibility shim */ +%include _lib11_compat.i + +/* Python 3 compatibility shim */ +%include _py3k_compat.i + +%{ +/* OpenSSL 1.0.2 copmatbility shim */ +#if OPENSSL_VERSION_NUMBER < 0x10002000L +typedef void (*OPENSSL_sk_freefunc)(void *); +typedef void *(*OPENSSL_sk_copyfunc)(const void *); +typedef struct stack_st OPENSSL_STACK; + +# define MIN_NODES 4 +# define sk_deep_copy OPENSSL_sk_deep_copy + +void OPENSSL_sk_free(OPENSSL_STACK *st) +{ + if (st == NULL) + return; + OPENSSL_free(st->data); + OPENSSL_free(st); +} + +OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, + OPENSSL_sk_copyfunc copy_func, + OPENSSL_sk_freefunc free_func) +{ + OPENSSL_STACK *ret; + int i; + + if (sk->num < 0) + return NULL; + + if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) + return NULL; + + /* direct structure assignment */ + *ret = *sk; + + ret->num_alloc = sk->num > MIN_NODES ? (size_t)sk->num : MIN_NODES; + ret->data = OPENSSL_zalloc(sizeof(*ret->data) * ret->num_alloc); + if (ret->data == NULL) { + OPENSSL_free(ret); + return NULL; + } + + for (i = 0; i < ret->num; ++i) { + if (sk->data[i] == NULL) + continue; + if ((ret->data[i] = copy_func(sk->data[i])) == NULL) { + while (--i >= 0) + if (ret->data[i] != NULL) + free_func((void *)ret->data[i]); + OPENSSL_sk_free(ret); + return NULL; + } + } + return ret; +} +#endif /* OpenSSL 1.0.2 copmatbility shim */ + + +/* Blob interface. Deprecated. */ + +Blob *blob_new(int len, const char *errmsg) { + + Blob *blob; + if (!(blob=(Blob *)PyMem_Malloc(sizeof(Blob)))){ + PyErr_SetString(PyExc_MemoryError, errmsg); + return NULL; + } + if (!(blob->data=(unsigned char *)PyMem_Malloc(len))) { + PyMem_Free(blob); + PyErr_SetString(PyExc_MemoryError, errmsg); + return NULL; + } + blob->len=len; + return blob; +} + +Blob *blob_copy(Blob *from, const char *errmsg) { + Blob *blob=blob_new(from->len, errmsg); + if (!blob) { + PyErr_SetString(PyExc_MemoryError, errmsg); + return NULL; + } + memcpy(blob->data, from->data, from->len); + return blob; +} + +void blob_free(Blob *blob) { + PyMem_Free(blob->data); + PyMem_Free(blob); +} + + +/* Python helpers. */ + +%} +%ignore PyObject_CheckBuffer; +%ignore PyObject_GetBuffer; +%ignore PyBuffer_Release; +%ignore m2_PyObject_AsReadBuffer; +%ignore m2_PyObject_AsReadBufferInt; +%ignore m2_PyObject_GetBufferInt; +%ignore m2_PyBuffer_Release; +%ignore m2_PyString_AsStringAndSizeInt; +%{ + +static int +m2_PyObject_AsReadBuffer(PyObject * obj, const void **buffer, + Py_ssize_t * buffer_len) +{ + int ret = 0; + Py_ssize_t len = 0; + Py_buffer view; + + if (PyObject_CheckBuffer(obj)) { + if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) == 0) { + *buffer = view.buf; + len = view.len; + } + } else { + if ((ret = PyObject_AsReadBuffer(obj, buffer, &len)) != 0) + return ret; + } + if (len > INT_MAX) { + m2_PyBuffer_Release(obj, &view); + PyErr_SetString(PyExc_ValueError, "object too large"); + return -1; + } + *buffer_len = len; + m2_PyBuffer_Release(obj, &view); + return 0; +} + +static int +m2_PyObject_AsReadBufferInt(PyObject * obj, const void **buffer, + int *buffer_len) +{ + int ret = 0; + Py_ssize_t len = 0; + + ret = m2_PyObject_AsReadBuffer(obj, buffer, &len); + *buffer_len = len; + return ret; +} + + + +static int m2_PyObject_GetBufferInt(PyObject *obj, Py_buffer *view, int flags) +{ + int ret; + + if (PyObject_CheckBuffer(obj)) + ret = PyObject_GetBuffer(obj, view, flags); + else { + const void *buf; + + ret = PyObject_AsReadBuffer(obj, &buf, &view->len); + if (ret == 0) + view->buf = (void *)buf; + } + if (ret) + return ret; + if (view->len > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "object too large"); + m2_PyBuffer_Release(obj, view); + return -1; + } + + return 0; +} + +static BIGNUM* +m2_PyObject_AsBIGNUM(PyObject* value, PyObject* _py_exc) +{ + BIGNUM* bn; + const void* vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { + PyErr_SetString(_py_exc, ERR_reason_error_string(ERR_get_error())); + return NULL; + } + + return bn; +} + +static void m2_PyBuffer_Release(PyObject *obj, Py_buffer *view) +{ + if (PyObject_CheckBuffer(obj)) + PyBuffer_Release(view); + /* else do nothing, view->buf comes from PyObject_AsReadBuffer */ +} + +static int +m2_PyString_AsStringAndSizeInt(PyObject *obj, char **s, int *len) +{ + int ret; + Py_ssize_t len2; + + ret = PyBytes_AsStringAndSize(obj, s, &len2); + + if (ret) + return ret; + if (len2 > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "string too large"); + return -1; + } + *len = len2; + return 0; +} + +/* Works as PyFile_Name, but always returns a new object. */ +PyObject *m2_PyFile_Name(PyObject *pyfile) { + PyObject *out = NULL; +#if PY_MAJOR_VERSION >= 3 + out = PyObject_GetAttrString(pyfile, "name"); +#else + out = PyFile_Name(pyfile); + Py_XINCREF(out); +#endif + return out; +} + +/* Yes, __FUNCTION__ is a non-standard symbol, but it is supported by + * both gcc and MSVC. */ +#define m2_PyErr_Msg(type) m2_PyErr_Msg_Caller(type, (const char*) __FUNCTION__) + +static void m2_PyErr_Msg_Caller(PyObject *err_type, const char* caller) { + const char *err_reason; + const char *data; + int flags; + /* This max size of a (longer than ours) OpenSSL error string is hardcoded + * in OpenSSL's crypto/err/err_prn.c:ERR_print_errors_cb() */ + char err_msg[4096]; + unsigned long err_code = ERR_get_error_line_data(NULL, NULL, &data, &flags); + + if (err_code != 0) { + err_reason = ERR_reason_error_string(err_code); + if (data && (flags & ERR_TXT_STRING)) + snprintf(err_msg, sizeof(err_msg), "%s (%s)", err_reason, data); + else + snprintf(err_msg, sizeof(err_msg), "%s", err_reason); + + PyErr_SetString(err_type, err_msg); + } else { + PyErr_Format(err_type, "Unknown error in function %s.", caller); + } +} + + +/* C callbacks invoked by OpenSSL; these in turn call back into +Python. */ + +int ssl_verify_callback(int ok, X509_STORE_CTX *ctx) { + PyObject *argv, *ret; + PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; + PyObject *_x509=0, *_ssl_ctx=0; + SSL *ssl; + SSL_CTX *ssl_ctx; + X509 *x509; + int errnum, errdepth; + int cret; + int new_style_callback = 0, warning_raised_exception=0; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + ssl = (SSL *)X509_STORE_CTX_get_app_data(ctx); + + gilstate = PyGILState_Ensure(); + + if (PyMethod_Check(ssl_verify_cb_func)) { + PyObject *func; + PyCodeObject *code; + func = PyMethod_Function(ssl_verify_cb_func); + code = (PyCodeObject *) PyFunction_GetCode(func); + if (code && code->co_argcount == 3) { /* XXX Python internals */ + new_style_callback = 1; + } + } else if (PyFunction_Check(ssl_verify_cb_func)) { + PyCodeObject *code = (PyCodeObject *) PyFunction_GetCode(ssl_verify_cb_func); + if (code && code->co_argcount == 2) { /* XXX Python internals */ + new_style_callback = 1; + } + } else { + /* XXX There are lots of other callable types, but we will assume + * XXX that any other type of callable uses the new style callback, + * XXX although this is not entirely safe assumption. + */ + new_style_callback = 1; + } + + if (new_style_callback) { + PyObject *x509mod; + + x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); + _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); + + _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); + _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); + + _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); + + argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); + } else { + if (PyErr_Warn(PyExc_DeprecationWarning, "Old style callback, use cb_func(ok, store) instead")) { + warning_raised_exception = 1; + } + + x509 = X509_STORE_CTX_get_current_cert(ctx); + errnum = X509_STORE_CTX_get_error(ctx); + errdepth = X509_STORE_CTX_get_error_depth(ctx); + + ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); + ssl_ctx = SSL_get_SSL_CTX(ssl); + + _x509 = SWIG_NewPointerObj((void *)x509, SWIGTYPE_p_X509, 0); + _ssl_ctx = SWIG_NewPointerObj((void *)ssl_ctx, SWIGTYPE_p_SSL_CTX, 0); + argv = Py_BuildValue("(OOiii)", _ssl_ctx, _x509, errnum, errdepth, ok); + } + + if (!warning_raised_exception) { + ret = PyEval_CallObject(ssl_verify_cb_func, argv); + } else { + ret = 0; + } + + if (!ret) { + /* Got an exception in PyEval_CallObject(), let's fail verification + * to be safe. + */ + cret = 0; + } else { + /* FIXME This is possibly problematic if ret > MAXINT */ + cret = (int)PyLong_AsLong(ret); + } + Py_XDECREF(ret); + Py_XDECREF(argv); + if (new_style_callback) { + Py_XDECREF(_x509_store_ctx_inst); + Py_XDECREF(_x509_store_ctx_obj); + Py_XDECREF(_x509_store_ctx_swigptr); + Py_XDECREF(_klass); + } else { + Py_XDECREF(_x509); + Py_XDECREF(_ssl_ctx); + } + + PyGILState_Release(gilstate); + + return cret; +} + +int x509_store_verify_callback(int ok, X509_STORE_CTX *ctx) { + PyGILState_STATE gilstate; + PyObject *argv, *ret; + PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; + int cret; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + PyObject *x509mod; + + + gilstate = PyGILState_Ensure(); + + /* Below, handle only what is called 'new style callback' in ssl_verify_callback(). + TODO: does 'old style callback' exist any more? */ + x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); + _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); + _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); + _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); + + _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); + + argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); + + ret = PyEval_CallObject(x509_store_verify_cb_func, argv); + if (!ret) { + /* Got an exception in PyEval_CallObject(), let's fail verification + * to be safe. + */ + cret = 0; + } else { + cret = (int)PyInt_AsLong(ret); + } + + Py_XDECREF(ret); + Py_XDECREF(argv); + Py_XDECREF(_x509_store_ctx_inst); + Py_XDECREF(_x509_store_ctx_obj); + Py_XDECREF(_x509_store_ctx_swigptr); + Py_XDECREF(_klass); + + PyGILState_Release(gilstate); + return cret; +} + +void ssl_info_callback(const SSL *s, int where, int ret) { + PyObject *argv, *retval, *_SSL; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + gilstate = PyGILState_Ensure(); + + _SSL = SWIG_NewPointerObj((void *)s, SWIGTYPE_p_SSL, 0); + argv = Py_BuildValue("(iiO)", where, ret, _SSL); + + retval = PyEval_CallObject(ssl_info_cb_func, argv); + + Py_XDECREF(retval); + Py_XDECREF(argv); + Py_XDECREF(_SSL); + + PyGILState_Release(gilstate); +} + +DH *ssl_set_tmp_dh_callback(SSL *ssl, int is_export, int keylength) { + PyObject *argv, *ret, *_ssl; + DH *dh; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + gilstate = PyGILState_Ensure(); + + _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); + argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); + + ret = PyEval_CallObject(ssl_set_tmp_dh_cb_func, argv); + + if ((SWIG_ConvertPtr(ret, (void **)&dh, SWIGTYPE_p_DH, SWIG_POINTER_EXCEPTION | 0)) == -1) + dh = NULL; + Py_XDECREF(ret); + Py_XDECREF(argv); + Py_XDECREF(_ssl); + + PyGILState_Release(gilstate); + + return dh; +} + +RSA *ssl_set_tmp_rsa_callback(SSL *ssl, int is_export, int keylength) { + PyObject *argv, *ret, *_ssl; + RSA *rsa; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + gilstate = PyGILState_Ensure(); + + _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); + argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); + + ret = PyEval_CallObject(ssl_set_tmp_rsa_cb_func, argv); + + if ((SWIG_ConvertPtr(ret, (void **)&rsa, SWIGTYPE_p_RSA, SWIG_POINTER_EXCEPTION | 0)) == -1) + rsa = NULL; + Py_XDECREF(ret); + Py_XDECREF(argv); + Py_XDECREF(_ssl); + + PyGILState_Release(gilstate); + + return rsa; +} + +/* Universal callback for dh_generate_parameters, + * dsa_generate_parametersm, and rsa_generate_key */ +int bn_gencb_callback(int p, int n, BN_GENCB *gencb) { + PyObject *argv, *ret, *cbfunc; + + cbfunc = (PyObject *)BN_GENCB_get_arg(gencb); + argv = Py_BuildValue("(ii)", p, n); + ret = PyEval_CallObject(cbfunc, argv); + PyErr_Clear(); + Py_DECREF(argv); + Py_XDECREF(ret); + return 1; +} + +int passphrase_callback(char *buf, int num, int v, void *arg) { + int i; + Py_ssize_t len; + char *str; + PyObject *argv, *ret, *cbfunc; + PyGILState_STATE gilstate; + + gilstate = PyGILState_Ensure(); + cbfunc = (PyObject *)arg; + argv = Py_BuildValue("(i)", v); + /* PyEval_CallObject sets exception, if needed. */ + ret = PyEval_CallObject(cbfunc, argv); + Py_DECREF(argv); + if (ret == NULL) { + PyGILState_Release(gilstate); + return -1; + } + + if (!PyBytes_Check(ret)) { + PyErr_SetString(PyExc_RuntimeError, + "Result of callback is not bytes()."); + Py_DECREF(ret); + PyGILState_Release(gilstate); + return -1; + } + if ((len = PyBytes_Size(ret)) > num) + len = num; + str = PyBytes_AsString(ret); + + for (i = 0; i < len; i++) + buf[i] = str[i]; + Py_DECREF(ret); + PyGILState_Release(gilstate); + return len; +} +%} + +%inline %{ + +void lib_init() { +#if OPENSSL_VERSION_NUMBER < 0x10100000L + SSLeay_add_all_algorithms(); + ERR_load_ERR_strings(); +#endif +} + +/* Bignum routines that aren't not numerous enough to +warrant a separate file. */ + +PyObject *bn_to_mpi(const BIGNUM *bn) { + int len = 0; + unsigned char *mpi; + PyObject *pyo; + + len = BN_bn2mpi(bn, NULL); + if (!(mpi=(unsigned char *)PyMem_Malloc(len))) { + m2_PyErr_Msg(PyExc_MemoryError); + return NULL; + } + len=BN_bn2mpi(bn, mpi); + + pyo=PyBytes_FromStringAndSize((const char *)mpi, len); + + PyMem_Free(mpi); + return pyo; +} + +const BIGNUM *mpi_to_bn(PyObject *value) { + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + return BN_mpi2bn(vbuf, vlen, NULL); +} + +PyObject *bn_to_bin(BIGNUM *bn) { + int len = 0; + unsigned char *bin; + PyObject *pyo; + + len = BN_num_bytes(bn); + if (!(bin=(unsigned char *)PyMem_Malloc(len))) { + PyErr_SetString(PyExc_MemoryError, "bn_to_bin"); + return NULL; + } + BN_bn2bin(bn, bin); + + pyo=PyBytes_FromStringAndSize((const char *)bin, len); + + PyMem_Free(bin); + return pyo; +} + +const BIGNUM *bin_to_bn(PyObject *value) { + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + return BN_bin2bn(vbuf, vlen, NULL); +} + +PyObject *bn_to_hex(BIGNUM *bn) { + char *hex; + PyObject *pyo; + Py_ssize_t len = 0; + + hex = BN_bn2hex(bn); + if (!hex) { + m2_PyErr_Msg(PyExc_RuntimeError); + OPENSSL_free(hex); + return NULL; + } + len = strlen(hex); + + pyo=PyBytes_FromStringAndSize(hex, len); + + OPENSSL_free(hex); + return pyo; +} + +BIGNUM *hex_to_bn(PyObject *value) { + const void *vbuf; + Py_ssize_t vlen = 0; + BIGNUM *bn; + Py_buffer view; + + if (PyObject_CheckBuffer(value)) { + if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { + vbuf = view.buf; + vlen = view.len; + } + } + else { + if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) + return NULL; + } + + if ((bn=BN_new())==NULL) { + m2_PyBuffer_Release(value, &view); + PyErr_SetString(PyExc_MemoryError, "hex_to_bn"); + return NULL; + } + if (BN_hex2bn(&bn, (const char *)vbuf) <= 0) { + m2_PyBuffer_Release(value, &view); + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return NULL; + } + m2_PyBuffer_Release(value, &view); + return bn; +} + +BIGNUM *dec_to_bn(PyObject *value) { + const void *vbuf; + Py_ssize_t vlen = 0; + BIGNUM *bn; + Py_buffer view; + + if (PyObject_CheckBuffer(value)) { + if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { + vbuf = view.buf; + vlen = view.len; + } + } + else { + if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) + return NULL; + } + + if ((bn=BN_new())==NULL) { + m2_PyBuffer_Release(value, &view); + PyErr_SetString(PyExc_MemoryError, "dec_to_bn"); + return NULL; + } + if ((BN_dec2bn(&bn, (const char *)vbuf) <= 0)) { + m2_PyBuffer_Release(value, &view); + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return NULL; + } + m2_PyBuffer_Release(value, &view); + return bn; +} +%} + + +/* Various useful typemaps. */ + +%typemap(in) Blob * { + Py_ssize_t len = 0; + + if (!PyBytes_Check($input)) { + PyErr_SetString(PyExc_TypeError, "expected PyString"); + return NULL; + } + len=PyBytes_Size($input); + + if (len > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "object too large"); + return NULL; + } + $1=(Blob *)PyMem_Malloc(sizeof(Blob)); + if (!$1) { + PyErr_SetString(PyExc_MemoryError, "malloc Blob"); + return NULL; + } + + $1->data=(unsigned char *)PyBytes_AsString($input); + + $1->len=len; +} + +%typemap(out) Blob * { + if ($1==NULL) { + Py_INCREF(Py_None); + $result=Py_None; + } else { + + $result=PyBytes_FromStringAndSize((const char *)$1->data, $1->len); + + PyMem_Free($1->data); + PyMem_Free($1); + } +} + +%typemap(in) PyObject *pyfunc { + if (!PyCallable_Check($input)) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + $1=$input; +} + +%typemap(in) PyObject *pyblob { + if (!PyBytes_Check($input)) { + + PyErr_SetString(PyExc_TypeError, "expected PyString"); + return NULL; + } + $1=$input; +} + +%typemap(in) PyObject * { + $1=$input; +} + +%typemap(out) PyObject * { + $result=$1; +} + +%typemap(out) int { + $result=PyLong_FromLong($1); + if (PyErr_Occurred()) SWIG_fail; +} + +/* Pointer checks. */ + +%apply Pointer NONNULL { Blob * }; + + +/* A bunch of "straight-thru" functions. */ + +%rename(err_print_errors) ERR_print_errors; +%threadallow ERR_print_errors; +extern void ERR_print_errors(BIO *); +%rename(err_get_error) ERR_get_error; +extern unsigned long ERR_get_error(void); +%rename(err_peek_error) ERR_peek_error; +extern unsigned long ERR_peek_error(void); +%rename(err_lib_error_string) ERR_lib_error_string; +extern const char *ERR_lib_error_string(unsigned long); +%rename(err_func_error_string) ERR_func_error_string; +extern const char *ERR_func_error_string(unsigned long); +%rename(err_reason_error_string) ERR_reason_error_string; +extern const char *ERR_reason_error_string(unsigned long); diff --git a/src/SWIG/_lib11_compat.i b/src/SWIG/_lib11_compat.i new file mode 100644 index 0000000..1ec42dd --- /dev/null +++ b/src/SWIG/_lib11_compat.i @@ -0,0 +1,458 @@ +/* + * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * + * Licensed under the OpenSSL license (the "License"). You may not use + * this file except in compliance with the License. You can obtain a copy + * in the file LICENSE in the source distribution or at + * https://www.openssl.org/source/license.html + */ + +%{ +#if OPENSSL_VERSION_NUMBER < 0x10100000L + +#include +#include + +# define OPENSSL_zalloc(num) \ + CRYPTO_zalloc(num, __FILE__, __LINE__) + +static void *CRYPTO_zalloc(size_t num, const char *file, int line) +{ + void *ret = CRYPTO_malloc(num, file, line); + if (ret != NULL) + memset(ret, 0, num); + return ret; +} + +#include + +#ifndef BN_F_BN_GENCB_NEW +# define BN_F_BN_GENCB_NEW 143 +#endif + +# define BN_GENCB_get_arg(gencb) ((gencb)->arg) + +BN_GENCB *BN_GENCB_new(void) +{ + BN_GENCB *ret; + + if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) { + BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE); + return (NULL); + } + + return ret; +} + +void BN_GENCB_free(BN_GENCB *cb) +{ + if (cb == NULL) + return; + OPENSSL_free(cb); +} + + +int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) +{ + /* If the fields n and e in r are NULL, the corresponding input + * parameters MUST be non-NULL for n and e. d may be + * left NULL (in case only the public key is used). + */ + if ((r->n == NULL && n == NULL) + || (r->e == NULL && e == NULL)) + return 0; + + if (n != NULL) { + BN_free(r->n); + r->n = n; + } + if (e != NULL) { + BN_free(r->e); + r->e = e; + } + if (d != NULL) { + BN_free(r->d); + r->d = d; + } + + return 1; +} + +int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) +{ + /* If the fields p and q in r are NULL, the corresponding input + * parameters MUST be non-NULL. + */ + if ((r->p == NULL && p == NULL) + || (r->q == NULL && q == NULL)) + return 0; + + if (p != NULL) { + BN_free(r->p); + r->p = p; + } + if (q != NULL) { + BN_free(r->q); + r->q = q; + } + + return 1; +} + +int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) +{ + /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input + * parameters MUST be non-NULL. + */ + if ((r->dmp1 == NULL && dmp1 == NULL) + || (r->dmq1 == NULL && dmq1 == NULL) + || (r->iqmp == NULL && iqmp == NULL)) + return 0; + + if (dmp1 != NULL) { + BN_free(r->dmp1); + r->dmp1 = dmp1; + } + if (dmq1 != NULL) { + BN_free(r->dmq1); + r->dmq1 = dmq1; + } + if (iqmp != NULL) { + BN_free(r->iqmp); + r->iqmp = iqmp; + } + + return 1; +} + +void RSA_get0_key(const RSA *r, + const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) +{ + if (n != NULL) + *n = r->n; + if (e != NULL) + *e = r->e; + if (d != NULL) + *d = r->d; +} + +void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) +{ + if (p != NULL) + *p = r->p; + if (q != NULL) + *q = r->q; +} + +void RSA_get0_crt_params(const RSA *r, + const BIGNUM **dmp1, const BIGNUM **dmq1, + const BIGNUM **iqmp) +{ + if (dmp1 != NULL) + *dmp1 = r->dmp1; + if (dmq1 != NULL) + *dmq1 = r->dmq1; + if (iqmp != NULL) + *iqmp = r->iqmp; +} + +void DSA_get0_pqg(const DSA *d, + const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) +{ + if (p != NULL) + *p = d->p; + if (q != NULL) + *q = d->q; + if (g != NULL) + *g = d->g; +} + +int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + /* If the fields p, q and g in d are NULL, the corresponding input + * parameters MUST be non-NULL. + */ + if ((d->p == NULL && p == NULL) + || (d->q == NULL && q == NULL) + || (d->g == NULL && g == NULL)) + return 0; + + if (p != NULL) { + BN_free(d->p); + d->p = p; + } + if (q != NULL) { + BN_free(d->q); + d->q = q; + } + if (g != NULL) { + BN_free(d->g); + d->g = g; + } + + return 1; +} + +void DSA_get0_key(const DSA *d, + const BIGNUM **pub_key, const BIGNUM **priv_key) +{ + if (pub_key != NULL) + *pub_key = d->pub_key; + if (priv_key != NULL) + *priv_key = d->priv_key; +} + +int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) +{ + /* If the field pub_key in d is NULL, the corresponding input + * parameters MUST be non-NULL. The priv_key field may + * be left NULL. + */ + if (d->pub_key == NULL && pub_key == NULL) + return 0; + + if (pub_key != NULL) { + BN_free(d->pub_key); + d->pub_key = pub_key; + } + if (priv_key != NULL) { + BN_free(d->priv_key); + d->priv_key = priv_key; + } + + return 1; +} + +void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) +{ + if (pr != NULL) + *pr = sig->r; + if (ps != NULL) + *ps = sig->s; +} + +int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) +{ + if (r == NULL || s == NULL) + return 0; + BN_clear_free(sig->r); + BN_clear_free(sig->s); + sig->r = r; + sig->s = s; + return 1; +} + +void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) +{ + if (pr != NULL) + *pr = sig->r; + if (ps != NULL) + *ps = sig->s; +} + +int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) +{ + if (r == NULL || s == NULL) + return 0; + BN_clear_free(sig->r); + BN_clear_free(sig->s); + sig->r = r; + sig->s = s; + return 1; +} + +void DH_get0_pqg(const DH *dh, + const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) +{ + if (p != NULL) + *p = dh->p; + if (q != NULL) + *q = dh->q; + if (g != NULL) + *g = dh->g; +} + +int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + /* If the fields p and g in d are NULL, the corresponding input + * parameters MUST be non-NULL. q may remain NULL. + */ + if ((dh->p == NULL && p == NULL) + || (dh->g == NULL && g == NULL)) + return 0; + + if (p != NULL) { + BN_free(dh->p); + dh->p = p; + } + if (q != NULL) { + BN_free(dh->q); + dh->q = q; + } + if (g != NULL) { + BN_free(dh->g); + dh->g = g; + } + + if (q != NULL) { + dh->length = BN_num_bits(q); + } + + return 1; +} + +void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) +{ + if (pub_key != NULL) + *pub_key = dh->pub_key; + if (priv_key != NULL) + *priv_key = dh->priv_key; +} + +int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) +{ + /* If the field pub_key in dh is NULL, the corresponding input + * parameters MUST be non-NULL. The priv_key field may + * be left NULL. + */ + if (dh->pub_key == NULL && pub_key == NULL) + return 0; + + if (pub_key != NULL) { + BN_free(dh->pub_key); + dh->pub_key = pub_key; + } + if (priv_key != NULL) { + BN_free(dh->priv_key); + dh->priv_key = priv_key; + } + + return 1; +} + +int DH_set_length(DH *dh, long length) +{ + dh->length = length; + return 1; +} + +const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx) +{ + return ctx->iv; +} + +unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx) +{ + return ctx->iv; +} + +EVP_MD_CTX *EVP_MD_CTX_new(void) +{ + return OPENSSL_zalloc(sizeof(EVP_MD_CTX)); +} + +void EVP_MD_CTX_free(EVP_MD_CTX *ctx) +{ + EVP_MD_CTX_cleanup(ctx); + OPENSSL_free(ctx); +} + +int RSA_size(const RSA* rsa) { + /* BIGNUM* n = NULL; + RSA_get0_key(rsa, n, NULL, NULL); */ + return BN_num_bytes(rsa->n); +} + +RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth) +{ + RSA_METHOD *ret; + + ret = OPENSSL_malloc(sizeof(RSA_METHOD)); + + if (ret != NULL) { + memcpy(ret, meth, sizeof(*meth)); + ret->name = OPENSSL_strdup(meth->name); + if (ret->name == NULL) { + OPENSSL_free(ret); + return NULL; + } + } + + return ret; +} + +int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) +{ + char *tmpname; + + tmpname = OPENSSL_strdup(name); + if (tmpname == NULL) { + return 0; + } + + OPENSSL_free((char *)meth->name); + meth->name = tmpname; + + return 1; +} + +int RSA_meth_set_priv_enc(RSA_METHOD *meth, + int (*priv_enc) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)) +{ + meth->rsa_priv_enc = priv_enc; + return 1; +} + +int RSA_meth_set_priv_dec(RSA_METHOD *meth, + int (*priv_dec) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)) +{ + meth->rsa_priv_dec = priv_dec; + return 1; +} + +int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa)) +{ + meth->finish = finish; + return 1; +} + +void RSA_meth_free(RSA_METHOD *meth) +{ + if (meth != NULL) { + OPENSSL_free((char *)meth->name); + OPENSSL_free(meth); + } +} + +int RSA_bits(const RSA *r) +{ + return (BN_num_bits(r->n)); +} + +RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) +{ + if (pkey->type != EVP_PKEY_RSA) { + return NULL; + } + return pkey->pkey.rsa; +} + +int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, + size_t *pderlen) +{ + /* Make sure encoding is valid */ + if (i2d_X509_NAME(nm, NULL) <= 0) + return 0; + if (pder != NULL) + *pder = (unsigned char *)nm->bytes->data; + if (pderlen != NULL) + *pderlen = nm->bytes->length; + return 1; +} + +#endif /* OPENSSL_VERSION_NUMBER */ +%} diff --git a/src/SWIG/_m2crypto.def b/src/SWIG/_m2crypto.def new file mode 100644 index 0000000..3e9d5bc --- /dev/null +++ b/src/SWIG/_m2crypto.def @@ -0,0 +1,2 @@ +EXPORTS +init_m2crypto diff --git a/src/SWIG/_m2crypto.i b/src/SWIG/_m2crypto.i new file mode 100644 index 0000000..e300a10 --- /dev/null +++ b/src/SWIG/_m2crypto.i @@ -0,0 +1,106 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999-2002 Ng Pheng Siong. All rights reserved. + * + * Portions created by Open Source Applications Foundation (OSAF) are + * Copyright (C) 2004-2006 OSAF. All Rights Reserved. + * + * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. + * + */ + +%module(threads=1) m2crypto +/* We really don't need threadblock (PyGILState_Ensure() etc.) anywhere. + Disable threadallow as well, only enable it for operations likely to + block. */ +%nothreadblock; +%nothreadallow; + +#if SWIG_VERSION >= 0x030000 +#define __WCHAR_MAX__ __WCHAR_MAX +#define __WCHAR_MIN__ __WCHAR_MIN +#endif +/* https://gitlab.com/m2crypto/m2crypto/issues/246 */ +%ignore WCHAR_MAX; +%ignore WCHAR_MIN; +/* http://swig.10945.n7.nabble.com/SWIG-AsVal-wchar-t-error-td2264.html */ +%{ +int SWIG_AsVal_wchar_t(PyObject *p, wchar_t *c) { return SWIG_OK; } +PyObject *SWIG_From_wchar_t(wchar_t c) { return SWIG_Py_Void(); } +%} + +%{ +#ifdef _WIN32 +#define _WINSOCKAPI_ +#include +#include +#pragma comment(lib, "Ws2_32") +typedef unsigned __int64 uint64_t; +#endif +%} + +%{ +#if defined __GNUC__ && __GNUC__ < 5 +#pragma GCC diagnostic ignored "-Wunused-label" +#pragma GCC diagnostic warning "-Wstrict-prototypes" +#endif + +#include +#include +#include <_lib.h> +#include +#include + +#include "compile.h" + +static PyObject *ssl_verify_cb_func; +static PyObject *ssl_info_cb_func; +static PyObject *ssl_set_tmp_dh_cb_func; +static PyObject *ssl_set_tmp_rsa_cb_func; +static PyObject *x509_store_verify_cb_func; +%} + +%include + +/* Bring in STACK_OF macro definition */ +#ifdef _WIN32 +%include +#endif +%include + +/* Bring in LHASH_OF macro definition */ +/* XXX Can't include lhash.h where LHASH_OF is defined, because it includes + XXX stdio.h etc. which we fail to include. So we have to (re)define + XXX LHASH_OF here instead. +%include +*/ +#if OPENSSL_VERSION_NUMBER >= 0x10000000L +#define LHASH_OF(type) struct lhash_st_##type +#endif + + +%include constraints.i +%include _threads.i +%include _lib.i +%include _bio.i +%include _bn.i +%include _rand.i +%include _evp.i +%include _aes.i +%include _rc4.i +%include _dh.i +%include _rsa.i +%include _dsa.i +%include _ssl.i +%include _x509.i +%include _asn1.i +%include _pkcs7.i +%include _util.i +%include _ec.i +%include _engine.i +%include _objects.i + +#ifdef SWIG_VERSION +%constant int encrypt = 1; +%constant int decrypt = 0; +#endif + diff --git a/src/SWIG/_m2crypto_wrap.c b/src/SWIG/_m2crypto_wrap.c new file mode 100644 index 0000000..6ed5429 --- /dev/null +++ b/src/SWIG/_m2crypto_wrap.c @@ -0,0 +1,34500 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.2 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + + +#ifndef SWIGPYTHON +#define SWIGPYTHON +#endif + +#define SWIG_PYTHON_THREADS +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE +#define SWIGPYTHON_BUILTIN + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + + +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include +#endif + +#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) +/* Use debug wrappers with the Python release dll */ +# undef _DEBUG +# include +# define _DEBUG 1 +#else +# include +#endif + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast(r) (r) +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCmp(const char *nb, const char *tb) { + int equiv = 1; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (equiv != 0 && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = SWIG_TypeNameComp(nb, ne, tb, te); + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0; +} + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + size_t l = 0; + size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + const unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + unsigned char *u = (unsigned char *) ptr; + const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + char d = *(c++); + unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = (unsigned char)((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = (unsigned char)((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (unsigned char)(d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (unsigned char)(d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyInt_FromSize_t(x) PyLong_FromSize_t(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03030000 + return (char *)PyUnicode_AsUTF8(str); +#elif PY_VERSION_HEX >= 0x03000000 + char *newstr = 0; + str = PyUnicode_AsUTF8String(str); + if (str) { + char *cstr; + Py_ssize_t len; + if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) { + newstr = (char *) malloc(len+1); + if (newstr) + memcpy(newstr, cstr, len+1); + } + Py_XDECREF(str); + } + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000 +# define SWIG_Python_str_DelForPy3(x) +#else +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#define Py_hash_t long +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + PyErr_Clear(); + Py_XINCREF(type); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); +#else + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# define SWIG_PYTHON_USE_GIL +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + const char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" +#endif + +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" +#endif + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, name, obj); + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +} + +/* Unpack the argument tuple */ + +SWIGINTERN Py_ssize_t +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + Py_ssize_t i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + Py_ssize_t i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +SWIGINTERN int +SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { + int no_kwargs = 1; + if (kwargs) { + assert(PyDict_Check(kwargs)); + if (PyDict_Size(kwargs) > 0) { + PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); + no_kwargs = 0; + } + } + return no_kwargs; +} + +/* A functor is a function object with one single object argument */ +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); + data->delargs = !(flags & (METH_O)); + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + + +#ifdef SWIGPYTHON_BUILTIN + +SWIGRUNTIME PyObject * +SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + + if (!sobj->dict) + sobj->dict = PyDict_New(); + + Py_INCREF(sobj->dict); + return sobj->dict; +} + +#endif + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_repr(SwigPyObject *v) +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); + if (v->next) { + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ +SWIGRUNTIME PyObject * +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + + /* PyObject_CallFunction() has the potential to silently drop + the active exception. In cases of unnamed temporary + variable or where we just finished iterating over a generator + StopIteration will be active right now, and this needs to + remain true upon return from SwigPyObject_dealloc. So save + and restore. */ + + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); + + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + if (!res) + PyErr_WriteUnraisable(destroy); + + PyErr_Restore(type, value, traceback); + + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (!SwigPyObject_Check(next)) { + PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } + } + return obj; + } +} + +static PyMethodDef +swigobject_methods[] = { + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, + {0, 0, 0, 0} +}; + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ +#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#else + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +static PyObject *Swig_This_global = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None && !implicit_conv) { + if (ptr) + *ptr = 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (implicit_conv) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + swig_cast_info *tc; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + return SWIG_OK; + } +} + +/* Convert a packed pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } else { + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } + } + } + Py_DECREF(empty_args); + } +#else + PyObject *dict = PyDict_New(); + if (dict) { + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } +#endif + } + return inst; +} + +SWIGRUNTIME int +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + return PyDict_SetItem(dict, SWIG_This(), swig_this); + } +#endif + return PyObject_SetAttr(inst, SWIG_This(), swig_this); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) + return NULL; + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + Py_DECREF(robj); + robj = inst; + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +SWIGRUNTIME void +SWIG_Python_DestroyModule(PyObject *obj) +{ + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + Swig_This_global = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); + } else { + swig_module_info *swig_module = SWIG_GetModule(0); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCapsule_New((void*) descriptor, NULL, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + const char *errmesg = tmp ? tmp : "Invalid error message"; + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, errmesg); + } else { + PyErr_Format(type, "%s %s", errmesg, mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : ""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +#ifdef SWIGPYTHON_BUILTIN +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res = -1; + +# ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +# else + if (!PyString_Check(name)) +# endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} +#endif + + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGINTERN Py_hash_t +SwigPyObject_hash(PyObject *obj) { + SwigPyObject *sobj = (SwigPyObject *)obj; + void *ptr = sobj->ptr; + return (Py_hash_t)ptr; +} + +SWIGINTERN Py_hash_t +SWIG_PyNumber_AsPyHash(PyObject *obj) { + Py_hash_t result = -1; +#if PY_VERSION_HEX < 0x03020000 + if (PyInt_Check(obj)) + result = PyInt_AsLong(obj); + else if (PyLong_Check(obj)) + result = PyLong_AsLong(obj); +#else + if (PyNumber_Check(obj)) + result = PyNumber_AsSsize_t(obj, NULL); +#endif + else + PyErr_Format(PyExc_TypeError, "Wrong type for hash function"); + return PyErr_Occurred() ? -1 : result; +} + +SWIGINTERN int +SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) { + PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name); + return -1; +} + +SWIGINTERN void +SwigPyBuiltin_BadDealloc(PyObject *obj) { + SwigPyObject *sobj = (SwigPyObject *)obj; + if (sobj->own) { + PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", obj->ob_type->tp_name); + } +} + +typedef struct { + PyCFunction get; + PyCFunction set; +} SwigPyGetSet; + +SWIGINTERN PyObject * +SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) { + SwigPyGetSet *getset; + PyObject *tuple, *result; + if (!closure) + return SWIG_Py_Void(); + getset = (SwigPyGetSet *)closure; + if (!getset->get) + return SWIG_Py_Void(); + tuple = PyTuple_New(0); + assert(tuple); + result = (*getset->get)(obj, tuple); + Py_DECREF(tuple); + return result; +} + +SWIGINTERN PyObject * +SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) { + SwigPyGetSet *getset; + PyObject *result; + if (!closure) + return SWIG_Py_Void(); + getset = (SwigPyGetSet *)closure; + if (!getset->get) + return SWIG_Py_Void(); + result = (*getset->get)(obj, NULL); + return result; +} + +SWIGINTERN int +SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { + SwigPyGetSet *getset; + PyObject *tuple, *result; + if (!closure) { + PyErr_Format(PyExc_TypeError, "Missing getset closure"); + return -1; + } + getset = (SwigPyGetSet *)closure; + if (!getset->set) { + PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); + return -1; + } + tuple = PyTuple_New(1); + assert(tuple); + Py_INCREF(val); + PyTuple_SET_ITEM(tuple, 0, val); + result = (*getset->set)(obj, tuple); + Py_DECREF(tuple); + Py_XDECREF(result); + return result ? 0 : -1; +} + +SWIGINTERN int +SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) { + SwigPyGetSet *getset; + PyObject *result; + if (!closure) { + PyErr_Format(PyExc_TypeError, "Missing getset closure"); + return -1; + } + getset = (SwigPyGetSet *)closure; + if (!getset->set) { + PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name); + return -1; + } + result = (*getset->set)(obj, val); + Py_XDECREF(result); + return result ? 0 : -1; +} + +SWIGINTERN void +SwigPyStaticVar_dealloc(PyDescrObject *descr) { + PyObject_GC_UnTrack(descr); + Py_XDECREF(PyDescr_TYPE(descr)); + Py_XDECREF(PyDescr_NAME(descr)); + PyObject_GC_Del(descr); +} + +SWIGINTERN PyObject * +SwigPyStaticVar_repr(PyGetSetDescrObject *descr) { +#if PY_VERSION_HEX >= 0x03000000 + + return PyUnicode_FromFormat("", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); +#else + return PyString_FromFormat("", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); +#endif +} + +SWIGINTERN int +SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) { + PyDescrObject *descr; + descr = (PyDescrObject *)self; + Py_VISIT((PyObject*) PyDescr_TYPE(descr)); + return 0; +} + +SWIGINTERN PyObject * +SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) { + if (descr->d_getset->get != NULL) + return descr->d_getset->get(obj, descr->d_getset->closure); +#if PY_VERSION_HEX >= 0x03000000 + PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); +#else + PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); +#endif + return NULL; +} + +SWIGINTERN int +SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) { + if (descr->d_getset->set != NULL) + return descr->d_getset->set(obj, value, descr->d_getset->closure); +#if PY_VERSION_HEX >= 0x03000000 + PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name); +#else + PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name); +#endif + return -1; +} + +SWIGINTERN int +SwigPyObjectType_setattro(PyObject *typeobject, PyObject *name, PyObject *value) { + PyObject *attribute; + PyTypeObject *type; + descrsetfunc local_set; + + assert(PyType_Check(typeobject)); + type = (PyTypeObject *)typeobject; + attribute = _PyType_Lookup(type, name); + if (attribute != NULL) { + /* Implement descriptor functionality, if any */ + local_set = attribute->ob_type->tp_descr_set; + if (local_set != NULL) + return local_set(attribute, (PyObject *)type, value); +#if PY_VERSION_HEX >= 0x03000000 + PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name); +#else + PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name)); +#endif + } else { +#if PY_VERSION_HEX >= 0x03000000 + PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name); +#else + PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name)); +#endif + } + + return -1; +} + +SWIGINTERN PyTypeObject* +SwigPyStaticVar_Type(void) { + static PyTypeObject staticvar_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(&PyType_Type, 0) +#else + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ +#endif + "swig_static_var_getset_descriptor", /* tp_name */ + sizeof(PyGetSetDescrObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyStaticVar_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)SwigPyStaticVar_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ + 0, /* tp_doc */ + SwigPyStaticVar_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + (descrgetfunc)SwigPyStaticVar_get, /* tp_descr_get */ + (descrsetfunc)SwigPyStaticVar_set, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + staticvar_type = tmp; + type_init = 1; + if (PyType_Ready(&staticvar_type) < 0) + return NULL; + } + return &staticvar_type; +} + +SWIGINTERN PyTypeObject* +SwigPyObjectType(void) { + static char swigpyobjecttype_doc[] = "Metaclass for SWIG wrapped types"; + static PyTypeObject swigpyobjecttype_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(&PyType_Type, 0) +#else + PyObject_HEAD_INIT(&PyType_Type) + 0, /* ob_size */ +#endif + "SwigPyObjectType", /* tp_name */ + PyType_Type.tp_basicsize, /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + SwigPyObjectType_setattro, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ + swigpyobjecttype_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + swigpyobjecttype_type = tmp; + type_init = 1; + swigpyobjecttype_type.tp_base = &PyType_Type; + if (PyType_Ready(&swigpyobjecttype_type) < 0) + return NULL; + } + return &swigpyobjecttype_type; +} + +SWIGINTERN PyGetSetDescrObject * +SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { + + PyGetSetDescrObject *descr; + descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0); + assert(descr); + Py_XINCREF(type); + PyDescr_TYPE(descr) = type; + PyDescr_NAME(descr) = PyString_InternFromString(getset->name); + descr->d_getset = getset; + if (PyDescr_NAME(descr) == NULL) { + Py_DECREF(descr); + descr = NULL; + } + return descr; +} + +SWIGINTERN void +SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { + Py_ssize_t base_count = 0; + PyTypeObject **b; + PyObject *tuple; + Py_ssize_t i; + + if (!bases[0]) { + bases[0] = SwigPyObject_type(); + bases[1] = NULL; + } + type->tp_base = bases[0]; + Py_INCREF((PyObject *)bases[0]); + for (b = bases; *b != NULL; ++b) + ++base_count; + tuple = PyTuple_New(base_count); + for (i = 0; i < base_count; ++i) { + Py_INCREF((PyObject *)bases[i]); + PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); + } + type->tp_bases = tuple; +} + +SWIGINTERN PyObject * +SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { + PyObject *result; + result = (PyObject *)SWIG_Python_GetSwigThis(self); + Py_XINCREF(result); + return result; +} + +SWIGINTERN void +SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) +{ +#if PY_VERSION_HEX >= 0x03000000 + type->ob_base.ob_base.ob_type = metatype; +#else + type->ob_type = metatype; +#endif +} + + +/* Start of callback function macros for use in PyTypeObject */ + +typedef PyObject *(*SwigPyWrapperFunction)(PyObject *, PyObject *); + +#define SWIGPY_UNARYFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_unaryfunc_closure(PyObject *a) { \ + return SwigPyBuiltin_unaryfunc_closure(wrapper, a); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_unaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + return wrapper(a, NULL); +} + +#define SWIGPY_DESTRUCTOR_CLOSURE(wrapper) \ +SWIGINTERN void \ +wrapper##_destructor_closure(PyObject *a) { \ + SwigPyBuiltin_destructor_closure(wrapper, #wrapper, a); \ +} +SWIGINTERN void +SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrappername, PyObject *a) { + SwigPyObject *sobj; + sobj = (SwigPyObject *)a; + Py_XDECREF(sobj->dict); + if (sobj->own) { + PyObject *o; + PyObject *type = 0, *value = 0, *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + o = wrapper(a, NULL); + if (!o) { + PyObject *deallocname = PyString_FromString(wrappername); + PyErr_WriteUnraisable(deallocname); + Py_DECREF(deallocname); + } + PyErr_Restore(type, value, traceback); + Py_XDECREF(o); + } + if (PyType_IS_GC(a->ob_type)) { + PyObject_GC_Del(a); + } else { + PyObject_Del(a); + } +} + +#define SWIGPY_INQUIRY_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_inquiry_closure(PyObject *a) { \ + return SwigPyBuiltin_inquiry_closure(wrapper, a); \ +} +SWIGINTERN int +SwigPyBuiltin_inquiry_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + PyObject *pyresult; + int result; + pyresult = wrapper(a, NULL); + result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0; + Py_XDECREF(pyresult); + return result; +} + +#define SWIGPY_GETITERFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_getiterfunc_closure(PyObject *a) { \ + return SwigPyBuiltin_getiterfunc_closure(wrapper, a); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_getiterfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + return wrapper(a, NULL); +} + +#define SWIGPY_BINARYFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_binaryfunc_closure(PyObject *a, PyObject *b) { \ + return SwigPyBuiltin_binaryfunc_closure(wrapper, a, b); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { + PyObject *tuple, *result; + tuple = PyTuple_New(1); + assert(tuple); + Py_INCREF(b); + PyTuple_SET_ITEM(tuple, 0, b); + result = wrapper(a, tuple); + Py_DECREF(tuple); + return result; +} + +typedef ternaryfunc ternarycallfunc; + +#define SWIGPY_TERNARYFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_ternaryfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \ + return SwigPyBuiltin_ternaryfunc_closure(wrapper, a, b, c); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { + PyObject *tuple, *result; + tuple = PyTuple_New(2); + assert(tuple); + Py_INCREF(b); + PyTuple_SET_ITEM(tuple, 0, b); + Py_INCREF(c); + PyTuple_SET_ITEM(tuple, 1, c); + result = wrapper(a, tuple); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_ternarycallfunc_closure(PyObject *a, PyObject *b, PyObject *c) { \ + return SwigPyBuiltin_ternarycallfunc_closure(wrapper, a, b, c); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_ternarycallfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { + (void) c; + return wrapper(a, b); +} + +#define SWIGPY_LENFUNC_CLOSURE(wrapper) \ +SWIGINTERN Py_ssize_t \ +wrapper##_lenfunc_closure(PyObject *a) { \ + return SwigPyBuiltin_lenfunc_closure(wrapper, a); \ +} +SWIGINTERN Py_ssize_t +SwigPyBuiltin_lenfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + PyObject *resultobj; + Py_ssize_t result; + resultobj = wrapper(a, NULL); + result = PyNumber_AsSsize_t(resultobj, NULL); + Py_DECREF(resultobj); + return result; +} + +#define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_ssizessizeargfunc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) { \ + return SwigPyBuiltin_ssizessizeargfunc_closure(wrapper, a, b, c); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_ssizessizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c) { + PyObject *tuple, *result; + tuple = PyTuple_New(2); + assert(tuple); + PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); + PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); + result = wrapper(a, tuple); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_ssizessizeobjargproc_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \ + return SwigPyBuiltin_ssizessizeobjargproc_closure(wrapper, a, b, c, d); \ +} +SWIGINTERN int +SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { + PyObject *tuple, *resultobj; + int result; + tuple = PyTuple_New(d ? 3 : 2); + assert(tuple); + PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); + PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); + if (d) { + Py_INCREF(d); + PyTuple_SET_ITEM(tuple, 2, d); + } + resultobj = wrapper(a, tuple); + result = resultobj ? 0 : -1; + Py_DECREF(tuple); + Py_XDECREF(resultobj); + return result; +} + +#define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \ + return SwigPyBuiltin_funpack_ssizeargfunc_closure(wrapper, a, b); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_funpack_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) { + PyObject *tuple, *result; + tuple = PyTuple_New(1); + assert(tuple); + PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); + result = wrapper(a, tuple); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_ssizeargfunc_closure(PyObject *a, Py_ssize_t b) { \ + return SwigPyBuiltin_ssizeargfunc_closure(wrapper, a, b); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_ssizeargfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b) { + PyObject *arg, *result; + arg = _PyLong_FromSsize_t(b); + result = wrapper(a, arg); + Py_DECREF(arg); + return result; +} + +#define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_ssizeobjargproc_closure(PyObject *a, Py_ssize_t b, PyObject *c) { \ + return SwigPyBuiltin_ssizeobjargproc_closure(wrapper, a, b, c); \ +} +SWIGINTERN int +SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py_ssize_t b, PyObject *c) { + PyObject *tuple, *resultobj; + int result; + tuple = PyTuple_New(2); + assert(tuple); + PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); + Py_INCREF(c); + PyTuple_SET_ITEM(tuple, 1, c); + resultobj = wrapper(a, tuple); + result = resultobj ? 0 : -1; + Py_XDECREF(resultobj); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_OBJOBJPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ + return SwigPyBuiltin_objobjproc_closure(wrapper, a, b); \ +} +SWIGINTERN int +SwigPyBuiltin_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { + int result; + PyObject *pyresult; + PyObject *tuple; + tuple = PyTuple_New(1); + assert(tuple); + Py_INCREF(b); + PyTuple_SET_ITEM(tuple, 0, b); + pyresult = wrapper(a, tuple); + result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; + Py_XDECREF(pyresult); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_FUNPACK_OBJOBJPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ + return SwigPyBuiltin_funpack_objobjproc_closure(wrapper, a, b); \ +} +SWIGINTERN int +SwigPyBuiltin_funpack_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { + int result; + PyObject *pyresult; + pyresult = wrapper(a, b); + result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; + Py_XDECREF(pyresult); + return result; +} + +#define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \ + return SwigPyBuiltin_objobjargproc_closure(wrapper, a, b, c); \ +} +SWIGINTERN int +SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b, PyObject *c) { + PyObject *tuple, *resultobj; + int result; + tuple = PyTuple_New(c ? 2 : 1); + assert(tuple); + Py_INCREF(b); + PyTuple_SET_ITEM(tuple, 0, b); + if (c) { + Py_INCREF(c); + PyTuple_SET_ITEM(tuple, 1, c); + } + resultobj = wrapper(a, tuple); + result = resultobj ? 0 : -1; + Py_XDECREF(resultobj); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_REPRFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_reprfunc_closure(PyObject *a) { \ + return SwigPyBuiltin_reprfunc_closure(wrapper, a); \ +} +SWIGINTERN PyObject * +SwigPyBuiltin_reprfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + return wrapper(a, NULL); +} + +#define SWIGPY_HASHFUNC_CLOSURE(wrapper) \ +SWIGINTERN Py_hash_t \ +wrapper##_hashfunc_closure(PyObject *a) { \ + return SwigPyBuiltin_hashfunc_closure(wrapper, a); \ +} +SWIGINTERN Py_hash_t +SwigPyBuiltin_hashfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + PyObject *pyresult; + Py_hash_t result; + pyresult = wrapper(a, NULL); + if (!pyresult) + return -1; + result = SWIG_PyNumber_AsPyHash(pyresult); + Py_DECREF(pyresult); + return result; +} + +#define SWIGPY_ITERNEXTFUNC_CLOSURE(wrapper) \ +SWIGINTERN PyObject * \ +wrapper##_iternextfunc_closure(PyObject *a) { \ + return SwigPyBuiltin_iternextfunc_closure(wrapper, a);\ +} +SWIGINTERN PyObject * +SwigPyBuiltin_iternextfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a) { + return wrapper(a, NULL); +} + +/* End of callback function macros for use in PyTypeObject */ + +#ifdef __cplusplus +} +#endif + + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + +#ifdef __cplusplus +} +#endif + + + #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_AES_KEY swig_types[0] +#define SWIGTYPE_p_ASN1_BIT_STRING swig_types[1] +#define SWIGTYPE_p_ASN1_INTEGER swig_types[2] +#define SWIGTYPE_p_ASN1_OBJECT swig_types[3] +#define SWIGTYPE_p_ASN1_STRING swig_types[4] +#define SWIGTYPE_p_ASN1_TIME swig_types[5] +#define SWIGTYPE_p_BIGNUM swig_types[6] +#define SWIGTYPE_p_BIO swig_types[7] +#define SWIGTYPE_p_BIO_METHOD swig_types[8] +#define SWIGTYPE_p_DH swig_types[9] +#define SWIGTYPE_p_DSA swig_types[10] +#define SWIGTYPE_p_ECDSA_SIG swig_types[11] +#define SWIGTYPE_p_EC_KEY swig_types[12] +#define SWIGTYPE_p_ENGINE swig_types[13] +#define SWIGTYPE_p_EVP_CIPHER swig_types[14] +#define SWIGTYPE_p_EVP_CIPHER_CTX swig_types[15] +#define SWIGTYPE_p_EVP_MD swig_types[16] +#define SWIGTYPE_p_EVP_MD_CTX swig_types[17] +#define SWIGTYPE_p_EVP_PKEY swig_types[18] +#define SWIGTYPE_p_FILE swig_types[19] +#define SWIGTYPE_p_HMAC_CTX swig_types[20] +#define SWIGTYPE_p_PKCS7 swig_types[21] +#define SWIGTYPE_p_PyObject swig_types[22] +#define SWIGTYPE_p_RC4_KEY swig_types[23] +#define SWIGTYPE_p_RSA swig_types[24] +#define SWIGTYPE_p_SSL swig_types[25] +#define SWIGTYPE_p_SSL_CIPHER swig_types[26] +#define SWIGTYPE_p_SSL_CTX swig_types[27] +#define SWIGTYPE_p_SSL_METHOD swig_types[28] +#define SWIGTYPE_p_SSL_SESSION swig_types[29] +#define SWIGTYPE_p_SwigPyObject swig_types[30] +#define SWIGTYPE_p_UI_METHOD swig_types[31] +#define SWIGTYPE_p_X509 swig_types[32] +#define SWIGTYPE_p_X509V3_CTX swig_types[33] +#define SWIGTYPE_p_X509_CRL swig_types[34] +#define SWIGTYPE_p_X509_EXTENSION swig_types[35] +#define SWIGTYPE_p_X509_NAME swig_types[36] +#define SWIGTYPE_p_X509_NAME_ENTRY swig_types[37] +#define SWIGTYPE_p_X509_REQ swig_types[38] +#define SWIGTYPE_p_X509_STORE swig_types[39] +#define SWIGTYPE_p_X509_STORE_CTX swig_types[40] +#define SWIGTYPE_p___INTMAX_TYPE__ swig_types[41] +#define SWIGTYPE_p___INT_FAST16_TYPE__ swig_types[42] +#define SWIGTYPE_p___INT_FAST32_TYPE__ swig_types[43] +#define SWIGTYPE_p___INT_FAST64_TYPE__ swig_types[44] +#define SWIGTYPE_p___INT_FAST8_TYPE__ swig_types[45] +#define SWIGTYPE_p___INT_LEAST16_TYPE__ swig_types[46] +#define SWIGTYPE_p___INT_LEAST32_TYPE__ swig_types[47] +#define SWIGTYPE_p___INT_LEAST64_TYPE__ swig_types[48] +#define SWIGTYPE_p___INT_LEAST8_TYPE__ swig_types[49] +#define SWIGTYPE_p___UINTMAX_TYPE__ swig_types[50] +#define SWIGTYPE_p___UINT_FAST16_TYPE__ swig_types[51] +#define SWIGTYPE_p___UINT_FAST32_TYPE__ swig_types[52] +#define SWIGTYPE_p___UINT_FAST64_TYPE__ swig_types[53] +#define SWIGTYPE_p___UINT_FAST8_TYPE__ swig_types[54] +#define SWIGTYPE_p___UINT_LEAST16_TYPE__ swig_types[55] +#define SWIGTYPE_p___UINT_LEAST32_TYPE__ swig_types[56] +#define SWIGTYPE_p___UINT_LEAST64_TYPE__ swig_types[57] +#define SWIGTYPE_p___UINT_LEAST8_TYPE__ swig_types[58] +#define SWIGTYPE_p__cbd_t swig_types[59] +#define SWIGTYPE_p_char swig_types[60] +#define SWIGTYPE_p_f_int_p_X509_STORE_CTX__int swig_types[61] +#define SWIGTYPE_p_f_p_char__void swig_types[62] +#define SWIGTYPE_p_f_p_q_const__char__p_char swig_types[63] +#define SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int swig_types[64] +#define SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int swig_types[65] +#define SWIGTYPE_p_f_p_q_const__void__p_void swig_types[66] +#define SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int swig_types[67] +#define SWIGTYPE_p_f_p_void__void swig_types[68] +#define SWIGTYPE_p_p_ASN1_OBJECT swig_types[69] +#define SWIGTYPE_p_p_EVP_PKEY_CTX swig_types[70] +#define SWIGTYPE_p_p_X509_NAME_ENTRY swig_types[71] +#define SWIGTYPE_p_p_unsigned_char swig_types[72] +#define SWIGTYPE_p_pyfd_struct swig_types[73] +#define SWIGTYPE_p_stack_st swig_types[74] +#define SWIGTYPE_p_stack_st_OPENSSL_BLOCK swig_types[75] +#define SWIGTYPE_p_stack_st_OPENSSL_CSTRING swig_types[76] +#define SWIGTYPE_p_stack_st_OPENSSL_STRING swig_types[77] +#define SWIGTYPE_p_stack_st_SSL_CIPHER swig_types[78] +#define SWIGTYPE_p_stack_st_X509 swig_types[79] +#define SWIGTYPE_p_stack_st_X509_EXTENSION swig_types[80] +#define SWIGTYPE_p_unsigned_char swig_types[81] +#define SWIGTYPE_p_void swig_types[82] +static swig_type_info *swig_types[84]; +static swig_module_info swig_module = {swig_types, 83, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery +#endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery + +/*----------------------------------------------- + @(target):= _m2crypto.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__m2crypto + +#else +# define SWIG_init init_m2crypto + +#endif +#define SWIG_name "_m2crypto" + +#define SWIGVERSION 0x040002 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include + + +int SWIG_AsVal_wchar_t(PyObject *p, wchar_t *c) { return SWIG_OK; } +PyObject *SWIG_From_wchar_t(wchar_t c) { return SWIG_Py_Void(); } + + +#ifdef _WIN32 +#define _WINSOCKAPI_ +#include +#include +#pragma comment(lib, "Ws2_32") +typedef unsigned __int64 uint64_t; +#endif + + +#if defined __GNUC__ && __GNUC__ < 5 +#pragma GCC diagnostic ignored "-Wunused-label" +#pragma GCC diagnostic warning "-Wstrict-prototypes" +#endif + +#include +#include +#include <_lib.h> +#include +#include + +#include "compile.h" + +static PyObject *ssl_verify_cb_func; +static PyObject *ssl_info_cb_func; +static PyObject *ssl_set_tmp_dh_cb_func; +static PyObject *ssl_set_tmp_rsa_cb_func; +static PyObject *x509_store_verify_cb_func; + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtrAndSize(const char* carray, size_t size) +{ + if (carray) { + if (size > INT_MAX) { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + return pchar_descriptor ? + SWIG_InternalNewPointerObj((char *)(carray), pchar_descriptor, 0) : SWIG_Py_Void(); + } else { +#if PY_VERSION_HEX >= 0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + return PyBytes_FromStringAndSize(carray, (Py_ssize_t)(size)); +#else + return PyUnicode_DecodeUTF8(carray, (Py_ssize_t)(size), "surrogateescape"); +#endif +#else + return PyString_FromStringAndSize(carray, (Py_ssize_t)(size)); +#endif + } + } else { + return SWIG_Py_Void(); + } +} + + +SWIGINTERNINLINE PyObject * +SWIG_FromCharPtr(const char *cptr) +{ + return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0)); +} + + +SWIGINTERNINLINE PyObject* + SWIG_From_int (int value) +{ + return PyInt_FromLong((long) value); +} + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; +#if PY_VERSION_HEX < 0x03000000 + } else if (PyInt_Check(obj)) { + if (val) *val = (double) PyInt_AsLong(obj); + return SWIG_OK; +#endif + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else +#endif + if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (PyBytes_Check(obj)) +#else + if (PyUnicode_Check(obj)) +#endif +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; + int ret = SWIG_OK; +#if PY_VERSION_HEX>=0x03000000 +#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; +#endif + if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; +#else + if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; +#endif + if (cptr) { + if (alloc) { + if (*alloc == SWIG_NEWOBJ) { + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { +#if PY_VERSION_HEX>=0x03000000 +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + *cptr = PyBytes_AsString(obj); +#else + assert(0); /* Should never reach here with Unicode strings in Python 3 */ +#endif +#else + *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; +#endif + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) + Py_XDECREF(obj); +#endif + return ret; + } else { +#if defined(SWIG_PYTHON_2_UNICODE) +#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) +#error "Cannot use both SWIG_PYTHON_2_UNICODE and SWIG_PYTHON_STRICT_BYTE_CHAR at once" +#endif +#if PY_VERSION_HEX<0x03000000 + if (PyUnicode_Check(obj)) { + char *cstr; Py_ssize_t len; + if (!alloc && cptr) { + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; + if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { + if (cptr) { + if (alloc) *alloc = SWIG_NEWOBJ; + *cptr = (char *)memcpy(malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + } + if (psize) *psize = len + 1; + + Py_XDECREF(obj); + return SWIG_OK; + } else { + Py_XDECREF(obj); + } + } +#endif +#endif + + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +#include +#include + +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L +#define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) +static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; +static long lock_count[CRYPTO_num_locks()]; +static int thread_mode = 0; +#endif + +void threading_locking_callback(int mode, int type, const char *file, int line) { +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L + if (mode & CRYPTO_LOCK) { + PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); + lock_count[type]++; + } else { + PyThread_release_lock(lock_cs[type]); + lock_count[type]--; + } +#endif +} + +unsigned long threading_id_callback(void) { +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L + return (unsigned long)PyThread_get_thread_ident(); +#else + return (unsigned long)0; +#endif +} + + +void threading_init(void) { +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L + int i; + if (!thread_mode) { + for (i=0; i +#include +#include +#include +#include +#include +#include +#include +#include + + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + +#include +#include + +# define OPENSSL_zalloc(num) \ + CRYPTO_zalloc(num, __FILE__, __LINE__) + +static void *CRYPTO_zalloc(size_t num, const char *file, int line) +{ + void *ret = CRYPTO_malloc(num, file, line); + if (ret != NULL) + memset(ret, 0, num); + return ret; +} + +#include + +#ifndef BN_F_BN_GENCB_NEW +# define BN_F_BN_GENCB_NEW 143 +#endif + +# define BN_GENCB_get_arg(gencb) ((gencb)->arg) + +BN_GENCB *BN_GENCB_new(void) +{ + BN_GENCB *ret; + + if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) { + BNerr(BN_F_BN_GENCB_NEW, ERR_R_MALLOC_FAILURE); + return (NULL); + } + + return ret; +} + +void BN_GENCB_free(BN_GENCB *cb) +{ + if (cb == NULL) + return; + OPENSSL_free(cb); +} + + +int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d) +{ + /* If the fields n and e in r are NULL, the corresponding input + * parameters MUST be non-NULL for n and e. d may be + * left NULL (in case only the public key is used). + */ + if ((r->n == NULL && n == NULL) + || (r->e == NULL && e == NULL)) + return 0; + + if (n != NULL) { + BN_free(r->n); + r->n = n; + } + if (e != NULL) { + BN_free(r->e); + r->e = e; + } + if (d != NULL) { + BN_free(r->d); + r->d = d; + } + + return 1; +} + +int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q) +{ + /* If the fields p and q in r are NULL, the corresponding input + * parameters MUST be non-NULL. + */ + if ((r->p == NULL && p == NULL) + || (r->q == NULL && q == NULL)) + return 0; + + if (p != NULL) { + BN_free(r->p); + r->p = p; + } + if (q != NULL) { + BN_free(r->q); + r->q = q; + } + + return 1; +} + +int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp) +{ + /* If the fields dmp1, dmq1 and iqmp in r are NULL, the corresponding input + * parameters MUST be non-NULL. + */ + if ((r->dmp1 == NULL && dmp1 == NULL) + || (r->dmq1 == NULL && dmq1 == NULL) + || (r->iqmp == NULL && iqmp == NULL)) + return 0; + + if (dmp1 != NULL) { + BN_free(r->dmp1); + r->dmp1 = dmp1; + } + if (dmq1 != NULL) { + BN_free(r->dmq1); + r->dmq1 = dmq1; + } + if (iqmp != NULL) { + BN_free(r->iqmp); + r->iqmp = iqmp; + } + + return 1; +} + +void RSA_get0_key(const RSA *r, + const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) +{ + if (n != NULL) + *n = r->n; + if (e != NULL) + *e = r->e; + if (d != NULL) + *d = r->d; +} + +void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q) +{ + if (p != NULL) + *p = r->p; + if (q != NULL) + *q = r->q; +} + +void RSA_get0_crt_params(const RSA *r, + const BIGNUM **dmp1, const BIGNUM **dmq1, + const BIGNUM **iqmp) +{ + if (dmp1 != NULL) + *dmp1 = r->dmp1; + if (dmq1 != NULL) + *dmq1 = r->dmq1; + if (iqmp != NULL) + *iqmp = r->iqmp; +} + +void DSA_get0_pqg(const DSA *d, + const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) +{ + if (p != NULL) + *p = d->p; + if (q != NULL) + *q = d->q; + if (g != NULL) + *g = d->g; +} + +int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + /* If the fields p, q and g in d are NULL, the corresponding input + * parameters MUST be non-NULL. + */ + if ((d->p == NULL && p == NULL) + || (d->q == NULL && q == NULL) + || (d->g == NULL && g == NULL)) + return 0; + + if (p != NULL) { + BN_free(d->p); + d->p = p; + } + if (q != NULL) { + BN_free(d->q); + d->q = q; + } + if (g != NULL) { + BN_free(d->g); + d->g = g; + } + + return 1; +} + +void DSA_get0_key(const DSA *d, + const BIGNUM **pub_key, const BIGNUM **priv_key) +{ + if (pub_key != NULL) + *pub_key = d->pub_key; + if (priv_key != NULL) + *priv_key = d->priv_key; +} + +int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key) +{ + /* If the field pub_key in d is NULL, the corresponding input + * parameters MUST be non-NULL. The priv_key field may + * be left NULL. + */ + if (d->pub_key == NULL && pub_key == NULL) + return 0; + + if (pub_key != NULL) { + BN_free(d->pub_key); + d->pub_key = pub_key; + } + if (priv_key != NULL) { + BN_free(d->priv_key); + d->priv_key = priv_key; + } + + return 1; +} + +void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) +{ + if (pr != NULL) + *pr = sig->r; + if (ps != NULL) + *ps = sig->s; +} + +int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s) +{ + if (r == NULL || s == NULL) + return 0; + BN_clear_free(sig->r); + BN_clear_free(sig->s); + sig->r = r; + sig->s = s; + return 1; +} + +void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) +{ + if (pr != NULL) + *pr = sig->r; + if (ps != NULL) + *ps = sig->s; +} + +int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s) +{ + if (r == NULL || s == NULL) + return 0; + BN_clear_free(sig->r); + BN_clear_free(sig->s); + sig->r = r; + sig->s = s; + return 1; +} + +void DH_get0_pqg(const DH *dh, + const BIGNUM **p, const BIGNUM **q, const BIGNUM **g) +{ + if (p != NULL) + *p = dh->p; + if (q != NULL) + *q = dh->q; + if (g != NULL) + *g = dh->g; +} + +int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + /* If the fields p and g in d are NULL, the corresponding input + * parameters MUST be non-NULL. q may remain NULL. + */ + if ((dh->p == NULL && p == NULL) + || (dh->g == NULL && g == NULL)) + return 0; + + if (p != NULL) { + BN_free(dh->p); + dh->p = p; + } + if (q != NULL) { + BN_free(dh->q); + dh->q = q; + } + if (g != NULL) { + BN_free(dh->g); + dh->g = g; + } + + if (q != NULL) { + dh->length = BN_num_bits(q); + } + + return 1; +} + +void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) +{ + if (pub_key != NULL) + *pub_key = dh->pub_key; + if (priv_key != NULL) + *priv_key = dh->priv_key; +} + +int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) +{ + /* If the field pub_key in dh is NULL, the corresponding input + * parameters MUST be non-NULL. The priv_key field may + * be left NULL. + */ + if (dh->pub_key == NULL && pub_key == NULL) + return 0; + + if (pub_key != NULL) { + BN_free(dh->pub_key); + dh->pub_key = pub_key; + } + if (priv_key != NULL) { + BN_free(dh->priv_key); + dh->priv_key = priv_key; + } + + return 1; +} + +int DH_set_length(DH *dh, long length) +{ + dh->length = length; + return 1; +} + +const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx) +{ + return ctx->iv; +} + +unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx) +{ + return ctx->iv; +} + +EVP_MD_CTX *EVP_MD_CTX_new(void) +{ + return OPENSSL_zalloc(sizeof(EVP_MD_CTX)); +} + +void EVP_MD_CTX_free(EVP_MD_CTX *ctx) +{ + EVP_MD_CTX_cleanup(ctx); + OPENSSL_free(ctx); +} + +int RSA_size(const RSA* rsa) { + /* BIGNUM* n = NULL; + RSA_get0_key(rsa, n, NULL, NULL); */ + return BN_num_bytes(rsa->n); +} + +RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth) +{ + RSA_METHOD *ret; + + ret = OPENSSL_malloc(sizeof(RSA_METHOD)); + + if (ret != NULL) { + memcpy(ret, meth, sizeof(*meth)); + ret->name = OPENSSL_strdup(meth->name); + if (ret->name == NULL) { + OPENSSL_free(ret); + return NULL; + } + } + + return ret; +} + +int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) +{ + char *tmpname; + + tmpname = OPENSSL_strdup(name); + if (tmpname == NULL) { + return 0; + } + + OPENSSL_free((char *)meth->name); + meth->name = tmpname; + + return 1; +} + +int RSA_meth_set_priv_enc(RSA_METHOD *meth, + int (*priv_enc) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)) +{ + meth->rsa_priv_enc = priv_enc; + return 1; +} + +int RSA_meth_set_priv_dec(RSA_METHOD *meth, + int (*priv_dec) (int flen, const unsigned char *from, + unsigned char *to, RSA *rsa, + int padding)) +{ + meth->rsa_priv_dec = priv_dec; + return 1; +} + +int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa)) +{ + meth->finish = finish; + return 1; +} + +void RSA_meth_free(RSA_METHOD *meth) +{ + if (meth != NULL) { + OPENSSL_free((char *)meth->name); + OPENSSL_free(meth); + } +} + +int RSA_bits(const RSA *r) +{ + return (BN_num_bits(r->n)); +} + +RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) +{ + if (pkey->type != EVP_PKEY_RSA) { + return NULL; + } + return pkey->pkey.rsa; +} + +int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, + size_t *pderlen) +{ + /* Make sure encoding is valid */ + if (i2d_X509_NAME(nm, NULL) <= 0) + return 0; + if (pder != NULL) + *pder = (unsigned char *)nm->bytes->data; + if (pderlen != NULL) + *pderlen = nm->bytes->length; + return 1; +} + +#endif /* OPENSSL_VERSION_NUMBER */ + + +#if PY_MAJOR_VERSION >= 3 + +FILE* PyFile_AsFile(PyObject *pyfile) { + FILE* fp; + int fd; + const char *mode_str = NULL; + PyObject *mode_obj; + + if ((fd = PyObject_AsFileDescriptor(pyfile)) == -1) { + PyErr_SetString(PyExc_BlockingIOError, + "Cannot find file handler for the Python file!"); + return NULL; + } + + if ((mode_obj = PyObject_GetAttrString(pyfile, "mode")) == NULL) { + mode_str = "rb"; + PyErr_Clear(); + } + else { + /* convert to plain string + * note that error checking is embedded in the function + */ + mode_str = PyUnicode_AsUTF8AndSize(mode_obj, NULL); + } + + if((fp = fdopen(fd, mode_str)) == NULL) { + PyErr_SetFromErrno(PyExc_IOError); + } + + Py_XDECREF(mode_obj); + return fp; +} + +#else /* PY2K */ + +#define PyLong_FromLong(x) PyInt_FromLong(x) +#define PyUnicode_AsUTF8(x) PyString_AsString(x) +#define PyUnicode_FromString(x) PyString_FromString(x) +#define PyUnicode_Format(x, y) PyString_Format(x, y) + +#endif /* PY_MAJOR_VERSION */ + + +/* OpenSSL 1.0.2 copmatbility shim */ +#if OPENSSL_VERSION_NUMBER < 0x10002000L +typedef void (*OPENSSL_sk_freefunc)(void *); +typedef void *(*OPENSSL_sk_copyfunc)(const void *); +typedef struct stack_st OPENSSL_STACK; + +# define MIN_NODES 4 +# define sk_deep_copy OPENSSL_sk_deep_copy + +void OPENSSL_sk_free(OPENSSL_STACK *st) +{ + if (st == NULL) + return; + OPENSSL_free(st->data); + OPENSSL_free(st); +} + +OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk, + OPENSSL_sk_copyfunc copy_func, + OPENSSL_sk_freefunc free_func) +{ + OPENSSL_STACK *ret; + int i; + + if (sk->num < 0) + return NULL; + + if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) + return NULL; + + /* direct structure assignment */ + *ret = *sk; + + ret->num_alloc = sk->num > MIN_NODES ? (size_t)sk->num : MIN_NODES; + ret->data = OPENSSL_zalloc(sizeof(*ret->data) * ret->num_alloc); + if (ret->data == NULL) { + OPENSSL_free(ret); + return NULL; + } + + for (i = 0; i < ret->num; ++i) { + if (sk->data[i] == NULL) + continue; + if ((ret->data[i] = copy_func(sk->data[i])) == NULL) { + while (--i >= 0) + if (ret->data[i] != NULL) + free_func((void *)ret->data[i]); + OPENSSL_sk_free(ret); + return NULL; + } + } + return ret; +} +#endif /* OpenSSL 1.0.2 copmatbility shim */ + + +/* Blob interface. Deprecated. */ + +Blob *blob_new(int len, const char *errmsg) { + + Blob *blob; + if (!(blob=(Blob *)PyMem_Malloc(sizeof(Blob)))){ + PyErr_SetString(PyExc_MemoryError, errmsg); + return NULL; + } + if (!(blob->data=(unsigned char *)PyMem_Malloc(len))) { + PyMem_Free(blob); + PyErr_SetString(PyExc_MemoryError, errmsg); + return NULL; + } + blob->len=len; + return blob; +} + +Blob *blob_copy(Blob *from, const char *errmsg) { + Blob *blob=blob_new(from->len, errmsg); + if (!blob) { + PyErr_SetString(PyExc_MemoryError, errmsg); + return NULL; + } + memcpy(blob->data, from->data, from->len); + return blob; +} + +void blob_free(Blob *blob) { + PyMem_Free(blob->data); + PyMem_Free(blob); +} + + +/* Python helpers. */ + + + + +static int +m2_PyObject_AsReadBuffer(PyObject * obj, const void **buffer, + Py_ssize_t * buffer_len) +{ + int ret = 0; + Py_ssize_t len = 0; + Py_buffer view; + + if (PyObject_CheckBuffer(obj)) { + if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) == 0) { + *buffer = view.buf; + len = view.len; + } + } else { + if ((ret = PyObject_AsReadBuffer(obj, buffer, &len)) != 0) + return ret; + } + if (len > INT_MAX) { + m2_PyBuffer_Release(obj, &view); + PyErr_SetString(PyExc_ValueError, "object too large"); + return -1; + } + *buffer_len = len; + m2_PyBuffer_Release(obj, &view); + return 0; +} + +static int +m2_PyObject_AsReadBufferInt(PyObject * obj, const void **buffer, + int *buffer_len) +{ + int ret = 0; + Py_ssize_t len = 0; + + ret = m2_PyObject_AsReadBuffer(obj, buffer, &len); + *buffer_len = len; + return ret; +} + + + +static int m2_PyObject_GetBufferInt(PyObject *obj, Py_buffer *view, int flags) +{ + int ret; + + if (PyObject_CheckBuffer(obj)) + ret = PyObject_GetBuffer(obj, view, flags); + else { + const void *buf; + + ret = PyObject_AsReadBuffer(obj, &buf, &view->len); + if (ret == 0) + view->buf = (void *)buf; + } + if (ret) + return ret; + if (view->len > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "object too large"); + m2_PyBuffer_Release(obj, view); + return -1; + } + + return 0; +} + +static BIGNUM* +m2_PyObject_AsBIGNUM(PyObject* value, PyObject* _py_exc) +{ + BIGNUM* bn; + const void* vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { + PyErr_SetString(_py_exc, ERR_reason_error_string(ERR_get_error())); + return NULL; + } + + return bn; +} + +static void m2_PyBuffer_Release(PyObject *obj, Py_buffer *view) +{ + if (PyObject_CheckBuffer(obj)) + PyBuffer_Release(view); + /* else do nothing, view->buf comes from PyObject_AsReadBuffer */ +} + +static int +m2_PyString_AsStringAndSizeInt(PyObject *obj, char **s, int *len) +{ + int ret; + Py_ssize_t len2; + + ret = PyBytes_AsStringAndSize(obj, s, &len2); + + if (ret) + return ret; + if (len2 > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "string too large"); + return -1; + } + *len = len2; + return 0; +} + +/* Works as PyFile_Name, but always returns a new object. */ +PyObject *m2_PyFile_Name(PyObject *pyfile) { + PyObject *out = NULL; +#if PY_MAJOR_VERSION >= 3 + out = PyObject_GetAttrString(pyfile, "name"); +#else + out = PyFile_Name(pyfile); + Py_XINCREF(out); +#endif + return out; +} + +/* Yes, __FUNCTION__ is a non-standard symbol, but it is supported by + * both gcc and MSVC. */ +#define m2_PyErr_Msg(type) m2_PyErr_Msg_Caller(type, (const char*) __FUNCTION__) + +static void m2_PyErr_Msg_Caller(PyObject *err_type, const char* caller) { + const char *err_reason; + const char *data; + int flags; + /* This max size of a (longer than ours) OpenSSL error string is hardcoded + * in OpenSSL's crypto/err/err_prn.c:ERR_print_errors_cb() */ + char err_msg[4096]; + unsigned long err_code = ERR_get_error_line_data(NULL, NULL, &data, &flags); + + if (err_code != 0) { + err_reason = ERR_reason_error_string(err_code); + if (data && (flags & ERR_TXT_STRING)) + snprintf(err_msg, sizeof(err_msg), "%s (%s)", err_reason, data); + else + snprintf(err_msg, sizeof(err_msg), "%s", err_reason); + + PyErr_SetString(err_type, err_msg); + } else { + PyErr_Format(err_type, "Unknown error in function %s.", caller); + } +} + + +/* C callbacks invoked by OpenSSL; these in turn call back into +Python. */ + +int ssl_verify_callback(int ok, X509_STORE_CTX *ctx) { + PyObject *argv, *ret; + PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; + PyObject *_x509=0, *_ssl_ctx=0; + SSL *ssl; + SSL_CTX *ssl_ctx; + X509 *x509; + int errnum, errdepth; + int cret; + int new_style_callback = 0, warning_raised_exception=0; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + ssl = (SSL *)X509_STORE_CTX_get_app_data(ctx); + + gilstate = PyGILState_Ensure(); + + if (PyMethod_Check(ssl_verify_cb_func)) { + PyObject *func; + PyCodeObject *code; + func = PyMethod_Function(ssl_verify_cb_func); + code = (PyCodeObject *) PyFunction_GetCode(func); + if (code && code->co_argcount == 3) { /* XXX Python internals */ + new_style_callback = 1; + } + } else if (PyFunction_Check(ssl_verify_cb_func)) { + PyCodeObject *code = (PyCodeObject *) PyFunction_GetCode(ssl_verify_cb_func); + if (code && code->co_argcount == 2) { /* XXX Python internals */ + new_style_callback = 1; + } + } else { + /* XXX There are lots of other callable types, but we will assume + * XXX that any other type of callable uses the new style callback, + * XXX although this is not entirely safe assumption. + */ + new_style_callback = 1; + } + + if (new_style_callback) { + PyObject *x509mod; + + x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); + _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); + + _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); + _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); + + _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); + + argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); + } else { + if (PyErr_Warn(PyExc_DeprecationWarning, "Old style callback, use cb_func(ok, store) instead")) { + warning_raised_exception = 1; + } + + x509 = X509_STORE_CTX_get_current_cert(ctx); + errnum = X509_STORE_CTX_get_error(ctx); + errdepth = X509_STORE_CTX_get_error_depth(ctx); + + ssl = (SSL *)X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); + ssl_ctx = SSL_get_SSL_CTX(ssl); + + _x509 = SWIG_NewPointerObj((void *)x509, SWIGTYPE_p_X509, 0); + _ssl_ctx = SWIG_NewPointerObj((void *)ssl_ctx, SWIGTYPE_p_SSL_CTX, 0); + argv = Py_BuildValue("(OOiii)", _ssl_ctx, _x509, errnum, errdepth, ok); + } + + if (!warning_raised_exception) { + ret = PyEval_CallObject(ssl_verify_cb_func, argv); + } else { + ret = 0; + } + + if (!ret) { + /* Got an exception in PyEval_CallObject(), let's fail verification + * to be safe. + */ + cret = 0; + } else { + /* FIXME This is possibly problematic if ret > MAXINT */ + cret = (int)PyLong_AsLong(ret); + } + Py_XDECREF(ret); + Py_XDECREF(argv); + if (new_style_callback) { + Py_XDECREF(_x509_store_ctx_inst); + Py_XDECREF(_x509_store_ctx_obj); + Py_XDECREF(_x509_store_ctx_swigptr); + Py_XDECREF(_klass); + } else { + Py_XDECREF(_x509); + Py_XDECREF(_ssl_ctx); + } + + PyGILState_Release(gilstate); + + return cret; +} + +int x509_store_verify_callback(int ok, X509_STORE_CTX *ctx) { + PyGILState_STATE gilstate; + PyObject *argv, *ret; + PyObject *_x509_store_ctx_swigptr=0, *_x509_store_ctx_obj=0, *_x509_store_ctx_inst=0, *_klass=0; + int cret; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + PyObject *x509mod; + + + gilstate = PyGILState_Ensure(); + + /* Below, handle only what is called 'new style callback' in ssl_verify_callback(). + TODO: does 'old style callback' exist any more? */ + x509mod = PyDict_GetItemString(PyImport_GetModuleDict(), "M2Crypto.X509"); + _klass = PyObject_GetAttrString(x509mod, "X509_Store_Context"); + _x509_store_ctx_swigptr = SWIG_NewPointerObj((void *)ctx, SWIGTYPE_p_X509_STORE_CTX, 0); + _x509_store_ctx_obj = Py_BuildValue("(Oi)", _x509_store_ctx_swigptr, 0); + + _x509_store_ctx_inst = PyObject_CallObject(_klass, _x509_store_ctx_obj); + + argv = Py_BuildValue("(iO)", ok, _x509_store_ctx_inst); + + ret = PyEval_CallObject(x509_store_verify_cb_func, argv); + if (!ret) { + /* Got an exception in PyEval_CallObject(), let's fail verification + * to be safe. + */ + cret = 0; + } else { + cret = (int)PyInt_AsLong(ret); + } + + Py_XDECREF(ret); + Py_XDECREF(argv); + Py_XDECREF(_x509_store_ctx_inst); + Py_XDECREF(_x509_store_ctx_obj); + Py_XDECREF(_x509_store_ctx_swigptr); + Py_XDECREF(_klass); + + PyGILState_Release(gilstate); + return cret; +} + +void ssl_info_callback(const SSL *s, int where, int ret) { + PyObject *argv, *retval, *_SSL; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + gilstate = PyGILState_Ensure(); + + _SSL = SWIG_NewPointerObj((void *)s, SWIGTYPE_p_SSL, 0); + argv = Py_BuildValue("(iiO)", where, ret, _SSL); + + retval = PyEval_CallObject(ssl_info_cb_func, argv); + + Py_XDECREF(retval); + Py_XDECREF(argv); + Py_XDECREF(_SSL); + + PyGILState_Release(gilstate); +} + +DH *ssl_set_tmp_dh_callback(SSL *ssl, int is_export, int keylength) { + PyObject *argv, *ret, *_ssl; + DH *dh; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + gilstate = PyGILState_Ensure(); + + _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); + argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); + + ret = PyEval_CallObject(ssl_set_tmp_dh_cb_func, argv); + + if ((SWIG_ConvertPtr(ret, (void **)&dh, SWIGTYPE_p_DH, SWIG_POINTER_EXCEPTION | 0)) == -1) + dh = NULL; + Py_XDECREF(ret); + Py_XDECREF(argv); + Py_XDECREF(_ssl); + + PyGILState_Release(gilstate); + + return dh; +} + +RSA *ssl_set_tmp_rsa_callback(SSL *ssl, int is_export, int keylength) { + PyObject *argv, *ret, *_ssl; + RSA *rsa; + PyGILState_STATE gilstate; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + gilstate = PyGILState_Ensure(); + + _ssl = SWIG_NewPointerObj((void *)ssl, SWIGTYPE_p_SSL, 0); + argv = Py_BuildValue("(Oii)", _ssl, is_export, keylength); + + ret = PyEval_CallObject(ssl_set_tmp_rsa_cb_func, argv); + + if ((SWIG_ConvertPtr(ret, (void **)&rsa, SWIGTYPE_p_RSA, SWIG_POINTER_EXCEPTION | 0)) == -1) + rsa = NULL; + Py_XDECREF(ret); + Py_XDECREF(argv); + Py_XDECREF(_ssl); + + PyGILState_Release(gilstate); + + return rsa; +} + +/* Universal callback for dh_generate_parameters, + * dsa_generate_parametersm, and rsa_generate_key */ +int bn_gencb_callback(int p, int n, BN_GENCB *gencb) { + PyObject *argv, *ret, *cbfunc; + + cbfunc = (PyObject *)BN_GENCB_get_arg(gencb); + argv = Py_BuildValue("(ii)", p, n); + ret = PyEval_CallObject(cbfunc, argv); + PyErr_Clear(); + Py_DECREF(argv); + Py_XDECREF(ret); + return 1; +} + +int passphrase_callback(char *buf, int num, int v, void *arg) { + int i; + Py_ssize_t len; + char *str; + PyObject *argv, *ret, *cbfunc; + PyGILState_STATE gilstate; + + gilstate = PyGILState_Ensure(); + cbfunc = (PyObject *)arg; + argv = Py_BuildValue("(i)", v); + /* PyEval_CallObject sets exception, if needed. */ + ret = PyEval_CallObject(cbfunc, argv); + Py_DECREF(argv); + if (ret == NULL) { + PyGILState_Release(gilstate); + return -1; + } + + if (!PyBytes_Check(ret)) { + PyErr_SetString(PyExc_RuntimeError, + "Result of callback is not bytes()."); + Py_DECREF(ret); + PyGILState_Release(gilstate); + return -1; + } + if ((len = PyBytes_Size(ret)) > num) + len = num; + str = PyBytes_AsString(ret); + + for (i = 0; i < len; i++) + buf[i] = str[i]; + Py_DECREF(ret); + PyGILState_Release(gilstate); + return len; +} + + + +void lib_init() { +#if OPENSSL_VERSION_NUMBER < 0x10100000L + SSLeay_add_all_algorithms(); + ERR_load_ERR_strings(); +#endif +} + +/* Bignum routines that aren't not numerous enough to +warrant a separate file. */ + +PyObject *bn_to_mpi(const BIGNUM *bn) { + int len = 0; + unsigned char *mpi; + PyObject *pyo; + + len = BN_bn2mpi(bn, NULL); + if (!(mpi=(unsigned char *)PyMem_Malloc(len))) { + m2_PyErr_Msg(PyExc_MemoryError); + return NULL; + } + len=BN_bn2mpi(bn, mpi); + + pyo=PyBytes_FromStringAndSize((const char *)mpi, len); + + PyMem_Free(mpi); + return pyo; +} + +const BIGNUM *mpi_to_bn(PyObject *value) { + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + return BN_mpi2bn(vbuf, vlen, NULL); +} + +PyObject *bn_to_bin(BIGNUM *bn) { + int len = 0; + unsigned char *bin; + PyObject *pyo; + + len = BN_num_bytes(bn); + if (!(bin=(unsigned char *)PyMem_Malloc(len))) { + PyErr_SetString(PyExc_MemoryError, "bn_to_bin"); + return NULL; + } + BN_bn2bin(bn, bin); + + pyo=PyBytes_FromStringAndSize((const char *)bin, len); + + PyMem_Free(bin); + return pyo; +} + +const BIGNUM *bin_to_bn(PyObject *value) { + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + return BN_bin2bn(vbuf, vlen, NULL); +} + +PyObject *bn_to_hex(BIGNUM *bn) { + char *hex; + PyObject *pyo; + Py_ssize_t len = 0; + + hex = BN_bn2hex(bn); + if (!hex) { + m2_PyErr_Msg(PyExc_RuntimeError); + OPENSSL_free(hex); + return NULL; + } + len = strlen(hex); + + pyo=PyBytes_FromStringAndSize(hex, len); + + OPENSSL_free(hex); + return pyo; +} + +BIGNUM *hex_to_bn(PyObject *value) { + const void *vbuf; + Py_ssize_t vlen = 0; + BIGNUM *bn; + Py_buffer view; + + if (PyObject_CheckBuffer(value)) { + if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { + vbuf = view.buf; + vlen = view.len; + } + } + else { + if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) + return NULL; + } + + if ((bn=BN_new())==NULL) { + m2_PyBuffer_Release(value, &view); + PyErr_SetString(PyExc_MemoryError, "hex_to_bn"); + return NULL; + } + if (BN_hex2bn(&bn, (const char *)vbuf) <= 0) { + m2_PyBuffer_Release(value, &view); + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return NULL; + } + m2_PyBuffer_Release(value, &view); + return bn; +} + +BIGNUM *dec_to_bn(PyObject *value) { + const void *vbuf; + Py_ssize_t vlen = 0; + BIGNUM *bn; + Py_buffer view; + + if (PyObject_CheckBuffer(value)) { + if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) == 0) { + vbuf = view.buf; + vlen = view.len; + } + } + else { + if (PyObject_AsReadBuffer(value, &vbuf, &vlen) == -1) + return NULL; + } + + if ((bn=BN_new())==NULL) { + m2_PyBuffer_Release(value, &view); + PyErr_SetString(PyExc_MemoryError, "dec_to_bn"); + return NULL; + } + if ((BN_dec2bn(&bn, (const char *)vbuf) <= 0)) { + m2_PyBuffer_Release(value, &view); + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return NULL; + } + m2_PyBuffer_Release(value, &view); + return bn; +} + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ +#if PY_VERSION_HEX < 0x03000000 + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else +#endif + if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + return SWIG_OverflowError; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +#include + + +static PyObject *_bio_err; + + +void pyfd_init(void); + +void bio_init(PyObject *bio_err) { + Py_INCREF(bio_err); + _bio_err = bio_err; + pyfd_init(); +} + +int bio_free(BIO *bio) { + int ret; + + Py_BEGIN_ALLOW_THREADS + ret = BIO_free(bio); + Py_END_ALLOW_THREADS + if (ret == 0) { + m2_PyErr_Msg(_bio_err); + } + return ret; +} + +BIO * bio_new_file(const char *filename, const char *mode) { + BIO *ret; + + Py_BEGIN_ALLOW_THREADS + ret = BIO_new_file(filename, mode); + Py_END_ALLOW_THREADS + + if (ret == NULL) { + m2_PyErr_Msg(_bio_err); + } + + return ret; +} + +BIO *bio_new_pyfile(PyObject *pyfile, int bio_close) { + FILE *fp = NULL; + BIO *bio = NULL; + + fp = PyFile_AsFile(pyfile); + + bio = BIO_new_fp(fp, bio_close); + + /* returns NULL if error occurred */ + if (bio == NULL) { + /* Find out the name of the file so we can have good error + * message. */ + PyObject *pyname = m2_PyFile_Name(pyfile); + char *name = PyBytes_AsString(pyname); + + if (name == NULL) { + PyErr_Format(_bio_err, + "Opening of the new BIO on file failed!"); + } + else { + PyErr_Format(_bio_err, + "Opening of the new BIO on file %s failed!", name); + } + Py_DECREF(pyname); + } + return bio; +} + +PyObject *bio_read(BIO *bio, int num) { + PyObject *blob; + void *buf; + int r; + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "bio_read"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + r = BIO_read(bio, buf, num); + Py_END_ALLOW_THREADS + if (r < 0) { + PyMem_Free(buf); + if (ERR_peek_error()) { + m2_PyErr_Msg(_bio_err); + return NULL; + } + Py_RETURN_NONE; + } + + blob = PyBytes_FromStringAndSize(buf, r); + + PyMem_Free(buf); + return blob; +} + +PyObject *bio_gets(BIO *bio, int num) { + PyObject *blob; + void *buf; + int r; + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "bio_gets"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + r = BIO_gets(bio, buf, num); + Py_END_ALLOW_THREADS + if (r < 1) { + PyMem_Free(buf); + if (ERR_peek_error()) { + m2_PyErr_Msg(_bio_err); + return NULL; + } + Py_RETURN_NONE; + } + + blob = PyBytes_FromStringAndSize(buf, r); + + PyMem_Free(buf); + return blob; +} + +int bio_write(BIO *bio, PyObject *from) { + const void *fbuf; + int flen = 0, ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return -1; + + Py_BEGIN_ALLOW_THREADS + ret = BIO_write(bio, fbuf, flen); + Py_END_ALLOW_THREADS + if (ret < 0) { + if (ERR_peek_error()) { + m2_PyErr_Msg(_bio_err); + return -1; + } + } + return ret; +} + +/* XXX Casting size_t to int. */ +int bio_ctrl_pending(BIO *bio) { + return (int)BIO_ctrl_pending(bio); +} + +int bio_ctrl_wpending(BIO *bio) { + return (int)BIO_ctrl_wpending(bio); +} + +int bio_ctrl_get_write_guarantee(BIO *a) { + return BIO_ctrl_get_write_guarantee(a); +} + +int bio_reset(BIO *bio) { + return (int)BIO_reset(bio); +} + + +int bio_flush(BIO *bio) { + return (int)BIO_flush(bio); +} + +int bio_seek(BIO *bio, int offset) { + return (int)BIO_seek(bio, offset); +} + +int bio_tell(BIO* bio) { + return BIO_tell(bio); +} + +void bio_set_flags(BIO *bio, int flags) { + BIO_set_flags(bio, flags); +} + +int bio_get_flags(BIO *bio) { + return BIO_get_flags(bio); +} + +/* + * sets the cipher of BIO @param b to c using key @param key and IV @iv. + * @param enc should be set to 1 for encryption and zero to decryption. + * + */ +PyObject *bio_set_cipher(BIO *b, EVP_CIPHER *c, PyObject *key, PyObject *iv, int op) { + const void *kbuf, *ibuf; + Py_ssize_t klen, ilen; + + if ((PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) + || (PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1)) + return NULL; + + BIO_set_cipher(b, (const EVP_CIPHER *)c, + (unsigned char *)kbuf, (unsigned char *)ibuf, op); + Py_RETURN_NONE; +} + +int bio_set_mem_eof_return(BIO *b, int v) { + return (int)BIO_set_mem_eof_return(b, v); +} + +int bio_get_fd(BIO *bio) { + return BIO_get_fd(bio, NULL); +} + + +int bio_do_handshake(BIO *bio) { + return BIO_do_handshake(bio); +} + +/* macro */ +int bio_make_bio_pair(BIO* b1, BIO* b2) { + return BIO_make_bio_pair(b1, b2); +} + +int bio_set_write_buf_size(BIO* b, size_t size) { + return BIO_set_write_buf_size(b, size); +} + +int bio_should_retry(BIO* a) { + return BIO_should_retry(a); +} + +int bio_should_read(BIO* a) { + return BIO_should_read(a); +} + +int bio_should_write(BIO* a) { + return BIO_should_write(a); +} + +/* Macros for things not defined before 1.1.0 */ +#if OPENSSL_VERSION_NUMBER < 0x10100000L +static BIO_METHOD * +BIO_meth_new( int type, const char *name ) +{ + BIO_METHOD *method = malloc( sizeof(BIO_METHOD) ); + memset( method, 0, sizeof(BIO_METHOD) ); + + method->type = type; + method->name = name; + + return method; +} + +static void +BIO_meth_free( BIO_METHOD *meth ) +{ + if ( meth == NULL ) { + return; + } + + free(meth); +} +#define BIO_meth_set_write(m, f) (m)->bwrite = (f) +#define BIO_meth_set_read(m, f) (m)->bread = (f) +#define BIO_meth_set_puts(m, f) (m)->bputs = (f) +#define BIO_meth_set_gets(m, f) (m)->bgets = (f) +#define BIO_meth_set_ctrl(m, f) (m)->ctrl = (f) +#define BIO_meth_set_create(m, f) (m)->create = (f) +#define BIO_meth_set_destroy(m, f) (m)->destroy = (f) +#define BIO_set_shutdown(b, x) (b)->shutdown = x +#define BIO_get_shutdown(b) (b)->shutdown +#define BIO_set_init(b, x) b->init = x +#define BIO_get_init(b) (b)->init +#define BIO_set_data(b, x) b->ptr = x +#define BIO_clear_flags(b, x) b->flags &= ~(x) +#define BIO_get_data(b) b->ptr +#endif + +/* implment custom BIO_s_pyfd */ + +#ifdef _WIN32 +# define clear_sys_error() SetLastError(0) +/* Linux doesn't use underscored calls yet */ +# define open(p, f, m) _open(p, f, m) +# define read(f, b, n) _read(f, b, n) +# define write(f, b, n) _write(f, b, n) +# define close(f) _close(f) +# define lseek(fd, o, w) _lseek(fd, o, w) +#else +# define clear_sys_error() errno=0 +#endif + +typedef struct pyfd_struct { + int fd; +} BIO_PYFD_CTX; + +/* Setting up methods_fdp */ +static BIO_METHOD *methods_fdp; + +static int pyfd_write(BIO *b, const char *in, int inl) { + int ret, fd; + + if (BIO_get_fd(b, &fd) == -1) { + PyErr_SetString(_bio_err, "BIO has not been initialized."); + return -1; + } + clear_sys_error(); + ret = write(fd, in, inl); + BIO_clear_retry_flags(b); + if (ret <= 0) { + if (BIO_fd_should_retry(ret)) + BIO_set_retry_write(b); + } + return ret; +} + +static int pyfd_read(BIO *b, char *out, int outl) { + int ret = 0, fd; + + if (BIO_get_fd(b, &fd) == -1) { + PyErr_SetString(_bio_err, "BIO has not been initialized."); + return -1; + } + if (out != NULL) { + clear_sys_error(); + ret = read(fd, out, outl); + BIO_clear_retry_flags(b); + if (ret <= 0) { + if (BIO_fd_should_retry(ret)) + BIO_set_retry_read(b); + } + } + return ret; +} + +static int pyfd_puts(BIO *bp, const char *str) { + int n, ret; + + n = strlen(str); + ret = pyfd_write(bp, str, n); + return ret; +} + +static int pyfd_gets(BIO *bp, char *buf, int size) { + int ret = 0; + char *ptr = buf; + char *end = buf + size - 1; + + /* See + https://github.com/openssl/openssl/pull/3442 + We were here just repeating a bug from OpenSSL + */ + while (ptr < end && pyfd_read(bp, ptr, 1) > 0) { + if (*ptr++ == '\n') + break; + } + + ptr[0] = '\0'; + + if (buf[0] != '\0') + ret = strlen(buf); + return ret; +} + +static int pyfd_new(BIO* b) { + BIO_PYFD_CTX* ctx; + + ctx = OPENSSL_zalloc(sizeof(*ctx)); + if (ctx == NULL) + return 0; + + ctx->fd = -1; + + BIO_set_data(b, ctx); + BIO_set_shutdown(b, 0); + BIO_set_init(b, 1); + + return 1; + } + +static int pyfd_free(BIO* b) { + BIO_PYFD_CTX* ctx; + + if (b == 0) + return 0; + + ctx = BIO_get_data(b); + if (ctx == NULL) + return 0; + + if (BIO_get_shutdown(b) && BIO_get_init(b)) + close(ctx->fd); + + BIO_set_data(b, NULL); + BIO_set_shutdown(b, 0); + BIO_set_init(b, 0); + + OPENSSL_free(ctx); + + return 1; +} + +static long pyfd_ctrl(BIO *b, int cmd, long num, void *ptr) { + BIO_PYFD_CTX* ctx; + int *ip; + long ret = 1; + + ctx = BIO_get_data(b); + if (ctx == NULL) + return 0; + + switch (cmd) { + case BIO_CTRL_RESET: + num = 0; + case BIO_C_FILE_SEEK: + ret = (long)lseek(ctx->fd, num, 0); + break; + case BIO_C_FILE_TELL: + case BIO_CTRL_INFO: + ret = (long)lseek(ctx->fd, 0, 1); + break; + case BIO_C_SET_FD: + pyfd_free(b); + if (*((int *)ptr) > -1) { + if (!pyfd_new(b) || !(ctx = BIO_get_data(b))) + return 0; + ctx->fd = *((int *)ptr); + BIO_set_shutdown(b, (int)num); + BIO_set_init(b, 1); + } + break; + case BIO_C_GET_FD: + if (BIO_get_init(b)) { + ip = (int *)ptr; + if (ip != NULL) + *ip = ctx->fd; + ret = ctx->fd; + } else + ret = -1; + break; + case BIO_CTRL_GET_CLOSE: + ret = BIO_get_shutdown(b); + break; + case BIO_CTRL_SET_CLOSE: + BIO_set_shutdown(b, (int)num); + break; + case BIO_CTRL_PENDING: + case BIO_CTRL_WPENDING: + ret = 0; + break; + case BIO_CTRL_DUP: + case BIO_CTRL_FLUSH: + ret = 1; + break; + default: + ret = 0; + break; + } + return ret; +} + +void pyfd_init(void) { +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + methods_fdp = BIO_meth_new( + BIO_get_new_index()|BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, + "python file descriptor"); +#else + methods_fdp = BIO_meth_new( + 100 |BIO_TYPE_DESCRIPTOR|BIO_TYPE_SOURCE_SINK, + "python file descriptor"); +#endif + + BIO_meth_set_write(methods_fdp, pyfd_write); + BIO_meth_set_read(methods_fdp, pyfd_read); + BIO_meth_set_puts(methods_fdp, pyfd_puts); + BIO_meth_set_gets(methods_fdp, pyfd_gets); + BIO_meth_set_ctrl(methods_fdp, pyfd_ctrl); + BIO_meth_set_create(methods_fdp, pyfd_new); + BIO_meth_set_destroy(methods_fdp, pyfd_free); +} + +BIO* BIO_new_pyfd(int fd, int close_flag) { + BIO *ret; + + ret = BIO_new(methods_fdp); + BIO_set_fd(ret, fd, close_flag); + return ret; + } + + +#if defined(LLONG_MAX) && !defined(SWIG_LONG_LONG_AVAILABLE) +# define SWIG_LONG_LONG_AVAILABLE +#endif + + +#ifdef SWIG_LONG_LONG_AVAILABLE +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long_SS_long (PyObject *obj, unsigned long long *val) +{ + int res = SWIG_TypeError; + if (PyLong_Check(obj)) { + unsigned long long v = PyLong_AsUnsignedLongLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + res = SWIG_OverflowError; + } + } else { + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj,&v); + if (SWIG_IsOK(res)) { + if (val) *val = v; + return res; + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + const double mant_max = 1LL << DBL_MANT_DIG; + double d; + res = SWIG_AsVal_double (obj,&d); + if (SWIG_IsOK(res) && !SWIG_CanCastAsInteger(&d, 0, mant_max)) + return SWIG_OverflowError; + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, mant_max)) { + if (val) *val = (unsigned long long)(d); + return SWIG_AddCast(res); + } + res = SWIG_TypeError; + } +#endif + return res; +} +#endif + + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + int res = SWIG_TypeError; +#ifdef SWIG_LONG_LONG_AVAILABLE + if (sizeof(size_t) <= sizeof(unsigned long)) { +#endif + unsigned long v; + res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); +#ifdef SWIG_LONG_LONG_AVAILABLE + } else if (sizeof(size_t) <= sizeof(unsigned long long)) { + unsigned long long v; + res = SWIG_AsVal_unsigned_SS_long_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + } +#endif + return res; +} + + +#include + + +PyObject *bn_rand(int bits, int top, int bottom) +{ + BIGNUM* rnd; + PyObject *ret; + char *randhex; + + rnd = BN_new(); + if (rnd == NULL) { + m2_PyErr_Msg(PyExc_Exception); + return NULL; + } + + if (!BN_rand(rnd, bits, top, bottom)) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + return NULL; + } + + randhex = BN_bn2hex(rnd); + if (!randhex) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + return NULL; + } + BN_free(rnd); + + ret = PyLong_FromString(randhex, NULL, 16); + OPENSSL_free(randhex); + return ret; +} + + +PyObject *bn_rand_range(PyObject *range) +{ + BIGNUM* rnd; + BIGNUM *rng = NULL; + PyObject *ret, *tuple; + PyObject *format, *rangePyString; + char *randhex; /* PyLong_FromString is unhappy with const */ + const char *rangehex; + + /* Wow, it's a lot of work to convert into a hex string in C! */ + format = PyUnicode_FromString("%x"); + + if (!format) { + PyErr_SetString(PyExc_RuntimeError, "Cannot create Python string '%x'"); + return NULL; + } + tuple = PyTuple_New(1); + if (!tuple) { + Py_DECREF(format); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + Py_INCREF(range); + PyTuple_SET_ITEM(tuple, 0, range); + + rangePyString = PyUnicode_Format(format, tuple); + + if (!rangePyString) { + PyErr_SetString(PyExc_Exception, "String Format failed"); + Py_DECREF(format); + Py_DECREF(tuple); + return NULL; + } + Py_DECREF(format); + Py_DECREF(tuple); + + rangehex = (const char*)PyUnicode_AsUTF8(rangePyString); + + if (!BN_hex2bn(&rng, rangehex)) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + Py_DECREF(rangePyString); + return NULL; + } + + Py_DECREF(rangePyString); + + if (!(rnd = BN_new())) { + PyErr_SetString(PyExc_MemoryError, "bn_rand_range"); + return NULL; + } + + if (!BN_rand_range(rnd, rng)) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + BN_free(rng); + return NULL; + } + + BN_free(rng); + + randhex = BN_bn2hex(rnd); + if (!randhex) { + /*Custom errors?*/ + m2_PyErr_Msg(PyExc_Exception); + BN_free(rnd); + return NULL; + } + BN_free(rnd); + + ret = PyLong_FromString(randhex, NULL, 16); + OPENSSL_free(randhex); + return ret; +} + + + +static PyObject *_rand_err; + +void rand_init(PyObject *rand_err) { + Py_INCREF(rand_err); + _rand_err = rand_err; +} + +PyObject *rand_seed(PyObject *seed) { + const void *buf; + int len = 0; + + m2_PyObject_AsReadBufferInt(seed, &buf, &len); + + RAND_seed(buf, len); + Py_RETURN_NONE; +} + +PyObject *rand_add(PyObject *blob, double entropy) { + const void *buf; + int len = 0; + + m2_PyObject_AsReadBufferInt(blob, &buf, &len); + + RAND_add(buf, len, entropy); + Py_RETURN_NONE; +} + +PyObject *rand_bytes(int n) { + void *blob; + int ret; + PyObject *obj; + + if (!(blob = PyMem_Malloc(n))) { + PyErr_SetString(PyExc_MemoryError, + "Insufficient memory for rand_bytes."); + return NULL; + } + if ((ret = RAND_bytes(blob, n)) == 1) { + obj = PyBytes_FromStringAndSize(blob, n); + PyMem_Free(blob); + return obj; + } else if (ret == 0) { + PyErr_SetString(_rand_err, "Not enough randomness."); + PyMem_Free(blob); + return NULL; + } else if (ret == -1) { + PyErr_SetString(_rand_err, + "Not supported by the current RAND method."); + PyMem_Free(blob); + return NULL; + } else { + PyMem_Free(blob); + m2_PyErr_Msg(_rand_err); + return NULL; + } +} + +PyObject *rand_pseudo_bytes(int n) { + int ret; + unsigned char *blob; + PyObject *tuple; + + if (!(blob=(unsigned char *)PyMem_Malloc(n))) { + PyErr_SetString(PyExc_MemoryError, "Insufficient memory for rand_pseudo_bytes."); + return NULL; + } + if (!(tuple=PyTuple_New(2))) { + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + PyMem_Free(blob); + return NULL; + } + ret = RAND_pseudo_bytes(blob, n); + if (ret == -1) { + PyMem_Free(blob); + Py_DECREF(tuple); + PyErr_SetString(_rand_err, + "Function RAND_pseudo_bytes not supported by the current RAND method."); + return NULL; + } else { + PyTuple_SET_ITEM(tuple, 0, PyBytes_FromStringAndSize((char*)blob, n)); + + PyMem_Free(blob); + PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong((long)ret)); + return tuple; + } +} + +PyObject *rand_file_name(void) { + PyObject *obj; + char *str; + if ((obj = PyBytes_FromStringAndSize(NULL, BUFSIZ))==NULL) { + PyErr_SetString(PyExc_MemoryError, "rand_file_name"); + return NULL; + } + str=PyBytes_AS_STRING(obj); + if (RAND_file_name(str, BUFSIZ)==NULL) { + PyErr_SetString(PyExc_RuntimeError, "rand_file_name"); + return NULL; + } + if (_PyBytes_Resize(&obj, (Py_ssize_t)strlen(str))!=0) + return NULL; /* mem exception set by _PyBytes_Resize */ + return obj; +} + +void rand_screen(void) { +#ifdef _WIN32 + RAND_screen(); +#endif +} + +int rand_win32_event(unsigned int imsg, int wparam, long lparam) { +#ifdef _WIN32 + return RAND_event(imsg, wparam, lparam); +#else + return 0; +#endif +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + +#include +#include +#include +#include +#include +#include + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + +HMAC_CTX *HMAC_CTX_new(void) { + HMAC_CTX *ret = PyMem_Malloc(sizeof(HMAC_CTX)); + HMAC_CTX_init(ret); + return ret; +} +#define HMAC_CTX_reset(ctx) HMAC_CTX_init(ctx) +#define HMAC_CTX_free(ctx) \ + do { \ + HMAC_CTX_cleanup(ctx); \ + PyMem_Free((void *)ctx); \ + } while(0) + +#define EVP_CIPHER_CTX_reset(ctx) EVP_CIPHER_CTX_init(ctx) +#endif + + +#define PKCS5_SALT_LEN 8 + +static PyObject *_evp_err; + +void evp_init(PyObject *evp_err) { + Py_INCREF(evp_err); + _evp_err = evp_err; +} + + +RSA *pkey_get1_rsa(EVP_PKEY *pkey) { + RSA *ret = NULL; + + if ((ret = EVP_PKEY_get1_RSA(pkey)) == NULL) { + /* _evp_err now inherits from PyExc_ValueError, so we should + * keep API intact. + */ + PyErr_Format(_evp_err, "Invalid key in function %s.", __FUNCTION__); + } + + return ret; +} + + +PyObject *pkcs5_pbkdf2_hmac_sha1(PyObject *pass, + PyObject *salt, + int iter, + int keylen) { + unsigned char *key; + const void *saltbuf; + const void *passbuf; + PyObject *ret; + int passlen = 0, saltlen = 0; + + if (m2_PyObject_AsReadBufferInt(pass, &passbuf, &passlen) == -1) + return NULL; + if (m2_PyObject_AsReadBufferInt(salt, &saltbuf, &saltlen) == -1) + return NULL; + + key = PyMem_Malloc(keylen); + if (key == NULL) + return PyErr_NoMemory(); + PKCS5_PBKDF2_HMAC_SHA1((const char *)passbuf, passlen, (const unsigned char *)saltbuf, saltlen, iter, + keylen, key); + ret = PyBytes_FromStringAndSize((char*)key, keylen); + OPENSSL_cleanse(key, keylen); + PyMem_Free(key); + return ret; +} + +EVP_MD_CTX *md_ctx_new(void) { + EVP_MD_CTX *ctx; + + if (!(ctx = EVP_MD_CTX_create())) { + PyErr_SetString(PyExc_MemoryError, "md_ctx_new"); + return NULL; + } + return ctx; +} + +void md_ctx_free(EVP_MD_CTX *ctx) { + EVP_MD_CTX_destroy(ctx); +} + +int digest_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + Py_ssize_t len; + + if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) + return -1; + + return EVP_DigestUpdate(ctx, buf, (size_t)len); +} + +PyObject *digest_final(EVP_MD_CTX *ctx) { + void *blob; + int blen; + PyObject *ret; + + if (!(blob = PyMem_Malloc(EVP_MD_CTX_size(ctx)))) { + PyErr_SetString(PyExc_MemoryError, "digest_final"); + return NULL; + } + if (!EVP_DigestFinal(ctx, blob, (unsigned int *)&blen)) { + PyMem_Free(blob); + m2_PyErr_Msg(_evp_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize(blob, blen); + + PyMem_Free(blob); + return ret; +} + +HMAC_CTX *hmac_ctx_new(void) { + HMAC_CTX *ctx; + + if (!(ctx = HMAC_CTX_new())) { + PyErr_SetString(PyExc_MemoryError, "hmac_ctx_new"); + return NULL; + } + return ctx; +} + +void hmac_ctx_free(HMAC_CTX *ctx) { + HMAC_CTX_free(ctx); +} + +PyObject *hmac_init(HMAC_CTX *ctx, PyObject *key, const EVP_MD *md) { + const void *kbuf; + int klen = 0; + + if (m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) + return NULL; + + if (!HMAC_Init_ex(ctx, kbuf, klen, md, NULL)) { + PyErr_SetString(_evp_err, "HMAC_Init failed"); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *hmac_update(HMAC_CTX *ctx, PyObject *blob) { + const void *buf; + Py_ssize_t len; + + if (m2_PyObject_AsReadBuffer(blob, &buf, &len) == -1) + return NULL; + + if (!HMAC_Update(ctx, (const unsigned char *)buf, (size_t)len)) { + PyErr_SetString(_evp_err, "HMAC_Update failed"); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *hmac_final(HMAC_CTX *ctx) { + void *blob; + int blen; + PyObject *ret; + + if (!(blob = PyMem_Malloc(HMAC_size(ctx)))) { + PyErr_SetString(PyExc_MemoryError, "hmac_final"); + return NULL; + } + + if (!HMAC_Final(ctx, blob, (unsigned int *)&blen)) { + PyErr_SetString(_evp_err, "HMAC_Final failed"); + return NULL; + } + + ret = PyBytes_FromStringAndSize(blob, blen); + + PyMem_Free(blob); + return ret; +} + +PyObject *hmac(PyObject *key, PyObject *data, const EVP_MD *md) { + const void *kbuf, *dbuf; + void *blob; + int klen = 0; + unsigned int blen; + Py_ssize_t dlen; + PyObject *ret; + + if ((m2_PyObject_AsReadBufferInt(key, &kbuf, &klen) == -1) + || (m2_PyObject_AsReadBuffer(data, &dbuf, &dlen) == -1)) + return NULL; + + if (!(blob = PyMem_Malloc(EVP_MAX_MD_SIZE))) { + PyErr_SetString(PyExc_MemoryError, "hmac"); + return NULL; + } + HMAC(md, kbuf, klen, (const unsigned char *)dbuf, (size_t)dlen, (unsigned char *)blob, &blen); + blob = PyMem_Realloc(blob, blen); + + ret = PyBytes_FromStringAndSize(blob, blen); + + PyMem_Free(blob); + return ret; +} + +EVP_CIPHER_CTX *cipher_ctx_new(void) { + EVP_CIPHER_CTX *ctx; + + if (!(ctx = EVP_CIPHER_CTX_new())) { + PyErr_SetString(PyExc_MemoryError, "cipher_ctx_new"); + return NULL; + } + EVP_CIPHER_CTX_reset(ctx); + return ctx; +} + +void cipher_ctx_free(EVP_CIPHER_CTX *ctx) { + EVP_CIPHER_CTX_free(ctx); +} + +PyObject *bytes_to_key(const EVP_CIPHER *cipher, EVP_MD *md, + PyObject *data, PyObject *salt, + PyObject *iv, /* Not used */ + int iter) { + unsigned char key[EVP_MAX_KEY_LENGTH]; + const void *dbuf, *sbuf; + int dlen = 0, klen; + Py_ssize_t slen; + PyObject *ret; + + if ((m2_PyObject_AsReadBufferInt(data, &dbuf, &dlen) == -1) + || (m2_PyObject_AsReadBuffer(salt, &sbuf, &slen) == -1)) + return NULL; + + assert((slen == 8) || (slen == 0)); + klen = EVP_BytesToKey(cipher, md, (unsigned char *)sbuf, + (unsigned char *)dbuf, dlen, iter, + key, NULL); /* Since we are not returning IV no need to derive it */ + + ret = PyBytes_FromStringAndSize((char*)key, klen); + + return ret; +} + +PyObject *cipher_init(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, + PyObject *key, PyObject *iv, int mode) { + const void *kbuf, *ibuf; + Py_ssize_t klen, ilen; + + if (key == Py_None) + kbuf = NULL; + else if (m2_PyObject_AsReadBuffer(key, &kbuf, &klen) == -1) + return NULL; + + if (iv == Py_None) + ibuf = NULL; + else if (m2_PyObject_AsReadBuffer(iv, &ibuf, &ilen) == -1) + return NULL; + + if (!EVP_CipherInit(ctx, cipher, (unsigned char *)kbuf, + (unsigned char *)ibuf, mode)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *cipher_update(EVP_CIPHER_CTX *ctx, PyObject *blob) { + const void *buf; + int len = 0, olen; + void *obuf; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) + return NULL; + + if (!(obuf = PyMem_Malloc(len + EVP_CIPHER_CTX_block_size(ctx) - 1))) { + PyErr_SetString(PyExc_MemoryError, "cipher_update"); + return NULL; + } + if (!EVP_CipherUpdate(ctx, obuf, &olen, (unsigned char *)buf, len)) { + PyMem_Free(obuf); + m2_PyErr_Msg(_evp_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize(obuf, olen); + + PyMem_Free(obuf); + return ret; +} + +PyObject *cipher_final(EVP_CIPHER_CTX *ctx) { + void *obuf; + int olen; + PyObject *ret; + + if (!(obuf = PyMem_Malloc(EVP_CIPHER_CTX_block_size(ctx)))) { + PyErr_SetString(PyExc_MemoryError, "cipher_final"); + return NULL; + } + if (!EVP_CipherFinal(ctx, (unsigned char *)obuf, &olen)) { + PyMem_Free(obuf); + m2_PyErr_Msg(_evp_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize(obuf, olen); + + PyMem_Free(obuf); + return ret; +} + +PyObject *sign_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len; + + if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) + return NULL; + + if (!EVP_SignUpdate(ctx, buf, (Py_ssize_t)len)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *sign_final(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { + PyObject *ret; + unsigned char *sigbuf; + unsigned int siglen = EVP_PKEY_size(pkey); + + sigbuf = (unsigned char*)OPENSSL_malloc(siglen); + if (!sigbuf) { + PyErr_SetString(PyExc_MemoryError, "sign_final"); + return NULL; + } + + if (!EVP_SignFinal(ctx, sigbuf, &siglen, pkey)) { + m2_PyErr_Msg(_evp_err); + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); + + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return ret; +} + +int verify_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len; + + if (m2_PyObject_AsReadBufferInt(blob, &buf, &len) == -1) + return -1; + + return EVP_VerifyUpdate(ctx, buf, (Py_ssize_t)len); +} + +int verify_final(EVP_MD_CTX *ctx, PyObject *blob, EVP_PKEY *pkey) { + const void *kbuf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, &kbuf, &len) == -1) + return -1; + + return EVP_VerifyFinal(ctx, (const unsigned char *)kbuf, len, pkey); +} + +int digest_sign_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { + return EVP_DigestSignInit(ctx, NULL, NULL, NULL, pkey); +} + +PyObject *digest_sign_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) + return NULL; + + if (!EVP_DigestSignUpdate(ctx, buf, len)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *digest_sign_final(EVP_MD_CTX *ctx) { + PyObject *ret; + unsigned char *sigbuf; + size_t siglen; + + if (!EVP_DigestSignFinal(ctx, NULL, &siglen)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + + sigbuf = (unsigned char*)OPENSSL_malloc(siglen); + if (!sigbuf) { + PyErr_SetString(PyExc_MemoryError, "digest_sign_final"); + return NULL; + } + + if (!EVP_DigestSignFinal(ctx, sigbuf, &siglen)) { + m2_PyErr_Msg(_evp_err); + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); + + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return ret; +} + +#if OPENSSL_VERSION_NUMBER >= 0x10101000L +PyObject *digest_sign(EVP_MD_CTX *ctx, PyObject *msg) { + PyObject *ret; + const void *msgbuf; + unsigned char *sigbuf; + int msglen = 0; + size_t siglen = 0; + + if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) + return NULL; + + if (!EVP_DigestSign(ctx, NULL, &siglen, msgbuf, msglen)) { + m2_PyErr_Msg(_evp_err); + return NULL; + } + + sigbuf = (unsigned char*)OPENSSL_malloc(siglen); + if (!sigbuf) { + PyErr_SetString(PyExc_MemoryError, "digest_sign"); + return NULL; + } + + if (!EVP_DigestSign(ctx, sigbuf, &siglen, msgbuf, msglen)) { + m2_PyErr_Msg(_evp_err); + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((char*)sigbuf, siglen); + + OPENSSL_cleanse(sigbuf, siglen); + OPENSSL_free(sigbuf); + return ret; + +} +#endif + +int digest_verify_init(EVP_MD_CTX *ctx, EVP_PKEY *pkey) { + return EVP_DigestVerifyInit(ctx, NULL, NULL, NULL, pkey); +} + +int digest_verify_update(EVP_MD_CTX *ctx, PyObject *blob) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, (const void **)&buf, &len) == -1) + return -1; + + return EVP_DigestVerifyUpdate(ctx, buf, len); +} + +int digest_verify_final(EVP_MD_CTX *ctx, PyObject *blob) { + unsigned char *sigbuf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(blob, (const void **)&sigbuf, &len) == -1) + return -1; + + return EVP_DigestVerifyFinal(ctx, sigbuf, len); +} + +#if OPENSSL_VERSION_NUMBER >= 0x10101000L +int digest_verify(EVP_MD_CTX *ctx, PyObject *sig, PyObject *msg) { + unsigned char *sigbuf; + unsigned char *msgbuf; + int siglen = 0; + int msglen = 0; + + if (m2_PyObject_AsReadBufferInt(sig, (const void **)&sigbuf, &siglen) == -1) + return -1; + + if (m2_PyObject_AsReadBufferInt(msg, (const void **)&msgbuf, &msglen) == -1) + return -1; + + return EVP_DigestVerify(ctx, sigbuf, siglen, msgbuf, msglen); +} +#endif + + +const EVP_MD *get_digestbyname(const char* name) { + const EVP_MD *ret = NULL; + + if ((ret = EVP_get_digestbyname(name)) == NULL) { + m2_PyErr_Msg(_evp_err); + } + + return ret; +} + + +int pkey_write_pem_no_cipher(EVP_PKEY *pkey, BIO *f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +int pkey_write_pem(EVP_PKEY *pkey, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_PKCS8PrivateKey(f, pkey, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +EVP_PKEY *pkey_new(void) { + EVP_PKEY *ret; + + if ((ret = EVP_PKEY_new()) == NULL) { + PyErr_Format(PyExc_MemoryError, + "Insufficient memory for new key in function %s.", __FUNCTION__); + } + + return ret; +} + +EVP_PKEY *pkey_read_pem(BIO *f, PyObject *pyfunc) { + EVP_PKEY *pk; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + pk = PEM_read_bio_PrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (pk == NULL) { + PyErr_Format(_evp_err, + "Unable to read private key in function %s.", __FUNCTION__); + } + + return pk; +} + +EVP_PKEY *pkey_read_pem_pubkey(BIO *f, PyObject *pyfunc) { + EVP_PKEY *pk; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + pk = PEM_read_bio_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (pk == NULL) { + PyErr_Format(_evp_err, + "Unable to read public key in function %s.", __FUNCTION__); + } + + return pk; +} + + +int pkey_assign_rsa(EVP_PKEY *pkey, RSA *rsa) { + return EVP_PKEY_assign_RSA(pkey, rsa); +} + +PyObject *pkey_as_der(EVP_PKEY *pkey) { + unsigned char * pp = NULL; + int len; + PyObject * der; + len = i2d_PUBKEY(pkey, &pp); + if (len < 0){ + PyErr_SetString(_evp_err, "EVP_PKEY as DER failed"); + return NULL; + } + + der = PyBytes_FromStringAndSize((char*)pp, len); + + OPENSSL_free(pp); + return der; +} + +PyObject *pkey_get_modulus(EVP_PKEY *pkey) +{ + RSA *rsa; + DSA *dsa; + BIO *bio; + BUF_MEM *bptr; + PyObject *ret; + const BIGNUM* bn; + + switch (EVP_PKEY_base_id(pkey)) { + case EVP_PKEY_RSA: + rsa = EVP_PKEY_get1_RSA(pkey); + + bio = BIO_new(BIO_s_mem()); + if (!bio) { + RSA_free(rsa); + PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); + return NULL; + } + + RSA_get0_key(rsa, &bn, NULL, NULL); + if (!BN_print(bio, bn)) { + m2_PyErr_Msg(PyExc_RuntimeError); + BIO_free(bio); + RSA_free(rsa); + return NULL; + } + BIO_get_mem_ptr(bio, &bptr); + + ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); + + (void)BIO_set_close(bio, BIO_CLOSE); + BIO_free(bio); + RSA_free(rsa); + + return ret; + break; + + case EVP_PKEY_DSA: + dsa = EVP_PKEY_get1_DSA(pkey); + + bio = BIO_new(BIO_s_mem()); + if (!bio) { + DSA_free(dsa); + PyErr_SetString(PyExc_MemoryError, "pkey_get_modulus"); + return NULL; + } + + DSA_get0_key(dsa, &bn, NULL); + if (!BN_print(bio, bn)) { + m2_PyErr_Msg(PyExc_RuntimeError); + BIO_free(bio); + DSA_free(dsa); + return NULL; + } + BIO_get_mem_ptr(bio, &bptr); + + ret = PyBytes_FromStringAndSize(bptr->data, bptr->length); + + (void)BIO_set_close(bio, BIO_CLOSE); + BIO_free(bio); + DSA_free(dsa); + + return ret; + break; + + default: + PyErr_SetString(_evp_err, "unsupported key type"); + return NULL; + } +} + + + +#include + +#if OPENSSL_VERSION_NUMBER >= 0x0090800fL +#include +#endif + +/* +// 2004-10-10, ngps: +// CTR mode is not included in the default OpenSSL build. +// To use the AES CTR ciphers, link with your own copy of OpenSSL. +*/ +#ifdef HAVE_AES_CTR +extern EVP_CIPHER const *EVP_aes_128_ctr(void); +extern EVP_CIPHER const *EVP_aes_192_ctr(void); +extern EVP_CIPHER const *EVP_aes_256_ctr(void); +#endif + + +AES_KEY *aes_new(void) { + AES_KEY *key; + + if (!(key = (AES_KEY *)PyMem_Malloc(sizeof(AES_KEY)))) { + PyErr_SetString(PyExc_MemoryError, + "Insufficient memory for AES key."); + return NULL; + } + return key; +} + +void AES_free(AES_KEY *key) { + PyMem_Free((void *)key); +} + +/* +// op == 0: encrypt +// otherwise: decrypt (Python code will supply the value 1.) +*/ +PyObject *AES_set_key(AES_KEY *key, PyObject *value, int bits, int op) { + char *vbuf; + Py_ssize_t vlen; + + if (PyBytes_AsStringAndSize(value, &vbuf, &vlen) == -1) + return NULL; + + if (op == 0) + AES_set_encrypt_key((const unsigned char *)vbuf, bits, key); + else + AES_set_decrypt_key((const unsigned char *)vbuf, bits, key); + Py_RETURN_NONE; +} + +/* +// op == 0: encrypt +// otherwise: decrypt (Python code will supply the value 1.) +*/ +PyObject *AES_crypt(const AES_KEY *key, PyObject *in, int outlen, int op) { + char *buf; + Py_ssize_t len; + unsigned char *out; + PyObject *res; + + if (PyBytes_AsStringAndSize(in, &buf, &len) == -1) + return NULL; + + if (!(out=(unsigned char *)PyMem_Malloc(outlen))) { + PyErr_SetString(PyExc_MemoryError, "AES_crypt"); + return NULL; + } + if (op == 0) + AES_encrypt((const unsigned char *)buf, out, key); + else + AES_decrypt((const unsigned char *)buf, out, key); + res = PyBytes_FromStringAndSize((char*)out, outlen); + PyMem_Free(out); + return res; +} + +int AES_type_check(AES_KEY *key) { + return 1; +} + + +#include + + +RC4_KEY *rc4_new(void) { + RC4_KEY *key; + + if (!(key = (RC4_KEY *)PyMem_Malloc(sizeof(RC4_KEY)))) + PyErr_SetString(PyExc_MemoryError, "rc4_new"); + return key; +} + +void rc4_free(RC4_KEY *key) { + PyMem_Free((void *)key); +} + +PyObject *rc4_set_key(RC4_KEY *key, PyObject *value) { + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + RC4_set_key(key, vlen, vbuf); + Py_RETURN_NONE; +} + +PyObject *rc4_update(RC4_KEY *key, PyObject *in) { + PyObject *ret; + const void *buf; + Py_ssize_t len; + void *out; + + if (PyObject_AsReadBuffer(in, &buf, &len) == -1) + return NULL; + + if (!(out = PyMem_Malloc(len))) { + PyErr_SetString(PyExc_MemoryError, "expected a string object"); + return NULL; + } + RC4(key, len, buf, out); + + ret = PyBytes_FromStringAndSize(out, len); + + PyMem_Free(out); + return ret; +} + +int rc4_type_check(RC4_KEY *key) { + return 1; +} + + +#include +#include +#include +#include +#include + + +static PyObject *_dh_err; + +void dh_init(PyObject *dh_err) { + Py_INCREF(dh_err); + _dh_err = dh_err; +} + +int dh_type_check(DH *dh) { + /* Our getting here means we passed Swig's type checking, + XXX Still need to check the pointer for sanity? */ + return 1; +} + + +DH *dh_read_parameters(BIO *bio) { + return PEM_read_bio_DHparams(bio, NULL, NULL, NULL); +} + +DH *dh_generate_parameters(int plen, int g, PyObject *pyfunc) { + DH *dh; + BN_GENCB *gencb; + int ret; + + if ((gencb=BN_GENCB_new()) == NULL) { + m2_PyErr_Msg(_dh_err); + return NULL; + } + + if ((dh=DH_new()) == NULL) { + m2_PyErr_Msg(_dh_err); + BN_GENCB_free(gencb); + return NULL; + } + + BN_GENCB_set(gencb, bn_gencb_callback, (void *)pyfunc); + + Py_INCREF(pyfunc); + ret = DH_generate_parameters_ex(dh, plen, g, gencb); + Py_DECREF(pyfunc); + BN_GENCB_free(gencb); + + if (ret) + return dh; + + m2_PyErr_Msg(_dh_err); + DH_free(dh); + return NULL; +} + +/* Note return value shenanigan. */ +int dh_check(DH *dh) { + int err; + + return (DH_check(dh, &err)) ? 0 : err; +} + +PyObject *dh_compute_key(DH *dh, PyObject *pubkey) { + const void *pkbuf; + int pklen = 0, klen; + void *key; + BIGNUM *pk; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(pubkey, &pkbuf, &pklen) == -1) + return NULL; + + if (!(pk = BN_mpi2bn((unsigned char *)pkbuf, pklen, NULL))) { + m2_PyErr_Msg(_dh_err); + return NULL; + } + if (!(key = PyMem_Malloc(DH_size(dh)))) { + BN_free(pk); + PyErr_SetString(PyExc_MemoryError, "dh_compute_key"); + return NULL; + } + if ((klen = DH_compute_key((unsigned char *)key, pk, dh)) == -1) { + BN_free(pk); + PyMem_Free(key); + m2_PyErr_Msg(_dh_err); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)key, klen); + + BN_free(pk); + PyMem_Free(key); + return ret; +} + +PyObject *dh_get_p(DH *dh) { + const BIGNUM* p = NULL; + DH_get0_pqg(dh, &p, NULL, NULL); + if (!p) { + PyErr_SetString(_dh_err, "'p' is unset"); + return NULL; + } + return bn_to_mpi(p); +} + +PyObject *dh_get_g(DH *dh) { + const BIGNUM* g = NULL; + DH_get0_pqg(dh, NULL, NULL, &g); + if (!g) { + PyErr_SetString(_dh_err, "'g' is unset"); + return NULL; + } + return bn_to_mpi(g); +} + +PyObject *dh_get_pub(DH *dh) { + const BIGNUM* pub_key = NULL; + DH_get0_key(dh, &pub_key, NULL); + if (!pub_key) { + PyErr_SetString(_dh_err, "'pub' is unset"); + return NULL; + } + return bn_to_mpi(pub_key); +} + +PyObject *dh_get_priv(DH *dh) { + const BIGNUM* priv_key = NULL; + DH_get0_key(dh, NULL, &priv_key); + if (!priv_key) { + PyErr_SetString(_dh_err, "'priv' is unset"); + return NULL; + } + return bn_to_mpi(priv_key); +} + +PyObject *dh_set_pg(DH *dh, PyObject *pval, PyObject* gval) { + BIGNUM* p, *g; + + if (!(p = m2_PyObject_AsBIGNUM(pval, _dh_err)) + || !(g = m2_PyObject_AsBIGNUM(gval, _dh_err))) + return NULL; + + if (!DH_set0_pqg(dh, p, NULL, g)) { + PyErr_SetString(_dh_err, + "Cannot set prime number or generator of Z_p for DH."); + BN_free(p); + BN_free(g); + return NULL; + } + + Py_RETURN_NONE; +} + + +#include +#include +#include +#include +#include + + +static PyObject *_rsa_err; + +void rsa_init(PyObject *rsa_err) { + Py_INCREF(rsa_err); + _rsa_err = rsa_err; +} + + +RSA *rsa_read_key(BIO *f, PyObject *pyfunc) { + RSA *rsa; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + rsa = PEM_read_bio_RSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return rsa; +} + + +int rsa_write_key(RSA *rsa, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_RSAPrivateKey(f, rsa, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +int rsa_write_key_no_cipher(RSA *rsa, BIO *f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_RSAPrivateKey(f, rsa, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +RSA *rsa_read_pub_key(BIO *f) { + return PEM_read_bio_RSA_PUBKEY(f, NULL, NULL, NULL); +} + + +int rsa_write_pub_key(RSA *rsa, BIO *f) { + return PEM_write_bio_RSA_PUBKEY(f, rsa); +} + +PyObject *rsa_get_e(RSA *rsa) { + const BIGNUM* e = NULL; + RSA_get0_key(rsa, NULL, &e, NULL); + if (!e) { + PyErr_SetString(_rsa_err, "'e' is unset"); + return NULL; + } + return bn_to_mpi(e); +} + +PyObject *rsa_get_n(RSA *rsa) { + const BIGNUM* n = NULL; + RSA_get0_key(rsa, &n, NULL, NULL); + if (!n) { + PyErr_SetString(_rsa_err, "'n' is unset"); + return NULL; + } + return bn_to_mpi(n); +} + +PyObject *rsa_set_e(RSA *rsa, PyObject *eval) { + const BIGNUM* n_read = NULL; + BIGNUM* n = NULL; + BIGNUM* e; + + if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err))) { + return NULL; + } + + /* n and e must be set at the same time so if e is unset, set it to zero */ + RSA_get0_key(rsa, &n_read, NULL, NULL); + if (!n_read) { + n = BN_new(); + } + + if (RSA_set0_key(rsa, n, e, NULL) != 1) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(e); + BN_free(n); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *rsa_set_n(RSA *rsa, PyObject *nval) { + BIGNUM* n; + const BIGNUM* e_read = NULL; + BIGNUM* e = NULL; + + if (!(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { + return NULL; + } + + /* n and e must be set at the same time so if e is unset, set it to zero */ + RSA_get0_key(rsa, NULL, &e_read, NULL); + if (!e_read) { + e = BN_new(); + } + + if (RSA_set0_key(rsa, n, e, NULL) != 1) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(n); + BN_free(e); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *rsa_set_en(RSA *rsa, PyObject *eval, PyObject* nval) { + BIGNUM* e, *n; + + if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err)) || + !(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { + return NULL; + } + + if (!RSA_set0_key(rsa, n, e, NULL)) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(e); + BN_free(n); + return NULL; + } + Py_RETURN_NONE; +} + +static BIGNUM* PyObject_Bin_AsBIGNUM(PyObject* value) { + BIGNUM* bn; + const void* vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(bn = BN_bin2bn((unsigned char *)vbuf, vlen, NULL))) { + m2_PyErr_Msg(_rsa_err); + return NULL; + } + + return bn; +} + +PyObject *rsa_set_en_bin(RSA *rsa, PyObject *eval, PyObject* nval) { + BIGNUM* e, *n; + + if (!(e = PyObject_Bin_AsBIGNUM(eval)) || + !(n = PyObject_Bin_AsBIGNUM(nval))) { + return NULL; + } + + if (!RSA_set0_key(rsa, e, n, NULL)) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(e); + BN_free(n); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *rsa_private_encrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_private_encrypt"); + return NULL; + } + tlen = RSA_private_encrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +PyObject *rsa_public_decrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen = 0; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + /* OpenSSL docs are confused here: it says we only need buffer + * 'RSA_size()-11', but it is true only for RSA PKCS#1 type 1 + * padding. For other uses we need to use different sizes. */ + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_public_decrypt"); + return NULL; + } + tlen = RSA_public_decrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +PyObject *rsa_public_encrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_public_encrypt"); + return NULL; + } + tlen = RSA_public_encrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +PyObject *rsa_private_decrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_private_decrypt"); + return NULL; + } + tlen = RSA_private_decrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +#if OPENSSL_VERSION_NUMBER >= 0x0090708fL +PyObject *rsa_padding_add_pkcs1_pss(RSA *rsa, PyObject *digest, EVP_MD *hash, int salt_length) { + const void *dbuf; + unsigned char *tbuf; + int dlen, result, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) + return NULL; + + tlen = RSA_size(rsa); + + if (!(tbuf = OPENSSL_malloc(tlen))) { + PyErr_SetString(PyExc_MemoryError, "rsa_padding_add_pkcs1_pss"); + return NULL; + } + result = RSA_padding_add_PKCS1_PSS( + rsa, + tbuf, + (unsigned char *)dbuf, + hash, + salt_length); + + if (result == -1) { + m2_PyErr_Msg(_rsa_err); + OPENSSL_cleanse(tbuf, tlen); + OPENSSL_free(tbuf); + return NULL; + } + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + OPENSSL_cleanse(tbuf, tlen); + OPENSSL_free(tbuf); + return ret; +} + +int rsa_verify_pkcs1_pss(RSA *rsa, PyObject *digest, PyObject *signature, EVP_MD *hash, int salt_length) { + const void *dbuf; + const void *sbuf; + int dlen, slen, ret; + + if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) { + return 0; + } + + if (m2_PyObject_AsReadBufferInt(signature, &sbuf, &slen) == -1) { + return 0; + } + + ret = RSA_verify_PKCS1_PSS( + rsa, + (unsigned char *)dbuf, + hash, + (unsigned char *)sbuf, + salt_length); + + return ret; +} +#endif + +PyObject *rsa_sign(RSA *rsa, PyObject *py_digest_string, int method_type) { + int digest_len = 0; + int buf_len = 0; + int ret = 0; + unsigned int real_buf_len = 0; + char *digest_string = NULL; + unsigned char * sign_buf = NULL; + PyObject *signature; + + ret = m2_PyString_AsStringAndSizeInt(py_digest_string, &digest_string, + &digest_len); + if (ret == -1) { + /* PyString_AsStringAndSize raises the correct exceptions. */ + return NULL; + } + + buf_len = RSA_size(rsa); + sign_buf = (unsigned char *)PyMem_Malloc(buf_len); + ret = RSA_sign(method_type, (const unsigned char *)digest_string, digest_len, + sign_buf, &real_buf_len, rsa); + + if (!ret) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(sign_buf); + return NULL; + } + + signature = PyBytes_FromStringAndSize((const char*) sign_buf, buf_len); + + PyMem_Free(sign_buf); + return signature; +} + +int rsa_verify(RSA *rsa, PyObject *py_verify_string, PyObject* py_sign_string, int method_type){ + int ret = 0; + char * sign_string = NULL; + char * verify_string = NULL; + int verify_len = 0; + int sign_len = 0; + + ret = m2_PyString_AsStringAndSizeInt(py_verify_string, &verify_string, + &verify_len); + if (ret == -1) { + /* PyString_AsStringAndSize raises the correct exceptions. */ + return 0; + } + ret = m2_PyString_AsStringAndSizeInt(py_sign_string, &sign_string, + &sign_len); + if (ret == -1) { + return 0; + } + + ret = RSA_verify(method_type, (unsigned char *) verify_string, + verify_len, (unsigned char *) sign_string, + sign_len, rsa); + if (!ret) { + m2_PyErr_Msg(_rsa_err); + return 0; + } + return ret; +} + +PyObject *rsa_generate_key(int bits, unsigned long e, PyObject *pyfunc) { + RSA *rsa; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + BN_GENCB *gencb; + BIGNUM *e_big; + int ret; + + if ((e_big=BN_new()) == NULL) { + m2_PyErr_Msg(_rsa_err); + return NULL; + } + + if (BN_set_word(e_big, e) == 0) { + m2_PyErr_Msg(_rsa_err); + BN_free(e_big); + return NULL; + } + + if ((gencb=BN_GENCB_new()) == NULL) { + m2_PyErr_Msg(_rsa_err); + BN_free(e_big); + return NULL; + } + + if ((rsa = RSA_new()) == NULL) { + m2_PyErr_Msg(_rsa_err); + BN_free(e_big); + BN_GENCB_free(gencb); + return NULL; + } + + BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); + + Py_INCREF(pyfunc); + ret = RSA_generate_key_ex(rsa, bits, e_big, gencb); + BN_free(e_big); + BN_GENCB_free(gencb); + Py_DECREF(pyfunc); + + if (ret) + return SWIG_NewPointerObj((void *)rsa, SWIGTYPE_p_RSA, 0); + + m2_PyErr_Msg(_rsa_err); + RSA_free(rsa); + return NULL; +} + +int rsa_type_check(RSA *rsa) { + return 1; +} + +int rsa_check_pub_key(RSA *rsa) { + const BIGNUM* n, *e; + RSA_get0_key(rsa, &n, &e, NULL); + return n && e; +} + + +int rsa_write_key_der(RSA *rsa, BIO *bio) { + return i2d_RSAPrivateKey_bio(bio, rsa); +} + + +#include +#include +#include +#include + +PyObject *dsa_sig_get_r(DSA_SIG *dsa_sig) { + const BIGNUM* pr; + DSA_SIG_get0(dsa_sig, &pr, NULL); + return bn_to_mpi(pr); +} + +PyObject *dsa_sig_get_s(DSA_SIG *dsa_sig) { + const BIGNUM* qs; + DSA_SIG_get0(dsa_sig, NULL, &qs); + return bn_to_mpi(qs); +} + + +static PyObject *_dsa_err; + +void dsa_init(PyObject *dsa_err) { + Py_INCREF(dsa_err); + _dsa_err = dsa_err; +} + + +DSA *dsa_generate_parameters(int bits, PyObject *pyfunc) { + DSA *dsa; + BN_GENCB *gencb; + int ret; + + if ((gencb=BN_GENCB_new()) == NULL) { + m2_PyErr_Msg(_dh_err); + return NULL; + } + + if ((dsa = DSA_new()) == NULL) { + m2_PyErr_Msg(_dsa_err); + BN_GENCB_free(gencb); + return NULL; + } + + BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); + + Py_INCREF(pyfunc); + ret = DSA_generate_parameters_ex(dsa, bits, NULL, 0, NULL, NULL, + gencb); + Py_DECREF(pyfunc); + BN_GENCB_free(gencb); + + if (ret) + return dsa; + + m2_PyErr_Msg(_dsa_err); + DSA_free(dsa); + return NULL; +} + +DSA *dsa_read_params(BIO *f, PyObject *pyfunc) { + DSA *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_DSAparams(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (ret == NULL) { + m2_PyErr_Msg(_dsa_err); + } + + return ret; +} + +DSA *dsa_read_key(BIO *f, PyObject *pyfunc) { + DSA *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_DSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (ret == NULL) { + m2_PyErr_Msg(_dsa_err); + } + + return ret; +} + +DSA *dsa_read_pub_key(BIO *f, PyObject *pyfunc) { + DSA *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_DSA_PUBKEY(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + + if (ret == NULL) { + m2_PyErr_Msg(_dsa_err); + } + + return ret; +} + + +PyObject *dsa_get_p(DSA *dsa) { + const BIGNUM* p = NULL; + DSA_get0_pqg(dsa, &p, NULL, NULL); + if (!p) { + PyErr_SetString(_dsa_err, "'p' is unset"); + return NULL; + } + return bn_to_mpi(p); +} + +PyObject *dsa_get_q(DSA *dsa) { + const BIGNUM* q = NULL; + DSA_get0_pqg(dsa, NULL, &q, NULL); + if (!q) { + PyErr_SetString(_dsa_err, "'q' is unset"); + return NULL; + } + return bn_to_mpi(q); +} + +PyObject *dsa_get_g(DSA *dsa) { + const BIGNUM* g = NULL; + DSA_get0_pqg(dsa, NULL, NULL, &g); + if (!g) { + PyErr_SetString(_dsa_err, "'g' is unset"); + return NULL; + } + return bn_to_mpi(g); +} + +PyObject *dsa_get_pub(DSA *dsa) { + const BIGNUM* pub_key = NULL; + DSA_get0_key(dsa, &pub_key, NULL); + if (!pub_key) { + PyErr_SetString(_dsa_err, "'pub' is unset"); + return NULL; + } + return bn_to_mpi(pub_key); +} + +PyObject *dsa_get_priv(DSA *dsa) { + const BIGNUM* priv_key = NULL; + DSA_get0_key(dsa, NULL, &priv_key); + if (!priv_key) { + PyErr_SetString(_dsa_err, "'priv' is unset"); + return NULL; + } + return bn_to_mpi(priv_key); +} + +PyObject *dsa_set_pqg(DSA *dsa, PyObject *pval, PyObject* qval, PyObject* gval) { + BIGNUM* p, *q, *g; + + if (!(p = m2_PyObject_AsBIGNUM(pval, _dsa_err)) + || !(q = m2_PyObject_AsBIGNUM(qval, _dsa_err)) + || !(g = m2_PyObject_AsBIGNUM(gval, _dsa_err))) + return NULL; + + if (!DSA_set0_pqg(dsa, p, q, g)) { + PyErr_SetString( + _dsa_err, + "Cannot set prime number, subprime, or generator of subgroup for DSA."); + BN_free(p); + BN_free(q); + BN_free(g); + return NULL; + } + + Py_RETURN_NONE; + } + +PyObject *dsa_set_pub(DSA *dsa, PyObject *value) { + BIGNUM *bn; + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(bn = BN_mpi2bn((unsigned char *)vbuf, vlen, NULL))) { + m2_PyErr_Msg(_dsa_err); + return NULL; + } + if (!DSA_set0_key(dsa, bn, NULL)) { + BN_free(bn); + PyErr_SetString(_dsa_err, "Cannot set private and public key for DSA."); + } + Py_RETURN_NONE; +} + + +int dsa_write_params_bio(DSA* dsa, BIO* f) { + return PEM_write_bio_DSAparams(f, dsa); +} + + +int dsa_write_key_bio(DSA* dsa, BIO* f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_DSAPrivateKey(f, dsa, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +int dsa_write_key_bio_no_cipher(DSA* dsa, BIO* f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_DSAPrivateKey(f, dsa, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +int dsa_write_pub_key_bio(DSA* dsa, BIO* f) { + return PEM_write_bio_DSA_PUBKEY(f, dsa); +} + + +PyObject *dsa_sign(DSA *dsa, PyObject *value) { + const void *vbuf; + int vlen = 0; + PyObject *tuple; + DSA_SIG *sig; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sig = DSA_do_sign(vbuf, vlen, dsa))) { + m2_PyErr_Msg(_dsa_err); + return NULL; + } + if (!(tuple = PyTuple_New(2))) { + DSA_SIG_free(sig); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + PyTuple_SET_ITEM(tuple, 0, dsa_sig_get_r(sig)); + PyTuple_SET_ITEM(tuple, 1, dsa_sig_get_s(sig)); + DSA_SIG_free(sig); + return tuple; +} + +int dsa_verify(DSA *dsa, PyObject *value, PyObject *r, PyObject *s) { + const void *vbuf, *rbuf, *sbuf; + int vlen = 0, rlen = 0, slen = 0; + DSA_SIG *sig; + BIGNUM* pr, *ps; + int ret; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) + || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) + return -1; + + if (!(sig = DSA_SIG_new())) { + m2_PyErr_Msg(_dsa_err); + return -1; + } + if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { + m2_PyErr_Msg(_dsa_err); + DSA_SIG_free(sig); + return -1; + } + if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { + m2_PyErr_Msg(_dsa_err); + DSA_SIG_free(sig); + BN_free(pr); + return -1; + } + if (!DSA_SIG_set0(sig, pr, ps)) { + m2_PyErr_Msg(_dsa_err); + DSA_SIG_free(sig); + BN_free(pr); + BN_free(ps); + return -1; + } + + ret = DSA_do_verify(vbuf, vlen, sig, dsa); + DSA_SIG_free(sig); + if (ret == -1) + m2_PyErr_Msg(_dsa_err); + return ret; +} + +PyObject *dsa_sign_asn1(DSA *dsa, PyObject *value) { + const void *vbuf; + int vlen = 0; + void *sigbuf; + unsigned int siglen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sigbuf = PyMem_Malloc(DSA_size(dsa)))) { + PyErr_SetString(PyExc_MemoryError, "dsa_sign_asn1"); + return NULL; + } + if (!DSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, dsa)) { + m2_PyErr_Msg(_dsa_err); + PyMem_Free(sigbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize(sigbuf, siglen); + + PyMem_Free(sigbuf); + return ret; +} + +int dsa_verify_asn1(DSA *dsa, PyObject *value, PyObject *sig) { + const void *vbuf; + void *sbuf; + int vlen = 0, slen = 0, ret = 0; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) + == -1)) + return -1; + + if ((ret = DSA_verify(0, vbuf, vlen, sbuf, slen, dsa)) == -1) + m2_PyErr_Msg(_dsa_err); + return ret; +} + +int dsa_check_key(DSA *dsa) { + const BIGNUM* pub_key, *priv_key; + DSA_get0_key(dsa, &pub_key, &priv_key); + return pub_key != NULL && priv_key != NULL; +} + +int dsa_check_pub_key(DSA *dsa) { + const BIGNUM* pub_key; + DSA_get0_key(dsa, &pub_key, NULL); + return pub_key ? 1 : 0; +} + +int dsa_keylen(DSA *dsa) { + const BIGNUM* p; + DSA_get0_pqg(dsa, &p, NULL, NULL); + return BN_num_bits(p); +} + +int dsa_type_check(DSA *dsa) { + return 1; +} + + +#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#include +#pragma comment(lib, "Ws2_32") +typedef unsigned __int64 uint64_t; +#else +#include +#include +#endif + + +static PyObject *_ssl_err; +static PyObject *_ssl_timeout_err; + +void ssl_init(PyObject *ssl_err, PyObject *ssl_timeout_err) { + SSL_library_init(); + SSL_load_error_strings(); + Py_INCREF(ssl_err); + Py_INCREF(ssl_timeout_err); + _ssl_err = ssl_err; + _ssl_timeout_err = ssl_timeout_err; +} + +const SSL_METHOD *tlsv1_method(void) { +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + PyErr_WarnEx(PyExc_DeprecationWarning, + "Function TLSv1_method has been deprecated.", 1); +#endif + return TLSv1_method(); +} + +void ssl_ctx_passphrase_callback(SSL_CTX *ctx, PyObject *pyfunc) { + SSL_CTX_set_default_passwd_cb(ctx, passphrase_callback); + SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *)pyfunc); + Py_INCREF(pyfunc); +} + +int ssl_ctx_use_x509(SSL_CTX *ctx, X509 *x) { + int i; + + if (!(i = SSL_CTX_use_certificate(ctx, x))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; + +} + +int ssl_ctx_use_cert(SSL_CTX *ctx, char *file) { + int i; + + if (!(i = SSL_CTX_use_certificate_file(ctx, file, SSL_FILETYPE_PEM))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + +int ssl_ctx_use_cert_chain(SSL_CTX *ctx, char *file) { + int i; + + if (!(i = SSL_CTX_use_certificate_chain_file(ctx, file))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + + +int ssl_ctx_use_privkey(SSL_CTX *ctx, char *file) { + int i; + + if (!(i = SSL_CTX_use_PrivateKey_file(ctx, file, SSL_FILETYPE_PEM))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + +int ssl_ctx_use_rsa_privkey(SSL_CTX *ctx, RSA *rsakey) { + int i; + + if (!(i = SSL_CTX_use_RSAPrivateKey(ctx, rsakey))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + +int ssl_ctx_use_pkey_privkey(SSL_CTX *ctx, EVP_PKEY *pkey) { + int i; + + if (!(i = SSL_CTX_use_PrivateKey(ctx, pkey))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + + +int ssl_ctx_check_privkey(SSL_CTX *ctx) { + int ret; + + if (!(ret = SSL_CTX_check_private_key(ctx))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return ret; +} + +void ssl_ctx_set_client_CA_list_from_file(SSL_CTX *ctx, const char *ca_file) { + SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(ca_file)); +} + +void ssl_ctx_set_verify_default(SSL_CTX *ctx, int mode) { + SSL_CTX_set_verify(ctx, mode, NULL); +} + +void ssl_ctx_set_verify(SSL_CTX *ctx, int mode, PyObject *pyfunc) { + Py_XDECREF(ssl_verify_cb_func); + Py_INCREF(pyfunc); + ssl_verify_cb_func = pyfunc; + SSL_CTX_set_verify(ctx, mode, ssl_verify_callback); +} + +int ssl_ctx_set_session_id_context(SSL_CTX *ctx, PyObject *sid_ctx) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) + return -1; + + return SSL_CTX_set_session_id_context(ctx, buf, len); +} + +void ssl_ctx_set_info_callback(SSL_CTX *ctx, PyObject *pyfunc) { + Py_XDECREF(ssl_info_cb_func); + Py_INCREF(pyfunc); + ssl_info_cb_func = pyfunc; + SSL_CTX_set_info_callback(ctx, ssl_info_callback); +} + +long ssl_ctx_set_tmp_dh(SSL_CTX *ctx, DH* dh) { + return SSL_CTX_set_tmp_dh(ctx, dh); +} + +void ssl_ctx_set_tmp_dh_callback(SSL_CTX *ctx, PyObject *pyfunc) { + Py_XDECREF(ssl_set_tmp_dh_cb_func); + Py_INCREF(pyfunc); + ssl_set_tmp_dh_cb_func = pyfunc; + SSL_CTX_set_tmp_dh_callback(ctx, ssl_set_tmp_dh_callback); +} + +long ssl_ctx_set_tmp_rsa(SSL_CTX *ctx, RSA* rsa) { + return SSL_CTX_set_tmp_rsa(ctx, rsa); +} + +void ssl_ctx_set_tmp_rsa_callback(SSL_CTX *ctx, PyObject *pyfunc) { + Py_XDECREF(ssl_set_tmp_rsa_cb_func); + Py_INCREF(pyfunc); + ssl_set_tmp_rsa_cb_func = pyfunc; + SSL_CTX_set_tmp_rsa_callback(ctx, ssl_set_tmp_rsa_callback); +} + +int ssl_ctx_load_verify_locations(SSL_CTX *ctx, const char *cafile, const char *capath) { + return SSL_CTX_load_verify_locations(ctx, cafile, capath); +} + +/* SSL_CTX_set_options is a macro. */ +long ssl_ctx_set_options(SSL_CTX *ctx, long op) { + return SSL_CTX_set_options(ctx, op); +} + +int bio_set_ssl(BIO *bio, SSL *ssl, int flag) { + SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); + return BIO_ctrl(bio, BIO_C_SET_SSL, flag, (char *)ssl); +} + +long ssl_set_mode(SSL *ssl, long mode) { + return SSL_set_mode(ssl, mode); +} + +long ssl_get_mode(SSL *ssl) { + return SSL_get_mode(ssl); +} + +int ssl_set_tlsext_host_name(SSL *ssl, const char *name) { + long l; + + if (!(l = SSL_set_tlsext_host_name(ssl, name))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + /* Return an "int" to match the 'typemap(out) int' in _lib.i */ + return 1; +} + +void ssl_set_client_CA_list_from_file(SSL *ssl, const char *ca_file) { + SSL_set_client_CA_list(ssl, SSL_load_client_CA_file(ca_file)); +} + +void ssl_set_client_CA_list_from_context(SSL *ssl, SSL_CTX *ctx) { + SSL_set_client_CA_list(ssl, SSL_CTX_get_client_CA_list(ctx)); +} + +int ssl_set_session_id_context(SSL *ssl, PyObject *sid_ctx) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) + return -1; + + return SSL_set_session_id_context(ssl, buf, len); +} + +int ssl_set_fd(SSL *ssl, int fd) { + int ret; + + if (!(ret = SSL_set_fd(ssl, fd))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return ret; +} + +static void ssl_handle_error(int ssl_err, int ret) { + int err; + + switch (ssl_err) { + case SSL_ERROR_SSL: + PyErr_SetString(_ssl_err, + ERR_reason_error_string(ERR_get_error())); + break; + case SSL_ERROR_SYSCALL: + err = ERR_get_error(); + if (err) + PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); + else if (ret == 0) + PyErr_SetString(_ssl_err, "unexpected eof"); + else if (ret == -1) + PyErr_SetFromErrno(_ssl_err); + else + assert(0); + break; + default: + PyErr_SetString(_ssl_err, "unexpected SSL error"); + } +} + +#ifdef _WIN32 +/* http://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows */ +int gettimeofday(struct timeval *tp, void *tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime( &system_time ); + SystemTimeToFileTime( &system_time, &file_time ); + time = ((uint64_t)file_time.dwLowDateTime ) ; + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((time - EPOCH) / 10000000L); + tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + return 0; +} +#endif + +static int ssl_sleep_with_timeout(SSL *ssl, const struct timeval *start, + double timeout, int ssl_err) { +#ifdef _WIN32 +WSAPOLLFD fd; +#else +struct pollfd fd; +#endif + struct timeval tv; + int ms, tmp; + + assert(timeout > 0); + again: + gettimeofday(&tv, NULL); + /* tv >= start */ + if ((timeout + start->tv_sec - tv.tv_sec) > INT_MAX / 1000) + ms = -1; + else { + int fract; + + ms = ((start->tv_sec + (int)timeout) - tv.tv_sec) * 1000; + fract = (int)((start->tv_usec + (timeout - (int)timeout) * 1000000 + - tv.tv_usec + 999) / 1000); + if (ms > 0 && fract > INT_MAX - ms) + ms = -1; + else { + ms += fract; + if (ms <= 0) + goto timeout; + } + } + switch (ssl_err) { + case SSL_ERROR_WANT_READ: + fd.fd = SSL_get_rfd(ssl); + fd.events = POLLIN; + break; + + case SSL_ERROR_WANT_WRITE: + fd.fd = SSL_get_wfd(ssl); + fd.events = POLLOUT; + break; + + case SSL_ERROR_WANT_X509_LOOKUP: + return 0; /* FIXME: is this correct? */ + + default: + assert(0); + } + if (fd.fd == -1) { + PyErr_SetString(_ssl_err, "timeout on a non-FD SSL"); + return -1; + } + Py_BEGIN_ALLOW_THREADS +#ifdef _WIN32 + tmp = WSAPoll(&fd, 1, ms); +#else + tmp = poll(&fd, 1, ms); +#endif + Py_END_ALLOW_THREADS + switch (tmp) { + case 1: + return 0; + case 0: + goto timeout; + case -1: +#ifdef _WIN32 + if (WSAGetLastError() == EINTR) +#else + if (errno == EINTR) +#endif + goto again; + PyErr_SetFromErrno(_ssl_err); + return -1; + } + return 0; + + timeout: + PyErr_SetString(_ssl_timeout_err, "timed out"); + return -1; +} + +PyObject *ssl_accept(SSL *ssl, double timeout) { + PyObject *obj = NULL; + int r, ssl_err; + struct timeval tv; + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_accept(ssl); + ssl_err = SSL_get_error(ssl, r); + Py_END_ALLOW_THREADS + + + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + obj = PyLong_FromLong((long)1); + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + if (timeout <= 0) { + obj = PyLong_FromLong((long)0); + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + obj = NULL; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + obj = NULL; + break; + } + + + return obj; +} + +PyObject *ssl_connect(SSL *ssl, double timeout) { + PyObject *obj = NULL; + int r, ssl_err; + struct timeval tv; + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_connect(ssl); + ssl_err = SSL_get_error(ssl, r); + Py_END_ALLOW_THREADS + + + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + obj = PyLong_FromLong((long)1); + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + if (timeout <= 0) { + obj = PyLong_FromLong((long)0); + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + obj = NULL; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + obj = NULL; + break; + } + + + return obj; +} + +void ssl_set_shutdown1(SSL *ssl, int mode) { + SSL_set_shutdown(ssl, mode); +} + +PyObject *ssl_read(SSL *ssl, int num, double timeout) { + PyObject *obj = NULL; + void *buf; + int r; + struct timeval tv; + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "ssl_read"); + return NULL; + } + + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_read(ssl, buf, num); + Py_END_ALLOW_THREADS + + if (r >= 0) { + buf = PyMem_Realloc(buf, r); + obj = PyBytes_FromStringAndSize(buf, r); + } else { + int ssl_err; + + ssl_err = SSL_get_error(ssl, r); + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + assert(0); + + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + if (timeout <= 0) { + Py_INCREF(Py_None); + obj = Py_None; + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + obj = NULL; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + obj = NULL; + break; + } + } + PyMem_Free(buf); + + + return obj; +} + +PyObject *ssl_read_nbio(SSL *ssl, int num) { + PyObject *obj = NULL; + void *buf; + int r, err; + + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "ssl_read"); + return NULL; + } + + + Py_BEGIN_ALLOW_THREADS + r = SSL_read(ssl, buf, num); + Py_END_ALLOW_THREADS + + + switch (SSL_get_error(ssl, r)) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + buf = PyMem_Realloc(buf, r); + + obj = PyBytes_FromStringAndSize(buf, r); + + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + Py_INCREF(Py_None); + obj = Py_None; + break; + case SSL_ERROR_SSL: + m2_PyErr_Msg(_ssl_err); + obj = NULL; + break; + case SSL_ERROR_SYSCALL: + err = ERR_get_error(); + if (err) + PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); + else if (r == 0) + PyErr_SetString(_ssl_err, "unexpected eof"); + else if (r == -1) + PyErr_SetFromErrno(_ssl_err); + obj = NULL; + break; + } + PyMem_Free(buf); + + + return obj; +} + +int ssl_write(SSL *ssl, PyObject *blob, double timeout) { + Py_buffer buf; + int r, ssl_err, ret; + struct timeval tv; + + + if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { + return -1; + } + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_write(ssl, buf.buf, buf.len); + ssl_err = SSL_get_error(ssl, r); + Py_END_ALLOW_THREADS + + + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + ret = r; + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + if (timeout <= 0) { + ret = -1; + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + ret = -1; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + default: + ret = -1; + } + + m2_PyBuffer_Release(blob, &buf); + return ret; +} + +int ssl_write_nbio(SSL *ssl, PyObject *blob) { + Py_buffer buf; + int r, err, ret; + + + if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { + return -1; + } + + + Py_BEGIN_ALLOW_THREADS + r = SSL_write(ssl, buf.buf, buf.len); + Py_END_ALLOW_THREADS + + + switch (SSL_get_error(ssl, r)) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + ret = r; + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + ret = -1; + break; + case SSL_ERROR_SSL: + ret = -1; + break; + case SSL_ERROR_SYSCALL: + err = ERR_get_error(); + if (err) + PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); + else if (r == 0) + PyErr_SetString(_ssl_err, "unexpected eof"); + else if (r == -1) + PyErr_SetFromErrno(_ssl_err); + default: + ret = -1; + } + + m2_PyBuffer_Release(blob, &buf); + return ret; +} + +int ssl_cipher_get_bits(SSL_CIPHER *c) { + return SSL_CIPHER_get_bits(c, NULL); +} + +int sk_ssl_cipher_num(STACK_OF(SSL_CIPHER) *stack) { + return sk_SSL_CIPHER_num(stack); +} + +const SSL_CIPHER *sk_ssl_cipher_value(STACK_OF(SSL_CIPHER) *stack, int idx) { + return sk_SSL_CIPHER_value(stack, idx); +} + +STACK_OF(X509) *ssl_get_peer_cert_chain(SSL *ssl) { + return SSL_get_peer_cert_chain(ssl); +} + +int sk_x509_num(STACK_OF(X509) *stack) { + return sk_X509_num(stack); +} + +X509 *sk_x509_value(STACK_OF(X509) *stack, int idx) { + return sk_X509_value(stack, idx); +} + + +void i2d_ssl_session(BIO *bio, SSL_SESSION *sess) { + i2d_SSL_SESSION_bio(bio, sess); +} + + +SSL_SESSION *ssl_session_read_pem(BIO *bio) { + return PEM_read_bio_SSL_SESSION(bio, NULL, NULL, NULL); +} + + +int ssl_session_write_pem(SSL_SESSION *sess, BIO *bio) { + return PEM_write_bio_SSL_SESSION(bio, sess); +} + +int ssl_ctx_set_session_cache_mode(SSL_CTX *ctx, int mode) +{ + return SSL_CTX_set_session_cache_mode(ctx, mode); +} + +int ssl_ctx_get_session_cache_mode(SSL_CTX *ctx) +{ + return SSL_CTX_get_session_cache_mode(ctx); +} + +static long ssl_ctx_set_cache_size(SSL_CTX *ctx, long arg) +{ + return SSL_CTX_sess_set_cache_size(ctx, arg); +} + +int ssl_is_init_finished(SSL *ssl) +{ + return SSL_is_init_finished(ssl); +} + + +#include +#include +#include + +#include + +typedef STACK_OF(X509) SEQ_CERT; + +ASN1_ITEM_TEMPLATE(SEQ_CERT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, SeqCert, X509) +ASN1_ITEM_TEMPLATE_END(SEQ_CERT) + +IMPLEMENT_ASN1_FUNCTIONS(SEQ_CERT) + + +X509 *x509_read_pem(BIO *bio) { + return PEM_read_bio_X509(bio, NULL, NULL, NULL); +} + + +X509 *d2i_x509(BIO *bio) { + return d2i_X509_bio(bio, NULL); +} + + +static PyObject *_x509_err; + +void x509_init(PyObject *x509_err) { + Py_INCREF(x509_err); + _x509_err = x509_err; +} + + +X509_REQ *d2i_x509_req(BIO *bio) { + return d2i_X509_REQ_bio(bio, NULL); +} + + +X509_REQ *x509_req_read_pem(BIO *bio) { + return PEM_read_bio_X509_REQ(bio, NULL, NULL, NULL); +} + + +PyObject *i2d_x509(X509 *x) { + int len; + PyObject *ret = NULL; + unsigned char *buf = NULL; + len = i2d_X509(x, &buf); + if (len < 0) { + m2_PyErr_Msg(_x509_err); + } + else { + + ret = PyBytes_FromStringAndSize((char*)buf, len); + + OPENSSL_free(buf); + } + return ret; +} + + +int x509_req_write_pem(BIO *bio, X509_REQ *x) { + return PEM_write_bio_X509_REQ(bio, x); +} + + +X509_CRL *x509_crl_read_pem(BIO *bio) { + return PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); +} + + +/* X509_set_version() is a macro. */ +int x509_set_version(X509 *x, long version) { + return X509_set_version(x, version); +} + +/* X509_get_version() is a macro. */ +long x509_get_version(X509 *x) { + return X509_get_version(x); +} + +/* X509_set_notBefore() is a macro. */ +int x509_set_not_before(X509 *x, ASN1_TIME *tm) { + return X509_set_notBefore(x, tm); +} + +/* X509_get_notBefore() is a macro. */ +ASN1_TIME *x509_get_not_before(X509 *x) { + return X509_get_notBefore(x); +} + +/* X509_set_notAfter() is a macro. */ +int x509_set_not_after(X509 *x, ASN1_TIME *tm) { + return X509_set_notAfter(x, tm); +} + +/* X509_get_notAfter() is a macro. */ +ASN1_TIME *x509_get_not_after(X509 *x) { + return X509_get_notAfter(x); +} + +int x509_sign(X509 *x, EVP_PKEY *pkey, EVP_MD *md) { + return X509_sign(x, pkey, md); +} + +/* x509_gmtime_adj() is a macro. */ +ASN1_TIME *x509_gmtime_adj(ASN1_TIME *s, long adj) { + return X509_gmtime_adj(s, adj); +} + +PyObject *x509_name_by_nid(X509_NAME *name, int nid) { + void *buf; + int len, xlen; + PyObject *ret; + + if ((len = X509_NAME_get_text_by_NID(name, nid, NULL, 0)) == -1) { + Py_RETURN_NONE; + } + len++; + if (!(buf = PyMem_Malloc(len))) { + PyErr_SetString(PyExc_MemoryError, "x509_name_by_nid"); + return NULL; + } + xlen = X509_NAME_get_text_by_NID(name, nid, buf, len); + + ret = PyBytes_FromStringAndSize(buf, xlen); + + PyMem_Free(buf); + return ret; +} + +int x509_name_set_by_nid(X509_NAME *name, int nid, PyObject *obj) { + return X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC, (unsigned char *)PyBytes_AsString(obj), -1, -1, 0); +} + +/* x509_name_add_entry_by_txt */ +int x509_name_add_entry_by_txt(X509_NAME *name, char *field, int type, char *bytes, int len, int loc, int set) { + return X509_NAME_add_entry_by_txt(name, field, type, (unsigned char *)bytes, len, loc, set); +} + +PyObject *x509_name_get_der(X509_NAME *name) { + const char* pder=""; + size_t pderlen; + i2d_X509_NAME(name, 0); + if (!X509_NAME_get0_der(name, (const unsigned char **)pder, &pderlen)) { + m2_PyErr_Msg(_x509_err); + return NULL; + } + return PyBytes_FromStringAndSize(pder, pderlen); +} + +/* sk_X509_free() is a macro. */ +void sk_x509_free(STACK_OF(X509) *stack) { + sk_X509_free(stack); +} + +/* sk_X509_push() is a macro. */ +int sk_x509_push(STACK_OF(X509) *stack, X509 *x509) { + return sk_X509_push(stack, x509); +} + +/* sk_X509_pop() is a macro. */ +X509 *sk_x509_pop(STACK_OF(X509) *stack) { + return sk_X509_pop(stack); +} + + +int x509_store_load_locations(X509_STORE *store, const char *file) { + int locations = 0; + + if ((locations = X509_STORE_load_locations(store, file, NULL)) < 1) { + m2_PyErr_Msg(_x509_err); + } + return locations; +} + +int x509_type_check(X509 *x509) { + return 1; +} + +int x509_name_type_check(X509_NAME *name) { + return 1; +} + +X509_NAME *x509_req_get_subject_name(X509_REQ *x) { + return X509_REQ_get_subject_name(x); +} + +long x509_req_get_version(X509_REQ *x) { + return X509_REQ_get_version(x); +} + +int x509_req_set_version(X509_REQ *x, long version) { + return X509_REQ_set_version(x, version); +} + +int x509_req_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts) { + return X509_REQ_add_extensions(req, exts); +} + +X509_NAME_ENTRY *x509_name_entry_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, char *bytes, int len) { + return X509_NAME_ENTRY_create_by_txt( ne, field, type, (unsigned char *)bytes, len); +} + + +X509V3_CTX * +x509v3_set_nconf(void) { + X509V3_CTX * ctx; + CONF *conf = NCONF_new(NULL); + + if (!(ctx=(X509V3_CTX *)PyMem_Malloc(sizeof(X509V3_CTX)))) { + PyErr_SetString(PyExc_MemoryError, "x509v3_set_nconf"); + return NULL; + } + /* X509V3_set_nconf does not generate any error signs at all. */ + X509V3_set_nconf(ctx, conf); + return ctx; +} + + +X509_EXTENSION * +x509v3_ext_conf(void *conf, X509V3_CTX *ctx, char *name, char *value) { + X509_EXTENSION * ext = NULL; + ext = X509V3_EXT_conf(conf, ctx, name, value); + PyMem_Free(ctx); + return ext; +} + + +/* X509_EXTENSION_free() might be a macro, didn't find definition. */ +void x509_extension_free(X509_EXTENSION *ext) { + X509_EXTENSION_free(ext); +} + +PyObject *x509_extension_get_name(X509_EXTENSION *ext) { + PyObject * ext_name; + const char * ext_name_str; + ext_name_str = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext))); + if (!ext_name_str) { + m2_PyErr_Msg(_x509_err); + return NULL; + } + ext_name = PyBytes_FromStringAndSize(ext_name_str, strlen(ext_name_str)); + return ext_name; +} + +/* sk_X509_EXTENSION_new_null is a macro. */ +STACK_OF(X509_EXTENSION) *sk_x509_extension_new_null(void) { + return sk_X509_EXTENSION_new_null(); +} + +/* sk_X509_EXTENSION_free() is a macro. */ +void sk_x509_extension_free(STACK_OF(X509_EXTENSION) *stack) { + sk_X509_EXTENSION_free(stack); +} + +/* sk_X509_EXTENSION_push() is a macro. */ +int sk_x509_extension_push(STACK_OF(X509_EXTENSION) *stack, X509_EXTENSION *x509_ext) { + return sk_X509_EXTENSION_push(stack, x509_ext); +} + +/* sk_X509_EXTENSION_pop() is a macro. */ +X509_EXTENSION *sk_x509_extension_pop(STACK_OF(X509_EXTENSION) *stack) { + return sk_X509_EXTENSION_pop(stack); +} + +/* sk_X509_EXTENSION_num() is a macro. */ +int sk_x509_extension_num(STACK_OF(X509_EXTENSION) *stack) { + return sk_X509_EXTENSION_num(stack); +} + +/* sk_X509_EXTENSION_value() is a macro. */ +X509_EXTENSION *sk_x509_extension_value(STACK_OF(X509_EXTENSION) *stack, int i) { + return sk_X509_EXTENSION_value(stack, i); +} + +/* X509_STORE_CTX_get_app_data is a macro. */ +void *x509_store_ctx_get_app_data(X509_STORE_CTX *ctx) { + return X509_STORE_CTX_get_app_data(ctx); +} + +/* X509_STORE_CTX_get_app_data is a macro. */ +void *x509_store_ctx_get_ex_data(X509_STORE_CTX *ctx, int idx) { + return X509_STORE_CTX_get_ex_data(ctx, idx); +} + +void x509_store_set_verify_cb(X509_STORE *store, PyObject *pyfunc) { + Py_XDECREF(x509_store_verify_cb_func); + Py_INCREF(pyfunc); + x509_store_verify_cb_func = pyfunc; + X509_STORE_set_verify_cb(store, x509_store_verify_callback); +} + + +STACK_OF(X509) * +make_stack_from_der_sequence(PyObject * pyEncodedString){ + STACK_OF(X509) *certs; + Py_ssize_t encoded_string_len; + char *encoded_string; + const unsigned char *tmp_str; + + encoded_string_len = PyBytes_Size(pyEncodedString); + + if (encoded_string_len > INT_MAX) { + PyErr_Format(_x509_err, "object too large"); + return NULL; + } + + encoded_string = PyBytes_AsString(pyEncodedString); + + if (!encoded_string) { + PyErr_SetString(_x509_err, + "Cannot convert Python Bytes to (char *)."); + return NULL; + } + + tmp_str = (unsigned char *)encoded_string; + certs = d2i_SEQ_CERT(NULL, &tmp_str, encoded_string_len); + if (certs == NULL) { + PyErr_SetString(_x509_err, "Generating STACK_OF(X509) failed."); + return NULL; + } + return certs; +} + +/* sk_X509_new_null() is a macro returning "STACK_OF(X509) *". */ +STACK_OF(X509) *sk_x509_new_null(void) { + return sk_X509_new_null(); +} + + +PyObject * +get_der_encoding_stack(STACK_OF(X509) *stack){ + PyObject * encodedString; + + unsigned char * encoding = NULL; + int len; + + len = i2d_SEQ_CERT(stack, &encoding); + if (!encoding) { + m2_PyErr_Msg(_x509_err); + return NULL; + } + + encodedString = PyBytes_FromStringAndSize((const char *)encoding, len); + + if (encoding) + OPENSSL_free(encoding); + + return encodedString; +} + + + +char *x509_name_oneline(X509_NAME *x) { + return X509_NAME_oneline(x, NULL, 0); +} + + +#include + + +/* ASN1_TIME_set_string () is a macro */ +int asn1_time_type_check(ASN1_TIME *ASN1_TIME) { + return 1; +} + +PyObject *asn1_integer_get(ASN1_INTEGER *asn1) { + BIGNUM *bn; + PyObject *ret; + char *hex; + + bn = ASN1_INTEGER_to_BN(asn1, NULL); + + if (!bn){ + m2_PyErr_Msg(PyExc_RuntimeError); + return NULL; + } + + hex = BN_bn2hex(bn); + + if (!hex){ + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return NULL; + } + + BN_free(bn); + + ret = PyLong_FromString(hex, NULL, 16); + + OPENSSL_free(hex); + + return ret; +} + +int asn1_integer_set(ASN1_INTEGER *asn1, PyObject *value) { + BIGNUM *bn = NULL; + PyObject *fmt, *args, *hex; + +/* Despite all hopes to the contrary, we cannot survive here with + * PyLong_AsLong shims as provided in + * /usr/include/python2.7/longobject.h. + */ + long val = PyLong_AsLong(value); + if (val >= 0) { + return ASN1_INTEGER_set(asn1, val); + } else { + PyErr_Clear(); + } + + if (!PyLong_Check(value)){ + PyErr_SetString(PyExc_TypeError, "expected int or long"); + return 0; + } + + fmt = PyUnicode_FromString("%x"); + + if (!fmt) + return 0; + + args = PyTuple_New(1); + + if (!args){ + Py_DECREF(fmt); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() failed"); + return 0; + } + + Py_INCREF(value); + PyTuple_SET_ITEM(args, 0, value); + hex = PyUnicode_Format(fmt, args); + + if (!hex){ + PyErr_SetString(PyExc_RuntimeError, "PyString_Format() failed"); + Py_DECREF(fmt); + Py_DECREF(args); + return 0; + } + + Py_DECREF(fmt); + Py_DECREF(args); + + if (BN_hex2bn(&bn, PyUnicode_AsUTF8(hex)) <= 0){ + m2_PyErr_Msg(PyExc_RuntimeError); + Py_DECREF(hex); + return 0; + } + + Py_DECREF(hex); + + if (!BN_to_ASN1_INTEGER(bn, asn1)){ + m2_PyErr_Msg(PyExc_RuntimeError); + BN_free(bn); + return 0; + } + + BN_free(bn); + + return 1; +} + + + +#include +#include +#include +#include + + +static PyObject *_pkcs7_err, *_smime_err; + +void pkcs7_init(PyObject *pkcs7_err) { + Py_INCREF(pkcs7_err); + _pkcs7_err = pkcs7_err; +} + +void smime_init(PyObject *smime_err) { + Py_INCREF(smime_err); + _smime_err = smime_err; +} + + +PyObject *pkcs7_decrypt(PKCS7 *pkcs7, EVP_PKEY *pkey, X509 *cert, int flags) { + int outlen; + char *outbuf; + BIO *bio; + PyObject *ret; + + if (!(bio=BIO_new(BIO_s_mem()))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); + return NULL; + } + if (!PKCS7_decrypt(pkcs7, pkey, cert, bio, flags)) { + m2_PyErr_Msg(_pkcs7_err); + BIO_free(bio); + return NULL; + } + outlen = BIO_ctrl_pending(bio); + if (!(outbuf=(char *)PyMem_Malloc(outlen))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); + BIO_free(bio); + return NULL; + } + BIO_read(bio, outbuf, outlen); + + ret = PyBytes_FromStringAndSize(outbuf, outlen); + + BIO_free(bio); + PyMem_Free(outbuf); + return ret; +} + + +PKCS7 *pkcs7_encrypt(STACK_OF(X509) *stack, BIO *bio, EVP_CIPHER *cipher, int flags) { + return PKCS7_encrypt(stack, bio, cipher, flags); +} + + + +PKCS7 *pkcs7_sign1(X509 *x509, EVP_PKEY *pkey, STACK_OF(X509) *stack, BIO *bio, EVP_MD *hash, int flags) { + + PKCS7 *p7 = PKCS7_sign(NULL, NULL, stack, bio, flags | PKCS7_STREAM); + if (p7 == NULL) { + return NULL; + } + if (PKCS7_sign_add_signer(p7, x509, pkey, hash, flags) == NULL) { + return NULL; + } + if (PKCS7_final(p7, bio, flags) != 1) { + return NULL; + } + return p7; +} + + +PKCS7 *pkcs7_sign0(X509 *x509, EVP_PKEY *pkey, BIO *bio, EVP_MD *hash, int flags) { + return pkcs7_sign1(x509, pkey, NULL, bio, hash, flags); +} + + +PKCS7 *pkcs7_read_bio(BIO *bio) { + return PEM_read_bio_PKCS7(bio, NULL, NULL, NULL); +} + + +PKCS7 *pkcs7_read_bio_der(BIO *bio) { + return d2i_PKCS7_bio(bio, NULL); +} + + +PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, BIO *data, int flags) { + int res, outlen; + char *outbuf; + BIO *bio; + PyObject *ret; + + if (!(bio=BIO_new(BIO_s_mem()))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + res = PKCS7_verify(pkcs7, stack, store, data, bio, flags); + Py_END_ALLOW_THREADS + if (!res) { + m2_PyErr_Msg(_pkcs7_err); + BIO_free(bio); + return NULL; + } + outlen = BIO_ctrl_pending(bio); + if (!(outbuf=(char *)PyMem_Malloc(outlen))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); + BIO_free(bio); + return NULL; + } + BIO_read(bio, outbuf, outlen); + + ret = PyBytes_FromStringAndSize(outbuf, outlen); + + BIO_free(bio); + PyMem_Free(outbuf); + return ret; +} + +PyObject *pkcs7_verify0(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, int flags) { + return pkcs7_verify1(pkcs7, stack, store, NULL, flags); +} + + +int smime_write_pkcs7_multi(BIO *bio, PKCS7 *pkcs7, BIO *data, int flags) { + return SMIME_write_PKCS7(bio, pkcs7, data, flags | PKCS7_DETACHED); +} + + +int smime_write_pkcs7(BIO *bio, PKCS7 *pkcs7, int flags) { + return SMIME_write_PKCS7(bio, pkcs7, NULL, flags); +} + +PyObject *smime_read_pkcs7(BIO *bio) { + BIO *bcont = NULL; + PKCS7 *p7; + PyObject *tuple, *_p7, *_BIO; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (BIO_method_type(bio) == BIO_TYPE_MEM) { + /* OpenSSL FAQ explains that this is needed for mem BIO to return EOF, + * like file BIO does. Might need to do this for more mem BIOs but + * not sure if that is safe, so starting with just this single place. + */ + BIO_set_mem_eof_return(bio, 0); + } + + Py_BEGIN_ALLOW_THREADS + p7=SMIME_read_PKCS7(bio, &bcont); + Py_END_ALLOW_THREADS + if (!p7) { + m2_PyErr_Msg(_smime_err); + return NULL; + } + if (!(tuple=PyTuple_New(2))) { + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + _p7 = SWIG_NewPointerObj((void *)p7, SWIGTYPE_p_PKCS7, 0); + PyTuple_SET_ITEM(tuple, 0, _p7); + if (!bcont) { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 1, Py_None); + } else { + _BIO = SWIG_NewPointerObj((void *)bcont, SWIGTYPE_p_BIO, 0); + PyTuple_SET_ITEM(tuple, 1, _BIO); + } + return tuple; +} + + +int pkcs7_write_bio(PKCS7 *pkcs7, BIO* bio) { + return PEM_write_bio_PKCS7(bio, pkcs7); +} + + +int pkcs7_write_bio_der(PKCS7 *pkcs7, BIO *bio) { + return i2d_PKCS7_bio(bio, pkcs7); +} + +int pkcs7_type_nid(PKCS7 *pkcs7) { + return OBJ_obj2nid(pkcs7->type); +} + +const char *pkcs7_type_sn(PKCS7 *pkcs7) { + return OBJ_nid2sn(OBJ_obj2nid(pkcs7->type)); +} + + +int smime_crlf_copy(BIO *in, BIO *out) { + return SMIME_crlf_copy(in, out, PKCS7_TEXT); +} + +/* return STACK_OF(X509)* */ +STACK_OF(X509) *pkcs7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) { + return PKCS7_get0_signers(p7, certs, flags); +} + + + +#include + + +static PyObject *_util_err; + +void util_init(PyObject *util_err) { + Py_INCREF(util_err); + _util_err = util_err; +} + +PyObject *util_hex_to_string(PyObject *blob) { + PyObject *obj; + const void *buf; + char *ret; + Py_ssize_t len; + + if (PyObject_AsReadBuffer(blob, &buf, &len) == -1) + return NULL; + + ret = hex_to_string((unsigned char *)buf, len); + if (!ret) { + m2_PyErr_Msg(_util_err); + return NULL; + } + + obj = PyBytes_FromString(ret); + + OPENSSL_free(ret); + return obj; +} + +PyObject *util_string_to_hex(PyObject *blob) { + PyObject *obj; + const void *buf; + unsigned char *ret; + Py_ssize_t len0; + long len; + + if (PyObject_AsReadBuffer(blob, &buf, &len0) == -1) + return NULL; + + len = len0; + ret = string_to_hex((char *)buf, &len); + if (ret == NULL) { + m2_PyErr_Msg(_util_err); + return NULL; + } + obj = PyBytes_FromStringAndSize((char*)ret, len); + OPENSSL_free(ret); + return obj; +} + + +#include +#include +#include +#include +#include +#include + + +static PyObject *_ec_err; + +void ec_init(PyObject *ec_err) { + Py_INCREF(ec_err); + _ec_err = ec_err; +} + +PyObject *ec_get_builtin_curves(void) { + /* size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t + * nitems); */ + EC_builtin_curve *curves; + Py_ssize_t ret_curves = 0; + size_t num_curves = EC_get_builtin_curves(NULL, 0); + PyObject *ret_tuple = NULL; + PyObject *ret_dict = NULL; + Py_ssize_t i; + const char *comment; + const char *sname; + + if (!(curves = PyMem_Malloc(num_curves * sizeof(EC_builtin_curve)))) { + PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); + return NULL; + } + + ret_curves = (Py_ssize_t)EC_get_builtin_curves(curves, num_curves); + + if (!(ret_tuple = PyTuple_New(ret_curves))) { + PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); + return NULL; + } + + for (i = 0; i < ret_curves; i++) { + if (!(ret_dict = PyDict_New())) { + PyErr_SetString(PyExc_MemoryError, "ec_get_builtin_curves"); + return NULL; + } + + comment = curves[i].comment; + sname = OBJ_nid2sn(curves[i].nid); + if (sname == NULL) + sname = ""; + + PyDict_SetItemString(ret_dict, "NID", + PyLong_FromLong((long)curves[i].nid)); + PyDict_SetItemString(ret_dict, "sname", + PyString_FromString(sname)); + PyDict_SetItemString(ret_dict, "comment", + PyString_FromString(comment)); + + PyTuple_SET_ITEM(ret_tuple, i, ret_dict); + + } + + PyMem_Free(curves); + + return ret_tuple; +} + +EC_KEY* ec_key_new_by_curve_name(int nid) +{ + EC_KEY *key; + EC_GROUP *group; + int ret =0; + point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; + int asn1_flag = OPENSSL_EC_NAMED_CURVE; + + /* If I simply do "return EC_KEY_new_by_curve_name(nid);" + * I get large public keys (222 vs 84 bytes for sect233k1 curve). + * I don't know why that is, but 'openssl ecparam -genkey ...' sets + * the ASN.1 flag and the point conversion form, and gets the + * small pub keys. So let's do that too. + */ + key = EC_KEY_new(); + if (!key) { + PyErr_SetString(PyExc_MemoryError, "ec_key_new_by_curve_name"); + return NULL; + } + group = EC_GROUP_new_by_curve_name(nid); + if (!group) { + m2_PyErr_Msg(_ec_err); + EC_KEY_free(key); + return NULL; + } + EC_GROUP_set_asn1_flag(group, asn1_flag); + EC_GROUP_set_point_conversion_form(group, form); + ret = EC_KEY_set_group(key, group); + EC_GROUP_free(group); + if (ret == 0) + { + /* EC_KEY_set_group only returns 0 or 1, and does not set error. */ + PyErr_SetString(_ec_err, "cannot set key's group"); + EC_KEY_free(key); + return NULL; + } + + return key; +} + +PyObject *ec_key_get_public_der(EC_KEY *key) { + char *src=NULL; + int src_len=0; + PyObject *pyo=NULL; + + /* Convert to binary */ + src_len = i2d_EC_PUBKEY( key, (unsigned char**)&src ); + if (src_len < 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + /* Create a PyBuffer containing a copy of the binary, + * to simplify memory deallocation + */ + pyo = PyBytes_FromStringAndSize( src, src_len ); + + OPENSSL_free(src); + + return pyo; +} + +PyObject *ec_key_get_public_key(EC_KEY *key) { + char *src=NULL; + int src_len=0; + PyObject *pyo=NULL; + + /* Convert to binary */ + src_len = i2o_ECPublicKey(key, (unsigned char**)&src); + if (src_len < 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + + pyo = PyBytes_FromStringAndSize( src, src_len ); + + OPENSSL_free(src); + + return pyo; +} + + + +EC_KEY *ec_key_read_pubkey(BIO *f) { + return PEM_read_bio_EC_PUBKEY(f, NULL, NULL, NULL); +} + + +int ec_key_write_pubkey(EC_KEY *key, BIO *f) { + return PEM_write_bio_EC_PUBKEY(f, key ); +} + + +EC_KEY *ec_key_read_bio(BIO *f, PyObject *pyfunc) { + EC_KEY *ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_read_bio_ECPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +int ec_key_write_bio(EC_KEY *key, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_ECPrivateKey(f, key, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +int ec_key_write_bio_no_cipher(EC_KEY *key, BIO *f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_ECPrivateKey(f, key, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} + + +PyObject *ecdsa_sig_get_r(ECDSA_SIG *ecdsa_sig) { + const BIGNUM* pr; + ECDSA_SIG_get0(ecdsa_sig, &pr, NULL); + return bn_to_mpi(pr); +} + +PyObject *ecdsa_sig_get_s(ECDSA_SIG *ecdsa_sig) { + const BIGNUM* ps; + ECDSA_SIG_get0(ecdsa_sig, NULL, &ps); + return bn_to_mpi(ps); +} + +PyObject *ecdsa_sign(EC_KEY *key, PyObject *value) { + const void *vbuf; + int vlen = 0; + PyObject *tuple; + ECDSA_SIG *sig; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sig = ECDSA_do_sign(vbuf, vlen, key))) { + m2_PyErr_Msg(_ec_err); + return NULL; + } + if (!(tuple = PyTuple_New(2))) { + ECDSA_SIG_free(sig); + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + PyTuple_SET_ITEM(tuple, 0, ecdsa_sig_get_r(sig)); + PyTuple_SET_ITEM(tuple, 1, ecdsa_sig_get_s(sig)); + ECDSA_SIG_free(sig); + return tuple; +} + +int ecdsa_verify(EC_KEY *key, PyObject *value, PyObject *r, PyObject *s) { + const void *vbuf, *rbuf, *sbuf; + int vlen = 0, rlen = 0, slen = 0; + ECDSA_SIG *sig; + int ret; + BIGNUM* pr, *ps; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(r, &rbuf, &rlen) == -1) + || (m2_PyObject_AsReadBufferInt(s, &sbuf, &slen) == -1)) + return -1; + + if (!(pr = BN_mpi2bn((unsigned char *)rbuf, rlen, NULL))) { + m2_PyErr_Msg(_ec_err); + return -1; + } + if (!(ps = BN_mpi2bn((unsigned char *)sbuf, slen, NULL))) { + m2_PyErr_Msg(_ec_err); + BN_free(pr); + return -1; + } + + if (!(sig = ECDSA_SIG_new())) { + m2_PyErr_Msg(_ec_err); + BN_free(pr); + BN_free(ps); + return -1; + } + if (!ECDSA_SIG_set0(sig, pr, ps)) { + PyErr_SetString(_ec_err, "Cannot set r and s fields of ECDSA_SIG."); + ECDSA_SIG_free(sig); + BN_free(pr); + BN_free(ps); + return -1; + } + ret = ECDSA_do_verify(vbuf, vlen, sig, key); + ECDSA_SIG_free(sig); + if (ret == -1) + m2_PyErr_Msg(_ec_err); + return ret; +} + + +PyObject *ecdsa_sign_asn1(EC_KEY *key, PyObject *value) { + const void *vbuf; + int vlen = 0; + void *sigbuf; + unsigned int siglen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(sigbuf = PyMem_Malloc(ECDSA_size(key)))) { + PyErr_SetString(PyExc_MemoryError, "ecdsa_sign_asn1"); + return NULL; + } + if (!ECDSA_sign(0, vbuf, vlen, (unsigned char *)sigbuf, &siglen, key)) { + m2_PyErr_Msg(_ec_err); + PyMem_Free(sigbuf); + return NULL; + } + ret = PyBytes_FromStringAndSize(sigbuf, siglen); + + PyMem_Free(sigbuf); + return ret; +} + + +int ecdsa_verify_asn1(EC_KEY *key, PyObject *value, PyObject *sig) { + const void *vbuf; + void *sbuf; + int vlen = 0, slen = 0, ret; + + if ((m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + || (m2_PyObject_AsReadBufferInt(sig, (const void **)&sbuf, &slen) + == -1)) + return -1; + + if ((ret = ECDSA_verify(0, vbuf, vlen, sbuf, slen, key)) == -1) + m2_PyErr_Msg(_ec_err); + return ret; +} + +PyObject *ecdh_compute_key(EC_KEY *keypairA, EC_KEY *pubkeyB) { + int sharedkeylen; + void *sharedkey; + const EC_POINT *pkpointB; + PyObject *ret; + const EC_GROUP* groupA; + + if ((pkpointB = EC_KEY_get0_public_key(pubkeyB)) == NULL) + { + PyErr_SetString(_ec_err, "Cannot get the public key of EC_KEY object."); + return NULL; + } + + groupA = EC_KEY_get0_group(keypairA); + sharedkeylen = (EC_GROUP_get_degree(groupA) + 7)/8; + + if (!(sharedkey = PyMem_Malloc(sharedkeylen))) { + PyErr_SetString(PyExc_MemoryError, "ecdh_compute_key"); + return NULL; + } + if ((sharedkeylen = ECDH_compute_key((unsigned char *)sharedkey, sharedkeylen, pkpointB, keypairA, NULL)) == -1) { + m2_PyErr_Msg(_ec_err); + PyMem_Free(sharedkey); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)sharedkey, sharedkeylen); + + PyMem_Free(sharedkey); + + return ret; +} + + +EC_KEY* ec_key_from_pubkey_der(PyObject *pubkey) { + const void *keypairbuf; + Py_ssize_t keypairbuflen; + const unsigned char *tempBuf; + EC_KEY *keypair; + + if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) + { + return NULL; + } + + tempBuf = (const unsigned char *)keypairbuf; + if ((keypair = d2i_EC_PUBKEY( NULL, &tempBuf, keypairbuflen)) == 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + return keypair; +} + +EC_KEY* ec_key_from_pubkey_params(int nid, PyObject *pubkey) { + const void *keypairbuf; + Py_ssize_t keypairbuflen; + const unsigned char *tempBuf; + EC_KEY *keypair; + + if (PyObject_AsReadBuffer(pubkey, &keypairbuf, &keypairbuflen) == -1) + { + return NULL; + } + + keypair = ec_key_new_by_curve_name(nid); + if (!keypair) { + m2_PyErr_Msg(_ec_err); + return NULL; + } + + tempBuf = (const unsigned char *)keypairbuf; + if ((o2i_ECPublicKey( &keypair, &tempBuf, keypairbuflen)) == 0) + { + m2_PyErr_Msg(_ec_err); + return NULL; + } + return keypair; +} + + +// According to [SEC2] the degree of the group is defined as EC key length +int ec_key_keylen(EC_KEY *key) { + const EC_GROUP *group = EC_KEY_get0_group(key); + return EC_GROUP_get_degree(group); +} + +int ec_key_type_check(EC_KEY *key) { + return 1; +} + + +#include +#include +#include + + + +/* + * Code from engine-pkcs11 1.4.0 in engine-pkcs11.c + * + +99 static char *get_pin(UI_METHOD * ui_method, void *callback_data, char *sc_pin, +100 int maxlen) +101 { +102 UI *ui; +103 struct { +104 const void *password; +105 const char *prompt_info; +106 } *mycb = callback_data; +107 +108 if (mycb->password) { +109 sc_pin = set_pin(mycb->password); +110 return sc_pin; +111 } + + * + * So callback_data need to be always provided and have fixed type. + * UI method still may be NULL. + * + * Following functions allocate and free callback data structure with + * optional password set. + */ + +typedef struct { + char * password; + char * prompt; +} _cbd_t; + +void * engine_pkcs11_data_new(const char *pin) { + _cbd_t * cb = (_cbd_t *) PyMem_Malloc(sizeof(_cbd_t)); + if (!cb) { + PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); + return NULL; + } + cb->password = NULL; + if (pin) { + size_t size = strlen(pin); + cb->password = (char *) PyMem_Malloc(size + 1); + if (!cb->password) { + PyErr_SetString(PyExc_MemoryError, "engine_pkcs11_data_new"); + PyMem_Free(cb); + return NULL; + } + memcpy(cb->password, pin, size + 1); + } + cb->prompt = NULL; + return cb; +} + +void engine_pkcs11_data_free(void * vcb) { + _cbd_t * cb = (_cbd_t *) vcb; + if (!cb) + return; + if (cb->password) + PyMem_Free(cb->password); + PyMem_Free(cb); +} + + + +static PyObject *_engine_err; + +void engine_init_error(PyObject *engine_err) { + Py_INCREF(engine_err); + _engine_err = engine_err; +} + +X509 * engine_load_certificate(ENGINE *e, const char * slot) { + struct { + const char * slot; + X509 * cert; + } cbd; + cbd.slot = slot; + cbd.cert = NULL; + if (!ENGINE_ctrl_cmd(e, "LOAD_CERT_CTRL", 0, &cbd, NULL, 0)) { + PyErr_SetString(_engine_err, "cannot load certificate"); + return NULL; + } + return cbd.cert; +} + + +#include + + +/* + From the manpage for OBJ_obt2txt (): + BUGS + OBJ_obj2txt() is awkward and messy to use: it doesn’t follow the + convention of other OpenSSL functions where the buffer can be set + to NULL to determine the amount of data that should be written. + Instead buf must point to a valid buffer and buf_len should be set + to a positive value. A buffer length of 80 should be more than + enough to handle any OID encountered in practice. + + The first call to OBJ_obj2txt () therefore passes a non-NULL dummy + buffer. This wart is reportedly removed in OpenSSL 0.9.8b, although + the manpage has not been updated. + + OBJ_obj2txt always prints \0 at the end. But the return value + is the number of "good" bytes written. So memory is allocated for + len + 1 bytes but only len bytes are marshalled to python. +*/ +PyObject *obj_obj2txt(const ASN1_OBJECT *obj, int no_name) +{ + int len; + PyObject *ret; + char *buf; + char dummy[1]; + + len = OBJ_obj2txt(dummy, 1, obj, no_name); + if (len < 0) { + m2_PyErr_Msg(PyExc_RuntimeError); + return NULL; + } else if (len == 0) { + /* XXX: For OpenSSL prior to 0.9.8b. + + Changes between 0.9.8a and 0.9.8b [04 May 2006] + ... + *) Several fixes and enhancements to the OID generation code. The old code + sometimes allowed invalid OIDs (1.X for X >= 40 for example), couldn't + handle numbers larger than ULONG_MAX, truncated printing and had a + non standard OBJ_obj2txt() behaviour. + [Steve Henson] + */ + + len = 80; + } + + buf = PyMem_Malloc(len + 1); + len = OBJ_obj2txt(buf, len + 1, obj, no_name); + + ret = PyBytes_FromStringAndSize(buf, len); + + PyMem_Free(buf); + + return ret; +} + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_OPENSSL_sk_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_num" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + result = (int)OPENSSL_sk_num((struct stack_st const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_value" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (void *)OPENSSL_sk_value((struct stack_st const *)arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + int arg2 ; + void *arg3 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + PyObject *swig_obj[3] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_set", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_set" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "OPENSSL_sk_set" "', argument " "3"" of type '" "void const *""'"); + } + result = (void *)OPENSSL_sk_set(arg1,arg2,(void const *)arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_sk_compfunc arg1 = (OPENSSL_sk_compfunc) 0 ; + PyObject *swig_obj[1] ; + OPENSSL_STACK *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_new" "', argument " "1"" of type '" "OPENSSL_sk_compfunc""'"); + } + } + result = (OPENSSL_STACK *)OPENSSL_sk_new(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_new_null(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_new_null", 0, 0, 0)) SWIG_fail; + result = (OPENSSL_STACK *)OPENSSL_sk_new_null(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_new_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_sk_compfunc arg1 = (OPENSSL_sk_compfunc) 0 ; + int arg2 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + OPENSSL_STACK *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_new_reserve", 2, 2, swig_obj)) SWIG_fail; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_new_reserve" "', argument " "1"" of type '" "OPENSSL_sk_compfunc""'"); + } + } + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_new_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (OPENSSL_STACK *)OPENSSL_sk_new_reserve(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_reserve", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_reserve" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)OPENSSL_sk_reserve(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_free" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + OPENSSL_sk_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_pop_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void (*arg2)(void *) = (void (*)(void *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_pop_free", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_pop_free" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_pop_free" "', argument " "2"" of type '" "void (*)(void *)""'"); + } + } + OPENSSL_sk_pop_free(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_deep_copy(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + OPENSSL_sk_copyfunc arg2 = (OPENSSL_sk_copyfunc) 0 ; + OPENSSL_sk_freefunc arg3 = (OPENSSL_sk_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + OPENSSL_STACK *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_deep_copy", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_deep_copy" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__void__p_void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_deep_copy" "', argument " "2"" of type '" "OPENSSL_sk_copyfunc""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_deep_copy" "', argument " "3"" of type '" "OPENSSL_sk_freefunc""'"); + } + } + result = (OPENSSL_STACK *)OPENSSL_sk_deep_copy((struct stack_st const *)arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_insert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_insert", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_insert" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_insert" "', argument " "2"" of type '" "void const *""'"); + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "OPENSSL_sk_insert" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)OPENSSL_sk_insert(arg1,(void const *)arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_delete(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_delete", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_delete" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "OPENSSL_sk_delete" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (void *)OPENSSL_sk_delete(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_delete_ptr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_delete_ptr", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_delete_ptr" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_delete_ptr" "', argument " "2"" of type '" "void const *""'"); + } + result = (void *)OPENSSL_sk_delete_ptr(arg1,(void const *)arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_find(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_find", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_find" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_find" "', argument " "2"" of type '" "void const *""'"); + } + result = (int)OPENSSL_sk_find(arg1,(void const *)arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_find_ex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_find_ex", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_find_ex" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_find_ex" "', argument " "2"" of type '" "void const *""'"); + } + result = (int)OPENSSL_sk_find_ex(arg1,(void const *)arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_push" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_push" "', argument " "2"" of type '" "void const *""'"); + } + result = (int)OPENSSL_sk_push(arg1,(void const *)arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_unshift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_unshift", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_unshift" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OPENSSL_sk_unshift" "', argument " "2"" of type '" "void const *""'"); + } + result = (int)OPENSSL_sk_unshift(arg1,(void const *)arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_shift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + void *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_shift" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + result = (void *)OPENSSL_sk_shift(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + void *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_pop" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + result = (void *)OPENSSL_sk_pop(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_zero(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_zero" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + OPENSSL_sk_zero(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_set_cmp_func(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + OPENSSL_sk_compfunc arg2 = (OPENSSL_sk_compfunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + OPENSSL_sk_compfunc result; + + if (!SWIG_Python_UnpackTuple(args, "OPENSSL_sk_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_set_cmp_func" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "OPENSSL_sk_set_cmp_func" "', argument " "2"" of type '" "OPENSSL_sk_compfunc""'"); + } + } + result = (OPENSSL_sk_compfunc)OPENSSL_sk_set_cmp_func(arg1,arg2); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__void_p_q_const__void__int); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_dup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + OPENSSL_STACK *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_dup" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + result = (OPENSSL_STACK *)OPENSSL_sk_dup((struct stack_st const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_sort(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_sort" "', argument " "1"" of type '" "OPENSSL_STACK *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + OPENSSL_sk_sort(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_OPENSSL_sk_is_sorted(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + OPENSSL_STACK *arg1 = (OPENSSL_STACK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OPENSSL_sk_is_sorted" "', argument " "1"" of type '" "OPENSSL_STACK const *""'"); + } + arg1 = (OPENSSL_STACK *)(argp1); + result = (int)OPENSSL_sk_is_sorted((struct stack_st const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_num" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + result = (int)sk_OPENSSL_STRING_num((struct stack_st_OPENSSL_STRING const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_value" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (char *)sk_OPENSSL_STRING_value((struct stack_st_OPENSSL_STRING const *)arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + sk_OPENSSL_STRING_compfunc arg1 = (sk_OPENSSL_STRING_compfunc) 0 ; + PyObject *swig_obj[1] ; + struct stack_st_OPENSSL_STRING *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_new" "', argument " "1"" of type '" "sk_OPENSSL_STRING_compfunc""'"); + } + } + result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_new(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_new_null(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_new_null", 0, 0, 0)) SWIG_fail; + result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_new_null(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_new_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + sk_OPENSSL_STRING_compfunc arg1 = (sk_OPENSSL_STRING_compfunc) 0 ; + int arg2 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + struct stack_st_OPENSSL_STRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_new_reserve", 2, 2, swig_obj)) SWIG_fail; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_new_reserve" "', argument " "1"" of type '" "sk_OPENSSL_STRING_compfunc""'"); + } + } + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_new_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_new_reserve(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_reserve", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_reserve" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)sk_OPENSSL_STRING_reserve(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + sk_OPENSSL_STRING_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_zero(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_zero" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + sk_OPENSSL_STRING_zero(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_delete(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_delete", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_delete" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_delete" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (char *)sk_OPENSSL_STRING_delete(arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_delete_ptr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_delete_ptr", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_delete_ptr" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_delete_ptr" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + result = (char *)sk_OPENSSL_STRING_delete_ptr(arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_push" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_push" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_STRING_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_unshift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_unshift", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_unshift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_unshift" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_STRING_unshift(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_pop" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + result = (char *)sk_OPENSSL_STRING_pop(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_shift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_shift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + result = (char *)sk_OPENSSL_STRING_shift(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_pop_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + sk_OPENSSL_STRING_freefunc arg2 = (sk_OPENSSL_STRING_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_pop_free", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_pop_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_char__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_pop_free" "', argument " "2"" of type '" "sk_OPENSSL_STRING_freefunc""'"); + } + } + sk_OPENSSL_STRING_pop_free(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_insert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_insert", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_insert" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_insert" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sk_OPENSSL_STRING_insert" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)sk_OPENSSL_STRING_insert(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject *swig_obj[3] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_set", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_set" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_STRING_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "sk_OPENSSL_STRING_set" "', argument " "3"" of type '" "char *""'"); + } + arg3 = (char *)(buf3); + result = (char *)sk_OPENSSL_STRING_set(arg1,arg2,arg3); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_find(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_find", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_find" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_find" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_STRING_find(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_find_ex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_find_ex", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_find_ex" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_STRING_find_ex" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_STRING_find_ex(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_sort(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_sort" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + sk_OPENSSL_STRING_sort(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_is_sorted(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_is_sorted" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + result = (int)sk_OPENSSL_STRING_is_sorted((struct stack_st_OPENSSL_STRING const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_dup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct stack_st_OPENSSL_STRING *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_dup" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_dup((struct stack_st_OPENSSL_STRING const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_deep_copy(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + sk_OPENSSL_STRING_copyfunc arg2 = (sk_OPENSSL_STRING_copyfunc) 0 ; + sk_OPENSSL_STRING_freefunc arg3 = (sk_OPENSSL_STRING_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + struct stack_st_OPENSSL_STRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_deep_copy", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_deep_copy" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__char__p_char); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_deep_copy" "', argument " "2"" of type '" "sk_OPENSSL_STRING_copyfunc""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_char__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_deep_copy" "', argument " "3"" of type '" "sk_OPENSSL_STRING_freefunc""'"); + } + } + result = (struct stack_st_OPENSSL_STRING *)sk_OPENSSL_STRING_deep_copy((struct stack_st_OPENSSL_STRING const *)arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_STRING_set_cmp_func(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_STRING *arg1 = (struct stack_st_OPENSSL_STRING *) 0 ; + sk_OPENSSL_STRING_compfunc arg2 = (sk_OPENSSL_STRING_compfunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + sk_OPENSSL_STRING_compfunc result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_STRING_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_STRING_set_cmp_func" "', argument " "1"" of type '" "struct stack_st_OPENSSL_STRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_STRING *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_STRING_set_cmp_func" "', argument " "2"" of type '" "sk_OPENSSL_STRING_compfunc""'"); + } + } + result = (sk_OPENSSL_STRING_compfunc)sk_OPENSSL_STRING_set_cmp_func(arg1,arg2); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_num" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + result = (int)sk_OPENSSL_CSTRING_num((struct stack_st_OPENSSL_CSTRING const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_value" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (char *)sk_OPENSSL_CSTRING_value((struct stack_st_OPENSSL_CSTRING const *)arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + sk_OPENSSL_CSTRING_compfunc arg1 = (sk_OPENSSL_CSTRING_compfunc) 0 ; + PyObject *swig_obj[1] ; + struct stack_st_OPENSSL_CSTRING *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_new" "', argument " "1"" of type '" "sk_OPENSSL_CSTRING_compfunc""'"); + } + } + result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_new(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_new_null(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_new_null", 0, 0, 0)) SWIG_fail; + result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_new_null(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_new_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + sk_OPENSSL_CSTRING_compfunc arg1 = (sk_OPENSSL_CSTRING_compfunc) 0 ; + int arg2 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + struct stack_st_OPENSSL_CSTRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_new_reserve", 2, 2, swig_obj)) SWIG_fail; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_new_reserve" "', argument " "1"" of type '" "sk_OPENSSL_CSTRING_compfunc""'"); + } + } + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_new_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_new_reserve(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_reserve", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_reserve" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)sk_OPENSSL_CSTRING_reserve(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + sk_OPENSSL_CSTRING_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_zero(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_zero" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + sk_OPENSSL_CSTRING_zero(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_delete(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_delete", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_delete" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_delete" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (char *)sk_OPENSSL_CSTRING_delete(arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_delete_ptr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_delete_ptr", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_delete_ptr" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_delete_ptr" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (char *)sk_OPENSSL_CSTRING_delete_ptr(arg1,(char const *)arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_push" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_push" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_CSTRING_push(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_unshift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_unshift", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_unshift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_unshift" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_CSTRING_unshift(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_pop" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + result = (char *)sk_OPENSSL_CSTRING_pop(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_shift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_shift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + result = (char *)sk_OPENSSL_CSTRING_shift(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_pop_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + sk_OPENSSL_CSTRING_freefunc arg2 = (sk_OPENSSL_CSTRING_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_pop_free", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_pop_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_char__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_pop_free" "', argument " "2"" of type '" "sk_OPENSSL_CSTRING_freefunc""'"); + } + } + sk_OPENSSL_CSTRING_pop_free(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_insert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_insert", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_insert" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_insert" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sk_OPENSSL_CSTRING_insert" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)sk_OPENSSL_CSTRING_insert(arg1,(char const *)arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject *swig_obj[3] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_set", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_set" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_CSTRING_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "sk_OPENSSL_CSTRING_set" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + result = (char *)sk_OPENSSL_CSTRING_set(arg1,arg2,(char const *)arg3); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_find(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_find", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_find" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_find" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_CSTRING_find(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_find_ex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_find_ex", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_find_ex" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_CSTRING_find_ex" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)sk_OPENSSL_CSTRING_find_ex(arg1,(char const *)arg2); + resultobj = SWIG_From_int((int)(result)); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_sort(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_sort" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + sk_OPENSSL_CSTRING_sort(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_is_sorted(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_is_sorted" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + result = (int)sk_OPENSSL_CSTRING_is_sorted((struct stack_st_OPENSSL_CSTRING const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_dup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct stack_st_OPENSSL_CSTRING *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_dup" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_dup((struct stack_st_OPENSSL_CSTRING const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_deep_copy(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + sk_OPENSSL_CSTRING_copyfunc arg2 = (sk_OPENSSL_CSTRING_copyfunc) 0 ; + sk_OPENSSL_CSTRING_freefunc arg3 = (sk_OPENSSL_CSTRING_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + struct stack_st_OPENSSL_CSTRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_deep_copy", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_deep_copy" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING const *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__char__p_char); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_deep_copy" "', argument " "2"" of type '" "sk_OPENSSL_CSTRING_copyfunc""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_char__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_deep_copy" "', argument " "3"" of type '" "sk_OPENSSL_CSTRING_freefunc""'"); + } + } + result = (struct stack_st_OPENSSL_CSTRING *)sk_OPENSSL_CSTRING_deep_copy((struct stack_st_OPENSSL_CSTRING const *)arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_CSTRING_set_cmp_func(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_CSTRING *arg1 = (struct stack_st_OPENSSL_CSTRING *) 0 ; + sk_OPENSSL_CSTRING_compfunc arg2 = (sk_OPENSSL_CSTRING_compfunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + sk_OPENSSL_CSTRING_compfunc result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_CSTRING_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_CSTRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_CSTRING_set_cmp_func" "', argument " "1"" of type '" "struct stack_st_OPENSSL_CSTRING *""'"); + } + arg1 = (struct stack_st_OPENSSL_CSTRING *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_CSTRING_set_cmp_func" "', argument " "2"" of type '" "sk_OPENSSL_CSTRING_compfunc""'"); + } + } + result = (sk_OPENSSL_CSTRING_compfunc)sk_OPENSSL_CSTRING_set_cmp_func(arg1,arg2); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_num" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + result = (int)sk_OPENSSL_BLOCK_num((struct stack_st_OPENSSL_BLOCK const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_value" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (void *)sk_OPENSSL_BLOCK_value((struct stack_st_OPENSSL_BLOCK const *)arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + sk_OPENSSL_BLOCK_compfunc arg1 = (sk_OPENSSL_BLOCK_compfunc) 0 ; + PyObject *swig_obj[1] ; + struct stack_st_OPENSSL_BLOCK *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_new" "', argument " "1"" of type '" "sk_OPENSSL_BLOCK_compfunc""'"); + } + } + result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_new(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_new_null(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_new_null", 0, 0, 0)) SWIG_fail; + result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_new_null(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_new_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + sk_OPENSSL_BLOCK_compfunc arg1 = (sk_OPENSSL_BLOCK_compfunc) 0 ; + int arg2 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + struct stack_st_OPENSSL_BLOCK *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_new_reserve", 2, 2, swig_obj)) SWIG_fail; + { + int res = SWIG_ConvertFunctionPtr(swig_obj[0], (void**)(&arg1), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_new_reserve" "', argument " "1"" of type '" "sk_OPENSSL_BLOCK_compfunc""'"); + } + } + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_new_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_new_reserve(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_reserve(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_reserve", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_reserve" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_reserve" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)sk_OPENSSL_BLOCK_reserve(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + sk_OPENSSL_BLOCK_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_zero(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_zero" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + sk_OPENSSL_BLOCK_zero(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_delete(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_delete", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_delete" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_delete" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (void *)sk_OPENSSL_BLOCK_delete(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_delete_ptr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_delete_ptr", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_delete_ptr" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_delete_ptr" "', argument " "2"" of type '" "void *""'"); + } + result = (void *)sk_OPENSSL_BLOCK_delete_ptr(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_push" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_push" "', argument " "2"" of type '" "void *""'"); + } + result = (int)sk_OPENSSL_BLOCK_push(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_unshift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_unshift", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_unshift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_unshift" "', argument " "2"" of type '" "void *""'"); + } + result = (int)sk_OPENSSL_BLOCK_unshift(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + void *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_pop" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + result = (void *)sk_OPENSSL_BLOCK_pop(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_shift(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + void *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_shift" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + result = (void *)sk_OPENSSL_BLOCK_shift(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_pop_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + sk_OPENSSL_BLOCK_freefunc arg2 = (sk_OPENSSL_BLOCK_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_pop_free", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_pop_free" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_pop_free" "', argument " "2"" of type '" "sk_OPENSSL_BLOCK_freefunc""'"); + } + } + sk_OPENSSL_BLOCK_pop_free(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_insert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_insert", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_insert" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_insert" "', argument " "2"" of type '" "void *""'"); + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "sk_OPENSSL_BLOCK_insert" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (int)sk_OPENSSL_BLOCK_insert(arg1,arg2,arg3); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + int arg2 ; + void *arg3 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + PyObject *swig_obj[3] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_set", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_set" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_OPENSSL_BLOCK_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_ConvertPtr(swig_obj[2],SWIG_as_voidptrptr(&arg3), 0, 0); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "sk_OPENSSL_BLOCK_set" "', argument " "3"" of type '" "void *""'"); + } + result = (void *)sk_OPENSSL_BLOCK_set(arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_find(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_find", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_find" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_find" "', argument " "2"" of type '" "void *""'"); + } + result = (int)sk_OPENSSL_BLOCK_find(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_find_ex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *arg2 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_find_ex", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_find_ex" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1],SWIG_as_voidptrptr(&arg2), 0, 0); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_OPENSSL_BLOCK_find_ex" "', argument " "2"" of type '" "void *""'"); + } + result = (int)sk_OPENSSL_BLOCK_find_ex(arg1,arg2); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_sort(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_sort" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + sk_OPENSSL_BLOCK_sort(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_is_sorted(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_is_sorted" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + result = (int)sk_OPENSSL_BLOCK_is_sorted((struct stack_st_OPENSSL_BLOCK const *)arg1); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_dup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct stack_st_OPENSSL_BLOCK *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_dup" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_dup((struct stack_st_OPENSSL_BLOCK const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_deep_copy(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + sk_OPENSSL_BLOCK_copyfunc arg2 = (sk_OPENSSL_BLOCK_copyfunc) 0 ; + sk_OPENSSL_BLOCK_freefunc arg3 = (sk_OPENSSL_BLOCK_freefunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + struct stack_st_OPENSSL_BLOCK *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_deep_copy", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_deep_copy" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK const *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__void__p_void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_deep_copy" "', argument " "2"" of type '" "sk_OPENSSL_BLOCK_copyfunc""'"); + } + } + { + int res = SWIG_ConvertFunctionPtr(swig_obj[2], (void**)(&arg3), SWIGTYPE_p_f_p_void__void); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_deep_copy" "', argument " "3"" of type '" "sk_OPENSSL_BLOCK_freefunc""'"); + } + } + result = (struct stack_st_OPENSSL_BLOCK *)sk_OPENSSL_BLOCK_deep_copy((struct stack_st_OPENSSL_BLOCK const *)arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_OPENSSL_BLOCK_set_cmp_func(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_OPENSSL_BLOCK *arg1 = (struct stack_st_OPENSSL_BLOCK *) 0 ; + sk_OPENSSL_BLOCK_compfunc arg2 = (sk_OPENSSL_BLOCK_compfunc) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + sk_OPENSSL_BLOCK_compfunc result; + + if (!SWIG_Python_UnpackTuple(args, "sk_OPENSSL_BLOCK_set_cmp_func", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_OPENSSL_BLOCK, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_OPENSSL_BLOCK_set_cmp_func" "', argument " "1"" of type '" "struct stack_st_OPENSSL_BLOCK *""'"); + } + arg1 = (struct stack_st_OPENSSL_BLOCK *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "sk_OPENSSL_BLOCK_set_cmp_func" "', argument " "2"" of type '" "sk_OPENSSL_BLOCK_compfunc""'"); + } + } + result = (sk_OPENSSL_BLOCK_compfunc)sk_OPENSSL_BLOCK_set_cmp_func(arg1,arg2); + resultobj = SWIG_NewFunctionPtrObj((void *)(result), SWIGTYPE_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_threading_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "threading_init", 0, 0, 0)) SWIG_fail; + threading_init(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_threading_cleanup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "threading_cleanup", 0, 0, 0)) SWIG_fail; + threading_cleanup(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_lib_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "lib_init", 0, 0, 0)) SWIG_fail; + lib_init(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bn_to_mpi(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIGNUM *arg1 = (BIGNUM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIGNUM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bn_to_mpi" "', argument " "1"" of type '" "BIGNUM const *""'"); + } + arg1 = (BIGNUM *)(argp1); + result = (PyObject *)bn_to_mpi((BIGNUM const *)arg1); + resultobj = result; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_mpi_to_bn(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + BIGNUM *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + arg1 = swig_obj[0]; + result = (BIGNUM *)mpi_to_bn(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bn_to_bin(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIGNUM *arg1 = (BIGNUM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIGNUM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bn_to_bin" "', argument " "1"" of type '" "BIGNUM *""'"); + } + arg1 = (BIGNUM *)(argp1); + result = (PyObject *)bn_to_bin(arg1); + resultobj = result; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bin_to_bn(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + BIGNUM *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + arg1 = swig_obj[0]; + result = (BIGNUM *)bin_to_bn(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bn_to_hex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIGNUM *arg1 = (BIGNUM *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIGNUM, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bn_to_hex" "', argument " "1"" of type '" "BIGNUM *""'"); + } + arg1 = (BIGNUM *)(argp1); + result = (PyObject *)bn_to_hex(arg1); + resultobj = result; + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hex_to_bn(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + BIGNUM *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + arg1 = swig_obj[0]; + result = (BIGNUM *)hex_to_bn(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dec_to_bn(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + BIGNUM *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + arg1 = swig_obj[0]; + result = (BIGNUM *)dec_to_bn(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_err_print_errors(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "err_print_errors" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + ERR_print_errors(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_err_get_error(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + unsigned long result; + + if (!SWIG_Python_UnpackTuple(args, "err_get_error", 0, 0, 0)) SWIG_fail; + result = (unsigned long)ERR_get_error(); + resultobj = SWIG_From_unsigned_SS_long((unsigned long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_err_peek_error(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + unsigned long result; + + if (!SWIG_Python_UnpackTuple(args, "err_peek_error", 0, 0, 0)) SWIG_fail; + result = (unsigned long)ERR_peek_error(); + resultobj = SWIG_From_unsigned_SS_long((unsigned long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_err_lib_error_string(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + unsigned long arg1 ; + unsigned long val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_unsigned_SS_long(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "err_lib_error_string" "', argument " "1"" of type '" "unsigned long""'"); + } + arg1 = (unsigned long)(val1); + result = (char *)ERR_lib_error_string(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_err_func_error_string(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + unsigned long arg1 ; + unsigned long val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_unsigned_SS_long(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "err_func_error_string" "', argument " "1"" of type '" "unsigned long""'"); + } + arg1 = (unsigned long)(val1); + result = (char *)ERR_func_error_string(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_err_reason_error_string(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + unsigned long arg1 ; + unsigned long val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_unsigned_SS_long(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "err_reason_error_string" "', argument " "1"" of type '" "unsigned long""'"); + } + arg1 = (unsigned long)(val1); + result = (char *)ERR_reason_error_string(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_s_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_s_bio", 0, 0, 0)) SWIG_fail; + result = (BIO_METHOD *)BIO_s_bio(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_s_mem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_s_mem", 0, 0, 0)) SWIG_fail; + result = (BIO_METHOD *)BIO_s_mem(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_s_socket(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_s_socket", 0, 0, 0)) SWIG_fail; + result = (BIO_METHOD *)BIO_s_socket(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_f_ssl(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_f_ssl", 0, 0, 0)) SWIG_fail; + result = (BIO_METHOD *)BIO_f_ssl(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_f_buffer(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_f_buffer", 0, 0, 0)) SWIG_fail; + result = (BIO_METHOD *)BIO_f_buffer(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_f_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_f_cipher", 0, 0, 0)) SWIG_fail; + result = (BIO_METHOD *)BIO_f_cipher(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO_METHOD *arg1 = (BIO_METHOD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + BIO *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO_METHOD, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_new" "', argument " "1"" of type '" "BIO_METHOD *""'"); + } + arg1 = (BIO_METHOD *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (BIO *)BIO_new(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_new_socket(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BIO *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_new_socket", 2, 2, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bio_new_socket" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_socket" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (BIO *)BIO_new_socket(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_free_all(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_free_all" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + BIO_free_all(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_dup_chain(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + BIO *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_dup_chain" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (BIO *)BIO_dup_chain(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + BIO *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_push" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_push" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (BIO *)BIO_push(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + BIO *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_pop" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (BIO *)BIO_pop(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_eof(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_eof" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)BIO_eof(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__bio_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_bio_err""' of type '""PyObject *""'"); + } + _bio_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__bio_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_bio_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_pyfd_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "pyfd_init", 0, 0, 0)) SWIG_fail; + pyfd_init(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + bio_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_free" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_free(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_new_file(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + char *arg2 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + BIO *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_new_file", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_new_file" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_new_file" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (BIO *)bio_new_file((char const *)arg1,(char const *)arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_new_pyfile(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + int arg2 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BIO *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_new_pyfile", 2, 2, swig_obj)) SWIG_fail; + { + arg1=swig_obj[0]; + } + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_pyfile" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (BIO *)bio_new_pyfile(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_read(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_read", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_read" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_read" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)bio_read(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_gets(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_gets", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_gets" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_gets" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)bio_gets(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_write(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bio_write", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_write" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_write(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_ctrl_pending(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_ctrl_pending" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_ctrl_pending(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_ctrl_wpending(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_ctrl_wpending" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_ctrl_wpending(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_ctrl_get_write_guarantee(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_ctrl_get_write_guarantee" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_ctrl_get_write_guarantee(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_reset(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_reset" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_reset(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_flush(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_flush" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)bio_flush(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_seek(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bio_seek", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_seek" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_seek" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_seek(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_tell(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_tell" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_tell(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_set_flags(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "bio_set_flags", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_flags" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_set_flags" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + bio_set_flags(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_get_flags(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_get_flags" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_get_flags(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_set_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + EVP_CIPHER *arg2 = (EVP_CIPHER *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_set_cipher", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_cipher" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_set_cipher" "', argument " "2"" of type '" "EVP_CIPHER *""'"); + } + arg2 = (EVP_CIPHER *)(argp2); + { + arg3=swig_obj[2]; + } + { + arg4=swig_obj[3]; + } + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "bio_set_cipher" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)bio_set_cipher(arg1,arg2,arg3,arg4,arg5); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_set_mem_eof_return(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bio_set_mem_eof_return", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_mem_eof_return" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_set_mem_eof_return" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_set_mem_eof_return(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_get_fd(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_get_fd" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_get_fd(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_do_handshake(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_do_handshake" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)bio_do_handshake(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_make_bio_pair(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bio_make_bio_pair", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_make_bio_pair" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_make_bio_pair" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_make_bio_pair(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_set_write_buf_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + size_t arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bio_set_write_buf_size", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_write_buf_size" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_set_write_buf_size" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_set_write_buf_size(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_should_retry(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_should_retry" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_should_retry(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_should_read(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_should_read" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_should_read(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_should_write(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_should_write" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_should_write(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BIO_PYFD_CTX_fd_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct pyfd_struct *arg1 = (struct pyfd_struct *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_pyfd_struct, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BIO_PYFD_CTX_fd_set" "', argument " "1"" of type '" "struct pyfd_struct *""'"); + } + arg1 = (struct pyfd_struct *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[0], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "BIO_PYFD_CTX_fd_set" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (arg1) (arg1)->fd = arg2; + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_BIO_PYFD_CTX_fd_get(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct pyfd_struct *arg1 = (struct pyfd_struct *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "BIO_PYFD_CTX_fd_get", 0, 0, 0)) SWIG_fail; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_pyfd_struct, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "BIO_PYFD_CTX_fd_get" "', argument " "1"" of type '" "struct pyfd_struct *""'"); + } + arg1 = (struct pyfd_struct *)(argp1); + result = (int) ((arg1)->fd); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int _wrap_new_BIO_PYFD_CTX(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + struct pyfd_struct *result = 0 ; + + if (!SWIG_Python_CheckNoKeywords(kwargs, "new_BIO_PYFD_CTX")) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "new_BIO_PYFD_CTX", 0, 0, 0)) SWIG_fail; + result = (struct pyfd_struct *)calloc(1, sizeof(struct pyfd_struct)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_pyfd_struct, SWIG_BUILTIN_INIT | 0 ); + return resultobj == Py_None ? -1 : 0; +fail: + return -1; +} + + +SWIGINTERN PyObject *_wrap_delete_BIO_PYFD_CTX(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct pyfd_struct *arg1 = (struct pyfd_struct *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!SWIG_Python_UnpackTuple(args, "delete_BIO_PYFD_CTX", 0, 0, 0)) SWIG_fail; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_pyfd_struct, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_BIO_PYFD_CTX" "', argument " "1"" of type '" "struct pyfd_struct *""'"); + } + arg1 = (struct pyfd_struct *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete_BIO_PYFD_CTX) /* defines _wrap_delete_BIO_PYFD_CTX_destructor_closure */ + +SWIGINTERN int Swig_var_methods_fdp_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_BIO_METHOD, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""methods_fdp""' of type '""BIO_METHOD *""'"); + } + methods_fdp = (BIO_METHOD *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var_methods_fdp_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(methods_fdp), SWIGTYPE_p_BIO_METHOD, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_pyfd_write(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pyfd_write", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_write" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_write" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_write" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pyfd_write(arg1,(char const *)arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pyfd_read(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pyfd_read", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_read" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_read" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_read" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pyfd_read(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pyfd_puts(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pyfd_puts", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_puts" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_puts" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pyfd_puts(arg1,(char const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pyfd_gets(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pyfd_gets", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_gets" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pyfd_gets" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_gets" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pyfd_gets(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pyfd_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_new" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pyfd_new(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pyfd_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_free" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pyfd_free(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pyfd_ctrl(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + int arg2 ; + long arg3 ; + void *arg4 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + long val3 ; + int ecode3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "pyfd_ctrl", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pyfd_ctrl" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pyfd_ctrl" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pyfd_ctrl" "', argument " "3"" of type '" "long""'"); + } + arg3 = (long)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pyfd_ctrl" "', argument " "4"" of type '" "void *""'"); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)pyfd_ctrl(arg1,arg2,arg3,arg4); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_new_pyfd(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BIO *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_new_pyfd", 2, 2, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bio_new_pyfd" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_pyfd" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (BIO *)BIO_new_pyfd(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bn_rand(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + int arg3 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bn_rand", 3, 3, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "bn_rand" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bn_rand" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bn_rand" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + result = (PyObject *)bn_rand(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bn_rand_range(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (PyObject *)bn_rand_range(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_file_name__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + size_t arg2 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + size_t val2 ; + int ecode2 = 0 ; + char *result = 0 ; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rand_file_name" "', argument " "1"" of type '" "char *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_file_name" "', argument " "2"" of type '" "size_t""'"); + } + arg2 = (size_t)(val2); + result = (char *)RAND_file_name(arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_load_file(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + long arg2 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rand_load_file", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rand_load_file" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_load_file" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + result = (int)RAND_load_file((char const *)arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_save_file(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rand_save_file" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + result = (int)RAND_write_file((char const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_poll(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rand_poll", 0, 0, 0)) SWIG_fail; + result = (int)RAND_poll(); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_status(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rand_status", 0, 0, 0)) SWIG_fail; + result = (int)RAND_status(); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_cleanup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "rand_cleanup", 0, 0, 0)) SWIG_fail; + RAND_cleanup(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__rand_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_rand_err""' of type '""PyObject *""'"); + } + _rand_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__rand_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_rand_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_rand_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + rand_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_seed(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (PyObject *)rand_seed(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_add(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + double arg2 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rand_add", 2, 2, swig_obj)) SWIG_fail; + { + arg1=swig_obj[0]; + } + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_add" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + result = (PyObject *)rand_add(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_bytes(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rand_bytes" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (PyObject *)rand_bytes(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_pseudo_bytes(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rand_pseudo_bytes" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (PyObject *)rand_pseudo_bytes(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_file_name__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) { + PyObject *resultobj = 0; + PyObject *result = 0 ; + + if ((nobjs < 0) || (nobjs > 0)) SWIG_fail; + result = (PyObject *)rand_file_name(); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_file_name(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "rand_file_name", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 0) { + return _wrap_rand_file_name__SWIG_1(self, argc, argv); + } + if (argc == 2) { + int _v; + int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0); + _v = SWIG_CheckState(res); + if (_v) { + { + int res = SWIG_AsVal_size_t(argv[1], NULL); + _v = SWIG_CheckState(res); + } + if (_v) { + return _wrap_rand_file_name__SWIG_0(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'rand_file_name'.\n" + " Possible C/C++ prototypes are:\n" + " RAND_file_name(char *,size_t)\n" + " rand_file_name()\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_rand_screen(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "rand_screen", 0, 0, 0)) SWIG_fail; + rand_screen(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rand_win32_event(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + unsigned int arg1 ; + int arg2 ; + long arg3 ; + unsigned int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + long val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rand_win32_event", 3, 3, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_unsigned_SS_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rand_win32_event" "', argument " "1"" of type '" "unsigned int""'"); + } + arg1 = (unsigned int)(val1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rand_win32_event" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rand_win32_event" "', argument " "3"" of type '" "long""'"); + } + arg3 = (long)(val3); + result = (int)rand_win32_event(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_md5(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "md5", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_md5(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sha1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sha1", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_sha1(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ripemd160(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ripemd160", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_ripemd160(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sha224(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sha224", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_sha224(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sha256(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sha256", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_sha256(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sha384(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sha384", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_sha384(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sha512(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sha512", 0, 0, 0)) SWIG_fail; + result = (EVP_MD *)EVP_sha512(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_MD *arg2 = (EVP_MD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "digest_init", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_init" "', argument " "2"" of type '" "EVP_MD const *""'"); + } + arg2 = (EVP_MD *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_DigestInit(arg1,(EVP_MD const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ecb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede3_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede3_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede3(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede3_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede3_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede3_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede3_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede3_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede3_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_des_ede3_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "des_ede3_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_des_ede3_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bf_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bf_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_bf_ecb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bf_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bf_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_bf_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bf_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bf_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_bf_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bf_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bf_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_bf_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cast5_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cast5_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_cast5_ecb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cast5_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cast5_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_cast5_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cast5_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cast5_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_cast5_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cast5_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cast5_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_cast5_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc4(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rc4", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_rc4(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc2_40_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rc2_40_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_rc2_40_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_128_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_128_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_128_ecb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_128_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_128_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_128_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_128_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_128_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_128_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_128_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_128_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_128_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_128_ctr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_128_ctr", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_128_ctr(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_192_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_192_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_192_ecb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_192_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_192_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_192_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_192_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_192_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_192_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_192_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_192_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_192_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_192_ctr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_192_ctr", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_192_ctr(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_256_ecb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_256_ecb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_256_ecb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_256_cbc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_256_cbc", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_256_cbc(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_256_cfb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_256_cfb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_256_cfb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_256_ofb(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_256_ofb", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_256_ofb(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_256_ctr(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_256_ctr", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER *)EVP_aes_256_ctr(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cipher_set_padding(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "cipher_set_padding", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_set_padding" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); + } + arg1 = (EVP_CIPHER_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "cipher_set_padding" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_CIPHER_CTX_set_padding(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_free" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + EVP_PKEY_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_assign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + int arg2 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkey_assign", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_assign" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "pkey_assign" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkey_assign" "', argument " "3"" of type '" "char *""'"); + } + arg3 = (char *)(buf3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_PKEY_assign(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_assign_ec(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + EC_KEY *arg2 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkey_assign_ec", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_assign_ec" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_assign_ec" "', argument " "2"" of type '" "EC_KEY *""'"); + } + arg2 = (EC_KEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_PKEY_assign_EC_KEY(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_set1_rsa(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + RSA *arg2 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkey_set1_rsa", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_set1_rsa" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_set1_rsa" "', argument " "2"" of type '" "RSA *""'"); + } + arg2 = (RSA *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_PKEY_set1_RSA(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sign_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_MD *arg2 = (EVP_MD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sign_init", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sign_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sign_init" "', argument " "2"" of type '" "EVP_MD const *""'"); + } + arg2 = (EVP_MD *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_SignInit(arg1,(EVP_MD const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_verify_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_MD *arg2 = (EVP_MD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "verify_init", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "verify_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "verify_init" "', argument " "2"" of type '" "EVP_MD const *""'"); + } + arg2 = (EVP_MD *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_VerifyInit(arg1,(EVP_MD const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_sign_init__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_PKEY_CTX **arg2 = (EVP_PKEY_CTX **) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + ENGINE *arg4 = (ENGINE *) 0 ; + EVP_PKEY *arg5 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int result; + + if ((nobjs < 5) || (nobjs > 5)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_EVP_PKEY_CTX, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_sign_init" "', argument " "2"" of type '" "EVP_PKEY_CTX **""'"); + } + arg2 = (EVP_PKEY_CTX **)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "digest_sign_init" "', argument " "3"" of type '" "EVP_MD const *""'"); + } + arg3 = (EVP_MD *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "digest_sign_init" "', argument " "4"" of type '" "ENGINE *""'"); + } + arg4 = (ENGINE *)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "digest_sign_init" "', argument " "5"" of type '" "EVP_PKEY *""'"); + } + arg5 = (EVP_PKEY *)(argp5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg5) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_DigestSignInit(arg1,arg2,(EVP_MD const *)arg3,arg4,arg5); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_verify_init__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_PKEY_CTX **arg2 = (EVP_PKEY_CTX **) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + ENGINE *arg4 = (ENGINE *) 0 ; + EVP_PKEY *arg5 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int result; + + if ((nobjs < 5) || (nobjs > 5)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_EVP_PKEY_CTX, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_verify_init" "', argument " "2"" of type '" "EVP_PKEY_CTX **""'"); + } + arg2 = (EVP_PKEY_CTX **)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "digest_verify_init" "', argument " "3"" of type '" "EVP_MD const *""'"); + } + arg3 = (EVP_MD *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "digest_verify_init" "', argument " "4"" of type '" "ENGINE *""'"); + } + arg4 = (ENGINE *)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "digest_verify_init" "', argument " "5"" of type '" "EVP_PKEY *""'"); + } + arg5 = (EVP_PKEY *)(argp5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg5) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_DigestVerifyInit(arg1,arg2,(EVP_MD const *)arg3,arg4,arg5); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_size" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EVP_PKEY_size(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__evp_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_evp_err""' of type '""PyObject *""'"); + } + _evp_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__evp_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_evp_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_evp_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + evp_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_get1_rsa(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + RSA *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_get1_rsa" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (RSA *)pkey_get1_rsa(arg1); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_RSA, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs5_pbkdf2_hmac_sha1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + int arg4 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs5_pbkdf2_hmac_sha1", 4, 4, swig_obj)) SWIG_fail; + { + arg1=swig_obj[0]; + } + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pkcs5_pbkdf2_hmac_sha1" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs5_pbkdf2_hmac_sha1" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + result = (PyObject *)pkcs5_pbkdf2_hmac_sha1(arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_md_ctx_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "md_ctx_new", 0, 0, 0)) SWIG_fail; + result = (EVP_MD_CTX *)md_ctx_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_md_ctx_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "md_ctx_free" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + md_ctx_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "digest_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)digest_update(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)digest_final(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hmac_ctx_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + HMAC_CTX *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "hmac_ctx_new", 0, 0, 0)) SWIG_fail; + result = (HMAC_CTX *)hmac_ctx_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_HMAC_CTX, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hmac_ctx_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_ctx_free" "', argument " "1"" of type '" "HMAC_CTX *""'"); + } + arg1 = (HMAC_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + hmac_ctx_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hmac_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "hmac_init", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_init" "', argument " "1"" of type '" "HMAC_CTX *""'"); + } + arg1 = (HMAC_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "hmac_init" "', argument " "3"" of type '" "EVP_MD const *""'"); + } + arg3 = (EVP_MD *)(argp3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)hmac_init(arg1,arg2,(EVP_MD const *)arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hmac_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "hmac_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_update" "', argument " "1"" of type '" "HMAC_CTX *""'"); + } + arg1 = (HMAC_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)hmac_update(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hmac_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + HMAC_CTX *arg1 = (HMAC_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_HMAC_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "hmac_final" "', argument " "1"" of type '" "HMAC_CTX *""'"); + } + arg1 = (HMAC_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)hmac_final(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_hmac(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "hmac", 3, 3, swig_obj)) SWIG_fail; + { + arg1=swig_obj[0]; + } + { + arg2=swig_obj[1]; + } + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "hmac" "', argument " "3"" of type '" "EVP_MD const *""'"); + } + arg3 = (EVP_MD *)(argp3); + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)hmac(arg1,arg2,(EVP_MD const *)arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cipher_ctx_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER_CTX *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cipher_ctx_new", 0, 0, 0)) SWIG_fail; + result = (EVP_CIPHER_CTX *)cipher_ctx_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cipher_ctx_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_ctx_free" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); + } + arg1 = (EVP_CIPHER_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + cipher_ctx_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bytes_to_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER *arg1 = (EVP_CIPHER *) 0 ; + EVP_MD *arg2 = (EVP_MD *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + PyObject *arg5 = (PyObject *) 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bytes_to_key", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bytes_to_key" "', argument " "1"" of type '" "EVP_CIPHER const *""'"); + } + arg1 = (EVP_CIPHER *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bytes_to_key" "', argument " "2"" of type '" "EVP_MD *""'"); + } + arg2 = (EVP_MD *)(argp2); + { + arg3=swig_obj[2]; + } + { + arg4=swig_obj[3]; + } + { + arg5=swig_obj[4]; + } + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "bytes_to_key" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)bytes_to_key((EVP_CIPHER const *)arg1,arg2,arg3,arg4,arg5,arg6); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cipher_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; + EVP_CIPHER *arg2 = (EVP_CIPHER *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cipher_init", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_init" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); + } + arg1 = (EVP_CIPHER_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "cipher_init" "', argument " "2"" of type '" "EVP_CIPHER const *""'"); + } + arg2 = (EVP_CIPHER *)(argp2); + { + arg3=swig_obj[2]; + } + { + arg4=swig_obj[3]; + } + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "cipher_init" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)cipher_init(arg1,(EVP_CIPHER const *)arg2,arg3,arg4,arg5); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cipher_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "cipher_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_update" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); + } + arg1 = (EVP_CIPHER_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)cipher_update(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_cipher_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_CIPHER_CTX *arg1 = (EVP_CIPHER_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_CIPHER_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "cipher_final" "', argument " "1"" of type '" "EVP_CIPHER_CTX *""'"); + } + arg1 = (EVP_CIPHER_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)cipher_final(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sign_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sign_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sign_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)sign_update(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sign_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sign_final", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sign_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sign_final" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)sign_final(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_verify_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "verify_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "verify_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)verify_update(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_verify_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + EVP_PKEY *arg3 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "verify_final", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "verify_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "verify_final" "', argument " "3"" of type '" "EVP_PKEY *""'"); + } + arg3 = (EVP_PKEY *)(argp3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)verify_final(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_sign_init__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int result; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_sign_init" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)digest_sign_init(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_sign_init(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[6] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "digest_sign_init", 0, 5, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_EVP_PKEY, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_digest_sign_init__SWIG_1(self, argc, argv); + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_p_EVP_PKEY_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_EVP_MD, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_ENGINE, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_EVP_PKEY, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_digest_sign_init__SWIG_0(self, argc, argv); + } + } + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'digest_sign_init'.\n" + " Possible C/C++ prototypes are:\n" + " EVP_DigestSignInit(EVP_MD_CTX *,EVP_PKEY_CTX **,EVP_MD const *,ENGINE *,EVP_PKEY *)\n" + " digest_sign_init(EVP_MD_CTX *,EVP_PKEY *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_digest_sign_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "digest_sign_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)digest_sign_update(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_sign_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)digest_sign_final(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_sign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "digest_sign", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_sign" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)digest_sign(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_verify_init__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int result; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_init" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "digest_verify_init" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)digest_verify_init(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_verify_init(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[6] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "digest_verify_init", 0, 5, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_EVP_PKEY, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_digest_verify_init__SWIG_1(self, argc, argv); + } + } + } + if (argc == 5) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_EVP_MD_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_p_EVP_PKEY_CTX, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[2], &vptr, SWIGTYPE_p_EVP_MD, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[3], &vptr, SWIGTYPE_p_ENGINE, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[4], &vptr, SWIGTYPE_p_EVP_PKEY, 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_digest_verify_init__SWIG_0(self, argc, argv); + } + } + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'digest_verify_init'.\n" + " Possible C/C++ prototypes are:\n" + " EVP_DigestVerifyInit(EVP_MD_CTX *,EVP_PKEY_CTX **,EVP_MD const *,ENGINE *,EVP_PKEY *)\n" + " digest_verify_init(EVP_MD_CTX *,EVP_PKEY *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_digest_verify_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "digest_verify_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_update" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)digest_verify_update(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_verify_final(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "digest_verify_final", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify_final" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)digest_verify_final(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_digest_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_MD_CTX *arg1 = (EVP_MD_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "digest_verify", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_MD_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "digest_verify" "', argument " "1"" of type '" "EVP_MD_CTX *""'"); + } + arg1 = (EVP_MD_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)digest_verify(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_get_digestbyname(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + EVP_MD *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_digestbyname" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + result = (EVP_MD *)get_digestbyname((char const *)arg1); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_MD, 0); + else { + resultobj = NULL; + } + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_write_pem_no_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + BIO *arg2 = (BIO *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkey_write_pem_no_cipher", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_write_pem_no_cipher" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_write_pem_no_cipher" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pkey_write_pem_no_cipher(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_write_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + BIO *arg2 = (BIO *) 0 ; + EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkey_write_pem", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_write_pem" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_write_pem" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkey_write_pem" "', argument " "3"" of type '" "EVP_CIPHER *""'"); + } + arg3 = (EVP_CIPHER *)(argp3); + { + if (!PyCallable_Check(swig_obj[3])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pkey_write_pem(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkey_new", 0, 0, 0)) SWIG_fail; + result = (EVP_PKEY *)pkey_new(); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_PKEY, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_read_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + EVP_PKEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkey_read_pem", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_read_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EVP_PKEY *)pkey_read_pem(arg1,arg2); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_PKEY, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_read_pem_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + EVP_PKEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkey_read_pem_pubkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_read_pem_pubkey" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EVP_PKEY *)pkey_read_pem_pubkey(arg1,arg2); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_EVP_PKEY, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_assign_rsa(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + RSA *arg2 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkey_assign_rsa", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_assign_rsa" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkey_assign_rsa" "', argument " "2"" of type '" "RSA *""'"); + } + arg2 = (RSA *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pkey_assign_rsa(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_as_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_as_der" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)pkey_as_der(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkey_get_modulus(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EVP_PKEY *arg1 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkey_get_modulus" "', argument " "1"" of type '" "EVP_PKEY *""'"); + } + arg1 = (EVP_PKEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)pkey_get_modulus(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_aes_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AES_KEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "aes_new", 0, 0, 0)) SWIG_fail; + result = (AES_KEY *)aes_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_AES_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AES_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AES_KEY *arg1 = (AES_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_free" "', argument " "1"" of type '" "AES_KEY *""'"); + } + arg1 = (AES_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + AES_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AES_set_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AES_KEY *arg1 = (AES_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "AES_set_key", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_set_key" "', argument " "1"" of type '" "AES_KEY *""'"); + } + arg1 = (AES_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AES_set_key" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "AES_set_key" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)AES_set_key(arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AES_crypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AES_KEY *arg1 = (AES_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "AES_crypt", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_crypt" "', argument " "1"" of type '" "AES_KEY const *""'"); + } + arg1 = (AES_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "AES_crypt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "AES_crypt" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)AES_crypt((AES_KEY const *)arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_AES_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + AES_KEY *arg1 = (AES_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_AES_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "AES_type_check" "', argument " "1"" of type '" "AES_KEY *""'"); + } + arg1 = (AES_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)AES_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc4_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RC4_KEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rc4_new", 0, 0, 0)) SWIG_fail; + result = (RC4_KEY *)rc4_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RC4_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc4_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RC4_KEY *arg1 = (RC4_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_free" "', argument " "1"" of type '" "RC4_KEY *""'"); + } + arg1 = (RC4_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + rc4_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc4_set_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RC4_KEY *arg1 = (RC4_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rc4_set_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_set_key" "', argument " "1"" of type '" "RC4_KEY *""'"); + } + arg1 = (RC4_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rc4_set_key(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc4_update(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RC4_KEY *arg1 = (RC4_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rc4_update", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_update" "', argument " "1"" of type '" "RC4_KEY *""'"); + } + arg1 = (RC4_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rc4_update(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rc4_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RC4_KEY *arg1 = (RC4_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RC4_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rc4_type_check" "', argument " "1"" of type '" "RC4_KEY *""'"); + } + arg1 = (RC4_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rc4_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dh_new", 0, 0, 0)) SWIG_fail; + result = (DH *)DH_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DH, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_free" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + DH_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_size" "', argument " "1"" of type '" "DH const *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)DH_size((DH const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_generate_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_generate_key" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)DH_generate_key(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dhparams_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + DH *arg2 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dhparams_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dhparams_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dhparams_print" "', argument " "2"" of type '" "DH const *""'"); + } + arg2 = (DH *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)DHparams_print(arg1,(DH const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__dh_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_dh_err""' of type '""PyObject *""'"); + } + _dh_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__dh_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_dh_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_dh_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + dh_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_type_check" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dh_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_read_parameters(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + DH *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_read_parameters" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (DH *)dh_read_parameters(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DH, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_generate_parameters(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int arg2 ; + PyObject *arg3 = (PyObject *) 0 ; + int val1 ; + int ecode1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[3] ; + DH *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dh_generate_parameters", 3, 3, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "dh_generate_parameters" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "dh_generate_parameters" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + result = (DH *)dh_generate_parameters(arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DH, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_check" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dh_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_compute_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dh_compute_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_compute_key" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dh_compute_key(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_get_p(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_p" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dh_get_p(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_get_g(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_g" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dh_get_g(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_get_pub(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_pub" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dh_get_pub(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_get_priv(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_get_priv" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dh_get_priv(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dh_set_pg(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DH *arg1 = (DH *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dh_set_pg", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dh_set_pg" "', argument " "1"" of type '" "DH *""'"); + } + arg1 = (DH *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dh_set_pg(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_size" "', argument " "1"" of type '" "RSA const *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)RSA_size((RSA const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_new", 0, 0, 0)) SWIG_fail; + result = (RSA *)RSA_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RSA, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_free" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + RSA_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_check_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_check_key" "', argument " "1"" of type '" "RSA const *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)RSA_check_key((RSA const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__rsa_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_rsa_err""' of type '""PyObject *""'"); + } + _rsa_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__rsa_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_rsa_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_rsa_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + rsa_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_read_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + RSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_read_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_read_key" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (RSA *)rsa_read_key(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RSA, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_write_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rsa_write_key", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_key" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_key" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rsa_write_key" "', argument " "3"" of type '" "EVP_CIPHER *""'"); + } + arg3 = (EVP_CIPHER *)(argp3); + { + if (!PyCallable_Check(swig_obj[3])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rsa_write_key(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_write_key_no_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rsa_write_key_no_cipher", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_key_no_cipher" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_key_no_cipher" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rsa_write_key_no_cipher(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_read_pub_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + RSA *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_read_pub_key" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (RSA *)rsa_read_pub_key(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_RSA, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_write_pub_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rsa_write_pub_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_pub_key" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_pub_key" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)rsa_write_pub_key(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_get_e(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_get_e" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_get_e(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_get_n(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_get_n" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_get_n(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_set_e(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_set_e", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_e" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_set_e(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_set_n(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_set_n", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_n" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_set_n(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_set_en(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_set_en", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_en" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_set_en(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_PyObject_Bin_AsBIGNUM(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + BIGNUM *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (BIGNUM *)PyObject_Bin_AsBIGNUM(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIGNUM, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_set_en_bin(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_set_en_bin", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_set_en_bin" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_set_en_bin(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_private_encrypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_private_encrypt", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_private_encrypt" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_private_encrypt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_private_encrypt(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_public_decrypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_public_decrypt", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_public_decrypt" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_public_decrypt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_public_decrypt(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_public_encrypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_public_encrypt", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_public_encrypt" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_public_encrypt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_public_encrypt(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_private_decrypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_private_decrypt", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_private_decrypt" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_private_decrypt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_private_decrypt(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_padding_add_pkcs1_pss(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_padding_add_pkcs1_pss", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_padding_add_pkcs1_pss" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "rsa_padding_add_pkcs1_pss" "', argument " "3"" of type '" "EVP_MD *""'"); + } + arg3 = (EVP_MD *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "rsa_padding_add_pkcs1_pss" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_padding_add_pkcs1_pss(arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_verify_pkcs1_pss(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + EVP_MD *arg4 = (EVP_MD *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rsa_verify_pkcs1_pss", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_verify_pkcs1_pss" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "rsa_verify_pkcs1_pss" "', argument " "4"" of type '" "EVP_MD *""'"); + } + arg4 = (EVP_MD *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "rsa_verify_pkcs1_pss" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rsa_verify_pkcs1_pss(arg1,arg2,arg3,arg4,arg5); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_sign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_sign", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_sign" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "rsa_sign" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_sign(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rsa_verify", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_verify" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "rsa_verify" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rsa_verify(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_generate_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned long arg2 ; + PyObject *arg3 = (PyObject *) 0 ; + int val1 ; + int ecode1 = 0 ; + unsigned long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "rsa_generate_key", 3, 3, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "rsa_generate_key" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + ecode2 = SWIG_AsVal_unsigned_SS_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "rsa_generate_key" "', argument " "2"" of type '" "unsigned long""'"); + } + arg2 = (unsigned long)(val2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)rsa_generate_key(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_type_check" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rsa_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_check_pub_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_check_pub_key" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)rsa_check_pub_key(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_rsa_write_key_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + RSA *arg1 = (RSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "rsa_write_key_der", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "rsa_write_key_der" "', argument " "1"" of type '" "RSA *""'"); + } + arg1 = (RSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "rsa_write_key_der" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)rsa_write_key_der(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_new", 0, 0, 0)) SWIG_fail; + result = (DSA *)DSA_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DSA, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_free" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + DSA_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_size" "', argument " "1"" of type '" "DSA const *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)DSA_size((DSA const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_gen_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_gen_key" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)DSA_generate_key(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__dsa_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_dsa_err""' of type '""PyObject *""'"); + } + _dsa_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__dsa_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_dsa_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_dsa_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + dsa_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_generate_parameters(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + PyObject *arg2 = (PyObject *) 0 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[2] ; + DSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_generate_parameters", 2, 2, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "dsa_generate_parameters" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (DSA *)dsa_generate_parameters(arg1,arg2); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_read_params(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + DSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_read_params", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_read_params" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (DSA *)dsa_read_params(arg1,arg2); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_read_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + DSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_read_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_read_key" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (DSA *)dsa_read_key(arg1,arg2); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_read_pub_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + DSA *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_read_pub_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_read_pub_key" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (DSA *)dsa_read_pub_key(arg1,arg2); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_DSA, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_get_p(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_p" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_get_p(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_get_q(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_q" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_get_q(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_get_g(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_g" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_get_g(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_get_pub(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_pub" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_get_pub(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_get_priv(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_get_priv" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_get_priv(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_set_pqg(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_set_pqg", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_set_pqg" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_set_pqg(arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_set_pub(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_set_pub", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_set_pub" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_set_pub(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_write_params_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dsa_write_params_bio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_params_bio" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_params_bio" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)dsa_write_params_bio(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_write_key_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dsa_write_key_bio", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_key_bio" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_key_bio" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "dsa_write_key_bio" "', argument " "3"" of type '" "EVP_CIPHER *""'"); + } + arg3 = (EVP_CIPHER *)(argp3); + { + if (!PyCallable_Check(swig_obj[3])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_write_key_bio(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_write_key_bio_no_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dsa_write_key_bio_no_cipher", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_key_bio_no_cipher" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_key_bio_no_cipher" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_write_key_bio_no_cipher(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_write_pub_key_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dsa_write_pub_key_bio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_write_pub_key_bio" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "dsa_write_pub_key_bio" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)dsa_write_pub_key_bio(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_sign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_sign", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_sign" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_sign(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dsa_verify", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_verify" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_verify(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_sign_asn1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "dsa_sign_asn1", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_sign_asn1" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)dsa_sign_asn1(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_verify_asn1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "dsa_verify_asn1", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_verify_asn1" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_verify_asn1(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_check_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_check_key" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_check_key(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_check_pub_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_check_pub_key" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_check_pub_key(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_keylen(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_keylen" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_keylen(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_dsa_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + DSA *arg1 = (DSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DSA, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "dsa_type_check" "', argument " "1"" of type '" "DSA *""'"); + } + arg1 = (DSA *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)dsa_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_ciphers(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct stack_st_SSL_CIPHER *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_ciphers" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (struct stack_st_SSL_CIPHER *)SSL_get_ciphers((SSL const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_SSL_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_version(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_version" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)SSL_get_version((SSL const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_error(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_get_error", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_error" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_get_error" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_get_error((SSL const *)arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_state(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_state" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)SSL_state_string((SSL const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_state_v(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_state_v" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)SSL_state_string_long((SSL const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_alert_type(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_type" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (char *)SSL_alert_type_string(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_alert_type_v(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_type_v" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (char *)SSL_alert_type_string_long(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_alert_desc(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_desc" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (char *)SSL_alert_desc_string(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_alert_desc_v(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ssl_get_alert_desc_v" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (char *)SSL_alert_desc_string_long(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sslv23_method(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sslv23_method", 0, 0, 0)) SWIG_fail; + result = (SSL_METHOD *)SSLv23_method(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_METHOD *arg1 = (SSL_METHOD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL_CTX *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_METHOD, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_new" "', argument " "1"" of type '" "SSL_METHOD *""'"); + } + arg1 = (SSL_METHOD *)(argp1); + result = (SSL_CTX *)SSL_CTX_new(arg1); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_SSL_CTX, 0); + else { + m2_PyErr_Msg(_ssl_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_free" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + SSL_CTX_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_verify_depth(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_verify_depth", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_verify_depth" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_verify_depth" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + SSL_CTX_set_verify_depth(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_get_verify_depth(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_verify_depth" "', argument " "1"" of type '" "SSL_CTX const *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_CTX_get_verify_depth((SSL_CTX const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_get_verify_mode(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_verify_mode" "', argument " "1"" of type '" "SSL_CTX const *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_CTX_get_verify_mode((SSL_CTX const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_cipher_list(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_cipher_list", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_cipher_list" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_cipher_list" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_CTX_set_cipher_list(arg1,(char const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_add_session(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_add_session", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_add_session" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_add_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); + } + arg2 = (SSL_SESSION *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_CTX_add_session(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_remove_session(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_remove_session", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_remove_session" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_remove_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); + } + arg2 = (SSL_SESSION *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_CTX_remove_session(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_session_timeout(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_session_timeout", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_session_timeout" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_session_timeout" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)SSL_CTX_set_timeout(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_get_session_timeout(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_session_timeout" "', argument " "1"" of type '" "SSL_CTX const *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)SSL_CTX_get_timeout((SSL_CTX const *)arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_get_cert_store(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_STORE *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_cert_store" "', argument " "1"" of type '" "SSL_CTX const *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_STORE *)SSL_CTX_get_cert_store((SSL_CTX const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_STORE, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_default_verify_paths(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_default_verify_paths" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_CTX_set_default_verify_paths(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_ex_data_x509_store_ctx_idx(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_get_ex_data_x509_store_ctx_idx", 0, 0, 0)) SWIG_fail; + result = (int)SSL_get_ex_data_X509_STORE_CTX_idx(); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_new_ssl(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + BIO *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "bio_new_ssl", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_new_ssl" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "bio_new_ssl" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (BIO *)BIO_new_ssl(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_BIO, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_new" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL *)SSL_new(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_free" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + SSL_free(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_dup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_dup" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL *)SSL_dup(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + BIO *arg2 = (BIO *) 0 ; + BIO *arg3 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[3] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_bio", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_bio" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_bio" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ssl_set_bio" "', argument " "3"" of type '" "BIO *""'"); + } + arg3 = (BIO *)(argp3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + SSL_set_bio(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_accept_state(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_accept_state" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + SSL_set_accept_state(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_connect_state(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_connect_state" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + SSL_set_connect_state(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_shutdown(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_shutdown" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_get_shutdown((SSL const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_shutdown(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_shutdown", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_shutdown" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_shutdown" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + SSL_set_shutdown(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_shutdown(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_shutdown" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)SSL_shutdown(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_clear(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_clear" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_clear(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_do_handshake(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_do_handshake" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)SSL_do_handshake(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_renegotiate(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_renegotiate" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)SSL_renegotiate(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_pending(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_pending" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_pending((SSL const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_peer_cert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_peer_cert" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509 *)SSL_get_peer_certificate((SSL const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_current_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL_CIPHER *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_current_cipher" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL_CIPHER *)SSL_get_current_cipher((SSL const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_verify_mode(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_verify_mode" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_get_verify_mode((SSL const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_verify_depth(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_verify_depth" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_get_verify_depth((SSL const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_verify_result(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_verify_result" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)SSL_get_verify_result((SSL const *)arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_ssl_ctx(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL_CTX *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_ssl_ctx" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL_CTX *)SSL_get_SSL_CTX((SSL const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_CTX, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_default_session_timeout(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_default_session_timeout" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)SSL_get_default_timeout((SSL const *)arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_cipher_list(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_cipher_list", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_cipher_list" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_cipher_list" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_set_cipher_list(arg1,(char const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_cipher_list(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_get_cipher_list", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_cipher_list" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_get_cipher_list" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)SSL_get_cipher_list((SSL const *)arg1,arg2); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_cipher_get_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CIPHER *arg1 = (SSL_CIPHER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_cipher_get_name" "', argument " "1"" of type '" "SSL_CIPHER const *""'"); + } + arg1 = (SSL_CIPHER *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)SSL_CIPHER_get_name((SSL_CIPHER const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_cipher_get_version(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CIPHER *arg1 = (SSL_CIPHER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_cipher_get_version" "', argument " "1"" of type '" "SSL_CIPHER const *""'"); + } + arg1 = (SSL_CIPHER *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)SSL_CIPHER_get_version((SSL_CIPHER const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_session(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL_SESSION *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_session" "', argument " "1"" of type '" "SSL const *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL_SESSION *)SSL_get_session((SSL const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get1_session(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL_SESSION *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get1_session" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL_SESSION *)SSL_get1_session(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_session(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_session", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_session" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); + } + arg2 = (SSL_SESSION *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)SSL_set_session(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_session_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_free" "', argument " "1"" of type '" "SSL_SESSION *""'"); + } + arg1 = (SSL_SESSION *)(argp1); + SSL_SESSION_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_session_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_session_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_session_print" "', argument " "2"" of type '" "SSL_SESSION const *""'"); + } + arg2 = (SSL_SESSION *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)SSL_SESSION_print(arg1,(SSL_SESSION const *)arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_session_set_timeout(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_session_set_timeout", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_set_timeout" "', argument " "1"" of type '" "SSL_SESSION *""'"); + } + arg1 = (SSL_SESSION *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_session_set_timeout" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + result = (long)SSL_SESSION_set_timeout(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_session_get_timeout(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_get_timeout" "', argument " "1"" of type '" "SSL_SESSION const *""'"); + } + arg1 = (SSL_SESSION *)(argp1); + result = (long)SSL_SESSION_get_timeout((SSL_SESSION const *)arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_accept(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + double arg2 = (double) -1 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_accept", 1, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_accept" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_accept" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ssl_accept(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_connect(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + double arg2 = (double) -1 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_connect", 1, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_connect" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + if (swig_obj[1]) { + ecode2 = SWIG_AsVal_double(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_connect" "', argument " "2"" of type '" "double""'"); + } + arg2 = (double)(val2); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ssl_connect(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_read(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + double arg3 = (double) -1 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + double val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_read", 2, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_read" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_read" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + if (swig_obj[2]) { + ecode3 = SWIG_AsVal_double(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ssl_read" "', argument " "3"" of type '" "double""'"); + } + arg3 = (double)(val3); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ssl_read(arg1,arg2,arg3); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_write(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + double arg3 = (double) -1 ; + void *argp1 = 0 ; + int res1 = 0 ; + double val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_write", 2, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_write" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + arg2=swig_obj[1]; + } + if (swig_obj[2]) { + ecode3 = SWIG_AsVal_double(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "ssl_write" "', argument " "3"" of type '" "double""'"); + } + arg3 = (double)(val3); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_write(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__ssl_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_ssl_err""' of type '""PyObject *""'"); + } + _ssl_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__ssl_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_ssl_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN int Swig_var__ssl_timeout_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_ssl_timeout_err""' of type '""PyObject *""'"); + } + _ssl_timeout_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__ssl_timeout_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_ssl_timeout_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_ssl_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_init", 2, 2, swig_obj)) SWIG_fail; + { + arg1=swig_obj[0]; + } + { + arg2=swig_obj[1]; + } + ssl_init(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_tlsv1_method(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "tlsv1_method", 0, 0, 0)) SWIG_fail; + result = (SSL_METHOD *)tlsv1_method(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_passphrase_callback(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_passphrase_callback", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_passphrase_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_passphrase_callback(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_use_x509(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_x509", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_x509" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_x509" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_use_x509(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_use_cert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_cert", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_cert" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_cert" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_use_cert(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_use_cert_chain(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_cert_chain", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_cert_chain" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_cert_chain" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_use_cert_chain(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_use_privkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_privkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_privkey" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_use_privkey(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_use_rsa_privkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + RSA *arg2 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_rsa_privkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_rsa_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_rsa_privkey" "', argument " "2"" of type '" "RSA *""'"); + } + arg2 = (RSA *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_use_rsa_privkey(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_use_pkey_privkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_use_pkey_privkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_use_pkey_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_use_pkey_privkey" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_use_pkey_privkey(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_check_privkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_check_privkey" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_check_privkey(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_client_CA_list_from_file(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_client_CA_list_from_file", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_client_CA_list_from_file" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_client_CA_list_from_file" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_set_client_CA_list_from_file(arg1,(char const *)arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_verify_default(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_verify_default", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_verify_default" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_verify_default" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_set_verify_default(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + int arg2 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[3] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_verify", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_verify" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_verify" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_set_verify(arg1,arg2,arg3); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_session_id_context(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_session_id_context", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_session_id_context" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_set_session_id_context(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_info_callback(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_info_callback", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_info_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_set_info_callback(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_dh(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + DH *arg2 = (DH *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_dh", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_dh" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_DH, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_tmp_dh" "', argument " "2"" of type '" "DH *""'"); + } + arg2 = (DH *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)ssl_ctx_set_tmp_dh(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_dh_callback(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_dh_callback", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_dh_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_set_tmp_dh_callback(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_rsa(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + RSA *arg2 = (RSA *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_rsa", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_rsa" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_RSA, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_set_tmp_rsa" "', argument " "2"" of type '" "RSA *""'"); + } + arg2 = (RSA *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)ssl_ctx_set_tmp_rsa(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_tmp_rsa_callback(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_tmp_rsa_callback", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_tmp_rsa_callback" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_ctx_set_tmp_rsa_callback(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_load_verify_locations(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_load_verify_locations", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_load_verify_locations" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_ctx_load_verify_locations" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ssl_ctx_load_verify_locations" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_load_verify_locations(arg1,(char const *)arg2,(char const *)arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_options(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_options", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_options" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_options" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)ssl_ctx_set_options(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_bio_set_ssl(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + SSL *arg2 = (SSL *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "bio_set_ssl", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "bio_set_ssl" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "bio_set_ssl" "', argument " "2"" of type '" "SSL *""'"); + } + arg2 = (SSL *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "bio_set_ssl" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)bio_set_ssl(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_mode(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_mode", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_mode" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_mode" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)ssl_set_mode(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_mode(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_mode" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)ssl_get_mode(arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_tlsext_host_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_tlsext_host_name", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_tlsext_host_name" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_tlsext_host_name" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_set_tlsext_host_name(arg1,(char const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_client_CA_list_from_file(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_client_CA_list_from_file", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_client_CA_list_from_file" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_client_CA_list_from_file" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_set_client_CA_list_from_file(arg1,(char const *)arg2); + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_client_CA_list_from_context(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + SSL_CTX *arg2 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_client_CA_list_from_context", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_client_CA_list_from_context" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_set_client_CA_list_from_context" "', argument " "2"" of type '" "SSL_CTX *""'"); + } + arg2 = (SSL_CTX *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_set_client_CA_list_from_context(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_session_id_context(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_session_id_context", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_session_id_context" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_set_session_id_context(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_fd(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_fd", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_fd" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_fd" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_set_fd(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_set_shutdown1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_set_shutdown1", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_set_shutdown1" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_set_shutdown1" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ssl_set_shutdown1(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_read_nbio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ssl_read_nbio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_read_nbio" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_read_nbio" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ssl_read_nbio(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_write_nbio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_write_nbio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_write_nbio" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_write_nbio(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_cipher_get_bits(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CIPHER *arg1 = (SSL_CIPHER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_cipher_get_bits" "', argument " "1"" of type '" "SSL_CIPHER *""'"); + } + arg1 = (SSL_CIPHER *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_cipher_get_bits(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_ssl_cipher_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_SSL_CIPHER *arg1 = (struct stack_st_SSL_CIPHER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_SSL_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_ssl_cipher_num" "', argument " "1"" of type '" "struct stack_st_SSL_CIPHER *""'"); + } + arg1 = (struct stack_st_SSL_CIPHER *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)sk_ssl_cipher_num(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_ssl_cipher_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_SSL_CIPHER *arg1 = (struct stack_st_SSL_CIPHER *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + SSL_CIPHER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_ssl_cipher_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_SSL_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_ssl_cipher_value" "', argument " "1"" of type '" "struct stack_st_SSL_CIPHER *""'"); + } + arg1 = (struct stack_st_SSL_CIPHER *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_ssl_cipher_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (SSL_CIPHER *)sk_ssl_cipher_value(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_SSL_CIPHER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_get_peer_cert_chain(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct stack_st_X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_get_peer_cert_chain" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (struct stack_st_X509 *)ssl_get_peer_cert_chain(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_num" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)sk_x509_num(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + X509 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_x509_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_value" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_x509_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509 *)sk_x509_value(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_i2d_ssl_session(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + SSL_SESSION *arg2 = (SSL_SESSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "i2d_ssl_session", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_ssl_session" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_ssl_session" "', argument " "2"" of type '" "SSL_SESSION *""'"); + } + arg2 = (SSL_SESSION *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + i2d_ssl_session(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_session_read_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + SSL_SESSION *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_read_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (SSL_SESSION *)ssl_session_read_pem(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_SSL_SESSION, 0); + else { + m2_PyErr_Msg(_ssl_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_session_write_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_SESSION *arg1 = (SSL_SESSION *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_session_write_pem", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_SESSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_session_write_pem" "', argument " "1"" of type '" "SSL_SESSION *""'"); + } + arg1 = (SSL_SESSION *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ssl_session_write_pem" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)ssl_session_write_pem(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_session_cache_mode(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_session_cache_mode", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_session_cache_mode" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_session_cache_mode" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_set_session_cache_mode(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_get_session_cache_mode(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_get_session_cache_mode" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_ctx_get_session_cache_mode(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_ctx_set_cache_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL_CTX *arg1 = (SSL_CTX *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + long result; + + if (!SWIG_Python_UnpackTuple(args, "ssl_ctx_set_cache_size", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_ctx_set_cache_size" "', argument " "1"" of type '" "SSL_CTX *""'"); + } + arg1 = (SSL_CTX *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ssl_ctx_set_cache_size" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)ssl_ctx_set_cache_size(arg1,arg2); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ssl_is_init_finished(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + SSL *arg1 = (SSL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_SSL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ssl_is_init_finished" "', argument " "1"" of type '" "SSL *""'"); + } + arg1 = (SSL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ssl_is_init_finished(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_check_ca(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_check_ca" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_check_ca(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_new", 0, 0, 0)) SWIG_fail; + result = (X509 *)X509_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_dup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_dup" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509 *)X509_dup(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_free" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + X509_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_crl_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_CRL *arg1 = (X509_CRL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_CRL, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_crl_free" "', argument " "1"" of type '" "X509_CRL *""'"); + } + arg1 = (X509_CRL *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + X509_CRL_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_crl_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_CRL *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_crl_new", 0, 0, 0)) SWIG_fail; + result = (X509_CRL *)X509_CRL_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_CRL, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_print" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)X509_print(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_crl_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_CRL *arg2 = (X509_CRL *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_crl_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_crl_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_CRL, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_crl_print" "', argument " "2"" of type '" "X509_CRL *""'"); + } + arg2 = (X509_CRL *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)X509_CRL_print(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_serial_number(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ASN1_INTEGER *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_serial_number" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_INTEGER *)X509_get_serialNumber(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_serial_number(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + ASN1_INTEGER *arg2 = (ASN1_INTEGER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_serial_number", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_serial_number" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_serial_number" "', argument " "2"" of type '" "ASN1_INTEGER *""'"); + } + arg2 = (ASN1_INTEGER *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_set_serialNumber(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + EVP_PKEY *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_pubkey" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EVP_PKEY *)X509_get_pubkey(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_pubkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_pubkey" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_pubkey" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_set_pubkey(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_issuer_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_NAME *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_issuer_name" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_NAME *)X509_get_issuer_name(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_issuer_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + X509_NAME *arg2 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_issuer_name", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_issuer_name" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_issuer_name" "', argument " "2"" of type '" "X509_NAME *""'"); + } + arg2 = (X509_NAME *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_set_issuer_name(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_subject_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_NAME *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_subject_name" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_NAME *)X509_get_subject_name(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_subject_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + X509_NAME *arg2 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_subject_name", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_subject_name" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_subject_name" "', argument " "2"" of type '" "X509_NAME *""'"); + } + arg2 = (X509_NAME *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_set_subject_name(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_cmp_current_time(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_cmp_current_time" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + result = (int)X509_cmp_current_time(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_check_purpose(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + int arg2 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_check_purpose", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_check_purpose" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_check_purpose" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_check_purpose" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_check_purpose(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_check_trust(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + int arg2 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_check_trust", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_check_trust" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_check_trust" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_check_trust" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_check_trust(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_write_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_write_pem", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_write_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_write_pem" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)PEM_write_bio_X509(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_write_pem_file(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + FILE *arg1 = (FILE *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_write_pem_file", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_FILE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_write_pem_file" "', argument " "1"" of type '" "FILE *""'"); + } + arg1 = (FILE *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_write_pem_file" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)PEM_write_X509(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_verify", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_verify" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_verify" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_verify(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_verify_error(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + long arg1 ; + long val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_long(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "x509_get_verify_error" "', argument " "1"" of type '" "long""'"); + } + arg1 = (long)(val1); + result = (char *)X509_verify_cert_error_string(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_add_ext(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + X509_EXTENSION *arg2 = (X509_EXTENSION *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_add_ext", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_add_ext" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_add_ext" "', argument " "2"" of type '" "X509_EXTENSION *""'"); + } + arg2 = (X509_EXTENSION *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_add_ext" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_add_ext(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_ext_count(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_ext_count" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_get_ext_count(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_ext(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + X509_EXTENSION *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_get_ext", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_ext" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_get_ext" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_EXTENSION *)X509_get_ext(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_ext_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_EXTENSION *arg2 = (X509_EXTENSION *) 0 ; + unsigned long arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + unsigned long val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_ext_print", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_ext_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_ext_print" "', argument " "2"" of type '" "X509_EXTENSION *""'"); + } + arg2 = (X509_EXTENSION *)(argp2); + ecode3 = SWIG_AsVal_unsigned_SS_long(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_ext_print" "', argument " "3"" of type '" "unsigned long""'"); + } + arg3 = (unsigned long)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "x509_ext_print" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)X509V3_EXT_print(arg1,arg2,arg3,arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_new", 0, 0, 0)) SWIG_fail; + result = (X509_NAME *)X509_NAME_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_free" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + X509_NAME_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_NAME *arg2 = (X509_NAME *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_print", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_print" "', argument " "2"" of type '" "X509_NAME *""'"); + } + arg2 = (X509_NAME *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_print" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)X509_NAME_print(arg1,arg2,arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_get_entry(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + X509_NAME_ENTRY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_get_entry", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_get_entry" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_get_entry" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_NAME_ENTRY *)X509_NAME_get_entry(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_count(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_count" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_entry_count(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_delete_entry(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + X509_NAME_ENTRY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_delete_entry", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_delete_entry" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_delete_entry" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_NAME_ENTRY *)X509_NAME_delete_entry(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_add_entry(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + X509_NAME_ENTRY *arg2 = (X509_NAME_ENTRY *) 0 ; + int arg3 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_add_entry" "', argument " "2"" of type '" "X509_NAME_ENTRY *""'"); + } + arg2 = (X509_NAME_ENTRY *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "x509_name_add_entry" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_add_entry(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_add_entry_by_obj(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + ASN1_OBJECT *arg2 = (ASN1_OBJECT *) 0 ; + int arg3 ; + unsigned char *arg4 = (unsigned char *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry_by_obj", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry_by_obj" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_add_entry_by_obj" "', argument " "2"" of type '" "ASN1_OBJECT *""'"); + } + arg2 = (ASN1_OBJECT *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry_by_obj" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_add_entry_by_obj" "', argument " "4"" of type '" "unsigned char *""'"); + } + arg4 = (unsigned char *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_add_entry_by_obj" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "x509_name_add_entry_by_obj" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "x509_name_add_entry_by_obj" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_add_entry_by_OBJ(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_add_entry_by_nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + int arg2 ; + int arg3 ; + unsigned char *arg4 = (unsigned char *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry_by_nid", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_add_entry_by_nid" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry_by_nid" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_add_entry_by_nid" "', argument " "4"" of type '" "unsigned char *""'"); + } + arg4 = (unsigned char *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_add_entry_by_nid" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "x509_name_add_entry_by_nid" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "x509_name_add_entry_by_nid" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_add_entry_by_NID(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_print_ex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_NAME *arg2 = (X509_NAME *) 0 ; + int arg3 ; + unsigned long arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + unsigned long val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_print_ex", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_print_ex" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_print_ex" "', argument " "2"" of type '" "X509_NAME *""'"); + } + arg2 = (X509_NAME *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_print_ex" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + ecode4 = SWIG_AsVal_unsigned_SS_long(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "x509_name_print_ex" "', argument " "4"" of type '" "unsigned long""'"); + } + arg4 = (unsigned long)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)X509_NAME_print_ex(arg1,arg2,arg3,arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_hash(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + unsigned long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_hash" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (unsigned long)X509_NAME_hash_old(arg1); + resultobj = SWIG_From_unsigned_SS_long((unsigned long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_get_index_by_nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + int arg2 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_get_index_by_nid", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_get_index_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_get_index_by_nid" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_get_index_by_nid" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_get_index_by_NID(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_new", 0, 0, 0)) SWIG_fail; + result = (X509_NAME_ENTRY *)X509_NAME_ENTRY_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_free" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); + } + arg1 = (X509_NAME_ENTRY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + X509_NAME_ENTRY_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_create_by_nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY **arg1 = (X509_NAME_ENTRY **) 0 ; + int arg2 ; + int arg3 ; + unsigned char *arg4 = (unsigned char *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + int val3 ; + int ecode3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + X509_NAME_ENTRY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_create_by_nid", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_create_by_nid" "', argument " "1"" of type '" "X509_NAME_ENTRY **""'"); + } + arg1 = (X509_NAME_ENTRY **)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_entry_create_by_nid" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_entry_create_by_nid" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_entry_create_by_nid" "', argument " "4"" of type '" "unsigned char *""'"); + } + arg4 = (unsigned char *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_entry_create_by_nid" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + result = (X509_NAME_ENTRY *)X509_NAME_ENTRY_create_by_NID(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_set_object(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; + ASN1_OBJECT *arg2 = (ASN1_OBJECT *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_set_object", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_set_object" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); + } + arg1 = (X509_NAME_ENTRY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_entry_set_object" "', argument " "2"" of type '" "ASN1_OBJECT *""'"); + } + arg2 = (ASN1_OBJECT *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_ENTRY_set_object(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_get_object(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ASN1_OBJECT *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_get_object" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); + } + arg1 = (X509_NAME_ENTRY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_OBJECT *)X509_NAME_ENTRY_get_object(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_get_data(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ASN1_STRING *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_get_data" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); + } + arg1 = (X509_NAME_ENTRY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_STRING *)X509_NAME_ENTRY_get_data(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_set_data(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY *arg1 = (X509_NAME_ENTRY *) 0 ; + int arg2 ; + unsigned char *arg3 = (unsigned char *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_set_data", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_set_data" "', argument " "1"" of type '" "X509_NAME_ENTRY *""'"); + } + arg1 = (X509_NAME_ENTRY *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_entry_set_data" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (PyString_Check(swig_obj[2])) { + Py_ssize_t len; + + arg3 = (unsigned char *)PyString_AsString(swig_obj[2]); + len = PyString_Size(swig_obj[2]); + + + if (len > INT_MAX) { + PyErr_SetString(_x509_err, "object too large"); + return NULL; + } + arg4 = len; + } else { + PyErr_SetString(PyExc_TypeError, "expected string"); + return NULL; + } + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_NAME_ENTRY_set_data(arg1,arg2,(unsigned char const *)arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_new", 0, 0, 0)) SWIG_fail; + result = (X509_REQ *)X509_REQ_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_REQ, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_free" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + X509_REQ_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_REQ *arg2 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_print" "', argument " "2"" of type '" "X509_REQ *""'"); + } + arg2 = (X509_REQ *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)X509_REQ_print(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_get_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + EVP_PKEY *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_get_pubkey" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EVP_PKEY *)X509_REQ_get_pubkey(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_set_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_set_pubkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_set_pubkey" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_set_pubkey" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_REQ_set_pubkey(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_set_subject_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + X509_NAME *arg2 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_set_subject_name", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_set_subject_name" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_set_subject_name" "', argument " "2"" of type '" "X509_NAME *""'"); + } + arg2 = (X509_NAME *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_REQ_set_subject_name(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_verify", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_verify" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_verify" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_REQ_verify(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_sign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_sign", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_sign" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_sign" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "x509_req_sign" "', argument " "3"" of type '" "EVP_MD const *""'"); + } + arg3 = (EVP_MD *)(argp3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_REQ_sign(arg1,arg2,(EVP_MD const *)arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_i2d_x509_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "i2d_x509_bio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_x509_bio" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_x509_bio" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)i2d_X509_bio(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_i2d_x509_req_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_REQ *arg2 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "i2d_x509_req_bio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_x509_req_bio" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_x509_req_bio" "', argument " "2"" of type '" "X509_REQ *""'"); + } + arg2 = (X509_REQ *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)i2d_X509_REQ_bio(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_store_new", 0, 0, 0)) SWIG_fail; + result = (X509_STORE *)X509_STORE_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_STORE, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE *arg1 = (X509_STORE *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_free" "', argument " "1"" of type '" "X509_STORE *""'"); + } + arg1 = (X509_STORE *)(argp1); + X509_STORE_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_add_cert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE *arg1 = (X509_STORE *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_store_add_cert", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_add_cert" "', argument " "1"" of type '" "X509_STORE *""'"); + } + arg1 = (X509_STORE *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_store_add_cert" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)X509_STORE_add_cert(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_set_verify_cb__SWIG_0(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + X509_STORE *arg1 = (X509_STORE *) 0 ; + int (*arg2)(int,X509_STORE_CTX *) = (int (*)(int,X509_STORE_CTX *)) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_set_verify_cb" "', argument " "1"" of type '" "X509_STORE *""'"); + } + arg1 = (X509_STORE *)(argp1); + { + int res = SWIG_ConvertFunctionPtr(swig_obj[1], (void**)(&arg2), SWIGTYPE_p_f_int_p_X509_STORE_CTX__int); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in method '" "x509_store_set_verify_cb" "', argument " "2"" of type '" "int (*)(int,X509_STORE_CTX *)""'"); + } + } + X509_STORE_set_verify_cb(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_get_current_cert(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_current_cert" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + result = (X509 *)X509_STORE_CTX_get_current_cert(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_get_error(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_error" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + result = (int)X509_STORE_CTX_get_error(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_get_error_depth(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_error_depth" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + result = (int)X509_STORE_CTX_get_error_depth(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_free" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + X509_STORE_CTX_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_get1_chain(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + struct stack_st_X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get1_chain" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + result = (struct stack_st_X509 *)X509_STORE_CTX_get1_chain(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_extension_get_critical(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_get_critical" "', argument " "1"" of type '" "X509_EXTENSION *""'"); + } + arg1 = (X509_EXTENSION *)(argp1); + result = (int)X509_EXTENSION_get_critical(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_extension_set_critical(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_extension_set_critical", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_set_critical" "', argument " "1"" of type '" "X509_EXTENSION *""'"); + } + arg1 = (X509_EXTENSION *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_extension_set_critical" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (int)X509_EXTENSION_set_critical(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_set_flags(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE *arg1 = (X509_STORE *) 0 ; + unsigned long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_store_set_flags", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_set_flags" "', argument " "1"" of type '" "X509_STORE *""'"); + } + arg1 = (X509_STORE *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_store_set_flags" "', argument " "2"" of type '" "unsigned long""'"); + } + arg2 = (unsigned long)(val2); + result = (int)X509_STORE_set_flags(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_read_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_read_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (X509 *)x509_read_pem(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509, 0); + else { + m2_PyErr_Msg(_x509_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_d2i_x509(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "d2i_x509" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (X509 *)d2i_x509(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509, 0); + else { + m2_PyErr_Msg(_x509_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__x509_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_x509_err""' of type '""PyObject *""'"); + } + _x509_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__x509_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_x509_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_x509_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + x509_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_d2i_x509_req(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_REQ *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "d2i_x509_req" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (X509_REQ *)d2i_x509_req(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_REQ, 0); + else { + m2_PyErr_Msg(_x509_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_read_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_REQ *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_read_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (X509_REQ *)x509_req_read_pem(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_REQ, 0); + else { + m2_PyErr_Msg(_x509_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_i2d_x509(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_x509" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)i2d_x509(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_write_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + X509_REQ *arg2 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_write_pem", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_write_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_write_pem" "', argument " "2"" of type '" "X509_REQ *""'"); + } + arg2 = (X509_REQ *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)x509_req_write_pem(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_crl_read_pem(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_CRL *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_crl_read_pem" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (X509_CRL *)x509_crl_read_pem(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_CRL, 0); + else { + m2_PyErr_Msg(_x509_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_version(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_version", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_version" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_set_version" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_set_version(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_version(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_version" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)x509_get_version(arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_not_before(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + ASN1_TIME *arg2 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_not_before", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_not_before" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_not_before" "', argument " "2"" of type '" "ASN1_TIME *""'"); + } + arg2 = (ASN1_TIME *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_set_not_before(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_not_before(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ASN1_TIME *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_not_before" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_TIME *)x509_get_not_before(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_set_not_after(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + ASN1_TIME *arg2 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_set_not_after", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_set_not_after" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_set_not_after" "', argument " "2"" of type '" "ASN1_TIME *""'"); + } + arg2 = (ASN1_TIME *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_set_not_after(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_get_not_after(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + ASN1_TIME *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_get_not_after" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_TIME *)x509_get_not_after(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_sign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + EVP_MD *arg3 = (EVP_MD *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_sign", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_sign" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_sign" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "x509_sign" "', argument " "3"" of type '" "EVP_MD *""'"); + } + arg3 = (EVP_MD *)(argp3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_sign(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_gmtime_adj(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + ASN1_TIME *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_gmtime_adj", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_gmtime_adj" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_gmtime_adj" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + result = (ASN1_TIME *)x509_gmtime_adj(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_by_nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_by_nid", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_by_nid" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)x509_name_by_nid(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_set_by_nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + int arg2 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_set_by_nid", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_set_by_nid" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_name_set_by_nid" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_name_set_by_nid(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_add_entry_by_txt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char *arg4 = (char *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject *swig_obj[7] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_add_entry_by_txt", 7, 7, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_add_entry_by_txt" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_add_entry_by_txt" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_add_entry_by_txt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_add_entry_by_txt" "', argument " "4"" of type '" "char *""'"); + } + arg4 = (char *)(buf4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_add_entry_by_txt" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "x509_name_add_entry_by_txt" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(swig_obj[6], &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "x509_name_add_entry_by_txt" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_name_add_entry_by_txt(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_get_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_get_der" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)x509_name_get_der(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_free" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + sk_x509_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_x509_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_push" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_x509_push" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)sk_x509_push(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_pop" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509 *)sk_x509_pop(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_load_locations(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE *arg1 = (X509_STORE *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_store_load_locations", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_load_locations" "', argument " "1"" of type '" "X509_STORE *""'"); + } + arg1 = (X509_STORE *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_store_load_locations" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + result = (int)x509_store_load_locations(arg1,(char const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_type_check" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_type_check" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_name_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_get_subject_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_NAME *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_get_subject_name" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509_NAME *)x509_req_get_subject_name(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_get_version(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + long result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_get_version" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (long)x509_req_get_version(arg1); + resultobj = SWIG_From_long((long)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_set_version(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_set_version", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_set_version" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_req_set_version" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_req_set_version(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_req_add_extensions(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_REQ *arg1 = (X509_REQ *) 0 ; + struct stack_st_X509_EXTENSION *arg2 = (struct stack_st_X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "x509_req_add_extensions", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_REQ, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_req_add_extensions" "', argument " "1"" of type '" "X509_REQ *""'"); + } + arg1 = (X509_REQ *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_req_add_extensions" "', argument " "2"" of type '" "struct stack_st_X509_EXTENSION *""'"); + } + arg2 = (struct stack_st_X509_EXTENSION *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)x509_req_add_extensions(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_entry_create_by_txt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME_ENTRY **arg1 = (X509_NAME_ENTRY **) 0 ; + char *arg2 = (char *) 0 ; + int arg3 ; + char *arg4 = (char *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + X509_NAME_ENTRY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_name_entry_create_by_txt", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_X509_NAME_ENTRY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_entry_create_by_txt" "', argument " "1"" of type '" "X509_NAME_ENTRY **""'"); + } + arg1 = (X509_NAME_ENTRY **)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509_name_entry_create_by_txt" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "x509_name_entry_create_by_txt" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509_name_entry_create_by_txt" "', argument " "4"" of type '" "char *""'"); + } + arg4 = (char *)(buf4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "x509_name_entry_create_by_txt" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + result = (X509_NAME_ENTRY *)x509_name_entry_create_by_txt(arg1,arg2,arg3,arg4,arg5); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_NAME_ENTRY, 0 | 0 ); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509v3_set_nconf(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509V3_CTX *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509v3_set_nconf", 0, 0, 0)) SWIG_fail; + result = (X509V3_CTX *)x509v3_set_nconf(); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509V3_CTX, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509v3_ext_conf(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + X509V3_CTX *arg2 = (X509V3_CTX *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + int res1 ; + void *argp2 = 0 ; + int res2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + PyObject *swig_obj[4] ; + X509_EXTENSION *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509v3_ext_conf", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509v3_ext_conf" "', argument " "1"" of type '" "void *""'"); + } + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509V3_CTX, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "x509v3_ext_conf" "', argument " "2"" of type '" "X509V3_CTX *""'"); + } + arg2 = (X509V3_CTX *)(argp2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "x509v3_ext_conf" "', argument " "3"" of type '" "char *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "x509v3_ext_conf" "', argument " "4"" of type '" "char *""'"); + } + arg4 = (char *)(buf4); + result = (X509_EXTENSION *)x509v3_ext_conf(arg1,arg2,arg3,arg4); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_X509_EXTENSION, 0); + else { + m2_PyErr_Msg(_x509_err); + resultobj = NULL; + } + } + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return resultobj; +fail: + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_extension_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_free" "', argument " "1"" of type '" "X509_EXTENSION *""'"); + } + arg1 = (X509_EXTENSION *)(argp1); + x509_extension_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_extension_get_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_EXTENSION *arg1 = (X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_extension_get_name" "', argument " "1"" of type '" "X509_EXTENSION *""'"); + } + arg1 = (X509_EXTENSION *)(argp1); + result = (PyObject *)x509_extension_get_name(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_extension_new_null(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509_EXTENSION *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_x509_extension_new_null", 0, 0, 0)) SWIG_fail; + result = (struct stack_st_X509_EXTENSION *)sk_x509_extension_new_null(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_extension_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_free" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); + } + arg1 = (struct stack_st_X509_EXTENSION *)(argp1); + sk_x509_extension_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_extension_push(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; + X509_EXTENSION *arg2 = (X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "sk_x509_extension_push", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_push" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); + } + arg1 = (struct stack_st_X509_EXTENSION *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "sk_x509_extension_push" "', argument " "2"" of type '" "X509_EXTENSION *""'"); + } + arg2 = (X509_EXTENSION *)(argp2); + result = (int)sk_x509_extension_push(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_extension_pop(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + X509_EXTENSION *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_pop" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); + } + arg1 = (struct stack_st_X509_EXTENSION *)(argp1); + result = (X509_EXTENSION *)sk_x509_extension_pop(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_extension_num(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_num" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); + } + arg1 = (struct stack_st_X509_EXTENSION *)(argp1); + result = (int)sk_x509_extension_num(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_extension_value(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509_EXTENSION *arg1 = (struct stack_st_X509_EXTENSION *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + X509_EXTENSION *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_x509_extension_value", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509_EXTENSION, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "sk_x509_extension_value" "', argument " "1"" of type '" "struct stack_st_X509_EXTENSION *""'"); + } + arg1 = (struct stack_st_X509_EXTENSION *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "sk_x509_extension_value" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (X509_EXTENSION *)sk_x509_extension_value(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509_EXTENSION, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_get_app_data(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + void *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_app_data" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + result = (void *)x509_store_ctx_get_app_data(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_ctx_get_ex_data(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_STORE_CTX *arg1 = (X509_STORE_CTX *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + void *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "x509_store_ctx_get_ex_data", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE_CTX, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_ctx_get_ex_data" "', argument " "1"" of type '" "X509_STORE_CTX *""'"); + } + arg1 = (X509_STORE_CTX *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "x509_store_ctx_get_ex_data" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + result = (void *)x509_store_ctx_get_ex_data(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_set_verify_cb__SWIG_1(PyObject *self, Py_ssize_t nobjs, PyObject **swig_obj) { + PyObject *resultobj = 0; + X509_STORE *arg1 = (X509_STORE *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_store_set_verify_cb" "', argument " "1"" of type '" "X509_STORE *""'"); + } + arg1 = (X509_STORE *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + x509_store_set_verify_cb(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_store_set_verify_cb(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[3] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "x509_store_set_verify_cb", 0, 2, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_X509_STORE, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *ptr = 0; + int res = SWIG_ConvertFunctionPtr(argv[1], &ptr, SWIGTYPE_p_f_int_p_X509_STORE_CTX__int); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_x509_store_set_verify_cb__SWIG_0(self, argc, argv); + } + } + } + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_X509_STORE, 0); + _v = SWIG_CheckState(res); + if (_v) { + _v = (argv[1] != 0); + if (_v) { + return _wrap_x509_store_set_verify_cb__SWIG_1(self, argc, argv); + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'x509_store_set_verify_cb'.\n" + " Possible C/C++ prototypes are:\n" + " X509_STORE_set_verify_cb(X509_STORE *,int (*)(int,X509_STORE_CTX *))\n" + " x509_store_set_verify_cb(X509_STORE *,PyObject *)\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_make_stack_from_der_sequence(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + struct stack_st_X509 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (struct stack_st_X509 *)make_stack_from_der_sequence(arg1); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_stack_st_X509, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_sk_x509_new_null(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "sk_x509_new_null", 0, 0, 0)) SWIG_fail; + result = (struct stack_st_X509 *)sk_x509_new_null(); + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_stack_st_X509, 0); + else { + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_get_der_encoding_stack(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "get_der_encoding_stack" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)get_der_encoding_stack(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_x509_name_oneline(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509_NAME *arg1 = (X509_NAME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509_NAME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "x509_name_oneline" "', argument " "1"" of type '" "X509_NAME *""'"); + } + arg1 = (X509_NAME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)x509_name_oneline(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + { + if (result != NULL) + OPENSSL_free(result); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_object_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_OBJECT *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_object_new", 0, 0, 0)) SWIG_fail; + result = (ASN1_OBJECT *)ASN1_OBJECT_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_object_create(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + unsigned char *arg2 = (unsigned char *) 0 ; + int arg3 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + int val1 ; + int ecode1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + PyObject *swig_obj[5] ; + ASN1_OBJECT *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_object_create", 5, 5, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "asn1_object_create" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_object_create" "', argument " "2"" of type '" "unsigned char *""'"); + } + arg2 = (unsigned char *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "asn1_object_create" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + res4 = SWIG_AsCharPtrAndSize(swig_obj[3], &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "asn1_object_create" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + res5 = SWIG_AsCharPtrAndSize(swig_obj[4], &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "asn1_object_create" "', argument " "5"" of type '" "char const *""'"); + } + arg5 = (char *)(buf5); + result = (ASN1_OBJECT *)ASN1_OBJECT_create(arg1,arg2,arg3,(char const *)arg4,(char const *)arg5); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); + return resultobj; +fail: + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_object_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_object_free" "', argument " "1"" of type '" "ASN1_OBJECT *""'"); + } + arg1 = (ASN1_OBJECT *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ASN1_OBJECT_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_i2d_asn1_object(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; + unsigned char **arg2 = (unsigned char **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "i2d_asn1_object", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "i2d_asn1_object" "', argument " "1"" of type '" "ASN1_OBJECT *""'"); + } + arg1 = (ASN1_OBJECT *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "i2d_asn1_object" "', argument " "2"" of type '" "unsigned char **""'"); + } + arg2 = (unsigned char **)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)i2d_ASN1_OBJECT(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_d2i_asn1_object(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_OBJECT **arg1 = (ASN1_OBJECT **) 0 ; + unsigned char **arg2 = (unsigned char **) 0 ; + long arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + long val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + ASN1_OBJECT *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "d2i_asn1_object", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "d2i_asn1_object" "', argument " "1"" of type '" "ASN1_OBJECT **""'"); + } + arg1 = (ASN1_OBJECT **)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_p_unsigned_char, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "d2i_asn1_object" "', argument " "2"" of type '" "unsigned char const **""'"); + } + arg2 = (unsigned char **)(argp2); + ecode3 = SWIG_AsVal_long(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "d2i_asn1_object" "', argument " "3"" of type '" "long""'"); + } + arg3 = (long)(val3); + result = (ASN1_OBJECT *)d2i_ASN1_OBJECT(arg1,(unsigned char const **)arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_bit_string_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_BIT_STRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_bit_string_new", 0, 0, 0)) SWIG_fail; + result = (ASN1_BIT_STRING *)ASN1_BIT_STRING_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_BIT_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_string_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_STRING *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_string_new", 0, 0, 0)) SWIG_fail; + result = (ASN1_STRING *)ASN1_STRING_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_STRING, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_string_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_STRING *arg1 = (ASN1_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_free" "', argument " "1"" of type '" "ASN1_STRING *""'"); + } + arg1 = (ASN1_STRING *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ASN1_STRING_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_string_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_STRING *arg1 = (ASN1_STRING *) 0 ; + void *arg2 = (void *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_string_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_set" "', argument " "1"" of type '" "ASN1_STRING *""'"); + } + arg1 = (ASN1_STRING *)(argp1); + { + if (PyBytes_Check(swig_obj[1])) { + Py_ssize_t len; + + arg2 = PyBytes_AsString(swig_obj[1]); + len = PyBytes_Size(swig_obj[1]); + + if (len > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "object too large"); + return NULL; + } + arg3 = len; + } + else { + PyErr_SetString(PyExc_TypeError, "expected string"); + return NULL; + } + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ASN1_STRING_set(arg1,(void const *)arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_string_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + ASN1_STRING *arg2 = (ASN1_STRING *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_string_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_string_print" "', argument " "2"" of type '" "ASN1_STRING *""'"); + } + arg2 = (ASN1_STRING *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)ASN1_STRING_print(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_string_print_ex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + ASN1_STRING *arg2 = (ASN1_STRING *) 0 ; + unsigned long arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + unsigned long val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_string_print_ex", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_string_print_ex" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_STRING, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_string_print_ex" "', argument " "2"" of type '" "ASN1_STRING *""'"); + } + arg2 = (ASN1_STRING *)(argp2); + ecode3 = SWIG_AsVal_unsigned_SS_long(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "asn1_string_print_ex" "', argument " "3"" of type '" "unsigned long""'"); + } + arg3 = (unsigned long)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)ASN1_STRING_print_ex(arg1,arg2,arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_time_new", 0, 0, 0)) SWIG_fail; + result = (ASN1_TIME *)ASN1_TIME_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_free" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ASN1_TIME_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_check" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ASN1_TIME_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + long arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + long val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + ASN1_TIME *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_time_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_set" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + ecode2 = SWIG_AsVal_long(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "asn1_time_set" "', argument " "2"" of type '" "long""'"); + } + arg2 = (long)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_TIME *)ASN1_TIME_set(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_set_string(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_time_set_string", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_set_string" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_time_set_string" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ASN1_TIME_set_string(arg1,(char const *)arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_print(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + ASN1_TIME *arg2 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_time_print", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_print" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_time_print" "', argument " "2"" of type '" "ASN1_TIME *""'"); + } + arg2 = (ASN1_TIME *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)ASN1_TIME_print(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_integer_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_INTEGER *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "asn1_integer_new", 0, 0, 0)) SWIG_fail; + result = (ASN1_INTEGER *)ASN1_INTEGER_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_integer_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_free" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); + } + arg1 = (ASN1_INTEGER *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + ASN1_INTEGER_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_integer_cmp(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; + ASN1_INTEGER *arg2 = (ASN1_INTEGER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_integer_cmp", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_cmp" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); + } + arg1 = (ASN1_INTEGER *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "asn1_integer_cmp" "', argument " "2"" of type '" "ASN1_INTEGER *""'"); + } + arg2 = (ASN1_INTEGER *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ASN1_INTEGER_cmp(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_time_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_TIME *arg1 = (ASN1_TIME *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_TIME, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_time_type_check" "', argument " "1"" of type '" "ASN1_TIME *""'"); + } + arg1 = (ASN1_TIME *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)asn1_time_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_integer_get(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_get" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); + } + arg1 = (ASN1_INTEGER *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)asn1_integer_get(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_asn1_integer_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_INTEGER *arg1 = (ASN1_INTEGER *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "asn1_integer_set", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_INTEGER, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "asn1_integer_set" "', argument " "1"" of type '" "ASN1_INTEGER *""'"); + } + arg1 = (ASN1_INTEGER *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)asn1_integer_set(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_new", 0, 0, 0)) SWIG_fail; + result = (PKCS7 *)PKCS7_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PKCS7, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_free" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + PKCS7_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_add_certificate(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + X509 *arg2 = (X509 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_add_certificate", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_add_certificate" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_add_certificate" "', argument " "2"" of type '" "X509 *""'"); + } + arg2 = (X509 *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + PKCS7_add_certificate(arg1,arg2); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__pkcs7_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_pkcs7_err""' of type '""PyObject *""'"); + } + _pkcs7_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__pkcs7_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_pkcs7_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN int Swig_var__smime_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_smime_err""' of type '""PyObject *""'"); + } + _smime_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__smime_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_smime_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + pkcs7_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_smime_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + smime_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_decrypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + X509 *arg3 = (X509 *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_decrypt", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_decrypt" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_decrypt" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_decrypt" "', argument " "3"" of type '" "X509 *""'"); + } + arg3 = (X509 *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs7_decrypt" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)pkcs7_decrypt(arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_encrypt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + struct stack_st_X509 *arg1 = (struct stack_st_X509 *) 0 ; + BIO *arg2 = (BIO *) 0 ; + EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PKCS7 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_encrypt", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_encrypt" "', argument " "1"" of type '" "struct stack_st_X509 *""'"); + } + arg1 = (struct stack_st_X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_encrypt" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_encrypt" "', argument " "3"" of type '" "EVP_CIPHER *""'"); + } + arg3 = (EVP_CIPHER *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs7_encrypt" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (PKCS7 *)pkcs7_encrypt(arg1,arg2,arg3,arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); + else { + m2_PyErr_Msg(_smime_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_sign1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + struct stack_st_X509 *arg3 = (struct stack_st_X509 *) 0 ; + BIO *arg4 = (BIO *) 0 ; + EVP_MD *arg5 = (EVP_MD *) 0 ; + int arg6 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + int val6 ; + int ecode6 = 0 ; + PyObject *swig_obj[6] ; + PKCS7 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_sign1", 6, 6, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_sign1" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_sign1" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_sign1" "', argument " "3"" of type '" "struct stack_st_X509 *""'"); + } + arg3 = (struct stack_st_X509 *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pkcs7_sign1" "', argument " "4"" of type '" "BIO *""'"); + } + arg4 = (BIO *)(argp4); + res5 = SWIG_ConvertPtr(swig_obj[4], &argp5,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "pkcs7_sign1" "', argument " "5"" of type '" "EVP_MD *""'"); + } + arg5 = (EVP_MD *)(argp5); + ecode6 = SWIG_AsVal_int(swig_obj[5], &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "pkcs7_sign1" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg5) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (PKCS7 *)pkcs7_sign1(arg1,arg2,arg3,arg4,arg5,arg6); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); + else { + m2_PyErr_Msg(_smime_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_sign0(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + X509 *arg1 = (X509 *) 0 ; + EVP_PKEY *arg2 = (EVP_PKEY *) 0 ; + BIO *arg3 = (BIO *) 0 ; + EVP_MD *arg4 = (EVP_MD *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + PKCS7 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_sign0", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_X509, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_sign0" "', argument " "1"" of type '" "X509 *""'"); + } + arg1 = (X509 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_sign0" "', argument " "2"" of type '" "EVP_PKEY *""'"); + } + arg2 = (EVP_PKEY *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_sign0" "', argument " "3"" of type '" "BIO *""'"); + } + arg3 = (BIO *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_EVP_MD, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pkcs7_sign0" "', argument " "4"" of type '" "EVP_MD *""'"); + } + arg4 = (EVP_MD *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "pkcs7_sign0" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (PKCS7 *)pkcs7_sign0(arg1,arg2,arg3,arg4,arg5); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); + else { + m2_PyErr_Msg(_smime_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_read_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PKCS7 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_read_bio" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (PKCS7 *)pkcs7_read_bio(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); + else { + m2_PyErr_Msg(_pkcs7_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_read_bio_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PKCS7 *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_read_bio_der" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (PKCS7 *)pkcs7_read_bio_der(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (result != NULL) + resultobj = SWIG_NewPointerObj(result, SWIGTYPE_p_PKCS7, 0); + else { + m2_PyErr_Msg(_pkcs7_err); + resultobj = NULL; + } + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_verify1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + struct stack_st_X509 *arg2 = (struct stack_st_X509 *) 0 ; + X509_STORE *arg3 = (X509_STORE *) 0 ; + BIO *arg4 = (BIO *) 0 ; + int arg5 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + void *argp4 = 0 ; + int res4 = 0 ; + int val5 ; + int ecode5 = 0 ; + PyObject *swig_obj[5] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_verify1", 5, 5, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_verify1" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_verify1" "', argument " "2"" of type '" "struct stack_st_X509 *""'"); + } + arg2 = (struct stack_st_X509 *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_verify1" "', argument " "3"" of type '" "X509_STORE *""'"); + } + arg3 = (X509_STORE *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3], &argp4,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "pkcs7_verify1" "', argument " "4"" of type '" "BIO *""'"); + } + arg4 = (BIO *)(argp4); + ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "pkcs7_verify1" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)pkcs7_verify1(arg1,arg2,arg3,arg4,arg5); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_verify0(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + struct stack_st_X509 *arg2 = (struct stack_st_X509 *) 0 ; + X509_STORE *arg3 = (X509_STORE *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_verify0", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_verify0" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_verify0" "', argument " "2"" of type '" "struct stack_st_X509 *""'"); + } + arg2 = (struct stack_st_X509 *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_X509_STORE, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "pkcs7_verify0" "', argument " "3"" of type '" "X509_STORE *""'"); + } + arg3 = (X509_STORE *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "pkcs7_verify0" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)pkcs7_verify0(arg1,arg2,arg3,arg4); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_smime_write_pkcs7_multi(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PKCS7 *arg2 = (PKCS7 *) 0 ; + BIO *arg3 = (BIO *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "smime_write_pkcs7_multi", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_write_pkcs7_multi" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "smime_write_pkcs7_multi" "', argument " "2"" of type '" "PKCS7 *""'"); + } + arg2 = (PKCS7 *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "smime_write_pkcs7_multi" "', argument " "3"" of type '" "BIO *""'"); + } + arg3 = (BIO *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "smime_write_pkcs7_multi" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)smime_write_pkcs7_multi(arg1,arg2,arg3,arg4); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_smime_write_pkcs7(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PKCS7 *arg2 = (PKCS7 *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "smime_write_pkcs7", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_write_pkcs7" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "smime_write_pkcs7" "', argument " "2"" of type '" "PKCS7 *""'"); + } + arg2 = (PKCS7 *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "smime_write_pkcs7" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)smime_write_pkcs7(arg1,arg2,arg3); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_smime_read_pkcs7(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_read_pkcs7" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)smime_read_pkcs7(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_write_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_write_bio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_write_bio" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_write_bio" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)pkcs7_write_bio(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_write_bio_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_write_bio_der", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_write_bio_der" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_write_bio_der" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)pkcs7_write_bio_der(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_type_nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_type_nid" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)pkcs7_type_nid(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_type_sn(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_type_sn" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)pkcs7_type_sn(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_smime_crlf_copy(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "smime_crlf_copy", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "smime_crlf_copy" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "smime_crlf_copy" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)smime_crlf_copy(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_pkcs7_get0_signers(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PKCS7 *arg1 = (PKCS7 *) 0 ; + struct stack_st_X509 *arg2 = (struct stack_st_X509 *) 0 ; + int arg3 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + int val3 ; + int ecode3 = 0 ; + PyObject *swig_obj[3] ; + struct stack_st_X509 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "pkcs7_get0_signers", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_PKCS7, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "pkcs7_get0_signers" "', argument " "1"" of type '" "PKCS7 *""'"); + } + arg1 = (PKCS7 *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_stack_st_X509, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "pkcs7_get0_signers" "', argument " "2"" of type '" "struct stack_st_X509 *""'"); + } + arg2 = (struct stack_st_X509 *)(argp2); + ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "pkcs7_get0_signers" "', argument " "3"" of type '" "int""'"); + } + arg3 = (int)(val3); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (struct stack_st_X509 *)pkcs7_get0_signers(arg1,arg2,arg3); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_stack_st_X509, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__util_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_util_err""' of type '""PyObject *""'"); + } + _util_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__util_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_util_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_util_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + util_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_util_hex_to_string(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (PyObject *)util_hex_to_string(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_util_string_to_hex(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (PyObject *)util_string_to_hex(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ec_key_new", 0, 0, 0)) SWIG_fail; + result = (EC_KEY *)EC_KEY_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_free" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + EC_KEY_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_size(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_size" "', argument " "1"" of type '" "EC_KEY const *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ECDSA_size((EC_KEY const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_gen_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_gen_key" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EC_KEY_generate_key(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_check_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_check_key" "', argument " "1"" of type '" "EC_KEY const *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)EC_KEY_check_key((EC_KEY const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int Swig_var__ec_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_ec_err""' of type '""PyObject *""'"); + } + _ec_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__ec_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_ec_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_ec_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + ec_init(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_get_builtin_curves(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ec_get_builtin_curves", 0, 0, 0)) SWIG_fail; + result = (PyObject *)ec_get_builtin_curves(); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_new_by_curve_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + EC_KEY *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ec_key_new_by_curve_name" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (EC_KEY *)ec_key_new_by_curve_name(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_get_public_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_get_public_der" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ec_key_get_public_der(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_get_public_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_get_public_key" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ec_key_get_public_key(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_read_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + EC_KEY *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_read_pubkey" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (EC_KEY *)ec_key_read_pubkey(arg1); + SWIG_PYTHON_THREAD_END_ALLOW; + } + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_write_pubkey(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + BIO *arg2 = (BIO *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ec_key_write_pubkey", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_write_pubkey" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ec_key_write_pubkey" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + SWIG_PYTHON_THREAD_BEGIN_ALLOW; + result = (int)ec_key_write_pubkey(arg1,arg2); + SWIG_PYTHON_THREAD_END_ALLOW; + } + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_read_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + BIO *arg1 = (BIO *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + EC_KEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ec_key_read_bio", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_read_bio" "', argument " "1"" of type '" "BIO *""'"); + } + arg1 = (BIO *)(argp1); + { + if (!PyCallable_Check(swig_obj[1])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EC_KEY *)ec_key_read_bio(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_write_bio(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + BIO *arg2 = (BIO *) 0 ; + EVP_CIPHER *arg3 = (EVP_CIPHER *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ec_key_write_bio", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_write_bio" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ec_key_write_bio" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_EVP_CIPHER, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ec_key_write_bio" "', argument " "3"" of type '" "EVP_CIPHER *""'"); + } + arg3 = (EVP_CIPHER *)(argp3); + { + if (!PyCallable_Check(swig_obj[3])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg4) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ec_key_write_bio(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_write_bio_no_cipher(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + BIO *arg2 = (BIO *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ec_key_write_bio_no_cipher", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_write_bio_no_cipher" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_BIO, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ec_key_write_bio_no_cipher" "', argument " "2"" of type '" "BIO *""'"); + } + arg2 = (BIO *)(argp2); + { + if (!PyCallable_Check(swig_obj[2])) { + PyErr_SetString(PyExc_TypeError, "expected PyCallable"); + return NULL; + } + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ec_key_write_bio_no_cipher(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdsa_sig_get_r(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ECDSA_SIG *arg1 = (ECDSA_SIG *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ECDSA_SIG, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sig_get_r" "', argument " "1"" of type '" "ECDSA_SIG *""'"); + } + arg1 = (ECDSA_SIG *)(argp1); + result = (PyObject *)ecdsa_sig_get_r(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdsa_sig_get_s(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ECDSA_SIG *arg1 = (ECDSA_SIG *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + PyObject *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ECDSA_SIG, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sig_get_s" "', argument " "1"" of type '" "ECDSA_SIG *""'"); + } + arg1 = (ECDSA_SIG *)(argp1); + result = (PyObject *)ecdsa_sig_get_s(arg1); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdsa_sign(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ecdsa_sign", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sign" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ecdsa_sign(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdsa_verify(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + PyObject *arg4 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ecdsa_verify", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_verify" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + arg4=swig_obj[3]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ecdsa_verify(arg1,arg2,arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdsa_sign_asn1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ecdsa_sign_asn1", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_sign_asn1" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ecdsa_sign_asn1(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdsa_verify_asn1(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + PyObject *arg2 = (PyObject *) 0 ; + PyObject *arg3 = (PyObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[3] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "ecdsa_verify_asn1", 3, 3, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdsa_verify_asn1" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + arg2=swig_obj[1]; + } + { + arg3=swig_obj[2]; + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ecdsa_verify_asn1(arg1,arg2,arg3); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ecdh_compute_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + EC_KEY *arg2 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + void *argp2 = 0 ; + int res2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ecdh_compute_key", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ecdh_compute_key" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ecdh_compute_key" "', argument " "2"" of type '" "EC_KEY *""'"); + } + arg2 = (EC_KEY *)(argp2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)ecdh_compute_key(arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_from_pubkey_der(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + EC_KEY *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + result = (EC_KEY *)ec_key_from_pubkey_der(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_from_pubkey_params(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + PyObject *arg2 = (PyObject *) 0 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[2] ; + EC_KEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ec_key_from_pubkey_params", 2, 2, swig_obj)) SWIG_fail; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "ec_key_from_pubkey_params" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + { + arg2=swig_obj[1]; + } + result = (EC_KEY *)ec_key_from_pubkey_params(arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EC_KEY, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_keylen(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_keylen" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ec_key_keylen(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ec_key_type_check(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + EC_KEY *arg1 = (EC_KEY *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_EC_KEY, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ec_key_type_check" "', argument " "1"" of type '" "EC_KEY *""'"); + } + arg1 = (EC_KEY *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ec_key_type_check(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_load_builtin_engines(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "engine_load_builtin_engines", 0, 0, 0)) SWIG_fail; + ENGINE_load_builtin_engines(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_load_dynamic(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "engine_load_dynamic", 0, 0, 0)) SWIG_fail; + ENGINE_load_dynamic(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_load_openssl(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "engine_load_openssl", 0, 0, 0)) SWIG_fail; + ENGINE_load_openssl(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_cleanup(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + + if (!SWIG_Python_UnpackTuple(args, "engine_cleanup", 0, 0, 0)) SWIG_fail; + ENGINE_cleanup(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "engine_new", 0, 0, 0)) SWIG_fail; + result = (ENGINE *)ENGINE_new(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ENGINE, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_by_id(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + ENGINE *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_by_id" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ENGINE *)ENGINE_by_id((char const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ENGINE, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_free" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ENGINE_free(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_init(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_init" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ENGINE_init(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_finish(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_finish" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ENGINE_finish(arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_get_id(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_get_id" "', argument " "1"" of type '" "ENGINE const *""'"); + } + arg1 = (ENGINE *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)ENGINE_get_id((ENGINE const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_get_name(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_get_name" "', argument " "1"" of type '" "ENGINE const *""'"); + } + arg1 = (ENGINE *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (char *)ENGINE_get_name((ENGINE const *)arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_ctrl_cmd_string(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + int arg4 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "engine_ctrl_cmd_string", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_ctrl_cmd_string" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_ctrl_cmd_string" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(swig_obj[2], &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "engine_ctrl_cmd_string" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "engine_ctrl_cmd_string" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ENGINE_ctrl_cmd_string(arg1,(char const *)arg2,(char const *)arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_ui_openssl(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + UI_METHOD *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "ui_openssl", 0, 0, 0)) SWIG_fail; + result = (UI_METHOD *)UI_OpenSSL(); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_UI_METHOD, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__cbd_t_password_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + _cbd_t *arg1 = (_cbd_t *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_password_set" "', argument " "1"" of type '" "_cbd_t *""'"); + } + arg1 = (_cbd_t *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_cbd_t_password_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + if (arg1->password) free((char*)arg1->password); + if (arg2) { + size_t size = strlen((const char *)(arg2)) + 1; + arg1->password = (char *)(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); + } else { + arg1->password = 0; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap__cbd_t_password_get(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + _cbd_t *arg1 = (_cbd_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "_cbd_t_password_get", 0, 0, 0)) SWIG_fail; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_password_get" "', argument " "1"" of type '" "_cbd_t *""'"); + } + arg1 = (_cbd_t *)(argp1); + result = (char *) ((arg1)->password); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap__cbd_t_prompt_set(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + _cbd_t *arg1 = (_cbd_t *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_prompt_set" "', argument " "1"" of type '" "_cbd_t *""'"); + } + arg1 = (_cbd_t *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "_cbd_t_prompt_set" "', argument " "2"" of type '" "char *""'"); + } + arg2 = (char *)(buf2); + if (arg1->prompt) free((char*)arg1->prompt); + if (arg2) { + size_t size = strlen((const char *)(arg2)) + 1; + arg1->prompt = (char *)(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); + } else { + arg1->prompt = 0; + } + resultobj = SWIG_Py_Void(); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap__cbd_t_prompt_get(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + _cbd_t *arg1 = (_cbd_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "_cbd_t_prompt_get", 0, 0, 0)) SWIG_fail; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_cbd_t_prompt_get" "', argument " "1"" of type '" "_cbd_t *""'"); + } + arg1 = (_cbd_t *)(argp1); + result = (char *) ((arg1)->prompt); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN int _wrap_new__cbd_t(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + _cbd_t *result = 0 ; + + if (!SWIG_Python_CheckNoKeywords(kwargs, "new__cbd_t")) SWIG_fail; + if (!SWIG_Python_UnpackTuple(args, "new__cbd_t", 0, 0, 0)) SWIG_fail; + result = (_cbd_t *)calloc(1, sizeof(_cbd_t)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p__cbd_t, SWIG_BUILTIN_INIT | 0 ); + return resultobj == Py_None ? -1 : 0; +fail: + return -1; +} + + +SWIGINTERN PyObject *_wrap_delete__cbd_t(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + _cbd_t *arg1 = (_cbd_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!SWIG_Python_UnpackTuple(args, "delete__cbd_t", 0, 0, 0)) SWIG_fail; + res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p__cbd_t, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__cbd_t" "', argument " "1"" of type '" "_cbd_t *""'"); + } + arg1 = (_cbd_t *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGPY_DESTRUCTOR_CLOSURE(_wrap_delete__cbd_t) /* defines _wrap_delete__cbd_t_destructor_closure */ + +SWIGINTERN PyObject *_wrap_engine_pkcs11_data_new(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + void *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_pkcs11_data_new" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + result = (void *)engine_pkcs11_data_new((char const *)arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_void, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_pkcs11_data_free(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + void *arg1 = (void *) 0 ; + int res1 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0],SWIG_as_voidptrptr(&arg1), 0, 0); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_pkcs11_data_free" "', argument " "1"" of type '" "void *""'"); + } + engine_pkcs11_data_free(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_load_private_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + char *arg2 = (char *) 0 ; + UI_METHOD *arg3 = (UI_METHOD *) 0 ; + void *arg4 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + EVP_PKEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "engine_load_private_key", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_load_private_key" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_load_private_key" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_UI_METHOD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "engine_load_private_key" "', argument " "3"" of type '" "UI_METHOD *""'"); + } + arg3 = (UI_METHOD *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "engine_load_private_key" "', argument " "4"" of type '" "void *""'"); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EVP_PKEY *)ENGINE_load_private_key(arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_load_public_key(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + char *arg2 = (char *) 0 ; + UI_METHOD *arg3 = (UI_METHOD *) 0 ; + void *arg4 = (void *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int res4 ; + PyObject *swig_obj[4] ; + EVP_PKEY *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "engine_load_public_key", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_load_public_key" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_load_public_key" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_UI_METHOD, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "engine_load_public_key" "', argument " "3"" of type '" "UI_METHOD *""'"); + } + arg3 = (UI_METHOD *)(argp3); + res4 = SWIG_ConvertPtr(swig_obj[3],SWIG_as_voidptrptr(&arg4), 0, 0); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "engine_load_public_key" "', argument " "4"" of type '" "void *""'"); + } + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (EVP_PKEY *)ENGINE_load_public_key(arg1,(char const *)arg2,arg3,arg4); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_EVP_PKEY, 0 | 0 ); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN int Swig_var__engine_err_set(PyObject *_val) { + { + void *argp = 0; + int res = SWIG_ConvertPtr(_val, &argp, SWIGTYPE_p_PyObject, 0 ); + if (!SWIG_IsOK(res)) { + SWIG_exception_fail(SWIG_ArgError(res), "in variable '""_engine_err""' of type '""PyObject *""'"); + } + _engine_err = (PyObject *)(argp); + } + return 0; +fail: + return 1; +} + + +SWIGINTERN PyObject *Swig_var__engine_err_get(void) { + PyObject *pyobj = 0; + PyObject *self = 0; + + (void)self; + pyobj = SWIG_NewPointerObj(SWIG_as_voidptr(_engine_err), SWIGTYPE_p_PyObject, 0 ); + return pyobj; +} + + +SWIGINTERN PyObject *_wrap_engine_init_error(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + PyObject *arg1 = (PyObject *) 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + { + arg1=swig_obj[0]; + } + engine_init_error(arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_load_certificate(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + char *arg2 = (char *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + PyObject *swig_obj[2] ; + X509 *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "engine_load_certificate", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_load_certificate" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + res2 = SWIG_AsCharPtrAndSize(swig_obj[1], &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "engine_load_certificate" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + { + if (!arg2) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (X509 *)engine_load_certificate(arg1,(char const *)arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_X509, 0 | 0 ); + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_engine_set_default(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ENGINE *arg1 = (ENGINE *) 0 ; + unsigned int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + unsigned int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "engine_set_default", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ENGINE, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "engine_set_default" "', argument " "1"" of type '" "ENGINE *""'"); + } + arg1 = (ENGINE *)(argp1); + ecode2 = SWIG_AsVal_unsigned_SS_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "engine_set_default" "', argument " "2"" of type '" "unsigned int""'"); + } + arg2 = (unsigned int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)ENGINE_set_default(arg1,arg2); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_nid2obj(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + ASN1_OBJECT *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "obj_nid2obj" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (ASN1_OBJECT *)OBJ_nid2obj(arg1); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_nid2ln(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "obj_nid2ln" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (char *)OBJ_nid2ln(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_nid2sn(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + int arg1 ; + int val1 ; + int ecode1 = 0 ; + PyObject *swig_obj[1] ; + char *result = 0 ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + ecode1 = SWIG_AsVal_int(swig_obj[0], &val1); + if (!SWIG_IsOK(ecode1)) { + SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "obj_nid2sn" "', argument " "1"" of type '" "int""'"); + } + arg1 = (int)(val1); + result = (char *)OBJ_nid2sn(arg1); + resultobj = SWIG_FromCharPtr((const char *)result); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_obj2nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_obj2nid" "', argument " "1"" of type '" "ASN1_OBJECT const *""'"); + } + arg1 = (ASN1_OBJECT *)(argp1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)OBJ_obj2nid((ASN1_OBJECT const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_ln2nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_ln2nid" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)OBJ_ln2nid((char const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_sn2nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_sn2nid" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)OBJ_sn2nid((char const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_txt2nid(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + PyObject *swig_obj[1] ; + int result; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_txt2nid" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)OBJ_txt2nid((char const *)arg1); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_txt2obj(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + ASN1_OBJECT *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "obj_txt2obj", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_txt2obj" "', argument " "1"" of type '" "char const *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "obj_txt2obj" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (ASN1_OBJECT *)OBJ_txt2obj((char const *)arg1,arg2); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap__obj_obj2txt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + char *arg1 = (char *) 0 ; + int arg2 ; + ASN1_OBJECT *arg3 = (ASN1_OBJECT *) 0 ; + int arg4 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int val2 ; + int ecode2 = 0 ; + void *argp3 = 0 ; + int res3 = 0 ; + int val4 ; + int ecode4 = 0 ; + PyObject *swig_obj[4] ; + int result; + + if (!SWIG_Python_UnpackTuple(args, "_obj_obj2txt", 4, 4, swig_obj)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(swig_obj[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "_obj_obj2txt" "', argument " "1"" of type '" "char *""'"); + } + arg1 = (char *)(buf1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "_obj_obj2txt" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "_obj_obj2txt" "', argument " "3"" of type '" "ASN1_OBJECT const *""'"); + } + arg3 = (ASN1_OBJECT *)(argp3); + ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "_obj_obj2txt" "', argument " "4"" of type '" "int""'"); + } + arg4 = (int)(val4); + { + if (!arg3) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (int)OBJ_obj2txt(arg1,arg2,(ASN1_OBJECT const *)arg3,arg4); + { + resultobj=PyLong_FromLong(result); + if (PyErr_Occurred()) SWIG_fail; + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_obj_obj2txt(PyObject *self, PyObject *args) { + PyObject *resultobj = 0; + ASN1_OBJECT *arg1 = (ASN1_OBJECT *) 0 ; + int arg2 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val2 ; + int ecode2 = 0 ; + PyObject *swig_obj[2] ; + PyObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args, "obj_obj2txt", 2, 2, swig_obj)) SWIG_fail; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ASN1_OBJECT, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "obj_obj2txt" "', argument " "1"" of type '" "ASN1_OBJECT const *""'"); + } + arg1 = (ASN1_OBJECT *)(argp1); + ecode2 = SWIG_AsVal_int(swig_obj[1], &val2); + if (!SWIG_IsOK(ecode2)) { + SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "obj_obj2txt" "', argument " "2"" of type '" "int""'"); + } + arg2 = (int)(val2); + { + if (!arg1) { + SWIG_exception(SWIG_ValueError,"Received a NULL pointer."); + } + } + result = (PyObject *)obj_obj2txt((ASN1_OBJECT const *)arg1,arg2); + { + resultobj=result; + } + return resultobj; +fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { "SWIG_PyInstanceMethod_New", SWIG_PyInstanceMethod_New, METH_O, NULL}, + { "OPENSSL_sk_num", _wrap_OPENSSL_sk_num, METH_O, NULL}, + { "OPENSSL_sk_value", _wrap_OPENSSL_sk_value, METH_VARARGS, NULL}, + { "OPENSSL_sk_set", _wrap_OPENSSL_sk_set, METH_VARARGS, NULL}, + { "OPENSSL_sk_new", _wrap_OPENSSL_sk_new, METH_O, NULL}, + { "OPENSSL_sk_new_null", _wrap_OPENSSL_sk_new_null, METH_NOARGS, NULL}, + { "OPENSSL_sk_new_reserve", _wrap_OPENSSL_sk_new_reserve, METH_VARARGS, NULL}, + { "OPENSSL_sk_reserve", _wrap_OPENSSL_sk_reserve, METH_VARARGS, NULL}, + { "OPENSSL_sk_free", _wrap_OPENSSL_sk_free, METH_O, NULL}, + { "OPENSSL_sk_pop_free", _wrap_OPENSSL_sk_pop_free, METH_VARARGS, NULL}, + { "OPENSSL_sk_deep_copy", _wrap_OPENSSL_sk_deep_copy, METH_VARARGS, NULL}, + { "OPENSSL_sk_insert", _wrap_OPENSSL_sk_insert, METH_VARARGS, NULL}, + { "OPENSSL_sk_delete", _wrap_OPENSSL_sk_delete, METH_VARARGS, NULL}, + { "OPENSSL_sk_delete_ptr", _wrap_OPENSSL_sk_delete_ptr, METH_VARARGS, NULL}, + { "OPENSSL_sk_find", _wrap_OPENSSL_sk_find, METH_VARARGS, NULL}, + { "OPENSSL_sk_find_ex", _wrap_OPENSSL_sk_find_ex, METH_VARARGS, NULL}, + { "OPENSSL_sk_push", _wrap_OPENSSL_sk_push, METH_VARARGS, NULL}, + { "OPENSSL_sk_unshift", _wrap_OPENSSL_sk_unshift, METH_VARARGS, NULL}, + { "OPENSSL_sk_shift", _wrap_OPENSSL_sk_shift, METH_O, NULL}, + { "OPENSSL_sk_pop", _wrap_OPENSSL_sk_pop, METH_O, NULL}, + { "OPENSSL_sk_zero", _wrap_OPENSSL_sk_zero, METH_O, NULL}, + { "OPENSSL_sk_set_cmp_func", _wrap_OPENSSL_sk_set_cmp_func, METH_VARARGS, NULL}, + { "OPENSSL_sk_dup", _wrap_OPENSSL_sk_dup, METH_O, NULL}, + { "OPENSSL_sk_sort", _wrap_OPENSSL_sk_sort, METH_O, NULL}, + { "OPENSSL_sk_is_sorted", _wrap_OPENSSL_sk_is_sorted, METH_O, NULL}, + { "sk_OPENSSL_STRING_num", _wrap_sk_OPENSSL_STRING_num, METH_O, NULL}, + { "sk_OPENSSL_STRING_value", _wrap_sk_OPENSSL_STRING_value, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_new", _wrap_sk_OPENSSL_STRING_new, METH_O, NULL}, + { "sk_OPENSSL_STRING_new_null", _wrap_sk_OPENSSL_STRING_new_null, METH_NOARGS, NULL}, + { "sk_OPENSSL_STRING_new_reserve", _wrap_sk_OPENSSL_STRING_new_reserve, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_reserve", _wrap_sk_OPENSSL_STRING_reserve, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_free", _wrap_sk_OPENSSL_STRING_free, METH_O, NULL}, + { "sk_OPENSSL_STRING_zero", _wrap_sk_OPENSSL_STRING_zero, METH_O, NULL}, + { "sk_OPENSSL_STRING_delete", _wrap_sk_OPENSSL_STRING_delete, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_delete_ptr", _wrap_sk_OPENSSL_STRING_delete_ptr, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_push", _wrap_sk_OPENSSL_STRING_push, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_unshift", _wrap_sk_OPENSSL_STRING_unshift, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_pop", _wrap_sk_OPENSSL_STRING_pop, METH_O, NULL}, + { "sk_OPENSSL_STRING_shift", _wrap_sk_OPENSSL_STRING_shift, METH_O, NULL}, + { "sk_OPENSSL_STRING_pop_free", _wrap_sk_OPENSSL_STRING_pop_free, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_insert", _wrap_sk_OPENSSL_STRING_insert, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_set", _wrap_sk_OPENSSL_STRING_set, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_find", _wrap_sk_OPENSSL_STRING_find, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_find_ex", _wrap_sk_OPENSSL_STRING_find_ex, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_sort", _wrap_sk_OPENSSL_STRING_sort, METH_O, NULL}, + { "sk_OPENSSL_STRING_is_sorted", _wrap_sk_OPENSSL_STRING_is_sorted, METH_O, NULL}, + { "sk_OPENSSL_STRING_dup", _wrap_sk_OPENSSL_STRING_dup, METH_O, NULL}, + { "sk_OPENSSL_STRING_deep_copy", _wrap_sk_OPENSSL_STRING_deep_copy, METH_VARARGS, NULL}, + { "sk_OPENSSL_STRING_set_cmp_func", _wrap_sk_OPENSSL_STRING_set_cmp_func, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_num", _wrap_sk_OPENSSL_CSTRING_num, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_value", _wrap_sk_OPENSSL_CSTRING_value, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_new", _wrap_sk_OPENSSL_CSTRING_new, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_new_null", _wrap_sk_OPENSSL_CSTRING_new_null, METH_NOARGS, NULL}, + { "sk_OPENSSL_CSTRING_new_reserve", _wrap_sk_OPENSSL_CSTRING_new_reserve, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_reserve", _wrap_sk_OPENSSL_CSTRING_reserve, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_free", _wrap_sk_OPENSSL_CSTRING_free, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_zero", _wrap_sk_OPENSSL_CSTRING_zero, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_delete", _wrap_sk_OPENSSL_CSTRING_delete, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_delete_ptr", _wrap_sk_OPENSSL_CSTRING_delete_ptr, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_push", _wrap_sk_OPENSSL_CSTRING_push, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_unshift", _wrap_sk_OPENSSL_CSTRING_unshift, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_pop", _wrap_sk_OPENSSL_CSTRING_pop, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_shift", _wrap_sk_OPENSSL_CSTRING_shift, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_pop_free", _wrap_sk_OPENSSL_CSTRING_pop_free, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_insert", _wrap_sk_OPENSSL_CSTRING_insert, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_set", _wrap_sk_OPENSSL_CSTRING_set, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_find", _wrap_sk_OPENSSL_CSTRING_find, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_find_ex", _wrap_sk_OPENSSL_CSTRING_find_ex, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_sort", _wrap_sk_OPENSSL_CSTRING_sort, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_is_sorted", _wrap_sk_OPENSSL_CSTRING_is_sorted, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_dup", _wrap_sk_OPENSSL_CSTRING_dup, METH_O, NULL}, + { "sk_OPENSSL_CSTRING_deep_copy", _wrap_sk_OPENSSL_CSTRING_deep_copy, METH_VARARGS, NULL}, + { "sk_OPENSSL_CSTRING_set_cmp_func", _wrap_sk_OPENSSL_CSTRING_set_cmp_func, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_num", _wrap_sk_OPENSSL_BLOCK_num, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_value", _wrap_sk_OPENSSL_BLOCK_value, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_new", _wrap_sk_OPENSSL_BLOCK_new, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_new_null", _wrap_sk_OPENSSL_BLOCK_new_null, METH_NOARGS, NULL}, + { "sk_OPENSSL_BLOCK_new_reserve", _wrap_sk_OPENSSL_BLOCK_new_reserve, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_reserve", _wrap_sk_OPENSSL_BLOCK_reserve, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_free", _wrap_sk_OPENSSL_BLOCK_free, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_zero", _wrap_sk_OPENSSL_BLOCK_zero, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_delete", _wrap_sk_OPENSSL_BLOCK_delete, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_delete_ptr", _wrap_sk_OPENSSL_BLOCK_delete_ptr, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_push", _wrap_sk_OPENSSL_BLOCK_push, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_unshift", _wrap_sk_OPENSSL_BLOCK_unshift, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_pop", _wrap_sk_OPENSSL_BLOCK_pop, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_shift", _wrap_sk_OPENSSL_BLOCK_shift, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_pop_free", _wrap_sk_OPENSSL_BLOCK_pop_free, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_insert", _wrap_sk_OPENSSL_BLOCK_insert, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_set", _wrap_sk_OPENSSL_BLOCK_set, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_find", _wrap_sk_OPENSSL_BLOCK_find, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_find_ex", _wrap_sk_OPENSSL_BLOCK_find_ex, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_sort", _wrap_sk_OPENSSL_BLOCK_sort, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_is_sorted", _wrap_sk_OPENSSL_BLOCK_is_sorted, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_dup", _wrap_sk_OPENSSL_BLOCK_dup, METH_O, NULL}, + { "sk_OPENSSL_BLOCK_deep_copy", _wrap_sk_OPENSSL_BLOCK_deep_copy, METH_VARARGS, NULL}, + { "sk_OPENSSL_BLOCK_set_cmp_func", _wrap_sk_OPENSSL_BLOCK_set_cmp_func, METH_VARARGS, NULL}, + { "threading_init", _wrap_threading_init, METH_NOARGS, NULL}, + { "threading_cleanup", _wrap_threading_cleanup, METH_NOARGS, NULL}, + { "lib_init", _wrap_lib_init, METH_NOARGS, NULL}, + { "bn_to_mpi", _wrap_bn_to_mpi, METH_O, NULL}, + { "mpi_to_bn", _wrap_mpi_to_bn, METH_O, NULL}, + { "bn_to_bin", _wrap_bn_to_bin, METH_O, NULL}, + { "bin_to_bn", _wrap_bin_to_bn, METH_O, NULL}, + { "bn_to_hex", _wrap_bn_to_hex, METH_O, NULL}, + { "hex_to_bn", _wrap_hex_to_bn, METH_O, NULL}, + { "dec_to_bn", _wrap_dec_to_bn, METH_O, NULL}, + { "err_print_errors", _wrap_err_print_errors, METH_O, NULL}, + { "err_get_error", _wrap_err_get_error, METH_NOARGS, NULL}, + { "err_peek_error", _wrap_err_peek_error, METH_NOARGS, NULL}, + { "err_lib_error_string", _wrap_err_lib_error_string, METH_O, NULL}, + { "err_func_error_string", _wrap_err_func_error_string, METH_O, NULL}, + { "err_reason_error_string", _wrap_err_reason_error_string, METH_O, NULL}, + { "bio_s_bio", _wrap_bio_s_bio, METH_NOARGS, NULL}, + { "bio_s_mem", _wrap_bio_s_mem, METH_NOARGS, NULL}, + { "bio_s_socket", _wrap_bio_s_socket, METH_NOARGS, NULL}, + { "bio_f_ssl", _wrap_bio_f_ssl, METH_NOARGS, NULL}, + { "bio_f_buffer", _wrap_bio_f_buffer, METH_NOARGS, NULL}, + { "bio_f_cipher", _wrap_bio_f_cipher, METH_NOARGS, NULL}, + { "bio_new", _wrap_bio_new, METH_O, NULL}, + { "bio_new_socket", _wrap_bio_new_socket, METH_VARARGS, NULL}, + { "bio_free_all", _wrap_bio_free_all, METH_O, NULL}, + { "bio_dup_chain", _wrap_bio_dup_chain, METH_O, NULL}, + { "bio_push", _wrap_bio_push, METH_VARARGS, NULL}, + { "bio_pop", _wrap_bio_pop, METH_O, NULL}, + { "bio_eof", _wrap_bio_eof, METH_O, NULL}, + { "pyfd_init", _wrap_pyfd_init, METH_NOARGS, NULL}, + { "bio_init", _wrap_bio_init, METH_O, NULL}, + { "bio_free", _wrap_bio_free, METH_O, NULL}, + { "bio_new_file", _wrap_bio_new_file, METH_VARARGS, NULL}, + { "bio_new_pyfile", _wrap_bio_new_pyfile, METH_VARARGS, NULL}, + { "bio_read", _wrap_bio_read, METH_VARARGS, NULL}, + { "bio_gets", _wrap_bio_gets, METH_VARARGS, NULL}, + { "bio_write", _wrap_bio_write, METH_VARARGS, NULL}, + { "bio_ctrl_pending", _wrap_bio_ctrl_pending, METH_O, NULL}, + { "bio_ctrl_wpending", _wrap_bio_ctrl_wpending, METH_O, NULL}, + { "bio_ctrl_get_write_guarantee", _wrap_bio_ctrl_get_write_guarantee, METH_O, NULL}, + { "bio_reset", _wrap_bio_reset, METH_O, NULL}, + { "bio_flush", _wrap_bio_flush, METH_O, NULL}, + { "bio_seek", _wrap_bio_seek, METH_VARARGS, NULL}, + { "bio_tell", _wrap_bio_tell, METH_O, NULL}, + { "bio_set_flags", _wrap_bio_set_flags, METH_VARARGS, NULL}, + { "bio_get_flags", _wrap_bio_get_flags, METH_O, NULL}, + { "bio_set_cipher", _wrap_bio_set_cipher, METH_VARARGS, NULL}, + { "bio_set_mem_eof_return", _wrap_bio_set_mem_eof_return, METH_VARARGS, NULL}, + { "bio_get_fd", _wrap_bio_get_fd, METH_O, NULL}, + { "bio_do_handshake", _wrap_bio_do_handshake, METH_O, NULL}, + { "bio_make_bio_pair", _wrap_bio_make_bio_pair, METH_VARARGS, NULL}, + { "bio_set_write_buf_size", _wrap_bio_set_write_buf_size, METH_VARARGS, NULL}, + { "bio_should_retry", _wrap_bio_should_retry, METH_O, NULL}, + { "bio_should_read", _wrap_bio_should_read, METH_O, NULL}, + { "bio_should_write", _wrap_bio_should_write, METH_O, NULL}, + { "pyfd_write", _wrap_pyfd_write, METH_VARARGS, NULL}, + { "pyfd_read", _wrap_pyfd_read, METH_VARARGS, NULL}, + { "pyfd_puts", _wrap_pyfd_puts, METH_VARARGS, NULL}, + { "pyfd_gets", _wrap_pyfd_gets, METH_VARARGS, NULL}, + { "pyfd_new", _wrap_pyfd_new, METH_O, NULL}, + { "pyfd_free", _wrap_pyfd_free, METH_O, NULL}, + { "pyfd_ctrl", _wrap_pyfd_ctrl, METH_VARARGS, NULL}, + { "bio_new_pyfd", _wrap_bio_new_pyfd, METH_VARARGS, NULL}, + { "bn_rand", _wrap_bn_rand, METH_VARARGS, NULL}, + { "bn_rand_range", _wrap_bn_rand_range, METH_O, NULL}, + { "rand_load_file", _wrap_rand_load_file, METH_VARARGS, NULL}, + { "rand_save_file", _wrap_rand_save_file, METH_O, NULL}, + { "rand_poll", _wrap_rand_poll, METH_NOARGS, NULL}, + { "rand_status", _wrap_rand_status, METH_NOARGS, NULL}, + { "rand_cleanup", _wrap_rand_cleanup, METH_NOARGS, NULL}, + { "rand_init", _wrap_rand_init, METH_O, NULL}, + { "rand_seed", _wrap_rand_seed, METH_O, NULL}, + { "rand_add", _wrap_rand_add, METH_VARARGS, NULL}, + { "rand_bytes", _wrap_rand_bytes, METH_O, NULL}, + { "rand_pseudo_bytes", _wrap_rand_pseudo_bytes, METH_O, NULL}, + { "rand_file_name", _wrap_rand_file_name, METH_VARARGS, NULL}, + { "rand_screen", _wrap_rand_screen, METH_NOARGS, NULL}, + { "rand_win32_event", _wrap_rand_win32_event, METH_VARARGS, NULL}, + { "md5", _wrap_md5, METH_NOARGS, NULL}, + { "sha1", _wrap_sha1, METH_NOARGS, NULL}, + { "ripemd160", _wrap_ripemd160, METH_NOARGS, NULL}, + { "sha224", _wrap_sha224, METH_NOARGS, NULL}, + { "sha256", _wrap_sha256, METH_NOARGS, NULL}, + { "sha384", _wrap_sha384, METH_NOARGS, NULL}, + { "sha512", _wrap_sha512, METH_NOARGS, NULL}, + { "digest_init", _wrap_digest_init, METH_VARARGS, NULL}, + { "des_ecb", _wrap_des_ecb, METH_NOARGS, NULL}, + { "des_ede_ecb", _wrap_des_ede_ecb, METH_NOARGS, NULL}, + { "des_ede3_ecb", _wrap_des_ede3_ecb, METH_NOARGS, NULL}, + { "des_cbc", _wrap_des_cbc, METH_NOARGS, NULL}, + { "des_ede_cbc", _wrap_des_ede_cbc, METH_NOARGS, NULL}, + { "des_ede3_cbc", _wrap_des_ede3_cbc, METH_NOARGS, NULL}, + { "des_cfb", _wrap_des_cfb, METH_NOARGS, NULL}, + { "des_ede_cfb", _wrap_des_ede_cfb, METH_NOARGS, NULL}, + { "des_ede3_cfb", _wrap_des_ede3_cfb, METH_NOARGS, NULL}, + { "des_ofb", _wrap_des_ofb, METH_NOARGS, NULL}, + { "des_ede_ofb", _wrap_des_ede_ofb, METH_NOARGS, NULL}, + { "des_ede3_ofb", _wrap_des_ede3_ofb, METH_NOARGS, NULL}, + { "bf_ecb", _wrap_bf_ecb, METH_NOARGS, NULL}, + { "bf_cbc", _wrap_bf_cbc, METH_NOARGS, NULL}, + { "bf_cfb", _wrap_bf_cfb, METH_NOARGS, NULL}, + { "bf_ofb", _wrap_bf_ofb, METH_NOARGS, NULL}, + { "cast5_ecb", _wrap_cast5_ecb, METH_NOARGS, NULL}, + { "cast5_cbc", _wrap_cast5_cbc, METH_NOARGS, NULL}, + { "cast5_cfb", _wrap_cast5_cfb, METH_NOARGS, NULL}, + { "cast5_ofb", _wrap_cast5_ofb, METH_NOARGS, NULL}, + { "rc4", _wrap_rc4, METH_NOARGS, NULL}, + { "rc2_40_cbc", _wrap_rc2_40_cbc, METH_NOARGS, NULL}, + { "aes_128_ecb", _wrap_aes_128_ecb, METH_NOARGS, NULL}, + { "aes_128_cbc", _wrap_aes_128_cbc, METH_NOARGS, NULL}, + { "aes_128_cfb", _wrap_aes_128_cfb, METH_NOARGS, NULL}, + { "aes_128_ofb", _wrap_aes_128_ofb, METH_NOARGS, NULL}, + { "aes_128_ctr", _wrap_aes_128_ctr, METH_NOARGS, NULL}, + { "aes_192_ecb", _wrap_aes_192_ecb, METH_NOARGS, NULL}, + { "aes_192_cbc", _wrap_aes_192_cbc, METH_NOARGS, NULL}, + { "aes_192_cfb", _wrap_aes_192_cfb, METH_NOARGS, NULL}, + { "aes_192_ofb", _wrap_aes_192_ofb, METH_NOARGS, NULL}, + { "aes_192_ctr", _wrap_aes_192_ctr, METH_NOARGS, NULL}, + { "aes_256_ecb", _wrap_aes_256_ecb, METH_NOARGS, NULL}, + { "aes_256_cbc", _wrap_aes_256_cbc, METH_NOARGS, NULL}, + { "aes_256_cfb", _wrap_aes_256_cfb, METH_NOARGS, NULL}, + { "aes_256_ofb", _wrap_aes_256_ofb, METH_NOARGS, NULL}, + { "aes_256_ctr", _wrap_aes_256_ctr, METH_NOARGS, NULL}, + { "cipher_set_padding", _wrap_cipher_set_padding, METH_VARARGS, NULL}, + { "pkey_free", _wrap_pkey_free, METH_O, NULL}, + { "pkey_assign", _wrap_pkey_assign, METH_VARARGS, NULL}, + { "pkey_assign_ec", _wrap_pkey_assign_ec, METH_VARARGS, NULL}, + { "pkey_set1_rsa", _wrap_pkey_set1_rsa, METH_VARARGS, NULL}, + { "sign_init", _wrap_sign_init, METH_VARARGS, NULL}, + { "verify_init", _wrap_verify_init, METH_VARARGS, NULL}, + { "pkey_size", _wrap_pkey_size, METH_O, NULL}, + { "evp_init", _wrap_evp_init, METH_O, NULL}, + { "pkey_get1_rsa", _wrap_pkey_get1_rsa, METH_O, NULL}, + { "pkcs5_pbkdf2_hmac_sha1", _wrap_pkcs5_pbkdf2_hmac_sha1, METH_VARARGS, NULL}, + { "md_ctx_new", _wrap_md_ctx_new, METH_NOARGS, NULL}, + { "md_ctx_free", _wrap_md_ctx_free, METH_O, NULL}, + { "digest_update", _wrap_digest_update, METH_VARARGS, NULL}, + { "digest_final", _wrap_digest_final, METH_O, NULL}, + { "hmac_ctx_new", _wrap_hmac_ctx_new, METH_NOARGS, NULL}, + { "hmac_ctx_free", _wrap_hmac_ctx_free, METH_O, NULL}, + { "hmac_init", _wrap_hmac_init, METH_VARARGS, NULL}, + { "hmac_update", _wrap_hmac_update, METH_VARARGS, NULL}, + { "hmac_final", _wrap_hmac_final, METH_O, NULL}, + { "hmac", _wrap_hmac, METH_VARARGS, NULL}, + { "cipher_ctx_new", _wrap_cipher_ctx_new, METH_NOARGS, NULL}, + { "cipher_ctx_free", _wrap_cipher_ctx_free, METH_O, NULL}, + { "bytes_to_key", _wrap_bytes_to_key, METH_VARARGS, NULL}, + { "cipher_init", _wrap_cipher_init, METH_VARARGS, NULL}, + { "cipher_update", _wrap_cipher_update, METH_VARARGS, NULL}, + { "cipher_final", _wrap_cipher_final, METH_O, NULL}, + { "sign_update", _wrap_sign_update, METH_VARARGS, NULL}, + { "sign_final", _wrap_sign_final, METH_VARARGS, NULL}, + { "verify_update", _wrap_verify_update, METH_VARARGS, NULL}, + { "verify_final", _wrap_verify_final, METH_VARARGS, NULL}, + { "digest_sign_init", _wrap_digest_sign_init, METH_VARARGS, NULL}, + { "digest_sign_update", _wrap_digest_sign_update, METH_VARARGS, NULL}, + { "digest_sign_final", _wrap_digest_sign_final, METH_O, NULL}, + { "digest_sign", _wrap_digest_sign, METH_VARARGS, NULL}, + { "digest_verify_init", _wrap_digest_verify_init, METH_VARARGS, NULL}, + { "digest_verify_update", _wrap_digest_verify_update, METH_VARARGS, NULL}, + { "digest_verify_final", _wrap_digest_verify_final, METH_VARARGS, NULL}, + { "digest_verify", _wrap_digest_verify, METH_VARARGS, NULL}, + { "get_digestbyname", _wrap_get_digestbyname, METH_O, NULL}, + { "pkey_write_pem_no_cipher", _wrap_pkey_write_pem_no_cipher, METH_VARARGS, NULL}, + { "pkey_write_pem", _wrap_pkey_write_pem, METH_VARARGS, NULL}, + { "pkey_new", _wrap_pkey_new, METH_NOARGS, NULL}, + { "pkey_read_pem", _wrap_pkey_read_pem, METH_VARARGS, NULL}, + { "pkey_read_pem_pubkey", _wrap_pkey_read_pem_pubkey, METH_VARARGS, NULL}, + { "pkey_assign_rsa", _wrap_pkey_assign_rsa, METH_VARARGS, NULL}, + { "pkey_as_der", _wrap_pkey_as_der, METH_O, NULL}, + { "pkey_get_modulus", _wrap_pkey_get_modulus, METH_O, NULL}, + { "aes_new", _wrap_aes_new, METH_NOARGS, NULL}, + { "AES_free", _wrap_AES_free, METH_O, NULL}, + { "AES_set_key", _wrap_AES_set_key, METH_VARARGS, NULL}, + { "AES_crypt", _wrap_AES_crypt, METH_VARARGS, NULL}, + { "AES_type_check", _wrap_AES_type_check, METH_O, NULL}, + { "rc4_new", _wrap_rc4_new, METH_NOARGS, NULL}, + { "rc4_free", _wrap_rc4_free, METH_O, NULL}, + { "rc4_set_key", _wrap_rc4_set_key, METH_VARARGS, NULL}, + { "rc4_update", _wrap_rc4_update, METH_VARARGS, NULL}, + { "rc4_type_check", _wrap_rc4_type_check, METH_O, NULL}, + { "dh_new", _wrap_dh_new, METH_NOARGS, NULL}, + { "dh_free", _wrap_dh_free, METH_O, NULL}, + { "dh_size", _wrap_dh_size, METH_O, NULL}, + { "dh_generate_key", _wrap_dh_generate_key, METH_O, NULL}, + { "dhparams_print", _wrap_dhparams_print, METH_VARARGS, NULL}, + { "dh_init", _wrap_dh_init, METH_O, NULL}, + { "dh_type_check", _wrap_dh_type_check, METH_O, NULL}, + { "dh_read_parameters", _wrap_dh_read_parameters, METH_O, NULL}, + { "dh_generate_parameters", _wrap_dh_generate_parameters, METH_VARARGS, NULL}, + { "dh_check", _wrap_dh_check, METH_O, NULL}, + { "dh_compute_key", _wrap_dh_compute_key, METH_VARARGS, NULL}, + { "dh_get_p", _wrap_dh_get_p, METH_O, NULL}, + { "dh_get_g", _wrap_dh_get_g, METH_O, NULL}, + { "dh_get_pub", _wrap_dh_get_pub, METH_O, NULL}, + { "dh_get_priv", _wrap_dh_get_priv, METH_O, NULL}, + { "dh_set_pg", _wrap_dh_set_pg, METH_VARARGS, NULL}, + { "rsa_size", _wrap_rsa_size, METH_O, NULL}, + { "rsa_new", _wrap_rsa_new, METH_NOARGS, NULL}, + { "rsa_free", _wrap_rsa_free, METH_O, NULL}, + { "rsa_check_key", _wrap_rsa_check_key, METH_O, NULL}, + { "rsa_init", _wrap_rsa_init, METH_O, NULL}, + { "rsa_read_key", _wrap_rsa_read_key, METH_VARARGS, NULL}, + { "rsa_write_key", _wrap_rsa_write_key, METH_VARARGS, NULL}, + { "rsa_write_key_no_cipher", _wrap_rsa_write_key_no_cipher, METH_VARARGS, NULL}, + { "rsa_read_pub_key", _wrap_rsa_read_pub_key, METH_O, NULL}, + { "rsa_write_pub_key", _wrap_rsa_write_pub_key, METH_VARARGS, NULL}, + { "rsa_get_e", _wrap_rsa_get_e, METH_O, NULL}, + { "rsa_get_n", _wrap_rsa_get_n, METH_O, NULL}, + { "rsa_set_e", _wrap_rsa_set_e, METH_VARARGS, NULL}, + { "rsa_set_n", _wrap_rsa_set_n, METH_VARARGS, NULL}, + { "rsa_set_en", _wrap_rsa_set_en, METH_VARARGS, NULL}, + { "PyObject_Bin_AsBIGNUM", _wrap_PyObject_Bin_AsBIGNUM, METH_O, NULL}, + { "rsa_set_en_bin", _wrap_rsa_set_en_bin, METH_VARARGS, NULL}, + { "rsa_private_encrypt", _wrap_rsa_private_encrypt, METH_VARARGS, NULL}, + { "rsa_public_decrypt", _wrap_rsa_public_decrypt, METH_VARARGS, NULL}, + { "rsa_public_encrypt", _wrap_rsa_public_encrypt, METH_VARARGS, NULL}, + { "rsa_private_decrypt", _wrap_rsa_private_decrypt, METH_VARARGS, NULL}, + { "rsa_padding_add_pkcs1_pss", _wrap_rsa_padding_add_pkcs1_pss, METH_VARARGS, NULL}, + { "rsa_verify_pkcs1_pss", _wrap_rsa_verify_pkcs1_pss, METH_VARARGS, NULL}, + { "rsa_sign", _wrap_rsa_sign, METH_VARARGS, NULL}, + { "rsa_verify", _wrap_rsa_verify, METH_VARARGS, NULL}, + { "rsa_generate_key", _wrap_rsa_generate_key, METH_VARARGS, NULL}, + { "rsa_type_check", _wrap_rsa_type_check, METH_O, NULL}, + { "rsa_check_pub_key", _wrap_rsa_check_pub_key, METH_O, NULL}, + { "rsa_write_key_der", _wrap_rsa_write_key_der, METH_VARARGS, NULL}, + { "dsa_new", _wrap_dsa_new, METH_NOARGS, NULL}, + { "dsa_free", _wrap_dsa_free, METH_O, NULL}, + { "dsa_size", _wrap_dsa_size, METH_O, NULL}, + { "dsa_gen_key", _wrap_dsa_gen_key, METH_O, NULL}, + { "dsa_init", _wrap_dsa_init, METH_O, NULL}, + { "dsa_generate_parameters", _wrap_dsa_generate_parameters, METH_VARARGS, NULL}, + { "dsa_read_params", _wrap_dsa_read_params, METH_VARARGS, NULL}, + { "dsa_read_key", _wrap_dsa_read_key, METH_VARARGS, NULL}, + { "dsa_read_pub_key", _wrap_dsa_read_pub_key, METH_VARARGS, NULL}, + { "dsa_get_p", _wrap_dsa_get_p, METH_O, NULL}, + { "dsa_get_q", _wrap_dsa_get_q, METH_O, NULL}, + { "dsa_get_g", _wrap_dsa_get_g, METH_O, NULL}, + { "dsa_get_pub", _wrap_dsa_get_pub, METH_O, NULL}, + { "dsa_get_priv", _wrap_dsa_get_priv, METH_O, NULL}, + { "dsa_set_pqg", _wrap_dsa_set_pqg, METH_VARARGS, NULL}, + { "dsa_set_pub", _wrap_dsa_set_pub, METH_VARARGS, NULL}, + { "dsa_write_params_bio", _wrap_dsa_write_params_bio, METH_VARARGS, NULL}, + { "dsa_write_key_bio", _wrap_dsa_write_key_bio, METH_VARARGS, NULL}, + { "dsa_write_key_bio_no_cipher", _wrap_dsa_write_key_bio_no_cipher, METH_VARARGS, NULL}, + { "dsa_write_pub_key_bio", _wrap_dsa_write_pub_key_bio, METH_VARARGS, NULL}, + { "dsa_sign", _wrap_dsa_sign, METH_VARARGS, NULL}, + { "dsa_verify", _wrap_dsa_verify, METH_VARARGS, NULL}, + { "dsa_sign_asn1", _wrap_dsa_sign_asn1, METH_VARARGS, NULL}, + { "dsa_verify_asn1", _wrap_dsa_verify_asn1, METH_VARARGS, NULL}, + { "dsa_check_key", _wrap_dsa_check_key, METH_O, NULL}, + { "dsa_check_pub_key", _wrap_dsa_check_pub_key, METH_O, NULL}, + { "dsa_keylen", _wrap_dsa_keylen, METH_O, NULL}, + { "dsa_type_check", _wrap_dsa_type_check, METH_O, NULL}, + { "ssl_get_ciphers", _wrap_ssl_get_ciphers, METH_O, NULL}, + { "ssl_get_version", _wrap_ssl_get_version, METH_O, NULL}, + { "ssl_get_error", _wrap_ssl_get_error, METH_VARARGS, NULL}, + { "ssl_get_state", _wrap_ssl_get_state, METH_O, NULL}, + { "ssl_get_state_v", _wrap_ssl_get_state_v, METH_O, NULL}, + { "ssl_get_alert_type", _wrap_ssl_get_alert_type, METH_O, NULL}, + { "ssl_get_alert_type_v", _wrap_ssl_get_alert_type_v, METH_O, NULL}, + { "ssl_get_alert_desc", _wrap_ssl_get_alert_desc, METH_O, NULL}, + { "ssl_get_alert_desc_v", _wrap_ssl_get_alert_desc_v, METH_O, NULL}, + { "sslv23_method", _wrap_sslv23_method, METH_NOARGS, NULL}, + { "ssl_ctx_new", _wrap_ssl_ctx_new, METH_O, NULL}, + { "ssl_ctx_free", _wrap_ssl_ctx_free, METH_O, NULL}, + { "ssl_ctx_set_verify_depth", _wrap_ssl_ctx_set_verify_depth, METH_VARARGS, NULL}, + { "ssl_ctx_get_verify_depth", _wrap_ssl_ctx_get_verify_depth, METH_O, NULL}, + { "ssl_ctx_get_verify_mode", _wrap_ssl_ctx_get_verify_mode, METH_O, NULL}, + { "ssl_ctx_set_cipher_list", _wrap_ssl_ctx_set_cipher_list, METH_VARARGS, NULL}, + { "ssl_ctx_add_session", _wrap_ssl_ctx_add_session, METH_VARARGS, NULL}, + { "ssl_ctx_remove_session", _wrap_ssl_ctx_remove_session, METH_VARARGS, NULL}, + { "ssl_ctx_set_session_timeout", _wrap_ssl_ctx_set_session_timeout, METH_VARARGS, NULL}, + { "ssl_ctx_get_session_timeout", _wrap_ssl_ctx_get_session_timeout, METH_O, NULL}, + { "ssl_ctx_get_cert_store", _wrap_ssl_ctx_get_cert_store, METH_O, NULL}, + { "ssl_ctx_set_default_verify_paths", _wrap_ssl_ctx_set_default_verify_paths, METH_O, NULL}, + { "ssl_get_ex_data_x509_store_ctx_idx", _wrap_ssl_get_ex_data_x509_store_ctx_idx, METH_NOARGS, NULL}, + { "bio_new_ssl", _wrap_bio_new_ssl, METH_VARARGS, NULL}, + { "ssl_new", _wrap_ssl_new, METH_O, NULL}, + { "ssl_free", _wrap_ssl_free, METH_O, NULL}, + { "ssl_dup", _wrap_ssl_dup, METH_O, NULL}, + { "ssl_set_bio", _wrap_ssl_set_bio, METH_VARARGS, NULL}, + { "ssl_set_accept_state", _wrap_ssl_set_accept_state, METH_O, NULL}, + { "ssl_set_connect_state", _wrap_ssl_set_connect_state, METH_O, NULL}, + { "ssl_get_shutdown", _wrap_ssl_get_shutdown, METH_O, NULL}, + { "ssl_set_shutdown", _wrap_ssl_set_shutdown, METH_VARARGS, NULL}, + { "ssl_shutdown", _wrap_ssl_shutdown, METH_O, NULL}, + { "ssl_clear", _wrap_ssl_clear, METH_O, NULL}, + { "ssl_do_handshake", _wrap_ssl_do_handshake, METH_O, NULL}, + { "ssl_renegotiate", _wrap_ssl_renegotiate, METH_O, NULL}, + { "ssl_pending", _wrap_ssl_pending, METH_O, NULL}, + { "ssl_get_peer_cert", _wrap_ssl_get_peer_cert, METH_O, NULL}, + { "ssl_get_current_cipher", _wrap_ssl_get_current_cipher, METH_O, NULL}, + { "ssl_get_verify_mode", _wrap_ssl_get_verify_mode, METH_O, NULL}, + { "ssl_get_verify_depth", _wrap_ssl_get_verify_depth, METH_O, NULL}, + { "ssl_get_verify_result", _wrap_ssl_get_verify_result, METH_O, NULL}, + { "ssl_get_ssl_ctx", _wrap_ssl_get_ssl_ctx, METH_O, NULL}, + { "ssl_get_default_session_timeout", _wrap_ssl_get_default_session_timeout, METH_O, NULL}, + { "ssl_set_cipher_list", _wrap_ssl_set_cipher_list, METH_VARARGS, NULL}, + { "ssl_get_cipher_list", _wrap_ssl_get_cipher_list, METH_VARARGS, NULL}, + { "ssl_cipher_get_name", _wrap_ssl_cipher_get_name, METH_O, NULL}, + { "ssl_cipher_get_version", _wrap_ssl_cipher_get_version, METH_O, NULL}, + { "ssl_get_session", _wrap_ssl_get_session, METH_O, NULL}, + { "ssl_get1_session", _wrap_ssl_get1_session, METH_O, NULL}, + { "ssl_set_session", _wrap_ssl_set_session, METH_VARARGS, NULL}, + { "ssl_session_free", _wrap_ssl_session_free, METH_O, NULL}, + { "ssl_session_print", _wrap_ssl_session_print, METH_VARARGS, NULL}, + { "ssl_session_set_timeout", _wrap_ssl_session_set_timeout, METH_VARARGS, NULL}, + { "ssl_session_get_timeout", _wrap_ssl_session_get_timeout, METH_O, NULL}, + { "ssl_accept", _wrap_ssl_accept, METH_VARARGS, NULL}, + { "ssl_connect", _wrap_ssl_connect, METH_VARARGS, NULL}, + { "ssl_read", _wrap_ssl_read, METH_VARARGS, NULL}, + { "ssl_write", _wrap_ssl_write, METH_VARARGS, NULL}, + { "ssl_init", _wrap_ssl_init, METH_VARARGS, NULL}, + { "tlsv1_method", _wrap_tlsv1_method, METH_NOARGS, NULL}, + { "ssl_ctx_passphrase_callback", _wrap_ssl_ctx_passphrase_callback, METH_VARARGS, NULL}, + { "ssl_ctx_use_x509", _wrap_ssl_ctx_use_x509, METH_VARARGS, NULL}, + { "ssl_ctx_use_cert", _wrap_ssl_ctx_use_cert, METH_VARARGS, NULL}, + { "ssl_ctx_use_cert_chain", _wrap_ssl_ctx_use_cert_chain, METH_VARARGS, NULL}, + { "ssl_ctx_use_privkey", _wrap_ssl_ctx_use_privkey, METH_VARARGS, NULL}, + { "ssl_ctx_use_rsa_privkey", _wrap_ssl_ctx_use_rsa_privkey, METH_VARARGS, NULL}, + { "ssl_ctx_use_pkey_privkey", _wrap_ssl_ctx_use_pkey_privkey, METH_VARARGS, NULL}, + { "ssl_ctx_check_privkey", _wrap_ssl_ctx_check_privkey, METH_O, NULL}, + { "ssl_ctx_set_client_CA_list_from_file", _wrap_ssl_ctx_set_client_CA_list_from_file, METH_VARARGS, NULL}, + { "ssl_ctx_set_verify_default", _wrap_ssl_ctx_set_verify_default, METH_VARARGS, NULL}, + { "ssl_ctx_set_verify", _wrap_ssl_ctx_set_verify, METH_VARARGS, NULL}, + { "ssl_ctx_set_session_id_context", _wrap_ssl_ctx_set_session_id_context, METH_VARARGS, NULL}, + { "ssl_ctx_set_info_callback", _wrap_ssl_ctx_set_info_callback, METH_VARARGS, NULL}, + { "ssl_ctx_set_tmp_dh", _wrap_ssl_ctx_set_tmp_dh, METH_VARARGS, NULL}, + { "ssl_ctx_set_tmp_dh_callback", _wrap_ssl_ctx_set_tmp_dh_callback, METH_VARARGS, NULL}, + { "ssl_ctx_set_tmp_rsa", _wrap_ssl_ctx_set_tmp_rsa, METH_VARARGS, NULL}, + { "ssl_ctx_set_tmp_rsa_callback", _wrap_ssl_ctx_set_tmp_rsa_callback, METH_VARARGS, NULL}, + { "ssl_ctx_load_verify_locations", _wrap_ssl_ctx_load_verify_locations, METH_VARARGS, NULL}, + { "ssl_ctx_set_options", _wrap_ssl_ctx_set_options, METH_VARARGS, NULL}, + { "bio_set_ssl", _wrap_bio_set_ssl, METH_VARARGS, NULL}, + { "ssl_set_mode", _wrap_ssl_set_mode, METH_VARARGS, NULL}, + { "ssl_get_mode", _wrap_ssl_get_mode, METH_O, NULL}, + { "ssl_set_tlsext_host_name", _wrap_ssl_set_tlsext_host_name, METH_VARARGS, NULL}, + { "ssl_set_client_CA_list_from_file", _wrap_ssl_set_client_CA_list_from_file, METH_VARARGS, NULL}, + { "ssl_set_client_CA_list_from_context", _wrap_ssl_set_client_CA_list_from_context, METH_VARARGS, NULL}, + { "ssl_set_session_id_context", _wrap_ssl_set_session_id_context, METH_VARARGS, NULL}, + { "ssl_set_fd", _wrap_ssl_set_fd, METH_VARARGS, NULL}, + { "ssl_set_shutdown1", _wrap_ssl_set_shutdown1, METH_VARARGS, NULL}, + { "ssl_read_nbio", _wrap_ssl_read_nbio, METH_VARARGS, NULL}, + { "ssl_write_nbio", _wrap_ssl_write_nbio, METH_VARARGS, NULL}, + { "ssl_cipher_get_bits", _wrap_ssl_cipher_get_bits, METH_O, NULL}, + { "sk_ssl_cipher_num", _wrap_sk_ssl_cipher_num, METH_O, NULL}, + { "sk_ssl_cipher_value", _wrap_sk_ssl_cipher_value, METH_VARARGS, NULL}, + { "ssl_get_peer_cert_chain", _wrap_ssl_get_peer_cert_chain, METH_O, NULL}, + { "sk_x509_num", _wrap_sk_x509_num, METH_O, NULL}, + { "sk_x509_value", _wrap_sk_x509_value, METH_VARARGS, NULL}, + { "i2d_ssl_session", _wrap_i2d_ssl_session, METH_VARARGS, NULL}, + { "ssl_session_read_pem", _wrap_ssl_session_read_pem, METH_O, NULL}, + { "ssl_session_write_pem", _wrap_ssl_session_write_pem, METH_VARARGS, NULL}, + { "ssl_ctx_set_session_cache_mode", _wrap_ssl_ctx_set_session_cache_mode, METH_VARARGS, NULL}, + { "ssl_ctx_get_session_cache_mode", _wrap_ssl_ctx_get_session_cache_mode, METH_O, NULL}, + { "ssl_ctx_set_cache_size", _wrap_ssl_ctx_set_cache_size, METH_VARARGS, NULL}, + { "ssl_is_init_finished", _wrap_ssl_is_init_finished, METH_O, NULL}, + { "x509_check_ca", _wrap_x509_check_ca, METH_O, NULL}, + { "x509_new", _wrap_x509_new, METH_NOARGS, NULL}, + { "x509_dup", _wrap_x509_dup, METH_O, NULL}, + { "x509_free", _wrap_x509_free, METH_O, NULL}, + { "x509_crl_free", _wrap_x509_crl_free, METH_O, NULL}, + { "x509_crl_new", _wrap_x509_crl_new, METH_NOARGS, NULL}, + { "x509_print", _wrap_x509_print, METH_VARARGS, NULL}, + { "x509_crl_print", _wrap_x509_crl_print, METH_VARARGS, NULL}, + { "x509_get_serial_number", _wrap_x509_get_serial_number, METH_O, NULL}, + { "x509_set_serial_number", _wrap_x509_set_serial_number, METH_VARARGS, NULL}, + { "x509_get_pubkey", _wrap_x509_get_pubkey, METH_O, NULL}, + { "x509_set_pubkey", _wrap_x509_set_pubkey, METH_VARARGS, NULL}, + { "x509_get_issuer_name", _wrap_x509_get_issuer_name, METH_O, NULL}, + { "x509_set_issuer_name", _wrap_x509_set_issuer_name, METH_VARARGS, NULL}, + { "x509_get_subject_name", _wrap_x509_get_subject_name, METH_O, NULL}, + { "x509_set_subject_name", _wrap_x509_set_subject_name, METH_VARARGS, NULL}, + { "x509_cmp_current_time", _wrap_x509_cmp_current_time, METH_O, NULL}, + { "x509_check_purpose", _wrap_x509_check_purpose, METH_VARARGS, NULL}, + { "x509_check_trust", _wrap_x509_check_trust, METH_VARARGS, NULL}, + { "x509_write_pem", _wrap_x509_write_pem, METH_VARARGS, NULL}, + { "x509_write_pem_file", _wrap_x509_write_pem_file, METH_VARARGS, NULL}, + { "x509_verify", _wrap_x509_verify, METH_VARARGS, NULL}, + { "x509_get_verify_error", _wrap_x509_get_verify_error, METH_O, NULL}, + { "x509_add_ext", _wrap_x509_add_ext, METH_VARARGS, NULL}, + { "x509_get_ext_count", _wrap_x509_get_ext_count, METH_O, NULL}, + { "x509_get_ext", _wrap_x509_get_ext, METH_VARARGS, NULL}, + { "x509_ext_print", _wrap_x509_ext_print, METH_VARARGS, NULL}, + { "x509_name_new", _wrap_x509_name_new, METH_NOARGS, NULL}, + { "x509_name_free", _wrap_x509_name_free, METH_O, NULL}, + { "x509_name_print", _wrap_x509_name_print, METH_VARARGS, NULL}, + { "x509_name_get_entry", _wrap_x509_name_get_entry, METH_VARARGS, NULL}, + { "x509_name_entry_count", _wrap_x509_name_entry_count, METH_O, NULL}, + { "x509_name_delete_entry", _wrap_x509_name_delete_entry, METH_VARARGS, NULL}, + { "x509_name_add_entry", _wrap_x509_name_add_entry, METH_VARARGS, NULL}, + { "x509_name_add_entry_by_obj", _wrap_x509_name_add_entry_by_obj, METH_VARARGS, NULL}, + { "x509_name_add_entry_by_nid", _wrap_x509_name_add_entry_by_nid, METH_VARARGS, NULL}, + { "x509_name_print_ex", _wrap_x509_name_print_ex, METH_VARARGS, NULL}, + { "x509_name_hash", _wrap_x509_name_hash, METH_O, NULL}, + { "x509_name_get_index_by_nid", _wrap_x509_name_get_index_by_nid, METH_VARARGS, NULL}, + { "x509_name_entry_new", _wrap_x509_name_entry_new, METH_NOARGS, NULL}, + { "x509_name_entry_free", _wrap_x509_name_entry_free, METH_O, NULL}, + { "x509_name_entry_create_by_nid", _wrap_x509_name_entry_create_by_nid, METH_VARARGS, NULL}, + { "x509_name_entry_set_object", _wrap_x509_name_entry_set_object, METH_VARARGS, NULL}, + { "x509_name_entry_get_object", _wrap_x509_name_entry_get_object, METH_O, NULL}, + { "x509_name_entry_get_data", _wrap_x509_name_entry_get_data, METH_O, NULL}, + { "x509_name_entry_set_data", _wrap_x509_name_entry_set_data, METH_VARARGS, NULL}, + { "x509_req_new", _wrap_x509_req_new, METH_NOARGS, NULL}, + { "x509_req_free", _wrap_x509_req_free, METH_O, NULL}, + { "x509_req_print", _wrap_x509_req_print, METH_VARARGS, NULL}, + { "x509_req_get_pubkey", _wrap_x509_req_get_pubkey, METH_O, NULL}, + { "x509_req_set_pubkey", _wrap_x509_req_set_pubkey, METH_VARARGS, NULL}, + { "x509_req_set_subject_name", _wrap_x509_req_set_subject_name, METH_VARARGS, NULL}, + { "x509_req_verify", _wrap_x509_req_verify, METH_VARARGS, NULL}, + { "x509_req_sign", _wrap_x509_req_sign, METH_VARARGS, NULL}, + { "i2d_x509_bio", _wrap_i2d_x509_bio, METH_VARARGS, NULL}, + { "i2d_x509_req_bio", _wrap_i2d_x509_req_bio, METH_VARARGS, NULL}, + { "x509_store_new", _wrap_x509_store_new, METH_NOARGS, NULL}, + { "x509_store_free", _wrap_x509_store_free, METH_O, NULL}, + { "x509_store_add_cert", _wrap_x509_store_add_cert, METH_VARARGS, NULL}, + { "x509_store_ctx_get_current_cert", _wrap_x509_store_ctx_get_current_cert, METH_O, NULL}, + { "x509_store_ctx_get_error", _wrap_x509_store_ctx_get_error, METH_O, NULL}, + { "x509_store_ctx_get_error_depth", _wrap_x509_store_ctx_get_error_depth, METH_O, NULL}, + { "x509_store_ctx_free", _wrap_x509_store_ctx_free, METH_O, NULL}, + { "x509_store_ctx_get1_chain", _wrap_x509_store_ctx_get1_chain, METH_O, NULL}, + { "x509_extension_get_critical", _wrap_x509_extension_get_critical, METH_O, NULL}, + { "x509_extension_set_critical", _wrap_x509_extension_set_critical, METH_VARARGS, NULL}, + { "x509_store_set_flags", _wrap_x509_store_set_flags, METH_VARARGS, NULL}, + { "x509_read_pem", _wrap_x509_read_pem, METH_O, NULL}, + { "d2i_x509", _wrap_d2i_x509, METH_O, NULL}, + { "x509_init", _wrap_x509_init, METH_O, NULL}, + { "d2i_x509_req", _wrap_d2i_x509_req, METH_O, NULL}, + { "x509_req_read_pem", _wrap_x509_req_read_pem, METH_O, NULL}, + { "i2d_x509", _wrap_i2d_x509, METH_O, NULL}, + { "x509_req_write_pem", _wrap_x509_req_write_pem, METH_VARARGS, NULL}, + { "x509_crl_read_pem", _wrap_x509_crl_read_pem, METH_O, NULL}, + { "x509_set_version", _wrap_x509_set_version, METH_VARARGS, NULL}, + { "x509_get_version", _wrap_x509_get_version, METH_O, NULL}, + { "x509_set_not_before", _wrap_x509_set_not_before, METH_VARARGS, NULL}, + { "x509_get_not_before", _wrap_x509_get_not_before, METH_O, NULL}, + { "x509_set_not_after", _wrap_x509_set_not_after, METH_VARARGS, NULL}, + { "x509_get_not_after", _wrap_x509_get_not_after, METH_O, NULL}, + { "x509_sign", _wrap_x509_sign, METH_VARARGS, NULL}, + { "x509_gmtime_adj", _wrap_x509_gmtime_adj, METH_VARARGS, NULL}, + { "x509_name_by_nid", _wrap_x509_name_by_nid, METH_VARARGS, NULL}, + { "x509_name_set_by_nid", _wrap_x509_name_set_by_nid, METH_VARARGS, NULL}, + { "x509_name_add_entry_by_txt", _wrap_x509_name_add_entry_by_txt, METH_VARARGS, NULL}, + { "x509_name_get_der", _wrap_x509_name_get_der, METH_O, NULL}, + { "sk_x509_free", _wrap_sk_x509_free, METH_O, NULL}, + { "sk_x509_push", _wrap_sk_x509_push, METH_VARARGS, NULL}, + { "sk_x509_pop", _wrap_sk_x509_pop, METH_O, NULL}, + { "x509_store_load_locations", _wrap_x509_store_load_locations, METH_VARARGS, NULL}, + { "x509_type_check", _wrap_x509_type_check, METH_O, NULL}, + { "x509_name_type_check", _wrap_x509_name_type_check, METH_O, NULL}, + { "x509_req_get_subject_name", _wrap_x509_req_get_subject_name, METH_O, NULL}, + { "x509_req_get_version", _wrap_x509_req_get_version, METH_O, NULL}, + { "x509_req_set_version", _wrap_x509_req_set_version, METH_VARARGS, NULL}, + { "x509_req_add_extensions", _wrap_x509_req_add_extensions, METH_VARARGS, NULL}, + { "x509_name_entry_create_by_txt", _wrap_x509_name_entry_create_by_txt, METH_VARARGS, NULL}, + { "x509v3_set_nconf", _wrap_x509v3_set_nconf, METH_NOARGS, NULL}, + { "x509v3_ext_conf", _wrap_x509v3_ext_conf, METH_VARARGS, NULL}, + { "x509_extension_free", _wrap_x509_extension_free, METH_O, NULL}, + { "x509_extension_get_name", _wrap_x509_extension_get_name, METH_O, NULL}, + { "sk_x509_extension_new_null", _wrap_sk_x509_extension_new_null, METH_NOARGS, NULL}, + { "sk_x509_extension_free", _wrap_sk_x509_extension_free, METH_O, NULL}, + { "sk_x509_extension_push", _wrap_sk_x509_extension_push, METH_VARARGS, NULL}, + { "sk_x509_extension_pop", _wrap_sk_x509_extension_pop, METH_O, NULL}, + { "sk_x509_extension_num", _wrap_sk_x509_extension_num, METH_O, NULL}, + { "sk_x509_extension_value", _wrap_sk_x509_extension_value, METH_VARARGS, NULL}, + { "x509_store_ctx_get_app_data", _wrap_x509_store_ctx_get_app_data, METH_O, NULL}, + { "x509_store_ctx_get_ex_data", _wrap_x509_store_ctx_get_ex_data, METH_VARARGS, NULL}, + { "x509_store_set_verify_cb", _wrap_x509_store_set_verify_cb, METH_VARARGS, NULL}, + { "make_stack_from_der_sequence", _wrap_make_stack_from_der_sequence, METH_O, NULL}, + { "sk_x509_new_null", _wrap_sk_x509_new_null, METH_NOARGS, NULL}, + { "get_der_encoding_stack", _wrap_get_der_encoding_stack, METH_O, NULL}, + { "x509_name_oneline", _wrap_x509_name_oneline, METH_O, NULL}, + { "asn1_object_new", _wrap_asn1_object_new, METH_NOARGS, NULL}, + { "asn1_object_create", _wrap_asn1_object_create, METH_VARARGS, NULL}, + { "asn1_object_free", _wrap_asn1_object_free, METH_O, NULL}, + { "i2d_asn1_object", _wrap_i2d_asn1_object, METH_VARARGS, NULL}, + { "d2i_asn1_object", _wrap_d2i_asn1_object, METH_VARARGS, NULL}, + { "asn1_bit_string_new", _wrap_asn1_bit_string_new, METH_NOARGS, NULL}, + { "asn1_string_new", _wrap_asn1_string_new, METH_NOARGS, NULL}, + { "asn1_string_free", _wrap_asn1_string_free, METH_O, NULL}, + { "asn1_string_set", _wrap_asn1_string_set, METH_VARARGS, NULL}, + { "asn1_string_print", _wrap_asn1_string_print, METH_VARARGS, NULL}, + { "asn1_string_print_ex", _wrap_asn1_string_print_ex, METH_VARARGS, NULL}, + { "asn1_time_new", _wrap_asn1_time_new, METH_NOARGS, NULL}, + { "asn1_time_free", _wrap_asn1_time_free, METH_O, NULL}, + { "asn1_time_check", _wrap_asn1_time_check, METH_O, NULL}, + { "asn1_time_set", _wrap_asn1_time_set, METH_VARARGS, NULL}, + { "asn1_time_set_string", _wrap_asn1_time_set_string, METH_VARARGS, NULL}, + { "asn1_time_print", _wrap_asn1_time_print, METH_VARARGS, NULL}, + { "asn1_integer_new", _wrap_asn1_integer_new, METH_NOARGS, NULL}, + { "asn1_integer_free", _wrap_asn1_integer_free, METH_O, NULL}, + { "asn1_integer_cmp", _wrap_asn1_integer_cmp, METH_VARARGS, NULL}, + { "asn1_time_type_check", _wrap_asn1_time_type_check, METH_O, NULL}, + { "asn1_integer_get", _wrap_asn1_integer_get, METH_O, NULL}, + { "asn1_integer_set", _wrap_asn1_integer_set, METH_VARARGS, NULL}, + { "pkcs7_new", _wrap_pkcs7_new, METH_NOARGS, NULL}, + { "pkcs7_free", _wrap_pkcs7_free, METH_O, NULL}, + { "pkcs7_add_certificate", _wrap_pkcs7_add_certificate, METH_VARARGS, NULL}, + { "pkcs7_init", _wrap_pkcs7_init, METH_O, NULL}, + { "smime_init", _wrap_smime_init, METH_O, NULL}, + { "pkcs7_decrypt", _wrap_pkcs7_decrypt, METH_VARARGS, NULL}, + { "pkcs7_encrypt", _wrap_pkcs7_encrypt, METH_VARARGS, NULL}, + { "pkcs7_sign1", _wrap_pkcs7_sign1, METH_VARARGS, NULL}, + { "pkcs7_sign0", _wrap_pkcs7_sign0, METH_VARARGS, NULL}, + { "pkcs7_read_bio", _wrap_pkcs7_read_bio, METH_O, NULL}, + { "pkcs7_read_bio_der", _wrap_pkcs7_read_bio_der, METH_O, NULL}, + { "pkcs7_verify1", _wrap_pkcs7_verify1, METH_VARARGS, NULL}, + { "pkcs7_verify0", _wrap_pkcs7_verify0, METH_VARARGS, NULL}, + { "smime_write_pkcs7_multi", _wrap_smime_write_pkcs7_multi, METH_VARARGS, NULL}, + { "smime_write_pkcs7", _wrap_smime_write_pkcs7, METH_VARARGS, NULL}, + { "smime_read_pkcs7", _wrap_smime_read_pkcs7, METH_O, NULL}, + { "pkcs7_write_bio", _wrap_pkcs7_write_bio, METH_VARARGS, NULL}, + { "pkcs7_write_bio_der", _wrap_pkcs7_write_bio_der, METH_VARARGS, NULL}, + { "pkcs7_type_nid", _wrap_pkcs7_type_nid, METH_O, NULL}, + { "pkcs7_type_sn", _wrap_pkcs7_type_sn, METH_O, NULL}, + { "smime_crlf_copy", _wrap_smime_crlf_copy, METH_VARARGS, NULL}, + { "pkcs7_get0_signers", _wrap_pkcs7_get0_signers, METH_VARARGS, NULL}, + { "util_init", _wrap_util_init, METH_O, NULL}, + { "util_hex_to_string", _wrap_util_hex_to_string, METH_O, NULL}, + { "util_string_to_hex", _wrap_util_string_to_hex, METH_O, NULL}, + { "ec_key_new", _wrap_ec_key_new, METH_NOARGS, NULL}, + { "ec_key_free", _wrap_ec_key_free, METH_O, NULL}, + { "ec_key_size", _wrap_ec_key_size, METH_O, NULL}, + { "ec_key_gen_key", _wrap_ec_key_gen_key, METH_O, NULL}, + { "ec_key_check_key", _wrap_ec_key_check_key, METH_O, NULL}, + { "ec_init", _wrap_ec_init, METH_O, NULL}, + { "ec_get_builtin_curves", _wrap_ec_get_builtin_curves, METH_NOARGS, NULL}, + { "ec_key_new_by_curve_name", _wrap_ec_key_new_by_curve_name, METH_O, NULL}, + { "ec_key_get_public_der", _wrap_ec_key_get_public_der, METH_O, NULL}, + { "ec_key_get_public_key", _wrap_ec_key_get_public_key, METH_O, NULL}, + { "ec_key_read_pubkey", _wrap_ec_key_read_pubkey, METH_O, NULL}, + { "ec_key_write_pubkey", _wrap_ec_key_write_pubkey, METH_VARARGS, NULL}, + { "ec_key_read_bio", _wrap_ec_key_read_bio, METH_VARARGS, NULL}, + { "ec_key_write_bio", _wrap_ec_key_write_bio, METH_VARARGS, NULL}, + { "ec_key_write_bio_no_cipher", _wrap_ec_key_write_bio_no_cipher, METH_VARARGS, NULL}, + { "ecdsa_sig_get_r", _wrap_ecdsa_sig_get_r, METH_O, NULL}, + { "ecdsa_sig_get_s", _wrap_ecdsa_sig_get_s, METH_O, NULL}, + { "ecdsa_sign", _wrap_ecdsa_sign, METH_VARARGS, NULL}, + { "ecdsa_verify", _wrap_ecdsa_verify, METH_VARARGS, NULL}, + { "ecdsa_sign_asn1", _wrap_ecdsa_sign_asn1, METH_VARARGS, NULL}, + { "ecdsa_verify_asn1", _wrap_ecdsa_verify_asn1, METH_VARARGS, NULL}, + { "ecdh_compute_key", _wrap_ecdh_compute_key, METH_VARARGS, NULL}, + { "ec_key_from_pubkey_der", _wrap_ec_key_from_pubkey_der, METH_O, NULL}, + { "ec_key_from_pubkey_params", _wrap_ec_key_from_pubkey_params, METH_VARARGS, NULL}, + { "ec_key_keylen", _wrap_ec_key_keylen, METH_O, NULL}, + { "ec_key_type_check", _wrap_ec_key_type_check, METH_O, NULL}, + { "engine_load_builtin_engines", _wrap_engine_load_builtin_engines, METH_NOARGS, NULL}, + { "engine_load_dynamic", _wrap_engine_load_dynamic, METH_NOARGS, NULL}, + { "engine_load_openssl", _wrap_engine_load_openssl, METH_NOARGS, NULL}, + { "engine_cleanup", _wrap_engine_cleanup, METH_NOARGS, NULL}, + { "engine_new", _wrap_engine_new, METH_NOARGS, NULL}, + { "engine_by_id", _wrap_engine_by_id, METH_O, NULL}, + { "engine_free", _wrap_engine_free, METH_O, NULL}, + { "engine_init", _wrap_engine_init, METH_O, NULL}, + { "engine_finish", _wrap_engine_finish, METH_O, NULL}, + { "engine_get_id", _wrap_engine_get_id, METH_O, NULL}, + { "engine_get_name", _wrap_engine_get_name, METH_O, NULL}, + { "engine_ctrl_cmd_string", _wrap_engine_ctrl_cmd_string, METH_VARARGS, NULL}, + { "ui_openssl", _wrap_ui_openssl, METH_NOARGS, NULL}, + { "engine_pkcs11_data_new", _wrap_engine_pkcs11_data_new, METH_O, NULL}, + { "engine_pkcs11_data_free", _wrap_engine_pkcs11_data_free, METH_O, NULL}, + { "engine_load_private_key", _wrap_engine_load_private_key, METH_VARARGS, NULL}, + { "engine_load_public_key", _wrap_engine_load_public_key, METH_VARARGS, NULL}, + { "engine_init_error", _wrap_engine_init_error, METH_O, NULL}, + { "engine_load_certificate", _wrap_engine_load_certificate, METH_VARARGS, NULL}, + { "engine_set_default", _wrap_engine_set_default, METH_VARARGS, NULL}, + { "obj_nid2obj", _wrap_obj_nid2obj, METH_O, NULL}, + { "obj_nid2ln", _wrap_obj_nid2ln, METH_O, NULL}, + { "obj_nid2sn", _wrap_obj_nid2sn, METH_O, NULL}, + { "obj_obj2nid", _wrap_obj_obj2nid, METH_O, NULL}, + { "obj_ln2nid", _wrap_obj_ln2nid, METH_O, NULL}, + { "obj_sn2nid", _wrap_obj_sn2nid, METH_O, NULL}, + { "obj_txt2nid", _wrap_obj_txt2nid, METH_O, NULL}, + { "obj_txt2obj", _wrap_obj_txt2obj, METH_VARARGS, NULL}, + { "_obj_obj2txt", _wrap__obj_obj2txt, METH_VARARGS, NULL}, + { "obj_obj2txt", _wrap_obj_obj2txt, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + +static PyMethodDef SwigMethods_proxydocs[] = { + { NULL, NULL, 0, NULL } +}; + +static SwigPyGetSet BIO_PYFD_CTX___dict___getset = { SwigPyObject_get___dict__, 0 }; +static SwigPyGetSet BIO_PYFD_CTX_fd_getset = { _wrap_BIO_PYFD_CTX_fd_get, _wrap_BIO_PYFD_CTX_fd_set }; +SWIGINTERN PyGetSetDef SwigPyBuiltin__pyfd_struct_getset[] = { + { (char *)"__dict__", SwigPyBuiltin_FunpackGetterClosure, 0, (char *)"", &BIO_PYFD_CTX___dict___getset }, + { (char *)"fd", SwigPyBuiltin_FunpackGetterClosure, SwigPyBuiltin_FunpackSetterClosure, (char *)"", &BIO_PYFD_CTX_fd_getset }, + { NULL, NULL, NULL, NULL, NULL } /* Sentinel */ +}; + +SWIGINTERN PyObject * +SwigPyBuiltin__pyfd_struct_richcompare(PyObject *self, PyObject *other, int op) { + PyObject *result = NULL; + if (!result) { + if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { + result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); + } else { + result = Py_NotImplemented; + Py_INCREF(result); + } + } + return result; +} + +SWIGINTERN PyMethodDef SwigPyBuiltin__pyfd_struct_methods[] = { + { NULL, NULL, 0, NULL } /* Sentinel */ +}; + +static PyHeapTypeObject SwigPyBuiltin__pyfd_struct_type = { + { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "m2crypto.BIO_PYFD_CTX", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + _wrap_delete_BIO_PYFD_CTX_destructor_closure, /* tp_dealloc */ + (printfunc) 0, /* tp_print */ + (getattrfunc) 0, /* tp_getattr */ + (setattrfunc) 0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_compare */ +#else + (cmpfunc) 0, /* tp_compare */ +#endif + (reprfunc) 0, /* tp_repr */ + &SwigPyBuiltin__pyfd_struct_type.as_number, /* tp_as_number */ + &SwigPyBuiltin__pyfd_struct_type.as_sequence, /* tp_as_sequence */ + &SwigPyBuiltin__pyfd_struct_type.as_mapping, /* tp_as_mapping */ + SwigPyObject_hash, /* tp_hash */ + (ternaryfunc) 0, /* tp_call */ + (reprfunc) 0, /* tp_str */ + (getattrofunc) 0, /* tp_getattro */ + (setattrofunc) 0, /* tp_setattro */ + &SwigPyBuiltin__pyfd_struct_type.as_buffer, /* tp_as_buffer */ +#if PY_VERSION_HEX >= 0x03000000 + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#endif + "::pyfd_struct", /* tp_doc */ + (traverseproc) 0, /* tp_traverse */ + (inquiry) 0, /* tp_clear */ + SwigPyBuiltin__pyfd_struct_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc) 0, /* tp_iter */ + (iternextfunc) 0, /* tp_iternext */ + SwigPyBuiltin__pyfd_struct_methods, /* tp_methods */ + 0, /* tp_members */ + SwigPyBuiltin__pyfd_struct_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + (descrgetfunc) 0, /* tp_descr_get */ + (descrsetfunc) 0, /* tp_descr_set */ + offsetof(SwigPyObject, dict), /* tp_dictoffset */ + _wrap_new_BIO_PYFD_CTX, /* tp_init */ + (allocfunc) 0, /* tp_alloc */ + (newfunc) 0, /* tp_new */ + (freefunc) 0, /* tp_free */ + (inquiry) 0, /* tp_is_gc */ + (PyObject *) 0, /* tp_bases */ + (PyObject *) 0, /* tp_mro */ + (PyObject *) 0, /* tp_cache */ + (PyObject *) 0, /* tp_subclasses */ + (PyObject *) 0, /* tp_weaklist */ + (destructor) 0, /* tp_del */ + (int) 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + (destructor) 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + (vectorcallfunc) 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + (Py_ssize_t) 0, /* tp_allocs */ + (Py_ssize_t) 0, /* tp_frees */ + (Py_ssize_t) 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0, /* tp_next */ +#endif + }, +#if PY_VERSION_HEX >= 0x03050000 + { + (unaryfunc) 0, /* am_await */ + (unaryfunc) 0, /* am_aiter */ + (unaryfunc) 0, /* am_anext */ + }, +#endif + { + (binaryfunc) 0, /* nb_add */ + (binaryfunc) 0, /* nb_subtract */ + (binaryfunc) 0, /* nb_multiply */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc) 0, /* nb_divide */ +#endif + (binaryfunc) 0, /* nb_remainder */ + (binaryfunc) 0, /* nb_divmod */ + (ternaryfunc) 0, /* nb_power */ + (unaryfunc) 0, /* nb_negative */ + (unaryfunc) 0, /* nb_positive */ + (unaryfunc) 0, /* nb_absolute */ + (inquiry) 0, /* nb_nonzero */ + (unaryfunc) 0, /* nb_invert */ + (binaryfunc) 0, /* nb_lshift */ + (binaryfunc) 0, /* nb_rshift */ + (binaryfunc) 0, /* nb_and */ + (binaryfunc) 0, /* nb_xor */ + (binaryfunc) 0, /* nb_or */ +#if PY_VERSION_HEX < 0x03000000 + (coercion) 0, /* nb_coerce */ +#endif + (unaryfunc) 0, /* nb_int */ +#if PY_VERSION_HEX >= 0x03000000 + (void *) 0, /* nb_reserved */ +#else + (unaryfunc) 0, /* nb_long */ +#endif + (unaryfunc) 0, /* nb_float */ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc) 0, /* nb_oct */ + (unaryfunc) 0, /* nb_hex */ +#endif + (binaryfunc) 0, /* nb_inplace_add */ + (binaryfunc) 0, /* nb_inplace_subtract */ + (binaryfunc) 0, /* nb_inplace_multiply */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc) 0, /* nb_inplace_divide */ +#endif + (binaryfunc) 0, /* nb_inplace_remainder */ + (ternaryfunc) 0, /* nb_inplace_power */ + (binaryfunc) 0, /* nb_inplace_lshift */ + (binaryfunc) 0, /* nb_inplace_rshift */ + (binaryfunc) 0, /* nb_inplace_and */ + (binaryfunc) 0, /* nb_inplace_xor */ + (binaryfunc) 0, /* nb_inplace_or */ + (binaryfunc) 0, /* nb_floor_divide */ + (binaryfunc) 0, /* nb_true_divide */ + (binaryfunc) 0, /* nb_inplace_floor_divide */ + (binaryfunc) 0, /* nb_inplace_true_divide */ + (unaryfunc) 0, /* nb_index */ +#if PY_VERSION_HEX >= 0x03050000 + (binaryfunc) 0, /* nb_matrix_multiply */ + (binaryfunc) 0, /* nb_inplace_matrix_multiply */ +#endif + }, + { + (lenfunc) 0, /* mp_length */ + (binaryfunc) 0, /* mp_subscript */ + (objobjargproc) 0, /* mp_ass_subscript */ + }, + { + (lenfunc) 0, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (ssizeargfunc) 0, /* sq_repeat */ + (ssizeargfunc) 0, /* sq_item */ +#if PY_VERSION_HEX >= 0x03000000 + (void *) 0, /* was_sq_slice */ +#else + (ssizessizeargfunc) 0, /* sq_slice */ +#endif + (ssizeobjargproc) 0, /* sq_ass_item */ +#if PY_VERSION_HEX >= 0x03000000 + (void *) 0, /* was_sq_ass_slice */ +#else + (ssizessizeobjargproc) 0, /* sq_ass_slice */ +#endif + (objobjproc) 0, /* sq_contains */ + (binaryfunc) 0, /* sq_inplace_concat */ + (ssizeargfunc) 0, /* sq_inplace_repeat */ + }, + { +#if PY_VERSION_HEX < 0x03000000 + (readbufferproc) 0, /* bf_getreadbuffer */ + (writebufferproc) 0, /* bf_getwritebuffer */ + (segcountproc) 0, /* bf_getsegcount */ + (charbufferproc) 0, /* bf_getcharbuffer */ +#endif + (getbufferproc) 0, /* bf_getbuffer */ + (releasebufferproc) 0, /* bf_releasebuffer */ + }, + (PyObject *) 0, /* ht_name */ + (PyObject *) 0, /* ht_slots */ +#if PY_VERSION_HEX >= 0x03030000 + (PyObject *) 0, /* ht_qualname */ + 0, /* ht_cached_keys */ +#endif +}; + +SWIGINTERN SwigPyClientData SwigPyBuiltin__pyfd_struct_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin__pyfd_struct_type}; + +static SwigPyGetSet _cbd_t___dict___getset = { SwigPyObject_get___dict__, 0 }; +static SwigPyGetSet _cbd_t_password_getset = { _wrap__cbd_t_password_get, _wrap__cbd_t_password_set }; +static SwigPyGetSet _cbd_t_prompt_getset = { _wrap__cbd_t_prompt_get, _wrap__cbd_t_prompt_set }; +SWIGINTERN PyGetSetDef SwigPyBuiltin___cbd_t_getset[] = { + { (char *)"__dict__", SwigPyBuiltin_FunpackGetterClosure, 0, (char *)"", &_cbd_t___dict___getset }, + { (char *)"password", SwigPyBuiltin_FunpackGetterClosure, SwigPyBuiltin_FunpackSetterClosure, (char *)"", &_cbd_t_password_getset }, + { (char *)"prompt", SwigPyBuiltin_FunpackGetterClosure, SwigPyBuiltin_FunpackSetterClosure, (char *)"", &_cbd_t_prompt_getset }, + { NULL, NULL, NULL, NULL, NULL } /* Sentinel */ +}; + +SWIGINTERN PyObject * +SwigPyBuiltin___cbd_t_richcompare(PyObject *self, PyObject *other, int op) { + PyObject *result = NULL; + if (!result) { + if (SwigPyObject_Check(self) && SwigPyObject_Check(other)) { + result = SwigPyObject_richcompare((SwigPyObject *)self, (SwigPyObject *)other, op); + } else { + result = Py_NotImplemented; + Py_INCREF(result); + } + } + return result; +} + +SWIGINTERN PyMethodDef SwigPyBuiltin___cbd_t_methods[] = { + { NULL, NULL, 0, NULL } /* Sentinel */ +}; + +static PyHeapTypeObject SwigPyBuiltin___cbd_t_type = { + { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "m2crypto._cbd_t", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + _wrap_delete__cbd_t_destructor_closure, /* tp_dealloc */ + (printfunc) 0, /* tp_print */ + (getattrfunc) 0, /* tp_getattr */ + (setattrfunc) 0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_compare */ +#else + (cmpfunc) 0, /* tp_compare */ +#endif + (reprfunc) 0, /* tp_repr */ + &SwigPyBuiltin___cbd_t_type.as_number, /* tp_as_number */ + &SwigPyBuiltin___cbd_t_type.as_sequence, /* tp_as_sequence */ + &SwigPyBuiltin___cbd_t_type.as_mapping, /* tp_as_mapping */ + SwigPyObject_hash, /* tp_hash */ + (ternaryfunc) 0, /* tp_call */ + (reprfunc) 0, /* tp_str */ + (getattrofunc) 0, /* tp_getattro */ + (setattrofunc) 0, /* tp_setattro */ + &SwigPyBuiltin___cbd_t_type.as_buffer, /* tp_as_buffer */ +#if PY_VERSION_HEX >= 0x03000000 + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#endif + "::_cbd_t", /* tp_doc */ + (traverseproc) 0, /* tp_traverse */ + (inquiry) 0, /* tp_clear */ + SwigPyBuiltin___cbd_t_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + (getiterfunc) 0, /* tp_iter */ + (iternextfunc) 0, /* tp_iternext */ + SwigPyBuiltin___cbd_t_methods, /* tp_methods */ + 0, /* tp_members */ + SwigPyBuiltin___cbd_t_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + (descrgetfunc) 0, /* tp_descr_get */ + (descrsetfunc) 0, /* tp_descr_set */ + offsetof(SwigPyObject, dict), /* tp_dictoffset */ + _wrap_new__cbd_t, /* tp_init */ + (allocfunc) 0, /* tp_alloc */ + (newfunc) 0, /* tp_new */ + (freefunc) 0, /* tp_free */ + (inquiry) 0, /* tp_is_gc */ + (PyObject *) 0, /* tp_bases */ + (PyObject *) 0, /* tp_mro */ + (PyObject *) 0, /* tp_cache */ + (PyObject *) 0, /* tp_subclasses */ + (PyObject *) 0, /* tp_weaklist */ + (destructor) 0, /* tp_del */ + (int) 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + (destructor) 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + (vectorcallfunc) 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + (Py_ssize_t) 0, /* tp_allocs */ + (Py_ssize_t) 0, /* tp_frees */ + (Py_ssize_t) 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0, /* tp_next */ +#endif + }, +#if PY_VERSION_HEX >= 0x03050000 + { + (unaryfunc) 0, /* am_await */ + (unaryfunc) 0, /* am_aiter */ + (unaryfunc) 0, /* am_anext */ + }, +#endif + { + (binaryfunc) 0, /* nb_add */ + (binaryfunc) 0, /* nb_subtract */ + (binaryfunc) 0, /* nb_multiply */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc) 0, /* nb_divide */ +#endif + (binaryfunc) 0, /* nb_remainder */ + (binaryfunc) 0, /* nb_divmod */ + (ternaryfunc) 0, /* nb_power */ + (unaryfunc) 0, /* nb_negative */ + (unaryfunc) 0, /* nb_positive */ + (unaryfunc) 0, /* nb_absolute */ + (inquiry) 0, /* nb_nonzero */ + (unaryfunc) 0, /* nb_invert */ + (binaryfunc) 0, /* nb_lshift */ + (binaryfunc) 0, /* nb_rshift */ + (binaryfunc) 0, /* nb_and */ + (binaryfunc) 0, /* nb_xor */ + (binaryfunc) 0, /* nb_or */ +#if PY_VERSION_HEX < 0x03000000 + (coercion) 0, /* nb_coerce */ +#endif + (unaryfunc) 0, /* nb_int */ +#if PY_VERSION_HEX >= 0x03000000 + (void *) 0, /* nb_reserved */ +#else + (unaryfunc) 0, /* nb_long */ +#endif + (unaryfunc) 0, /* nb_float */ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc) 0, /* nb_oct */ + (unaryfunc) 0, /* nb_hex */ +#endif + (binaryfunc) 0, /* nb_inplace_add */ + (binaryfunc) 0, /* nb_inplace_subtract */ + (binaryfunc) 0, /* nb_inplace_multiply */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc) 0, /* nb_inplace_divide */ +#endif + (binaryfunc) 0, /* nb_inplace_remainder */ + (ternaryfunc) 0, /* nb_inplace_power */ + (binaryfunc) 0, /* nb_inplace_lshift */ + (binaryfunc) 0, /* nb_inplace_rshift */ + (binaryfunc) 0, /* nb_inplace_and */ + (binaryfunc) 0, /* nb_inplace_xor */ + (binaryfunc) 0, /* nb_inplace_or */ + (binaryfunc) 0, /* nb_floor_divide */ + (binaryfunc) 0, /* nb_true_divide */ + (binaryfunc) 0, /* nb_inplace_floor_divide */ + (binaryfunc) 0, /* nb_inplace_true_divide */ + (unaryfunc) 0, /* nb_index */ +#if PY_VERSION_HEX >= 0x03050000 + (binaryfunc) 0, /* nb_matrix_multiply */ + (binaryfunc) 0, /* nb_inplace_matrix_multiply */ +#endif + }, + { + (lenfunc) 0, /* mp_length */ + (binaryfunc) 0, /* mp_subscript */ + (objobjargproc) 0, /* mp_ass_subscript */ + }, + { + (lenfunc) 0, /* sq_length */ + (binaryfunc) 0, /* sq_concat */ + (ssizeargfunc) 0, /* sq_repeat */ + (ssizeargfunc) 0, /* sq_item */ +#if PY_VERSION_HEX >= 0x03000000 + (void *) 0, /* was_sq_slice */ +#else + (ssizessizeargfunc) 0, /* sq_slice */ +#endif + (ssizeobjargproc) 0, /* sq_ass_item */ +#if PY_VERSION_HEX >= 0x03000000 + (void *) 0, /* was_sq_ass_slice */ +#else + (ssizessizeobjargproc) 0, /* sq_ass_slice */ +#endif + (objobjproc) 0, /* sq_contains */ + (binaryfunc) 0, /* sq_inplace_concat */ + (ssizeargfunc) 0, /* sq_inplace_repeat */ + }, + { +#if PY_VERSION_HEX < 0x03000000 + (readbufferproc) 0, /* bf_getreadbuffer */ + (writebufferproc) 0, /* bf_getwritebuffer */ + (segcountproc) 0, /* bf_getsegcount */ + (charbufferproc) 0, /* bf_getcharbuffer */ +#endif + (getbufferproc) 0, /* bf_getbuffer */ + (releasebufferproc) 0, /* bf_releasebuffer */ + }, + (PyObject *) 0, /* ht_name */ + (PyObject *) 0, /* ht_slots */ +#if PY_VERSION_HEX >= 0x03030000 + (PyObject *) 0, /* ht_qualname */ + 0, /* ht_cached_keys */ +#endif +}; + +SWIGINTERN SwigPyClientData SwigPyBuiltin___cbd_t_clientdata = {0, 0, 0, 0, 0, 0, (PyTypeObject *)&SwigPyBuiltin___cbd_t_type}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_AES_KEY = {"_p_AES_KEY", "AES_KEY *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ASN1_BIT_STRING = {"_p_ASN1_BIT_STRING", "ASN1_BIT_STRING *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ASN1_INTEGER = {"_p_ASN1_INTEGER", "ASN1_INTEGER *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ASN1_OBJECT = {"_p_ASN1_OBJECT", "ASN1_OBJECT *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ASN1_STRING = {"_p_ASN1_STRING", "ASN1_STRING *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ASN1_TIME = {"_p_ASN1_TIME", "ASN1_TIME *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BIGNUM = {"_p_BIGNUM", "BIGNUM *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BIO = {"_p_BIO", "BIO *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_BIO_METHOD = {"_p_BIO_METHOD", "BIO_METHOD *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_DH = {"_p_DH", "DH *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_DSA = {"_p_DSA", "DSA *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ECDSA_SIG = {"_p_ECDSA_SIG", "ECDSA_SIG *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_EC_KEY = {"_p_EC_KEY", "EC_KEY *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_ENGINE = {"_p_ENGINE", "ENGINE *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_EVP_CIPHER = {"_p_EVP_CIPHER", "EVP_CIPHER *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_EVP_CIPHER_CTX = {"_p_EVP_CIPHER_CTX", "EVP_CIPHER_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_EVP_MD = {"_p_EVP_MD", "EVP_MD *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_EVP_MD_CTX = {"_p_EVP_MD_CTX", "EVP_MD_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_EVP_PKEY = {"_p_EVP_PKEY", "EVP_PKEY *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_FILE = {"_p_FILE", "FILE *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_HMAC_CTX = {"_p_HMAC_CTX", "HMAC_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_PKCS7 = {"_p_PKCS7", "PKCS7 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_PyObject = {"_p_PyObject", "PyObject *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_RC4_KEY = {"_p_RC4_KEY", "RC4_KEY *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_RSA = {"_p_RSA", "RSA *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SSL = {"_p_SSL", "SSL *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SSL_CIPHER = {"_p_SSL_CIPHER", "SSL_CIPHER *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SSL_CTX = {"_p_SSL_CTX", "SSL_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SSL_METHOD = {"_p_SSL_METHOD", "SSL_METHOD *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SSL_SESSION = {"_p_SSL_SESSION", "SSL_SESSION *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_SwigPyObject = {"_p_SwigPyObject", "SwigPyObject *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_UI_METHOD = {"_p_UI_METHOD", "UI_METHOD *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509 = {"_p_X509", "X509 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509V3_CTX = {"_p_X509V3_CTX", "X509V3_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_CRL = {"_p_X509_CRL", "X509_CRL *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_EXTENSION = {"_p_X509_EXTENSION", "X509_EXTENSION *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_NAME = {"_p_X509_NAME", "X509_NAME *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_NAME_ENTRY = {"_p_X509_NAME_ENTRY", "X509_NAME_ENTRY *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_REQ = {"_p_X509_REQ", "X509_REQ *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_STORE = {"_p_X509_STORE", "X509_STORE *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_X509_STORE_CTX = {"_p_X509_STORE_CTX", "X509_STORE_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INTMAX_TYPE__ = {"_p___INTMAX_TYPE__", "__INTMAX_TYPE__ *|intmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_FAST16_TYPE__ = {"_p___INT_FAST16_TYPE__", "__INT_FAST16_TYPE__ *|int_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_FAST32_TYPE__ = {"_p___INT_FAST32_TYPE__", "__INT_FAST32_TYPE__ *|int_fast32_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_FAST64_TYPE__ = {"_p___INT_FAST64_TYPE__", "__INT_FAST64_TYPE__ *|int_fast64_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_FAST8_TYPE__ = {"_p___INT_FAST8_TYPE__", "__INT_FAST8_TYPE__ *|int_fast8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_LEAST16_TYPE__ = {"_p___INT_LEAST16_TYPE__", "__INT_LEAST16_TYPE__ *|int_least16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_LEAST32_TYPE__ = {"_p___INT_LEAST32_TYPE__", "__INT_LEAST32_TYPE__ *|int_least32_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_LEAST64_TYPE__ = {"_p___INT_LEAST64_TYPE__", "__INT_LEAST64_TYPE__ *|int_least64_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___INT_LEAST8_TYPE__ = {"_p___INT_LEAST8_TYPE__", "__INT_LEAST8_TYPE__ *|int_least8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINTMAX_TYPE__ = {"_p___UINTMAX_TYPE__", "__UINTMAX_TYPE__ *|uintmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_FAST16_TYPE__ = {"_p___UINT_FAST16_TYPE__", "__UINT_FAST16_TYPE__ *|uint_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_FAST32_TYPE__ = {"_p___UINT_FAST32_TYPE__", "__UINT_FAST32_TYPE__ *|uint_fast32_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_FAST64_TYPE__ = {"_p___UINT_FAST64_TYPE__", "__UINT_FAST64_TYPE__ *|uint_fast64_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_FAST8_TYPE__ = {"_p___UINT_FAST8_TYPE__", "__UINT_FAST8_TYPE__ *|uint_fast8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_LEAST16_TYPE__ = {"_p___UINT_LEAST16_TYPE__", "__UINT_LEAST16_TYPE__ *|uint_least16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_LEAST32_TYPE__ = {"_p___UINT_LEAST32_TYPE__", "__UINT_LEAST32_TYPE__ *|uint_least32_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_LEAST64_TYPE__ = {"_p___UINT_LEAST64_TYPE__", "__UINT_LEAST64_TYPE__ *|uint_least64_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p___UINT_LEAST8_TYPE__ = {"_p___UINT_LEAST8_TYPE__", "__UINT_LEAST8_TYPE__ *|uint_least8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p__cbd_t = {"_p__cbd_t", "_cbd_t *", 0, 0, (void*)&SwigPyBuiltin___cbd_t_clientdata, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_int_p_X509_STORE_CTX__int = {"_p_f_int_p_X509_STORE_CTX__int", "int (*)(int,X509_STORE_CTX *)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_char__void = {"_p_f_p_char__void", "void (*)(char *)|sk_OPENSSL_STRING_freefunc|sk_OPENSSL_CSTRING_freefunc", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__char__p_char = {"_p_f_p_q_const__char__p_char", "char *(*)(char const *)|sk_OPENSSL_STRING_copyfunc|sk_OPENSSL_CSTRING_copyfunc", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int = {"_p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int", "int (*)(char const *const *,char const *const *)|sk_OPENSSL_STRING_compfunc|sk_OPENSSL_CSTRING_compfunc", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int = {"_p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int", "int (*)(void const *const *,void const *const *)|sk_OPENSSL_BLOCK_compfunc", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__void__p_void = {"_p_f_p_q_const__void__p_void", "void *(*)(void const *)|OPENSSL_sk_copyfunc|sk_OPENSSL_BLOCK_copyfunc", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_q_const__void_p_q_const__void__int = {"_p_f_p_q_const__void_p_q_const__void__int", "int (*)(void const *,void const *)|OPENSSL_sk_compfunc", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_f_p_void__void = {"_p_f_p_void__void", "OPENSSL_sk_freefunc|sk_OPENSSL_BLOCK_freefunc|void (*)(void *)", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_ASN1_OBJECT = {"_p_p_ASN1_OBJECT", "ASN1_OBJECT **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_EVP_PKEY_CTX = {"_p_p_EVP_PKEY_CTX", "EVP_PKEY_CTX **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_X509_NAME_ENTRY = {"_p_p_X509_NAME_ENTRY", "X509_NAME_ENTRY **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_unsigned_char = {"_p_p_unsigned_char", "unsigned char **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_pyfd_struct = {"_p_pyfd_struct", "BIO_PYFD_CTX *|struct pyfd_struct *|pyfd_struct *", 0, 0, (void*)&SwigPyBuiltin__pyfd_struct_clientdata, 0}; +static swig_type_info _swigt__p_stack_st = {"_p_stack_st", "struct stack_st *|OPENSSL_STACK *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_stack_st_OPENSSL_BLOCK = {"_p_stack_st_OPENSSL_BLOCK", "struct stack_st_OPENSSL_BLOCK *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_stack_st_OPENSSL_CSTRING = {"_p_stack_st_OPENSSL_CSTRING", "struct stack_st_OPENSSL_CSTRING *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_stack_st_OPENSSL_STRING = {"_p_stack_st_OPENSSL_STRING", "struct stack_st_OPENSSL_STRING *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_stack_st_SSL_CIPHER = {"_p_stack_st_SSL_CIPHER", "struct stack_st_SSL_CIPHER *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_stack_st_X509 = {"_p_stack_st_X509", "struct stack_st_X509 *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_stack_st_X509_EXTENSION = {"_p_stack_st_X509_EXTENSION", "struct stack_st_X509_EXTENSION *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_AES_KEY, + &_swigt__p_ASN1_BIT_STRING, + &_swigt__p_ASN1_INTEGER, + &_swigt__p_ASN1_OBJECT, + &_swigt__p_ASN1_STRING, + &_swigt__p_ASN1_TIME, + &_swigt__p_BIGNUM, + &_swigt__p_BIO, + &_swigt__p_BIO_METHOD, + &_swigt__p_DH, + &_swigt__p_DSA, + &_swigt__p_ECDSA_SIG, + &_swigt__p_EC_KEY, + &_swigt__p_ENGINE, + &_swigt__p_EVP_CIPHER, + &_swigt__p_EVP_CIPHER_CTX, + &_swigt__p_EVP_MD, + &_swigt__p_EVP_MD_CTX, + &_swigt__p_EVP_PKEY, + &_swigt__p_FILE, + &_swigt__p_HMAC_CTX, + &_swigt__p_PKCS7, + &_swigt__p_PyObject, + &_swigt__p_RC4_KEY, + &_swigt__p_RSA, + &_swigt__p_SSL, + &_swigt__p_SSL_CIPHER, + &_swigt__p_SSL_CTX, + &_swigt__p_SSL_METHOD, + &_swigt__p_SSL_SESSION, + &_swigt__p_SwigPyObject, + &_swigt__p_UI_METHOD, + &_swigt__p_X509, + &_swigt__p_X509V3_CTX, + &_swigt__p_X509_CRL, + &_swigt__p_X509_EXTENSION, + &_swigt__p_X509_NAME, + &_swigt__p_X509_NAME_ENTRY, + &_swigt__p_X509_REQ, + &_swigt__p_X509_STORE, + &_swigt__p_X509_STORE_CTX, + &_swigt__p___INTMAX_TYPE__, + &_swigt__p___INT_FAST16_TYPE__, + &_swigt__p___INT_FAST32_TYPE__, + &_swigt__p___INT_FAST64_TYPE__, + &_swigt__p___INT_FAST8_TYPE__, + &_swigt__p___INT_LEAST16_TYPE__, + &_swigt__p___INT_LEAST32_TYPE__, + &_swigt__p___INT_LEAST64_TYPE__, + &_swigt__p___INT_LEAST8_TYPE__, + &_swigt__p___UINTMAX_TYPE__, + &_swigt__p___UINT_FAST16_TYPE__, + &_swigt__p___UINT_FAST32_TYPE__, + &_swigt__p___UINT_FAST64_TYPE__, + &_swigt__p___UINT_FAST8_TYPE__, + &_swigt__p___UINT_LEAST16_TYPE__, + &_swigt__p___UINT_LEAST32_TYPE__, + &_swigt__p___UINT_LEAST64_TYPE__, + &_swigt__p___UINT_LEAST8_TYPE__, + &_swigt__p__cbd_t, + &_swigt__p_char, + &_swigt__p_f_int_p_X509_STORE_CTX__int, + &_swigt__p_f_p_char__void, + &_swigt__p_f_p_q_const__char__p_char, + &_swigt__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int, + &_swigt__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int, + &_swigt__p_f_p_q_const__void__p_void, + &_swigt__p_f_p_q_const__void_p_q_const__void__int, + &_swigt__p_f_p_void__void, + &_swigt__p_p_ASN1_OBJECT, + &_swigt__p_p_EVP_PKEY_CTX, + &_swigt__p_p_X509_NAME_ENTRY, + &_swigt__p_p_unsigned_char, + &_swigt__p_pyfd_struct, + &_swigt__p_stack_st, + &_swigt__p_stack_st_OPENSSL_BLOCK, + &_swigt__p_stack_st_OPENSSL_CSTRING, + &_swigt__p_stack_st_OPENSSL_STRING, + &_swigt__p_stack_st_SSL_CIPHER, + &_swigt__p_stack_st_X509, + &_swigt__p_stack_st_X509_EXTENSION, + &_swigt__p_unsigned_char, + &_swigt__p_void, +}; + +static swig_cast_info _swigc__p_AES_KEY[] = { {&_swigt__p_AES_KEY, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ASN1_BIT_STRING[] = { {&_swigt__p_ASN1_BIT_STRING, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ASN1_INTEGER[] = { {&_swigt__p_ASN1_INTEGER, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ASN1_OBJECT[] = { {&_swigt__p_ASN1_OBJECT, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ASN1_STRING[] = { {&_swigt__p_ASN1_STRING, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ASN1_TIME[] = { {&_swigt__p_ASN1_TIME, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BIGNUM[] = { {&_swigt__p_BIGNUM, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BIO[] = { {&_swigt__p_BIO, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_BIO_METHOD[] = { {&_swigt__p_BIO_METHOD, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_DH[] = { {&_swigt__p_DH, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_DSA[] = { {&_swigt__p_DSA, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ECDSA_SIG[] = { {&_swigt__p_ECDSA_SIG, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_EC_KEY[] = { {&_swigt__p_EC_KEY, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_ENGINE[] = { {&_swigt__p_ENGINE, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_EVP_CIPHER[] = { {&_swigt__p_EVP_CIPHER, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_EVP_CIPHER_CTX[] = { {&_swigt__p_EVP_CIPHER_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_EVP_MD[] = { {&_swigt__p_EVP_MD, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_EVP_MD_CTX[] = { {&_swigt__p_EVP_MD_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_EVP_PKEY[] = { {&_swigt__p_EVP_PKEY, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_FILE[] = { {&_swigt__p_FILE, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_HMAC_CTX[] = { {&_swigt__p_HMAC_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_PKCS7[] = { {&_swigt__p_PKCS7, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_PyObject[] = { {&_swigt__p_PyObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_RC4_KEY[] = { {&_swigt__p_RC4_KEY, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_RSA[] = { {&_swigt__p_RSA, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SSL[] = { {&_swigt__p_SSL, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SSL_CIPHER[] = { {&_swigt__p_SSL_CIPHER, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SSL_CTX[] = { {&_swigt__p_SSL_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SSL_METHOD[] = { {&_swigt__p_SSL_METHOD, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SSL_SESSION[] = { {&_swigt__p_SSL_SESSION, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_SwigPyObject[] = { {&_swigt__p_SwigPyObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_UI_METHOD[] = { {&_swigt__p_UI_METHOD, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509[] = { {&_swigt__p_X509, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509V3_CTX[] = { {&_swigt__p_X509V3_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_CRL[] = { {&_swigt__p_X509_CRL, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_EXTENSION[] = { {&_swigt__p_X509_EXTENSION, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_NAME[] = { {&_swigt__p_X509_NAME, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_NAME_ENTRY[] = { {&_swigt__p_X509_NAME_ENTRY, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_REQ[] = { {&_swigt__p_X509_REQ, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_STORE[] = { {&_swigt__p_X509_STORE, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_X509_STORE_CTX[] = { {&_swigt__p_X509_STORE_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INTMAX_TYPE__[] = { {&_swigt__p___INTMAX_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_FAST16_TYPE__[] = { {&_swigt__p___INT_FAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_FAST32_TYPE__[] = { {&_swigt__p___INT_FAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_FAST64_TYPE__[] = { {&_swigt__p___INT_FAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_FAST8_TYPE__[] = { {&_swigt__p___INT_FAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_LEAST16_TYPE__[] = { {&_swigt__p___INT_LEAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_LEAST32_TYPE__[] = { {&_swigt__p___INT_LEAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_LEAST64_TYPE__[] = { {&_swigt__p___INT_LEAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___INT_LEAST8_TYPE__[] = { {&_swigt__p___INT_LEAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINTMAX_TYPE__[] = { {&_swigt__p___UINTMAX_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_FAST16_TYPE__[] = { {&_swigt__p___UINT_FAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_FAST32_TYPE__[] = { {&_swigt__p___UINT_FAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_FAST64_TYPE__[] = { {&_swigt__p___UINT_FAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_FAST8_TYPE__[] = { {&_swigt__p___UINT_FAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_LEAST16_TYPE__[] = { {&_swigt__p___UINT_LEAST16_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_LEAST32_TYPE__[] = { {&_swigt__p___UINT_LEAST32_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_LEAST64_TYPE__[] = { {&_swigt__p___UINT_LEAST64_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p___UINT_LEAST8_TYPE__[] = { {&_swigt__p___UINT_LEAST8_TYPE__, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p__cbd_t[] = { {&_swigt__p__cbd_t, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_int_p_X509_STORE_CTX__int[] = { {&_swigt__p_f_int_p_X509_STORE_CTX__int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_char__void[] = { {&_swigt__p_f_p_char__void, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__char__p_char[] = { {&_swigt__p_f_p_q_const__char__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int[] = { {&_swigt__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int[] = { {&_swigt__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__void__p_void[] = { {&_swigt__p_f_p_q_const__void__p_void, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_q_const__void_p_q_const__void__int[] = { {&_swigt__p_f_p_q_const__void_p_q_const__void__int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_f_p_void__void[] = { {&_swigt__p_f_p_void__void, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_ASN1_OBJECT[] = { {&_swigt__p_p_ASN1_OBJECT, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_EVP_PKEY_CTX[] = { {&_swigt__p_p_EVP_PKEY_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_X509_NAME_ENTRY[] = { {&_swigt__p_p_X509_NAME_ENTRY, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_unsigned_char[] = { {&_swigt__p_p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_pyfd_struct[] = { {&_swigt__p_pyfd_struct, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st[] = { {&_swigt__p_stack_st, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st_OPENSSL_BLOCK[] = { {&_swigt__p_stack_st_OPENSSL_BLOCK, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st_OPENSSL_CSTRING[] = { {&_swigt__p_stack_st_OPENSSL_CSTRING, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st_OPENSSL_STRING[] = { {&_swigt__p_stack_st_OPENSSL_STRING, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st_SSL_CIPHER[] = { {&_swigt__p_stack_st_SSL_CIPHER, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st_X509[] = { {&_swigt__p_stack_st_X509, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_stack_st_X509_EXTENSION[] = { {&_swigt__p_stack_st_X509_EXTENSION, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_AES_KEY, + _swigc__p_ASN1_BIT_STRING, + _swigc__p_ASN1_INTEGER, + _swigc__p_ASN1_OBJECT, + _swigc__p_ASN1_STRING, + _swigc__p_ASN1_TIME, + _swigc__p_BIGNUM, + _swigc__p_BIO, + _swigc__p_BIO_METHOD, + _swigc__p_DH, + _swigc__p_DSA, + _swigc__p_ECDSA_SIG, + _swigc__p_EC_KEY, + _swigc__p_ENGINE, + _swigc__p_EVP_CIPHER, + _swigc__p_EVP_CIPHER_CTX, + _swigc__p_EVP_MD, + _swigc__p_EVP_MD_CTX, + _swigc__p_EVP_PKEY, + _swigc__p_FILE, + _swigc__p_HMAC_CTX, + _swigc__p_PKCS7, + _swigc__p_PyObject, + _swigc__p_RC4_KEY, + _swigc__p_RSA, + _swigc__p_SSL, + _swigc__p_SSL_CIPHER, + _swigc__p_SSL_CTX, + _swigc__p_SSL_METHOD, + _swigc__p_SSL_SESSION, + _swigc__p_SwigPyObject, + _swigc__p_UI_METHOD, + _swigc__p_X509, + _swigc__p_X509V3_CTX, + _swigc__p_X509_CRL, + _swigc__p_X509_EXTENSION, + _swigc__p_X509_NAME, + _swigc__p_X509_NAME_ENTRY, + _swigc__p_X509_REQ, + _swigc__p_X509_STORE, + _swigc__p_X509_STORE_CTX, + _swigc__p___INTMAX_TYPE__, + _swigc__p___INT_FAST16_TYPE__, + _swigc__p___INT_FAST32_TYPE__, + _swigc__p___INT_FAST64_TYPE__, + _swigc__p___INT_FAST8_TYPE__, + _swigc__p___INT_LEAST16_TYPE__, + _swigc__p___INT_LEAST32_TYPE__, + _swigc__p___INT_LEAST64_TYPE__, + _swigc__p___INT_LEAST8_TYPE__, + _swigc__p___UINTMAX_TYPE__, + _swigc__p___UINT_FAST16_TYPE__, + _swigc__p___UINT_FAST32_TYPE__, + _swigc__p___UINT_FAST64_TYPE__, + _swigc__p___UINT_FAST8_TYPE__, + _swigc__p___UINT_LEAST16_TYPE__, + _swigc__p___UINT_LEAST32_TYPE__, + _swigc__p___UINT_LEAST64_TYPE__, + _swigc__p___UINT_LEAST8_TYPE__, + _swigc__p__cbd_t, + _swigc__p_char, + _swigc__p_f_int_p_X509_STORE_CTX__int, + _swigc__p_f_p_char__void, + _swigc__p_f_p_q_const__char__p_char, + _swigc__p_f_p_q_const__p_q_const__char_p_q_const__p_q_const__char__int, + _swigc__p_f_p_q_const__p_q_const__void_p_q_const__p_q_const__void__int, + _swigc__p_f_p_q_const__void__p_void, + _swigc__p_f_p_q_const__void_p_q_const__void__int, + _swigc__p_f_p_void__void, + _swigc__p_p_ASN1_OBJECT, + _swigc__p_p_EVP_PKEY_CTX, + _swigc__p_p_X509_NAME_ENTRY, + _swigc__p_p_unsigned_char, + _swigc__p_pyfd_struct, + _swigc__p_stack_st, + _swigc__p_stack_st_OPENSSL_BLOCK, + _swigc__p_stack_st_OPENSSL_CSTRING, + _swigc__p_stack_st_OPENSSL_STRING, + _swigc__p_stack_st_SSL_CIPHER, + _swigc__p_stack_st_X509, + _swigc__p_stack_st_X509_EXTENSION, + _swigc__p_unsigned_char, + _swigc__p_void, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +static PyTypeObject *builtin_bases[2]; + +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned statically to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int init; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + iter=module_head; + do { + if (iter==&swig_module) { + /* Our module is already in the list, so there's nothing more to do. */ + return; + } + iter=iter->next; + } while (iter!= module_head); + + /* otherwise we must add our module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpreters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString(""); +#else + return PyString_FromString(""); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + "swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag */ +#if PY_VERSION_HEX >= 0x03040000 + 0, /* tp_finalize */ +#endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif +#ifdef COUNT_ALLOCS + 0, /* tp_allocs */ + 0, /* tp_frees */ + 0, /* tp_maxalloc */ + 0, /* tp_prev */ + 0 /* tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; + if (PyType_Ready(&varlink_type) < 0) + return NULL; + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + memcpy(gv->name, name, size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *globals = 0; + if (!globals) { + globals = SWIG_newvarlink(); + } + return globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (!c) continue; + c = strstr(c, "swig_ptr: "); + if (c) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + memcpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + memcpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + + /* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + + /* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif + } + + /* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + + SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md, *globals; + +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + SwigPyObject_own, + SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + PyTypeObject *swigpyobject; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + PyObject *self = 0; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + (void)self; + + /* Metaclass is used to implement static member variables */ + metatype = SwigPyObjectType(); + assert(metatype); +#endif + + (void)globals; + + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule(SWIG_name, SwigMethods); +#endif + + md = d = PyModule_GetDict(m); + (void)md; + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + swigpyobject = SwigPyObject_TypeOnce(); + + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = swigpyobject; + } else if (swigpyobject->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_VERSION_NUMBER",SWIG_From_long((long)(0x1010108fL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_VERSION_TEXT",SWIG_FromCharPtr("OpenSSL 1.1.1h 22 Sep 2020")); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SHLIB_VERSION_HISTORY",SWIG_FromCharPtr("")); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SHLIB_VERSION_NUMBER",SWIG_FromCharPtr("1.1")); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_FILE",SWIG_FromCharPtr("/usr/include/openssl/opensslconf.h")); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_LINE",SWIG_From_int((int)(134))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_MIN_API",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_API_COMPAT",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "bio_noclose",SWIG_From_int((int)(BIO_NOCLOSE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "bio_close",SWIG_From_int((int)(BIO_CLOSE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_READ",SWIG_From_int((int)(0x01))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_WRITE",SWIG_From_int((int)(0x02))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_IO_SPECIAL",SWIG_From_int((int)(0x04))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_RWS",SWIG_From_int((int)((BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_SHOULD_RETRY",SWIG_From_int((int)(0x08))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "BIO_FLAGS_MEM_RDONLY",SWIG_From_int((int)(0x200))); + globals = SWIG_globals(); + if (!globals) { + PyErr_SetString(PyExc_TypeError, "Failure to create SWIG globals."); +#if PY_VERSION_HEX >= 0x03000000 + return NULL; +#else + return; +#endif + } + PyDict_SetItemString(md, "cvar", globals); + Py_DECREF(globals); + SwigPyBuiltin_AddPublicSymbol(public_interface, "cvar"); + SWIG_addvarlink(globals, "_bio_err", Swig_var__bio_err_get, Swig_var__bio_err_set); + + /* type '::pyfd_struct' */ + builtin_pytype = (PyTypeObject *)&SwigPyBuiltin__pyfd_struct_type; + builtin_pytype->tp_dict = d = PyDict_New(); + SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); + builtin_pytype->tp_new = PyType_GenericNew; + builtin_base_count = 0; + builtin_bases[builtin_base_count] = NULL; + SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); + PyDict_SetItemString(d, "this", this_descr); + PyDict_SetItemString(d, "thisown", thisown_descr); + if (PyType_Ready(builtin_pytype) < 0) { + PyErr_SetString(PyExc_TypeError, "Could not create type 'BIO_PYFD_CTX'."); +#if PY_VERSION_HEX >= 0x03000000 + return NULL; +#else + return; +#endif + } + Py_INCREF(builtin_pytype); + PyModule_AddObject(m, "BIO_PYFD_CTX", (PyObject *)builtin_pytype); + SwigPyBuiltin_AddPublicSymbol(public_interface, "BIO_PYFD_CTX"); + d = md; + SWIG_addvarlink(globals, "methods_fdp", Swig_var_methods_fdp_get, Swig_var_methods_fdp_set); + SWIG_addvarlink(globals, "_rand_err", Swig_var__rand_err_get, Swig_var__rand_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS5_SALT_LEN",SWIG_From_int((int)(8))); + SWIG_addvarlink(globals, "_evp_err", Swig_var__evp_err_get, Swig_var__evp_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "AES_BLOCK_SIZE",SWIG_From_int((int)(AES_BLOCK_SIZE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_NO_RC4",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_ok",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_p_not_prime",SWIG_From_int((int)(DH_CHECK_P_NOT_PRIME))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_p_not_strong",SWIG_From_int((int)(DH_CHECK_P_NOT_STRONG_PRIME))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_g_failed",SWIG_From_int((int)(DH_UNABLE_TO_CHECK_GENERATOR))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "dh_check_bad_g",SWIG_From_int((int)(DH_NOT_SUITABLE_GENERATOR))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "DH_GENERATOR_2",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "DH_GENERATOR_5",SWIG_From_int((int)(5))); + SWIG_addvarlink(globals, "_dh_err", Swig_var__dh_err_get, Swig_var__dh_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "no_padding",SWIG_From_int((int)(RSA_NO_PADDING))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "pkcs1_padding",SWIG_From_int((int)(RSA_PKCS1_PADDING))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "sslv23_padding",SWIG_From_int((int)(RSA_SSLV23_PADDING))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "pkcs1_oaep_padding",SWIG_From_int((int)(RSA_PKCS1_OAEP_PADDING))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha1",SWIG_From_int((int)(NID_sha1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha224",SWIG_From_int((int)(NID_sha224))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha256",SWIG_From_int((int)(NID_sha256))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha384",SWIG_From_int((int)(NID_sha384))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sha512",SWIG_From_int((int)(NID_sha512))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_md5",SWIG_From_int((int)(NID_md5))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_ripemd160",SWIG_From_int((int)(NID_ripemd160))); + SWIG_addvarlink(globals, "_rsa_err", Swig_var__rsa_err_get, Swig_var__rsa_err_set); + SWIG_addvarlink(globals, "_dsa_err", Swig_var__dsa_err_get, Swig_var__dsa_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_none",SWIG_From_int((int)(SSL_ERROR_NONE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_ssl",SWIG_From_int((int)(SSL_ERROR_SSL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_read",SWIG_From_int((int)(SSL_ERROR_WANT_READ))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_write",SWIG_From_int((int)(SSL_ERROR_WANT_WRITE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_x509_lookup",SWIG_From_int((int)(SSL_ERROR_WANT_X509_LOOKUP))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_syscall",SWIG_From_int((int)(SSL_ERROR_SYSCALL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_zero_return",SWIG_From_int((int)(SSL_ERROR_ZERO_RETURN))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ssl_error_want_connect",SWIG_From_int((int)(SSL_ERROR_WANT_CONNECT))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_NONE",SWIG_From_int((int)(0x00))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_PEER",SWIG_From_int((int)(0x01))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_FAIL_IF_NO_PEER_CERT",SWIG_From_int((int)(0x02))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_VERIFY_CLIENT_ONCE",SWIG_From_int((int)(0x04))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK_LEAF",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK_CHAIN",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_CONNECT",SWIG_From_int((int)(0x1000))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_ACCEPT",SWIG_From_int((int)(0x2000))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_MASK",SWIG_From_int((int)(0x0FFF))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_INIT",SWIG_From_int((int)((SSL_ST_CONNECT|SSL_ST_ACCEPT)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_BEFORE",SWIG_From_int((int)(0x4000))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_OK",SWIG_From_int((int)(0x03))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_ST_RENEGOTIATE",SWIG_From_int((int)((0x04|SSL_ST_CONNECT|SSL_ST_ACCEPT)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_LOOP",SWIG_From_int((int)(0x01))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_EXIT",SWIG_From_int((int)(0x02))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_READ",SWIG_From_int((int)(0x04))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_WRITE",SWIG_From_int((int)(0x08))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_ALERT",SWIG_From_int((int)(0x4000))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_READ_ALERT",SWIG_From_int((int)((SSL_CB_ALERT|SSL_CB_READ)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_WRITE_ALERT",SWIG_From_int((int)((SSL_CB_ALERT|SSL_CB_WRITE)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_ACCEPT_LOOP",SWIG_From_int((int)((SSL_ST_ACCEPT|SSL_CB_LOOP)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_ACCEPT_EXIT",SWIG_From_int((int)((SSL_ST_ACCEPT|SSL_CB_EXIT)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_CONNECT_LOOP",SWIG_From_int((int)((SSL_ST_CONNECT|SSL_CB_LOOP)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_CONNECT_EXIT",SWIG_From_int((int)((SSL_ST_CONNECT|SSL_CB_EXIT)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_HANDSHAKE_START",SWIG_From_int((int)(0x10))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_CB_HANDSHAKE_DONE",SWIG_From_int((int)(0x20))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SENT_SHUTDOWN",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_RECEIVED_SHUTDOWN",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_OFF",SWIG_From_int((int)(0x000))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_CLIENT",SWIG_From_int((int)(0x001))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_SERVER",SWIG_From_int((int)(0x002))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_SESS_CACHE_BOTH",SWIG_From_int((int)((SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_ALL",SWIG_From_int((int)(0x00000FFFL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_NO_SSLv2",SWIG_From_int((int)(0x01000000L))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_NO_SSLv3",SWIG_From_int((int)(0x02000000L))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_NO_TLSv1",SWIG_From_int((int)(0x04000000L))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS",SWIG_From_int((int)(0x00000800L))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_MODE_ENABLE_PARTIAL_WRITE",SWIG_From_int((int)(SSL_MODE_ENABLE_PARTIAL_WRITE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER",SWIG_From_int((int)(SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "SSL_MODE_AUTO_RETRY",SWIG_From_int((int)(SSL_MODE_AUTO_RETRY))); + SWIG_addvarlink(globals, "_ssl_err", Swig_var__ssl_err_get, Swig_var__ssl_err_set); + SWIG_addvarlink(globals, "_ssl_timeout_err", Swig_var__ssl_timeout_err_get, Swig_var__ssl_timeout_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_DEFAULT",SWIG_From_int((int)(-1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_COMPAT",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_SSL_CLIENT",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_SSL_SERVER",SWIG_From_int((int)(3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_EMAIL",SWIG_From_int((int)(4))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_OBJECT_SIGN",SWIG_From_int((int)(5))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_OCSP_SIGN",SWIG_From_int((int)(6))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_OCSP_REQUEST",SWIG_From_int((int)(7))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_DYNAMIC",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_DYNAMIC_NAME",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_TRUSTED",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_REJECTED",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_TRUST_UNTRUSTED",SWIG_From_int((int)(3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SSL_CLIENT",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SSL_SERVER",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_NS_SSL_SERVER",SWIG_From_int((int)(3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SMIME_SIGN",SWIG_From_int((int)(4))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_SMIME_ENCRYPT",SWIG_From_int((int)(5))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_CRL_SIGN",SWIG_From_int((int)(6))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_ANY",SWIG_From_int((int)(7))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_PURPOSE_OCSP_HELPER",SWIG_From_int((int)(8))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_UNKNOWN_MASK",SWIG_From_long((long)((0xfL << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_DEFAULT",SWIG_From_long((long)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_ERROR_UNKNOWN",SWIG_From_long((long)((1L << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_PARSE_UNKNOWN",SWIG_From_long((long)((2L << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509V3_EXT_DUMP_UNKNOWN",SWIG_From_long((long)((3L << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_commonName",SWIG_From_int((int)(13))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_countryName",SWIG_From_int((int)(14))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_localityName",SWIG_From_int((int)(15))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_stateOrProvinceName",SWIG_From_int((int)(16))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_organizationName",SWIG_From_int((int)(17))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_organizationalUnitName",SWIG_From_int((int)(18))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_serialNumber",SWIG_From_int((int)(105))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_surname",SWIG_From_int((int)(100))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_givenName",SWIG_From_int((int)(99))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_pkcs9_emailAddress",SWIG_From_int((int)(48))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_OK",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_GET_CRL",SWIG_From_int((int)(3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE",SWIG_From_int((int)(4))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE",SWIG_From_int((int)(5))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY",SWIG_From_int((int)(6))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_SIGNATURE_FAILURE",SWIG_From_int((int)(7))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CRL_SIGNATURE_FAILURE",SWIG_From_int((int)(8))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_NOT_YET_VALID",SWIG_From_int((int)(9))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_HAS_EXPIRED",SWIG_From_int((int)(10))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CRL_NOT_YET_VALID",SWIG_From_int((int)(11))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CRL_HAS_EXPIRED",SWIG_From_int((int)(12))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD",SWIG_From_int((int)(13))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD",SWIG_From_int((int)(14))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD",SWIG_From_int((int)(15))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD",SWIG_From_int((int)(16))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_OUT_OF_MEM",SWIG_From_int((int)(17))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT",SWIG_From_int((int)(18))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN",SWIG_From_int((int)(19))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY",SWIG_From_int((int)(20))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE",SWIG_From_int((int)(21))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_CHAIN_TOO_LONG",SWIG_From_int((int)(22))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_REVOKED",SWIG_From_int((int)(23))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_INVALID_CA",SWIG_From_int((int)(24))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_PATH_LENGTH_EXCEEDED",SWIG_From_int((int)(25))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_INVALID_PURPOSE",SWIG_From_int((int)(26))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_UNTRUSTED",SWIG_From_int((int)(27))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_CERT_REJECTED",SWIG_From_int((int)(28))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "X509_V_ERR_APPLICATION_VERIFICATION",SWIG_From_int((int)(50))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_ALLOW_PROXY_CERTS",SWIG_From_int((int)(X509_V_FLAG_ALLOW_PROXY_CERTS))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CB_ISSUER_CHECK",SWIG_From_int((int)(X509_V_FLAG_CB_ISSUER_CHECK))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CHECK_SS_SIGNATURE",SWIG_From_int((int)(X509_V_FLAG_CHECK_SS_SIGNATURE))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_CRL_CHECK_ALL",SWIG_From_int((int)(X509_V_FLAG_CRL_CHECK_ALL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_EXPLICIT_POLICY",SWIG_From_int((int)(X509_V_FLAG_EXPLICIT_POLICY))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_EXTENDED_CRL_SUPPORT",SWIG_From_int((int)(X509_V_FLAG_EXTENDED_CRL_SUPPORT))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_IGNORE_CRITICAL",SWIG_From_int((int)(X509_V_FLAG_IGNORE_CRITICAL))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_INHIBIT_ANY",SWIG_From_int((int)(X509_V_FLAG_INHIBIT_ANY))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_INHIBIT_MAP",SWIG_From_int((int)(X509_V_FLAG_INHIBIT_MAP))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_NO_ALT_CHAINS",SWIG_From_int((int)(X509_V_FLAG_NO_ALT_CHAINS))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_NOTIFY_POLICY",SWIG_From_int((int)(X509_V_FLAG_NOTIFY_POLICY))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_PARTIAL_CHAIN",SWIG_From_int((int)(X509_V_FLAG_PARTIAL_CHAIN))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_POLICY_CHECK",SWIG_From_int((int)(X509_V_FLAG_POLICY_CHECK))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_TRUSTED_FIRST",SWIG_From_int((int)(X509_V_FLAG_TRUSTED_FIRST))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_USE_DELTAS",SWIG_From_int((int)(X509_V_FLAG_USE_DELTAS))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "VERIFY_X509_STRICT",SWIG_From_int((int)(X509_V_FLAG_X509_STRICT))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_COMPAT",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SEP_COMMA_PLUS",SWIG_From_int((int)((1 << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SEP_CPLUS_SPC",SWIG_From_int((int)((2 << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SEP_MULTILINE",SWIG_From_int((int)((4 << 16)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_DN_REV",SWIG_From_int((int)((1 << 20)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_FN_LN",SWIG_From_int((int)((1 << 21)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_SPC_EQ",SWIG_From_int((int)((1 << 23)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_DUMP_UNKNOWN_FIELDS",SWIG_From_int((int)((1 << 24)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_FN_ALIGN",SWIG_From_int((int)((1 << 25)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_ONELINE",SWIG_From_int((int)((ASN1_STRFLGS_RFC2253|ASN1_STRFLGS_ESC_QUOTE|XN_FLAG_SEP_CPLUS_SPC|XN_FLAG_SPC_EQ)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_MULTILINE",SWIG_From_int((int)((ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB|XN_FLAG_SEP_MULTILINE|XN_FLAG_SPC_EQ|XN_FLAG_FN_LN|XN_FLAG_FN_ALIGN)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "XN_FLAG_RFC2253",SWIG_From_int((int)((ASN1_STRFLGS_RFC2253|XN_FLAG_SEP_COMMA_PLUS|XN_FLAG_DN_REV|XN_FLAG_DUMP_UNKNOWN_FIELDS)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "RSA_3",SWIG_From_int((int)(0x3L))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "RSA_F4",SWIG_From_int((int)(0x10001L))); + SWIG_addvarlink(globals, "_x509_err", Swig_var__x509_err_get, Swig_var__x509_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_2253",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_CTRL",SWIG_From_int((int)(2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_MSB",SWIG_From_int((int)(4))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_ESC_QUOTE",SWIG_From_int((int)(8))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_UTF8_CONVERT",SWIG_From_int((int)(0x10))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_IGNORE_TYPE",SWIG_From_int((int)(0x20))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_SHOW_TYPE",SWIG_From_int((int)(0x40))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_DUMP_ALL",SWIG_From_int((int)(0x80))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_DUMP_UNKNOWN",SWIG_From_int((int)(0x100))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_DUMP_DER",SWIG_From_int((int)(0x200))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ASN1_STRFLGS_RFC2253",SWIG_From_int((int)((ASN1_STRFLGS_ESC_2253|ASN1_STRFLGS_ESC_CTRL|ASN1_STRFLGS_ESC_MSB|ASN1_STRFLGS_UTF8_CONVERT|ASN1_STRFLGS_DUMP_UNKNOWN|ASN1_STRFLGS_DUMP_DER)))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_TEXT",SWIG_From_int((int)(0x1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOCERTS",SWIG_From_int((int)(0x2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOSIGS",SWIG_From_int((int)(0x4))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOCHAIN",SWIG_From_int((int)(0x8))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOINTERN",SWIG_From_int((int)(0x10))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOVERIFY",SWIG_From_int((int)(0x20))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_DETACHED",SWIG_From_int((int)(0x40))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_BINARY",SWIG_From_int((int)(0x80))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_NOATTR",SWIG_From_int((int)(0x100))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_SIGNED",SWIG_From_int((int)(NID_pkcs7_signed))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_ENVELOPED",SWIG_From_int((int)(NID_pkcs7_enveloped))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_SIGNED_ENVELOPED",SWIG_From_int((int)(NID_pkcs7_signedAndEnveloped))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "PKCS7_DATA",SWIG_From_int((int)(NID_pkcs7_data))); + SWIG_addvarlink(globals, "_pkcs7_err", Swig_var__pkcs7_err_get, Swig_var__pkcs7_err_set); + SWIG_addvarlink(globals, "_smime_err", Swig_var__smime_err_get, Swig_var__smime_err_set); + SWIG_addvarlink(globals, "_util_err", Swig_var__util_err_get, Swig_var__util_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "OPENSSL_NO_EC",SWIG_From_int((int)(0))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp112r1",SWIG_From_int((int)(NID_secp112r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp112r2",SWIG_From_int((int)(NID_secp112r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp128r1",SWIG_From_int((int)(NID_secp128r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp128r2",SWIG_From_int((int)(NID_secp128r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp160k1",SWIG_From_int((int)(NID_secp160k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp160r1",SWIG_From_int((int)(NID_secp160r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp160r2",SWIG_From_int((int)(NID_secp160r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp192k1",SWIG_From_int((int)(NID_secp192k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp224k1",SWIG_From_int((int)(NID_secp224k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp224r1",SWIG_From_int((int)(NID_secp224r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp256k1",SWIG_From_int((int)(NID_secp256k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp384r1",SWIG_From_int((int)(NID_secp384r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_secp521r1",SWIG_From_int((int)(NID_secp521r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect113r1",SWIG_From_int((int)(NID_sect113r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect113r2",SWIG_From_int((int)(NID_sect113r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect131r1",SWIG_From_int((int)(NID_sect131r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect131r2",SWIG_From_int((int)(NID_sect131r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect163k1",SWIG_From_int((int)(NID_sect163k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect163r1",SWIG_From_int((int)(NID_sect163r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect163r2",SWIG_From_int((int)(NID_sect163r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect193r1",SWIG_From_int((int)(NID_sect193r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect193r2",SWIG_From_int((int)(NID_sect193r2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect233k1",SWIG_From_int((int)(NID_sect233k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect233r1",SWIG_From_int((int)(NID_sect233r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect239k1",SWIG_From_int((int)(NID_sect239k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect283k1",SWIG_From_int((int)(NID_sect283k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect283r1",SWIG_From_int((int)(NID_sect283r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect409k1",SWIG_From_int((int)(NID_sect409k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect409r1",SWIG_From_int((int)(NID_sect409r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect571k1",SWIG_From_int((int)(NID_sect571k1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_sect571r1",SWIG_From_int((int)(NID_sect571r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime192v1",SWIG_From_int((int)(NID_X9_62_prime192v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime192v2",SWIG_From_int((int)(NID_X9_62_prime192v2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime192v3",SWIG_From_int((int)(NID_X9_62_prime192v3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime239v1",SWIG_From_int((int)(NID_X9_62_prime239v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime239v2",SWIG_From_int((int)(NID_X9_62_prime239v2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime239v3",SWIG_From_int((int)(NID_X9_62_prime239v3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_prime256v1",SWIG_From_int((int)(NID_X9_62_prime256v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb163v1",SWIG_From_int((int)(NID_X9_62_c2pnb163v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb163v2",SWIG_From_int((int)(NID_X9_62_c2pnb163v2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb163v3",SWIG_From_int((int)(NID_X9_62_c2pnb163v3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb176v1",SWIG_From_int((int)(NID_X9_62_c2pnb176v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb191v1",SWIG_From_int((int)(NID_X9_62_c2tnb191v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb191v2",SWIG_From_int((int)(NID_X9_62_c2tnb191v2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb191v3",SWIG_From_int((int)(NID_X9_62_c2tnb191v3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb208w1",SWIG_From_int((int)(NID_X9_62_c2pnb208w1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb239v1",SWIG_From_int((int)(NID_X9_62_c2tnb239v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb239v2",SWIG_From_int((int)(NID_X9_62_c2tnb239v2))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb239v3",SWIG_From_int((int)(NID_X9_62_c2tnb239v3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb272w1",SWIG_From_int((int)(NID_X9_62_c2pnb272w1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb304w1",SWIG_From_int((int)(NID_X9_62_c2pnb304w1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb359v1",SWIG_From_int((int)(NID_X9_62_c2tnb359v1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2pnb368w1",SWIG_From_int((int)(NID_X9_62_c2pnb368w1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_X9_62_c2tnb431r1",SWIG_From_int((int)(NID_X9_62_c2tnb431r1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls1",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls3",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls4",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls4))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls5",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls5))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls6",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls6))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls7",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls7))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls8",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls8))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls9",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls9))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls10",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls10))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls11",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls11))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_wap_wsg_idm_ecid_wtls12",SWIG_From_int((int)(NID_wap_wsg_idm_ecid_wtls12))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_ipsec3",SWIG_From_int((int)(NID_ipsec3))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "NID_ipsec4",SWIG_From_int((int)(NID_ipsec4))); + SWIG_addvarlink(globals, "_ec_err", Swig_var__ec_err_get, Swig_var__ec_err_set); + + /* type '::_cbd_t' */ + builtin_pytype = (PyTypeObject *)&SwigPyBuiltin___cbd_t_type; + builtin_pytype->tp_dict = d = PyDict_New(); + SwigPyBuiltin_SetMetaType(builtin_pytype, metatype); + builtin_pytype->tp_new = PyType_GenericNew; + builtin_base_count = 0; + builtin_bases[builtin_base_count] = NULL; + SwigPyBuiltin_InitBases(builtin_pytype, builtin_bases); + PyDict_SetItemString(d, "this", this_descr); + PyDict_SetItemString(d, "thisown", thisown_descr); + if (PyType_Ready(builtin_pytype) < 0) { + PyErr_SetString(PyExc_TypeError, "Could not create type '_cbd_t'."); +#if PY_VERSION_HEX >= 0x03000000 + return NULL; +#else + return; +#endif + } + Py_INCREF(builtin_pytype); + PyModule_AddObject(m, "_cbd_t", (PyObject *)builtin_pytype); + SwigPyBuiltin_AddPublicSymbol(public_interface, "_cbd_t"); + d = md; + SWIG_addvarlink(globals, "_engine_err", Swig_var__engine_err_get, Swig_var__engine_err_set); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_RSA",SWIG_From_int((int)(0x0001))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_DSA",SWIG_From_int((int)(0x0002))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_DH",SWIG_From_int((int)(0x0004))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_RAND",SWIG_From_int((int)(0x0008))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_ECDH",SWIG_From_int((int)(0x0010))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_ECDSA",SWIG_From_int((int)(0x0020))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_CIPHERS",SWIG_From_int((int)(0x0040))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_DIGESTS",SWIG_From_int((int)(0x0080))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_STORE",SWIG_From_int((int)(0x0100))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_ALL",SWIG_From_int((int)(0xFFFF))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "ENGINE_METHOD_NONE",SWIG_From_int((int)(0x0000))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "encrypt",SWIG_From_int((int)(1))); + SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "decrypt",SWIG_From_int((int)(0))); + + /* Initialize threading */ + SWIG_PYTHON_INITIALIZE_THREADS; +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/src/SWIG/_objects.i b/src/SWIG/_objects.i new file mode 100644 index 0000000..b389d7f --- /dev/null +++ b/src/SWIG/_objects.i @@ -0,0 +1,97 @@ +/* + * -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: syntax=c sts=4 sw=4 + * + * ASN1_OBJECT manipulation functions from OBJ_obj2txt(3SSL). + * + * Pavel Shramov + * IMEC MSU + */ +%{ +#include +%} + +%apply Pointer NONNULL { ASN1_OBJECT * }; +%apply Pointer NONNULL { const char * }; + +%rename(obj_nid2obj) OBJ_nid2obj; +extern ASN1_OBJECT * OBJ_nid2obj(int n); +%rename(obj_nid2ln) OBJ_nid2ln; +extern const char * OBJ_nid2ln(int n); +%rename(obj_nid2sn) OBJ_nid2sn; +extern const char * OBJ_nid2sn(int n); + +%rename(obj_obj2nid) OBJ_obj2nid; +extern int OBJ_obj2nid(const ASN1_OBJECT *o); + +%rename(obj_ln2nid) OBJ_ln2nid; +extern int OBJ_ln2nid(const char *ln); +%rename(obj_sn2nid) OBJ_sn2nid; +extern int OBJ_sn2nid(const char *sn); + +%rename(obj_txt2nid) OBJ_txt2nid; +extern int OBJ_txt2nid(const char *s); + +%rename(obj_txt2obj) OBJ_txt2obj; +extern ASN1_OBJECT * OBJ_txt2obj(const char *s, int no_name); + + +%rename(_obj_obj2txt) OBJ_obj2txt; +extern int OBJ_obj2txt(char *, int, const ASN1_OBJECT *, int); + + +%inline %{ +/* + From the manpage for OBJ_obt2txt (): + BUGS + OBJ_obj2txt() is awkward and messy to use: it doesn’t follow the + convention of other OpenSSL functions where the buffer can be set + to NULL to determine the amount of data that should be written. + Instead buf must point to a valid buffer and buf_len should be set + to a positive value. A buffer length of 80 should be more than + enough to handle any OID encountered in practice. + + The first call to OBJ_obj2txt () therefore passes a non-NULL dummy + buffer. This wart is reportedly removed in OpenSSL 0.9.8b, although + the manpage has not been updated. + + OBJ_obj2txt always prints \0 at the end. But the return value + is the number of "good" bytes written. So memory is allocated for + len + 1 bytes but only len bytes are marshalled to python. +*/ +PyObject *obj_obj2txt(const ASN1_OBJECT *obj, int no_name) +{ + int len; + PyObject *ret; + char *buf; + char dummy[1]; + + len = OBJ_obj2txt(dummy, 1, obj, no_name); + if (len < 0) { + m2_PyErr_Msg(PyExc_RuntimeError); + return NULL; + } else if (len == 0) { + /* XXX: For OpenSSL prior to 0.9.8b. + + Changes between 0.9.8a and 0.9.8b [04 May 2006] + ... + *) Several fixes and enhancements to the OID generation code. The old code + sometimes allowed invalid OIDs (1.X for X >= 40 for example), couldn't + handle numbers larger than ULONG_MAX, truncated printing and had a + non standard OBJ_obj2txt() behaviour. + [Steve Henson] + */ + + len = 80; + } + + buf = PyMem_Malloc(len + 1); + len = OBJ_obj2txt(buf, len + 1, obj, no_name); + + ret = PyBytes_FromStringAndSize(buf, len); + + PyMem_Free(buf); + + return ret; +} +%} diff --git a/src/SWIG/_pkcs7.i b/src/SWIG/_pkcs7.i new file mode 100644 index 0000000..d1fddfb --- /dev/null +++ b/src/SWIG/_pkcs7.i @@ -0,0 +1,284 @@ +/* Copyright (c) 2000 Ng Pheng Siong. All rights reserved. + * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. +*/ +/* $Id$ */ + +%{ +#include +#include +#include +#include +%} + +%apply Pointer NONNULL { BIO * }; +%apply Pointer NONNULL { EVP_CIPHER * }; +%apply Pointer NONNULL { EVP_PKEY * }; +%apply Pointer NONNULL { PKCS7 * }; +%apply Pointer NONNULL { STACK_OF(X509) * }; +%apply Pointer NONNULL { X509 * }; + +%rename(pkcs7_new) PKCS7_new; +extern PKCS7 *PKCS7_new(void); +%rename(pkcs7_free) PKCS7_free; +extern void PKCS7_free(PKCS7 *); +%rename(pkcs7_add_certificate) PKCS7_add_certificate; +extern void PKCS7_add_certificate(PKCS7 *, X509 *); + +/* S/MIME operation */ +%constant int PKCS7_TEXT = 0x1; +%constant int PKCS7_NOCERTS = 0x2; +%constant int PKCS7_NOSIGS = 0x4; +%constant int PKCS7_NOCHAIN = 0x8; +%constant int PKCS7_NOINTERN = 0x10; +%constant int PKCS7_NOVERIFY = 0x20; +%constant int PKCS7_DETACHED = 0x40; +%constant int PKCS7_BINARY = 0x80; +%constant int PKCS7_NOATTR = 0x100; + +%constant int PKCS7_SIGNED = NID_pkcs7_signed; +%constant int PKCS7_ENVELOPED = NID_pkcs7_enveloped; +%constant int PKCS7_SIGNED_ENVELOPED = NID_pkcs7_signedAndEnveloped; +%constant int PKCS7_DATA = NID_pkcs7_data; + +%warnfilter(454) _pkcs7_err; +%warnfilter(454) _smime_err; +%inline %{ +static PyObject *_pkcs7_err, *_smime_err; + +void pkcs7_init(PyObject *pkcs7_err) { + Py_INCREF(pkcs7_err); + _pkcs7_err = pkcs7_err; +} + +void smime_init(PyObject *smime_err) { + Py_INCREF(smime_err); + _smime_err = smime_err; +} +%} + +%inline %{ +PyObject *pkcs7_decrypt(PKCS7 *pkcs7, EVP_PKEY *pkey, X509 *cert, int flags) { + int outlen; + char *outbuf; + BIO *bio; + PyObject *ret; + + if (!(bio=BIO_new(BIO_s_mem()))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); + return NULL; + } + if (!PKCS7_decrypt(pkcs7, pkey, cert, bio, flags)) { + m2_PyErr_Msg(_pkcs7_err); + BIO_free(bio); + return NULL; + } + outlen = BIO_ctrl_pending(bio); + if (!(outbuf=(char *)PyMem_Malloc(outlen))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_decrypt"); + BIO_free(bio); + return NULL; + } + BIO_read(bio, outbuf, outlen); + + ret = PyBytes_FromStringAndSize(outbuf, outlen); + + BIO_free(bio); + PyMem_Free(outbuf); + return ret; +} +%} + +%typemap(out) PKCS7 * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_smime_err); + $result = NULL; + } +} +%threadallow pkcs7_encrypt; +%inline %{ +PKCS7 *pkcs7_encrypt(STACK_OF(X509) *stack, BIO *bio, EVP_CIPHER *cipher, int flags) { + return PKCS7_encrypt(stack, bio, cipher, flags); +} + +%} + +%threadallow pkcs7_sign1; +%inline %{ +PKCS7 *pkcs7_sign1(X509 *x509, EVP_PKEY *pkey, STACK_OF(X509) *stack, BIO *bio, EVP_MD *hash, int flags) { + + PKCS7 *p7 = PKCS7_sign(NULL, NULL, stack, bio, flags | PKCS7_STREAM); + if (p7 == NULL) { + return NULL; + } + if (PKCS7_sign_add_signer(p7, x509, pkey, hash, flags) == NULL) { + return NULL; + } + if (PKCS7_final(p7, bio, flags) != 1) { + return NULL; + } + return p7; +} +%} + +%threadallow pkcs7_sign0; +%inline %{ +PKCS7 *pkcs7_sign0(X509 *x509, EVP_PKEY *pkey, BIO *bio, EVP_MD *hash, int flags) { + return pkcs7_sign1(x509, pkey, NULL, bio, hash, flags); +} +%} + +%typemap(out) PKCS7 * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_pkcs7_err); + $result = NULL; + } +} +%threadallow pkcs7_read_bio; +%inline %{ +PKCS7 *pkcs7_read_bio(BIO *bio) { + return PEM_read_bio_PKCS7(bio, NULL, NULL, NULL); +} +%} + +%threadallow pkcs7_read_bio_der; +%inline %{ +PKCS7 *pkcs7_read_bio_der(BIO *bio) { + return d2i_PKCS7_bio(bio, NULL); +} +%} + +%typemap(out) PKCS7 * ; + +%inline %{ +PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, BIO *data, int flags) { + int res, outlen; + char *outbuf; + BIO *bio; + PyObject *ret; + + if (!(bio=BIO_new(BIO_s_mem()))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + res = PKCS7_verify(pkcs7, stack, store, data, bio, flags); + Py_END_ALLOW_THREADS + if (!res) { + m2_PyErr_Msg(_pkcs7_err); + BIO_free(bio); + return NULL; + } + outlen = BIO_ctrl_pending(bio); + if (!(outbuf=(char *)PyMem_Malloc(outlen))) { + PyErr_SetString(PyExc_MemoryError, "pkcs7_verify1"); + BIO_free(bio); + return NULL; + } + BIO_read(bio, outbuf, outlen); + + ret = PyBytes_FromStringAndSize(outbuf, outlen); + + BIO_free(bio); + PyMem_Free(outbuf); + return ret; +} + +PyObject *pkcs7_verify0(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, int flags) { + return pkcs7_verify1(pkcs7, stack, store, NULL, flags); +} +%} + +%threadallow smime_write_pkcs7_multi; +%inline %{ +int smime_write_pkcs7_multi(BIO *bio, PKCS7 *pkcs7, BIO *data, int flags) { + return SMIME_write_PKCS7(bio, pkcs7, data, flags | PKCS7_DETACHED); +} +%} + +%threadallow smime_write_pkcs7; +%inline %{ +int smime_write_pkcs7(BIO *bio, PKCS7 *pkcs7, int flags) { + return SMIME_write_PKCS7(bio, pkcs7, NULL, flags); +} + +PyObject *smime_read_pkcs7(BIO *bio) { + BIO *bcont = NULL; + PKCS7 *p7; + PyObject *tuple, *_p7, *_BIO; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if (BIO_method_type(bio) == BIO_TYPE_MEM) { + /* OpenSSL FAQ explains that this is needed for mem BIO to return EOF, + * like file BIO does. Might need to do this for more mem BIOs but + * not sure if that is safe, so starting with just this single place. + */ + BIO_set_mem_eof_return(bio, 0); + } + + Py_BEGIN_ALLOW_THREADS + p7=SMIME_read_PKCS7(bio, &bcont); + Py_END_ALLOW_THREADS + if (!p7) { + m2_PyErr_Msg(_smime_err); + return NULL; + } + if (!(tuple=PyTuple_New(2))) { + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + return NULL; + } + _p7 = SWIG_NewPointerObj((void *)p7, SWIGTYPE_p_PKCS7, 0); + PyTuple_SET_ITEM(tuple, 0, _p7); + if (!bcont) { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(tuple, 1, Py_None); + } else { + _BIO = SWIG_NewPointerObj((void *)bcont, SWIGTYPE_p_BIO, 0); + PyTuple_SET_ITEM(tuple, 1, _BIO); + } + return tuple; +} +%} + +%threadallow pkcs7_write_bio; +%inline %{ +int pkcs7_write_bio(PKCS7 *pkcs7, BIO* bio) { + return PEM_write_bio_PKCS7(bio, pkcs7); +} +%} + +%threadallow pkcs7_write_bio_der; +%inline %{ +int pkcs7_write_bio_der(PKCS7 *pkcs7, BIO *bio) { + return i2d_PKCS7_bio(bio, pkcs7); +} + +int pkcs7_type_nid(PKCS7 *pkcs7) { + return OBJ_obj2nid(pkcs7->type); +} + +const char *pkcs7_type_sn(PKCS7 *pkcs7) { + return OBJ_nid2sn(OBJ_obj2nid(pkcs7->type)); +} +%} + +%threadallow smime_crlf_copy; +%inline %{ +int smime_crlf_copy(BIO *in, BIO *out) { + return SMIME_crlf_copy(in, out, PKCS7_TEXT); +} + +/* return STACK_OF(X509)* */ +STACK_OF(X509) *pkcs7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags) { + return PKCS7_get0_signers(p7, certs, flags); +} + +%} + diff --git a/src/SWIG/_py3k_compat.i b/src/SWIG/_py3k_compat.i new file mode 100644 index 0000000..7c90bb4 --- /dev/null +++ b/src/SWIG/_py3k_compat.i @@ -0,0 +1,43 @@ +%{ +#if PY_MAJOR_VERSION >= 3 + +FILE* PyFile_AsFile(PyObject *pyfile) { + FILE* fp; + int fd; + const char *mode_str = NULL; + PyObject *mode_obj; + + if ((fd = PyObject_AsFileDescriptor(pyfile)) == -1) { + PyErr_SetString(PyExc_BlockingIOError, + "Cannot find file handler for the Python file!"); + return NULL; + } + + if ((mode_obj = PyObject_GetAttrString(pyfile, "mode")) == NULL) { + mode_str = "rb"; + PyErr_Clear(); + } + else { + /* convert to plain string + * note that error checking is embedded in the function + */ + mode_str = PyUnicode_AsUTF8AndSize(mode_obj, NULL); + } + + if((fp = fdopen(fd, mode_str)) == NULL) { + PyErr_SetFromErrno(PyExc_IOError); + } + + Py_XDECREF(mode_obj); + return fp; +} + +#else /* PY2K */ + +#define PyLong_FromLong(x) PyInt_FromLong(x) +#define PyUnicode_AsUTF8(x) PyString_AsString(x) +#define PyUnicode_FromString(x) PyString_FromString(x) +#define PyUnicode_Format(x, y) PyString_Format(x, y) + +#endif /* PY_MAJOR_VERSION */ +%} diff --git a/src/SWIG/_rand.i b/src/SWIG/_rand.i new file mode 100644 index 0000000..01ab4ef --- /dev/null +++ b/src/SWIG/_rand.i @@ -0,0 +1,150 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. + * Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. +*/ +/* $Id: _rand.i 721 2010-02-13 06:30:33Z heikki $ */ + +%module _rand + +%rename(rand_file_name) RAND_file_name; +extern const char *RAND_file_name(char *, size_t ); +%rename(rand_load_file) RAND_load_file; +extern int RAND_load_file(const char *, long); +%rename(rand_save_file) RAND_write_file; +extern int RAND_write_file(const char *); +%rename(rand_poll) RAND_poll; +extern int RAND_poll(void); +%rename(rand_status) RAND_status; +extern int RAND_status(void); +%rename(rand_cleanup) RAND_cleanup; +extern void RAND_cleanup(void); + +%warnfilter(454) _rand_err; +%inline %{ +static PyObject *_rand_err; + +void rand_init(PyObject *rand_err) { + Py_INCREF(rand_err); + _rand_err = rand_err; +} + +PyObject *rand_seed(PyObject *seed) { + const void *buf; + int len = 0; + + m2_PyObject_AsReadBufferInt(seed, &buf, &len); + + RAND_seed(buf, len); + Py_RETURN_NONE; +} + +PyObject *rand_add(PyObject *blob, double entropy) { + const void *buf; + int len = 0; + + m2_PyObject_AsReadBufferInt(blob, &buf, &len); + + RAND_add(buf, len, entropy); + Py_RETURN_NONE; +} + +PyObject *rand_bytes(int n) { + void *blob; + int ret; + PyObject *obj; + + if (!(blob = PyMem_Malloc(n))) { + PyErr_SetString(PyExc_MemoryError, + "Insufficient memory for rand_bytes."); + return NULL; + } + if ((ret = RAND_bytes(blob, n)) == 1) { + obj = PyBytes_FromStringAndSize(blob, n); + PyMem_Free(blob); + return obj; + } else if (ret == 0) { + PyErr_SetString(_rand_err, "Not enough randomness."); + PyMem_Free(blob); + return NULL; + } else if (ret == -1) { + PyErr_SetString(_rand_err, + "Not supported by the current RAND method."); + PyMem_Free(blob); + return NULL; + } else { + PyMem_Free(blob); + m2_PyErr_Msg(_rand_err); + return NULL; + } +} + +PyObject *rand_pseudo_bytes(int n) { + int ret; + unsigned char *blob; + PyObject *tuple; + + if (!(blob=(unsigned char *)PyMem_Malloc(n))) { + PyErr_SetString(PyExc_MemoryError, "Insufficient memory for rand_pseudo_bytes."); + return NULL; + } + if (!(tuple=PyTuple_New(2))) { + PyErr_SetString(PyExc_RuntimeError, "PyTuple_New() fails"); + PyMem_Free(blob); + return NULL; + } + ret = RAND_pseudo_bytes(blob, n); + if (ret == -1) { + PyMem_Free(blob); + Py_DECREF(tuple); + PyErr_SetString(_rand_err, + "Function RAND_pseudo_bytes not supported by the current RAND method."); + return NULL; + } else { + PyTuple_SET_ITEM(tuple, 0, PyBytes_FromStringAndSize((char*)blob, n)); + + PyMem_Free(blob); + PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong((long)ret)); + return tuple; + } +} + +PyObject *rand_file_name(void) { + PyObject *obj; + char *str; + if ((obj = PyBytes_FromStringAndSize(NULL, BUFSIZ))==NULL) { + PyErr_SetString(PyExc_MemoryError, "rand_file_name"); + return NULL; + } + str=PyBytes_AS_STRING(obj); + if (RAND_file_name(str, BUFSIZ)==NULL) { + PyErr_SetString(PyExc_RuntimeError, "rand_file_name"); + return NULL; + } + if (_PyBytes_Resize(&obj, (Py_ssize_t)strlen(str))!=0) + return NULL; /* mem exception set by _PyBytes_Resize */ + return obj; +} + +void rand_screen(void) { +#ifdef _WIN32 + RAND_screen(); +#endif +} + +int rand_win32_event(unsigned int imsg, int wparam, long lparam) { +#ifdef _WIN32 + return RAND_event(imsg, wparam, lparam); +#else + return 0; +#endif +} +%} + +/* +2004-04-05, ngps: Still missing: + RAND_egd + RAND_egd_bytes + RAND_query_egd_bytes +*/ + + diff --git a/src/SWIG/_rc4.i b/src/SWIG/_rc4.i new file mode 100644 index 0000000..eb4747e --- /dev/null +++ b/src/SWIG/_rc4.i @@ -0,0 +1,69 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%include + +#if defined(OPENSSL_NO_RC4) +#undef OPENSSL_NO_RC4 +%constant OPENSSL_NO_RC4 = 1; +#else +%constant OPENSSL_NO_RC4 = 0; + +%{ +#include +%} + +%apply Pointer NONNULL { RC4_KEY * }; + +%inline %{ +RC4_KEY *rc4_new(void) { + RC4_KEY *key; + + if (!(key = (RC4_KEY *)PyMem_Malloc(sizeof(RC4_KEY)))) + PyErr_SetString(PyExc_MemoryError, "rc4_new"); + return key; +} + +void rc4_free(RC4_KEY *key) { + PyMem_Free((void *)key); +} + +PyObject *rc4_set_key(RC4_KEY *key, PyObject *value) { + const void *vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + RC4_set_key(key, vlen, vbuf); + Py_RETURN_NONE; +} + +PyObject *rc4_update(RC4_KEY *key, PyObject *in) { + PyObject *ret; + const void *buf; + Py_ssize_t len; + void *out; + + if (PyObject_AsReadBuffer(in, &buf, &len) == -1) + return NULL; + + if (!(out = PyMem_Malloc(len))) { + PyErr_SetString(PyExc_MemoryError, "expected a string object"); + return NULL; + } + RC4(key, len, buf, out); + + ret = PyBytes_FromStringAndSize(out, len); + + PyMem_Free(out); + return ret; +} + +int rc4_type_check(RC4_KEY *key) { + return 1; +} +%} + +#endif diff --git a/src/SWIG/_rsa.i b/src/SWIG/_rsa.i new file mode 100644 index 0000000..4ffae01 --- /dev/null +++ b/src/SWIG/_rsa.i @@ -0,0 +1,518 @@ +/* Copyright (c) 1999-2000 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%{ +#include +#include +#include +#include +#include +%} + +%apply Pointer NONNULL { RSA * }; +%apply Pointer NONNULL { PyObject *pyfunc }; + +%rename(rsa_size) RSA_size; +extern int RSA_size(const RSA*); +%rename(rsa_new) RSA_new; +extern RSA *RSA_new(void); +%rename(rsa_free) RSA_free; +extern void RSA_free(RSA *); +%rename(rsa_check_key) RSA_check_key; +extern int RSA_check_key(const RSA *); + +%constant int no_padding = RSA_NO_PADDING; +%constant int pkcs1_padding = RSA_PKCS1_PADDING; +%constant int sslv23_padding = RSA_SSLV23_PADDING; +%constant int pkcs1_oaep_padding = RSA_PKCS1_OAEP_PADDING; + +%constant int NID_sha1 = NID_sha1; + +#if OPENSSL_VERSION_NUMBER >= 0x0090800fL +%constant int NID_sha224 = NID_sha224; +%constant int NID_sha256 = NID_sha256; +%constant int NID_sha384 = NID_sha384; +%constant int NID_sha512 = NID_sha512; +#endif + +%constant int NID_md5 = NID_md5; + +%constant int NID_ripemd160 = NID_ripemd160; + +%warnfilter(454) _rsa_err; +%inline %{ +static PyObject *_rsa_err; + +void rsa_init(PyObject *rsa_err) { + Py_INCREF(rsa_err); + _rsa_err = rsa_err; +} +%} + +%inline %{ +RSA *rsa_read_key(BIO *f, PyObject *pyfunc) { + RSA *rsa; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + rsa = PEM_read_bio_RSAPrivateKey(f, NULL, passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return rsa; +} +%} + +%inline %{ +int rsa_write_key(RSA *rsa, BIO *f, EVP_CIPHER *cipher, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_RSAPrivateKey(f, rsa, cipher, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%inline %{ +int rsa_write_key_no_cipher(RSA *rsa, BIO *f, PyObject *pyfunc) { + int ret; + + Py_INCREF(pyfunc); + Py_BEGIN_ALLOW_THREADS + ret = PEM_write_bio_RSAPrivateKey(f, rsa, NULL, NULL, 0, + passphrase_callback, (void *)pyfunc); + Py_END_ALLOW_THREADS + Py_DECREF(pyfunc); + return ret; +} +%} + +%threadallow rsa_read_pub_key; +%inline %{ +RSA *rsa_read_pub_key(BIO *f) { + return PEM_read_bio_RSA_PUBKEY(f, NULL, NULL, NULL); +} +%} + +%threadallow rsa_write_pub_key; +%inline %{ +int rsa_write_pub_key(RSA *rsa, BIO *f) { + return PEM_write_bio_RSA_PUBKEY(f, rsa); +} + +PyObject *rsa_get_e(RSA *rsa) { + const BIGNUM* e = NULL; + RSA_get0_key(rsa, NULL, &e, NULL); + if (!e) { + PyErr_SetString(_rsa_err, "'e' is unset"); + return NULL; + } + return bn_to_mpi(e); +} + +PyObject *rsa_get_n(RSA *rsa) { + const BIGNUM* n = NULL; + RSA_get0_key(rsa, &n, NULL, NULL); + if (!n) { + PyErr_SetString(_rsa_err, "'n' is unset"); + return NULL; + } + return bn_to_mpi(n); +} + +PyObject *rsa_set_e(RSA *rsa, PyObject *eval) { + const BIGNUM* n_read = NULL; + BIGNUM* n = NULL; + BIGNUM* e; + + if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err))) { + return NULL; + } + + /* n and e must be set at the same time so if e is unset, set it to zero */ + RSA_get0_key(rsa, &n_read, NULL, NULL); + if (!n_read) { + n = BN_new(); + } + + if (RSA_set0_key(rsa, n, e, NULL) != 1) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(e); + BN_free(n); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *rsa_set_n(RSA *rsa, PyObject *nval) { + BIGNUM* n; + const BIGNUM* e_read = NULL; + BIGNUM* e = NULL; + + if (!(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { + return NULL; + } + + /* n and e must be set at the same time so if e is unset, set it to zero */ + RSA_get0_key(rsa, NULL, &e_read, NULL); + if (!e_read) { + e = BN_new(); + } + + if (RSA_set0_key(rsa, n, e, NULL) != 1) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(n); + BN_free(e); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *rsa_set_en(RSA *rsa, PyObject *eval, PyObject* nval) { + BIGNUM* e, *n; + + if (!(e = m2_PyObject_AsBIGNUM(eval, _rsa_err)) || + !(n = m2_PyObject_AsBIGNUM(nval, _rsa_err))) { + return NULL; + } + + if (!RSA_set0_key(rsa, n, e, NULL)) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(e); + BN_free(n); + return NULL; + } + Py_RETURN_NONE; +} + +static BIGNUM* PyObject_Bin_AsBIGNUM(PyObject* value) { + BIGNUM* bn; + const void* vbuf; + int vlen = 0; + + if (m2_PyObject_AsReadBufferInt(value, &vbuf, &vlen) == -1) + return NULL; + + if (!(bn = BN_bin2bn((unsigned char *)vbuf, vlen, NULL))) { + m2_PyErr_Msg(_rsa_err); + return NULL; + } + + return bn; +} + +PyObject *rsa_set_en_bin(RSA *rsa, PyObject *eval, PyObject* nval) { + BIGNUM* e, *n; + + if (!(e = PyObject_Bin_AsBIGNUM(eval)) || + !(n = PyObject_Bin_AsBIGNUM(nval))) { + return NULL; + } + + if (!RSA_set0_key(rsa, e, n, NULL)) { + PyErr_SetString(_rsa_err, "Cannot set fields of RSA object."); + BN_free(e); + BN_free(n); + return NULL; + } + Py_RETURN_NONE; +} + +PyObject *rsa_private_encrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_private_encrypt"); + return NULL; + } + tlen = RSA_private_encrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +PyObject *rsa_public_decrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen = 0; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + /* OpenSSL docs are confused here: it says we only need buffer + * 'RSA_size()-11', but it is true only for RSA PKCS#1 type 1 + * padding. For other uses we need to use different sizes. */ + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_public_decrypt"); + return NULL; + } + tlen = RSA_public_decrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +PyObject *rsa_public_encrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_public_encrypt"); + return NULL; + } + tlen = RSA_public_encrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +PyObject *rsa_private_decrypt(RSA *rsa, PyObject *from, int padding) { + const void *fbuf; + void *tbuf; + int flen = 0, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(from, &fbuf, &flen) == -1) + return NULL; + + if (!(tbuf = PyMem_Malloc(RSA_size(rsa)))) { + PyErr_SetString(PyExc_MemoryError, "rsa_private_decrypt"); + return NULL; + } + tlen = RSA_private_decrypt(flen, (unsigned char *)fbuf, + (unsigned char *)tbuf, rsa, padding); + if (tlen == -1) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(tbuf); + return NULL; + } + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + + PyMem_Free(tbuf); + return ret; +} + +#if OPENSSL_VERSION_NUMBER >= 0x0090708fL +PyObject *rsa_padding_add_pkcs1_pss(RSA *rsa, PyObject *digest, EVP_MD *hash, int salt_length) { + const void *dbuf; + unsigned char *tbuf; + int dlen, result, tlen; + PyObject *ret; + + if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) + return NULL; + + tlen = RSA_size(rsa); + + if (!(tbuf = OPENSSL_malloc(tlen))) { + PyErr_SetString(PyExc_MemoryError, "rsa_padding_add_pkcs1_pss"); + return NULL; + } + result = RSA_padding_add_PKCS1_PSS( + rsa, + tbuf, + (unsigned char *)dbuf, + hash, + salt_length); + + if (result == -1) { + m2_PyErr_Msg(_rsa_err); + OPENSSL_cleanse(tbuf, tlen); + OPENSSL_free(tbuf); + return NULL; + } + ret = PyBytes_FromStringAndSize((const char *)tbuf, tlen); + OPENSSL_cleanse(tbuf, tlen); + OPENSSL_free(tbuf); + return ret; +} + +int rsa_verify_pkcs1_pss(RSA *rsa, PyObject *digest, PyObject *signature, EVP_MD *hash, int salt_length) { + const void *dbuf; + const void *sbuf; + int dlen, slen, ret; + + if (m2_PyObject_AsReadBufferInt(digest, &dbuf, &dlen) == -1) { + return 0; + } + + if (m2_PyObject_AsReadBufferInt(signature, &sbuf, &slen) == -1) { + return 0; + } + + ret = RSA_verify_PKCS1_PSS( + rsa, + (unsigned char *)dbuf, + hash, + (unsigned char *)sbuf, + salt_length); + + return ret; +} +#endif + +PyObject *rsa_sign(RSA *rsa, PyObject *py_digest_string, int method_type) { + int digest_len = 0; + int buf_len = 0; + int ret = 0; + unsigned int real_buf_len = 0; + char *digest_string = NULL; + unsigned char * sign_buf = NULL; + PyObject *signature; + + ret = m2_PyString_AsStringAndSizeInt(py_digest_string, &digest_string, + &digest_len); + if (ret == -1) { + /* PyString_AsStringAndSize raises the correct exceptions. */ + return NULL; + } + + buf_len = RSA_size(rsa); + sign_buf = (unsigned char *)PyMem_Malloc(buf_len); + ret = RSA_sign(method_type, (const unsigned char *)digest_string, digest_len, + sign_buf, &real_buf_len, rsa); + + if (!ret) { + m2_PyErr_Msg(_rsa_err); + PyMem_Free(sign_buf); + return NULL; + } + + signature = PyBytes_FromStringAndSize((const char*) sign_buf, buf_len); + + PyMem_Free(sign_buf); + return signature; +} + +int rsa_verify(RSA *rsa, PyObject *py_verify_string, PyObject* py_sign_string, int method_type){ + int ret = 0; + char * sign_string = NULL; + char * verify_string = NULL; + int verify_len = 0; + int sign_len = 0; + + ret = m2_PyString_AsStringAndSizeInt(py_verify_string, &verify_string, + &verify_len); + if (ret == -1) { + /* PyString_AsStringAndSize raises the correct exceptions. */ + return 0; + } + ret = m2_PyString_AsStringAndSizeInt(py_sign_string, &sign_string, + &sign_len); + if (ret == -1) { + return 0; + } + + ret = RSA_verify(method_type, (unsigned char *) verify_string, + verify_len, (unsigned char *) sign_string, + sign_len, rsa); + if (!ret) { + m2_PyErr_Msg(_rsa_err); + return 0; + } + return ret; +} + +PyObject *rsa_generate_key(int bits, unsigned long e, PyObject *pyfunc) { + RSA *rsa; + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + BN_GENCB *gencb; + BIGNUM *e_big; + int ret; + + if ((e_big=BN_new()) == NULL) { + m2_PyErr_Msg(_rsa_err); + return NULL; + } + + if (BN_set_word(e_big, e) == 0) { + m2_PyErr_Msg(_rsa_err); + BN_free(e_big); + return NULL; + } + + if ((gencb=BN_GENCB_new()) == NULL) { + m2_PyErr_Msg(_rsa_err); + BN_free(e_big); + return NULL; + } + + if ((rsa = RSA_new()) == NULL) { + m2_PyErr_Msg(_rsa_err); + BN_free(e_big); + BN_GENCB_free(gencb); + return NULL; + } + + BN_GENCB_set(gencb, bn_gencb_callback, (void *) pyfunc); + + Py_INCREF(pyfunc); + ret = RSA_generate_key_ex(rsa, bits, e_big, gencb); + BN_free(e_big); + BN_GENCB_free(gencb); + Py_DECREF(pyfunc); + + if (ret) + return SWIG_NewPointerObj((void *)rsa, SWIGTYPE_p_RSA, 0); + + m2_PyErr_Msg(_rsa_err); + RSA_free(rsa); + return NULL; +} + +int rsa_type_check(RSA *rsa) { + return 1; +} + +int rsa_check_pub_key(RSA *rsa) { + const BIGNUM* n, *e; + RSA_get0_key(rsa, &n, &e, NULL); + return n && e; +} +%} + +%threadallow rsa_write_key_der; +%inline %{ +int rsa_write_key_der(RSA *rsa, BIO *bio) { + return i2d_RSAPrivateKey_bio(bio, rsa); +} +%} diff --git a/src/SWIG/_ssl.i b/src/SWIG/_ssl.i new file mode 100644 index 0000000..4f723ea --- /dev/null +++ b/src/SWIG/_ssl.i @@ -0,0 +1,953 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ +/* +** Portions created by Open Source Applications Foundation (OSAF) are +** Copyright (C) 2004-2005 OSAF. All Rights Reserved. +** +** Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. +** +*/ +/* $Id$ */ +%{ +#include +#include +#include +#include +#include +#include +#include +#ifdef _WIN32 +#include +#include +#pragma comment(lib, "Ws2_32") +typedef unsigned __int64 uint64_t; +#else +#include +#include +#endif +%} + +#if OPENSSL_VERSION_NUMBER >= 0x10100005L +%include +#endif + +%apply Pointer NONNULL { SSL_CTX * }; +%apply Pointer NONNULL { SSL * }; +%apply Pointer NONNULL { SSL_CIPHER * }; +%apply Pointer NONNULL { STACK_OF(SSL_CIPHER) * }; +%apply Pointer NONNULL { STACK_OF(X509) * }; +%apply Pointer NONNULL { BIO * }; +%apply Pointer NONNULL { DH * }; +%apply Pointer NONNULL { RSA * }; +%apply Pointer NONNULL { EVP_PKEY *}; +%apply Pointer NONNULL { PyObject *pyfunc }; + +%rename(ssl_get_ciphers) SSL_get_ciphers; +extern STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl); + +%rename(ssl_get_version) SSL_get_version; +extern const char *SSL_get_version(const SSL *); +%rename(ssl_get_error) SSL_get_error; +extern int SSL_get_error(const SSL *, int); +%rename(ssl_get_state) SSL_state_string; +extern const char *SSL_state_string(const SSL *); +%rename(ssl_get_state_v) SSL_state_string_long; +extern const char *SSL_state_string_long(const SSL *); +%rename(ssl_get_alert_type) SSL_alert_type_string; +extern const char *SSL_alert_type_string(int); +%rename(ssl_get_alert_type_v) SSL_alert_type_string_long; +extern const char *SSL_alert_type_string_long(int); +%rename(ssl_get_alert_desc) SSL_alert_desc_string; +extern const char *SSL_alert_desc_string(int); +%rename(ssl_get_alert_desc_v) SSL_alert_desc_string_long; +extern const char *SSL_alert_desc_string_long(int); + +%rename(sslv23_method) SSLv23_method; +extern SSL_METHOD *SSLv23_method(void); +%ignore TLSv1_method; +extern SSL_METHOD *TLSv1_method(void); + +%typemap(out) SSL_CTX * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_ssl_err); + $result = NULL; + } +} +%rename(ssl_ctx_new) SSL_CTX_new; +extern SSL_CTX *SSL_CTX_new(SSL_METHOD *); +%typemap(out) SSL_CTX *; + +%rename(ssl_ctx_free) SSL_CTX_free; +extern void SSL_CTX_free(SSL_CTX *); +%rename(ssl_ctx_set_verify_depth) SSL_CTX_set_verify_depth; +extern void SSL_CTX_set_verify_depth(SSL_CTX *, int); +%rename(ssl_ctx_get_verify_depth) SSL_CTX_get_verify_depth; +extern int SSL_CTX_get_verify_depth(const SSL_CTX *); +%rename(ssl_ctx_get_verify_mode) SSL_CTX_get_verify_mode; +extern int SSL_CTX_get_verify_mode(const SSL_CTX *); +%rename(ssl_ctx_set_cipher_list) SSL_CTX_set_cipher_list; +extern int SSL_CTX_set_cipher_list(SSL_CTX *, const char *); +%rename(ssl_ctx_add_session) SSL_CTX_add_session; +extern int SSL_CTX_add_session(SSL_CTX *, SSL_SESSION *); +%rename(ssl_ctx_remove_session) SSL_CTX_remove_session; +extern int SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *); +%rename(ssl_ctx_set_session_timeout) SSL_CTX_set_timeout; +extern long SSL_CTX_set_timeout(SSL_CTX *, long); +%rename(ssl_ctx_get_session_timeout) SSL_CTX_get_timeout; +extern long SSL_CTX_get_timeout(const SSL_CTX *); +%rename(ssl_ctx_get_cert_store) SSL_CTX_get_cert_store; +extern X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); +%rename(ssl_ctx_set_default_verify_paths) SSL_CTX_set_default_verify_paths; +extern int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); +%rename(ssl_get_ex_data_x509_store_ctx_idx) SSL_get_ex_data_X509_STORE_CTX_idx; +extern int SSL_get_ex_data_X509_STORE_CTX_idx(void); + +%rename(bio_new_ssl) BIO_new_ssl; +extern BIO *BIO_new_ssl(SSL_CTX *, int); + +%rename(ssl_new) SSL_new; +extern SSL *SSL_new(SSL_CTX *); +%rename(ssl_free) SSL_free; +%threadallow SSL_free; +extern void SSL_free(SSL *); +%rename(ssl_dup) SSL_dup; +extern SSL *SSL_dup(SSL *); +%rename(ssl_set_bio) SSL_set_bio; +extern void SSL_set_bio(SSL *, BIO *, BIO *); +%rename(ssl_set_accept_state) SSL_set_accept_state; +extern void SSL_set_accept_state(SSL *); +%rename(ssl_set_connect_state) SSL_set_connect_state; +extern void SSL_set_connect_state(SSL *); +%rename(ssl_get_shutdown) SSL_get_shutdown; +extern int SSL_get_shutdown(const SSL *); +%rename(ssl_set_shutdown) SSL_set_shutdown; +extern void SSL_set_shutdown(SSL *, int); +%rename(ssl_shutdown) SSL_shutdown; +%threadallow SSL_shutdown; +extern int SSL_shutdown(SSL *); +%rename(ssl_clear) SSL_clear; +extern int SSL_clear(SSL *); +%rename(ssl_do_handshake) SSL_do_handshake; +%threadallow SSL_do_handshake; +extern int SSL_do_handshake(SSL *); +%rename(ssl_renegotiate) SSL_renegotiate; +%threadallow SSL_renegotiate; +extern int SSL_renegotiate(SSL *); +%rename(ssl_pending) SSL_pending; +extern int SSL_pending(const SSL *); + +%rename(ssl_get_peer_cert) SSL_get_peer_certificate; +extern X509 *SSL_get_peer_certificate(const SSL *); +%rename(ssl_get_current_cipher) SSL_get_current_cipher; +extern SSL_CIPHER *SSL_get_current_cipher(const SSL *); +%rename(ssl_get_verify_mode) SSL_get_verify_mode; +extern int SSL_get_verify_mode(const SSL *); +%rename(ssl_get_verify_depth) SSL_get_verify_depth; +extern int SSL_get_verify_depth(const SSL *); +%rename(ssl_get_verify_result) SSL_get_verify_result; +extern long SSL_get_verify_result(const SSL *); +%rename(ssl_get_ssl_ctx) SSL_get_SSL_CTX; +extern SSL_CTX *SSL_get_SSL_CTX(const SSL *); +%rename(ssl_get_default_session_timeout) SSL_get_default_timeout; +extern long SSL_get_default_timeout(const SSL *); + +%rename(ssl_set_cipher_list) SSL_set_cipher_list; +extern int SSL_set_cipher_list(SSL *, const char *); +%rename(ssl_get_cipher_list) SSL_get_cipher_list; +extern const char *SSL_get_cipher_list(const SSL *, int); + +%rename(ssl_cipher_get_name) SSL_CIPHER_get_name; +extern const char *SSL_CIPHER_get_name(const SSL_CIPHER *); +%rename(ssl_cipher_get_version) SSL_CIPHER_get_version; +extern char *SSL_CIPHER_get_version(const SSL_CIPHER *); + +%rename(ssl_get_session) SSL_get_session; +extern SSL_SESSION *SSL_get_session(const SSL *); +%rename(ssl_get1_session) SSL_get1_session; +extern SSL_SESSION *SSL_get1_session(SSL *); +%rename(ssl_set_session) SSL_set_session; +extern int SSL_set_session(SSL *, SSL_SESSION *); +%rename(ssl_session_free) SSL_SESSION_free; +extern void SSL_SESSION_free(SSL_SESSION *); +%rename(ssl_session_print) SSL_SESSION_print; +%threadallow SSL_SESSION_print; +extern int SSL_SESSION_print(BIO *, const SSL_SESSION *); +%rename(ssl_session_set_timeout) SSL_SESSION_set_timeout; +extern long SSL_SESSION_set_timeout(SSL_SESSION *, long); +%rename(ssl_session_get_timeout) SSL_SESSION_get_timeout; +extern long SSL_SESSION_get_timeout(const SSL_SESSION *); + +extern PyObject *ssl_accept(SSL *ssl, double timeout = -1); +extern PyObject *ssl_connect(SSL *ssl, double timeout = -1); +extern PyObject *ssl_read(SSL *ssl, int num, double timeout = -1); +extern int ssl_write(SSL *ssl, PyObject *blob, double timeout = -1); + +%constant int ssl_error_none = SSL_ERROR_NONE; +%constant int ssl_error_ssl = SSL_ERROR_SSL; +%constant int ssl_error_want_read = SSL_ERROR_WANT_READ; +%constant int ssl_error_want_write = SSL_ERROR_WANT_WRITE; +%constant int ssl_error_want_x509_lookup = SSL_ERROR_WANT_X509_LOOKUP; +%constant int ssl_error_syscall = SSL_ERROR_SYSCALL; +%constant int ssl_error_zero_return = SSL_ERROR_ZERO_RETURN; +%constant int ssl_error_want_connect = SSL_ERROR_WANT_CONNECT; + +%constant int SSL_VERIFY_NONE = 0x00; +%constant int SSL_VERIFY_PEER = 0x01; +%constant int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 0x02; +%constant int SSL_VERIFY_CLIENT_ONCE = 0x04; + +%constant int VERIFY_CRL_CHECK_LEAF = X509_V_FLAG_CRL_CHECK; +%constant int VERIFY_CRL_CHECK_CHAIN = X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL; + + +%constant int SSL_ST_CONNECT = 0x1000; +%constant int SSL_ST_ACCEPT = 0x2000; +%constant int SSL_ST_MASK = 0x0FFF; +%constant int SSL_ST_INIT = (SSL_ST_CONNECT|SSL_ST_ACCEPT); +%constant int SSL_ST_BEFORE = 0x4000; +%constant int SSL_ST_OK = 0x03; +/* SWIG 3.0.1 complains about the next line -- simplified declaration for now */ +/*%constant int SSL_ST_RENEGOTIATE = (0x04|SSL_ST_INIT);*/ +%constant int SSL_ST_RENEGOTIATE = (0x04|SSL_ST_CONNECT|SSL_ST_ACCEPT); + +%constant int SSL_CB_LOOP = 0x01; +%constant int SSL_CB_EXIT = 0x02; +%constant int SSL_CB_READ = 0x04; +%constant int SSL_CB_WRITE = 0x08; +%constant int SSL_CB_ALERT = 0x4000; /* used in callback */ +%constant int SSL_CB_READ_ALERT = (SSL_CB_ALERT|SSL_CB_READ); +%constant int SSL_CB_WRITE_ALERT = (SSL_CB_ALERT|SSL_CB_WRITE); +%constant int SSL_CB_ACCEPT_LOOP = (SSL_ST_ACCEPT|SSL_CB_LOOP); +%constant int SSL_CB_ACCEPT_EXIT = (SSL_ST_ACCEPT|SSL_CB_EXIT); +%constant int SSL_CB_CONNECT_LOOP = (SSL_ST_CONNECT|SSL_CB_LOOP); +%constant int SSL_CB_CONNECT_EXIT = (SSL_ST_CONNECT|SSL_CB_EXIT); +%constant int SSL_CB_HANDSHAKE_START = 0x10; +%constant int SSL_CB_HANDSHAKE_DONE = 0x20; + +%constant int SSL_SENT_SHUTDOWN = 1; +%constant int SSL_RECEIVED_SHUTDOWN = 2; + +%constant int SSL_SESS_CACHE_OFF = 0x000; +%constant int SSL_SESS_CACHE_CLIENT = 0x001; +%constant int SSL_SESS_CACHE_SERVER = 0x002; +%constant int SSL_SESS_CACHE_BOTH = (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER); + +%constant int SSL_OP_ALL = 0x00000FFFL; + +%constant int SSL_OP_NO_SSLv2 = 0x01000000L; +%constant int SSL_OP_NO_SSLv3 = 0x02000000L; +%constant int SSL_OP_NO_TLSv1 = 0x04000000L; +%constant int SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS = 0x00000800L; + +%constant int SSL_MODE_ENABLE_PARTIAL_WRITE = SSL_MODE_ENABLE_PARTIAL_WRITE; +%constant int SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER = SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER; +%constant int SSL_MODE_AUTO_RETRY = SSL_MODE_AUTO_RETRY; + +%ignore ssl_handle_error; +%ignore ssl_sleep_with_timeout; +%warnfilter(454) _ssl_err; +%warnfilter(454) _ssl_timeout_err; +%inline %{ +static PyObject *_ssl_err; +static PyObject *_ssl_timeout_err; + +void ssl_init(PyObject *ssl_err, PyObject *ssl_timeout_err) { + SSL_library_init(); + SSL_load_error_strings(); + Py_INCREF(ssl_err); + Py_INCREF(ssl_timeout_err); + _ssl_err = ssl_err; + _ssl_timeout_err = ssl_timeout_err; +} + +const SSL_METHOD *tlsv1_method(void) { +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + PyErr_WarnEx(PyExc_DeprecationWarning, + "Function TLSv1_method has been deprecated.", 1); +#endif + return TLSv1_method(); +} + +void ssl_ctx_passphrase_callback(SSL_CTX *ctx, PyObject *pyfunc) { + SSL_CTX_set_default_passwd_cb(ctx, passphrase_callback); + SSL_CTX_set_default_passwd_cb_userdata(ctx, (void *)pyfunc); + Py_INCREF(pyfunc); +} + +int ssl_ctx_use_x509(SSL_CTX *ctx, X509 *x) { + int i; + + if (!(i = SSL_CTX_use_certificate(ctx, x))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; + +} + +int ssl_ctx_use_cert(SSL_CTX *ctx, char *file) { + int i; + + if (!(i = SSL_CTX_use_certificate_file(ctx, file, SSL_FILETYPE_PEM))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + +int ssl_ctx_use_cert_chain(SSL_CTX *ctx, char *file) { + int i; + + if (!(i = SSL_CTX_use_certificate_chain_file(ctx, file))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + + +int ssl_ctx_use_privkey(SSL_CTX *ctx, char *file) { + int i; + + if (!(i = SSL_CTX_use_PrivateKey_file(ctx, file, SSL_FILETYPE_PEM))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + +int ssl_ctx_use_rsa_privkey(SSL_CTX *ctx, RSA *rsakey) { + int i; + + if (!(i = SSL_CTX_use_RSAPrivateKey(ctx, rsakey))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + +int ssl_ctx_use_pkey_privkey(SSL_CTX *ctx, EVP_PKEY *pkey) { + int i; + + if (!(i = SSL_CTX_use_PrivateKey(ctx, pkey))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return i; +} + + +int ssl_ctx_check_privkey(SSL_CTX *ctx) { + int ret; + + if (!(ret = SSL_CTX_check_private_key(ctx))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return ret; +} + +void ssl_ctx_set_client_CA_list_from_file(SSL_CTX *ctx, const char *ca_file) { + SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(ca_file)); +} + +void ssl_ctx_set_verify_default(SSL_CTX *ctx, int mode) { + SSL_CTX_set_verify(ctx, mode, NULL); +} + +void ssl_ctx_set_verify(SSL_CTX *ctx, int mode, PyObject *pyfunc) { + Py_XDECREF(ssl_verify_cb_func); + Py_INCREF(pyfunc); + ssl_verify_cb_func = pyfunc; + SSL_CTX_set_verify(ctx, mode, ssl_verify_callback); +} + +int ssl_ctx_set_session_id_context(SSL_CTX *ctx, PyObject *sid_ctx) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) + return -1; + + return SSL_CTX_set_session_id_context(ctx, buf, len); +} + +void ssl_ctx_set_info_callback(SSL_CTX *ctx, PyObject *pyfunc) { + Py_XDECREF(ssl_info_cb_func); + Py_INCREF(pyfunc); + ssl_info_cb_func = pyfunc; + SSL_CTX_set_info_callback(ctx, ssl_info_callback); +} + +long ssl_ctx_set_tmp_dh(SSL_CTX *ctx, DH* dh) { + return SSL_CTX_set_tmp_dh(ctx, dh); +} + +void ssl_ctx_set_tmp_dh_callback(SSL_CTX *ctx, PyObject *pyfunc) { + Py_XDECREF(ssl_set_tmp_dh_cb_func); + Py_INCREF(pyfunc); + ssl_set_tmp_dh_cb_func = pyfunc; + SSL_CTX_set_tmp_dh_callback(ctx, ssl_set_tmp_dh_callback); +} + +long ssl_ctx_set_tmp_rsa(SSL_CTX *ctx, RSA* rsa) { + return SSL_CTX_set_tmp_rsa(ctx, rsa); +} + +void ssl_ctx_set_tmp_rsa_callback(SSL_CTX *ctx, PyObject *pyfunc) { + Py_XDECREF(ssl_set_tmp_rsa_cb_func); + Py_INCREF(pyfunc); + ssl_set_tmp_rsa_cb_func = pyfunc; + SSL_CTX_set_tmp_rsa_callback(ctx, ssl_set_tmp_rsa_callback); +} + +int ssl_ctx_load_verify_locations(SSL_CTX *ctx, const char *cafile, const char *capath) { + return SSL_CTX_load_verify_locations(ctx, cafile, capath); +} + +/* SSL_CTX_set_options is a macro. */ +long ssl_ctx_set_options(SSL_CTX *ctx, long op) { + return SSL_CTX_set_options(ctx, op); +} + +int bio_set_ssl(BIO *bio, SSL *ssl, int flag) { + SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); + return BIO_ctrl(bio, BIO_C_SET_SSL, flag, (char *)ssl); +} + +long ssl_set_mode(SSL *ssl, long mode) { + return SSL_set_mode(ssl, mode); +} + +long ssl_get_mode(SSL *ssl) { + return SSL_get_mode(ssl); +} + +int ssl_set_tlsext_host_name(SSL *ssl, const char *name) { + long l; + + if (!(l = SSL_set_tlsext_host_name(ssl, name))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + /* Return an "int" to match the 'typemap(out) int' in _lib.i */ + return 1; +} + +void ssl_set_client_CA_list_from_file(SSL *ssl, const char *ca_file) { + SSL_set_client_CA_list(ssl, SSL_load_client_CA_file(ca_file)); +} + +void ssl_set_client_CA_list_from_context(SSL *ssl, SSL_CTX *ctx) { + SSL_set_client_CA_list(ssl, SSL_CTX_get_client_CA_list(ctx)); +} + +int ssl_set_session_id_context(SSL *ssl, PyObject *sid_ctx) { + const void *buf; + int len = 0; + + if (m2_PyObject_AsReadBufferInt(sid_ctx, &buf, &len) == -1) + return -1; + + return SSL_set_session_id_context(ssl, buf, len); +} + +int ssl_set_fd(SSL *ssl, int fd) { + int ret; + + if (!(ret = SSL_set_fd(ssl, fd))) { + m2_PyErr_Msg(_ssl_err); + return -1; + } + return ret; +} + +static void ssl_handle_error(int ssl_err, int ret) { + int err; + + switch (ssl_err) { + case SSL_ERROR_SSL: + PyErr_SetString(_ssl_err, + ERR_reason_error_string(ERR_get_error())); + break; + case SSL_ERROR_SYSCALL: + err = ERR_get_error(); + if (err) + PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); + else if (ret == 0) + PyErr_SetString(_ssl_err, "unexpected eof"); + else if (ret == -1) + PyErr_SetFromErrno(_ssl_err); + else + assert(0); + break; + default: + PyErr_SetString(_ssl_err, "unexpected SSL error"); + } +} + +#ifdef _WIN32 +/* http://stackoverflow.com/questions/10905892/equivalent-of-gettimeday-for-windows */ +int gettimeofday(struct timeval *tp, void *tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime( &system_time ); + SystemTimeToFileTime( &system_time, &file_time ); + time = ((uint64_t)file_time.dwLowDateTime ) ; + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((time - EPOCH) / 10000000L); + tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + return 0; +} +#endif + +static int ssl_sleep_with_timeout(SSL *ssl, const struct timeval *start, + double timeout, int ssl_err) { +#ifdef _WIN32 +WSAPOLLFD fd; +#else +struct pollfd fd; +#endif + struct timeval tv; + int ms, tmp; + + assert(timeout > 0); + again: + gettimeofday(&tv, NULL); + /* tv >= start */ + if ((timeout + start->tv_sec - tv.tv_sec) > INT_MAX / 1000) + ms = -1; + else { + int fract; + + ms = ((start->tv_sec + (int)timeout) - tv.tv_sec) * 1000; + fract = (int)((start->tv_usec + (timeout - (int)timeout) * 1000000 + - tv.tv_usec + 999) / 1000); + if (ms > 0 && fract > INT_MAX - ms) + ms = -1; + else { + ms += fract; + if (ms <= 0) + goto timeout; + } + } + switch (ssl_err) { + case SSL_ERROR_WANT_READ: + fd.fd = SSL_get_rfd(ssl); + fd.events = POLLIN; + break; + + case SSL_ERROR_WANT_WRITE: + fd.fd = SSL_get_wfd(ssl); + fd.events = POLLOUT; + break; + + case SSL_ERROR_WANT_X509_LOOKUP: + return 0; /* FIXME: is this correct? */ + + default: + assert(0); + } + if (fd.fd == -1) { + PyErr_SetString(_ssl_err, "timeout on a non-FD SSL"); + return -1; + } + Py_BEGIN_ALLOW_THREADS +#ifdef _WIN32 + tmp = WSAPoll(&fd, 1, ms); +#else + tmp = poll(&fd, 1, ms); +#endif + Py_END_ALLOW_THREADS + switch (tmp) { + case 1: + return 0; + case 0: + goto timeout; + case -1: +#ifdef _WIN32 + if (WSAGetLastError() == EINTR) +#else + if (errno == EINTR) +#endif + goto again; + PyErr_SetFromErrno(_ssl_err); + return -1; + } + return 0; + + timeout: + PyErr_SetString(_ssl_timeout_err, "timed out"); + return -1; +} + +PyObject *ssl_accept(SSL *ssl, double timeout) { + PyObject *obj = NULL; + int r, ssl_err; + struct timeval tv; + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_accept(ssl); + ssl_err = SSL_get_error(ssl, r); + Py_END_ALLOW_THREADS + + + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + obj = PyLong_FromLong((long)1); + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + if (timeout <= 0) { + obj = PyLong_FromLong((long)0); + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + obj = NULL; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + obj = NULL; + break; + } + + + return obj; +} + +PyObject *ssl_connect(SSL *ssl, double timeout) { + PyObject *obj = NULL; + int r, ssl_err; + struct timeval tv; + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_connect(ssl); + ssl_err = SSL_get_error(ssl, r); + Py_END_ALLOW_THREADS + + + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + obj = PyLong_FromLong((long)1); + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + if (timeout <= 0) { + obj = PyLong_FromLong((long)0); + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + obj = NULL; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + obj = NULL; + break; + } + + + return obj; +} + +void ssl_set_shutdown1(SSL *ssl, int mode) { + SSL_set_shutdown(ssl, mode); +} + +PyObject *ssl_read(SSL *ssl, int num, double timeout) { + PyObject *obj = NULL; + void *buf; + int r; + struct timeval tv; + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "ssl_read"); + return NULL; + } + + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_read(ssl, buf, num); + Py_END_ALLOW_THREADS + + if (r >= 0) { + buf = PyMem_Realloc(buf, r); + obj = PyBytes_FromStringAndSize(buf, r); + } else { + int ssl_err; + + ssl_err = SSL_get_error(ssl, r); + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + assert(0); + + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + if (timeout <= 0) { + Py_INCREF(Py_None); + obj = Py_None; + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + obj = NULL; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + obj = NULL; + break; + } + } + PyMem_Free(buf); + + + return obj; +} + +PyObject *ssl_read_nbio(SSL *ssl, int num) { + PyObject *obj = NULL; + void *buf; + int r, err; + + + if (!(buf = PyMem_Malloc(num))) { + PyErr_SetString(PyExc_MemoryError, "ssl_read"); + return NULL; + } + + + Py_BEGIN_ALLOW_THREADS + r = SSL_read(ssl, buf, num); + Py_END_ALLOW_THREADS + + + switch (SSL_get_error(ssl, r)) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + buf = PyMem_Realloc(buf, r); + + obj = PyBytes_FromStringAndSize(buf, r); + + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + Py_INCREF(Py_None); + obj = Py_None; + break; + case SSL_ERROR_SSL: + m2_PyErr_Msg(_ssl_err); + obj = NULL; + break; + case SSL_ERROR_SYSCALL: + err = ERR_get_error(); + if (err) + PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); + else if (r == 0) + PyErr_SetString(_ssl_err, "unexpected eof"); + else if (r == -1) + PyErr_SetFromErrno(_ssl_err); + obj = NULL; + break; + } + PyMem_Free(buf); + + + return obj; +} + +int ssl_write(SSL *ssl, PyObject *blob, double timeout) { + Py_buffer buf; + int r, ssl_err, ret; + struct timeval tv; + + + if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { + return -1; + } + + if (timeout > 0) + gettimeofday(&tv, NULL); + again: + Py_BEGIN_ALLOW_THREADS + r = SSL_write(ssl, buf.buf, buf.len); + ssl_err = SSL_get_error(ssl, r); + Py_END_ALLOW_THREADS + + + switch (ssl_err) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + ret = r; + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + if (timeout <= 0) { + ret = -1; + break; + } + if (ssl_sleep_with_timeout(ssl, &tv, timeout, ssl_err) == 0) + goto again; + ret = -1; + break; + case SSL_ERROR_SSL: + case SSL_ERROR_SYSCALL: + ssl_handle_error(ssl_err, r); + default: + ret = -1; + } + + m2_PyBuffer_Release(blob, &buf); + return ret; +} + +int ssl_write_nbio(SSL *ssl, PyObject *blob) { + Py_buffer buf; + int r, err, ret; + + + if (m2_PyObject_GetBufferInt(blob, &buf, PyBUF_CONTIG_RO) == -1) { + return -1; + } + + + Py_BEGIN_ALLOW_THREADS + r = SSL_write(ssl, buf.buf, buf.len); + Py_END_ALLOW_THREADS + + + switch (SSL_get_error(ssl, r)) { + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + ret = r; + break; + case SSL_ERROR_WANT_WRITE: + case SSL_ERROR_WANT_READ: + case SSL_ERROR_WANT_X509_LOOKUP: + ret = -1; + break; + case SSL_ERROR_SSL: + ret = -1; + break; + case SSL_ERROR_SYSCALL: + err = ERR_get_error(); + if (err) + PyErr_SetString(_ssl_err, ERR_reason_error_string(err)); + else if (r == 0) + PyErr_SetString(_ssl_err, "unexpected eof"); + else if (r == -1) + PyErr_SetFromErrno(_ssl_err); + default: + ret = -1; + } + + m2_PyBuffer_Release(blob, &buf); + return ret; +} + +int ssl_cipher_get_bits(SSL_CIPHER *c) { + return SSL_CIPHER_get_bits(c, NULL); +} + +int sk_ssl_cipher_num(STACK_OF(SSL_CIPHER) *stack) { + return sk_SSL_CIPHER_num(stack); +} + +const SSL_CIPHER *sk_ssl_cipher_value(STACK_OF(SSL_CIPHER) *stack, int idx) { + return sk_SSL_CIPHER_value(stack, idx); +} + +STACK_OF(X509) *ssl_get_peer_cert_chain(SSL *ssl) { + return SSL_get_peer_cert_chain(ssl); +} + +int sk_x509_num(STACK_OF(X509) *stack) { + return sk_X509_num(stack); +} + +X509 *sk_x509_value(STACK_OF(X509) *stack, int idx) { + return sk_X509_value(stack, idx); +} +%} + +%threadallow i2d_ssl_session; +%inline %{ +void i2d_ssl_session(BIO *bio, SSL_SESSION *sess) { + i2d_SSL_SESSION_bio(bio, sess); +} +%} + +%typemap(out) SSL_SESSION * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_ssl_err); + $result = NULL; + } +} +%threadallow ssl_session_read_pem; +%inline %{ +SSL_SESSION *ssl_session_read_pem(BIO *bio) { + return PEM_read_bio_SSL_SESSION(bio, NULL, NULL, NULL); +} +%} +%typemap(out) SSL_SESSION * ; + +%threadallow ssl_session_write_pem; +%inline %{ +int ssl_session_write_pem(SSL_SESSION *sess, BIO *bio) { + return PEM_write_bio_SSL_SESSION(bio, sess); +} + +int ssl_ctx_set_session_cache_mode(SSL_CTX *ctx, int mode) +{ + return SSL_CTX_set_session_cache_mode(ctx, mode); +} + +int ssl_ctx_get_session_cache_mode(SSL_CTX *ctx) +{ + return SSL_CTX_get_session_cache_mode(ctx); +} + +static long ssl_ctx_set_cache_size(SSL_CTX *ctx, long arg) +{ + return SSL_CTX_sess_set_cache_size(ctx, arg); +} + +int ssl_is_init_finished(SSL *ssl) +{ + return SSL_is_init_finished(ssl); +} +%} + diff --git a/src/SWIG/_threads.i b/src/SWIG/_threads.i new file mode 100644 index 0000000..69adb9f --- /dev/null +++ b/src/SWIG/_threads.i @@ -0,0 +1,67 @@ +/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ +/* $Id$ */ + +%{ +#include +#include + +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L +#define CRYPTO_num_locks() (CRYPTO_NUM_LOCKS) +static PyThread_type_lock lock_cs[CRYPTO_num_locks()]; +static long lock_count[CRYPTO_num_locks()]; +static int thread_mode = 0; +#endif + +void threading_locking_callback(int mode, int type, const char *file, int line) { +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L + if (mode & CRYPTO_LOCK) { + PyThread_acquire_lock(lock_cs[type], WAIT_LOCK); + lock_count[type]++; + } else { + PyThread_release_lock(lock_cs[type]); + lock_count[type]--; + } +#endif +} + +unsigned long threading_id_callback(void) { +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L + return (unsigned long)PyThread_get_thread_ident(); +#else + return (unsigned long)0; +#endif +} +%} + +%inline %{ +void threading_init(void) { +#if defined(THREADING) && OPENSSL_VERSION_NUMBER < 0x10100000L + int i; + if (!thread_mode) { + for (i=0; i +%} + +%warnfilter(454) _util_err; +%inline %{ +static PyObject *_util_err; + +void util_init(PyObject *util_err) { + Py_INCREF(util_err); + _util_err = util_err; +} + +PyObject *util_hex_to_string(PyObject *blob) { + PyObject *obj; + const void *buf; + char *ret; + Py_ssize_t len; + + if (PyObject_AsReadBuffer(blob, &buf, &len) == -1) + return NULL; + + ret = hex_to_string((unsigned char *)buf, len); + if (!ret) { + m2_PyErr_Msg(_util_err); + return NULL; + } + + obj = PyBytes_FromString(ret); + + OPENSSL_free(ret); + return obj; +} + +PyObject *util_string_to_hex(PyObject *blob) { + PyObject *obj; + const void *buf; + unsigned char *ret; + Py_ssize_t len0; + long len; + + if (PyObject_AsReadBuffer(blob, &buf, &len0) == -1) + return NULL; + + len = len0; + ret = string_to_hex((char *)buf, &len); + if (ret == NULL) { + m2_PyErr_Msg(_util_err); + return NULL; + } + obj = PyBytes_FromStringAndSize((char*)ret, len); + OPENSSL_free(ret); + return obj; +} +%} diff --git a/src/SWIG/_x509.i b/src/SWIG/_x509.i new file mode 100644 index 0000000..b6334df --- /dev/null +++ b/src/SWIG/_x509.i @@ -0,0 +1,851 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* Copyright (c) 1999-2004 Ng Pheng Siong. All rights reserved. */ +/* +** Portions created by Open Source Applications Foundation (OSAF) are +** Copyright (C) 2004-2005 OSAF. All Rights Reserved. +** +** Copyright (c) 2009-2010 Heikki Toivonen. All rights reserved. +** +*/ +/* $Id$ */ + +%{ +#include +#include +#include + +#include + +typedef STACK_OF(X509) SEQ_CERT; + +ASN1_ITEM_TEMPLATE(SEQ_CERT) = + ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, SeqCert, X509) +ASN1_ITEM_TEMPLATE_END(SEQ_CERT) + +IMPLEMENT_ASN1_FUNCTIONS(SEQ_CERT) +%} + +%apply Pointer NONNULL { BIO * }; +%apply Pointer NONNULL { X509 * }; +%apply Pointer NONNULL { X509_CRL * }; +%apply Pointer NONNULL { X509_REQ * }; +%apply Pointer NONNULL { X509_NAME * }; +%apply Pointer NONNULL { X509_NAME_ENTRY * }; +%apply Pointer NONNULL { EVP_PKEY * }; + +#if OPENSSL_VERSION_NUMBER >= 0x0090800fL +%rename(x509_check_ca) X509_check_ca; +extern int X509_check_ca(X509 *); +#endif + +%rename(x509_new) X509_new; +extern X509 *X509_new( void ); +%rename(x509_dup) X509_dup; +extern X509 *X509_dup(X509 *); +%rename(x509_free) X509_free; +extern void X509_free(X509 *); +%rename(x509_crl_free) X509_CRL_free; +extern void X509_CRL_free(X509_CRL *); +%rename(x509_crl_new) X509_CRL_new; +extern X509_CRL * X509_CRL_new(); + +%rename(x509_print) X509_print; +%threadallow X509_print; +extern int X509_print(BIO *, X509 *); +%rename(x509_crl_print) X509_CRL_print; +%threadallow X509_CRL_print; +extern int X509_CRL_print(BIO *, X509_CRL *); + +%rename(x509_get_serial_number) X509_get_serialNumber; +extern ASN1_INTEGER *X509_get_serialNumber(X509 *); +%rename(x509_set_serial_number) X509_set_serialNumber; +extern int X509_set_serialNumber(X509 *, ASN1_INTEGER *); +%rename(x509_get_pubkey) X509_get_pubkey; +extern EVP_PKEY *X509_get_pubkey(X509 *); +%rename(x509_set_pubkey) X509_set_pubkey; +extern int X509_set_pubkey(X509 *, EVP_PKEY *); +%rename(x509_get_issuer_name) X509_get_issuer_name; +extern X509_NAME *X509_get_issuer_name(X509 *); +%rename(x509_set_issuer_name) X509_set_issuer_name; +extern int X509_set_issuer_name(X509 *, X509_NAME *); +%rename(x509_get_subject_name) X509_get_subject_name; +extern X509_NAME *X509_get_subject_name(X509 *); +%rename(x509_set_subject_name) X509_set_subject_name; +extern int X509_set_subject_name(X509 *, X509_NAME *); +%rename(x509_cmp_current_time) X509_cmp_current_time; +extern int X509_cmp_current_time(ASN1_TIME *); + + +/* From x509.h */ +/* standard trust ids */ +%constant int X509_TRUST_DEFAULT = -1; +%constant int X509_TRUST_COMPAT = 1; +%constant int X509_TRUST_SSL_CLIENT = 2; +%constant int X509_TRUST_SSL_SERVER = 3; +%constant int X509_TRUST_EMAIL = 4; +%constant int X509_TRUST_OBJECT_SIGN = 5; +%constant int X509_TRUST_OCSP_SIGN = 6; +%constant int X509_TRUST_OCSP_REQUEST = 7; + +/* trust_flags values */ +%constant int X509_TRUST_DYNAMIC = 1; +%constant int X509_TRUST_DYNAMIC_NAME = 2; + +/* check_trust return codes */ +%constant int X509_TRUST_TRUSTED = 1; +%constant int X509_TRUST_REJECTED = 2; +%constant int X509_TRUST_UNTRUSTED = 3; + +/* From x509v3.h */ +%constant int X509_PURPOSE_SSL_CLIENT = 1; +%constant int X509_PURPOSE_SSL_SERVER = 2; +%constant int X509_PURPOSE_NS_SSL_SERVER = 3; +%constant int X509_PURPOSE_SMIME_SIGN = 4; +%constant int X509_PURPOSE_SMIME_ENCRYPT = 5; +%constant int X509_PURPOSE_CRL_SIGN = 6; +%constant int X509_PURPOSE_ANY = 7; +%constant int X509_PURPOSE_OCSP_HELPER = 8; + +%rename(x509_check_purpose) X509_check_purpose; +extern int X509_check_purpose(X509 *, int, int); +%rename(x509_check_trust) X509_check_trust; +extern int X509_check_trust(X509 *, int, int); + +%rename(x509_write_pem) PEM_write_bio_X509; +%threadallow PEM_write_bio_X509; +extern int PEM_write_bio_X509(BIO *, X509 *); +%rename(x509_write_pem_file) PEM_write_X509; +extern int PEM_write_X509(FILE *, X509 *); + +%rename(x509_verify) X509_verify; +extern int X509_verify(X509 *a, EVP_PKEY *r); +%rename(x509_get_verify_error) X509_verify_cert_error_string; +extern const char *X509_verify_cert_error_string(long); + +%constant long X509V3_EXT_UNKNOWN_MASK = (0xfL << 16); +%constant long X509V3_EXT_DEFAULT = 0; +%constant long X509V3_EXT_ERROR_UNKNOWN = (1L << 16); +%constant long X509V3_EXT_PARSE_UNKNOWN = (2L << 16); +%constant long X509V3_EXT_DUMP_UNKNOWN = (3L << 16); + +%rename(x509_add_ext) X509_add_ext; +extern int X509_add_ext(X509 *, X509_EXTENSION *, int); +%rename(x509_get_ext_count) X509_get_ext_count; +extern int X509_get_ext_count(X509 *); +%rename(x509_get_ext) X509_get_ext; +extern X509_EXTENSION *X509_get_ext(X509 *, int); +%rename(x509_ext_print) X509V3_EXT_print; +%threadallow X509V3_EXT_print; +extern int X509V3_EXT_print(BIO *, X509_EXTENSION *, unsigned long, int); + +%rename(x509_name_new) X509_NAME_new; +extern X509_NAME *X509_NAME_new( void ); +%rename(x509_name_free) X509_NAME_free; +extern void X509_NAME_free(X509_NAME *); +%rename(x509_name_print) X509_NAME_print; +%threadallow X509_NAME_print; +extern int X509_NAME_print(BIO *, X509_NAME *, int); +%rename(x509_name_get_entry) X509_NAME_get_entry; +extern X509_NAME_ENTRY *X509_NAME_get_entry(X509_NAME *, int); +%rename(x509_name_entry_count) X509_NAME_entry_count; +extern int X509_NAME_entry_count(X509_NAME *); +%rename(x509_name_delete_entry) X509_NAME_delete_entry; +extern X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *, int); +%rename(x509_name_add_entry) X509_NAME_add_entry; +extern int X509_NAME_add_entry(X509_NAME *, X509_NAME_ENTRY *, int, int); +%rename(x509_name_add_entry_by_obj) X509_NAME_add_entry_by_OBJ; +extern int X509_NAME_add_entry_by_OBJ(X509_NAME *, ASN1_OBJECT *, int, unsigned char *, int, int, int ); +%rename(x509_name_add_entry_by_nid) X509_NAME_add_entry_by_NID; +extern int X509_NAME_add_entry_by_NID(X509_NAME *, int, int, unsigned char *, int, int, int ); +%rename(x509_name_print_ex) X509_NAME_print_ex; +%threadallow X509_NAME_print_ex; +extern int X509_NAME_print_ex(BIO *, X509_NAME *, int, unsigned long); + +#if OPENSSL_VERSION_NUMBER >= 0x10000000L +%rename(x509_name_hash) X509_NAME_hash_old; +extern unsigned long X509_NAME_hash_old(X509_NAME *); +#else +%rename(x509_name_hash) X509_NAME_hash; +extern unsigned long X509_NAME_hash(X509_NAME *); +#endif + +%rename(x509_name_get_index_by_nid) X509_NAME_get_index_by_NID; +extern int X509_NAME_get_index_by_NID(X509_NAME *, int, int); + +%rename(x509_name_entry_new) X509_NAME_ENTRY_new; +extern X509_NAME_ENTRY *X509_NAME_ENTRY_new( void ); +%rename(x509_name_entry_free) X509_NAME_ENTRY_free; +extern void X509_NAME_ENTRY_free( X509_NAME_ENTRY *); +/*XXX This is probably bogus:*/ +%rename(x509_name_entry_create_by_nid) X509_NAME_ENTRY_create_by_NID; +extern X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID( X509_NAME_ENTRY **, int, int, unsigned char *, int); +%rename(x509_name_entry_set_object) X509_NAME_ENTRY_set_object; +extern int X509_NAME_ENTRY_set_object( X509_NAME_ENTRY *, ASN1_OBJECT *); +%rename(x509_name_entry_get_object) X509_NAME_ENTRY_get_object; +extern ASN1_OBJECT *X509_NAME_ENTRY_get_object(X509_NAME_ENTRY *); +%rename(x509_name_entry_get_data) X509_NAME_ENTRY_get_data; +extern ASN1_STRING *X509_NAME_ENTRY_get_data(X509_NAME_ENTRY *); + +%typemap(in) (const unsigned char *, int) { +#if PY_MAJOR_VERSION >= 3 + if (PyBytes_Check($input)) { + Py_ssize_t len; + + $1 = PyBytes_AsString($input); + len = PyBytes_Size($input); +#else + if (PyString_Check($input)) { + Py_ssize_t len; + + $1 = (unsigned char *)PyString_AsString($input); + len = PyString_Size($input); +#endif // PY_MAJOR_VERSION >= 3 + + if (len > INT_MAX) { + PyErr_SetString(_x509_err, "object too large"); + return NULL; + } + $2 = len; + } else { + PyErr_SetString(PyExc_TypeError, "expected string"); + return NULL; + } +} +%rename(x509_name_entry_set_data) X509_NAME_ENTRY_set_data; +extern int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *, int, const unsigned char *, int); +%typemap(in) (const unsigned char *, int); + +%rename(x509_req_new) X509_REQ_new; +extern X509_REQ * X509_REQ_new(); +%rename(x509_req_free) X509_REQ_free; +extern void X509_REQ_free(X509_REQ *); +%rename(x509_req_print) X509_REQ_print; +%threadallow X509_REQ_print; +extern int X509_REQ_print(BIO *, X509_REQ *); + +%rename(x509_req_get_pubkey) X509_REQ_get_pubkey; +extern EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *); +%rename(x509_req_set_pubkey) X509_REQ_set_pubkey; +extern int X509_REQ_set_pubkey(X509_REQ *, EVP_PKEY *); +%rename(x509_req_set_subject_name) X509_REQ_set_subject_name; +extern int X509_REQ_set_subject_name(X509_REQ *, X509_NAME *); + +%rename(x509_req_verify) X509_REQ_verify; +extern int X509_REQ_verify(X509_REQ *, EVP_PKEY *); +%rename(x509_req_sign) X509_REQ_sign; +extern int X509_REQ_sign(X509_REQ *, EVP_PKEY *, const EVP_MD *); + +%rename(i2d_x509_bio) i2d_X509_bio; +%threadallow i2d_X509_bio; +extern int i2d_X509_bio(BIO *, X509 *); +%rename(i2d_x509_req_bio) i2d_X509_REQ_bio; +%threadallow i2d_X509_REQ_bio; +extern int i2d_X509_REQ_bio(BIO *, X509_REQ *); + +%rename(x509_store_new) X509_STORE_new; +extern X509_STORE *X509_STORE_new(void); +%rename(x509_store_free) X509_STORE_free; +extern void X509_STORE_free(X509_STORE *); +%rename(x509_store_add_cert) X509_STORE_add_cert; +extern int X509_STORE_add_cert(X509_STORE *, X509 *); +%rename(x509_store_set_verify_cb) X509_STORE_set_verify_cb; +extern void X509_STORE_set_verify_cb(X509_STORE *st, + int (*verify_cb)(int ok, X509_STORE_CTX *ctx)); + +%rename(x509_store_ctx_get_current_cert) X509_STORE_CTX_get_current_cert; +extern X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *); +%rename(x509_store_ctx_get_error) X509_STORE_CTX_get_error; +extern int X509_STORE_CTX_get_error(X509_STORE_CTX *); +%rename(x509_store_ctx_get_error_depth) X509_STORE_CTX_get_error_depth; +extern int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *); +%rename(x509_store_ctx_free) X509_STORE_CTX_free; +extern void X509_STORE_CTX_free(X509_STORE_CTX *); +%rename(x509_store_ctx_get1_chain) X509_STORE_CTX_get1_chain; +extern STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *); + +%rename(x509_extension_get_critical) X509_EXTENSION_get_critical; +extern int X509_EXTENSION_get_critical(X509_EXTENSION *); +%rename(x509_extension_set_critical) X509_EXTENSION_set_critical; +extern int X509_EXTENSION_set_critical(X509_EXTENSION *, int); + + +%rename(x509_store_set_flags) X509_STORE_set_flags; +extern int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); + + +%typemap(out) X509 * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_x509_err); + $result = NULL; + } +} + + +/* Functions using m2_PyErr_Msg and thus using internal Python C API are + * not thread safe, so if we want to have %threadallow here, error + * handling must be done outside of these internal functions. */ +%threadallow x509_read_pem; +%inline %{ +X509 *x509_read_pem(BIO *bio) { + return PEM_read_bio_X509(bio, NULL, NULL, NULL); +} +%} + +%threadallow d2i_x509; +%inline %{ +X509 *d2i_x509(BIO *bio) { + return d2i_X509_bio(bio, NULL); +} +%} +%typemap(out) X509 *; + +%constant int NID_commonName = 13; +%constant int NID_countryName = 14; +%constant int NID_localityName = 15; +%constant int NID_stateOrProvinceName = 16; +%constant int NID_organizationName = 17; +%constant int NID_organizationalUnitName = 18; +%constant int NID_serialNumber = 105; +%constant int NID_surname = 100; +%constant int NID_givenName = 99; +%constant int NID_pkcs9_emailAddress = 48; + +/* Cribbed from x509_vfy.h. */ +%constant int X509_V_OK = 0; +%constant int X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT = 2; +%constant int X509_V_ERR_UNABLE_TO_GET_CRL = 3; +%constant int X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE = 4; +%constant int X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE = 5; +%constant int X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY = 6; +%constant int X509_V_ERR_CERT_SIGNATURE_FAILURE = 7; +%constant int X509_V_ERR_CRL_SIGNATURE_FAILURE = 8; +%constant int X509_V_ERR_CERT_NOT_YET_VALID = 9; +%constant int X509_V_ERR_CERT_HAS_EXPIRED = 10; +%constant int X509_V_ERR_CRL_NOT_YET_VALID = 11; +%constant int X509_V_ERR_CRL_HAS_EXPIRED = 12; +%constant int X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD = 13; +%constant int X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD = 14; +%constant int X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD = 15; +%constant int X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 16; +%constant int X509_V_ERR_OUT_OF_MEM = 17; +%constant int X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT = 18; +%constant int X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN = 19; +%constant int X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 20; +%constant int X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE = 21; +%constant int X509_V_ERR_CERT_CHAIN_TOO_LONG = 22; +%constant int X509_V_ERR_CERT_REVOKED = 23; +%constant int X509_V_ERR_INVALID_CA = 24; +%constant int X509_V_ERR_PATH_LENGTH_EXCEEDED = 25; +%constant int X509_V_ERR_INVALID_PURPOSE = 26; +%constant int X509_V_ERR_CERT_UNTRUSTED = 27; +%constant int X509_V_ERR_CERT_REJECTED = 28; +%constant int X509_V_ERR_APPLICATION_VERIFICATION = 50; + +/* See man page of X509_VERIFY_PARAM_set_flags for definition of all these flags */ + +#ifdef X509_V_FLAG_ALLOW_PROXY_CERTS +%constant int VERIFY_ALLOW_PROXY_CERTS = X509_V_FLAG_ALLOW_PROXY_CERTS; +#endif +#ifdef X509_V_FLAG_CB_ISSUER_CHECK +%constant int VERIFY_CB_ISSUER_CHECK = X509_V_FLAG_CB_ISSUER_CHECK; +#endif +#ifdef X509_V_FLAG_CHECK_SS_SIGNATURE +%constant int VERIFY_CHECK_SS_SIGNATURE = X509_V_FLAG_CHECK_SS_SIGNATURE; +#endif +/* note: X509_V_FLAG_CRL_CHECK is already defined in _ssl.i as VERIFY_CRL_CHECK_LEAF +However I add it here for consistency */ +#ifdef X509_V_FLAG_CRL_CHECK +%constant int VERIFY_CRL_CHECK = X509_V_FLAG_CRL_CHECK; +#endif +#ifdef X509_V_FLAG_CRL_CHECK_ALL +%constant int VERIFY_CRL_CHECK_ALL = X509_V_FLAG_CRL_CHECK_ALL; +#endif +#ifdef X509_V_FLAG_EXPLICIT_POLICY +%constant int VERIFY_EXPLICIT_POLICY = X509_V_FLAG_EXPLICIT_POLICY; +#endif +#ifdef X509_V_FLAG_EXTENDED_CRL_SUPPORT +%constant int VERIFY_EXTENDED_CRL_SUPPORT = X509_V_FLAG_EXTENDED_CRL_SUPPORT; +#endif +#ifdef X509_V_FLAG_IGNORE_CRITICAL +%constant int VERIFY_IGNORE_CRITICAL = X509_V_FLAG_IGNORE_CRITICAL; +#endif +#ifdef X509_V_FLAG_INHIBIT_ANY +%constant int VERIFY_INHIBIT_ANY = X509_V_FLAG_INHIBIT_ANY; +#endif +#ifdef X509_V_FLAG_INHIBIT_MAP +%constant int VERIFY_INHIBIT_MAP = X509_V_FLAG_INHIBIT_MAP; +#endif +#ifdef X509_V_FLAG_NO_ALT_CHAINS +%constant int VERIFY_NO_ALT_CHAINS = X509_V_FLAG_NO_ALT_CHAINS; +#endif +#ifdef X509_V_FLAG_NO_CHECK_TIME +%constant int VERIFY_NO_CHECK_TIME = X509_V_FLAG_NO_CHECK_TIME; +#endif +#ifdef X509_V_FLAG_NOTIFY_POLICY +%constant int VERIFY_NOTIFY_POLICY = X509_V_FLAG_NOTIFY_POLICY; +#endif +#ifdef X509_V_FLAG_PARTIAL_CHAIN +%constant int VERIFY_PARTIAL_CHAIN = X509_V_FLAG_PARTIAL_CHAIN; +#endif +#ifdef X509_V_FLAG_POLICY_CHECK +%constant int VERIFY_POLICY_CHECK = X509_V_FLAG_POLICY_CHECK; +#endif +#ifdef X509_V_FLAG_TRUSTED_FIRST +%constant int VERIFY_TRUSTED_FIRST = X509_V_FLAG_TRUSTED_FIRST; +#endif +#ifdef X509_V_FLAG_USE_DELTAS +%constant int VERIFY_USE_DELTAS = X509_V_FLAG_USE_DELTAS; +#endif +#ifdef X509_V_FLAG_X509_STRICT +%constant int VERIFY_X509_STRICT = X509_V_FLAG_X509_STRICT; +#endif + + + +/* x509.h */ +%constant int XN_FLAG_COMPAT = 0; +%constant int XN_FLAG_SEP_COMMA_PLUS = (1 << 16); +%constant int XN_FLAG_SEP_CPLUS_SPC = (2 << 16); +%constant int XN_FLAG_SEP_MULTILINE = (4 << 16); +%constant int XN_FLAG_DN_REV = (1 << 20); +%constant int XN_FLAG_FN_LN = (1 << 21); +%constant int XN_FLAG_SPC_EQ = (1 << 23); +%constant int XN_FLAG_DUMP_UNKNOWN_FIELDS = (1 << 24); +%constant int XN_FLAG_FN_ALIGN = (1 << 25); +%constant int XN_FLAG_ONELINE =(ASN1_STRFLGS_RFC2253 | \ + ASN1_STRFLGS_ESC_QUOTE | \ + XN_FLAG_SEP_CPLUS_SPC | \ + XN_FLAG_SPC_EQ); +%constant int XN_FLAG_MULTILINE = (ASN1_STRFLGS_ESC_CTRL | \ + ASN1_STRFLGS_ESC_MSB | \ + XN_FLAG_SEP_MULTILINE | \ + XN_FLAG_SPC_EQ | \ + XN_FLAG_FN_LN | \ + XN_FLAG_FN_ALIGN); +%constant int XN_FLAG_RFC2253 = (ASN1_STRFLGS_RFC2253 | \ + XN_FLAG_SEP_COMMA_PLUS | \ + XN_FLAG_DN_REV | \ + XN_FLAG_DUMP_UNKNOWN_FIELDS); + +/* Cribbed from rsa.h. */ +%constant int RSA_3 = 0x3L; +%constant int RSA_F4 = 0x10001L; + +%warnfilter(454) _x509_err; +%inline %{ +static PyObject *_x509_err; + +void x509_init(PyObject *x509_err) { + Py_INCREF(x509_err); + _x509_err = x509_err; +} +%} + +%typemap(out) X509_REQ * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_x509_err); + $result = NULL; + } +} +%threadallow d2i_x509_req; +%inline %{ +X509_REQ *d2i_x509_req(BIO *bio) { + return d2i_X509_REQ_bio(bio, NULL); +} +%} + +%threadallow x509_req_read_pem; +%inline %{ +X509_REQ *x509_req_read_pem(BIO *bio) { + return PEM_read_bio_X509_REQ(bio, NULL, NULL, NULL); +} +%} + +%typemap(out) X509_REQ *; + +%inline %{ +PyObject *i2d_x509(X509 *x) { + int len; + PyObject *ret = NULL; + unsigned char *buf = NULL; + len = i2d_X509(x, &buf); + if (len < 0) { + m2_PyErr_Msg(_x509_err); + } + else { + + ret = PyBytes_FromStringAndSize((char*)buf, len); + + OPENSSL_free(buf); + } + return ret; +} +%} + +%threadallow x509_req_write_pem; +%inline %{ +int x509_req_write_pem(BIO *bio, X509_REQ *x) { + return PEM_write_bio_X509_REQ(bio, x); +} +%} + +%typemap(out) X509_CRL * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_x509_err); + $result = NULL; + } +} +%threadallow x509_crl_read_pem; +%inline %{ +X509_CRL *x509_crl_read_pem(BIO *bio) { + return PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); +} +%} +%typemap(out) X509_CRL * ; + +%inline %{ +/* X509_set_version() is a macro. */ +int x509_set_version(X509 *x, long version) { + return X509_set_version(x, version); +} + +/* X509_get_version() is a macro. */ +long x509_get_version(X509 *x) { + return X509_get_version(x); +} + +/* X509_set_notBefore() is a macro. */ +int x509_set_not_before(X509 *x, ASN1_TIME *tm) { + return X509_set_notBefore(x, tm); +} + +/* X509_get_notBefore() is a macro. */ +ASN1_TIME *x509_get_not_before(X509 *x) { + return X509_get_notBefore(x); +} + +/* X509_set_notAfter() is a macro. */ +int x509_set_not_after(X509 *x, ASN1_TIME *tm) { + return X509_set_notAfter(x, tm); +} + +/* X509_get_notAfter() is a macro. */ +ASN1_TIME *x509_get_not_after(X509 *x) { + return X509_get_notAfter(x); +} + +int x509_sign(X509 *x, EVP_PKEY *pkey, EVP_MD *md) { + return X509_sign(x, pkey, md); +} + +/* x509_gmtime_adj() is a macro. */ +ASN1_TIME *x509_gmtime_adj(ASN1_TIME *s, long adj) { + return X509_gmtime_adj(s, adj); +} + +PyObject *x509_name_by_nid(X509_NAME *name, int nid) { + void *buf; + int len, xlen; + PyObject *ret; + + if ((len = X509_NAME_get_text_by_NID(name, nid, NULL, 0)) == -1) { + Py_RETURN_NONE; + } + len++; + if (!(buf = PyMem_Malloc(len))) { + PyErr_SetString(PyExc_MemoryError, "x509_name_by_nid"); + return NULL; + } + xlen = X509_NAME_get_text_by_NID(name, nid, buf, len); + + ret = PyBytes_FromStringAndSize(buf, xlen); + + PyMem_Free(buf); + return ret; +} + +int x509_name_set_by_nid(X509_NAME *name, int nid, PyObject *obj) { + return X509_NAME_add_entry_by_NID(name, nid, MBSTRING_ASC, (unsigned char *)PyBytes_AsString(obj), -1, -1, 0); +} + +/* x509_name_add_entry_by_txt */ +int x509_name_add_entry_by_txt(X509_NAME *name, char *field, int type, char *bytes, int len, int loc, int set) { + return X509_NAME_add_entry_by_txt(name, field, type, (unsigned char *)bytes, len, loc, set); +} + +PyObject *x509_name_get_der(X509_NAME *name) { + const char* pder=""; + size_t pderlen; + i2d_X509_NAME(name, 0); + if (!X509_NAME_get0_der(name, (const unsigned char **)pder, &pderlen)) { + m2_PyErr_Msg(_x509_err); + return NULL; + } + return PyBytes_FromStringAndSize(pder, pderlen); +} + +/* sk_X509_free() is a macro. */ +void sk_x509_free(STACK_OF(X509) *stack) { + sk_X509_free(stack); +} + +/* sk_X509_push() is a macro. */ +int sk_x509_push(STACK_OF(X509) *stack, X509 *x509) { + return sk_X509_push(stack, x509); +} + +/* sk_X509_pop() is a macro. */ +X509 *sk_x509_pop(STACK_OF(X509) *stack) { + return sk_X509_pop(stack); +} +%} + +%inline %{ +int x509_store_load_locations(X509_STORE *store, const char *file) { + int locations = 0; + + if ((locations = X509_STORE_load_locations(store, file, NULL)) < 1) { + m2_PyErr_Msg(_x509_err); + } + return locations; +} + +int x509_type_check(X509 *x509) { + return 1; +} + +int x509_name_type_check(X509_NAME *name) { + return 1; +} + +X509_NAME *x509_req_get_subject_name(X509_REQ *x) { + return X509_REQ_get_subject_name(x); +} + +long x509_req_get_version(X509_REQ *x) { + return X509_REQ_get_version(x); +} + +int x509_req_set_version(X509_REQ *x, long version) { + return X509_REQ_set_version(x, version); +} + +int x509_req_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts) { + return X509_REQ_add_extensions(req, exts); +} + +X509_NAME_ENTRY *x509_name_entry_create_by_txt(X509_NAME_ENTRY **ne, char *field, int type, char *bytes, int len) { + return X509_NAME_ENTRY_create_by_txt( ne, field, type, (unsigned char *)bytes, len); +} +%} + +%typemap(out) X509V3_CTX * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + $result = NULL; + } +} +%inline %{ +X509V3_CTX * +x509v3_set_nconf(void) { + X509V3_CTX * ctx; + CONF *conf = NCONF_new(NULL); + + if (!(ctx=(X509V3_CTX *)PyMem_Malloc(sizeof(X509V3_CTX)))) { + PyErr_SetString(PyExc_MemoryError, "x509v3_set_nconf"); + return NULL; + } + /* X509V3_set_nconf does not generate any error signs at all. */ + X509V3_set_nconf(ctx, conf); + return ctx; +} +%} +%typemap(out) X509V3_CTX * ; + +%typemap(out) X509_EXTENSION * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + m2_PyErr_Msg(_x509_err); + $result = NULL; + } +} +%inline %{ +X509_EXTENSION * +x509v3_ext_conf(void *conf, X509V3_CTX *ctx, char *name, char *value) { + X509_EXTENSION * ext = NULL; + ext = X509V3_EXT_conf(conf, ctx, name, value); + PyMem_Free(ctx); + return ext; +} +%} +%typemap(out) X509_EXTENSION * ; + +%inline %{ +/* X509_EXTENSION_free() might be a macro, didn't find definition. */ +void x509_extension_free(X509_EXTENSION *ext) { + X509_EXTENSION_free(ext); +} + +PyObject *x509_extension_get_name(X509_EXTENSION *ext) { + PyObject * ext_name; + const char * ext_name_str; + ext_name_str = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext))); + if (!ext_name_str) { + m2_PyErr_Msg(_x509_err); + return NULL; + } + ext_name = PyBytes_FromStringAndSize(ext_name_str, strlen(ext_name_str)); + return ext_name; +} + +/* sk_X509_EXTENSION_new_null is a macro. */ +STACK_OF(X509_EXTENSION) *sk_x509_extension_new_null(void) { + return sk_X509_EXTENSION_new_null(); +} + +/* sk_X509_EXTENSION_free() is a macro. */ +void sk_x509_extension_free(STACK_OF(X509_EXTENSION) *stack) { + sk_X509_EXTENSION_free(stack); +} + +/* sk_X509_EXTENSION_push() is a macro. */ +int sk_x509_extension_push(STACK_OF(X509_EXTENSION) *stack, X509_EXTENSION *x509_ext) { + return sk_X509_EXTENSION_push(stack, x509_ext); +} + +/* sk_X509_EXTENSION_pop() is a macro. */ +X509_EXTENSION *sk_x509_extension_pop(STACK_OF(X509_EXTENSION) *stack) { + return sk_X509_EXTENSION_pop(stack); +} + +/* sk_X509_EXTENSION_num() is a macro. */ +int sk_x509_extension_num(STACK_OF(X509_EXTENSION) *stack) { + return sk_X509_EXTENSION_num(stack); +} + +/* sk_X509_EXTENSION_value() is a macro. */ +X509_EXTENSION *sk_x509_extension_value(STACK_OF(X509_EXTENSION) *stack, int i) { + return sk_X509_EXTENSION_value(stack, i); +} + +/* X509_STORE_CTX_get_app_data is a macro. */ +void *x509_store_ctx_get_app_data(X509_STORE_CTX *ctx) { + return X509_STORE_CTX_get_app_data(ctx); +} + +/* X509_STORE_CTX_get_app_data is a macro. */ +void *x509_store_ctx_get_ex_data(X509_STORE_CTX *ctx, int idx) { + return X509_STORE_CTX_get_ex_data(ctx, idx); +} + +void x509_store_set_verify_cb(X509_STORE *store, PyObject *pyfunc) { + Py_XDECREF(x509_store_verify_cb_func); + Py_INCREF(pyfunc); + x509_store_verify_cb_func = pyfunc; + X509_STORE_set_verify_cb(store, x509_store_verify_callback); +} +%} + +%typemap(out) STACK_OF(X509) * { + PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */ + + if ($1 != NULL) + $result = SWIG_NewPointerObj($1, $1_descriptor, 0); + else { + $result = NULL; + } +} + +%inline %{ +STACK_OF(X509) * +make_stack_from_der_sequence(PyObject * pyEncodedString){ + STACK_OF(X509) *certs; + Py_ssize_t encoded_string_len; + char *encoded_string; + const unsigned char *tmp_str; + + encoded_string_len = PyBytes_Size(pyEncodedString); + + if (encoded_string_len > INT_MAX) { + PyErr_Format(_x509_err, "object too large"); + return NULL; + } + + encoded_string = PyBytes_AsString(pyEncodedString); + + if (!encoded_string) { + PyErr_SetString(_x509_err, + "Cannot convert Python Bytes to (char *)."); + return NULL; + } + + tmp_str = (unsigned char *)encoded_string; + certs = d2i_SEQ_CERT(NULL, &tmp_str, encoded_string_len); + if (certs == NULL) { + PyErr_SetString(_x509_err, "Generating STACK_OF(X509) failed."); + return NULL; + } + return certs; +} + +/* sk_X509_new_null() is a macro returning "STACK_OF(X509) *". */ +STACK_OF(X509) *sk_x509_new_null(void) { + return sk_X509_new_null(); +} +%} + +%typemap(out) STACK_OF(X509) *; + +%inline %{ +PyObject * +get_der_encoding_stack(STACK_OF(X509) *stack){ + PyObject * encodedString; + + unsigned char * encoding = NULL; + int len; + + len = i2d_SEQ_CERT(stack, &encoding); + if (!encoding) { + m2_PyErr_Msg(_x509_err); + return NULL; + } + + encodedString = PyBytes_FromStringAndSize((const char *)encoding, len); + + if (encoding) + OPENSSL_free(encoding); + + return encodedString; +} + +%} + +/* Free malloc'ed return value for x509_name_oneline */ +%typemap(ret) char * { + if ($1 != NULL) + OPENSSL_free($1); +} +%inline %{ +char *x509_name_oneline(X509_NAME *x) { + return X509_NAME_oneline(x, NULL, 0); +} +%} +%typemap(ret) char *; diff --git a/src/SWIG/libcrypto-compat.h b/src/SWIG/libcrypto-compat.h new file mode 100644 index 0000000..7c4c913 --- /dev/null +++ b/src/SWIG/libcrypto-compat.h @@ -0,0 +1,62 @@ +#ifndef LIBCRYPTO_COMPAT_H +#define LIBCRYPTO_COMPAT_H + +#if OPENSSL_VERSION_NUMBER < 0x10100000L + +#include +#include +#include +#include +#include +#include + +int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); +int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); +int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); +void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); +void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); +void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1, const BIGNUM **iqmp); + +void DSA_get0_pqg(const DSA *d, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); +int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); +void DSA_get0_key(const DSA *d, const BIGNUM **pub_key, const BIGNUM **priv_key); +int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); + +void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); +int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); + +void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); +int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); + +void DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); +int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); +void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key); +int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); +int DH_set_length(DH *dh, long length); + +const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); +unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); +EVP_MD_CTX *EVP_MD_CTX_new(void); +void EVP_MD_CTX_free(EVP_MD_CTX *ctx); +#define EVP_CIPHER_impl_ctx_size(e) e->ctx_size +#define EVP_CIPHER_CTX_get_cipher_data(ctx) ctx->cipher_data + +int RSA_size(const RSA* rsa); +RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); +int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); +#define RSA_meth_get_finish(meth) meth->finish +int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc) (int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); +int RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec) (int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding)); +int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish) (RSA *rsa)); +void RSA_meth_free(RSA_METHOD *meth); + +int RSA_bits(const RSA *r); + +RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey); + +int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, + size_t *pderlen); + +#endif /* OPENSSL_VERSION_NUMBER */ + +#endif /* LIBCRYPTO_COMPAT_H */ diff --git a/src/SWIG/py3k_compat.h b/src/SWIG/py3k_compat.h new file mode 100644 index 0000000..2e914a5 --- /dev/null +++ b/src/SWIG/py3k_compat.h @@ -0,0 +1,32 @@ +#ifndef PY3K_COMPAT_H +#define PY3K_COMPAT_H + +#if PY_MAJOR_VERSION >= 3 + +FILE* PyFile_AsFile(PyObject *p); +PyObject* PyFile_Name(PyObject *p); + +#else /* PY2K */ + +/* Concerning PyBytes* functions: + * + * Python 3’s str() type is equivalent to Python 2’s unicode(); the + * C functions are called PyUnicode_* for both. The old 8-bit string + * type has become bytes(), with C functions called PyBytes_*. Python + * 2.6 and later provide a compatibility header, bytesobject.h, mapping + * PyBytes names to PyString ones. For best compatibility with Python 3, + * PyUnicode should be used for textual data and PyBytes for binary + * data. It’s also important to remember that PyBytes and PyUnicode in + * Python 3 are not interchangeable like PyString and PyUnicode are in + * Python 2. The following example shows best practices with regards to + * PyUnicode, PyString, and PyBytes. + * + * From https://docs.python.org/2.7/howto/cporting.html + */ + +PyObject* PyLong_FromLong(long x); +const char* PyUnicode_AsUTF8(PyObject *unicode); + +#endif /* PY_MAJOR_VERSION */ + +#endif /* PY3K_COMPAT_H */ -- cgit v1.2.1