本文整理匯總了Python中cryptography.hazmat.primitives.cmac.CMAC.finalize方法的典型用法代碼示例。如果您正苦於以下問題:Python CMAC.finalize方法的具體用法?Python CMAC.finalize怎麽用?Python CMAC.finalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cryptography.hazmat.primitives.cmac.CMAC
的用法示例。
在下文中一共展示了CMAC.finalize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_raises_after_finalize
# 需要導入模塊: from cryptography.hazmat.primitives.cmac import CMAC [as 別名]
# 或者: from cryptography.hazmat.primitives.cmac.CMAC import finalize [as 別名]
def test_raises_after_finalize(self, backend):
key = b"2b7e151628aed2a6abf7158809cf4f3c"
cmac = CMAC(AES(key), backend)
cmac.finalize()
with pytest.raises(AlreadyFinalized):
cmac.update(b"foo")
with pytest.raises(AlreadyFinalized):
cmac.copy()
with pytest.raises(AlreadyFinalized):
cmac.finalize()
示例2: test_aes_generate
# 需要導入模塊: from cryptography.hazmat.primitives.cmac import CMAC [as 別名]
# 或者: from cryptography.hazmat.primitives.cmac.CMAC import finalize [as 別名]
def test_aes_generate(self, backend, params):
key = params["key"]
message = params["message"]
output = params["output"]
cmac = CMAC(AES(binascii.unhexlify(key)), backend)
cmac.update(binascii.unhexlify(message))
assert binascii.hexlify(cmac.finalize()) == output
示例3: test_3des_generate
# 需要導入模塊: from cryptography.hazmat.primitives.cmac import CMAC [as 別名]
# 或者: from cryptography.hazmat.primitives.cmac.CMAC import finalize [as 別名]
def test_3des_generate(self, backend, params):
key1 = params["key1"]
key2 = params["key2"]
key3 = params["key3"]
key = key1 + key2 + key3
message = params["message"]
output = params["output"]
cmac = CMAC(TripleDES(binascii.unhexlify(key)), backend)
cmac.update(binascii.unhexlify(message))
assert binascii.hexlify(cmac.finalize()) == output
示例4: test_copy_with_backend
# 需要導入模塊: from cryptography.hazmat.primitives.cmac import CMAC [as 別名]
# 或者: from cryptography.hazmat.primitives.cmac.CMAC import finalize [as 別名]
def test_copy_with_backend(self, backend):
key = b"2b7e151628aed2a6abf7158809cf4f3c"
cmac = CMAC(AES(key), backend)
cmac.update(b"6bc1bee22e409f96e93d7e117393172a")
copy_cmac = cmac.copy()
assert cmac.finalize() == copy_cmac.finalize()