2 * Copyright (C) 2000-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
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.
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.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #ifndef GNUTLS_RECORD_H
24 #define GNUTLS_RECORD_H
26 #include <gnutls/gnutls.h>
27 #include <gnutls_buffers.h>
28 #include <gnutls_constate.h>
30 ssize_t _gnutls_send_tlen_int(gnutls_session_t session,
32 gnutls_handshake_description_t htype,
33 unsigned int epoch_rel, const void *data,
34 size_t sizeofdata, size_t min_pad,
38 _gnutls_send_int(gnutls_session_t session, content_type_t type,
39 gnutls_handshake_description_t htype,
40 unsigned int epoch_rel, const void *_data,
41 size_t data_size, unsigned int mflags)
43 return _gnutls_send_tlen_int(session, type, htype, epoch_rel,
44 _data, data_size, 0, mflags);
47 ssize_t _gnutls_recv_int(gnutls_session_t session, content_type_t type,
48 gnutls_handshake_description_t,
49 gnutls_packet_t *packet,
51 size_t sizeofdata, void *seq, unsigned int ms);
53 inline static unsigned max_record_recv_size(gnutls_session_t session)
57 size = MAX_CIPHER_BLOCK_SIZE /*iv*/ + MAX_PAD_SIZE + MAX_HASH_SIZE/*MAC*/;
59 if (gnutls_compression_get(session)!=GNUTLS_COMP_NULL || session->internals.priorities.allow_large_records != 0)
60 size += EXTRA_COMP_SIZE;
62 size += session->security_parameters.max_record_recv_size + RECORD_HEADER_SIZE(session);
67 inline static unsigned max_decrypted_size(gnutls_session_t session)
71 if (session->internals.priorities.allow_large_records != 0)
72 size += EXTRA_COMP_SIZE;
74 size += session->security_parameters.max_record_recv_size;
79 /* Returns the headers + any IV that the ciphersuite
82 unsigned int get_total_headers(gnutls_session_t session)
85 record_parameters_st *params;
86 unsigned total = RECORD_HEADER_SIZE(session);
88 ret = _gnutls_epoch_get(session, EPOCH_WRITE_CURRENT, ¶ms);
93 return total + _gnutls_cipher_get_explicit_iv_size(params->cipher);
97 unsigned int get_total_headers2(gnutls_session_t session, record_parameters_st *params)
99 unsigned total = RECORD_HEADER_SIZE(session);
101 return total + _gnutls_cipher_get_explicit_iv_size(params->cipher);