@@ -1442,6 +1442,60 @@ auto SSL_SESSION_get_app_data()(const(SSL_SESSION)* s) { return (SSL_SESSION_get
1442
1442
auto SSL_CTX_get_app_data ()(const (SSL_CTX )* ctx) { return (SSL_CTX_get_ex_data(ctx,0 )); }
1443
1443
auto SSL_CTX_set_app_data ()(SSL_CTX * ctx, char * arg) { return (SSL_CTX_set_ex_data(ctx,0 ,arg)); }
1444
1444
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
+
1445
1499
/* The following are the possible values for ssl->state are are
1446
1500
* used to indicate where we are up to in the SSL connection establishment.
1447
1501
* The macros that follow are about the only things you should need to use
@@ -1472,12 +1526,11 @@ enum SSL_CB_HANDSHAKE_START = 0x10;
1472
1526
enum SSL_CB_HANDSHAKE_DONE = 0x20 ;
1473
1527
1474
1528
/* 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);
1481
1534
1482
1535
/* The following 2 states are kept in ssl->rstate when reads fail,
1483
1536
* you should not need these */
@@ -2023,8 +2076,7 @@ SSL_CTX* SSL_set_SSL_CTX(SSL* ssl, SSL_CTX* ctx);
2023
2076
void SSL_set_info_callback (SSL * ssl,
2024
2077
ExternC! (void function (const (SSL )* ssl,int type,int val)) cb);
2025
2078
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);
2028
2080
2029
2081
void SSL_set_verify_result (SSL * ssl,c_long v);
2030
2082
c_long SSL_get_verify_result (const (SSL )* ssl);
0 commit comments