Debian Codegraph @

mlspp/include/mls/key_schedule.h

raw symbols SCIP
1 #cxx . . $ `<file>/mlspp/include/mls/key_schedule.h`/pragma once
2
3 #include <map>
4 #include <mls/common.h>cxx . . $ `<file>/mlspp/include/mls/common.h`/
5 #include <mls/crypto.h>cxx . . $ `<file>/mlspp/include/mls/crypto.h`/
6 #include <mls/messages.h>cxx . . $ `<file>/mlspp/include/mls/messages.h`/
7 #include <mls/tree_math.h>cxx . . $ `<file>/mlspp/include/mls/tree_math.h`/
8
9 namespace mlsppcxx . . $ mlspp/ {
10
11 struct HashRatchetcxx . . $ mlspp/HashRatchet#
12 {
13 CipherSuitecxx . . $ mlspp/CipherSuite# suitecxx . . $ mlspp/HashRatchet#suite.;
14 bytescxx . . $ mlspp/bytes_ns/bytes# next_secretcxx . . $ mlspp/HashRatchet#next_secret.;
15 uint32_tcxx . . $ uint32_t# next_generationcxx . . $ mlspp/HashRatchet#next_generation.;
16 stdcxx . . $ std/::mapcxx . . $ std/map#<uint32_tcxx . . $ uint32_t#, KeyAndNoncecxx . . $ mlspp/KeyAndNonce#> cachecxx . . $ mlspp/HashRatchet#cache.;
17
18 size_t key_sizecxx . . $ mlspp/HashRatchet#key_size.;
19 size_t nonce_sizecxx . . $ mlspp/HashRatchet#nonce_size.;
20 size_t secret_sizecxx . . $ mlspp/HashRatchet#secret_size.;
21
22 // These defaults are necessary for use with containers
23 HashRatchetcxx . . $ mlspp/HashRatchet#HashRatchet(49f6e7a06ebc5aa8).() = default;
24 HashRatchetcxx . . $ mlspp/HashRatchet#HashRatchet(fc9c55f0a32f184c).(const HashRatchetcxx . . $ mlspp/HashRatchet#& other) = default;
25 HashRatchetcxx . . $ mlspp/HashRatchet#HashRatchet(786a9a5d1027a5fe).(HashRatchetcxx . . $ mlspp/HashRatchet#&& other) = default;
26 HashRatchetcxx . . $ mlspp/HashRatchet#& operatorcxx . . $ mlspp/HashRatchet#`operator=`(d0200823cf5ffd5e).=(const HashRatchetcxx . . $ mlspp/HashRatchet#& other) = default;
27 HashRatchetcxx . . $ mlspp/HashRatchet#& operatorcxx . . $ mlspp/HashRatchet#`operator=`(70fd287a47265d8a).=(HashRatchetcxx . . $ mlspp/HashRatchet#&& other) = default;
28
29 HashRatchetcxx . . $ mlspp/HashRatchet#HashRatchet(69bc69b11a84d9c3).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in, bytescxx . . $ mlspp/bytes_ns/bytes# base_secret_in);
30
31 stdcxx . . $ std/::tuplecxx . . $ std/tuple#<uint32_tcxx . . $ uint32_t#, KeyAndNoncecxx . . $ mlspp/KeyAndNonce#> nextcxx . . $ mlspp/HashRatchet#next(e4908337947e37ad).();
32 KeyAndNoncecxx . . $ mlspp/KeyAndNonce# getcxx . . $ mlspp/HashRatchet#get(6b3d961c32b85bc7).(uint32_tcxx . . $ uint32_t# generation);
33 void erasecxx . . $ mlspp/HashRatchet#erase(cb2f890c2fdad230).(uint32_tcxx . . $ uint32_t# generation);
34 };
35
36 struct SecretTreecxx . . $ mlspp/SecretTree#
37 {
38 SecretTreecxx . . $ mlspp/SecretTree#SecretTree(49f6e7a06ebc5aa8).() = default;
39 SecretTreecxx . . $ mlspp/SecretTree#SecretTree(b16addc4ae0f84c9).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
40 LeafCountcxx . . $ mlspp/LeafCount# group_size_in,
41 bytescxx . . $ mlspp/bytes_ns/bytes# encryption_secret_in);
42
43 bool has_leafcxx . . $ mlspp/SecretTree#has_leaf(5c30a2d8336e88c0).(LeafIndexcxx . . $ mlspp/LeafIndex# sender) { return sender <cxx . . $ mlspp/LeafIndex#`operator<`(6a6f1ee87d9a491e). group_sizecxx . . $ mlspp/SecretTree#group_size.; }
44
45 bytescxx . . $ mlspp/bytes_ns/bytes# getcxx . . $ mlspp/SecretTree#get(a1b9d39d51a01b86).(LeafIndexcxx . . $ mlspp/LeafIndex# sender);
46
47 private:
48 CipherSuitecxx . . $ mlspp/CipherSuite# suitecxx . . $ mlspp/SecretTree#suite.;
49 LeafCountcxx . . $ mlspp/LeafCount# group_sizecxx . . $ mlspp/SecretTree#group_size.;
50 NodeIndexcxx . . $ mlspp/NodeIndex# rootcxx . . $ mlspp/SecretTree#root.;
51 stdcxx . . $ std/::mapcxx . . $ std/map#<NodeIndexcxx . . $ mlspp/NodeIndex#, bytescxx . . $ mlspp/bytes_ns/bytes#> secretscxx . . $ mlspp/SecretTree#secrets.;
52 size_t secret_sizecxx . . $ mlspp/SecretTree#secret_size.;
53 };
54
55 using ReuseGuardcxx . . $ mlspp/ReuseGuard# = stdcxx . . $ std/::arraycxx . . $ std/array#<uint8_tcxx . . $ uint8_t#, 4>;
56
57 struct GroupKeySourcecxx . . $ mlspp/GroupKeySource#
58 {
59 enum struct RatchetTypecxx . . $ mlspp/GroupKeySource#RatchetType#
60 {
61 handshakecxx . . $ mlspp/GroupKeySource#RatchetType#handshake.,
62 applicationcxx . . $ mlspp/GroupKeySource#RatchetType#application.,
63 };
64
65 GroupKeySourcecxx . . $ mlspp/GroupKeySource#GroupKeySource(49f6e7a06ebc5aa8).() = default;
66 GroupKeySourcecxx . . $ mlspp/GroupKeySource#GroupKeySource(b16addc4ae0f84c9).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
67 LeafCountcxx . . $ mlspp/LeafCount# group_size,
68 bytescxx . . $ mlspp/bytes_ns/bytes# encryption_secret);
69
70 bool has_leafcxx . . $ mlspp/GroupKeySource#has_leaf(5c30a2d8336e88c0).(LeafIndexcxx . . $ mlspp/LeafIndex# sender) { return secret_treecxx . . $ mlspp/GroupKeySource#secret_tree..has_leafcxx . . $ mlspp/SecretTree#has_leaf(5c30a2d8336e88c0).(sender); }
71
72 stdcxx . . $ std/::tuplecxx . . $ std/tuple#<uint32_tcxx . . $ uint32_t#, ReuseGuardcxx . . $ mlspp/ReuseGuard#, KeyAndNoncecxx . . $ mlspp/KeyAndNonce#> nextcxx . . $ mlspp/GroupKeySource#next(93009b092b6559de).(ContentTypecxx . . $ mlspp/ContentType# content_type,
73 LeafIndexcxx . . $ mlspp/LeafIndex# sender);
74 KeyAndNoncecxx . . $ mlspp/KeyAndNonce# getcxx . . $ mlspp/GroupKeySource#get(b7daedcd7d3908ca).(ContentTypecxx . . $ mlspp/ContentType# content_type,
75 LeafIndexcxx . . $ mlspp/LeafIndex# sender,
76 uint32_tcxx . . $ uint32_t# generation,
77 ReuseGuardcxx . . $ mlspp/ReuseGuard# reuse_guard);
78 void erasecxx . . $ mlspp/GroupKeySource#erase(efc0287f6c9543eb).(ContentTypecxx . . $ mlspp/ContentType# type, LeafIndexcxx . . $ mlspp/LeafIndex# sender, uint32_tcxx . . $ uint32_t# generation);
79
80 private:
81 CipherSuitecxx . . $ mlspp/CipherSuite# suitecxx . . $ mlspp/GroupKeySource#suite.;
82 SecretTreecxx . . $ mlspp/SecretTree# secret_treecxx . . $ mlspp/GroupKeySource#secret_tree.;
83
84 using Keycxx . . $ mlspp/GroupKeySource#Key# = stdcxx . . $ std/::tuplecxx . . $ std/tuple#<RatchetTypecxx . . $ mlspp/GroupKeySource#RatchetType#, LeafIndexcxx . . $ mlspp/LeafIndex#>;
85 stdcxx . . $ std/::mapcxx . . $ std/map#<Keycxx . . $ mlspp/GroupKeySource#Key#, HashRatchetcxx . . $ mlspp/HashRatchet#> chainscxx . . $ mlspp/GroupKeySource#chains.;
86
87 HashRatchetcxx . . $ mlspp/HashRatchet#& chaincxx . . $ mlspp/GroupKeySource#chain(78835417b4c098a5).(RatchetTypecxx . . $ mlspp/GroupKeySource#RatchetType# type, LeafIndexcxx . . $ mlspp/LeafIndex# sender);
88 HashRatchetcxx . . $ mlspp/HashRatchet#& chaincxx . . $ mlspp/GroupKeySource#chain(459e588c614e4c15).(ContentTypecxx . . $ mlspp/ContentType# type, LeafIndexcxx . . $ mlspp/LeafIndex# sender);
89
90 static const stdcxx . . $ std/::arraycxx . . $ std/array#<RatchetTypecxx . . $ mlspp/GroupKeySource#RatchetType#, 2> all_ratchet_typescxx . . $ mlspp/GroupKeySource#all_ratchet_types.;
91 };
92
93 struct KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#
94 {
95 private:
96 CipherSuitecxx . . $ mlspp/CipherSuite# suitecxx . . $ mlspp/KeyScheduleEpoch#suite.;
97
98 public:
99 bytescxx . . $ mlspp/bytes_ns/bytes# joiner_secretcxx . . $ mlspp/KeyScheduleEpoch#joiner_secret.;
100 bytescxx . . $ mlspp/bytes_ns/bytes# epoch_secretcxx . . $ mlspp/KeyScheduleEpoch#epoch_secret.;
101
102 bytescxx . . $ mlspp/bytes_ns/bytes# sender_data_secretcxx . . $ mlspp/KeyScheduleEpoch#sender_data_secret.;
103 bytescxx . . $ mlspp/bytes_ns/bytes# encryption_secretcxx . . $ mlspp/KeyScheduleEpoch#encryption_secret.;
104 bytescxx . . $ mlspp/bytes_ns/bytes# exporter_secretcxx . . $ mlspp/KeyScheduleEpoch#exporter_secret.;
105 bytescxx . . $ mlspp/bytes_ns/bytes# epoch_authenticatorcxx . . $ mlspp/KeyScheduleEpoch#epoch_authenticator.;
106 bytescxx . . $ mlspp/bytes_ns/bytes# external_secretcxx . . $ mlspp/KeyScheduleEpoch#external_secret.;
107 bytescxx . . $ mlspp/bytes_ns/bytes# confirmation_keycxx . . $ mlspp/KeyScheduleEpoch#confirmation_key.;
108 bytescxx . . $ mlspp/bytes_ns/bytes# membership_keycxx . . $ mlspp/KeyScheduleEpoch#membership_key.;
109 bytescxx . . $ mlspp/bytes_ns/bytes# resumption_pskcxx . . $ mlspp/KeyScheduleEpoch#resumption_psk.;
110 bytescxx . . $ mlspp/bytes_ns/bytes# init_secretcxx . . $ mlspp/KeyScheduleEpoch#init_secret.;
111
112 HPKEPrivateKeycxx . . $ mlspp/HPKEPrivateKey# external_privcxx . . $ mlspp/KeyScheduleEpoch#external_priv.;
113
114 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#KeyScheduleEpoch(49f6e7a06ebc5aa8).() = default;
115
116 // Full initializer, used by invited joiner
117 static KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch# joinercxx . . $ mlspp/KeyScheduleEpoch#joiner(25b4bb31cd83193c).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
118 const bytescxx . . $ mlspp/bytes_ns/bytes#& joiner_secret,
119 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<PSKWithSecretcxx . . $ mlspp/PSKWithSecret#>& psks,
120 const bytescxx . . $ mlspp/bytes_ns/bytes#& context);
121
122 // Ciphersuite-only initializer, used by external joiner
123 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#KeyScheduleEpoch(1ae84ca71f879861).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in);
124
125 // Initial epoch
126 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#KeyScheduleEpoch(e9b6b1168c720405).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
127 const bytescxx . . $ mlspp/bytes_ns/bytes#& init_secret,
128 const bytescxx . . $ mlspp/bytes_ns/bytes#& context);
129
130 static stdcxx . . $ std/::tuplecxx . . $ std/tuple#<bytescxx . . $ mlspp/bytes_ns/bytes#, bytescxx . . $ mlspp/bytes_ns/bytes#> external_initcxx . . $ mlspp/KeyScheduleEpoch#external_init(d332d7d6e9cedbfc).(
131 CipherSuitecxx . . $ mlspp/CipherSuite# suite,
132 const HPKEPublicKeycxx . . $ mlspp/HPKEPublicKey#& external_pub);
133 bytescxx . . $ mlspp/bytes_ns/bytes# receive_external_initcxx . . $ mlspp/KeyScheduleEpoch#receive_external_init(c5e1b85e16e94921).(const bytescxx . . $ mlspp/bytes_ns/bytes#& kem_output) const;
134
135 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch# nextcxx . . $ mlspp/KeyScheduleEpoch#next(5d822d0102bcfbee).(const bytescxx . . $ mlspp/bytes_ns/bytes#& commit_secret,
136 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<PSKWithSecretcxx . . $ mlspp/PSKWithSecret#>& psks,
137 const stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#>& force_init_secret,
138 const bytescxx . . $ mlspp/bytes_ns/bytes#& context) const;
139
140 GroupKeySourcecxx . . $ mlspp/GroupKeySource# encryption_keyscxx . . $ mlspp/KeyScheduleEpoch#encryption_keys(578ffb7a4920202).(LeafCountcxx . . $ mlspp/LeafCount# size) const;
141 bytescxx . . $ mlspp/bytes_ns/bytes# confirmation_tagcxx . . $ mlspp/KeyScheduleEpoch#confirmation_tag(c5e1b85e16e94921).(const bytescxx . . $ mlspp/bytes_ns/bytes#& confirmed_transcript_hash) const;
142 bytescxx . . $ mlspp/bytes_ns/bytes# do_exportcxx . . $ mlspp/KeyScheduleEpoch#do_export(7012e37337977242).(const stdcxx . . $ std/::stringcxx . . $ std/string#& label,
143 const bytescxx . . $ mlspp/bytes_ns/bytes#& context,
144 size_t size) const;
145 PSKWithSecretcxx . . $ mlspp/PSKWithSecret# resumption_psk_w_secretcxx . . $ mlspp/KeyScheduleEpoch#resumption_psk_w_secret(1919b725acead621).(ResumptionPSKUsagecxx . . $ mlspp/ResumptionPSKUsage# usage,
146 const bytescxx . . $ mlspp/bytes_ns/bytes#& group_id,
147 epoch_tcxx . . $ mlspp/epoch_t# epoch);
148
149 static bytescxx . . $ mlspp/bytes_ns/bytes# make_psk_secretcxx . . $ mlspp/KeyScheduleEpoch#make_psk_secret(1d3bdec8dd887667).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
150 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<PSKWithSecretcxx . . $ mlspp/PSKWithSecret#>& psks);
151 static bytescxx . . $ mlspp/bytes_ns/bytes# welcome_secretcxx . . $ mlspp/KeyScheduleEpoch#welcome_secret(e5f3c7282c3439d1).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
152 const bytescxx . . $ mlspp/bytes_ns/bytes#& joiner_secret,
153 const stdcxx . . $ std/::vectorcxx . . $ std/vector#<PSKWithSecretcxx . . $ mlspp/PSKWithSecret#>& psks);
154 static KeyAndNoncecxx . . $ mlspp/KeyAndNonce# sender_data_keyscxx . . $ mlspp/KeyScheduleEpoch#sender_data_keys(65fe22caf18b2b69).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
155 const bytescxx . . $ mlspp/bytes_ns/bytes#& sender_data_secret,
156 const bytescxx . . $ mlspp/bytes_ns/bytes#& ciphertext);
157
158 // TODO(RLB) make these methods private, but accessible to test vectors
159 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#KeyScheduleEpoch(381fa99b4ceb7e56).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
160 const bytescxx . . $ mlspp/bytes_ns/bytes#& init_secret,
161 const bytescxx . . $ mlspp/bytes_ns/bytes#& commit_secret,
162 const bytescxx . . $ mlspp/bytes_ns/bytes#& psk_secret,
163 const bytescxx . . $ mlspp/bytes_ns/bytes#& context);
164 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch# next_rawcxx . . $ mlspp/KeyScheduleEpoch#next_raw(4425c67f05643958).(const bytescxx . . $ mlspp/bytes_ns/bytes#& commit_secret,
165 const bytescxx . . $ mlspp/bytes_ns/bytes#& psk_secret,
166 const stdcxx . . $ std/::optionalcxx . . $ std/optional#<bytescxx . . $ mlspp/bytes_ns/bytes#>& force_init_secret,
167 const bytescxx . . $ mlspp/bytes_ns/bytes#& context) const;
168 static bytescxx . . $ mlspp/bytes_ns/bytes# welcome_secret_rawcxx . . $ mlspp/KeyScheduleEpoch#welcome_secret_raw(e67fb899a8b6167f).(CipherSuitecxx . . $ mlspp/CipherSuite# suite,
169 const bytescxx . . $ mlspp/bytes_ns/bytes#& joiner_secret,
170 const bytescxx . . $ mlspp/bytes_ns/bytes#& psk_secret);
171
172 private:
173 KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#KeyScheduleEpoch(9ca0faf22fb2ce09).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
174 const bytescxx . . $ mlspp/bytes_ns/bytes#& joiner_secret,
175 const bytescxx . . $ mlspp/bytes_ns/bytes#& psk_secret,
176 const bytescxx . . $ mlspp/bytes_ns/bytes#& context);
177 };
178
179 bool
180 operatorcxx . . $ mlspp/`operator==`(9649cf35f662b0fb).==(const KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#& lhs, const KeyScheduleEpochcxx . . $ mlspp/KeyScheduleEpoch#& rhs);
181
182 struct TranscriptHashcxx . . $ mlspp/TranscriptHash#
183 {
184 CipherSuitecxx . . $ mlspp/CipherSuite# suitecxx . . $ mlspp/TranscriptHash#suite.;
185 bytescxx . . $ mlspp/bytes_ns/bytes# confirmedcxx . . $ mlspp/TranscriptHash#confirmed.;
186 bytescxx . . $ mlspp/bytes_ns/bytes# interimcxx . . $ mlspp/TranscriptHash#interim.;
187
188 // For a new group
189 TranscriptHashcxx . . $ mlspp/TranscriptHash#TranscriptHash(1ae84ca71f879861).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in);
190
191 // For joining a group
192 TranscriptHashcxx . . $ mlspp/TranscriptHash#TranscriptHash(7bb436d88e17613d).(CipherSuitecxx . . $ mlspp/CipherSuite# suite_in,
193 bytescxx . . $ mlspp/bytes_ns/bytes# confirmed_in,
194 const bytescxx . . $ mlspp/bytes_ns/bytes#& confirmation_tag);
195
196 void updatecxx . . $ mlspp/TranscriptHash#update(15c3fae94687094).(const AuthenticatedContentcxx . . $ mlspp/AuthenticatedContent#& content_auth);
197 void update_confirmedcxx . . $ mlspp/TranscriptHash#update_confirmed(15c3fae94687094).(const AuthenticatedContentcxx . . $ mlspp/AuthenticatedContent#& content_auth);
198 void update_interimcxx . . $ mlspp/TranscriptHash#update_interim(68ca607eebb5be3e).(const bytescxx . . $ mlspp/bytes_ns/bytes#& confirmation_tag);
199 void update_interimcxx . . $ mlspp/TranscriptHash#update_interim(15c3fae94687094).(const AuthenticatedContentcxx . . $ mlspp/AuthenticatedContent#& content_auth);
200 };
201
202 bool
203 operatorcxx . . $ mlspp/`operator==`(476a4c82fd602b31).==(const TranscriptHashcxx . . $ mlspp/TranscriptHash#& lhs, const TranscriptHashcxx . . $ mlspp/TranscriptHash#& rhs);
204
205 } // namespace mlspp