Debian Codegraph @

mlspp/src/session.cpp

raw symbols SCIP
1 #cxx . . $ `<file>/mlspp/src/session.cpp`/include <mls/messages.h>cxx . . $ `<file>/mlspp/include/mls/messages.h`/
2 #include <mls/session.h>cxx . . $ `<file>/mlspp/include/mls/session.h`/
3
4 #include <deque>
5
6 namespace mlsppcxx . . $ mlspp/ {
7
8 ///
9 /// Inner struct declarations for PendingJoin and Session
10 ///
11
12 struct PendingJoincxx . . $ mlspp/PendingJoin#::Innercxx . . $ mlspp/PendingJoin#Inner#
13 {
14 const CipherSuitecxx . . $ mlspp/CipherSuite# suitecxx . . $ mlspp/PendingJoin#Inner#suite.;
15 const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey# init_privcxx . . $ mlspp/PendingJoin#Inner#init_priv.;
16 const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey# leaf_privcxx . . $ mlspp/PendingJoin#Inner#leaf_priv.;
17 const SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey# sig_privcxx . . $ mlspp/PendingJoin#Inner#sig_priv.;
18 const KeyPackagecxx . . $ mlspp/KeyPackage# key_packagecxx . . $ mlspp/PendingJoin#Inner#key_package.;
19
20 Innercxx . . $ mlspp/PendingJoin#Inner#Inner(e1b65f719e256a5d).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
21 SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey# sig_priv_in,
22 Credentialcxx . . $ mlspp/Credential# cred_in);
23
24 static PendingJoincxx . . $ mlspp/PendingJoin# createcxx . . $ mlspp/PendingJoin#Inner#create(59ec54d5927b1c9d).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
25 SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey# sig_priv,
26 Credentialcxx . . $ mlspp/Credential# cred);
27 };
28
29 struct Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#
30 {
31 stdcxx . . $ std/::dequecxx . . $ std/deque#<Statecxx . . $ mlspp/State#> historycxx . . $ mlspp/Session#Inner#history.;
32 stdcxx . . $ std/::mapcxx . . $ std/map#<bytescxx . . $ mlspp/bytes_ns/bytes#, Statecxx . . $ mlspp/State#> outbound_cachecxx . . $ mlspp/Session#Inner#outbound_cache.;
33 bool encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake.{ false };
34
35 explicit Innercxx . . $ mlspp/Session#Inner#Inner(47703e9e6546fd4f).(Statecxx . . $ mlspp/State# state);
36
37 static Sessioncxx . . $ mlspp/Session# begincxx . . $ mlspp/Session#Inner#begin(420306a94e91a5ae).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
38 const bytescxx . . $ mlspp/bytes_ns/bytes#& group_id,
39 const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#& leaf_priv,
40 const SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey#& sig_priv,
41 const LeafNodecxx . . $ mlspp/LeafNode#& leaf_node);
42 static Sessioncxx . . $ mlspp/Session# joincxx . . $ mlspp/Session#Inner#join(5530aefacff6e985).(const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#& init_priv,
43 const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#& leaf_priv,
44 const SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey#& sig_priv,
45 const KeyPackagecxx . . $ mlspp/KeyPackage#& key_package,
46 const bytescxx . . $ mlspp/bytes_ns/bytes#& welcome_data);
47
48 bytescxx . . $ mlspp/bytes_ns/bytes# fresh_secretcxx . . $ mlspp/Session#Inner#fresh_secret(d7392ba79aa35767).() const;
49 MLSMessagecxx . . $ mlspp/MLSMessage# import_handshakecxx . . $ mlspp/Session#Inner#import_handshake(49e5c1adfa818c9d).(const bytescxx . . $ mlspp/bytes_ns/bytes#& encoded) const;
50 Statecxx . . $ mlspp/State#& for_epochcxx . . $ mlspp/Session#Inner#for_epoch(79c3df9b21666572).(epoch_tcxx . . $ mlspp/epoch_t# epoch);
51 };
52
53 ///
54 /// Client
55 ///
56
57 Clientcxx . . $ mlspp/Client#::Clientcxx . . $ mlspp/Client#Client(e1b65f719e256a5d).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
58 SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey# sig_priv_in,
59 Credentialcxx . . $ mlspp/Credential# cred_in)
60 : suitecxx . . $ mlspp/Client#suite.(suite_in)
61 , sig_privcxx . . $ mlspp/Client#sig_priv.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sig_priv_in))
62 , credcxx . . $ mlspp/Client#cred.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cred_in))
63 {
64 }
65
66 Sessioncxx . . $ mlspp/Session#
67 Clientcxx . . $ mlspp/Client#::begin_sessioncxx . . $ mlspp/Client#begin_session(8d8bcc04c5fd1007).(const bytescxx . . $ mlspp/bytes_ns/bytes#& group_id) const
68 {
69 auto leaf_priv = HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#::generatecxx . . $ mlspp/HPKEPrivateKey#generate(4a2a6d1c0a9e0cd3).(suitecxx . . $ mlspp/Client#suite.);
70 auto leaf_node = LeafNodecxx . . $ mlspp/LeafNode#LeafNode(9cfddcd946cb7e25).(suitecxx . . $ mlspp/Client#suite.,
71 leaf_priv.public_keycxx . . $ mlspp/HPKEPrivateKey#public_key.,
72 sig_privcxx . . $ mlspp/Client#sig_priv..public_keycxx . . $ mlspp/SignaturePrivateKey#public_key.,
73 credcxx . . $ mlspp/Client#cred.,
74 Capabilitiescxx . . $ mlspp/Capabilities#::create_defaultcxx . . $ mlspp/Capabilities#create_default(72893c932794c163).(),
75 Lifetimecxx . . $ mlspp/Lifetime#::create_defaultcxx . . $ mlspp/Lifetime#create_default(e767398740424635).(),
76 {},
77 sig_privcxx . . $ mlspp/Client#sig_priv.);
78
79 return Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::begincxx . . $ mlspp/Session#Inner#begin(420306a94e91a5ae).(suitecxx . . $ mlspp/Client#suite., group_id, leaf_priv, sig_privcxx . . $ mlspp/Client#sig_priv., leaf_node);
80 }
81
82 PendingJoincxx . . $ mlspp/PendingJoin#
83 Clientcxx . . $ mlspp/Client#::start_joincxx . . $ mlspp/Client#start_join(80aba4e6009c629c).() const
84 {
85 return PendingJoincxx . . $ mlspp/PendingJoin#::Innercxx . . $ mlspp/PendingJoin#Inner#::createcxx . . $ mlspp/PendingJoin#Inner#create(59ec54d5927b1c9d).(suitecxx . . $ mlspp/Client#suite., sig_privcxx . . $ mlspp/Client#sig_priv., credcxx . . $ mlspp/Client#cred.);
86 }
87
88 ///
89 /// PendingJoin
90 ///
91
92 PendingJoincxx . . $ mlspp/PendingJoin#::Innercxx . . $ mlspp/PendingJoin#Inner#::Innercxx . . $ mlspp/PendingJoin#Inner#Inner(e1b65f719e256a5d).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
93 SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey# sig_priv_in,
94 Credentialcxx . . $ mlspp/Credential# cred_in)
95 : suitecxx . . $ mlspp/PendingJoin#Inner#suite.(suite_in)
96 , init_privcxx . . $ mlspp/PendingJoin#Inner#init_priv.(HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#::generatecxx . . $ mlspp/HPKEPrivateKey#generate(4a2a6d1c0a9e0cd3).(suitecxx . . $ mlspp/PendingJoin#Inner#suite.))
97 , leaf_privcxx . . $ mlspp/PendingJoin#Inner#leaf_priv.(HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#::generatecxx . . $ mlspp/HPKEPrivateKey#generate(4a2a6d1c0a9e0cd3).(suitecxx . . $ mlspp/PendingJoin#Inner#suite.))
98 , sig_privcxx . . $ mlspp/PendingJoin#Inner#sig_priv.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sig_priv_in))
99 , key_packagecxx . . $ mlspp/PendingJoin#Inner#key_package.(suitecxx . . $ mlspp/PendingJoin#Inner#suite.,
100 init_privcxx . . $ mlspp/PendingJoin#Inner#init_priv..public_keycxx . . $ mlspp/HPKEPrivateKey#public_key.,
101 LeafNodecxx . . $ mlspp/LeafNode#LeafNode(9cfddcd946cb7e25).(suitecxx . . $ mlspp/PendingJoin#Inner#suite.,
102 leaf_privcxx . . $ mlspp/PendingJoin#Inner#leaf_priv..public_keycxx . . $ mlspp/HPKEPrivateKey#public_key.,
103 sig_privcxx . . $ mlspp/PendingJoin#Inner#sig_priv..public_keycxx . . $ mlspp/SignaturePrivateKey#public_key.,
104 stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cred_in),
105 Capabilitiescxx . . $ mlspp/Capabilities#::create_defaultcxx . . $ mlspp/Capabilities#create_default(72893c932794c163).(),
106 Lifetimecxx . . $ mlspp/Lifetime#::create_defaultcxx . . $ mlspp/Lifetime#create_default(e767398740424635).(),
107 {},
108 sig_privcxx . . $ mlspp/PendingJoin#Inner#sig_priv.),
109 {},
110 sig_privcxx . . $ mlspp/PendingJoin#Inner#sig_priv.)
111 {
112 }
113
114 PendingJoincxx . . $ mlspp/PendingJoin#
115 PendingJoincxx . . $ mlspp/PendingJoin#::Innercxx . . $ mlspp/PendingJoin#Inner#::createcxx . . $ mlspp/PendingJoin#Inner#create(59ec54d5927b1c9d).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
116 SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey# sig_priv,
117 Credentialcxx . . $ mlspp/Credential# cred)
118 {
119 auto inner =
120 stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<Innercxx . . $ mlspp/PendingJoin#Inner#>(suite, stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sig_priv), stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cred));
121 return {cxx . . $ mlspp/PendingJoin#PendingJoin(acb4e0c1a30c9f27). inner.releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).() };
122 }
123
124 PendingJoincxx . . $ mlspp/PendingJoin#::PendingJoincxx . . $ mlspp/PendingJoin#PendingJoin(66fe689790c5212a).(PendingJoincxx . . $ mlspp/PendingJoin#&& other) noexcept = default;
125
126 PendingJoincxx . . $ mlspp/PendingJoin#&
127 PendingJoincxx . . $ mlspp/PendingJoin#::operatorcxx . . $ mlspp/PendingJoin#`operator=`(bee7155b6c38152d).=(PendingJoincxx . . $ mlspp/PendingJoin#&& other) noexcept = default;
128
129 PendingJoincxx . . $ mlspp/PendingJoin#::~cxx . . $ mlspp/PendingJoin#`~PendingJoin`(ced63f7c635d850d).PendingJoincxx . . $ mlspp/PendingJoin#() = default;
130
131 PendingJoincxx . . $ mlspp/PendingJoin#::PendingJoincxx . . $ mlspp/PendingJoin#PendingJoin(acb4e0c1a30c9f27).(Innercxx . . $ mlspp/PendingJoin#Inner#* inner_in)
132 : innercxx . . $ mlspp/PendingJoin#inner.(inner_in)
133 {
134 }
135
136 bytescxx . . $ mlspp/bytes_ns/bytes#
137 PendingJoincxx . . $ mlspp/PendingJoin#::key_packagecxx . . $ mlspp/PendingJoin#key_package(d7392ba79aa35767).() const
138 {
139 return tlscxx . . $ mlspp/bytes_ns/bytes#bytes(dd8c33c7e39dbe02).::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(innercxx . . $ mlspp/PendingJoin#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).key_packagecxx . . $ mlspp/PendingJoin#Inner#key_package.);
140 }
141
142 Sessioncxx . . $ mlspp/Session#
143 PendingJoincxx . . $ mlspp/PendingJoin#::completecxx . . $ mlspp/PendingJoin#complete(8d8bcc04c5fd1007).(const bytescxx . . $ mlspp/bytes_ns/bytes#& welcome) const
144 {
145 return Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::joincxx . . $ mlspp/Session#Inner#join(5530aefacff6e985).(innercxx . . $ mlspp/PendingJoin#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).init_privcxx . . $ mlspp/PendingJoin#Inner#init_priv.,
146 innercxx . . $ mlspp/PendingJoin#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).leaf_privcxx . . $ mlspp/PendingJoin#Inner#leaf_priv.,
147 innercxx . . $ mlspp/PendingJoin#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).sig_privcxx . . $ mlspp/PendingJoin#Inner#sig_priv.,
148 innercxx . . $ mlspp/PendingJoin#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).key_packagecxx . . $ mlspp/PendingJoin#Inner#key_package.,
149 welcome);
150 }
151
152 ///
153 /// Session
154 ///
155
156 Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::Innercxx . . $ mlspp/Session#Inner#Inner(47703e9e6546fd4f).(Statecxx . . $ mlspp/State# state)
157 : historycxx . . $ mlspp/Session#Inner#history.{ stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(state) }
158 , encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake.(true)
159 {
160 }
161
162 Sessioncxx . . $ mlspp/Session#
163 Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::begincxx . . $ mlspp/Session#Inner#begin(420306a94e91a5ae).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
164 const bytescxx . . $ mlspp/bytes_ns/bytes#& group_id,
165 const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#& leaf_priv,
166 const SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey#& sig_priv,
167 const LeafNodecxx . . $ mlspp/LeafNode#& leaf_node)
168 {
169 auto state = Statecxx . . $ mlspp/State#State(5c99977e15e97b35).(group_idcxx . . $ mlspp/bytes_ns/bytes#bytes(68ca607eebb5be3e)., suite, leaf_priv, sig_priv, leaf_node, {});
170 auto inner = stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<Innercxx . . $ mlspp/Session#Inner#>(state);
171 return {cxx . . $ mlspp/Session#Session(115d991b8dafe68b). inner.releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).() };
172 }
173
174 Sessioncxx . . $ mlspp/Session#
175 Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::joincxx . . $ mlspp/Session#Inner#join(5530aefacff6e985).(const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#& init_priv,
176 const HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#& leaf_priv,
177 const SignaturePrivateKeycxx . . $ mlspp/SignaturePrivateKey#& sig_priv,
178 const KeyPackagecxx . . $ mlspp/KeyPackage#& key_package,
179 const bytescxx . . $ mlspp/bytes_ns/bytes#& welcome_data)
180 {
181 auto welcome = tlscxx . . $ mlspp/tls/::getcxx . . $ mlspp/tls/get(fdfeec44f419faae).<Welcomecxx . . $ mlspp/Welcome#>(welcome_data);
182
183 auto state = Statecxx . . $ mlspp/State#State(b37a46165eb9ffa8).(
184 init_priv, leaf_priv, sig_priv, key_package, welcome, stdcxx . . $ std/optional#optional(eb2253fdec8870b5).::nulloptcxx . . $ std/nullopt., {cxx . . $ std/map#map(49f6e7a06ebc5aa8).});
185 auto inner = stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<Innercxx . . $ mlspp/Session#Inner#>(state);
186 return {cxx . . $ mlspp/Session#Session(115d991b8dafe68b). inner.releasecxx . . $ std/unique_ptr#release(aad4c3669c5e940c).() };
187 }
188
189 bytescxx . . $ mlspp/bytes_ns/bytes#
190 Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::fresh_secretcxx . . $ mlspp/Session#Inner#fresh_secret(d7392ba79aa35767).() const
191 {
192 const auto suite = historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(fb1649ee09dd2205).().cipher_suitecxx . . $ mlspp/State#cipher_suite(17658033c3289662).();
193 return random_bytescxx . . $ mlspp/random_bytes(b7161179e0ed6f95).(suite.secret_sizecxx . . $ mlspp/CipherSuite#secret_size(fe4d2d262d4164a8).());
194 }
195
196 MLSMessagecxx . . $ mlspp/MLSMessage#
197 Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::import_handshakecxx . . $ mlspp/Session#Inner#import_handshake(49e5c1adfa818c9d).(const bytescxx . . $ mlspp/bytes_ns/bytes#& encoded) const
198 {
199 auto msg = tlscxx . . $ mlspp/tls/::getcxx . . $ mlspp/tls/get(fdfeec44f419faae).<MLSMessagecxx . . $ mlspp/MLSMessage#>(encoded);
200
201 switch (msg.wire_formatcxx . . $ mlspp/MLSMessage#wire_format(6821ab1531194d4c).()) {
202 case WireFormatcxx . . $ mlspp/WireFormat#::mls_public_messagecxx . . $ mlspp/WireFormat#mls_public_message.:
203 if (encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake.) {
204 throw ProtocolErrorcxx . . $ mlspp/ProtocolError#("Handshake not encrypted as required");
205 }
206
207 return msg;
208
209 case WireFormatcxx . . $ mlspp/WireFormat#::mls_private_messagecxx . . $ mlspp/WireFormat#mls_private_message.: {
210 if (!encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake.) {
211 throw ProtocolErrorcxx . . $ mlspp/ProtocolError#("Unexpected handshake encryption");
212 }
213
214 return msg;
215 }
216
217 default:
218 throw InvalidParameterErrorcxx . . $ mlspp/InvalidParameterError#("Illegal wire format");
219 }
220 }
221
222 Statecxx . . $ mlspp/State#&
223 Sessioncxx . . $ mlspp/Session#::Innercxx . . $ mlspp/Session#Inner#::for_epochcxx . . $ mlspp/Session#Inner#for_epoch(79c3df9b21666572).(epoch_tcxx . . $ mlspp/epoch_t# epoch)
224 {
225 for (auto& state : historycxx . . $ mlspp/Session#Inner#history.) {
226 if (state.epochcxx . . $ mlspp/State#epoch(fe4d2d262d4164a8).() == epoch) {
227 return state;
228 }
229 }
230
231 throw MissingStateErrorcxx . . $ mlspp/MissingStateError#("No state for epoch");
232 }
233
234 Sessioncxx . . $ mlspp/Session#::Sessioncxx . . $ mlspp/Session#Session(d4ff7b29e24e0b3c).(Sessioncxx . . $ mlspp/Session#&& other) noexcept = default;
235
236 Sessioncxx . . $ mlspp/Session#&
237 Sessioncxx . . $ mlspp/Session#::operatorcxx . . $ mlspp/Session#`operator=`(bb04ebce023303c1).=(Sessioncxx . . $ mlspp/Session#&& other) noexcept = default;
238
239 Sessioncxx . . $ mlspp/Session#::~cxx . . $ mlspp/Session#`~Session`(ced63f7c635d850d).Sessioncxx . . $ mlspp/Session#() = default;
240
241 Sessioncxx . . $ mlspp/Session#::Sessioncxx . . $ mlspp/Session#Session(115d991b8dafe68b).(Innercxx . . $ mlspp/Session#Inner#* inner_in)
242 : innercxx . . $ mlspp/Session#inner.(inner_in)
243 {
244 }
245
246 void
247 Sessioncxx . . $ mlspp/Session#::encrypt_handshakecxx . . $ mlspp/Session#encrypt_handshake(b45ddcbc8423892c).(bool enabled)
248 {
249 innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake. = enabled;
250 }
251
252 bytescxx . . $ mlspp/bytes_ns/bytes#
253 Sessioncxx . . $ mlspp/Session#::addcxx . . $ mlspp/Session#add(dfba7759a1cb6e97).(const bytescxx . . $ mlspp/bytes_ns/bytes#& key_package_data)
254 {
255 auto key_package = tlscxx . . $ mlspp/tls/::getcxx . . $ mlspp/tls/get(fdfeec44f419faae).<KeyPackagecxx . . $ mlspp/KeyPackage#>(key_package_data);
256 auto proposal = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().addcxx . . $ mlspp/State#add(42c8642ea0f153d7).(
257 key_package, { innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake., {}, 0 });
258 return tlscxx . . $ mlspp/bytes_ns/bytes#bytes(dd8c33c7e39dbe02).::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(proposal);
259 }
260
261 bytescxx . . $ mlspp/bytes_ns/bytes#
262 Sessioncxx . . $ mlspp/Session#::updatecxx . . $ mlspp/Session#update(ca7897ad6b2c4824).()
263 {
264 auto leaf_secret = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).fresh_secretcxx . . $ mlspp/Session#Inner#fresh_secret(d7392ba79aa35767).();
265
266 auto leaf_priv = HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey#::generatecxx . . $ mlspp/HPKEPrivateKey#generate(4a2a6d1c0a9e0cd3).(cipher_suitecxx . . $ mlspp/Session#cipher_suite(17658033c3289662).());
267 auto proposal = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().updatecxx . . $ mlspp/State#update(be9350ea97adfaa1).(
268 stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(leaf_priv), {}, { innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake., {}, 0 });
269 return tlscxx . . $ mlspp/bytes_ns/bytes#bytes(dd8c33c7e39dbe02).::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(proposal);
270 }
271
272 bytescxx . . $ mlspp/bytes_ns/bytes#
273 Sessioncxx . . $ mlspp/Session#::removecxx . . $ mlspp/Session#remove(3bf799d0b417da05).(uint32_tcxx . . $ uint32_t# index)
274 {
275 auto proposal = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().removecxx . . $ mlspp/State#remove(2ba6878df04e464).(
276 RosterIndexcxx . . $ mlspp/RosterIndex#{ index }, { innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake., {}, 0 });
277 return tlscxx . . $ mlspp/bytes_ns/bytes#bytes(dd8c33c7e39dbe02).::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(proposal);
278 }
279
280 stdcxx . . $ std/::tuplecxx . . $ std/tuple#<bytescxx . . $ mlspp/bytes_ns/bytes#, bytescxx . . $ mlspp/bytes_ns/bytes#>
281 Sessioncxx . . $ mlspp/Session#::commitcxx . . $ mlspp/Session#commit(de8c44e7c96b83a5).(const bytescxx . . $ mlspp/bytes_ns/bytes#& proposal)
282 {
283 return commitcxx . . $ mlspp/Session#commit(7bb89ffec2d8fe59).(stdcxx . . $ std/vector#vector(9619226211e5a241).::vectorcxx . . $ std/vector#<bytescxx . . $ mlspp/bytes_ns/bytes#>{ proposal });
284 }
285
286 stdcxx . . $ std/::tuplecxx . . $ std/tuple#<bytescxx . . $ mlspp/bytes_ns/bytes#, bytescxx . . $ mlspp/bytes_ns/bytes#>
287 Sessioncxx . . $ mlspp/Session#::commitcxx . . $ mlspp/Session#commit(7bb89ffec2d8fe59).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<bytescxx . . $ mlspp/bytes_ns/bytes#>& proposals)
288 {
289 auto provisional_state = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).();
290 for (const auto& proposal_data : proposals) {
291 auto msg = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).import_handshakecxx . . $ mlspp/Session#Inner#import_handshake(49e5c1adfa818c9d).(proposal_data);
292 auto maybe_state = provisional_state.handlecxx . . $ mlspp/State#handle(2758c2375a1dbd3).(msg);
293 if (maybe_state) {
294 throw InvalidParameterErrorcxx . . $ mlspp/InvalidParameterError#("Invalid proposal; actually a commit");
295 }
296 }
297
298 innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).() =cxx . . $ mlspp/State#`operator=`(92b87e335dd31705). stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(provisional_state);
299 return commitcxx . . $ mlspp/Session#commit(a98c4a6c7c0c881c).();
300 }
301
302 stdcxx . . $ std/::tuplecxx . . $ std/tuple#<bytescxx . . $ mlspp/bytes_ns/bytes#, bytescxx . . $ mlspp/bytes_ns/bytes#>
303 Sessioncxx . . $ mlspp/Session#::commitcxx . . $ mlspp/Session#commit(a98c4a6c7c0c881c).()
304 {
305 auto commit_secret = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).fresh_secretcxx . . $ mlspp/Session#Inner#fresh_secret(d7392ba79aa35767).();
306 auto encrypt = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake.;
307 auto [commit, welcome, new_state] = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().commitcxx . . $ mlspp/State#commit(79c4e4ce2bdb005c).(
308 commit_secret, CommitOptscxx . . $ std/optional#optional(e3f0d6382bd52f24).{ {}, true, encrypt, {} }, { encrypt, {}, 0 });
309
310 auto commit_msg = tlscxx . . $ mlspp/tls/::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(commit);
311 auto welcome_msg = tlscxx . . $ mlspp/tls/::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(welcome);
312
313 innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).outbound_cachecxx . . $ mlspp/Session#Inner#outbound_cache..insertcxx . . $ std/map#insert(274b9441a76f0de8).({cxx . . $ std/pair#pair(14d64bafa7379ebc). commit_msg, new_state });
314 return stdcxx . . $ std/tuple#tuple(1fdc5ba6d7e3595).::make_tuplecxx . . $ std/make_tuple(3964edbfd7e8599f).(welcome_msg, commit_msg);
315 }
316
317 bool
318 Sessioncxx . . $ mlspp/Session#::handlecxx . . $ mlspp/Session#handle(5324a0d004675752).(const bytescxx . . $ mlspp/bytes_ns/bytes#& handshake_data)
319 {
320 auto msg = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).import_handshakecxx . . $ mlspp/Session#Inner#import_handshake(49e5c1adfa818c9d).(handshake_data);
321
322 auto maybe_cached_state = stdcxx . . $ std/optional#optional(ced63f7c635d850d).::optionalcxx . . $ std/optional#<Statecxx . . $ mlspp/State#>{};
323 auto node = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).outbound_cachecxx . . $ mlspp/Session#Inner#outbound_cache..extractcxx . . $ std/map#extract(d9401cf645c267cb).(handshake_data);
324 if (!node.emptycxx . . $ std/_Node_handle_common#empty(3482b152b9333168).()) {
325 maybe_cached_state =cxx . . $ std/optional#`operator=`(4ce4dd0ee161fed). node.mappedcxx . . $ std/_Node_handle#mapped(17e598cc1ac8da5c).();
326 }
327
328 auto maybe_next_state =
329 innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().handlecxx . . $ mlspp/State#handle(2377cf03b043af66).(msg, maybe_cached_state);
330 if (!maybe_next_state) {
331 return false;
332 }
333
334 innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..emplace_frontcxx . . $ std/deque#emplace_front(df8c12b98d24bd1e).(opt::getcxx . . $ mlspp/tls/opt/get(f3e04ae79584f296).(maybe_next_state));
335 return true;
336 }
337
338 epoch_tcxx . . $ mlspp/epoch_t#
339 Sessioncxx . . $ mlspp/Session#::epochcxx . . $ mlspp/Session#epoch(fe4d2d262d4164a8).() const
340 {
341 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().epochcxx . . $ mlspp/State#epoch(fe4d2d262d4164a8).();
342 }
343
344 LeafIndexcxx . . $ mlspp/LeafIndex#
345 Sessioncxx . . $ mlspp/Session#::indexcxx . . $ mlspp/Session#index(80d08586c54e2b43).() const
346 {
347 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().indexcxx . . $ mlspp/State#index(80d08586c54e2b43).();
348 }
349
350 CipherSuitecxx . . $ mlspp/CipherSuite#
351 Sessioncxx . . $ mlspp/Session#::cipher_suitecxx . . $ mlspp/Session#cipher_suite(17658033c3289662).() const
352 {
353 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().cipher_suitecxx . . $ mlspp/State#cipher_suite(17658033c3289662).();
354 }
355
356 const ExtensionListcxx . . $ mlspp/ExtensionList#&
357 Sessioncxx . . $ mlspp/Session#::extensionscxx . . $ mlspp/Session#extensions(c8bb7beb367464e2).() const
358 {
359 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().extensionscxx . . $ mlspp/State#extensions(c8bb7beb367464e2).();
360 }
361
362 const TreeKEMPublicKeycxx . . $ mlspp/TreeKEMPublicKey#&
363 Sessioncxx . . $ mlspp/Session#::treecxx . . $ mlspp/Session#tree(c9f2b9505afa0dfa).() const
364 {
365 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().treecxx . . $ mlspp/State#tree(c9f2b9505afa0dfa).();
366 }
367
368 bytescxx . . $ mlspp/bytes_ns/bytes#
369 Sessioncxx . . $ mlspp/Session#::do_exportcxx . . $ mlspp/Session#do_export(7012e37337977242).(const stdcxx . . $ std/::stringcxx . . $ std/string#& label,
370 const bytescxx . . $ mlspp/bytes_ns/bytes#& context,
371 size_t size) const
372 {
373 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().do_exportcxx . . $ mlspp/State#do_export(7012e37337977242).(label, context, size);
374 }
375
376 GroupInfocxx . . $ mlspp/GroupInfo#
377 Sessioncxx . . $ mlspp/Session#::group_infocxx . . $ mlspp/Session#group_info(7d4a8b166841cdad).() const
378 {
379 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().group_infocxx . . $ mlspp/State#group_info(c29763f177bca0e).(true);
380 }
381
382 stdcxx . . $ std/::vectorcxx . . $ std/vector#<LeafNodecxx . . $ mlspp/LeafNode#>
383 Sessioncxx . . $ mlspp/Session#::rostercxx . . $ mlspp/Session#roster(e6c5b5c0a1adb3b2).() const
384 {
385 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().rostercxx . . $ mlspp/State#roster(e6c5b5c0a1adb3b2).();
386 }
387
388 bytescxx . . $ mlspp/bytes_ns/bytes#
389 Sessioncxx . . $ mlspp/Session#::epoch_authenticatorcxx . . $ mlspp/Session#epoch_authenticator(d7392ba79aa35767).() const
390 {
391 return innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().epoch_authenticatorcxx . . $ mlspp/State#epoch_authenticator(d7392ba79aa35767).();
392 }
393
394 bytescxx . . $ mlspp/bytes_ns/bytes#
395 Sessioncxx . . $ mlspp/Session#::protectcxx . . $ mlspp/Session#protect(dfba7759a1cb6e97).(const bytescxx . . $ mlspp/bytes_ns/bytes#& plaintext)
396 {
397 auto msg = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..frontcxx . . $ std/deque#front(1c9784b1aa27a05e).().protectcxx . . $ mlspp/State#protect(ae39f86e951371d3).({cxx . . $ mlspp/bytes_ns/bytes#bytes(ced63f7c635d850d).}, plaintext, 0);
398 return tlscxx . . $ mlspp/bytes_ns/bytes#bytes(dd8c33c7e39dbe02).::marshalcxx . . $ mlspp/tls/marshal(7df0b13a9cabe487).(msg);
399 }
400
401 // TODO([email protected]): It would be good to expose identity information
402 // here, since ciphertexts are authenticated per sender. Who sent
403 // this ciphertext?
404 bytescxx . . $ mlspp/bytes_ns/bytes#
405 Sessioncxx . . $ mlspp/Session#::unprotectcxx . . $ mlspp/Session#unprotect(dfba7759a1cb6e97).(const bytescxx . . $ mlspp/bytes_ns/bytes#& ciphertext)
406 {
407 auto ciphertext_obj = tlscxx . . $ mlspp/tls/::getcxx . . $ mlspp/tls/get(fdfeec44f419faae).<MLSMessagecxx . . $ mlspp/MLSMessage#>(ciphertext);
408 auto& state = innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).for_epochcxx . . $ mlspp/Session#Inner#for_epoch(79c3df9b21666572).(ciphertext_obj.epochcxx . . $ mlspp/MLSMessage#epoch(fe4d2d262d4164a8).());
409 auto [aad, pt] = state.unprotectcxx . . $ mlspp/State#unprotect(2711fe3526d2deb9).(ciphertext_obj);
410 silence_unusedcxx . . $ mlspp/silence_unused(77d9f17553126ecb).(aad);
411 return ptcxx . . $ mlspp/bytes_ns/bytes#bytes(68ca607eebb5be3e).;
412 }
413
414 bool
415 operatorcxx . . $ mlspp/`operator==`(a380c757fead9107).==(const Sessioncxx . . $ mlspp/Session#& lhs, const Sessioncxx . . $ mlspp/Session#& rhs)
416 {
417 if (lhs.innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake. != rhs.innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).encrypt_handshakecxx . . $ mlspp/Session#Inner#encrypt_handshake.) {
418 return false;
419 }
420
421 auto size = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(lhs.innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..sizecxx . . $ std/deque#size(c9b1e749b64d5edc).(), rhs.innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..sizecxx . . $ std/deque#size(c9b1e749b64d5edc).());
422 for (size_t i = 0; i < size; i += 1) {
423 if (lhs.innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..atcxx . . $ std/deque#at(c07c1250c739abcb).(i) !=cxx . . $ mlspp/`operator!=`(f7ea92d64b4f5a4f). rhs.innercxx . . $ mlspp/Session#inner.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).historycxx . . $ mlspp/Session#Inner#history..atcxx . . $ std/deque#at(c07c1250c739abcb).(i)) {
424 return false;
425 }
426 }
427
428 return true;
429 }
430
431 bool
432 operatorcxx . . $ mlspp/`operator!=`(a380c757fead9107).!=(const Sessioncxx . . $ mlspp/Session#& lhs, const Sessioncxx . . $ mlspp/Session#& rhs)
433 {
434 return !(lhs ==cxx . . $ mlspp/`operator==`(a380c757fead9107). rhs);
435 }
436
437 } // namespace mlspp