def test_direct_hkdf_verify_key_with_invalid_material(self): material = COSEKey.from_symmetric_key( key=base64url_decode( "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"), alg="A256GCM", ) ctx = DirectHKDF({1: -10}, {-20: b"aabbccddeeff"}) context = { "alg": "AES-CCM-16-64-128", "party_u": { "identity": "lighting-client", }, "party_v": { "identity": "lighting-server", }, "supp_pub": { "other": "Encryption Example 02", }, } key = ctx.apply( material, context=context, ) with pytest.raises(VerifyError) as err: ctx.verify_key( b"xxxxxxxxxx", key.key, context=context, ) pytest.fail("verify_key() should fail.") assert "Failed to verify key." in str(err.value)
def test_direct_hkdf_verify_key(self): material = COSEKey.from_symmetric_key( key=base64url_decode( "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"), alg="A256GCM", ) ctx = DirectHKDF({1: -10}, {-20: b"aabbccddeeff"}) context = { "alg": "AES-CCM-16-64-128", "party_u": { "identity": "lighting-client", }, "party_v": { "identity": "lighting-server", }, "supp_pub": { "other": "Encryption Example 02", }, } key = ctx.apply(material, context=context) ctx.verify_key( base64url_decode("hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"), key.key, context=context, )
def test_direct_hkdf_verify_key_with_raw_context(self): material = COSEKey.from_symmetric_key( key=base64url_decode( "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"), alg="A256GCM", ) ctx = DirectHKDF({1: -10}, {-20: b"aabbccddeeff"}) context = [ 10, [b"lighting-client", None, None], [b"lighting-server", None, None], [128, cbor2.dumps({1: -10}), b"Encryption Example 02"], ] key = ctx.apply(material, context=context) ctx.verify_key( base64url_decode("hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"), key.key, context=context, )