Ejemplo n.º 1
0
    def encrypt(self, nonce, data, associated_data):
        if associated_data is None:
            associated_data = b""

        self._check_params(nonce, data, associated_data)
        return aead._encrypt(
            backend, self, nonce, data, associated_data, 16
        )
Ejemplo n.º 2
0
    def encrypt(self, nonce, data, associated_data):
        if associated_data is None:
            associated_data = b""

        self._check_params(nonce, data, associated_data)
        return aead._encrypt(
            backend, self, nonce, data, associated_data, 16
        )
Ejemplo n.º 3
0
    def encrypt(self, nonce, data, associated_data):
        if associated_data is None:
            associated_data = b""

        self._check_params(nonce, data, associated_data)
        self._validate_lengths(nonce, len(data))
        return aead._encrypt(backend, self, nonce, data, associated_data,
                             self._tag_length)
Ejemplo n.º 4
0
    def encrypt(self, nonce, data, associated_data):
        if associated_data is None:
            associated_data = b""

        self._check_params(nonce, data, associated_data)
        self._validate_lengths(nonce, len(data))
        return aead._encrypt(
            backend, self, nonce, data, associated_data, self._tag_length
        )
Ejemplo n.º 5
0
    def encrypt(self, nonce, data, associated_data):
        if associated_data is None:
            associated_data = b""

        if len(data) > self._MAX_SIZE or len(associated_data) > self._MAX_SIZE:
            # This is OverflowError to match what cffi would raise
            raise OverflowError(
                "Data or associated table_s too long. Max 2**32 bytes")

        self._check_params(nonce, data, associated_data)
        return aead._encrypt(backend, self, nonce, data, associated_data, 16)
Ejemplo n.º 6
0
Archivo: aead.py Proyecto: reidefe/foxy
    def encrypt(self, nonce: bytes, data: bytes,
                associated_data: typing.Optional[bytes]) -> bytes:
        if associated_data is None:
            associated_data = b""

        if len(data) > self._MAX_SIZE or len(associated_data) > self._MAX_SIZE:
            # This is OverflowError to match what cffi would raise
            raise OverflowError(
                "Data or associated data too long. Max 2**32 bytes")

        self._check_params(nonce, data, associated_data)
        self._validate_lengths(nonce, len(data))
        return aead._encrypt(backend, self, nonce, data, associated_data,
                             self._tag_length)
Ejemplo n.º 7
0
    def encrypt(self, nonce, data, associated_data):
        if associated_data is None:
            associated_data = b""

        if len(data) > self._MAX_SIZE or len(associated_data) > self._MAX_SIZE:
            # This is OverflowError to match what cffi would raise
            raise OverflowError(
                "Data or associated data too long. Max 2**32 bytes"
            )

        self._check_params(nonce, data, associated_data)
        return aead._encrypt(
            backend, self, nonce, data, associated_data, 16
        )
Ejemplo n.º 8
0
    def encrypt(
        self,
        data: bytes,
        associated_data: typing.Optional[typing.List[bytes]],
    ) -> bytes:
        if associated_data is None:
            associated_data = []

        self._check_params(data, associated_data)

        if len(data) > self._MAX_SIZE or any(
                len(ad) > self._MAX_SIZE for ad in associated_data):
            # This is OverflowError to match what cffi would raise
            raise OverflowError(
                "Data or associated data too long. Max 2**31 - 1 bytes")

        return aead._encrypt(backend, self, b"", data, associated_data, 16)