This is a fork of the mbed port of axTLS

Dependents:   TLS_axTLS-Example HTTPSClientExample

Overview

This library is a fork from the mbed port of axTLS. It attempts to :

  • reduce the usage of dynamic memory
  • verify certificates with key size up to 2048 bits
  • provide a simple interface

Encryption

This library uses either RC4 or AES for encryption.

Memory usage

During the establishment of a connection, about 10KB of memory is allocated dynamically (it depends on certificates). Once the connection is established, the memory consumption is relatively low. This means that your program must not use too much static memory or allocate memory before you establish a TLS connection.

Certificates

Certificates are the major source of problem and will often be the reason why your program will crash. Due to memory constraint, there are some limitations on certificates :

  • Each certificate must not be bigger than 2KB
  • TLS client can only handle a chain of up to three certificates (excluding the root certificate). This means that the server must not send more than three certificates.

Also, this library can only load certificates following these specifications :

  • encoded in binary DER format (PKCS1)
  • The public key must use RSA only

Once the connection is established, you should free all loaded certificates by calling CertificateManager::clear(). This will free a few kilobytes (it depends on your certificates). In addition, to enable certificate verification during the connection, this library has a "precomputed mode". This mode uses much less memory than a normal certificate verification.

Normal mode

You need to copy the root certificate in binary-DER format on the mbed. Then in your code, let's say that your root certificate is saved on the mbed as "root.der", assuming that you include CertificateManager.h and that you created a LocalFileSystem, you can load this certificate as this ;

Load root certificate

CertificateManager::add("/local/root.der");
CertificateManager::load();

Do not forget that this mode takes quite a lot of memory ( the memory peak is high while verifying certificates) and will only work if the key size is not bigger than 1024 bits (otherwise it will crash while verifying certificates).

Precomputed mode

In this mode, you need to save the entire chain of certificates (in binary-DER format) including the root certificate on the mbed. In practice, this means that you must first retrieve all certificates that the server sends during a connection and then find the right root certificate. In your code, you must call CertificateManager::add for each certificate and in the right order : from the server certificate to the root certificate. Here is how you shoud load certificates in this mode :

Loadcertificates in precomputed mode

CertificateManager::add("/local/server1.der");
CertificateManager::add("/local/server2.der");
CertificateManager::add("/local/server3.der");
CertificateManager::add("/local/root.der");
CertificateManager::load(true);

Using this mode, you should be able to verify certificates with key size up to 2048 bits.

How do I find these certificates ?

I posted an entry in my notebook detailing how to get certificates from a server. You should be able to get all certificates you need except the root certificate. Here is a way how to get the root certificate on windows :

  1. Open (double-click) the last certificate sent by the server
  2. Go to details panel and click on the entry called Issuer. The first line gives you the name of this certificate and the second line indicates the company who created this certificate
  3. Open firefox
  4. Go to options, advanced panel and click on View Certificates
  5. Go to Authorities panel
  6. Choose the certificate whose name match the issuer of the last certificate sent by the server
  7. Export this certificate to binary-DER format.

Connect to mbed.org !

Import programTLS_axTLS-Example

Establishing a connection to mbed.org using TLS

Committer:
feb11
Date:
Thu Sep 12 15:18:04 2013 +0000
Revision:
0:85fceccc1a7c
intial import

Who changed what in which revision?

UserRevisionLine numberNew contents of line
feb11 0:85fceccc1a7c 1 /*
feb11 0:85fceccc1a7c 2 * Copyright (c) 2007, Cameron Rich
feb11 0:85fceccc1a7c 3 *
feb11 0:85fceccc1a7c 4 * All rights reserved.
feb11 0:85fceccc1a7c 5 *
feb11 0:85fceccc1a7c 6 * Redistribution and use in source and binary forms, with or without
feb11 0:85fceccc1a7c 7 * modification, are permitted provided that the following conditions are met:
feb11 0:85fceccc1a7c 8 *
feb11 0:85fceccc1a7c 9 * * Redistributions of source code must retain the above copyright notice,
feb11 0:85fceccc1a7c 10 * this list of conditions and the following disclaimer.
feb11 0:85fceccc1a7c 11 * * Redistributions in binary form must reproduce the above copyright notice,
feb11 0:85fceccc1a7c 12 * this list of conditions and the following disclaimer in the documentation
feb11 0:85fceccc1a7c 13 * and/or other materials provided with the distribution.
feb11 0:85fceccc1a7c 14 * * Neither the name of the axTLS project nor the names of its contributors
feb11 0:85fceccc1a7c 15 * may be used to endorse or promote products derived from this software
feb11 0:85fceccc1a7c 16 * without specific prior written permission.
feb11 0:85fceccc1a7c 17 *
feb11 0:85fceccc1a7c 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
feb11 0:85fceccc1a7c 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
feb11 0:85fceccc1a7c 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
feb11 0:85fceccc1a7c 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
feb11 0:85fceccc1a7c 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
feb11 0:85fceccc1a7c 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
feb11 0:85fceccc1a7c 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
feb11 0:85fceccc1a7c 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
feb11 0:85fceccc1a7c 26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
feb11 0:85fceccc1a7c 27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
feb11 0:85fceccc1a7c 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
feb11 0:85fceccc1a7c 29 */
feb11 0:85fceccc1a7c 30
feb11 0:85fceccc1a7c 31 /**
feb11 0:85fceccc1a7c 32 * @file tls1.h
feb11 0:85fceccc1a7c 33 *
feb11 0:85fceccc1a7c 34 * @brief The definitions for the TLS library.
feb11 0:85fceccc1a7c 35 */
feb11 0:85fceccc1a7c 36 #ifndef HEADER_SSL_LIB_H
feb11 0:85fceccc1a7c 37 #define HEADER_SSL_LIB_H
feb11 0:85fceccc1a7c 38
feb11 0:85fceccc1a7c 39
feb11 0:85fceccc1a7c 40 #ifdef __cplusplus
feb11 0:85fceccc1a7c 41 extern "C" {
feb11 0:85fceccc1a7c 42 #endif
feb11 0:85fceccc1a7c 43
feb11 0:85fceccc1a7c 44 #include "version.h"
feb11 0:85fceccc1a7c 45 #include "os_int.h"
feb11 0:85fceccc1a7c 46 #include "crypto.h"
feb11 0:85fceccc1a7c 47 #include "crypto_misc.h"
feb11 0:85fceccc1a7c 48
feb11 0:85fceccc1a7c 49 #include "config.h"
feb11 0:85fceccc1a7c 50
feb11 0:85fceccc1a7c 51 #define SSL_PROTOCOL_MIN_VERSION 0x31 /* TLS v1.0 */
feb11 0:85fceccc1a7c 52 #define SSL_PROTOCOL_MINOR_VERSION 0x02 /* TLS v1.1 */
feb11 0:85fceccc1a7c 53 #define SSL_PROTOCOL_VERSION_MAX 0x32 /* TLS v1.1 */
feb11 0:85fceccc1a7c 54 #define SSL_PROTOCOL_VERSION1_1 0x32 /* TLS v1.1 */
feb11 0:85fceccc1a7c 55 #define SSL_RANDOM_SIZE 32
feb11 0:85fceccc1a7c 56 #define SSL_SECRET_SIZE 48
feb11 0:85fceccc1a7c 57 #define SSL_FINISHED_HASH_SIZE 12
feb11 0:85fceccc1a7c 58 #define SSL_RECORD_SIZE 5
feb11 0:85fceccc1a7c 59 #define SSL_SERVER_READ 0
feb11 0:85fceccc1a7c 60 #define SSL_SERVER_WRITE 1
feb11 0:85fceccc1a7c 61 #define SSL_CLIENT_READ 2
feb11 0:85fceccc1a7c 62 #define SSL_CLIENT_WRITE 3
feb11 0:85fceccc1a7c 63 #define SSL_HS_HDR_SIZE 4
feb11 0:85fceccc1a7c 64
feb11 0:85fceccc1a7c 65 /* the flags we use while establishing a connection */
feb11 0:85fceccc1a7c 66 #define SSL_NEED_RECORD 0x0001
feb11 0:85fceccc1a7c 67 #define SSL_TX_ENCRYPTED 0x0002
feb11 0:85fceccc1a7c 68 #define SSL_RX_ENCRYPTED 0x0004
feb11 0:85fceccc1a7c 69 #define SSL_SESSION_RESUME 0x0008
feb11 0:85fceccc1a7c 70 #define SSL_IS_CLIENT 0x0010
feb11 0:85fceccc1a7c 71 #define SSL_HAS_CERT_REQ 0x0020
feb11 0:85fceccc1a7c 72 #define SSL_SENT_CLOSE_NOTIFY 0x0040
feb11 0:85fceccc1a7c 73
feb11 0:85fceccc1a7c 74 /* some macros to muck around with flag bits */
feb11 0:85fceccc1a7c 75 #define SET_SSL_FLAG(A) (ssl->flag |= A)
feb11 0:85fceccc1a7c 76 #define CLR_SSL_FLAG(A) (ssl->flag &= ~A)
feb11 0:85fceccc1a7c 77 #define IS_SET_SSL_FLAG(A) (ssl->flag & A)
feb11 0:85fceccc1a7c 78
feb11 0:85fceccc1a7c 79 #define MAX_KEY_BYTE_SIZE 256 /* for a 2048 bit key */
feb11 0:85fceccc1a7c 80 #define RT_MAX_PLAIN_LENGTH 2048//16384
feb11 0:85fceccc1a7c 81 #define RT_EXTRA 256//1024
feb11 0:85fceccc1a7c 82 #define BM_RECORD_OFFSET 5
feb11 0:85fceccc1a7c 83 #define BM_ALL_DATA_SIZE (RT_MAX_PLAIN_LENGTH+RT_EXTRA-BM_RECORD_OFFSET)
feb11 0:85fceccc1a7c 84
feb11 0:85fceccc1a7c 85 #ifdef CONFIG_SSL_SKELETON_MODE
feb11 0:85fceccc1a7c 86 #define NUM_PROTOCOLS 1
feb11 0:85fceccc1a7c 87 #else
feb11 0:85fceccc1a7c 88 #define NUM_PROTOCOLS 4
feb11 0:85fceccc1a7c 89 #endif
feb11 0:85fceccc1a7c 90
feb11 0:85fceccc1a7c 91 #define PARANOIA_CHECK(A, B) if (A < B) { \
feb11 0:85fceccc1a7c 92 ret = SSL_ERROR_INVALID_HANDSHAKE; goto error; }
feb11 0:85fceccc1a7c 93
feb11 0:85fceccc1a7c 94 /* protocol types */
feb11 0:85fceccc1a7c 95 enum
feb11 0:85fceccc1a7c 96 {
feb11 0:85fceccc1a7c 97 PT_CHANGE_CIPHER_SPEC = 20,
feb11 0:85fceccc1a7c 98 PT_ALERT_PROTOCOL,
feb11 0:85fceccc1a7c 99 PT_HANDSHAKE_PROTOCOL,
feb11 0:85fceccc1a7c 100 PT_APP_PROTOCOL_DATA
feb11 0:85fceccc1a7c 101 };
feb11 0:85fceccc1a7c 102
feb11 0:85fceccc1a7c 103 /* handshaking types */
feb11 0:85fceccc1a7c 104 enum
feb11 0:85fceccc1a7c 105 {
feb11 0:85fceccc1a7c 106 HS_HELLO_REQUEST,
feb11 0:85fceccc1a7c 107 HS_CLIENT_HELLO,
feb11 0:85fceccc1a7c 108 HS_SERVER_HELLO,
feb11 0:85fceccc1a7c 109 HS_CERTIFICATE = 11,
feb11 0:85fceccc1a7c 110 HS_SERVER_KEY_XCHG,
feb11 0:85fceccc1a7c 111 HS_CERT_REQ,
feb11 0:85fceccc1a7c 112 HS_SERVER_HELLO_DONE,
feb11 0:85fceccc1a7c 113 HS_CERT_VERIFY,
feb11 0:85fceccc1a7c 114 HS_CLIENT_KEY_XCHG,
feb11 0:85fceccc1a7c 115 HS_FINISHED = 20
feb11 0:85fceccc1a7c 116 };
feb11 0:85fceccc1a7c 117
feb11 0:85fceccc1a7c 118 typedef struct
feb11 0:85fceccc1a7c 119 {
feb11 0:85fceccc1a7c 120 uint8_t cipher;
feb11 0:85fceccc1a7c 121 uint8_t key_size;
feb11 0:85fceccc1a7c 122 uint8_t iv_size;
feb11 0:85fceccc1a7c 123 uint8_t key_block_size;
feb11 0:85fceccc1a7c 124 uint8_t padding_size;
feb11 0:85fceccc1a7c 125 uint8_t digest_size;
feb11 0:85fceccc1a7c 126 hmac_func hmac;
feb11 0:85fceccc1a7c 127 crypt_func encrypt;
feb11 0:85fceccc1a7c 128 crypt_func decrypt;
feb11 0:85fceccc1a7c 129 } cipher_info_t;
feb11 0:85fceccc1a7c 130
feb11 0:85fceccc1a7c 131 struct _SSLObjLoader
feb11 0:85fceccc1a7c 132 {
feb11 0:85fceccc1a7c 133 uint8_t *buf;
feb11 0:85fceccc1a7c 134 int len;
feb11 0:85fceccc1a7c 135 };
feb11 0:85fceccc1a7c 136
feb11 0:85fceccc1a7c 137 typedef struct _SSLObjLoader SSLObjLoader;
feb11 0:85fceccc1a7c 138
feb11 0:85fceccc1a7c 139 typedef struct
feb11 0:85fceccc1a7c 140 {
feb11 0:85fceccc1a7c 141 time_t conn_time;
feb11 0:85fceccc1a7c 142 uint8_t session_id[SSL_SESSION_ID_SIZE];
feb11 0:85fceccc1a7c 143 uint8_t master_secret[SSL_SECRET_SIZE];
feb11 0:85fceccc1a7c 144 } SSL_SESSION;
feb11 0:85fceccc1a7c 145
feb11 0:85fceccc1a7c 146 typedef struct
feb11 0:85fceccc1a7c 147 {
feb11 0:85fceccc1a7c 148 uint8_t *buf;
feb11 0:85fceccc1a7c 149 int size;
feb11 0:85fceccc1a7c 150 } SSL_CERT;
feb11 0:85fceccc1a7c 151
feb11 0:85fceccc1a7c 152 typedef struct
feb11 0:85fceccc1a7c 153 {
feb11 0:85fceccc1a7c 154 MD5_CTX md5_ctx;
feb11 0:85fceccc1a7c 155 SHA1_CTX sha1_ctx;
feb11 0:85fceccc1a7c 156 uint8_t final_finish_mac[SSL_FINISHED_HASH_SIZE];
feb11 0:85fceccc1a7c 157 uint8_t key_block[MAX_KEYBLOCK_SIZE];
feb11 0:85fceccc1a7c 158 uint8_t master_secret[SSL_SECRET_SIZE];
feb11 0:85fceccc1a7c 159 uint8_t client_random[SSL_RANDOM_SIZE]; /* client's random sequence */
feb11 0:85fceccc1a7c 160 uint8_t server_random[SSL_RANDOM_SIZE]; /* server's random sequence */
feb11 0:85fceccc1a7c 161 uint16_t bm_proc_index;
feb11 0:85fceccc1a7c 162 } DISPOSABLE_CTX;
feb11 0:85fceccc1a7c 163
feb11 0:85fceccc1a7c 164 struct _SSL
feb11 0:85fceccc1a7c 165 {
feb11 0:85fceccc1a7c 166 uint32_t flag;
feb11 0:85fceccc1a7c 167 uint16_t need_bytes;
feb11 0:85fceccc1a7c 168 uint16_t got_bytes;
feb11 0:85fceccc1a7c 169 uint8_t record_type;
feb11 0:85fceccc1a7c 170 uint8_t cipher;
feb11 0:85fceccc1a7c 171 uint8_t sess_id_size;
feb11 0:85fceccc1a7c 172 uint8_t version;
feb11 0:85fceccc1a7c 173 uint8_t client_version;
feb11 0:85fceccc1a7c 174 int16_t next_state;
feb11 0:85fceccc1a7c 175 int16_t hs_status;
feb11 0:85fceccc1a7c 176 DISPOSABLE_CTX *dc; /* temporary data which we'll get rid of soon */
feb11 0:85fceccc1a7c 177 int client_fd;
feb11 0:85fceccc1a7c 178 void *connection;
feb11 0:85fceccc1a7c 179 const cipher_info_t *cipher_info;
feb11 0:85fceccc1a7c 180 void *encrypt_ctx;
feb11 0:85fceccc1a7c 181 void *decrypt_ctx;
feb11 0:85fceccc1a7c 182 uint8_t bm_all_data[RT_MAX_PLAIN_LENGTH];
feb11 0:85fceccc1a7c 183 uint8_t *bm_data;
feb11 0:85fceccc1a7c 184 uint16_t bm_index;
feb11 0:85fceccc1a7c 185 uint16_t bm_remaining_bytes;
feb11 0:85fceccc1a7c 186 struct _SSL *next; /* doubly linked list */
feb11 0:85fceccc1a7c 187 struct _SSL *prev;
feb11 0:85fceccc1a7c 188 struct _SSL_CTX *ssl_ctx; /* back reference to a clnt/svr ctx */
feb11 0:85fceccc1a7c 189 #ifndef CONFIG_SSL_SKELETON_MODE
feb11 0:85fceccc1a7c 190 uint16_t session_index;
feb11 0:85fceccc1a7c 191 SSL_SESSION *session;
feb11 0:85fceccc1a7c 192 #endif
feb11 0:85fceccc1a7c 193 #ifdef CONFIG_SSL_CERT_VERIFICATION
feb11 0:85fceccc1a7c 194 X509_CTX *x509_ctx;
feb11 0:85fceccc1a7c 195 #endif
feb11 0:85fceccc1a7c 196
feb11 0:85fceccc1a7c 197 uint8_t session_id[SSL_SESSION_ID_SIZE];
feb11 0:85fceccc1a7c 198 uint8_t client_mac[SHA1_SIZE]; /* for HMAC verification */
feb11 0:85fceccc1a7c 199 uint8_t server_mac[SHA1_SIZE]; /* for HMAC verification */
feb11 0:85fceccc1a7c 200 uint8_t read_sequence[8]; /* 64 bit sequence number */
feb11 0:85fceccc1a7c 201 uint8_t write_sequence[8]; /* 64 bit sequence number */
feb11 0:85fceccc1a7c 202 uint8_t hmac_header[SSL_RECORD_SIZE]; /* rx hmac */
feb11 0:85fceccc1a7c 203 };
feb11 0:85fceccc1a7c 204
feb11 0:85fceccc1a7c 205 typedef struct _SSL SSL;
feb11 0:85fceccc1a7c 206
feb11 0:85fceccc1a7c 207 struct _SSL_CTX
feb11 0:85fceccc1a7c 208 {
feb11 0:85fceccc1a7c 209 uint32_t options;
feb11 0:85fceccc1a7c 210 uint8_t chain_length;
feb11 0:85fceccc1a7c 211 RSA_CTX *rsa_ctx;
feb11 0:85fceccc1a7c 212 #ifdef CONFIG_SSL_CERT_VERIFICATION
feb11 0:85fceccc1a7c 213 CA_CERT_CTX *ca_cert_ctx;
feb11 0:85fceccc1a7c 214 #endif
feb11 0:85fceccc1a7c 215 SSL *head;
feb11 0:85fceccc1a7c 216 SSL *tail;
feb11 0:85fceccc1a7c 217 SSL_CERT certs[CONFIG_SSL_MAX_CERTS];
feb11 0:85fceccc1a7c 218 #ifndef CONFIG_SSL_SKELETON_MODE
feb11 0:85fceccc1a7c 219 uint16_t num_sessions;
feb11 0:85fceccc1a7c 220 SSL_SESSION **ssl_sessions;
feb11 0:85fceccc1a7c 221 #endif
feb11 0:85fceccc1a7c 222 #ifdef CONFIG_SSL_CTX_MUTEXING
feb11 0:85fceccc1a7c 223 SSL_CTX_MUTEX_TYPE mutex;
feb11 0:85fceccc1a7c 224 #endif
feb11 0:85fceccc1a7c 225 #ifdef CONFIG_OPENSSL_COMPATIBLE
feb11 0:85fceccc1a7c 226 void *bonus_attr;
feb11 0:85fceccc1a7c 227 #endif
feb11 0:85fceccc1a7c 228 };
feb11 0:85fceccc1a7c 229
feb11 0:85fceccc1a7c 230 typedef struct _SSL_CTX SSL_CTX;
feb11 0:85fceccc1a7c 231
feb11 0:85fceccc1a7c 232 /* backwards compatibility */
feb11 0:85fceccc1a7c 233 typedef struct _SSL_CTX SSLCTX;
feb11 0:85fceccc1a7c 234
feb11 0:85fceccc1a7c 235 extern const uint8_t ssl_prot_prefs[NUM_PROTOCOLS];
feb11 0:85fceccc1a7c 236
feb11 0:85fceccc1a7c 237 SSL *ssl_new(SSL *ssl, int client_fd);
feb11 0:85fceccc1a7c 238 void disposable_new(SSL *ssl);
feb11 0:85fceccc1a7c 239 void disposable_free(SSL *ssl);
feb11 0:85fceccc1a7c 240 int send_packet(SSL *ssl, uint8_t protocol,
feb11 0:85fceccc1a7c 241 const uint8_t *in, int length);
feb11 0:85fceccc1a7c 242 int do_svr_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len);
feb11 0:85fceccc1a7c 243 int do_clnt_handshake(SSL *ssl, int handshake_type, uint8_t *buf, int hs_len);
feb11 0:85fceccc1a7c 244 int process_finished(SSL *ssl, uint8_t *buf, int hs_len);
feb11 0:85fceccc1a7c 245 int process_sslv23_client_hello(SSL *ssl);
feb11 0:85fceccc1a7c 246 int send_alert(SSL *ssl, int error_code);
feb11 0:85fceccc1a7c 247 int send_finished(SSL *ssl);
feb11 0:85fceccc1a7c 248 int send_certificate(SSL *ssl);
feb11 0:85fceccc1a7c 249 int basic_read2(SSL *ssl, uint8_t *data, uint32_t length);
feb11 0:85fceccc1a7c 250 int read_record(SSL *ssl);
feb11 0:85fceccc1a7c 251 int basic_decrypt(SSL *ssl, uint8_t *buf, int len);
feb11 0:85fceccc1a7c 252 int process_data(SSL* ssl, uint8_t *in_data, int len);
feb11 0:85fceccc1a7c 253 int ssl_read(SSL *ssl, uint8_t *in_data, int len);
feb11 0:85fceccc1a7c 254 int send_change_cipher_spec(SSL *ssl);
feb11 0:85fceccc1a7c 255 void finished_digest(SSL *ssl, const char *label, uint8_t *digest);
feb11 0:85fceccc1a7c 256 void generate_master_secret(SSL *ssl, const uint8_t *premaster_secret);
feb11 0:85fceccc1a7c 257 void add_packet(SSL *ssl, const uint8_t *pkt, int len);
feb11 0:85fceccc1a7c 258 int add_cert(SSL_CTX *ssl_ctx, const uint8_t *buf, int len);
feb11 0:85fceccc1a7c 259 int add_private_key(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj);
feb11 0:85fceccc1a7c 260 void ssl_obj_free(SSLObjLoader *ssl_obj);
feb11 0:85fceccc1a7c 261 int pkcs8_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password);
feb11 0:85fceccc1a7c 262 int pkcs12_decode(SSL_CTX *ssl_ctx, SSLObjLoader *ssl_obj, const char *password);
feb11 0:85fceccc1a7c 263 int load_key_certs(SSL_CTX *ssl_ctx);
feb11 0:85fceccc1a7c 264 #ifdef CONFIG_SSL_CERT_VERIFICATION
feb11 0:85fceccc1a7c 265 int add_cert_auth(SSL_CTX *ssl_ctx, const uint8_t *buf, int len);
feb11 0:85fceccc1a7c 266 void remove_ca_certs(CA_CERT_CTX *ca_cert_ctx);
feb11 0:85fceccc1a7c 267 #endif
feb11 0:85fceccc1a7c 268 #ifdef CONFIG_SSL_ENABLE_CLIENT
feb11 0:85fceccc1a7c 269 int do_client_connect(SSL *ssl);
feb11 0:85fceccc1a7c 270 #endif
feb11 0:85fceccc1a7c 271
feb11 0:85fceccc1a7c 272 #ifdef CONFIG_SSL_FULL_MODE
feb11 0:85fceccc1a7c 273 void DISPLAY_STATE(SSL *ssl, int is_send, uint8_t state, int not_ok);
feb11 0:85fceccc1a7c 274 void DISPLAY_BYTES(SSL *ssl, const char *format,
feb11 0:85fceccc1a7c 275 const uint8_t *data, int size, ...);
feb11 0:85fceccc1a7c 276 void DISPLAY_CERT(SSL *ssl, const X509_CTX *x509_ctx);
feb11 0:85fceccc1a7c 277 void DISPLAY_RSA(SSL *ssl, const RSA_CTX *rsa_ctx);
feb11 0:85fceccc1a7c 278 void DISPLAY_ALERT(SSL *ssl, int alert);
feb11 0:85fceccc1a7c 279 #else
feb11 0:85fceccc1a7c 280 #define DISPLAY_STATE(A,B,C,D)
feb11 0:85fceccc1a7c 281 #define DISPLAY_CERT(A,B)
feb11 0:85fceccc1a7c 282 #define DISPLAY_RSA(A,B)
feb11 0:85fceccc1a7c 283 #define DISPLAY_ALERT(A, B)
feb11 0:85fceccc1a7c 284 #ifdef WIN32
feb11 0:85fceccc1a7c 285 void DISPLAY_BYTES(SSL *ssl, const char *format,/* win32 has no variadic macros */
feb11 0:85fceccc1a7c 286 const uint8_t *data, int size, ...);
feb11 0:85fceccc1a7c 287 #else
feb11 0:85fceccc1a7c 288 #define DISPLAY_BYTES(A,B,C,D,...)
feb11 0:85fceccc1a7c 289 #endif
feb11 0:85fceccc1a7c 290 #endif
feb11 0:85fceccc1a7c 291
feb11 0:85fceccc1a7c 292 #ifdef CONFIG_SSL_CERT_VERIFICATION
feb11 0:85fceccc1a7c 293 int process_certificate(SSL *ssl, X509_CTX **x509_ctx);
feb11 0:85fceccc1a7c 294 #endif
feb11 0:85fceccc1a7c 295
feb11 0:85fceccc1a7c 296 SSL_SESSION *ssl_session_update(int max_sessions,
feb11 0:85fceccc1a7c 297 SSL_SESSION *ssl_sessions[], SSL *ssl,
feb11 0:85fceccc1a7c 298 const uint8_t *session_id);
feb11 0:85fceccc1a7c 299 void kill_ssl_session(SSL_SESSION **ssl_sessions, SSL *ssl);
feb11 0:85fceccc1a7c 300
feb11 0:85fceccc1a7c 301 #ifdef __cplusplus
feb11 0:85fceccc1a7c 302 }
feb11 0:85fceccc1a7c 303 #endif
feb11 0:85fceccc1a7c 304
feb11 0:85fceccc1a7c 305 #endif
feb11 0:85fceccc1a7c 306
feb11 0:85fceccc1a7c 307