Example #1
0
    def _parse_iv_length(self, byte_array, off):
        self._iv_length = utils.bytes_to_int(byte_array[off])

        if self._iv_length < 0:
            raise exceptions.BadCipherTextError(
                'Invalid IV length ({})'.format(self._iv_length))

        return 1
Example #2
0
    def _parse_frame_content_length(self, byte_array, off):
        self.frame_content_length = utils.bytes_to_int(byte_array[off:off + 4])

        if self.frame_content_length < 0:
            raise exceptions.BadCipherTextError(
                'Invalid frame length ({})'.format(self.frame_content_length))

        return 4
Example #3
0
    def _parse_content_type(self, byte_array, off):
        self.content_type = utils.bytes_to_int(byte_array[off])

        if self.content_type not in (1, 2):
            raise exceptions.BadCipherTextError(
                'Invalid content type ({})'.format(self.content_type))

        return 1
Example #4
0
    def _parse_type(self, byte_array, off):
        self.type = utils.bytes_to_int(byte_array[off])

        if self.type != 0x80:
            raise exceptions.BadCipherTextError(
                'Invalid message type ({})'.format(self.type))

        return 1
Example #5
0
    def _parse_version(self, byte_array, off):
        self.version = utils.bytes_to_int(byte_array[off])

        if self.version != 1:
            raise exceptions.BadCipherTextError(
                'Invalid version number ({})'.format(self.version))

        return 1
Example #6
0
    def _parse_reserved_field(self, byte_array, off):
        self.reserved_field = utils.bytes_to_int(byte_array[off:off + 4])

        if self.reserved_field != 0:
            raise exceptions.BadCipherTextError(
                'Invalid value for reserved field ({})'.format(
                    self.reserved_field))

        return 4
Example #7
0
    def _parse_encryption_context_length(self, byte_array, off):
        self._encryption_context_length = utils.bytes_to_int(
            byte_array[off:off + 2])

        if self._encryption_context_length < 0:
            raise exceptions.BadCipherTextError(
                'Invalid encryption context length ({})'.format(
                    self._encryption_context_length))

        return 2