/src/gnutls/lib/buffers.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2000-2012 Free Software Foundation, Inc. |
3 | | * |
4 | | * Author: Nikos Mavrogiannopoulos |
5 | | * |
6 | | * This file is part of GnuTLS. |
7 | | * |
8 | | * The GnuTLS is free software; you can redistribute it and/or |
9 | | * modify it under the terms of the GNU Lesser General Public License |
10 | | * as published by the Free Software Foundation; either version 2.1 of |
11 | | * the License, or (at your option) any later version. |
12 | | * |
13 | | * This library is distributed in the hope that it will be useful, but |
14 | | * WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * Lesser General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/> |
20 | | * |
21 | | */ |
22 | | |
23 | | #ifndef GNUTLS_LIB_BUFFERS_H |
24 | | #define GNUTLS_LIB_BUFFERS_H |
25 | | |
26 | | #include "mbuffers.h" |
27 | | |
28 | 0 | #define MBUFFER_FLUSH 1 |
29 | | |
30 | | void _gnutls_record_buffer_put(gnutls_session_t session, content_type_t type, |
31 | | uint64_t seq, mbuffer_st *bufel); |
32 | | |
33 | | inline static int _gnutls_record_buffer_get_size(gnutls_session_t session) |
34 | 0 | { |
35 | 0 | return session->internals.record_buffer.byte_length; |
36 | 0 | } Unexecuted instantiation: record.c:_gnutls_record_buffer_get_size Unexecuted instantiation: cipher.c:_gnutls_record_buffer_get_size Unexecuted instantiation: handshake-tls13.c:_gnutls_record_buffer_get_size Unexecuted instantiation: buffers.c:_gnutls_record_buffer_get_size Unexecuted instantiation: handshake.c:_gnutls_record_buffer_get_size Unexecuted instantiation: kx.c:_gnutls_record_buffer_get_size Unexecuted instantiation: session.c:_gnutls_record_buffer_get_size Unexecuted instantiation: sslv2_compat.c:_gnutls_record_buffer_get_size Unexecuted instantiation: constate.c:_gnutls_record_buffer_get_size Unexecuted instantiation: alert.c:_gnutls_record_buffer_get_size Unexecuted instantiation: state.c:_gnutls_record_buffer_get_size Unexecuted instantiation: cert-cred-x509.c:_gnutls_record_buffer_get_size Unexecuted instantiation: dtls.c:_gnutls_record_buffer_get_size Unexecuted instantiation: system_override.c:_gnutls_record_buffer_get_size Unexecuted instantiation: prf.c:_gnutls_record_buffer_get_size Unexecuted instantiation: handshake-checks.c:_gnutls_record_buffer_get_size Unexecuted instantiation: dtls-sw.c:_gnutls_record_buffer_get_size Unexecuted instantiation: ocsp-api.c:_gnutls_record_buffer_get_size Unexecuted instantiation: encrypted_extensions.c:_gnutls_record_buffer_get_size Unexecuted instantiation: certificate_request.c:_gnutls_record_buffer_get_size Unexecuted instantiation: certificate_verify.c:_gnutls_record_buffer_get_size Unexecuted instantiation: finished.c:_gnutls_record_buffer_get_size Unexecuted instantiation: key_update.c:_gnutls_record_buffer_get_size Unexecuted instantiation: hello_retry.c:_gnutls_record_buffer_get_size Unexecuted instantiation: session_ticket.c:_gnutls_record_buffer_get_size Unexecuted instantiation: certificate.c:_gnutls_record_buffer_get_size Unexecuted instantiation: early_data.c:_gnutls_record_buffer_get_size Unexecuted instantiation: post_handshake.c:_gnutls_record_buffer_get_size Unexecuted instantiation: heartbeat.c:_gnutls_record_buffer_get_size Unexecuted instantiation: key_share.c:_gnutls_record_buffer_get_size Unexecuted instantiation: pre_shared_key.c:_gnutls_record_buffer_get_size Unexecuted instantiation: status_request.c:_gnutls_record_buffer_get_size Unexecuted instantiation: supported_versions.c:_gnutls_record_buffer_get_size Unexecuted instantiation: cert.c:_gnutls_record_buffer_get_size Unexecuted instantiation: tls-sig.c:_gnutls_record_buffer_get_size |
37 | | |
38 | | #define NO_TIMEOUT_FUNC_SET(session) \ |
39 | 0 | unlikely(session->internals.pull_timeout_func == \ |
40 | 0 | gnutls_system_recv_timeout && \ |
41 | 0 | session->internals.pull_func != system_read) |
42 | | |
43 | | /*- |
44 | | * record_check_unprocessed: |
45 | | * @session: is a #gnutls_session_t structure. |
46 | | * |
47 | | * This function checks if there are unprocessed data |
48 | | * in the gnutls record buffers. Those data might not |
49 | | * be complete records. |
50 | | * |
51 | | * Returns: Returns the size of the data or zero. |
52 | | -*/ |
53 | | inline static size_t record_check_unprocessed(gnutls_session_t session) |
54 | 0 | { |
55 | 0 | return session->internals.record_recv_buffer.byte_length; |
56 | 0 | } Unexecuted instantiation: record.c:record_check_unprocessed Unexecuted instantiation: cipher.c:record_check_unprocessed Unexecuted instantiation: handshake-tls13.c:record_check_unprocessed Unexecuted instantiation: buffers.c:record_check_unprocessed Unexecuted instantiation: handshake.c:record_check_unprocessed Unexecuted instantiation: kx.c:record_check_unprocessed Unexecuted instantiation: session.c:record_check_unprocessed Unexecuted instantiation: sslv2_compat.c:record_check_unprocessed Unexecuted instantiation: constate.c:record_check_unprocessed Unexecuted instantiation: alert.c:record_check_unprocessed Unexecuted instantiation: state.c:record_check_unprocessed Unexecuted instantiation: cert-cred-x509.c:record_check_unprocessed Unexecuted instantiation: dtls.c:record_check_unprocessed Unexecuted instantiation: system_override.c:record_check_unprocessed Unexecuted instantiation: prf.c:record_check_unprocessed Unexecuted instantiation: handshake-checks.c:record_check_unprocessed Unexecuted instantiation: dtls-sw.c:record_check_unprocessed Unexecuted instantiation: ocsp-api.c:record_check_unprocessed Unexecuted instantiation: encrypted_extensions.c:record_check_unprocessed Unexecuted instantiation: certificate_request.c:record_check_unprocessed Unexecuted instantiation: certificate_verify.c:record_check_unprocessed Unexecuted instantiation: finished.c:record_check_unprocessed Unexecuted instantiation: key_update.c:record_check_unprocessed Unexecuted instantiation: hello_retry.c:record_check_unprocessed Unexecuted instantiation: session_ticket.c:record_check_unprocessed Unexecuted instantiation: certificate.c:record_check_unprocessed Unexecuted instantiation: early_data.c:record_check_unprocessed Unexecuted instantiation: post_handshake.c:record_check_unprocessed Unexecuted instantiation: heartbeat.c:record_check_unprocessed Unexecuted instantiation: key_share.c:record_check_unprocessed Unexecuted instantiation: pre_shared_key.c:record_check_unprocessed Unexecuted instantiation: status_request.c:record_check_unprocessed Unexecuted instantiation: supported_versions.c:record_check_unprocessed Unexecuted instantiation: cert.c:record_check_unprocessed Unexecuted instantiation: tls-sig.c:record_check_unprocessed |
57 | | |
58 | | int _gnutls_record_buffer_get(content_type_t type, gnutls_session_t session, |
59 | | uint8_t *data, size_t length, uint8_t seq[8]); |
60 | | int _gnutls_record_buffer_get_packet(content_type_t type, |
61 | | gnutls_session_t session, |
62 | | gnutls_packet_t *packet); |
63 | | ssize_t _gnutls_io_read_buffered(gnutls_session_t, size_t n, content_type_t, |
64 | | unsigned int *ms); |
65 | | int _gnutls_io_clear_peeked_data(gnutls_session_t session); |
66 | | |
67 | | ssize_t _gnutls_io_write_buffered(gnutls_session_t session, mbuffer_st *bufel, |
68 | | unsigned int mflag); |
69 | | |
70 | | int _gnutls_handshake_io_cache_int(gnutls_session_t, |
71 | | gnutls_handshake_description_t, |
72 | | mbuffer_st *bufel); |
73 | | |
74 | | ssize_t _gnutls_handshake_io_recv_int(gnutls_session_t session, |
75 | | gnutls_handshake_description_t htype, |
76 | | handshake_buffer_st *hsk, |
77 | | unsigned int optional); |
78 | | |
79 | | ssize_t _gnutls_io_write_flush(gnutls_session_t session); |
80 | | int _gnutls_io_check_recv(gnutls_session_t session, unsigned int ms); |
81 | | ssize_t _gnutls_handshake_io_write_flush(gnutls_session_t session); |
82 | | |
83 | | inline static void _gnutls_handshake_buffer_clear(handshake_buffer_st *hsk) |
84 | 0 | { |
85 | 0 | _gnutls_buffer_clear(&hsk->data); |
86 | 0 | hsk->htype = -1; |
87 | 0 | } Unexecuted instantiation: record.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: cipher.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: handshake-tls13.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: buffers.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: handshake.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: kx.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: session.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: sslv2_compat.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: constate.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: alert.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: state.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: cert-cred-x509.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: dtls.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: system_override.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: prf.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: handshake-checks.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: dtls-sw.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: ocsp-api.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: encrypted_extensions.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: certificate_request.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: certificate_verify.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: finished.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: key_update.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: hello_retry.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: session_ticket.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: certificate.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: early_data.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: post_handshake.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: heartbeat.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: key_share.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: pre_shared_key.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: status_request.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: supported_versions.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: cert.c:_gnutls_handshake_buffer_clear Unexecuted instantiation: tls-sig.c:_gnutls_handshake_buffer_clear |
88 | | |
89 | | inline static void _gnutls_handshake_buffer_init(handshake_buffer_st *hsk) |
90 | 0 | { |
91 | 0 | memset(hsk, 0, sizeof(*hsk)); |
92 | 0 | _gnutls_buffer_init(&hsk->data); |
93 | 0 | hsk->htype = -1; |
94 | 0 | } Unexecuted instantiation: record.c:_gnutls_handshake_buffer_init Unexecuted instantiation: cipher.c:_gnutls_handshake_buffer_init Unexecuted instantiation: handshake-tls13.c:_gnutls_handshake_buffer_init Unexecuted instantiation: buffers.c:_gnutls_handshake_buffer_init Unexecuted instantiation: handshake.c:_gnutls_handshake_buffer_init Unexecuted instantiation: kx.c:_gnutls_handshake_buffer_init Unexecuted instantiation: session.c:_gnutls_handshake_buffer_init Unexecuted instantiation: sslv2_compat.c:_gnutls_handshake_buffer_init Unexecuted instantiation: constate.c:_gnutls_handshake_buffer_init Unexecuted instantiation: alert.c:_gnutls_handshake_buffer_init Unexecuted instantiation: state.c:_gnutls_handshake_buffer_init Unexecuted instantiation: cert-cred-x509.c:_gnutls_handshake_buffer_init Unexecuted instantiation: dtls.c:_gnutls_handshake_buffer_init Unexecuted instantiation: system_override.c:_gnutls_handshake_buffer_init Unexecuted instantiation: prf.c:_gnutls_handshake_buffer_init Unexecuted instantiation: handshake-checks.c:_gnutls_handshake_buffer_init Unexecuted instantiation: dtls-sw.c:_gnutls_handshake_buffer_init Unexecuted instantiation: ocsp-api.c:_gnutls_handshake_buffer_init Unexecuted instantiation: encrypted_extensions.c:_gnutls_handshake_buffer_init Unexecuted instantiation: certificate_request.c:_gnutls_handshake_buffer_init Unexecuted instantiation: certificate_verify.c:_gnutls_handshake_buffer_init Unexecuted instantiation: finished.c:_gnutls_handshake_buffer_init Unexecuted instantiation: key_update.c:_gnutls_handshake_buffer_init Unexecuted instantiation: hello_retry.c:_gnutls_handshake_buffer_init Unexecuted instantiation: session_ticket.c:_gnutls_handshake_buffer_init Unexecuted instantiation: certificate.c:_gnutls_handshake_buffer_init Unexecuted instantiation: early_data.c:_gnutls_handshake_buffer_init Unexecuted instantiation: post_handshake.c:_gnutls_handshake_buffer_init Unexecuted instantiation: heartbeat.c:_gnutls_handshake_buffer_init Unexecuted instantiation: key_share.c:_gnutls_handshake_buffer_init Unexecuted instantiation: pre_shared_key.c:_gnutls_handshake_buffer_init Unexecuted instantiation: status_request.c:_gnutls_handshake_buffer_init Unexecuted instantiation: supported_versions.c:_gnutls_handshake_buffer_init Unexecuted instantiation: cert.c:_gnutls_handshake_buffer_init Unexecuted instantiation: tls-sig.c:_gnutls_handshake_buffer_init |
95 | | |
96 | | inline static void _gnutls_handshake_recv_buffer_clear(gnutls_session_t session) |
97 | 0 | { |
98 | 0 | int i; |
99 | 0 | for (i = 0; i < session->internals.handshake_recv_buffer_size; i++) |
100 | 0 | _gnutls_handshake_buffer_clear( |
101 | 0 | &session->internals.handshake_recv_buffer[i]); |
102 | 0 | session->internals.handshake_recv_buffer_size = 0; |
103 | 0 | _mbuffer_head_clear(&session->internals.handshake_header_recv_buffer); |
104 | 0 | } Unexecuted instantiation: record.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: cipher.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: handshake-tls13.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: buffers.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: handshake.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: kx.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: session.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: sslv2_compat.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: constate.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: alert.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: state.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: cert-cred-x509.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: dtls.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: system_override.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: prf.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: handshake-checks.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: dtls-sw.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: ocsp-api.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: encrypted_extensions.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: certificate_request.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: certificate_verify.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: finished.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: key_update.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: hello_retry.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: session_ticket.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: certificate.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: early_data.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: post_handshake.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: heartbeat.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: key_share.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: pre_shared_key.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: status_request.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: supported_versions.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: cert.c:_gnutls_handshake_recv_buffer_clear Unexecuted instantiation: tls-sig.c:_gnutls_handshake_recv_buffer_clear |
105 | | |
106 | | inline static void _gnutls_handshake_recv_buffer_init(gnutls_session_t session) |
107 | 0 | { |
108 | 0 | int i; |
109 | 0 | for (i = 0; i < MAX_HANDSHAKE_MSGS; i++) { |
110 | 0 | _gnutls_handshake_buffer_init( |
111 | 0 | &session->internals.handshake_recv_buffer[i]); |
112 | 0 | } |
113 | 0 | session->internals.handshake_recv_buffer_size = 0; |
114 | 0 | _mbuffer_head_init(&session->internals.handshake_header_recv_buffer); |
115 | 0 | } Unexecuted instantiation: record.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: cipher.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: handshake-tls13.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: buffers.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: handshake.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: kx.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: session.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: sslv2_compat.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: constate.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: alert.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: state.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: cert-cred-x509.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: dtls.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: system_override.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: prf.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: handshake-checks.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: dtls-sw.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: ocsp-api.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: encrypted_extensions.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: certificate_request.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: certificate_verify.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: finished.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: key_update.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: hello_retry.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: session_ticket.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: certificate.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: early_data.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: post_handshake.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: heartbeat.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: key_share.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: pre_shared_key.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: status_request.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: supported_versions.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: cert.c:_gnutls_handshake_recv_buffer_init Unexecuted instantiation: tls-sig.c:_gnutls_handshake_recv_buffer_init |
116 | | |
117 | | int _gnutls_parse_record_buffered_msgs(gnutls_session_t session); |
118 | | |
119 | | ssize_t _gnutls_recv_in_buffers(gnutls_session_t session, content_type_t type, |
120 | | gnutls_handshake_description_t htype, |
121 | | unsigned int ms); |
122 | | |
123 | | #define _gnutls_handshake_io_buffer_clear(session) \ |
124 | 0 | _mbuffer_head_clear(&session->internals.handshake_send_buffer); \ |
125 | 0 | _gnutls_handshake_recv_buffer_clear(session); |
126 | | |
127 | | #endif /* GNUTLS_LIB_BUFFERS_H */ |