change some parameters in the library to meet the needs of the website httpbin.org

Fork of MiniTLS-GPL by Donatien Garnier

Committer:
MiniTLS
Date:
Mon Jun 09 14:57:54 2014 +0000
Revision:
2:527a66d0a1a9
Change name to MiniTLS and added doc

Who changed what in which revision?

UserRevisionLine numberNew 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_protocol.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_PROTOCOL_H_
MiniTLS 2:527a66d0a1a9 26 #define TLS_PROTOCOL_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
MiniTLS 2:527a66d0a1a9 34 //See rfc5246 and rfc4492
MiniTLS 2:527a66d0a1a9 35
MiniTLS 2:527a66d0a1a9 36
MiniTLS 2:527a66d0a1a9 37 typedef struct __tls_plaintext
MiniTLS 2:527a66d0a1a9 38 {
MiniTLS 2:527a66d0a1a9 39 tls_content_type_t type;
MiniTLS 2:527a66d0a1a9 40 tls_protocol_version_t version;
MiniTLS 2:527a66d0a1a9 41 uint16_t length; //(MAX 2^14 = 16384)
MiniTLS 2:527a66d0a1a9 42 //uint8_t* fragment; //(plaintext)
MiniTLS 2:527a66d0a1a9 43 } tls_plaintext_t;
MiniTLS 2:527a66d0a1a9 44
MiniTLS 2:527a66d0a1a9 45 typedef struct __tls_ciphertext
MiniTLS 2:527a66d0a1a9 46 {
MiniTLS 2:527a66d0a1a9 47 tls_content_type_t type;
MiniTLS 2:527a66d0a1a9 48 tls_protocol_version_t version;
MiniTLS 2:527a66d0a1a9 49 uint16_t length; ////(MAX 2^14 + 2048 = 18432)
MiniTLS 2:527a66d0a1a9 50 /*
MiniTLS 2:527a66d0a1a9 51 select (SecurityParameters.cipher_type) {
MiniTLS 2:527a66d0a1a9 52 case stream: GenericStreamCipher;
MiniTLS 2:527a66d0a1a9 53 case block: GenericBlockCipher;
MiniTLS 2:527a66d0a1a9 54 case aead: GenericAEADCipher;
MiniTLS 2:527a66d0a1a9 55 } fragment;
MiniTLS 2:527a66d0a1a9 56 */
MiniTLS 2:527a66d0a1a9 57 void* cipher;
MiniTLS 2:527a66d0a1a9 58 } tls_ciphertext_t;
MiniTLS 2:527a66d0a1a9 59
MiniTLS 2:527a66d0a1a9 60
MiniTLS 2:527a66d0a1a9 61 typedef struct __tls_block_cipher
MiniTLS 2:527a66d0a1a9 62 {
MiniTLS 2:527a66d0a1a9 63 uint8_t* initialization_vector;
MiniTLS 2:527a66d0a1a9 64 uint8_t* fragment;
MiniTLS 2:527a66d0a1a9 65 uint8_t* mac;
MiniTLS 2:527a66d0a1a9 66 uint8_t* padding;
MiniTLS 2:527a66d0a1a9 67 uint8_t padding_length;
MiniTLS 2:527a66d0a1a9 68 } tls_block_cipher_t;
MiniTLS 2:527a66d0a1a9 69
MiniTLS 2:527a66d0a1a9 70 typedef struct __tls_session_keys
MiniTLS 2:527a66d0a1a9 71 {
MiniTLS 2:527a66d0a1a9 72 uint8_t* server_write_mac_key;
MiniTLS 2:527a66d0a1a9 73 uint8_t* client_write_mac_key;
MiniTLS 2:527a66d0a1a9 74 uint8_t* server_write_key;
MiniTLS 2:527a66d0a1a9 75 uint8_t* client_write_key;
MiniTLS 2:527a66d0a1a9 76 //uint8_t* server_write_initialization_vector; -- only useful for certain specific ciphers
MiniTLS 2:527a66d0a1a9 77 //uint8_t* client_write_initialization_vector;
MiniTLS 2:527a66d0a1a9 78 } tls_session_keys_t;
MiniTLS 2:527a66d0a1a9 79
MiniTLS 2:527a66d0a1a9 80 //Known ciphersuites
MiniTLS 2:527a66d0a1a9 81 //CipherSuite TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA = { 0xC0, 0x04 }
MiniTLS 2:527a66d0a1a9 82 //#define TLS_CIPHERSUITE_ECDH_ECDSA_WITH_AES_128_CBC_SHA { 0xC0, 0x04 }
MiniTLS 2:527a66d0a1a9 83
MiniTLS 2:527a66d0a1a9 84 /* Messages */
MiniTLS 2:527a66d0a1a9 85
MiniTLS 2:527a66d0a1a9 86 typedef struct __tls_message_change_cipher_spec
MiniTLS 2:527a66d0a1a9 87 {
MiniTLS 2:527a66d0a1a9 88 enum {
MiniTLS 2:527a66d0a1a9 89 CHANGE_CIPHER_SPEC = 1,
MiniTLS 2:527a66d0a1a9 90 UNKNOWN = 255
MiniTLS 2:527a66d0a1a9 91 } type;
MiniTLS 2:527a66d0a1a9 92 } tls_message_change_cipher_spec_t;
MiniTLS 2:527a66d0a1a9 93
MiniTLS 2:527a66d0a1a9 94
MiniTLS 2:527a66d0a1a9 95
MiniTLS 2:527a66d0a1a9 96 typedef uint32_t uint24_t; //!BEWARE!
MiniTLS 2:527a66d0a1a9 97 /*
MiniTLS 2:527a66d0a1a9 98 typedef struct __tls_message_handshake
MiniTLS 2:527a66d0a1a9 99 {
MiniTLS 2:527a66d0a1a9 100 uint24_t length : 3;
MiniTLS 2:527a66d0a1a9 101 enum
MiniTLS 2:527a66d0a1a9 102 {
MiniTLS 2:527a66d0a1a9 103 hello_request = (0), client_hello = (1), server_hello = (2),
MiniTLS 2:527a66d0a1a9 104 certificate = (11), server_key_exchange = (12),
MiniTLS 2:527a66d0a1a9 105 certificate_request = (13), server_hello_done = (14),
MiniTLS 2:527a66d0a1a9 106 certificate_verify = (15), client_key_exchange = (16),
MiniTLS 2:527a66d0a1a9 107 finished = (20), unknown = (255)
MiniTLS 2:527a66d0a1a9 108 } handshake_type;
MiniTLS 2:527a66d0a1a9 109
MiniTLS 2:527a66d0a1a9 110 select (HandshakeType) {
MiniTLS 2:527a66d0a1a9 111 case hello_request: HelloRequest;
MiniTLS 2:527a66d0a1a9 112 case client_hello: ClientHello;
MiniTLS 2:527a66d0a1a9 113 case server_hello: ServerHello;
MiniTLS 2:527a66d0a1a9 114 case certificate: Certificate;
MiniTLS 2:527a66d0a1a9 115 case server_key_exchange: ServerKeyExchange;
MiniTLS 2:527a66d0a1a9 116 case certificate_request: CertificateRequest;
MiniTLS 2:527a66d0a1a9 117 case server_hello_done: ServerHelloDone;
MiniTLS 2:527a66d0a1a9 118 case certificate_verify: CertificateVerify;
MiniTLS 2:527a66d0a1a9 119 case client_key_exchange: ClientKeyExchange;
MiniTLS 2:527a66d0a1a9 120 case finished: Finished;
MiniTLS 2:527a66d0a1a9 121 } body;
MiniTLS 2:527a66d0a1a9 122
MiniTLS 2:527a66d0a1a9 123 uint8_t* body;
MiniTLS 2:527a66d0a1a9 124 } tls_message_handshake_t;
MiniTLS 2:527a66d0a1a9 125 */
MiniTLS 2:527a66d0a1a9 126 #ifdef __cplusplus
MiniTLS 2:527a66d0a1a9 127 }
MiniTLS 2:527a66d0a1a9 128 #endif
MiniTLS 2:527a66d0a1a9 129
MiniTLS 2:527a66d0a1a9 130 #endif /* TLS_PROTOCOL_H_ */