Skip to content

Commit b09b8a4

Browse files
committed
deimos.openssl.ssl: Update SSL state declarations
1 parent 3c50a39 commit b09b8a4

File tree

1 file changed

+60
-8
lines changed

1 file changed

+60
-8
lines changed

deimos/openssl/ssl.d

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,60 @@ auto SSL_SESSION_get_app_data()(const(SSL_SESSION)* s) { return (SSL_SESSION_get
14421442
auto SSL_CTX_get_app_data()(const(SSL_CTX)* ctx) { return (SSL_CTX_get_ex_data(ctx,0)); }
14431443
auto SSL_CTX_set_app_data()(SSL_CTX* ctx, char* arg) { return (SSL_CTX_set_ex_data(ctx,0,arg)); }
14441444

1445+
/*
1446+
* The valid handshake states (one for each type message sent and one for each
1447+
* type of message received). There are also two "special" states:
1448+
* TLS = TLS or DTLS state
1449+
* DTLS = DTLS specific state
1450+
* CR/SR = Client Read/Server Read
1451+
* CW/SW = Client Write/Server Write
1452+
*
1453+
* The "special" states are:
1454+
* TLS_ST_BEFORE = No handshake has been initiated yet
1455+
* TLS_ST_OK = A handshake has been successfully completed
1456+
*/
1457+
enum
1458+
{
1459+
TLS_ST_BEFORE,
1460+
TLS_ST_OK,
1461+
DTLS_ST_CR_HELLO_VERIFY_REQUEST,
1462+
TLS_ST_CR_SRVR_HELLO,
1463+
TLS_ST_CR_CERT,
1464+
TLS_ST_CR_CERT_STATUS,
1465+
TLS_ST_CR_KEY_EXCH,
1466+
TLS_ST_CR_CERT_REQ,
1467+
TLS_ST_CR_SRVR_DONE,
1468+
TLS_ST_CR_SESSION_TICKET,
1469+
TLS_ST_CR_CHANGE,
1470+
TLS_ST_CR_FINISHED,
1471+
TLS_ST_CW_CLNT_HELLO,
1472+
TLS_ST_CW_CERT,
1473+
TLS_ST_CW_KEY_EXCH,
1474+
TLS_ST_CW_CERT_VRFY,
1475+
TLS_ST_CW_CHANGE,
1476+
TLS_ST_CW_NEXT_PROTO,
1477+
TLS_ST_CW_FINISHED,
1478+
TLS_ST_SW_HELLO_REQ,
1479+
TLS_ST_SR_CLNT_HELLO,
1480+
DTLS_ST_SW_HELLO_VERIFY_REQUEST,
1481+
TLS_ST_SW_SRVR_HELLO,
1482+
TLS_ST_SW_CERT,
1483+
TLS_ST_SW_KEY_EXCH,
1484+
TLS_ST_SW_CERT_REQ,
1485+
TLS_ST_SW_SRVR_DONE,
1486+
TLS_ST_SR_CERT,
1487+
TLS_ST_SR_KEY_EXCH,
1488+
TLS_ST_SR_CERT_VRFY,
1489+
TLS_ST_SR_NEXT_PROTO,
1490+
TLS_ST_SR_CHANGE,
1491+
TLS_ST_SR_FINISHED,
1492+
TLS_ST_SW_SESSION_TICKET,
1493+
TLS_ST_SW_CERT_STATUS,
1494+
TLS_ST_SW_CHANGE,
1495+
TLS_ST_SW_FINISHED
1496+
}
1497+
alias OSSL_HANDSHAKE_STATE = typeof(TLS_ST_BEFORE);
1498+
14451499
/* The following are the possible values for ssl->state are are
14461500
* used to indicate where we are up to in the SSL connection establishment.
14471501
* The macros that follow are about the only things you should need to use
@@ -1472,12 +1526,11 @@ enum SSL_CB_HANDSHAKE_START = 0x10;
14721526
enum SSL_CB_HANDSHAKE_DONE = 0x20;
14731527

14741528
/* Is the SSL_connection established? */
1475-
auto SSL_get_state()(const(SSL)* a) { return SSL_state(a); }
1476-
auto SSL_is_init_finished()(const(SSL)* a) { return (SSL_state(a) == SSL_ST_OK); }
1477-
auto SSL_in_init()(const(SSL)* a) { return (SSL_state(a)&SSL_ST_INIT); }
1478-
auto SSL_in_before()(const(SSL)* a) { return (SSL_state(a)&SSL_ST_BEFORE); }
1479-
auto SSL_in_connect_init()(const(SSL)* a) { return (SSL_state(a)&SSL_ST_CONNECT); }
1480-
auto SSL_in_accept_init()(const(SSL)* a) { return (SSL_state(a)&SSL_ST_ACCEPT); }
1529+
bool SSL_in_connect_init()(const(SSL)* a) { return SSL_in_init(a) && !SSL_is_server(a); }
1530+
bool SSL_in_accept_init()(const(SSL)* a) { return SSL_in_init(a) && SSL_is_server(a); }
1531+
int SSL_in_init(SSL *s);
1532+
int SSL_in_before(SSL *s);
1533+
int SSL_is_init_finished(SSL *s);
14811534

14821535
/* The following 2 states are kept in ssl->rstate when reads fail,
14831536
* you should not need these */
@@ -2023,8 +2076,7 @@ SSL_CTX* SSL_set_SSL_CTX(SSL* ssl, SSL_CTX* ctx);
20232076
void SSL_set_info_callback(SSL* ssl,
20242077
ExternC!(void function(const(SSL)* ssl,int type,int val)) cb);
20252078
ExternC!(void function(const(SSL)* ssl,int type,int val)) SSL_get_info_callback(const(SSL)* ssl);
2026-
int SSL_state(const(SSL)* ssl);
2027-
void SSL_set_state(SSL *ssl, int state);
2079+
OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl);
20282080

20292081
void SSL_set_verify_result(SSL* ssl,c_long v);
20302082
c_long SSL_get_verify_result(const(SSL)* ssl);

0 commit comments

Comments
 (0)