change some parameters in the library to meet the needs of the website httpbin.org
Fork of MiniTLS-GPL by
tls/tls_record.h@5:95f70ebfe61f, 2015-02-06 (annotated)
- Committer:
- shiyilei
- Date:
- Fri Feb 06 06:17:33 2015 +0000
- Revision:
- 5:95f70ebfe61f
- Parent:
- 2:527a66d0a1a9
change some parameters in the library to meet the needs of httpbin.org
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MiniTLS | 2:527a66d0a1a9 | 1 | /* |
MiniTLS | 2:527a66d0a1a9 | 2 | MiniTLS - A super trimmed down TLS/SSL Library for embedded devices |
MiniTLS | 2:527a66d0a1a9 | 3 | Author: Donatien Garnier |
MiniTLS | 2:527a66d0a1a9 | 4 | Copyright (C) 2013-2014 AppNearMe Ltd |
MiniTLS | 2:527a66d0a1a9 | 5 | |
MiniTLS | 2:527a66d0a1a9 | 6 | This program is free software; you can redistribute it and/or |
MiniTLS | 2:527a66d0a1a9 | 7 | modify it under the terms of the GNU General Public License |
MiniTLS | 2:527a66d0a1a9 | 8 | as published by the Free Software Foundation; either version 2 |
MiniTLS | 2:527a66d0a1a9 | 9 | of the License, or (at your option) any later version. |
MiniTLS | 2:527a66d0a1a9 | 10 | |
MiniTLS | 2:527a66d0a1a9 | 11 | This program is distributed in the hope that it will be useful, |
MiniTLS | 2:527a66d0a1a9 | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
MiniTLS | 2:527a66d0a1a9 | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MiniTLS | 2:527a66d0a1a9 | 14 | GNU General Public License for more details. |
MiniTLS | 2:527a66d0a1a9 | 15 | |
MiniTLS | 2:527a66d0a1a9 | 16 | You should have received a copy of the GNU General Public License |
MiniTLS | 2:527a66d0a1a9 | 17 | along with this program; if not, write to the Free Software |
MiniTLS | 2:527a66d0a1a9 | 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
MiniTLS | 2:527a66d0a1a9 | 19 | *//** |
MiniTLS | 2:527a66d0a1a9 | 20 | * \file tls_record.h |
MiniTLS | 2:527a66d0a1a9 | 21 | * \copyright Copyright (c) AppNearMe Ltd 2013 |
MiniTLS | 2:527a66d0a1a9 | 22 | * \author Donatien Garnier |
MiniTLS | 2:527a66d0a1a9 | 23 | */ |
MiniTLS | 2:527a66d0a1a9 | 24 | |
MiniTLS | 2:527a66d0a1a9 | 25 | #ifndef TLS_RECORD_H_ |
MiniTLS | 2:527a66d0a1a9 | 26 | #define TLS_RECORD_H_ |
MiniTLS | 2:527a66d0a1a9 | 27 | |
MiniTLS | 2:527a66d0a1a9 | 28 | #ifdef __cplusplus |
MiniTLS | 2:527a66d0a1a9 | 29 | extern "C" { |
MiniTLS | 2:527a66d0a1a9 | 30 | #endif |
MiniTLS | 2:527a66d0a1a9 | 31 | |
MiniTLS | 2:527a66d0a1a9 | 32 | #include "core/fwk.h" |
MiniTLS | 2:527a66d0a1a9 | 33 | #include "inc/minitls_errors.h" |
MiniTLS | 2:527a66d0a1a9 | 34 | |
MiniTLS | 2:527a66d0a1a9 | 35 | #define TLS_DEFAULT_MAX_FRAGMENT_SIZE 18432 //(MAX 2^14 + 2048 = 18432) -- encrypted |
MiniTLS | 2:527a66d0a1a9 | 36 | |
MiniTLS | 2:527a66d0a1a9 | 37 | #define TLS_ENCRYPTION_MAX_OVERHEAD (20 + 256 + 16) //MAC + Max Padding + IV |
MiniTLS | 2:527a66d0a1a9 | 38 | |
MiniTLS | 2:527a66d0a1a9 | 39 | #include "tls_socket_defs.h" |
MiniTLS | 2:527a66d0a1a9 | 40 | |
MiniTLS | 2:527a66d0a1a9 | 41 | /* |
MiniTLS | 2:527a66d0a1a9 | 42 | * When a new session |
MiniTLS | 2:527a66d0a1a9 | 43 | begins, the record layer's connection state encryption, hash, and |
MiniTLS | 2:527a66d0a1a9 | 44 | compression algorithms are initialized to null. The current |
MiniTLS | 2:527a66d0a1a9 | 45 | connection state is used for renegotiation messages. |
MiniTLS | 2:527a66d0a1a9 | 46 | */ |
MiniTLS | 2:527a66d0a1a9 | 47 | minitls_err_t tls_record_init(tls_record_t* record, tls_socket_t* socket, uint8_t* buf, size_t buf_size); |
MiniTLS | 2:527a66d0a1a9 | 48 | |
MiniTLS | 2:527a66d0a1a9 | 49 | //Should be called after server hello message; |
MiniTLS | 2:527a66d0a1a9 | 50 | void tls_record_set_protocol_version(tls_record_t* record, uint8_t major, uint8_t minor); |
MiniTLS | 2:527a66d0a1a9 | 51 | void tls_record_get_protocol_version(tls_record_t* record, uint8_t* major, uint8_t* minor); |
MiniTLS | 2:527a66d0a1a9 | 52 | |
MiniTLS | 2:527a66d0a1a9 | 53 | minitls_err_t tls_record_change_cipher_spec(tls_record_t* record, bool tx_nrx); |
MiniTLS | 2:527a66d0a1a9 | 54 | |
MiniTLS | 2:527a66d0a1a9 | 55 | bool tls_record_is_secure(tls_record_t* record); |
MiniTLS | 2:527a66d0a1a9 | 56 | |
MiniTLS | 2:527a66d0a1a9 | 57 | //Read on message and process it |
MiniTLS | 2:527a66d0a1a9 | 58 | //TODO mutex this |
MiniTLS | 2:527a66d0a1a9 | 59 | minitls_err_t tls_record_connect(tls_record_t* record, const char* hostname, uint16_t port); |
MiniTLS | 2:527a66d0a1a9 | 60 | |
MiniTLS | 2:527a66d0a1a9 | 61 | minitls_err_t tls_record_process(tls_record_t* record); |
MiniTLS | 2:527a66d0a1a9 | 62 | minitls_err_t tls_record_send(tls_record_t* record, tls_content_type_t content_type, buffer_t* payload); |
MiniTLS | 2:527a66d0a1a9 | 63 | |
MiniTLS | 2:527a66d0a1a9 | 64 | //Keys will be copied in local buffer |
MiniTLS | 2:527a66d0a1a9 | 65 | minitls_err_t tls_record_set_keys(tls_record_t* record, tls_security_type_t security, const uint8_t* client_write_mac_key, |
MiniTLS | 2:527a66d0a1a9 | 66 | const uint8_t* server_write_mac_key, const uint8_t* client_write_cipher_key, const uint8_t* server_write_cipher_key); |
MiniTLS | 2:527a66d0a1a9 | 67 | |
MiniTLS | 2:527a66d0a1a9 | 68 | minitls_err_t tls_record_close(tls_record_t* record); |
MiniTLS | 2:527a66d0a1a9 | 69 | |
MiniTLS | 2:527a66d0a1a9 | 70 | minitls_err_t tls_record_set_read_timeout(tls_record_t* record, int timeout); |
MiniTLS | 2:527a66d0a1a9 | 71 | minitls_err_t tls_record_set_write_timeout(tls_record_t* record, int timeout); |
MiniTLS | 2:527a66d0a1a9 | 72 | |
MiniTLS | 2:527a66d0a1a9 | 73 | #ifdef __cplusplus |
MiniTLS | 2:527a66d0a1a9 | 74 | } |
MiniTLS | 2:527a66d0a1a9 | 75 | #endif |
MiniTLS | 2:527a66d0a1a9 | 76 | |
MiniTLS | 2:527a66d0a1a9 | 77 | #endif /* TLS_RECORD_H_ */ |