Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
PKCS7_NOCHAIN = m2.PKCS7_NOCHAIN
PKCS7_NOINTERN = m2.PKCS7_NOINTERN
PKCS7_NOVERIFY = m2.PKCS7_NOVERIFY
PKCS7_DETACHED = m2.PKCS7_DETACHED
PKCS7_BINARY = m2.PKCS7_BINARY
PKCS7_NOATTR = m2.PKCS7_NOATTR

PKCS7_SIGNED = m2.PKCS7_SIGNED
PKCS7_ENVELOPED = m2.PKCS7_ENVELOPED
PKCS7_SIGNED_ENVELOPED = m2.PKCS7_SIGNED_ENVELOPED  # Deprecated
PKCS7_DATA = m2.PKCS7_DATA

class PKCS7_Error(Exception):  # noqa
    pass

m2.pkcs7_init(PKCS7_Error)

class PKCS7:

    m2_pkcs7_free = m2.pkcs7_free

    def __init__(self, pkcs7=None, _pyfree=0):
        if pkcs7 is not None:
            self.pkcs7 = pkcs7
            self._pyfree = _pyfree
        else:
            self.pkcs7 = m2.pkcs7_new()
            self._pyfree = 1

    def __del__(self):
        if getattr(self, '_pyfree', 0):