當前位置: 首頁>>代碼示例>>Python>>正文


Python HKDF.verify方法代碼示例

本文整理匯總了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
        )
開發者ID:OspreyX,項目名稱:cryptography,代碼行數:36,代碼來源:test_hkdf.py

示例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")
開發者ID:OspreyX,項目名稱:cryptography,代碼行數:12,代碼來源:test_hkdf.py

示例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")
開發者ID:OspreyX,項目名稱:cryptography,代碼行數:13,代碼來源:test_hkdf.py

示例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"))
開發者ID:OspreyX,項目名稱:cryptography,代碼行數:53,代碼來源:test_hkdf.py


注:本文中的cryptography.hazmat.primitives.kdf.hkdf.HKDF.verify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。