Lines Matching defs:peer
760 static int create_peer(PEER *peer, SSL_CTX *ctx)
771 peer->ssl = ssl;
772 peer->write_buf = write_buf;
773 peer->read_buf = read_buf;
774 peer->write_buf_len = peer->read_buf_len = peer_buffer_size;
783 static void peer_free_data(PEER *peer)
785 SSL_free(peer->ssl);
786 OPENSSL_free(peer->write_buf);
787 OPENSSL_free(peer->read_buf);
794 static void do_handshake_step(PEER *peer)
796 if (!TEST_int_eq(peer->status, PEER_RETRY)) {
797 peer->status = PEER_TEST_FAILURE;
799 int ret = SSL_do_handshake(peer->ssl);
802 peer->status = PEER_SUCCESS;
804 peer->status = PEER_ERROR;
806 int error = SSL_get_error(peer->ssl, ret);
809 peer->status = PEER_ERROR;
823 static void do_app_data_step(PEER *peer)
827 if (!TEST_int_eq(peer->status, PEER_RETRY)) {
828 peer->status = PEER_TEST_FAILURE;
833 while (ret > 0 && peer->bytes_to_read) {
834 ret = SSL_read(peer->ssl, peer->read_buf, peer->read_buf_len);
836 if (!TEST_int_le(ret, peer->bytes_to_read)) {
837 peer->status = PEER_TEST_FAILURE;
840 peer->bytes_to_read -= ret;
842 peer->status = PEER_ERROR;
845 int error = SSL_get_error(peer->ssl, ret);
847 peer->status = PEER_ERROR;
854 write_bytes = peer->bytes_to_write < peer->write_buf_len ? peer->bytes_to_write :
855 peer->write_buf_len;
857 ret = SSL_write(peer->ssl, peer->write_buf, write_bytes);
861 peer->status = PEER_TEST_FAILURE;
864 peer->bytes_to_write -= ret;
870 peer->status = PEER_ERROR;
881 if (!peer->bytes_to_write && !peer->bytes_to_read) {
882 peer->status = PEER_SUCCESS;
886 static void do_reneg_setup_step(const SSL_TEST_CTX *test_ctx, PEER *peer)
891 if (peer->status == PEER_SUCCESS) {
897 peer->status = PEER_RETRY;
898 do_handshake_step(peer);
902 if (!TEST_int_eq(peer->status, PEER_RETRY)
913 peer->status = PEER_TEST_FAILURE;
918 peer->bytes_to_write = peer->bytes_to_read = test_ctx->app_data_size;
920 /* Check if we are the peer that is going to initiate */
922 && SSL_is_server(peer->ssl))
924 && !SSL_is_server(peer->ssl))) {
929 if (!SSL_renegotiate_pending(peer->ssl)) {
935 if (SSL_is_server(peer->ssl)) {
936 ret = SSL_renegotiate(peer->ssl);
939 if (!SSL_set_cipher_list(peer->ssl,
941 peer->status = PEER_ERROR;
944 ret = SSL_renegotiate(peer->ssl);
946 ret = SSL_renegotiate_abbreviated(peer->ssl);
950 peer->status = PEER_ERROR;
953 do_handshake_step(peer);
955 * If status is PEER_RETRY it means we're waiting on the peer to
964 if (peer->status == PEER_RETRY)
965 peer->status = PEER_SUCCESS;
966 else if (peer->status == PEER_SUCCESS)
967 peer->status = PEER_RETRY;
973 if (SSL_is_server(peer->ssl)
976 peer->status = PEER_SUCCESS;
980 ret = SSL_key_update(peer->ssl, test_ctx->key_update_type);
982 peer->status = PEER_ERROR;
985 do_handshake_step(peer);
990 if (peer->status != PEER_SUCCESS)
991 peer->status = PEER_ERROR;
994 if (SSL_is_server(peer->ssl)) {
997 peer->ssl->post_handshake_auth = SSL_PHA_EXT_RECEIVED;
998 ret = SSL_verify_client_post_handshake(peer->ssl);
1000 peer->status = PEER_ERROR;
1004 do_handshake_step(peer);
1009 if (peer->status != PEER_SUCCESS)
1010 peer->status = PEER_ERROR;
1019 ret = SSL_read(peer->ssl, &buf, sizeof(buf));
1025 peer->status = PEER_ERROR;
1028 int error = SSL_get_error(peer->ssl, ret);
1030 peer->status = PEER_ERROR;
1034 if (!SSL_in_init(peer->ssl))
1038 peer->status = PEER_SUCCESS;
1057 static void do_shutdown_step(PEER *peer)
1061 if (!TEST_int_eq(peer->status, PEER_RETRY)) {
1062 peer->status = PEER_TEST_FAILURE;
1065 ret = SSL_shutdown(peer->ssl);
1068 peer->status = PEER_SUCCESS;
1070 int error = SSL_get_error(peer->ssl, ret);
1073 peer->status = PEER_ERROR;
1137 static void do_connect_step(const SSL_TEST_CTX *test_ctx, PEER *peer,
1142 do_handshake_step(peer);
1145 do_app_data_step(peer);
1148 do_reneg_setup_step(test_ctx, peer);
1151 do_handshake_step(peer);
1154 do_app_data_step(peer);
1157 do_shutdown_step(peer);
1180 * last_status: the status of the peer to have acted last.
1181 * previous_status: the status of the peer that didn't act last.
1205 /* Let the first peer finish. */
1209 * Second peer succeeded despite the fact that the first peer
1228 * First peer succeeded but second peer errored.
1230 * application data?) to ensure the first peer receives the
1236 /* We errored; let the peer finish. */
1554 * We use non-blocking BIOs, so whenever one peer blocks for read, it
1555 * returns PEER_RETRY to indicate that it's the other peer's turn to write.
1556 * The handshake succeeds once both peers have succeeded. If one peer
1557 * errors out, we also let the other peer retry (and presumably fail).
1609 * With "real" sockets we only swap to processing the peer