本文整理匯總了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"))