当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.AlreadyFinalized方法代码示例

本文整理汇总了Python中cryptography.exceptions.AlreadyFinalized方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.AlreadyFinalized方法的具体用法?Python exceptions.AlreadyFinalized怎么用?Python exceptions.AlreadyFinalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cryptography.exceptions的用法示例。


在下文中一共展示了exceptions.AlreadyFinalized方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def update(self, data):
        if self._buffer is None:
            raise AlreadyFinalized("Context was already finalized.")

        if not isinstance(data, bytes):
            raise TypeError("data must be bytes.")

        self._buffer += data

        finished_blocks = max(
            len(self._buffer) // (self.block_size // 8) - 1,
            0
        )

        result = self._buffer[:finished_blocks * (self.block_size // 8)]
        self._buffer = self._buffer[finished_blocks * (self.block_size // 8):]

        return result 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:20,代码来源:padding.py

示例2: finalize

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def finalize(self):
        if self._buffer is None:
            raise AlreadyFinalized("Context was already finalized.")

        if len(self._buffer) != self.block_size // 8:
            raise ValueError("Invalid padding bytes.")

        valid = lib.Cryptography_check_pkcs7_padding(
            self._buffer, self.block_size // 8
        )

        if not valid:
            raise ValueError("Invalid padding bytes.")

        pad_size = six.indexbytes(self._buffer, -1)
        res = self._buffer[:-pad_size]
        self._buffer = None
        return res 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:20,代码来源:padding.py

示例3: _byte_unpadding_update

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def _byte_unpadding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    if not isinstance(data, bytes):
        raise TypeError("data must be bytes.")

    buffer_ += data

    finished_blocks = max(len(buffer_) // (block_size // 8) - 1, 0)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:padding.py

示例4: _byte_padding_update

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def _byte_padding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    if not isinstance(data, bytes):
        raise TypeError("data must be bytes.")

    buffer_ += data

    finished_blocks = len(buffer_) // (block_size // 8)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:padding.py

示例5: _byte_padding_pad

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def _byte_padding_pad(buffer_, block_size, paddingfn):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    pad_size = block_size // 8 - len(buffer_)
    return buffer_ + paddingfn(pad_size) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:padding.py

示例6: _byte_unpadding_check

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def _byte_unpadding_check(buffer_, block_size, checkfn):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    if len(buffer_) != block_size // 8:
        raise ValueError("Invalid padding bytes.")

    valid = checkfn(buffer_, block_size // 8)

    if not valid:
        raise ValueError("Invalid padding bytes.")

    pad_size = six.indexbytes(buffer_, -1)
    return buffer_[:-pad_size] 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:padding.py

示例7: _byte_padding_update

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def _byte_padding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    utils._check_bytes("data", data)

    buffer_ += data

    finished_blocks = len(buffer_) // (block_size // 8)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
开发者ID:tp4a,项目名称:teleport,代码行数:16,代码来源:padding.py

示例8: _byte_unpadding_update

# 需要导入模块: from cryptography import exceptions [as 别名]
# 或者: from cryptography.exceptions import AlreadyFinalized [as 别名]
def _byte_unpadding_update(buffer_, data, block_size):
    if buffer_ is None:
        raise AlreadyFinalized("Context was already finalized.")

    utils._check_bytes("data", data)

    buffer_ += data

    finished_blocks = max(len(buffer_) // (block_size // 8) - 1, 0)

    result = buffer_[:finished_blocks * (block_size // 8)]
    buffer_ = buffer_[finished_blocks * (block_size // 8):]

    return buffer_, result 
开发者ID:tp4a,项目名称:teleport,代码行数:16,代码来源:padding.py


注:本文中的cryptography.exceptions.AlreadyFinalized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。