Coverage Report

Created: 2022-06-23 06:44

/src/botan/build/include/botan/internal/tls_channel_impl.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
* TLS Channel
3
* (C) 2011,2012,2014,2015 Jack Lloyd
4
*     2016 Matthias Gierlings
5
*     2021 Elektrobit Automotive GmbH
6
*     2022 René Meusel, Hannes Rantzsch - neXenio GmbH
7
*
8
* Botan is released under the Simplified BSD License (see license.txt)
9
*/
10
11
#ifndef BOTAN_TLS_CHANNEL_IMPL_H_
12
#define BOTAN_TLS_CHANNEL_IMPL_H_
13
14
#include <botan/tls_channel.h>
15
#include <botan/tls_version.h>
16
#include <botan/tls_magic.h>
17
18
#include <vector>
19
#include <memory>
20
21
namespace Botan {
22
23
class Credentials_Manager;
24
class X509_Certificate;
25
26
namespace TLS {
27
28
class Channel_Impl
29
   {
30
   public:
31
5.96k
      virtual ~Channel_Impl() = default;
32
33
      /**
34
      * Inject TLS traffic received from counterparty
35
      * @return a hint as the how many more bytes we need to q the
36
      *         current record (this may be 0 if on a record boundary)
37
      */
38
      virtual size_t received_data(const uint8_t buf[], size_t buf_size) = 0;
39
40
      /**
41
      * Inject plaintext intended for counterparty
42
      * Throws an exception if is_active() is false
43
      */
44
      virtual void send(const uint8_t buf[], size_t buf_size) = 0;
45
46
      /**
47
      * Send a TLS alert message. If the alert is fatal, the internal
48
      * state (keys, etc) will be reset.
49
      * @param alert the Alert to send
50
      */
51
      virtual void send_alert(const Alert& alert) = 0;
52
53
      /**
54
      * Send a warning alert
55
      */
56
1.11k
      void send_warning_alert(Alert::Type type) { send_alert(Alert(type, false)); }
57
58
      /**
59
      * Send a fatal alert
60
      */
61
3.57k
      void send_fatal_alert(Alert::Type type) { send_alert(Alert(type, true)); }
62
63
      /**
64
      * Send a close notification alert
65
      */
66
0
      void close() { send_warning_alert(Alert::CLOSE_NOTIFY); }
67
68
      /**
69
      * @return true iff the connection is active for sending application data
70
      */
71
      virtual bool is_active() const = 0;
72
73
      /**
74
      * @return true iff the connection has been definitely closed
75
      */
76
      virtual bool is_closed() const = 0;
77
78
      /**
79
      * @return certificate chain of the peer (may be empty)
80
      */
81
      virtual std::vector<X509_Certificate> peer_cert_chain() const = 0;
82
83
      /**
84
      * Key material export (RFC 5705)
85
      * @param label a disambiguating label string
86
      * @param context a per-association context value
87
      * @param length the length of the desired key in bytes
88
      * @return key of length bytes
89
      */
90
      virtual SymmetricKey key_material_export(const std::string& label,
91
                                       const std::string& context,
92
                                       size_t length) const = 0;
93
94
      /**
95
      * Attempt to renegotiate the session
96
      * @param force_full_renegotiation if true, require a full renegotiation,
97
      * otherwise allow session resumption
98
      */
99
      virtual void renegotiate(bool force_full_renegotiation = false) = 0;
100
101
      /**
102
      * @return true iff the counterparty supports the secure
103
      * renegotiation extensions.
104
      */
105
      virtual bool secure_renegotiation_supported() const = 0;
106
107
      /**
108
      * Perform a handshake timeout check. This does nothing unless
109
      * this is a DTLS channel with a pending handshake state, in
110
      * which case we check for timeout and potentially retransmit
111
      * handshake packets.
112
      */
113
      virtual bool timeout_check() = 0;
114
115
      virtual std::string application_protocol() const = 0;
116
   };
117
118
}
119
120
}
121
122
#endif