101 lines
3.9 KiB
HTML
101 lines
3.9 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
|
|
<head>
|
|
<title>Test for Messaging Layer Security</title>
|
|
<!-- SimpleTest Helpers -->
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
<!-- Local Helpers -->
|
|
<script src="head_mls.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
async function test_utils_get_group_identifier_and_epoch() {
|
|
|
|
const mls = new MLS();
|
|
|
|
// Generate Identities for Alice and Bob
|
|
let alice = await mls.generateIdentity();
|
|
let bob = await mls.generateIdentity();
|
|
|
|
// Generate Credentials for Alice and Bob
|
|
let credential_alice = await mls.generateCredential("alice");
|
|
let credential_bob = await mls.generateCredential("bob");
|
|
|
|
// Generate a KeyPackage for Bob
|
|
let kp_bob = await mls.generateKeyPackage(bob, credential_bob);
|
|
|
|
// Creation of a Group by Alice
|
|
let group_alice = await mls.groupCreate(alice, credential_alice);
|
|
|
|
// Test: compare the group identifier to the invalid value
|
|
info("Group Id:", byteArrayToHexString(group_alice.groupId));
|
|
isnot(byteArrayToHexString(group_alice.groupId), "", "Group Identifier != ''");
|
|
|
|
// Alice adds Bob to a group
|
|
let commit_output = await group_alice.add(kp_bob);
|
|
|
|
// Test: compare the commit output to the invalid value
|
|
info("Commit Output:", byteArrayToHexString(commit_output.commit));
|
|
isnot(byteArrayToHexString(commit_output.commit), "", "Commit != ''");
|
|
|
|
// Get the group details
|
|
let details = await group_alice.details();
|
|
info("Group Id:", byteArrayToHexString(details.groupId));
|
|
info("Group Epoch:", byteArrayToHexString(details.groupEpoch));
|
|
|
|
// Get the group identifier from the commit
|
|
let gid_commit = await mls.getGroupIdFromMessage(commit_output.commit);
|
|
info("Group Id from Commit Message:", byteArrayToHexString(gid_commit.content));
|
|
|
|
// Get the group identifier from the commit
|
|
let epoch_commit = await mls.getGroupEpochFromMessage(commit_output.commit);
|
|
info("Group Epoch from Commit Message:", byteArrayToHexString(epoch_commit.content));
|
|
|
|
// Note: the following is forbidden because Welcome is not an MLSMessage
|
|
// let gid_welcome = await mls.getGroupIdFromMessage(commit_output.welcome);
|
|
// info("Group Id from Welcome Message:", byteArrayToHexString(gid_welcome.content));
|
|
|
|
// Test: compare the group id of the commit to the current group id
|
|
is(byteArrayToHexString(details.groupId), byteArrayToHexString(gid_commit.content));
|
|
// Test: compare the group epoch of the commit to the current group epoch
|
|
is(byteArrayToHexString(details.groupEpoch), byteArrayToHexString(epoch_commit.content));
|
|
|
|
// Alice: process her Add commit
|
|
await group_alice.receive(commit_output.commit);
|
|
|
|
// Get the group details after processing the commit
|
|
let details2 = await group_alice.details();
|
|
info("Group Epoch 2:", byteArrayToHexString(details2.groupEpoch));
|
|
|
|
// Alice: removed Bob
|
|
let commit_output2 = await group_alice.remove(bob);
|
|
|
|
// Get the group identifier from the commit
|
|
let gid_commit2 = await mls.getGroupIdFromMessage(commit_output2.commit);
|
|
info("Group Id 2 from Commit Message 2:", byteArrayToHexString(gid_commit2.content));
|
|
|
|
// Get the group identifier from the commit2
|
|
let epoch_commit2 = await mls.getGroupEpochFromMessage(commit_output2.commit);
|
|
info("Group Epoch 2 from Commit Message 2:", byteArrayToHexString(epoch_commit2.content));
|
|
|
|
// Test: compare the group id of the commit to the current group id
|
|
is(byteArrayToHexString(details2.groupId), byteArrayToHexString(gid_commit2.content));
|
|
// Test: compare the group epoch of the commit to the current group epoch
|
|
is(byteArrayToHexString(details2.groupEpoch), byteArrayToHexString(epoch_commit2.content));
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
test_utils_get_group_identifier_and_epoch();
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
|
|
</html>
|