#include "x509.h"
#include "rsa.h"
#include "dhm.h"
#include "md5.h"
#include "sha1.h"
Go to the source code of this file.
Definition in file ssl.h.
#define ERR_SSL_BAD_HS_CERTIFICATE_VERIFY 0xC800 |
#define ERR_SSL_BAD_HS_CLIENT_HELLO 0x9000 |
#define ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE 0xC000 |
#define ERR_SSL_BAD_HS_SERVER_HELLO 0x9800 |
#define ERR_SSL_BAD_HS_SERVER_HELLO_DONE 0xB800 |
#define ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE 0xB000 |
#define ERR_SSL_CERTIFICATE_REQUIRED 0x5800 |
Definition at line 26 of file ssl.h.
Referenced by ssl_parse_certificate_request(), and ssl_write_certificate().
#define ERR_SSL_CERTIFICATE_TOO_LARGE 0x5000 |
#define ERR_SSL_FEATURE_UNAVAILABLE 0x1000 |
Definition at line 17 of file ssl.h.
Referenced by ssl_decrypt_buf(), ssl_derive_keys(), ssl_encrypt_buf(), ssl_handshake(), ssl_parse_client_key_exchange(), ssl_parse_server_key_exchange(), ssl_write_client_key_exchange(), and ssl_write_server_key_exchange().
#define ERR_SSL_INVALID_MAC 0x1800 |
#define ERR_SSL_NO_CIPHER_CHOSEN 0x3800 |
Definition at line 22 of file ssl.h.
Referenced by ssl_parse_client_hello(), and ssl_parse_server_hello().
#define ERR_SSL_NO_SESSION_FOUND 0x4000 |
#define ERR_SSL_PRIVATE_KEY_REQUIRED 0x6000 |
#define ERR_SSL_UNEXPECTED_MESSAGE 0x7000 |
Definition at line 29 of file ssl.h.
Referenced by ssl_parse_certificate_request(), ssl_parse_server_hello(), ssl_parse_server_hello_done(), ssl_parse_server_key_exchange(), and ssl_read().
#define SSL3_EDH_RSA_DES_168_SHA 22 |
Definition at line 76 of file ssl.h.
Referenced by ssl_derive_keys(), ssl_parse_client_key_exchange(), ssl_parse_server_key_exchange(), ssl_write_client_key_exchange(), and ssl_write_server_key_exchange().
#define SSL3_RSA_DES_168_SHA 10 |
#define SSL3_RSA_RC4_128_MD5 4 |
#define SSL3_RSA_RC4_128_SHA 5 |
#define SSL_ALERT_CLOSE_NOTIFY 0 |
#define SSL_ALERT_NO_CERTIFICATE 41 |
#define SSL_ALERT_WARNING 1 |
#define SSL_BUFFER_LEN (SSL_MAX_CONTENT_LEN + 512) |
#define SSL_COMPRESS_NULL 0 |
Definition at line 54 of file ssl.h.
Referenced by ssl_parse_server_hello(), ssl_write_client_hello(), and ssl_write_server_hello().
#define SSL_EXPIRATION_TIME 86400 |
#define SSL_HS_CERTIFICATE 11 |
#define SSL_HS_CERTIFICATE_REQUEST 13 |
Definition at line 100 of file ssl.h.
Referenced by ssl_parse_certificate_request(), and ssl_write_certificate_request().
#define SSL_HS_CERTIFICATE_VERIFY 15 |
Definition at line 102 of file ssl.h.
Referenced by ssl_parse_certificate_verify(), and ssl_write_certificate_verify().
#define SSL_HS_CLIENT_HELLO 1 |
Definition at line 96 of file ssl.h.
Referenced by ssl_parse_client_hello(), and ssl_write_client_hello().
#define SSL_HS_CLIENT_KEY_EXCHANGE 16 |
Definition at line 103 of file ssl.h.
Referenced by ssl_parse_client_key_exchange(), and ssl_write_client_key_exchange().
#define SSL_HS_SERVER_HELLO 2 |
Definition at line 97 of file ssl.h.
Referenced by ssl_parse_server_hello(), and ssl_write_server_hello().
#define SSL_HS_SERVER_HELLO_DONE 14 |
Definition at line 101 of file ssl.h.
Referenced by ssl_parse_server_hello_done(), and ssl_write_server_hello_done().
#define SSL_HS_SERVER_KEY_EXCHANGE 12 |
Definition at line 99 of file ssl.h.
Referenced by ssl_parse_server_key_exchange(), and ssl_write_server_key_exchange().
#define SSL_IS_CLIENT 0 |
Definition at line 52 of file ssl.h.
Referenced by main(), ssl_derive_keys(), ssl_handshake(), and ssl_write_certificate().
#define SSL_IS_SERVER 1 |
#define SSL_MAX_CONTENT_LEN 16384 |
#define SSL_MSG_ALERT 21 |
#define SSL_MSG_APPLICATION_DATA 23 |
#define SSL_MSG_HANDSHAKE 22 |
Definition at line 87 of file ssl.h.
Referenced by ssl_parse_certificate_request(), ssl_parse_certificate_verify(), ssl_parse_client_hello(), ssl_parse_client_key_exchange(), ssl_parse_server_hello(), ssl_parse_server_hello_done(), ssl_parse_server_key_exchange(), ssl_write_certificate(), ssl_write_certificate_request(), ssl_write_certificate_verify(), ssl_write_client_hello(), ssl_write_client_key_exchange(), ssl_write_record(), ssl_write_server_hello(), ssl_write_server_hello_done(), and ssl_write_server_key_exchange().
#define SSL_SESSION_TBL_LEN 8192 |
#define SSL_VERIFY_NONE 0 |
#define SSL_VERIFY_REQUIRED 2 |
#define SSLV3_MAJOR_VERSION 3 |
Definition at line 47 of file ssl.h.
Referenced by ssl_parse_client_hello(), ssl_parse_server_hello(), and ssl_write_client_hello().
#define SSLV3_MINOR_VERSION 0 |
Definition at line 48 of file ssl.h.
Referenced by ssl_calc_verify(), ssl_decrypt_buf(), ssl_derive_keys(), ssl_encrypt_buf(), ssl_parse_client_key_exchange(), ssl_parse_server_hello(), ssl_write_certificate(), ssl_write_client_hello(), and ssl_write_client_key_exchange().
#define TLS10_MINOR_VERSION 1 |
Definition at line 49 of file ssl.h.
Referenced by ssl_parse_client_hello(), ssl_parse_server_hello(), and ssl_write_client_hello().
#define TLS1_EDH_RSA_AES_256_SHA 57 |
Definition at line 78 of file ssl.h.
Referenced by ssl_derive_keys(), ssl_parse_client_key_exchange(), ssl_parse_server_key_exchange(), ssl_write_client_key_exchange(), and ssl_write_server_key_exchange().
#define TLS1_RSA_AES_256_SHA 53 |
enum ssl_states |
int ssl_calc_verify | ( | ssl_context * | ssl, | |
unsigned char | hash[36] | |||
) |
Definition at line 326 of file ssl_tls.c.
References ssl_context::hs_md5, ssl_context::hs_sha1, ssl_context::master, md5(), md5_finish(), md5_starts(), md5_update(), ssl_context::minor_ver, sha1(), sha1_finish(), sha1_starts(), sha1_update(), and SSLV3_MINOR_VERSION.
Referenced by ssl_parse_certificate_verify(), and ssl_write_certificate_verify().
int ssl_client_start | ( | ssl_context * | ssl | ) |
Definition at line 438 of file ssl_cli.c.
References SSL_CERTIFICATE_REQUEST, SSL_CERTIFICATE_VERIFY, SSL_CLIENT_CERTIFICATE, SSL_CLIENT_CHANGE_CIPHER_SPEC, SSL_CLIENT_FINISHED, SSL_CLIENT_HELLO, SSL_CLIENT_KEY_EXCHANGE, ssl_flush_output(), SSL_HELLO_REQUEST, ssl_parse_certificate(), ssl_parse_certificate_request(), ssl_parse_change_cipher_spec(), ssl_parse_finished(), ssl_parse_server_hello(), ssl_parse_server_hello_done(), ssl_parse_server_key_exchange(), SSL_SERVER_CERTIFICATE, SSL_SERVER_CHANGE_CIPHER_SPEC, SSL_SERVER_FINISHED, SSL_SERVER_HELLO, SSL_SERVER_HELLO_DONE, SSL_SERVER_KEY_EXCHANGE, ssl_write_certificate(), ssl_write_certificate_verify(), ssl_write_change_cipher_spec(), ssl_write_client_hello(), ssl_write_client_key_exchange(), ssl_write_finished(), and ssl_context::state.
Referenced by ssl_handshake().
int ssl_close_notify | ( | ssl_context * | ssl | ) |
Notify the peer that the connection is being closed.
Definition at line 1450 of file ssl_tls.c.
References ssl_context::out_msg, ssl_context::out_msglen, ssl_context::out_msgtype, SSL_ALERT_CLOSE_NOTIFY, SSL_ALERT_WARNING, ssl_flush_output(), SSL_HANDSHAKE_OVER, SSL_MSG_ALERT, ssl_write_record(), and ssl_context::state.
Referenced by main().
int ssl_derive_keys | ( | ssl_context * | ssl | ) |
Definition at line 101 of file ssl_tls.c.
References aes_set_key(), arc4_setup(), ssl_context::cipher, ssl_context::ctx_dec, ssl_context::ctx_enc, ssl_context::ctxlen, des3_set_3keys(), ssl_context::endpoint, ERR_SSL_FEATURE_UNAVAILABLE, ssl_context::iv_dec, ssl_context::iv_enc, ssl_context::ivlen, ssl_context::keylen, ssl_context::mac_dec, ssl_context::mac_enc, ssl_context::maclen, ssl_context::master, md5(), md5_finish(), md5_starts(), md5_update(), ssl_context::minlen, ssl_context::minor_ver, ssl_context::pmslen, ssl_context::premaster, ssl_context::randbytes, ssl_context::resumed, sha1(), sha1_finish(), sha1_starts(), sha1_update(), SSL3_EDH_RSA_DES_168_SHA, SSL3_RSA_DES_168_SHA, SSL3_RSA_RC4_128_MD5, SSL3_RSA_RC4_128_SHA, SSL_IS_CLIENT, SSLV3_MINOR_VERSION, TLS1_EDH_RSA_AES_256_SHA, tls1_prf(), and TLS1_RSA_AES_256_SHA.
Referenced by ssl_parse_client_key_exchange(), ssl_parse_server_hello(), ssl_write_client_key_exchange(), and ssl_write_server_hello().
int ssl_flush_output | ( | ssl_context * | ssl | ) |
Definition at line 823 of file ssl_tls.c.
References net_send(), ssl_context::out_hdr, ssl_context::out_left, ssl_context::out_msglen, and ssl_context::write_fd.
Referenced by ssl_client_start(), ssl_close_notify(), and ssl_server_start().
void ssl_free | ( | ssl_context * | ssl | ) |
Free an SSL context.
Definition at line 1473 of file ssl_tls.c.
References ssl_context::ctx_dec, ssl_context::ctx_enc, ssl_context::ctxlen, ssl_context::dhm_ctx, dhm_free(), ssl_context::in_ctr, ssl_context::out_ctr, ssl_context::peer_cert, SSL_BUFFER_LEN, and x509_free_cert().
Referenced by main().
char* ssl_get_cipher_name | ( | ssl_context * | ssl | ) |
int ssl_get_verify_result | ( | ssl_context * | ssl | ) |
Return the result of the certificate verification.
Definition at line 1303 of file ssl_tls.c.
References ssl_context::verify_result.
Referenced by main().
int ssl_handshake | ( | ssl_context * | ssl | ) |
Perform the SSL handshake.
Definition at line 1369 of file ssl_tls.c.
References ssl_context::endpoint, ERR_SSL_FEATURE_UNAVAILABLE, ssl_client_start(), SSL_IS_CLIENT, SSL_IS_SERVER, and ssl_server_start().
Referenced by main(), ssl_read(), and ssl_write().
int ssl_init | ( | ssl_context * | ssl, | |
int | client_resume | |||
) |
Initialize the SSL context. If client_resume is not null, the session id and premaster secret are preserved (client-side only).
Definition at line 1199 of file ssl_tls.c.
References ssl_context::in_ctr, ssl_context::in_hdr, ssl_context::in_msg, ssl_context::master, ssl_context::out_ctr, ssl_context::out_hdr, ssl_context::out_msg, ssl_context::sessid, ssl_context::sidlen, and SSL_BUFFER_LEN.
Referenced by main().
int ssl_parse_certificate | ( | ssl_context * | ssl | ) |
int ssl_parse_change_cipher_spec | ( | ssl_context * | ssl | ) |
Definition at line 1028 of file ssl_tls.c.
Referenced by ssl_client_start(), and ssl_server_start().
int ssl_parse_finished | ( | ssl_context * | ssl | ) |
Definition at line 1154 of file ssl_tls.c.
Referenced by ssl_client_start(), and ssl_server_start().
int ssl_read | ( | ssl_context * | ssl, | |
unsigned char * | buf, | |||
int * | len | |||
) |
Read at most 'len' application data bytes.
Definition at line 1387 of file ssl_tls.c.
References ERR_SSL_UNEXPECTED_MESSAGE, ssl_context::in_msg, ssl_context::in_msglen, ssl_context::in_msgtype, ssl_context::in_offt, ssl_handshake(), SSL_MSG_APPLICATION_DATA, and ssl_read_record().
Referenced by main().
int ssl_read_record | ( | ssl_context * | ssl, | |
int | do_crypt | |||
) |
Definition at line 682 of file ssl_tls.c.
Referenced by ssl_parse_certificate_request(), ssl_parse_certificate_verify(), ssl_parse_client_key_exchange(), ssl_parse_server_hello(), ssl_parse_server_hello_done(), ssl_parse_server_key_exchange(), and ssl_read().
int ssl_server_start | ( | ssl_context * | ssl | ) |
Definition at line 663 of file ssl_srv.c.
References SSL_CERTIFICATE_REQUEST, SSL_CERTIFICATE_VERIFY, SSL_CLIENT_CERTIFICATE, SSL_CLIENT_CHANGE_CIPHER_SPEC, SSL_CLIENT_FINISHED, SSL_CLIENT_HELLO, SSL_CLIENT_KEY_EXCHANGE, ssl_flush_output(), SSL_HELLO_REQUEST, ssl_parse_certificate(), ssl_parse_certificate_verify(), ssl_parse_change_cipher_spec(), ssl_parse_client_hello(), ssl_parse_client_key_exchange(), ssl_parse_finished(), SSL_SERVER_CERTIFICATE, SSL_SERVER_CHANGE_CIPHER_SPEC, SSL_SERVER_FINISHED, SSL_SERVER_HELLO, SSL_SERVER_HELLO_DONE, SSL_SERVER_KEY_EXCHANGE, ssl_write_certificate(), ssl_write_certificate_request(), ssl_write_change_cipher_spec(), ssl_write_finished(), ssl_write_server_hello(), ssl_write_server_hello_done(), ssl_write_server_key_exchange(), and ssl_context::state.
Referenced by main(), and ssl_handshake().
void ssl_set_authmode | ( | ssl_context * | ssl, | |
int | authmode | |||
) |
Set the certificate verification mode.
mode | can be: |
SSL_VERIFY_OPTIONAL: peer certificate is checked, however the handshake continues even if verification failed; you may want to check ssl->verify_result after.
SSL_VERIFY_REQUIRED: peer *must* present a valid certificate, handshake is aborted if verification failed.
Definition at line 1249 of file ssl_tls.c.
Referenced by main().
void ssl_set_ca_chain | ( | ssl_context * | ssl, | |
x509_cert * | ca, | |||
char * | cn | |||
) |
void ssl_set_ciphlist | ( | ssl_context * | ssl, | |
int * | ciphers | |||
) |
int ssl_set_dhm_vals | ( | ssl_context * | ssl, | |
char * | dhm_P, | |||
char * | dhm_G | |||
) |
void ssl_set_endpoint | ( | ssl_context * | ssl, | |
int | endpoint | |||
) |
Set the current endpoint type, SSL_IS_CLIENT or SSL_IS_SERVER.
Definition at line 1244 of file ssl_tls.c.
References ssl_context::endpoint.
Referenced by main().
void ssl_set_io_files | ( | ssl_context * | ssl, | |
int | read_fd, | |||
int | write_fd | |||
) |
void ssl_set_rng_func | ( | ssl_context * | ssl, | |
int(*)(void *) | rng_f, | |||
void * | rng_d | |||
) |
void ssl_set_rsa_cert | ( | ssl_context * | ssl, | |
x509_cert * | own_cert, | |||
rsa_context * | own_key | |||
) |
void ssl_set_sidtable | ( | ssl_context * | ssl, | |
unsigned char * | sidtable | |||
) |
int ssl_write | ( | ssl_context * | ssl, | |
unsigned char * | buf, | |||
int | len | |||
) |
Write 'len' application data bytes.
Definition at line 1422 of file ssl_tls.c.
References ssl_context::out_msg, ssl_context::out_msglen, ssl_context::out_msgtype, ssl_context::out_uoff, ssl_handshake(), SSL_MAX_CONTENT_LEN, SSL_MSG_APPLICATION_DATA, and ssl_write_record().
Referenced by main().
int ssl_write_certificate | ( | ssl_context * | ssl | ) |
Definition at line 843 of file ssl_tls.c.
References ssl_context::client_auth, ssl_context::endpoint, ERR_SSL_CERTIFICATE_REQUIRED, ERR_SSL_CERTIFICATE_TOO_LARGE, _x509_buf::len, ssl_context::minor_ver, _x509_cert::next, ssl_context::out_msg, ssl_context::out_msglen, ssl_context::out_msgtype, ssl_context::own_cert, _x509_buf::p, _x509_cert::raw, SSL_ALERT_NO_CERTIFICATE, SSL_ALERT_WARNING, SSL_HS_CERTIFICATE, SSL_IS_CLIENT, SSL_MAX_CONTENT_LEN, SSL_MSG_ALERT, SSL_MSG_HANDSHAKE, ssl_write_record(), SSLV3_MINOR_VERSION, and ssl_context::state.
Referenced by ssl_client_start(), and ssl_server_start().
int ssl_write_change_cipher_spec | ( | ssl_context * | ssl | ) |
Definition at line 1019 of file ssl_tls.c.
Referenced by ssl_client_start(), and ssl_server_start().
int ssl_write_finished | ( | ssl_context * | ssl | ) |
Definition at line 1117 of file ssl_tls.c.
Referenced by ssl_client_start(), and ssl_server_start().
int ssl_write_record | ( | ssl_context * | ssl, | |
int | do_crypt | |||
) |
Definition at line 645 of file ssl_tls.c.
References ssl_context::hs_md5, ssl_context::hs_sha1, ssl_context::major_ver, md5_update(), ssl_context::minor_ver, net_send(), ssl_context::out_hdr, ssl_context::out_left, ssl_context::out_msg, ssl_context::out_msglen, ssl_context::out_msgtype, sha1_update(), ssl_encrypt_buf(), SSL_MSG_HANDSHAKE, and ssl_context::write_fd.
Referenced by ssl_close_notify(), ssl_write(), ssl_write_certificate(), ssl_write_certificate_request(), ssl_write_certificate_verify(), ssl_write_client_hello(), ssl_write_client_key_exchange(), ssl_write_server_hello(), ssl_write_server_hello_done(), and ssl_write_server_key_exchange().