Line data Source code
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_CONSTATE_H 24 : #define GNUTLS_LIB_CONSTATE_H 25 : 26 : int _gnutls_set_cipher_suite2(gnutls_session_t session, 27 : const gnutls_cipher_suite_entry_st *cs); 28 : 29 : int _gnutls_epoch_set_keys(gnutls_session_t session, uint16_t epoch, hs_stage_t stage); 30 : int _gnutls_connection_state_init(gnutls_session_t session); 31 : int _gnutls_read_connection_state_init(gnutls_session_t session); 32 : int _gnutls_write_connection_state_init(gnutls_session_t session); 33 : 34 : #define _gnutls_epoch_bump(session) \ 35 : (session)->security_parameters.epoch_next++ 36 : 37 : int _gnutls_epoch_dup(gnutls_session_t session, unsigned int epoch_rel); 38 : 39 : int _gnutls_epoch_get(gnutls_session_t session, unsigned int epoch_rel, 40 : record_parameters_st ** params_out); 41 : int _gnutls_epoch_setup_next(gnutls_session_t session, unsigned null_epoch, record_parameters_st **newp); 42 : void _gnutls_epoch_gc(gnutls_session_t session); 43 : void _gnutls_epoch_free(gnutls_session_t session, 44 : record_parameters_st * state); 45 : 46 : void _gnutls_set_resumed_parameters(gnutls_session_t session); 47 : 48 : int _tls13_connection_state_init(gnutls_session_t session, hs_stage_t stage); 49 : int _tls13_read_connection_state_init(gnutls_session_t session, hs_stage_t stage); 50 : int _tls13_write_connection_state_init(gnutls_session_t session, hs_stage_t stage); 51 : 52 11014 : static inline int _gnutls_epoch_is_valid(gnutls_session_t session, 53 : int epoch) 54 : { 55 11014 : record_parameters_st *params; 56 11014 : int ret; 57 : 58 11014 : ret = _gnutls_epoch_get(session, epoch, ¶ms); 59 11014 : if (ret < 0) 60 6 : return 0; 61 : 62 : return 1; 63 : } 64 : 65 : 66 97482 : static inline int _gnutls_epoch_refcount_inc(gnutls_session_t session, 67 : int epoch) 68 : { 69 97482 : record_parameters_st *params; 70 97482 : int ret; 71 : 72 97482 : ret = _gnutls_epoch_get(session, epoch, ¶ms); 73 97482 : if (ret < 0) 74 : return ret; 75 : 76 97482 : params->usage_cnt++; 77 : 78 97482 : return params->epoch; 79 : } 80 : 81 97053 : static inline int _gnutls_epoch_refcount_dec(gnutls_session_t session, 82 : uint16_t epoch) 83 : { 84 97053 : record_parameters_st *params; 85 97053 : int ret; 86 : 87 97053 : ret = _gnutls_epoch_get(session, epoch, ¶ms); 88 97053 : if (ret < 0) 89 : return ret; 90 : 91 97053 : params->usage_cnt--; 92 97053 : if (params->usage_cnt < 0) 93 0 : return GNUTLS_E_INTERNAL_ERROR; 94 : 95 : return 0; 96 : } 97 : 98 : #endif /* GNUTLS_LIB_CONSTATE_H */