Lines Matching defs:peer
732 static int create_peer(PEER *peer, SSL_CTX *ctx)
743 peer->ssl = ssl;
744 peer->write_buf = write_buf;
745 peer->read_buf = read_buf;
746 peer->write_buf_len = peer->read_buf_len = peer_buffer_size;
755 static void peer_free_data(PEER *peer)
757 SSL_free(peer->ssl);
758 OPENSSL_free(peer->write_buf);
759 OPENSSL_free(peer->read_buf);
766 static void do_handshake_step(PEER *peer)
768 if (!TEST_int_eq(peer->status, PEER_RETRY)) {
769 peer->status = PEER_TEST_FAILURE;
771 int ret = SSL_do_handshake(peer->ssl);
774 peer->status = PEER_SUCCESS;
776 peer->status = PEER_ERROR;
778 int error = SSL_get_error(peer->ssl, ret);
783 peer->status = PEER_ERROR;
797 static void do_app_data_step(PEER *peer)
801 if (!TEST_int_eq(peer->status, PEER_RETRY)) {
802 peer->status = PEER_TEST_FAILURE;
807 while (ret > 0 && peer->bytes_to_read) {
808 ret = SSL_read(peer->ssl, peer->read_buf, peer->read_buf_len);
810 if (!TEST_int_le(ret, peer->bytes_to_read)) {
811 peer->status = PEER_TEST_FAILURE;
814 peer->bytes_to_read -= ret;
816 peer->status = PEER_ERROR;
819 int error = SSL_get_error(peer->ssl, ret);
821 peer->status = PEER_ERROR;
828 write_bytes = peer->bytes_to_write < peer->write_buf_len ? peer->bytes_to_write :
829 peer->write_buf_len;
831 ret = SSL_write(peer->ssl, peer->write_buf, write_bytes);
835 peer->status = PEER_TEST_FAILURE;
838 peer->bytes_to_write -= ret;
844 peer->status = PEER_ERROR;
855 if (peer->bytes_to_write == 0 && peer->bytes_to_read == 0) {
856 peer->status = PEER_SUCCESS;
860 static void do_reneg_setup_step(const SSL_TEST_CTX *test_ctx, PEER *peer)
865 if (peer->status == PEER_SUCCESS) {
871 peer->status = PEER_RETRY;
872 do_handshake_step(peer);
876 if (!TEST_int_eq(peer->status, PEER_RETRY)
887 peer->status = PEER_TEST_FAILURE;
892 peer->bytes_to_write = peer->bytes_to_read = test_ctx->app_data_size;
894 /* Check if we are the peer that is going to initiate */
896 && SSL_is_server(peer->ssl))
898 && !SSL_is_server(peer->ssl))) {
903 if (!SSL_renegotiate_pending(peer->ssl)) {
909 if (SSL_is_server(peer->ssl)) {
910 ret = SSL_renegotiate(peer->ssl);
915 SSL_set_options(peer->ssl, SSL_OP_NO_EXTENDED_MASTER_SECRET);
919 if (!SSL_set_cipher_list(peer->ssl,
921 peer->status = PEER_ERROR;
927 ret = SSL_renegotiate(peer->ssl);
929 ret = SSL_renegotiate_abbreviated(peer->ssl);
932 peer->status = PEER_ERROR;
935 do_handshake_step(peer);
937 * If status is PEER_RETRY it means we're waiting on the peer to
946 if (peer->status == PEER_RETRY)
947 peer->status = PEER_SUCCESS;
948 else if (peer->status == PEER_SUCCESS)
949 peer->status = PEER_RETRY;
955 if (SSL_is_server(peer->ssl)
958 peer->status = PEER_SUCCESS;
962 ret = SSL_key_update(peer->ssl, test_ctx->key_update_type);
964 peer->status = PEER_ERROR;
967 do_handshake_step(peer);
972 if (peer->status != PEER_SUCCESS)
973 peer->status = PEER_ERROR;
976 if (SSL_is_server(peer->ssl)) {
979 peer->ssl->post_handshake_auth = SSL_PHA_EXT_RECEIVED;
980 ret = SSL_verify_client_post_handshake(peer->ssl);
982 peer->status = PEER_ERROR;
986 do_handshake_step(peer);
991 if (peer->status != PEER_SUCCESS)
992 peer->status = PEER_ERROR;
1001 ret = SSL_read(peer->ssl, &buf, sizeof(buf));
1007 peer->status = PEER_ERROR;
1010 int error = SSL_get_error(peer->ssl, ret);
1012 peer->status = PEER_ERROR;
1016 if (!SSL_in_init(peer->ssl))
1020 peer->status = PEER_SUCCESS;
1039 static void do_shutdown_step(PEER *peer)
1043 if (!TEST_int_eq(peer->status, PEER_RETRY)) {
1044 peer->status = PEER_TEST_FAILURE;
1047 ret = SSL_shutdown(peer->ssl);
1050 peer->status = PEER_SUCCESS;
1052 int error = SSL_get_error(peer->ssl, ret);
1055 peer->status = PEER_ERROR;
1119 static void do_connect_step(const SSL_TEST_CTX *test_ctx, PEER *peer,
1124 do_handshake_step(peer);
1127 do_app_data_step(peer);
1130 do_reneg_setup_step(test_ctx, peer);
1133 do_handshake_step(peer);
1136 do_app_data_step(peer);
1139 do_shutdown_step(peer);
1162 * last_status: the status of the peer to have acted last.
1163 * previous_status: the status of the peer that didn't act last.
1187 /* Let the first peer finish. */
1191 * Second peer succeeded despite the fact that the first peer
1209 /* First peer succeeded but second peer errored. */
1212 /* We errored; let the peer finish. */
1527 * We use non-blocking BIOs, so whenever one peer blocks for read, it
1528 * returns PEER_RETRY to indicate that it's the other peer's turn to write.
1529 * The handshake succeeds once both peers have succeeded. If one peer
1530 * errors out, we also let the other peer retry (and presumably fail).
1582 * With "real" sockets we only swap to processing the peer