MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / valid

Method valid

mlspp/src/state.cpp:1472–1533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1470///
1471
1472bool
1473State::valid(const LeafNode& leaf_node,
1474 LeafNodeSource required_source,
1475 std::optional<LeafIndex> index) const
1476{
1477 // Verify that the credential in the LeafNode is valid as described in Section
1478 // 5.3.1.
1479 // XXX(RLB) N/A, no credential validation in the library right now
1480
1481 // Verify the leaf_node_source field:
1482 const auto correct_source = (leaf_node.source() == required_source);
1483
1484 // Verify that the signature on the LeafNode is valid using signature_key.
1485 auto binding = std::optional<LeafNode::MemberBinding>{};
1486 switch (required_source) {
1487 case LeafNodeSource::commit:
1488 case LeafNodeSource::update:
1489 binding = LeafNode::MemberBinding{ _group_id, opt::get(index) };
1490 break;
1491
1492 default:
1493 // Nothing to do
1494 break;
1495 }
1496
1497 const auto signature_valid = leaf_node.verify(_suite, binding);
1498
1499 // Verify that the LeafNode is compatible with the group's parameters. If the
1500 // GroupContext has a required_capabilities extension, then the required
1501 // extensions, proposals, and credential types MUST be listed in the
1502 // LeafNode's capabilities field.
1503 const auto supports_group_extensions =
1504 leaf_node.verify_extension_support(_extensions);
1505
1506 // TODO(RLB) Verify the lifetime field
1507
1508 // Verify that the credential type is supported by all members of the group,
1509 // as specified by the capabilities field of each member's LeafNode, and that
1510 // the capabilities field of this LeafNode indicates support for all the
1511 // credential types currently in use by other members.
1512 //
1513 // Verify that the following fields are unique among the members of the group:
1514 // signature_key
1515 // encryption_key
1516 //
1517 // Note: Uniqueness of signature and encryption keys is assured by the
1518 // tree operations (add/update), so we do not need to verify those here.
1519 const auto mutual_credential_support =
1520 _tree.all_leaves([&](auto /* i */, const auto& leaf) {
1521 return leaf.capabilities.credential_supported(leaf_node.credential) &&
1522 leaf_node.capabilities.credential_supported(leaf.credential);
1523 });
1524
1525 // Verify that the extensions in the LeafNode are supported by checking that
1526 // the ID for each extension in the extensions field is listed in the
1527 // capabilities.extensions field of the LeafNode.
1528 auto supports_own_extensions =
1529 leaf_node.verify_extension_support(leaf_node.extensions);

Callers

nothing calls this directly

Calls 12

all_leavesMethod · 0.80
credential_supportedMethod · 0.80
leaf_nodeMethod · 0.80
countMethod · 0.80
getFunction · 0.50
containsFunction · 0.50
sourceMethod · 0.45
verifyMethod · 0.45
has_leafMethod · 0.45
cipher_suiteMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected