|
| 1 | +/**************************************************************************** |
| 2 | + * apps/crypto/openssl_mbedtls_wrapper/include/openssl/ssl.h |
| 3 | + * |
| 4 | + * Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + ****************************************************************************/ |
| 18 | + |
| 19 | +#ifndef OPENSSL_MBEDTLS_WRAPPER_SSL_H |
| 20 | +#define OPENSSL_MBEDTLS_WRAPPER_SSL_H |
| 21 | + |
| 22 | +/**************************************************************************** |
| 23 | + * Included Files |
| 24 | + ****************************************************************************/ |
| 25 | + |
| 26 | +#include <stddef.h> |
| 27 | +#include <openssl/types.h> |
| 28 | +#include <openssl/x509_vfy.h> |
| 29 | +#include <openssl/tls1.h> |
| 30 | + |
| 31 | +/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ |
| 32 | +#define SSL_SENT_SHUTDOWN 1 |
| 33 | +#define SSL_RECEIVED_SHUTDOWN 2 |
| 34 | + |
| 35 | +#define SSL_VERIFY_NONE 0x00 |
| 36 | +#define SSL_VERIFY_PEER 0x01 |
| 37 | +#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 |
| 38 | +#define SSL_VERIFY_CLIENT_ONCE 0x04 |
| 39 | + |
| 40 | +/* The following 3 states are kept in ssl->rlayer.rstate when reads fail, you |
| 41 | + * should not need these |
| 42 | + */ |
| 43 | +#define SSL_ST_READ_HEADER 0xF0 |
| 44 | +#define SSL_ST_READ_BODY 0xF1 |
| 45 | +#define SSL_ST_READ_DONE 0xF2 |
| 46 | + |
| 47 | +#define SSL_NOTHING 1 |
| 48 | +#define SSL_WRITING 2 |
| 49 | +#define SSL_READING 3 |
| 50 | +#define SSL_X509_LOOKUP 4 |
| 51 | +#define SSL_ASYNC_PAUSED 5 |
| 52 | +#define SSL_ASYNC_NO_JOBS 6 |
| 53 | + |
| 54 | +#define SSL_ERROR_NONE 0 |
| 55 | +#define SSL_ERROR_SSL 1 |
| 56 | +#define SSL_ERROR_WANT_READ 2 |
| 57 | +#define SSL_ERROR_WANT_WRITE 3 |
| 58 | +#define SSL_ERROR_WANT_X509_LOOKUP 4 |
| 59 | +#define SSL_ERROR_SYSCALL 5/* look at error stack/return value/errno */ |
| 60 | +#define SSL_ERROR_ZERO_RETURN 6 |
| 61 | +#define SSL_ERROR_WANT_CONNECT 7 |
| 62 | +#define SSL_ERROR_WANT_ACCEPT 8 |
| 63 | +#define SSL_ERROR_WANT_ASYNC 9 |
| 64 | +#define SSL_ERROR_WANT_ASYNC_JOB 10 |
| 65 | + |
| 66 | +typedef enum |
| 67 | +{ |
| 68 | + TLS_ST_BEFORE, |
| 69 | + TLS_ST_OK, |
| 70 | + DTLS_ST_CR_HELLO_VERIFY_REQUEST, |
| 71 | + TLS_ST_CR_SRVR_HELLO, |
| 72 | + TLS_ST_CR_CERT, |
| 73 | + TLS_ST_CR_CERT_STATUS, |
| 74 | + TLS_ST_CR_KEY_EXCH, |
| 75 | + TLS_ST_CR_CERT_REQ, |
| 76 | + TLS_ST_CR_SRVR_DONE, |
| 77 | + TLS_ST_CR_SESSION_TICKET, |
| 78 | + TLS_ST_CR_CHANGE, |
| 79 | + TLS_ST_CR_FINISHED, |
| 80 | + TLS_ST_CW_CLNT_HELLO, |
| 81 | + TLS_ST_CW_CERT, |
| 82 | + TLS_ST_CW_KEY_EXCH, |
| 83 | + TLS_ST_CW_CERT_VRFY, |
| 84 | + TLS_ST_CW_CHANGE, |
| 85 | + TLS_ST_CW_NEXT_PROTO, |
| 86 | + TLS_ST_CW_FINISHED, |
| 87 | + TLS_ST_SW_HELLO_REQ, |
| 88 | + TLS_ST_SR_CLNT_HELLO, |
| 89 | + DTLS_ST_SW_HELLO_VERIFY_REQUEST, |
| 90 | + TLS_ST_SW_SRVR_HELLO, |
| 91 | + TLS_ST_SW_CERT, |
| 92 | + TLS_ST_SW_KEY_EXCH, |
| 93 | + TLS_ST_SW_CERT_REQ, |
| 94 | + TLS_ST_SW_SRVR_DONE, |
| 95 | + TLS_ST_SR_CERT, |
| 96 | + TLS_ST_SR_KEY_EXCH, |
| 97 | + TLS_ST_SR_CERT_VRFY, |
| 98 | + TLS_ST_SR_NEXT_PROTO, |
| 99 | + TLS_ST_SR_CHANGE, |
| 100 | + TLS_ST_SR_FINISHED, |
| 101 | + TLS_ST_SW_SESSION_TICKET, |
| 102 | + TLS_ST_SW_CERT_STATUS, |
| 103 | + TLS_ST_SW_CHANGE, |
| 104 | + TLS_ST_SW_FINISHED |
| 105 | +} |
| 106 | +OSSL_HANDSHAKE_STATE; |
| 107 | + |
| 108 | +#ifdef __cplusplus |
| 109 | +extern "C" |
| 110 | +{ |
| 111 | +#endif |
| 112 | + |
| 113 | +/**************************************************************************** |
| 114 | + * Public Function Prototypes |
| 115 | + ****************************************************************************/ |
| 116 | + |
| 117 | +X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); |
| 118 | + |
| 119 | +int X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, |
| 120 | + unsigned long flags); |
| 121 | + |
| 122 | +int X509_VERIFY_PARAM_clear_hostflags(X509_VERIFY_PARAM *param, |
| 123 | + unsigned long flags); |
| 124 | + |
| 125 | +int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x); |
| 126 | + |
| 127 | +int SSL_CTX_add_client_CA_ASN1(SSL_CTX *ssl, int len, |
| 128 | + const unsigned char *d); |
| 129 | + |
| 130 | +int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); |
| 131 | + |
| 132 | +int SSL_use_certificate(SSL *ssl, X509 *x); |
| 133 | + |
| 134 | +X509 *SSL_get_certificate(const SSL *ssl); |
| 135 | + |
| 136 | +int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, |
| 137 | + const unsigned char *d); |
| 138 | + |
| 139 | +int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); |
| 140 | + |
| 141 | +int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); |
| 142 | + |
| 143 | +int SSL_use_certificate_file(SSL *ssl, const char *file, int type); |
| 144 | + |
| 145 | +X509 *SSL_get_peer_certificate(const SSL *ssl); |
| 146 | + |
| 147 | +int SSL_want(const SSL *ssl); |
| 148 | + |
| 149 | +int SSL_want_nothing(const SSL *ssl); |
| 150 | + |
| 151 | +int SSL_want_read(const SSL *ssl); |
| 152 | + |
| 153 | +int SSL_want_write(const SSL *ssl); |
| 154 | + |
| 155 | +int SSL_want_x509_lookup(const SSL *ssl); |
| 156 | + |
| 157 | +void _ssl_set_alpn_list(const SSL *ssl); |
| 158 | + |
| 159 | +int SSL_get_error(const SSL *ssl, int ret_code); |
| 160 | + |
| 161 | +OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl); |
| 162 | + |
| 163 | +SSL_CTX *SSL_CTX_new(const SSL_METHOD *method, void *rngctx); |
| 164 | + |
| 165 | +void SSL_CTX_free(SSL_CTX *ctx); |
| 166 | + |
| 167 | +int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth); |
| 168 | + |
| 169 | +const SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx); |
| 170 | + |
| 171 | +SSL *SSL_new(SSL_CTX *ctx); |
| 172 | + |
| 173 | +void SSL_free(SSL *ssl); |
| 174 | + |
| 175 | +int SSL_do_handshake(SSL *ssl); |
| 176 | + |
| 177 | +int SSL_connect(SSL *ssl); |
| 178 | + |
| 179 | +int SSL_accept(SSL *ssl); |
| 180 | + |
| 181 | +int SSL_shutdown(SSL *ssl); |
| 182 | + |
| 183 | +int SSL_clear(SSL *ssl); |
| 184 | + |
| 185 | +int SSL_read(SSL *ssl, void *buffer, int len); |
| 186 | + |
| 187 | +int SSL_write(SSL *ssl, const void *buffer, int len); |
| 188 | + |
| 189 | +SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); |
| 190 | + |
| 191 | +const SSL_METHOD *SSL_get_ssl_method(SSL *ssl); |
| 192 | + |
| 193 | +int SSL_set_ssl_method(SSL *ssl, const SSL_METHOD *method); |
| 194 | + |
| 195 | +int SSL_get_shutdown(const SSL *ssl); |
| 196 | + |
| 197 | +void SSL_set_shutdown(SSL *ssl, int mode); |
| 198 | + |
| 199 | +int SSL_pending(const SSL *ssl); |
| 200 | + |
| 201 | +int SSL_has_pending(const SSL *ssl); |
| 202 | + |
| 203 | +unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op); |
| 204 | + |
| 205 | +unsigned long SSL_CTX_get_options(SSL_CTX *ctx); |
| 206 | + |
| 207 | +unsigned long SSL_clear_options(SSL *ssl, unsigned long op); |
| 208 | + |
| 209 | +unsigned long SSL_get_options(SSL *ssl); |
| 210 | + |
| 211 | +unsigned long SSL_set_options(SSL *ssl, unsigned long op); |
| 212 | + |
| 213 | +int SSL_get_fd(const SSL *ssl); |
| 214 | + |
| 215 | +int SSL_get_rfd(const SSL *ssl); |
| 216 | + |
| 217 | +int SSL_get_wfd(const SSL *ssl); |
| 218 | + |
| 219 | +int SSL_set_fd(SSL *ssl, int fd); |
| 220 | + |
| 221 | +int SSL_set_rfd(SSL *ssl, int fd); |
| 222 | + |
| 223 | +int SSL_set_wfd(SSL *ssl, int fd); |
| 224 | + |
| 225 | +int SSL_version(const SSL *ssl); |
| 226 | + |
| 227 | +const char *SSL_alert_type_string(int value); |
| 228 | + |
| 229 | +void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len); |
| 230 | + |
| 231 | +void SSL_set_default_read_buffer_len(SSL *ssl, size_t len); |
| 232 | + |
| 233 | +void SSL_set_info_callback(SSL *ssl, |
| 234 | + void (*cb) (const SSL *ssl, int type, int val)); |
| 235 | + |
| 236 | +int SSL_CTX_up_ref(SSL_CTX *ctx); |
| 237 | + |
| 238 | +void SSL_set_security_level(SSL *ssl, int level); |
| 239 | + |
| 240 | +int SSL_get_security_level(const SSL *ssl); |
| 241 | + |
| 242 | +int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); |
| 243 | + |
| 244 | +long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); |
| 245 | + |
| 246 | +long SSL_CTX_get_timeout(const SSL_CTX *ctx); |
| 247 | + |
| 248 | +void SSL_set_read_ahead(SSL *ssl, int yes); |
| 249 | + |
| 250 | +void SSL_CTX_set_read_ahead(SSL_CTX *ctx, int yes); |
| 251 | + |
| 252 | +int SSL_get_read_ahead(const SSL *ssl); |
| 253 | + |
| 254 | +long SSL_CTX_get_read_ahead(SSL_CTX *ctx); |
| 255 | + |
| 256 | +long SSL_CTX_get_default_read_ahead(SSL_CTX *ctx); |
| 257 | + |
| 258 | +long SSL_set_time(SSL *ssl, long t); |
| 259 | + |
| 260 | +long SSL_set_timeout(SSL *ssl, long t); |
| 261 | + |
| 262 | +long SSL_get_verify_result(const SSL *ssl); |
| 263 | + |
| 264 | +int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); |
| 265 | + |
| 266 | +void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); |
| 267 | + |
| 268 | +int SSL_get_verify_depth(const SSL *ssl); |
| 269 | + |
| 270 | +void SSL_set_verify_depth(SSL *ssl, int depth); |
| 271 | + |
| 272 | +void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, |
| 273 | + int (*verify_callback)(int, X509_STORE_CTX *)); |
| 274 | + |
| 275 | +void SSL_set_verify(SSL *ssl, int mode, |
| 276 | + int (*verify_callback)(int, X509_STORE_CTX *)); |
| 277 | + |
| 278 | +void *SSL_CTX_get_ex_data(const SSL_CTX *ctx, int idx); |
| 279 | + |
| 280 | +void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, next_proto_cb cb, void *arg); |
| 281 | + |
| 282 | +void SSL_set_alpn_select_cb(SSL *ssl, void *arg); |
| 283 | + |
| 284 | +int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); |
| 285 | + |
| 286 | +int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); |
| 287 | + |
| 288 | +int SSL_CTX_use_PrivateKey_ASN1(int type, SSL_CTX *ctx, |
| 289 | + const unsigned char *d, long len); |
| 290 | + |
| 291 | +int SSL_use_PrivateKey_ASN1(int type, SSL *ssl, |
| 292 | + const unsigned char *d, long len); |
| 293 | + |
| 294 | +int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); |
| 295 | + |
| 296 | +int SSL_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); |
| 297 | + |
| 298 | +int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, |
| 299 | + long len); |
| 300 | + |
| 301 | +#ifdef __cplusplus |
| 302 | +} |
| 303 | +#endif |
| 304 | + |
| 305 | +#endif /* OPENSSL_MBEDTLS_WRAPPER_SSL_H */ |
0 commit comments