2016-09-22 02:28:08 +00:00
|
|
|
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-09-20 08:58:46 +00:00
|
|
|
#ifndef _SSL_CODE_H_
|
|
|
|
#define _SSL_CODE_H_
|
|
|
|
|
2016-09-23 07:18:14 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-09-20 08:58:46 +00:00
|
|
|
#include "ssl3.h"
|
|
|
|
#include "tls1.h"
|
2016-09-22 07:15:16 +00:00
|
|
|
#include "x509_vfy.h"
|
2016-09-20 08:58:46 +00:00
|
|
|
|
|
|
|
/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
|
|
|
|
# define SSL_SENT_SHUTDOWN 1
|
|
|
|
# define SSL_RECEIVED_SHUTDOWN 2
|
|
|
|
|
2016-09-23 03:41:57 +00:00
|
|
|
# define SSL_VERIFY_NONE 0x00
|
|
|
|
# define SSL_VERIFY_PEER 0x01
|
|
|
|
# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
|
|
|
|
# define SSL_VERIFY_CLIENT_ONCE 0x04
|
|
|
|
|
2016-09-20 08:58:46 +00:00
|
|
|
/*
|
|
|
|
* The following 3 states are kept in ssl->rlayer.rstate when reads fail, you
|
|
|
|
* should not need these
|
|
|
|
*/
|
|
|
|
# define SSL_ST_READ_HEADER 0xF0
|
|
|
|
# define SSL_ST_READ_BODY 0xF1
|
|
|
|
# define SSL_ST_READ_DONE 0xF2
|
|
|
|
|
|
|
|
# define SSL_NOTHING 1
|
|
|
|
# define SSL_WRITING 2
|
|
|
|
# define SSL_READING 3
|
|
|
|
# define SSL_X509_LOOKUP 4
|
|
|
|
# define SSL_ASYNC_PAUSED 5
|
|
|
|
# define SSL_ASYNC_NO_JOBS 6
|
|
|
|
|
|
|
|
|
|
|
|
# define SSL_ERROR_NONE 0
|
|
|
|
# define SSL_ERROR_SSL 1
|
|
|
|
# define SSL_ERROR_WANT_READ 2
|
|
|
|
# define SSL_ERROR_WANT_WRITE 3
|
|
|
|
# define SSL_ERROR_WANT_X509_LOOKUP 4
|
|
|
|
# define SSL_ERROR_SYSCALL 5/* look at error stack/return value/errno */
|
|
|
|
# define SSL_ERROR_ZERO_RETURN 6
|
|
|
|
# define SSL_ERROR_WANT_CONNECT 7
|
|
|
|
# define SSL_ERROR_WANT_ACCEPT 8
|
|
|
|
# define SSL_ERROR_WANT_ASYNC 9
|
|
|
|
# define SSL_ERROR_WANT_ASYNC_JOB 10
|
|
|
|
|
|
|
|
/* Message flow states */
|
|
|
|
typedef enum {
|
|
|
|
/* No handshake in progress */
|
|
|
|
MSG_FLOW_UNINITED,
|
|
|
|
/* A permanent error with this connection */
|
|
|
|
MSG_FLOW_ERROR,
|
|
|
|
/* We are about to renegotiate */
|
|
|
|
MSG_FLOW_RENEGOTIATE,
|
|
|
|
/* We are reading messages */
|
|
|
|
MSG_FLOW_READING,
|
|
|
|
/* We are writing messages */
|
|
|
|
MSG_FLOW_WRITING,
|
|
|
|
/* Handshake has finished */
|
|
|
|
MSG_FLOW_FINISHED
|
|
|
|
} MSG_FLOW_STATE;
|
|
|
|
|
2016-09-23 06:50:27 +00:00
|
|
|
/* SSL subsystem states */
|
2016-09-20 08:58:46 +00:00
|
|
|
typedef enum {
|
|
|
|
TLS_ST_BEFORE,
|
|
|
|
TLS_ST_OK,
|
|
|
|
DTLS_ST_CR_HELL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