• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5079590438

25 May 2023 12:28PM UTC coverage: 92.228% (+0.5%) from 91.723%
5079590438

Pull #3502

github

Pull Request #3502: Apply clang-format to the codebase

75589 of 81959 relevant lines covered (92.23%)

12139530.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.15
/src/lib/tls/tls_session.cpp
1
/*
2
* TLS Session State
3
* (C) 2011-2012,2015,2019 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include <botan/tls_session.h>
9

10
#include <botan/aead.h>
11
#include <botan/asn1_obj.h>
12
#include <botan/ber_dec.h>
13
#include <botan/der_enc.h>
14
#include <botan/mac.h>
15
#include <botan/pem.h>
16
#include <botan/rng.h>
17
#include <botan/internal/loadstor.h>
18

19
#include <botan/tls_callbacks.h>
20
#include <botan/tls_messages.h>
21

22
#include <botan/internal/stl_util.h>
23

24
#include <utility>
25

26
namespace Botan::TLS {
27

28
void Session_Handle::validate_constraints() const {
3,436✔
29
   std::visit(overloaded{
6,872✔
30
                 [](const Session_ID& id) {
645✔
31
                    // RFC 5246 7.4.1.2
32
                    //    opaque SessionID<0..32>;
33
                    BOTAN_ARG_CHECK(!id.empty(), "Session ID must not be empty");
645✔
34
                    BOTAN_ARG_CHECK(id.size() <= 32, "Session ID cannot be longer than 32 bytes");
645✔
35
                 },
645✔
36
                 [](const Session_Ticket& ticket) {
2,113✔
37
                    BOTAN_ARG_CHECK(!ticket.empty(), "Ticket most not be empty");
2,113✔
38
                    BOTAN_ARG_CHECK(ticket.size() <= std::numeric_limits<uint16_t>::max(),
2,113✔
39
                                    "Ticket cannot be longer than 64kB");
40
                 },
2,113✔
41
                 [](const Opaque_Session_Handle& handle) {
678✔
42
                    // RFC 8446 4.6.1
43
                    //    opaque ticket<1..2^16-1>;
44
                    BOTAN_ARG_CHECK(!handle.empty(), "Opaque session handle must not be empty");
678✔
45
                    BOTAN_ARG_CHECK(handle.size() <= std::numeric_limits<uint16_t>::max(),
678✔
46
                                    "Opaque session handle cannot be longer than 64kB");
47
                 },
678✔
48
              },
49
              m_handle);
3,436✔
50
}
3,436✔
51

52
Opaque_Session_Handle Session_Handle::opaque_handle() const {
361✔
53
   // both a Session_ID and a Session_Ticket could be an Opaque_Session_Handle
54
   return Opaque_Session_Handle(std::visit([](const auto& handle) { return handle.get(); }, m_handle));
722✔
55
}
56

57
std::optional<Session_ID> Session_Handle::id() const {
2,385✔
58
   if(is_id()) {
2,385✔
59
      return std::get<Session_ID>(m_handle);
594✔
60
   }
61

62
   // Opaque handles can mimick as a Session_ID if they are short enough
63
   if(is_opaque_handle()) {
1,791✔
64
      const auto& handle = std::get<Opaque_Session_Handle>(m_handle);
670✔
65
      if(handle.size() <= 32) {
670✔
66
         return Session_ID(handle.get());
22✔
67
      }
68
   }
69

70
   return std::nullopt;
1,769✔
71
}
72

73
std::optional<Session_Ticket> Session_Handle::ticket() const {
1,701✔
74
   if(is_ticket()) {
1,701✔
75
      return std::get<Session_Ticket>(m_handle);
1,195✔
76
   }
77

78
   // Opaque handles can mimick 'normal' Session_Tickets at any time
79
   if(is_opaque_handle()) {
506✔
80
      return Session_Ticket(std::get<Opaque_Session_Handle>(m_handle).get());
216✔
81
   }
82

83
   return std::nullopt;
290✔
84
}
85

86
Ciphersuite Session_Base::ciphersuite() const {
4,788✔
87
   auto suite = Ciphersuite::by_id(m_ciphersuite);
4,788✔
88
   if(!suite.has_value()) {
4,788✔
89
      throw Decoding_Error("Failed to find cipher suite for ID " + std::to_string(m_ciphersuite));
×
90
   }
91
   return suite.value();
4,788✔
92
}
93

94
Session_Summary::Session_Summary(const Session_Base& base, bool was_resumption) : Session_Base(base) {
1,729✔
95
   BOTAN_ARG_CHECK(version().is_pre_tls_13(), "Instantiated a TLS 1.2 session summary with an newer TLS version");
1,729✔
96

97
   const auto cs = ciphersuite();
1,729✔
98
   m_psk_used = cs.psk_ciphersuite();
1,729✔
99
   m_kex_algo = cs.kex_algo();
1,729✔
100
   m_was_resumption = was_resumption;
1,729✔
101
}
1,729✔
102

103
#if defined(BOTAN_HAS_TLS_13)
104

105
Session_Summary::Session_Summary(const Server_Hello_13& server_hello,
587✔
106
                                 Connection_Side side,
107
                                 std::vector<X509_Certificate> peer_certs,
108
                                 Server_Information server_info,
109
                                 std::chrono::system_clock::time_point current_timestamp) :
587✔
110
      Session_Base(current_timestamp,
111
                   server_hello.selected_version(),
112
                   server_hello.ciphersuite(),
587✔
113
                   side,
114

115
                   // TODO: SRTP might become necessary when DTLS 1.3 is being implemented
116
                   0,
117

118
                   // RFC 8446 Appendix D
119
                   //    Because TLS 1.3 always hashes in the transcript up to the server
120
                   //    Finished, implementations which support both TLS 1.3 and earlier
121
                   //    versions SHOULD indicate the use of the Extended Master Secret
122
                   //    extension in their APIs whenever TLS 1.3 is used.
123
                   true,
124

125
                   // TLS 1.3 uses AEADs, so technically encrypt-then-MAC is not applicable.
126
                   false,
127
                   std::move(peer_certs),
587✔
128
                   std::move(server_info)) {
1,174✔
129
   BOTAN_ARG_CHECK(version().is_tls_13_or_later(), "Instantiated a TLS 1.3 session summary with an older TLS version");
587✔
130
   set_session_id(server_hello.session_id());
1,174✔
131

132
   // Currently, we use PSK exclusively for session resumption. Hence, a
133
   // server hello with a PSK extension indicates a session resumption.
134
   //
135
   // TODO: once manually configured PSKs are implemented, this will need
136
   //       extra consideration to tell PSK usage and resumption apart.
137
   m_psk_used = server_hello.extensions().has<PSK>();
587✔
138
   m_was_resumption = m_psk_used;
587✔
139

140
   // In TLS 1.3 the key exchange algorithm is not negotiated in the ciphersuite
141
   // anymore. This provides a compatible identifier for applications to use.
142
   m_kex_algo = kex_method_to_string([&] {
587✔
143
      if(m_psk_used) {
587✔
144
         if(const auto keyshare = server_hello.extensions().get<Key_Share>()) {
161✔
145
            const auto group = keyshare->selected_group();
161✔
146
            if(is_dh(group)) {
161✔
147
               return Kex_Algo::DHE_PSK;
148
            } else if(is_ecdh(group) || is_x25519(group)) {
161✔
149
               return Kex_Algo::ECDHE_PSK;
161✔
150
            }
151
         } else {
152
            return Kex_Algo::PSK;
153
         }
154
      } else {
155
         const auto keyshare = server_hello.extensions().get<Key_Share>();
426✔
156
         BOTAN_ASSERT_NONNULL(keyshare);
426✔
157
         const auto group = keyshare->selected_group();
426✔
158
         if(is_dh(group)) {
426✔
159
            return Kex_Algo::DH;
160
         } else if(is_ecdh(group) || is_x25519(group)) {
426✔
161
            return Kex_Algo::ECDH;
426✔
162
         }
163
      }
164

165
      return Kex_Algo::UNDEFINED;
166
   }());
587✔
167
}
587✔
168

169
#endif
170

171
Session::Session(const secure_vector<uint8_t>& master_secret,
1,607✔
172
                 Protocol_Version version,
173
                 uint16_t ciphersuite,
174
                 Connection_Side side,
175
                 bool extended_master_secret,
176
                 bool encrypt_then_mac,
177
                 const std::vector<X509_Certificate>& certs,
178
                 const Server_Information& server_info,
179
                 uint16_t srtp_profile,
180
                 std::chrono::system_clock::time_point current_timestamp,
181
                 std::chrono::seconds lifetime_hint) :
1,607✔
182
      Session_Base(current_timestamp,
183
                   version,
184
                   ciphersuite,
185
                   side,
186
                   srtp_profile,
187
                   extended_master_secret,
188
                   encrypt_then_mac,
189
                   certs,
190
                   server_info),
191
      m_master_secret(master_secret),
1,607✔
192
      m_early_data_allowed(false),
1,607✔
193
      m_max_early_data_bytes(0),
1,607✔
194
      m_ticket_age_add(0),
1,607✔
195
      m_lifetime_hint(lifetime_hint) {
1,607✔
196
   BOTAN_ARG_CHECK(version.is_pre_tls_13(), "Instantiated a TLS 1.2 session object with a TLS version newer than 1.2");
1,607✔
197
}
1,607✔
198

199
#if defined(BOTAN_HAS_TLS_13)
200

201
Session::Session(const secure_vector<uint8_t>& session_psk,
566✔
202
                 const std::optional<uint32_t>& max_early_data_bytes,
203
                 uint32_t ticket_age_add,
204
                 std::chrono::seconds lifetime_hint,
205
                 Protocol_Version version,
206
                 uint16_t ciphersuite,
207
                 Connection_Side side,
208
                 const std::vector<X509_Certificate>& peer_certs,
209
                 const Server_Information& server_info,
210
                 std::chrono::system_clock::time_point current_timestamp) :
566✔
211
      Session_Base(current_timestamp,
212
                   version,
213
                   ciphersuite,
214
                   side,
215

216
                   // TODO: SRTP might become necessary when DTLS 1.3 is being implemented
217
                   0,
218

219
                   // RFC 8446 Appendix D
220
                   //    Because TLS 1.3 always hashes in the transcript up to the server
221
                   //    Finished, implementations which support both TLS 1.3 and earlier
222
                   //    versions SHOULD indicate the use of the Extended Master Secret
223
                   //    extension in their APIs whenever TLS 1.3 is used.
224
                   true,
225

226
                   // TLS 1.3 uses AEADs, so technically encrypt-then-MAC is not applicable.
227
                   false,
228
                   peer_certs,
229
                   server_info),
230
      m_master_secret(session_psk),
566✔
231
      m_early_data_allowed(max_early_data_bytes.has_value()),
566✔
232
      m_max_early_data_bytes(max_early_data_bytes.value_or(0)),
566✔
233
      m_ticket_age_add(ticket_age_add),
566✔
234
      m_lifetime_hint(lifetime_hint) {
566✔
235
   BOTAN_ARG_CHECK(!version.is_pre_tls_13(), "Instantiated a TLS 1.3 session object with a TLS version older than 1.3");
566✔
236
}
566✔
237

238
Session::Session(secure_vector<uint8_t>&& session_psk,
275✔
239
                 const std::optional<uint32_t>& max_early_data_bytes,
240
                 std::chrono::seconds lifetime_hint,
241
                 const std::vector<X509_Certificate>& peer_certs,
242
                 const Client_Hello_13& client_hello,
243
                 const Server_Hello_13& server_hello,
244
                 Callbacks& callbacks,
245
                 RandomNumberGenerator& rng) :
275✔
246
      Session_Base(callbacks.tls_current_timestamp(),
275✔
247
                   server_hello.selected_version(),
248
                   server_hello.ciphersuite(),
275✔
249
                   Connection_Side::Server,
250
                   0,
251
                   true,
252
                   false,  // see constructor above for rationales
253
                   peer_certs,
254
                   Server_Information(client_hello.sni_hostname())),
550✔
255
      m_master_secret(std::move(session_psk)),
275✔
256
      m_early_data_allowed(max_early_data_bytes.has_value()),
275✔
257
      m_max_early_data_bytes(max_early_data_bytes.value_or(0)),
275✔
258
      m_ticket_age_add(load_be<uint32_t>(rng.random_vec(4).data(), 0)),
275✔
259
      m_lifetime_hint(lifetime_hint) {
825✔
260
   BOTAN_ARG_CHECK(!m_version.is_pre_tls_13(),
275✔
261
                   "Instantiated a TLS 1.3 session object with a TLS version older than 1.3");
262
}
275✔
263

264
#endif
265

266
Session::Session(std::string_view pem) : Session(PEM_Code::decode_check_label(pem, "TLS SESSION")) {}
3✔
267

268
Session::Session(std::span<const uint8_t> ber_data) {
455✔
269
   uint8_t side_code = 0;
455✔
270

271
   ASN1_String server_hostname;
455✔
272
   ASN1_String server_service;
455✔
273
   size_t server_port;
455✔
274

275
   uint8_t major_version = 0, minor_version = 0;
455✔
276

277
   size_t start_time = 0;
455✔
278
   size_t srtp_profile = 0;
455✔
279
   uint16_t ciphersuite_code = 0;
455✔
280
   uint64_t lifetime_hint = 0;
455✔
281

282
   BER_Decoder(ber_data.data(), ber_data.size())
455✔
283
      .start_sequence()
910✔
284
      .decode_and_check(static_cast<size_t>(TLS_SESSION_PARAM_STRUCT_VERSION),
910✔
285
                        "Unknown version in serialized TLS session")
286
      .decode_integer_type(start_time)
455✔
287
      .decode_integer_type(major_version)
455✔
288
      .decode_integer_type(minor_version)
455✔
289
      .decode_integer_type(ciphersuite_code)
455✔
290
      .decode_integer_type(side_code)
455✔
291
      .decode(m_extended_master_secret)
455✔
292
      .decode(m_encrypt_then_mac)
455✔
293
      .decode(m_master_secret, ASN1_Type::OctetString)
455✔
294
      .decode_list<X509_Certificate>(m_peer_certs)
455✔
295
      .decode(server_hostname)
455✔
296
      .decode(server_service)
455✔
297
      .decode(server_port)
455✔
298
      .decode(srtp_profile)
455✔
299
      .decode(m_early_data_allowed)
455✔
300
      .decode_integer_type(m_max_early_data_bytes)
455✔
301
      .decode_integer_type(m_ticket_age_add)
455✔
302
      .decode_integer_type(lifetime_hint)
455✔
303
      .end_cons()
455✔
304
      .verify_end();
455✔
305

306
   if(!Ciphersuite::by_id(ciphersuite_code)) {
455✔
307
      throw Decoding_Error(
1✔
308
         "Serialized TLS session contains unknown cipher suite "
309
         "(" +
2✔
310
         std::to_string(ciphersuite_code) + ")");
4✔
311
   }
312

313
   m_ciphersuite = ciphersuite_code;
454✔
314
   m_version = Protocol_Version(major_version, minor_version);
454✔
315
   m_start_time = std::chrono::system_clock::from_time_t(start_time);
454✔
316
   m_connection_side = static_cast<Connection_Side>(side_code);
454✔
317
   m_srtp_profile = static_cast<uint16_t>(srtp_profile);
454✔
318

319
   m_server_info =
454✔
320
      Server_Information(server_hostname.value(), server_service.value(), static_cast<uint16_t>(server_port));
908✔
321

322
   m_lifetime_hint = std::chrono::seconds(lifetime_hint);
454✔
323
}
458✔
324

325
secure_vector<uint8_t> Session::DER_encode() const {
1,118✔
326
   return DER_Encoder()
1,118✔
327
      .start_sequence()
1,118✔
328
      .encode(static_cast<size_t>(TLS_SESSION_PARAM_STRUCT_VERSION))
1,118✔
329
      .encode(static_cast<size_t>(std::chrono::system_clock::to_time_t(m_start_time)))
1,118✔
330
      .encode(static_cast<size_t>(m_version.major_version()))
1,118✔
331
      .encode(static_cast<size_t>(m_version.minor_version()))
1,118✔
332
      .encode(static_cast<size_t>(m_ciphersuite))
1,118✔
333
      .encode(static_cast<size_t>(m_connection_side))
1,118✔
334
      .encode(m_extended_master_secret)
1,118✔
335
      .encode(m_encrypt_then_mac)
1,118✔
336
      .encode(m_master_secret, ASN1_Type::OctetString)
1,118✔
337
      .start_sequence()
1,482✔
338
      .encode_list(m_peer_certs)
1,118✔
339
      .end_cons()
1,118✔
340
      .encode(ASN1_String(m_server_info.hostname(), ASN1_Type::Utf8String))
3,598✔
341
      .encode(ASN1_String(m_server_info.service(), ASN1_Type::Utf8String))
3,354✔
342
      .encode(static_cast<size_t>(m_server_info.port()))
1,118✔
343
      .encode(static_cast<size_t>(m_srtp_profile))
1,118✔
344

345
      // the fields below were introduced for TLS 1.3 session tickets
346
      .encode(m_early_data_allowed)
1,118✔
347
      .encode(static_cast<size_t>(m_max_early_data_bytes))
1,118✔
348
      .encode(static_cast<size_t>(m_ticket_age_add))
1,118✔
349
      .encode(static_cast<size_t>(m_lifetime_hint.count()))
1,118✔
350
      .end_cons()
1,118✔
351
      .get_contents();
2,236✔
352
}
353

354
std::string Session::PEM_encode() const { return PEM_Code::encode(this->DER_encode(), "TLS SESSION"); }
6✔
355

356
secure_vector<uint8_t> Session::extract_master_secret() {
177✔
357
   BOTAN_STATE_CHECK(!m_master_secret.empty());
177✔
358
   return std::exchange(m_master_secret, {});
177✔
359
}
360

361
namespace {
362

363
// The output length of the HMAC must be a valid keylength for the AEAD
364
const char* const TLS_SESSION_CRYPT_HMAC = "HMAC(SHA-512-256)";
365
// SIV would be better, but we can't assume it is available
366
const char* const TLS_SESSION_CRYPT_AEAD = "AES-256/GCM";
367
const char* const TLS_SESSION_CRYPT_KEY_NAME = "BOTAN TLS SESSION KEY NAME";
368
const uint64_t TLS_SESSION_CRYPT_MAGIC = 0x068B5A9D396C0000;
369
const size_t TLS_SESSION_CRYPT_MAGIC_LEN = 8;
370
const size_t TLS_SESSION_CRYPT_KEY_NAME_LEN = 4;
371
const size_t TLS_SESSION_CRYPT_AEAD_NONCE_LEN = 12;
372
const size_t TLS_SESSION_CRYPT_AEAD_KEY_SEED_LEN = 16;
373
const size_t TLS_SESSION_CRYPT_AEAD_TAG_SIZE = 16;
374

375
const size_t TLS_SESSION_CRYPT_HDR_LEN = TLS_SESSION_CRYPT_MAGIC_LEN + TLS_SESSION_CRYPT_KEY_NAME_LEN +
376
                                         TLS_SESSION_CRYPT_AEAD_NONCE_LEN + TLS_SESSION_CRYPT_AEAD_KEY_SEED_LEN;
377

378
const size_t TLS_SESSION_CRYPT_OVERHEAD = TLS_SESSION_CRYPT_HDR_LEN + TLS_SESSION_CRYPT_AEAD_TAG_SIZE;
379

380
}
381

382
std::vector<uint8_t> Session::encrypt(const SymmetricKey& key, RandomNumberGenerator& rng) const {
1,110✔
383
   auto hmac = MessageAuthenticationCode::create_or_throw(TLS_SESSION_CRYPT_HMAC);
1,110✔
384
   hmac->set_key(key);
1,110✔
385

386
   // First derive the "key name"
387
   std::vector<uint8_t> key_name(hmac->output_length());
1,110✔
388
   hmac->update(TLS_SESSION_CRYPT_KEY_NAME);
1,110✔
389
   hmac->final(key_name.data());
1,110✔
390
   key_name.resize(TLS_SESSION_CRYPT_KEY_NAME_LEN);
1,110✔
391

392
   std::vector<uint8_t> aead_nonce;
1,110✔
393
   std::vector<uint8_t> key_seed;
1,110✔
394

395
   rng.random_vec(aead_nonce, TLS_SESSION_CRYPT_AEAD_NONCE_LEN);
1,110✔
396
   rng.random_vec(key_seed, TLS_SESSION_CRYPT_AEAD_KEY_SEED_LEN);
1,110✔
397

398
   hmac->update(key_seed);
1,110✔
399
   const secure_vector<uint8_t> aead_key = hmac->final();
1,110✔
400

401
   secure_vector<uint8_t> bits = this->DER_encode();
1,110✔
402

403
   // create the header
404
   std::vector<uint8_t> buf;
1,110✔
405
   buf.reserve(TLS_SESSION_CRYPT_OVERHEAD + bits.size());
1,110✔
406
   buf.resize(TLS_SESSION_CRYPT_MAGIC_LEN);
1,110✔
407
   store_be(TLS_SESSION_CRYPT_MAGIC, &buf[0]);
1,110✔
408
   buf += key_name;
1,110✔
409
   buf += key_seed;
1,110✔
410
   buf += aead_nonce;
1,110✔
411

412
   auto aead = AEAD_Mode::create_or_throw(TLS_SESSION_CRYPT_AEAD, Cipher_Dir::Encryption);
1,110✔
413
   BOTAN_ASSERT_NOMSG(aead->valid_nonce_length(TLS_SESSION_CRYPT_AEAD_NONCE_LEN));
1,110✔
414
   BOTAN_ASSERT_NOMSG(aead->tag_size() == TLS_SESSION_CRYPT_AEAD_TAG_SIZE);
1,110✔
415
   aead->set_key(aead_key);
1,110✔
416
   aead->set_associated_data(buf);
1,110✔
417
   aead->start(aead_nonce);
1,110✔
418
   aead->finish(bits, 0);
1,110✔
419

420
   // append the ciphertext
421
   buf += bits;
1,110✔
422
   return buf;
1,110✔
423
}
7,770✔
424

425
Session Session::decrypt(std::span<const uint8_t> in, const SymmetricKey& key) {
456✔
426
   try {
456✔
427
      const size_t min_session_size = 48 + 4;  // serious under-estimate
456✔
428
      if(in.size() < TLS_SESSION_CRYPT_OVERHEAD + min_session_size)
456✔
429
         throw Decoding_Error("Encrypted session too short to be valid");
3✔
430

431
      // TODO: replace those raw pointers with sub-spans into `in`
432
      const uint8_t* magic = in.data();
453✔
433
      const uint8_t* key_name = magic + TLS_SESSION_CRYPT_MAGIC_LEN;
453✔
434
      const uint8_t* key_seed = key_name + TLS_SESSION_CRYPT_KEY_NAME_LEN;
453✔
435
      const uint8_t* aead_nonce = key_seed + TLS_SESSION_CRYPT_AEAD_KEY_SEED_LEN;
453✔
436
      const uint8_t* ctext = aead_nonce + TLS_SESSION_CRYPT_AEAD_NONCE_LEN;
453✔
437
      const size_t ctext_len = in.size() - TLS_SESSION_CRYPT_HDR_LEN;  // includes the tag
453✔
438

439
      if(load_be<uint64_t>(magic, 0) != TLS_SESSION_CRYPT_MAGIC)
453✔
440
         throw Decoding_Error("Missing expected magic numbers");
×
441

442
      auto hmac = MessageAuthenticationCode::create_or_throw(TLS_SESSION_CRYPT_HMAC);
453✔
443
      hmac->set_key(key);
453✔
444

445
      // First derive and check the "key name"
446
      std::vector<uint8_t> cmp_key_name(hmac->output_length());
457✔
447
      hmac->update(TLS_SESSION_CRYPT_KEY_NAME);
453✔
448
      hmac->final(cmp_key_name.data());
453✔
449

450
      if(same_mem(cmp_key_name.data(), key_name, TLS_SESSION_CRYPT_KEY_NAME_LEN) == false)
906✔
451
         throw Decoding_Error("Wrong key name for encrypted session");
1✔
452

453
      hmac->update(key_seed, TLS_SESSION_CRYPT_AEAD_KEY_SEED_LEN);
452✔
454
      const secure_vector<uint8_t> aead_key = hmac->final();
452✔
455

456
      auto aead = AEAD_Mode::create_or_throw(TLS_SESSION_CRYPT_AEAD, Cipher_Dir::Decryption);
455✔
457
      aead->set_key(aead_key);
452✔
458
      aead->set_associated_data(in.data(), TLS_SESSION_CRYPT_HDR_LEN);
452✔
459
      aead->start(aead_nonce, TLS_SESSION_CRYPT_AEAD_NONCE_LEN);
452✔
460
      secure_vector<uint8_t> buf(ctext, ctext + ctext_len);
455✔
461
      aead->finish(buf, 0);
452✔
462
      return Session(buf);
452✔
463
   } catch(std::exception& e) {
2,265✔
464
      throw Decoding_Error("Failed to decrypt serialized TLS session: " + std::string(e.what()));
14✔
465
   }
7✔
466
}
467

468
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc