Exemple #1
0
M2Crypto wrapper for OpenSSL ENGINE API.

Pavel Shramov
IMEC MSU
"""

from M2Crypto import EVP, Err, X509, m2, six, util
if util.py27plus:
    from typing import AnyStr, Callable, Optional  # noqa


class EngineError(Exception):
    pass


m2.engine_init_error(EngineError)


class Engine:
    """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)
Exemple #2
0
# vim: sts=4 sw=4 et
"""
M2Crypto wrapper for OpenSSL ENGINE API.

Pavel Shramov
IMEC MSU
"""

from M2Crypto import EVP, Err, X509, m2

class EngineError(Exception):
    pass

m2.engine_init_error(EngineError)

class Engine:
    """Wrapper for ENGINE object."""

    m2_engine_free = m2.engine_free

    def __init__(self, id=None, _ptr=None, _pyfree=1):
        """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