Skip to content

Commit

Permalink
Allow recursion; forbid multi-credential nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
bifurcation committed Aug 27, 2023
1 parent 209e0d6 commit 0ecf80b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Checks: '*,
-llvmlibc-restrict-system-libc-headers,
-misc-non-private-member-variables-in-classes,
-misc-use-anonymous-namespace,
-misc-no-recursion,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-function-cognitive-complexity,
Expand Down
4 changes: 4 additions & 0 deletions src/credential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ CredentialBinding::CredentialBinding(CipherSuite cipher_suite_in,
, credential(std::move(credential_in))
, credential_key(credential_priv.public_key)
{
if (credential.type() == CredentialType::multi_draft_00) {
throw InvalidParameterError("Multi-credentials cannot be nested");
}

if (!credential.valid_for(credential_key)) {
throw InvalidParameterError("Credential key does not match credential");
}
Expand Down
5 changes: 2 additions & 3 deletions src/treekem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ TreeKEMPublicKey::parent_hash_valid() const
}

std::vector<NodeIndex>
TreeKEMPublicKey::resolve(NodeIndex index) const // NOLINT(misc-no-recursion)
TreeKEMPublicKey::resolve(NodeIndex index) const
{
auto at_leaf = (index.level() == 0);
if (!node_at(index).blank()) {
Expand Down Expand Up @@ -797,7 +797,7 @@ struct TreeHashInput
};

const bytes&
TreeKEMPublicKey::get_hash(NodeIndex index) // NOLINT(misc-no-recursion)
TreeKEMPublicKey::get_hash(NodeIndex index)
{
if (hashes.count(index) > 0) {
return hashes.at(index);
Expand Down Expand Up @@ -905,7 +905,6 @@ TreeKEMPublicKey::parent_hashes(
}

const bytes&
// NOLINTNEXTLINE(misc-no-recursion)
TreeKEMPublicKey::original_tree_hash(TreeHashCache& cache,
NodeIndex index,
std::vector<LeafIndex> parent_except) const
Expand Down

0 comments on commit 0ecf80b

Please sign in to comment.