本文整理汇总了Python中cryptography.hazmat.primitives.kdf.hkdf.HKDF.verify方法的典型用法代码示例。如果您正苦于以下问题:Python HKDF.verify方法的具体用法?Python HKDF.verify怎么用?Python HKDF.verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptography.hazmat.primitives.kdf.hkdf.HKDF
的用法示例。
在下文中一共展示了HKDF.verify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_already_finalized
# 需要导入模块: from cryptography.hazmat.primitives.kdf.hkdf import HKDF [as 别名]
# 或者: from cryptography.hazmat.primitives.kdf.hkdf.HKDF import verify [as 别名]
def test_already_finalized(self, backend):
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
hkdf.derive(b"\x01" * 16)
with pytest.raises(AlreadyFinalized):
hkdf.derive(b"\x02" * 16)
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
hkdf.verify(b"\x01" * 16, b"gJ\xfb{\xb1Oi\xc5sMC\xb7\[email protected]\xf7u")
with pytest.raises(AlreadyFinalized):
hkdf.verify(b"\x02" * 16, b"gJ\xfb{\xb1Oi\xc5sMC\xb7\[email protected]\xf7u")
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
示例2: test_verify
# 需要导入模块: from cryptography.hazmat.primitives.kdf.hkdf import HKDF [as 别名]
# 或者: from cryptography.hazmat.primitives.kdf.hkdf.HKDF import verify [as 别名]
def test_verify(self, backend):
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
hkdf.verify(b"\x01" * 16, b"gJ\xfb{\xb1Oi\xc5sMC\xb7\[email protected]\xf7u")
示例3: test_verify_invalid
# 需要导入模块: from cryptography.hazmat.primitives.kdf.hkdf import HKDF [as 别名]
# 或者: from cryptography.hazmat.primitives.kdf.hkdf.HKDF import verify [as 别名]
def test_verify_invalid(self, backend):
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
with pytest.raises(InvalidKey):
hkdf.verify(b"\x02" * 16, b"gJ\xfb{\xb1Oi\xc5sMC\xb7\[email protected]\xf7u")
示例4: test_unicode_typeerror
# 需要导入模块: from cryptography.hazmat.primitives.kdf.hkdf import HKDF [as 别名]
# 或者: from cryptography.hazmat.primitives.kdf.hkdf.HKDF import verify [as 别名]
def test_unicode_typeerror(self, backend):
with pytest.raises(TypeError):
HKDF(
hashes.SHA256(),
16,
salt=six.u("foo"),
info=None,
backend=backend
)
with pytest.raises(TypeError):
HKDF(
hashes.SHA256(),
16,
salt=None,
info=six.u("foo"),
backend=backend
)
with pytest.raises(TypeError):
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
hkdf.derive(six.u("foo"))
with pytest.raises(TypeError):
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
hkdf.verify(six.u("foo"), b"bar")
with pytest.raises(TypeError):
hkdf = HKDF(
hashes.SHA256(),
16,
salt=None,
info=None,
backend=backend
)
hkdf.verify(b"foo", six.u("bar"))