MCPcopy Create free account
hub / github.com/bcgit/bc-java / importTree

Method importTree

mls/src/main/java/org/bouncycastle/mls/protocol/Group.java:2368–2403  ·  view source on GitHub ↗
(byte[] treeHash, TreeKEMPublicKey external, List<Extension> extensions)

Source from the content-addressed store, hash-verified

2366 return new GroupContext(suite, groupID, epoch, tree.getRootHash(), transcriptHash.getConfirmed(), extensions);
2367 }
2368
2369 private TreeKEMPublicKey importTree(byte[] treeHash, TreeKEMPublicKey external, List<Extension> extensions)
2370 throws Exception
2371 {
2372 // Check if extensions contain a ratchet tree
2373 TreeKEMPublicKey outTree = null;
2374 for (Extension ext : extensions)
2375 {
2376 outTree = ext.getRatchetTree();
2377 if (outTree != null)
2378 {
2379 break;
2380 }
2381 }
2382 if (external != null)
2383 {
2384 outTree = external;
2385 }
2386 else if (outTree == null)
2387 {
2388 throw new Exception("No tree available");
2389 }
2390
2391 outTree.setSuite(suite);
2392 outTree.setHashAll();
2393 if (!Arrays.areEqual(outTree.getRootHash(), treeHash))
2394 {
2395 throw new Exception("Tree does not match GroupInfo");
2396 }
2397
2398 if (!outTree.verifyParentHash())
2399 {
2400 throw new Exception("Invalid tree");
2401 }
2402
2403 return outTree;
2404 }
2405
2406 private List<KeyScheduleEpoch.PSKWithSecret> resolve(List<PreSharedKeyID> psks)

Callers 1

GroupMethod · 0.95

Calls 6

setSuiteMethod · 0.95
setHashAllMethod · 0.95
areEqualMethod · 0.95
getRootHashMethod · 0.95
verifyParentHashMethod · 0.95
getRatchetTreeMethod · 0.80

Tested by

no test coverage detected