Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate passive client tests #356

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cmd/interop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ run: ${BUILD_DIR}/${APP_NAME}
./${BUILD_DIR}/${APP_NAME} -live 50001

self-test: ${BUILD_DIR}/${APP_NAME}
# TODO(RLB) Extend to 13 to cover passive client tests
for tv_type in 1 2 3 4 5 6 7 8 9 10 11 12; do \
for tv_type in 1 2 3 4 5 6 7 8 9 10 11 12 13; do \
echo Self-test on test vector type $$tv_type; \
./${BUILD_DIR}/${APP_NAME} -gen $$tv_type | ./${BUILD_DIR}/${APP_NAME} -ver $$tv_type; \
done
Expand All @@ -34,8 +33,7 @@ interop-test: ${BUILD_DIR}/${APP_NAME}
./${BUILD_DIR}/${APP_NAME} -ver 9 <${TEST_VECTOR_DIR}/welcome.json
./${BUILD_DIR}/${APP_NAME} -ver 10 <${TEST_VECTOR_DIR}/tree-operations.json
./${BUILD_DIR}/${APP_NAME} -ver 11 <${TEST_VECTOR_DIR}/treekem.json
# TODO(RLB) Uncomment once the messages test vectors are fixed
#./${BUILD_DIR}/${APP_NAME} -ver 12 <${TEST_VECTOR_DIR}/messages.json
./${BUILD_DIR}/${APP_NAME} -ver 12 <${TEST_VECTOR_DIR}/messages.json
./${BUILD_DIR}/${APP_NAME} -ver 13 <${TEST_VECTOR_DIR}/passive-client-welcome.json
./${BUILD_DIR}/${APP_NAME} -ver 13 <${TEST_VECTOR_DIR}/passive-client-handling-commit.json

Expand Down
6 changes: 5 additions & 1 deletion cmd/interop/src/json_details.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector::PSK, psk_id, psk)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector::Epoch,
proposals,
commit,
epoch_authenticator)
epoch_authenticator,
application_data,
application_message)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector,
cipher_suite,
key_package,
Expand All @@ -354,6 +356,8 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(PassiveClientTestVector,
welcome,
ratchet_tree,
initial_epoch_authenticator,
initial_epoch_application_data,
initial_epoch_application_message,
epochs)

} // namespace mls_vectors
12 changes: 11 additions & 1 deletion cmd/interop/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,17 @@ make_test_vector(uint64_t type)
MessagesTestVector(),
};

// TODO(RLB) TestVectorClass::passive_client_scenarios
case TestVectorClass::passive_client_scenarios: {
auto cases = std::vector<PassiveClientTestVector>();

for (const auto& suite : mls::all_supported_suites) {
for (const auto& scenario : PassiveClientTestVector::all_scenarios) {
cases.emplace_back(suite, scenario);
}
}

return cases;
}

default:
return nullptr;
Expand Down
28 changes: 28 additions & 0 deletions lib/mls_vectors/include/mls_vectors/mls_vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ struct PseudoRandom
bytes secret(const std::string& label) const;
bytes generate(const std::string& label, size_t size) const;

bool boolean(const std::string& label) const;
uint16_t uint16(const std::string& label) const;
uint32_t uint32(const std::string& label) const;
uint64_t uint64(const std::string& label) const;

uint32_t rand(const std::string& label, uint32_t max) const;

mls::SignaturePrivateKey signature_key(const std::string& label) const;
mls::HPKEPrivateKey hpke_key(const std::string& label) const;

std::tuple<mls::HPKEPrivateKey,
mls::HPKEPrivateKey,
mls::SignaturePrivateKey,
mls::KeyPackage>
key_package(const std::string& label) const;

size_t output_length() const;

private:
Expand Down Expand Up @@ -530,6 +539,19 @@ struct MessagesTestVector : PseudoRandom

struct PassiveClientTestVector : PseudoRandom
{
enum struct Scenario : uint32_t
{
join_via_welcome,
join_via_welcome_external_tree,
handle_commit_public,
handle_commit_private,
handle_commit_by_reference,
handle_external_commit,
handle_100_random_commits,
};

static const std::vector<Scenario> all_scenarios;

struct PSK
{
bytes psk_id;
Expand All @@ -541,6 +563,8 @@ struct PassiveClientTestVector : PseudoRandom
std::vector<mls::MLSMessage> proposals;
mls::MLSMessage commit;
bytes epoch_authenticator;
bytes application_data;
mls::MLSMessage application_message;
};

mls::CipherSuite cipher_suite;
Expand All @@ -554,10 +578,14 @@ struct PassiveClientTestVector : PseudoRandom

mls::MLSMessage welcome;
std::optional<mls::TreeKEMPublicKey> ratchet_tree;

bytes initial_epoch_authenticator;
bytes initial_epoch_application_data;
mls::MLSMessage initial_epoch_application_message;

std::vector<Epoch> epochs;

PassiveClientTestVector(mls::CipherSuite suite, Scenario scenario);
PassiveClientTestVector() = default;
std::optional<std::string> verify();
};
Expand Down
Loading
Loading