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

Method unwrap

mlspp/src/state.cpp:409–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407}
408
409ValidatedContent
410State::unwrap(const MLSMessage& msg)
411{
412 if (msg.version != ProtocolVersion::mls10) {
413 throw InvalidParameterError("Unsupported version");
414 }
415
416 const auto unprotect = overloaded{
417 [&](const PublicMessage& pt) -> ValidatedContent {
418 if (pt.get_group_id() != _group_id) {
419 throw ProtocolError("PublicMessage not for this group");
420 }
421
422 if (pt.get_epoch() != _epoch) {
423 throw ProtocolError("PublicMessage not for this epoch");
424 }
425
426 auto maybe_content_auth =
427 pt.unprotect(_suite, _key_schedule.membership_key, group_context());
428 if (!maybe_content_auth) {
429 throw ProtocolError("Membership tag failed to verify");
430 }
431 return opt::get(maybe_content_auth);
432 },
433
434 [&](const PrivateMessage& ct) -> ValidatedContent {
435 if (ct.get_group_id() != _group_id) {
436 throw ProtocolError("PrivateMessage not for this group");
437 }
438
439 if (ct.get_epoch() != _epoch) {
440 throw ProtocolError("PrivateMessage not for this epoch");
441 }
442
443 auto maybe_content_auth =
444 ct.unprotect(_suite, _keys, _key_schedule.sender_data_secret);
445 if (!maybe_content_auth) {
446 throw ProtocolError("PrivateMessage decryption failure");
447 }
448 return opt::get(maybe_content_auth);
449 },
450
451 [](const auto& /* unused */) -> ValidatedContent {
452 throw ProtocolError("Invalid wire format");
453 },
454 };
455
456 auto val_content = var::visit(unprotect, msg.message);
457 if (!verify(val_content.content_auth)) {
458 throw InvalidParameterError("Message signature failed to verify");
459 }
460
461 return val_content;
462}
463
464Proposal
465State::add_proposal(const KeyPackage& key_package) const

Callers 1

process_proposalsMethod · 0.80

Calls 6

ProtocolErrorClass · 0.85
getFunction · 0.50
get_group_idMethod · 0.45
get_epochMethod · 0.45
unprotectMethod · 0.45

Tested by

no test coverage detected