71 #define SSL_SESSION_ID_SIZE 32
76 typedef struct SSL_CTX_ SSL_CTX;
77 typedef struct SSL_ SSL;
80 #define SSL_CLIENT_AUTHENTICATION 0x00010000
81 #define SSL_SERVER_VERIFY_LATER 0x00020000
82 #define SSL_NO_DEFAULT_KEY 0x00040000
83 #define SSL_DISPLAY_STATES 0x00080000
84 #define SSL_DISPLAY_BYTES 0x00100000
85 #define SSL_DISPLAY_CERTS 0x00200000
86 #define SSL_DISPLAY_RSA 0x00400000
87 #define SSL_CONNECT_IN_PARTS 0x00800000
92 #define SSL_ERROR_DEAD -2
93 #define SSL_CLOSE_NOTIFY -3
94 #define SSL_ERROR_CONN_LOST -256
95 #define SSL_ERROR_SOCK_SETUP_FAILURE -258
96 #define SSL_ERROR_INVALID_HANDSHAKE -260
97 #define SSL_ERROR_INVALID_PROT_MSG -261
98 #define SSL_ERROR_INVALID_HMAC -262
99 #define SSL_ERROR_INVALID_VERSION -263
100 #define SSL_ERROR_INVALID_SESSION -265
101 #define SSL_ERROR_NO_CIPHER -266
102 #define SSL_ERROR_BAD_CERTIFICATE -268
103 #define SSL_ERROR_INVALID_KEY -269
104 #define SSL_ERROR_FINISHED_INVALID -271
105 #define SSL_ERROR_NO_CERT_DEFINED -272
106 #define SSL_ERROR_NO_CLIENT_RENOG -273
107 #define SSL_ERROR_NOT_SUPPORTED -274
108 #define SSL_X509_OFFSET -512
109 #define SSL_X509_ERROR(A) (SSL_X509_OFFSET+A)
112 #define SSL_ALERT_TYPE_WARNING 1
113 #define SLL_ALERT_TYPE_FATAL 2
116 #define SSL_ALERT_CLOSE_NOTIFY 0
117 #define SSL_ALERT_UNEXPECTED_MESSAGE 10
118 #define SSL_ALERT_BAD_RECORD_MAC 20
119 #define SSL_ALERT_HANDSHAKE_FAILURE 40
120 #define SSL_ALERT_BAD_CERTIFICATE 42
121 #define SSL_ALERT_ILLEGAL_PARAMETER 47
122 #define SSL_ALERT_DECODE_ERROR 50
123 #define SSL_ALERT_DECRYPT_ERROR 51
124 #define SSL_ALERT_INVALID_VERSION 70
125 #define SSL_ALERT_NO_RENEGOTIATION 100
128 #define SSL_AES128_SHA 0x2f
129 #define SSL_AES256_SHA 0x35
130 #define SSL_RC4_128_SHA 0x05
131 #define SSL_RC4_128_MD5 0x04
134 #define SSL_BUILD_SKELETON_MODE 0x01
135 #define SSL_BUILD_SERVER_ONLY 0x02
136 #define SSL_BUILD_ENABLE_VERIFICATION 0x03
137 #define SSL_BUILD_ENABLE_CLIENT 0x04
138 #define SSL_BUILD_FULL_MODE 0x05
141 #define SSL_BUILD_MODE 0
142 #define SSL_MAX_CERT_CFG_OFFSET 1
143 #define SSL_MAX_CA_CERT_CFG_OFFSET 2
144 #define SSL_HAS_PEM 3
147 #define SSL_DEFAULT_SVR_SESS 5
148 #define SSL_DEFAULT_CLNT_SESS 1
151 #define SSL_X509_CERT_COMMON_NAME 0
152 #define SSL_X509_CERT_ORGANIZATION 1
153 #define SSL_X509_CERT_ORGANIZATIONAL_NAME 2
154 #define SSL_X509_CA_CERT_COMMON_NAME 3
155 #define SSL_X509_CA_CERT_ORGANIZATION 4
156 #define SSL_X509_CA_CERT_ORGANIZATIONAL_NAME 5
159 #define SSL_OBJ_X509_CERT 1
160 #define SSL_OBJ_X509_CACERT 2
161 #define SSL_OBJ_RSA_KEY 3
162 #define SSL_OBJ_PKCS8 4
163 #define SSL_OBJ_PKCS12 5
209 EXP_FUNC SSL_CTX * STDCALL
ssl_ctx_new(uint32_t options,
int num_sessions);
229 EXP_FUNC SSL * STDCALL
ssl_server_new(SSL_CTX *ssl_ctx,
int client_fd);
249 EXP_FUNC SSL * STDCALL
ssl_client_new(SSL_CTX *ssl_ctx,
int client_fd,
const uint8_t *session_id, uint8_t sess_id_size);
258 EXP_FUNC
void STDCALL
ssl_free(SSL *ssl);
276 EXP_FUNC
int STDCALL
ssl_read(SSL *ssl, uint8_t **in_data);
288 EXP_FUNC
int STDCALL
ssl_write(SSL *ssl,
const uint8_t *out_data,
int out_len);
300 EXP_FUNC SSL * STDCALL
ssl_find(SSL_CTX *ssl_ctx,
int client_fd);
405 EXP_FUNC
const char * STDCALL
ssl_get_cert_dn(
const SSL *ssl,
int component);
456 EXP_FUNC
int STDCALL
ssl_obj_load(SSL_CTX *ssl_ctx,
int obj_type,
const char *filename,
const char *password);
471 EXP_FUNC
int STDCALL
ssl_obj_memory_load(SSL_CTX *ssl_ctx,
int obj_type,
const uint8_t *data,
int len,
const char *password);
473 #ifdef CONFIG_SSL_GENERATE_X509_CERT
496 EXP_FUNC
int STDCALL ssl_x509_create(SSL_CTX *ssl_ctx, uint32_t options,
const char * dn[], uint8_t **cert_data);
const char * ssl_get_cert_dn(const SSL *ssl, int component)
Retrieve an X.509 distinguished name component.
const uint8_t * ssl_get_session_id(const SSL *ssl)
Get the session id for a handshake.
int ssl_get_config(int offset)
Retrieve various parameters about the axTLS engine.
int ssl_match_fingerprint(const SSL *ssl, const uint8_t *fp)
Check if certificate fingerprint (SHA1) matches the one given.
int ssl_handshake_status(const SSL *ssl)
Return the status of the handshake.
uint8_t ssl_get_cipher_id(const SSL *ssl)
Return the cipher id (in the SSL form).
int ssl_renegotiate(SSL *ssl)
Force the client to perform its handshake again.
int ssl_read(SSL *ssl, uint8_t **in_data)
Read the SSL data stream. If the socket is non-blocking and data is blocked then SSO_OK will be retur...
SSL * ssl_client_new(SSL_CTX *ssl_ctx, int client_fd, const uint8_t *session_id, uint8_t sess_id_size)
(client only) Establish a new SSL connection to an SSL server.
void ssl_free(SSL *ssl)
Free any used resources on this connection.
int ssl_verify_cert(const SSL *ssl)
Authenticate a received certificate.
int ssl_write(SSL *ssl, const uint8_t *out_data, int out_len)
Write to the SSL data stream. if the socket is non-blocking and data is blocked then a check is made ...
SSL * ssl_find(SSL_CTX *ssl_ctx, int client_fd)
Find an ssl object based on a file descriptor.
uint8_t ssl_get_session_id_size(const SSL *ssl)
Get the session id size for a handshake.
void ssl_display_error(int error_code)
Display why the handshake failed.
const char * ssl_get_cert_subject_alt_dnsname(const SSL *ssl, int dnsindex)
Retrieve a Subject Alternative DNSName.
int ssl_obj_load(SSL_CTX *ssl_ctx, int obj_type, const char *filename, const char *password)
Process a file that is in binary DER or ASCII PEM format.
int ssl_obj_memory_load(SSL_CTX *ssl_ctx, int obj_type, const uint8_t *data, int len, const char *password)
Process binary data.
SSL * ssl_server_new(SSL_CTX *ssl_ctx, int client_fd)
(server only) Establish a new SSL connection to an SSL client.
const char * ssl_version(void)
Return the axTLS library version as a string.
SSL_CTX * ssl_ctx_new(uint32_t options, int num_sessions)
Establish a new client/server context.
void ssl_ctx_free(SSL_CTX *ssl_ctx)
Remove a client/server context.