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

randombit / botan / 5587103969

18 Jul 2023 12:36PM UTC coverage: 91.691% (-0.06%) from 91.749%
5587103969

push

github

randombit
Merge GH #3622 Extend Credentials_Manager to support TLS 1.3 PSK

78319 of 85416 relevant lines covered (91.69%)

12316990.45 hits per line

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

41.67
/src/lib/tls/tls13/tls_psk_identity_13.cpp
1
/**
2
 * Wrapper type for a TLS 1.3 session ticket
3
 * (C) 2023 Jack Lloyd
4
 *     2023 René Meusel - Rohde & Schwarz Cybersecurity
5
 *
6
 * Botan is released under the Simplified BSD License (see license.txt)
7
 */
8

9
#include <botan/tls_psk_identity_13.h>
10

11
#include <botan/internal/stl_util.h>
12

13
namespace Botan::TLS {
14

15
namespace {
16

17
uint32_t obfuscate_ticket_age(const uint64_t in, const uint64_t ticket_age_add) {
82✔
18
   // RFC 8446 4.2.11.1
19
   //    The "obfuscated_ticket_age" field of each PskIdentity contains an
20
   //    obfuscated version of the ticket age formed by taking the age in
21
   //    milliseconds and adding the "ticket_age_add" value that was included
22
   //    with the ticket, modulo 2^32.
23
   return static_cast<uint32_t>(in + ticket_age_add);
82✔
24
}
25

26
}  // namespace
27

28
PskIdentity::PskIdentity(Opaque_Session_Handle identity,
82✔
29
                         const std::chrono::milliseconds age,
30
                         const uint32_t ticket_age_add) :
82✔
31
      PskIdentity(std::move(identity.get()), obfuscate_ticket_age(age.count(), ticket_age_add)) {}
82✔
32

33
PskIdentity::PskIdentity(PresharedKeyID identity) :
×
34
      m_identity(to_byte_vector(identity.get())),
×
35

36
      // RFC 8446 4.2.11
37
      //    For identities established externally, an obfuscated_ticket_age of
38
      //    0 SHOULD be used, and servers MUST ignore the value.
39
      m_obfuscated_age(0) {}
×
40

41
std::chrono::milliseconds PskIdentity::age(const uint32_t ticket_age_add) const {
×
42
   return std::chrono::milliseconds(obfuscate_ticket_age(m_obfuscated_age, ticket_age_add));
×
43
}
44

45
std::string PskIdentity::identity_as_string() const {
×
46
   return Botan::to_string(m_identity);
×
47
}
48

49
}  // namespace Botan::TLS
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

© 2025 Coveralls, Inc