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.
Dependents: MiniTLS-HTTPS-Example
tls_protocol.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_protocol.h 00021 * \copyright Copyright (c) AppNearMe Ltd 2013 00022 * \author Donatien Garnier 00023 */ 00024 00025 #ifndef TLS_PROTOCOL_H_ 00026 #define TLS_PROTOCOL_H_ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #include "core/fwk.h" 00033 00034 //See rfc5246 and rfc4492 00035 00036 00037 typedef struct __tls_plaintext 00038 { 00039 tls_content_type_t type; 00040 tls_protocol_version_t version; 00041 uint16_t length; //(MAX 2^14 = 16384) 00042 //uint8_t* fragment; //(plaintext) 00043 } tls_plaintext_t; 00044 00045 typedef struct __tls_ciphertext 00046 { 00047 tls_content_type_t type; 00048 tls_protocol_version_t version; 00049 uint16_t length; ////(MAX 2^14 + 2048 = 18432) 00050 /* 00051 select (SecurityParameters.cipher_type) { 00052 case stream: GenericStreamCipher; 00053 case block: GenericBlockCipher; 00054 case aead: GenericAEADCipher; 00055 } fragment; 00056 */ 00057 void* cipher; 00058 } tls_ciphertext_t; 00059 00060 00061 typedef struct __tls_block_cipher 00062 { 00063 uint8_t* initialization_vector; 00064 uint8_t* fragment; 00065 uint8_t* mac; 00066 uint8_t* padding; 00067 uint8_t padding_length; 00068 } tls_block_cipher_t; 00069 00070 typedef struct __tls_session_keys 00071 { 00072 uint8_t* server_write_mac_key; 00073 uint8_t* client_write_mac_key; 00074 uint8_t* server_write_key; 00075 uint8_t* client_write_key; 00076 //uint8_t* server_write_initialization_vector; -- only useful for certain specific ciphers 00077 //uint8_t* client_write_initialization_vector; 00078 } tls_session_keys_t; 00079 00080 //Known ciphersuites 00081 //CipherSuite TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = { 0xC0, 0x04 } 00082 //#define TLS_CIPHERSUITE_ECDH_ECDSA_WITH_AES_128_CBC_SHA { 0xC0, 0x04 } 00083 00084 /* Messages */ 00085 00086 typedef struct __tls_message_change_cipher_spec 00087 { 00088 enum { 00089 CHANGE_CIPHER_SPEC = 1, 00090 UNKNOWN = 255 00091 } type; 00092 } tls_message_change_cipher_spec_t; 00093 00094 00095 00096 typedef uint32_t uint24_t; //!BEWARE! 00097 /* 00098 typedef struct __tls_message_handshake 00099 { 00100 uint24_t length : 3; 00101 enum 00102 { 00103 hello_request = (0), client_hello = (1), server_hello = (2), 00104 certificate = (11), server_key_exchange = (12), 00105 certificate_request = (13), server_hello_done = (14), 00106 certificate_verify = (15), client_key_exchange = (16), 00107 finished = (20), unknown = (255) 00108 } handshake_type; 00109 00110 select (HandshakeType) { 00111 case hello_request: HelloRequest; 00112 case client_hello: ClientHello; 00113 case server_hello: ServerHello; 00114 case certificate: Certificate; 00115 case server_key_exchange: ServerKeyExchange; 00116 case certificate_request: CertificateRequest; 00117 case server_hello_done: ServerHelloDone; 00118 case certificate_verify: CertificateVerify; 00119 case client_key_exchange: ClientKeyExchange; 00120 case finished: Finished; 00121 } body; 00122 00123 uint8_t* body; 00124 } tls_message_handshake_t; 00125 */ 00126 #ifdef __cplusplus 00127 } 00128 #endif 00129 00130 #endif /* TLS_PROTOCOL_H_ */
Generated on Wed Jul 13 2022 00:22:55 by
1.7.2