本文整理汇总了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
示例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
示例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
示例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
示例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)
示例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]
示例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
示例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