@@ -39,15 +39,15 @@ TEST_CASE("SFrame Round-Trip")
3939 auto & key = pair.second ;
4040
4141 auto send = Context (suite);
42- UNWRAP ( send.add_key (kid, KeyUsage::protect, key));
42+ send.add_key (kid, KeyUsage::protect, key). unwrap ( );
4343
4444 auto recv = Context (suite);
45- UNWRAP ( recv.add_key (kid, KeyUsage::unprotect, key));
45+ recv.add_key (kid, KeyUsage::unprotect, key). unwrap ( );
4646
4747 for (int i = 0 ; i < rounds; i++) {
4848 auto encrypted =
49- to_bytes (UNWRAP ( send.protect (kid, ct_out, plaintext, {})));
50- auto decrypted = to_bytes (UNWRAP ( recv.unprotect (pt_out, encrypted, {})));
49+ to_bytes (send.protect (kid, ct_out, plaintext, {}). unwrap ( ));
50+ auto decrypted = to_bytes (recv.unprotect (pt_out, encrypted, {}). unwrap ( ));
5151 CHECK (decrypted == plaintext);
5252 }
5353 }
@@ -82,20 +82,22 @@ TEST_CASE("MLS Round-Trip")
8282 for (MLSContext::EpochID epoch_id = 0 ; epoch_id < test_epochs; epoch_id++) {
8383 const auto sframe_epoch_secret = bytes (8 , uint8_t (epoch_id));
8484
85- UNWRAP ( member_a.add_epoch (epoch_id, sframe_epoch_secret));
86- UNWRAP ( member_b.add_epoch (epoch_id, sframe_epoch_secret));
85+ member_a.add_epoch (epoch_id, sframe_epoch_secret). unwrap ( );
86+ member_b.add_epoch (epoch_id, sframe_epoch_secret). unwrap ( );
8787
8888 for (int i = 0 ; i < epoch_rounds; i++) {
89- auto encrypted_ab = UNWRAP (
90- member_a.protect (epoch_id, sender_id_a, ct_out, plaintext, metadata));
89+ auto encrypted_ab =
90+ member_a.protect (epoch_id, sender_id_a, ct_out, plaintext, metadata)
91+ .unwrap ();
9192 auto decrypted_ab =
92- UNWRAP ( member_b.unprotect (pt_out, encrypted_ab, metadata));
93+ member_b.unprotect (pt_out, encrypted_ab, metadata). unwrap ( );
9394 CHECK (plaintext == to_bytes (decrypted_ab));
9495
95- auto encrypted_ba = UNWRAP (
96- member_b.protect (epoch_id, sender_id_b, ct_out, plaintext, metadata));
96+ auto encrypted_ba =
97+ member_b.protect (epoch_id, sender_id_b, ct_out, plaintext, metadata)
98+ .unwrap ();
9799 auto decrypted_ba =
98- UNWRAP ( member_a.unprotect (pt_out, encrypted_ba, metadata));
100+ member_a.unprotect (pt_out, encrypted_ba, metadata). unwrap ( );
99101 CHECK (plaintext == to_bytes (decrypted_ba));
100102 }
101103 }
@@ -135,33 +137,46 @@ TEST_CASE("MLS Round-Trip with context")
135137 for (MLSContext::EpochID epoch_id = 0 ; epoch_id < test_epochs; epoch_id++) {
136138 const auto sframe_epoch_secret = bytes (8 , uint8_t (epoch_id));
137139
138- UNWRAP (
139- member_a_0. add_epoch (epoch_id, sframe_epoch_secret, sender_id_bits) );
140- UNWRAP (
141- member_a_1. add_epoch (epoch_id, sframe_epoch_secret, sender_id_bits) );
142- UNWRAP ( member_b.add_epoch (epoch_id, sframe_epoch_secret));
140+ member_a_0. add_epoch (epoch_id, sframe_epoch_secret, sender_id_bits)
141+ . unwrap ( );
142+ member_a_1. add_epoch (epoch_id, sframe_epoch_secret, sender_id_bits)
143+ . unwrap ( );
144+ member_b.add_epoch (epoch_id, sframe_epoch_secret). unwrap ( );
143145
144146 for (int i = 0 ; i < epoch_rounds; i++) {
145- auto encrypted_ab_0 = UNWRAP (member_a_0.protect (
146- epoch_id, sender_id_a, context_id_0, ct_out_0, plaintext, metadata));
147+ auto encrypted_ab_0 = member_a_0
148+ .protect (epoch_id,
149+ sender_id_a,
150+ context_id_0,
151+ ct_out_0,
152+ plaintext,
153+ metadata)
154+ .unwrap ();
147155 auto decrypted_ab_0 = to_bytes (
148- UNWRAP ( member_b.unprotect (pt_out, encrypted_ab_0, metadata)));
156+ member_b.unprotect (pt_out, encrypted_ab_0, metadata). unwrap ( ));
149157 CHECK (plaintext == decrypted_ab_0);
150158
151- auto encrypted_ab_1 = UNWRAP (member_a_1.protect (
152- epoch_id, sender_id_a, context_id_1, ct_out_1, plaintext, metadata));
159+ auto encrypted_ab_1 = member_a_1
160+ .protect (epoch_id,
161+ sender_id_a,
162+ context_id_1,
163+ ct_out_1,
164+ plaintext,
165+ metadata)
166+ .unwrap ();
153167 auto decrypted_ab_1 = to_bytes (
154- UNWRAP ( member_b.unprotect (pt_out, encrypted_ab_1, metadata)));
168+ member_b.unprotect (pt_out, encrypted_ab_1, metadata). unwrap ( ));
155169 CHECK (plaintext == decrypted_ab_1);
156170
157171 CHECK (to_bytes (encrypted_ab_0) != to_bytes (encrypted_ab_1));
158172
159- auto encrypted_ba = UNWRAP (member_b.protect (
160- epoch_id, sender_id_b, ct_out_0, plaintext, metadata));
173+ auto encrypted_ba =
174+ member_b.protect (epoch_id, sender_id_b, ct_out_0, plaintext, metadata)
175+ .unwrap ();
161176 auto decrypted_ba_0 = to_bytes (
162- UNWRAP ( member_a_0.unprotect (pt_out, encrypted_ba, metadata)));
177+ member_a_0.unprotect (pt_out, encrypted_ba, metadata). unwrap ( ));
163178 auto decrypted_ba_1 = to_bytes (
164- UNWRAP ( member_a_1.unprotect (pt_out, encrypted_ba, metadata)));
179+ member_a_1.unprotect (pt_out, encrypted_ba, metadata). unwrap ( ));
165180 CHECK (plaintext == decrypted_ba_0);
166181 CHECK (plaintext == decrypted_ba_1);
167182 }
@@ -187,17 +202,18 @@ TEST_CASE("MLS Failure after Purge")
187202
188203 // Install epoch 1 and create a cipihertext
189204 const auto epoch_id_1 = MLSContext::EpochID (1 );
190- UNWRAP ( member_a.add_epoch (epoch_id_1, sframe_epoch_secret_1));
191- UNWRAP ( member_b.add_epoch (epoch_id_1, sframe_epoch_secret_1));
205+ member_a.add_epoch (epoch_id_1, sframe_epoch_secret_1). unwrap ( );
206+ member_b.add_epoch (epoch_id_1, sframe_epoch_secret_1). unwrap ( );
192207
193- const auto enc_ab_1 = UNWRAP (
194- member_a.protect (epoch_id_1, sender_id_a, ct_out, plaintext, metadata));
208+ const auto enc_ab_1 =
209+ member_a.protect (epoch_id_1, sender_id_a, ct_out, plaintext, metadata)
210+ .unwrap ();
195211 const auto enc_ab_1_data = to_bytes (enc_ab_1);
196212
197213 // Install epoch 2
198214 const auto epoch_id_2 = MLSContext::EpochID (2 );
199- UNWRAP ( member_a.add_epoch (epoch_id_2, sframe_epoch_secret_2));
200- UNWRAP ( member_b.add_epoch (epoch_id_2, sframe_epoch_secret_2));
215+ member_a.add_epoch (epoch_id_2, sframe_epoch_secret_2). unwrap ( );
216+ member_b.add_epoch (epoch_id_2, sframe_epoch_secret_2). unwrap ( );
201217
202218 // Purge epoch 1 and verify failure
203219 member_a.purge_before (epoch_id_2);
@@ -209,8 +225,9 @@ TEST_CASE("MLS Failure after Purge")
209225 CHECK (member_b.unprotect (pt_out, enc_ab_1_data, metadata).error ().type () ==
210226 SFrameErrorType::invalid_parameter_error);
211227
212- const auto enc_ab_2 = UNWRAP (
213- member_a.protect (epoch_id_2, sender_id_a, ct_out, plaintext, metadata));
214- const auto dec_ab_2 = UNWRAP (member_b.unprotect (pt_out, enc_ab_2, metadata));
228+ const auto enc_ab_2 =
229+ member_a.protect (epoch_id_2, sender_id_a, ct_out, plaintext, metadata)
230+ .unwrap ();
231+ const auto dec_ab_2 = member_b.unprotect (pt_out, enc_ab_2, metadata).unwrap ();
215232 CHECK (plaintext == to_bytes (dec_ab_2));
216233}
0 commit comments