Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MiniTLS-GPL by
tls_record.h
00001 /* 00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices 00003 Author: Donatien Garnier 00004 Copyright (C) 2013-2014 AppNearMe Ltd 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 *//** 00020 * \file tls_record.h 00021 * \copyright Copyright (c) AppNearMe Ltd 2013 00022 * \author Donatien Garnier 00023 */ 00024 00025 #ifndef TLS_RECORD_H_ 00026 #define TLS_RECORD_H_ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #include "core/fwk.h" 00033 #include "inc/minitls_errors.h" 00034 00035 #define TLS_DEFAULT_MAX_FRAGMENT_SIZE 18432 //(MAX 2^14 + 2048 = 18432) -- encrypted 00036 00037 #define TLS_ENCRYPTION_MAX_OVERHEAD (20 + 256 + 16) //MAC + Max Padding + IV 00038 00039 #include "tls_socket_defs.h" 00040 00041 /* 00042 * When a new session 00043 begins, the record layer's connection state encryption, hash, and 00044 compression algorithms are initialized to null. The current 00045 connection state is used for renegotiation messages. 00046 */ 00047 minitls_err_t tls_record_init(tls_record_t* record, tls_socket_t* socket, uint8_t* buf, size_t buf_size); 00048 00049 //Should be called after server hello message; 00050 void tls_record_set_protocol_version(tls_record_t* record, uint8_t major, uint8_t minor); 00051 void tls_record_get_protocol_version(tls_record_t* record, uint8_t* major, uint8_t* minor); 00052 00053 minitls_err_t tls_record_change_cipher_spec(tls_record_t* record, bool tx_nrx); 00054 00055 bool tls_record_is_secure(tls_record_t* record); 00056 00057 //Read on message and process it 00058 //TODO mutex this 00059 minitls_err_t tls_record_connect(tls_record_t* record, const char* hostname, uint16_t port); 00060 00061 minitls_err_t tls_record_process(tls_record_t* record); 00062 minitls_err_t tls_record_send(tls_record_t* record, tls_content_type_t content_type, buffer_t* payload); 00063 00064 //Keys will be copied in local buffer 00065 minitls_err_t tls_record_set_keys(tls_record_t* record, tls_security_type_t security, const uint8_t* client_write_mac_key, 00066 const uint8_t* server_write_mac_key, const uint8_t* client_write_cipher_key, const uint8_t* server_write_cipher_key); 00067 00068 minitls_err_t tls_record_close(tls_record_t* record); 00069 00070 minitls_err_t tls_record_set_read_timeout(tls_record_t* record, int timeout); 00071 minitls_err_t tls_record_set_write_timeout(tls_record_t* record, int timeout); 00072 00073 #ifdef __cplusplus 00074 } 00075 #endif 00076 00077 #endif /* TLS_RECORD_H_ */
Generated on Tue Jul 12 2022 19:20:10 by
1.7.2
