diff --git a/ci/build_picotls.ps1 b/ci/build_picotls.ps1 index 5f33da69e5c91aa29912c0411ae6f18aeaa60551..15d269a359065ea15ad3cec2486a6612109e9167 100644 --- a/ci/build_picotls.ps1 +++ b/ci/build_picotls.ps1 @@ -1,5 +1,5 @@ # Build at a known-good commit -$COMMIT_ID="8443c09c0f091482679e0b32c4f238928b7f5c1e" +$COMMIT_ID="241f684346d3be4f5ba8dc46010e9f9486a79991" # Match expectations of picotlsvs project. foreach ($dir in "$Env:OPENSSLDIR","$Env:OPENSSL64DIR") { diff --git a/ci/build_picotls.sh b/ci/build_picotls.sh index 4b9accd0c5bcbfe8b2b0e6d95f9a552680fd2c5b..ca4b51daa57ef2e98899957714fec47f65724504 100755 --- a/ci/build_picotls.sh +++ b/ci/build_picotls.sh @@ -2,7 +2,7 @@ #build last picotls master (for Travis) # Build at a known-good commit -COMMIT_ID=8443c09c0f091482679e0b32c4f238928b7f5c1e +COMMIT_ID=241f684346d3be4f5ba8dc46010e9f9486a79991 cd .. git clone --branch master --single-branch --shallow-submodules --recurse-submodules --no-tags https://github.com/h2o/picotls diff --git a/picoquic/frames.c b/picoquic/frames.c index 352522400b268c902eb98ca67130abde83185349..99fa6c1ac31f1bae8dcd0e59182fe7eb59bcca74 100644 --- a/picoquic/frames.c +++ b/picoquic/frames.c @@ -397,9 +397,6 @@ int picoquic_prepare_new_connection_id_frame(picoquic_cnx_t * cnx, picoquic_path int ret = 0; size_t byte_index = 0; size_t ls; - int is_draft_14 = ( - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); *consumed = 0; @@ -408,27 +405,13 @@ int picoquic_prepare_new_connection_id_frame(picoquic_cnx_t * cnx, picoquic_path ret = PICOQUIC_ERROR_FRAME_BUFFER_TOO_SMALL; } else { bytes[byte_index++] = picoquic_frame_type_new_connection_id; + bytes[byte_index++] = path_x->local_cnxid.id_len; + ls = picoquic_varint_encode(bytes + byte_index, bytes_max - byte_index, + path_x->path_sequence); + byte_index += ls; - if (is_draft_14) { - ls = picoquic_varint_encode(bytes + byte_index, bytes_max - byte_index, - path_x->path_sequence); - byte_index += ls; - - if (ls == 0) { - ret = PICOQUIC_ERROR_FRAME_BUFFER_TOO_SMALL; - } else { - bytes[byte_index++] = path_x->local_cnxid.id_len; - } - } - else { - bytes[byte_index++] = path_x->local_cnxid.id_len; - ls = picoquic_varint_encode(bytes + byte_index, bytes_max - byte_index, - path_x->path_sequence); - byte_index += ls; - - if (ls == 0) { - ret = PICOQUIC_ERROR_FRAME_BUFFER_TOO_SMALL; - } + if (ls == 0) { + ret = PICOQUIC_ERROR_FRAME_BUFFER_TOO_SMALL; } if (ret == 0) { @@ -450,19 +433,12 @@ int picoquic_prepare_new_connection_id_frame(picoquic_cnx_t * cnx, picoquic_path return ret; } -uint8_t* picoquic_skip_new_connection_id_frame(uint8_t* bytes, const uint8_t* bytes_max, int is_draft_14) +uint8_t* picoquic_skip_new_connection_id_frame(uint8_t* bytes, const uint8_t* bytes_max) { uint8_t cid_length = 0; - - if (is_draft_14) { - if ((bytes = picoquic_frames_varint_skip(bytes + 1, bytes_max)) != NULL) { - bytes = picoquic_frames_uint8_decode(bytes, bytes_max, &cid_length); - } - } - else { - if ((bytes = picoquic_frames_uint8_decode(bytes + 1, bytes_max, &cid_length)) != NULL) { - bytes = picoquic_frames_varint_skip(bytes, bytes_max); - } + + if ((bytes = picoquic_frames_uint8_decode(bytes + 1, bytes_max, &cid_length)) != NULL) { + bytes = picoquic_frames_varint_skip(bytes, bytes_max); } if (bytes != NULL) { @@ -472,7 +448,7 @@ uint8_t* picoquic_skip_new_connection_id_frame(uint8_t* bytes, const uint8_t* by return bytes; } -uint8_t* picoquic_decode_new_connection_id_frame(picoquic_cnx_t* cnx, uint8_t* bytes, const uint8_t* bytes_max, int is_draft_14) +uint8_t* picoquic_decode_new_connection_id_frame(picoquic_cnx_t* cnx, uint8_t* bytes, const uint8_t* bytes_max) { /* store the connection ID in order to support migration. */ uint64_t sequence = 0; @@ -480,15 +456,8 @@ uint8_t* picoquic_decode_new_connection_id_frame(picoquic_cnx_t* cnx, uint8_t* b uint8_t * cnxid_bytes = NULL; uint8_t * secret_bytes = NULL; - if (is_draft_14) { - if ((bytes = picoquic_frames_varint_decode(bytes + 1, bytes_max, &sequence)) != NULL) { - bytes = picoquic_frames_uint8_decode(bytes, bytes_max, &cid_length); - } - } - else { - if ((bytes = picoquic_frames_uint8_decode(bytes + 1, bytes_max, &cid_length)) != NULL) { - bytes = picoquic_frames_varint_decode(bytes, bytes_max, &sequence); - } + if ((bytes = picoquic_frames_uint8_decode(bytes + 1, bytes_max, &cid_length)) != NULL) { + bytes = picoquic_frames_varint_decode(bytes, bytes_max, &sequence); } if (bytes != NULL) { @@ -551,12 +520,6 @@ int picoquic_queue_retire_connection_id_frame(picoquic_cnx_t * cnx, uint64_t seq { size_t consumed = 0; uint8_t frame_buffer[258]; - - if (picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION) { - return 0; - } - int ret = picoquic_prepare_retire_connection_id_frame(sequence, frame_buffer, sizeof(frame_buffer), &consumed); if (ret == 0 && consumed > 0) { @@ -1617,7 +1580,7 @@ static int picoquic_process_ack_of_stream_frame(picoquic_cnx_t* cnx, uint8_t* by return ret; } -void picoquic_process_possible_ack_of_ack_frame(picoquic_cnx_t* cnx, picoquic_packet_t* p, int is_draft_14) +void picoquic_process_possible_ack_of_ack_frame(picoquic_cnx_t* cnx, picoquic_packet_t* p) { int ret = 0; size_t byte_index; @@ -1644,7 +1607,7 @@ void picoquic_process_possible_ack_of_ack_frame(picoquic_cnx_t* cnx, picoquic_pa byte_index += frame_length; } else { ret = picoquic_skip_frame(&p->bytes[byte_index], - p->length - byte_index, &frame_length, &frame_is_pure_ack, is_draft_14); + p->length - byte_index, &frame_length, &frame_is_pure_ack); byte_index += frame_length; } } @@ -1681,9 +1644,7 @@ static int picoquic_process_ack_range( } } /* If the packet contained an ACK frame, perform the ACK of ACK pruning logic */ - picoquic_process_possible_ack_of_ack_frame(cnx, p, - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); + picoquic_process_possible_ack_of_ack_frame(cnx, p); (void)picoquic_dequeue_retransmit_packet(cnx, p, 1); p = next; @@ -1701,7 +1662,7 @@ static int picoquic_process_ack_range( } uint8_t* picoquic_decode_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint8_t* bytes, - const uint8_t* bytes_max, uint64_t current_time, int epoch, int is_ecn, int is_draft_14) + const uint8_t* bytes_max, uint64_t current_time, int epoch, int is_ecn) { uint64_t num_block; uint64_t largest; @@ -1711,8 +1672,7 @@ uint8_t* picoquic_decode_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint8_t* bytes uint64_t ecnx3[3] = { 0, 0, 0 }; uint8_t first_byte = bytes[0]; - if (picoquic_parse_ack_header(bytes, bytes_max-bytes, &num_block, - (is_ecn && is_draft_14)? ecnx3:NULL, + if (picoquic_parse_ack_header(bytes, bytes_max-bytes, &num_block, NULL, &largest, &ack_delay, &consumed, cnx->remote_parameters.ack_delay_exponent) != 0) { bytes = NULL; @@ -1780,7 +1740,7 @@ uint8_t* picoquic_decode_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint8_t* bytes } } - if (bytes != 0 && is_ecn && !is_draft_14) { + if (bytes != 0 && is_ecn) { for (int ecnx = 0; bytes != NULL && ecnx < 3; ecnx++) { bytes = picoquic_frames_varint_decode(bytes, bytes_max, &ecnx3[ecnx]); } @@ -1798,15 +1758,13 @@ uint8_t* picoquic_decode_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint8_t* bytes uint8_t* picoquic_decode_ack_frame(picoquic_cnx_t* cnx, uint8_t* bytes, const uint8_t* bytes_max, uint64_t current_time, int epoch) { - return picoquic_decode_ack_frame_maybe_ecn(cnx, bytes, bytes_max, current_time, epoch, 0, 0); + return picoquic_decode_ack_frame_maybe_ecn(cnx, bytes, bytes_max, current_time, epoch, 0); } uint8_t* picoquic_decode_ack_ecn_frame(picoquic_cnx_t* cnx, uint8_t* bytes, const uint8_t* bytes_max, uint64_t current_time, int epoch) { - return picoquic_decode_ack_frame_maybe_ecn(cnx, bytes, bytes_max, current_time, epoch, 1, - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); + return picoquic_decode_ack_frame_maybe_ecn(cnx, bytes, bytes_max, current_time, epoch, 1); } static int encode_ecn_block(picoquic_cnx_t* cnx, uint8_t* bytes, size_t bytes_max, size_t* byte_index) @@ -1852,11 +1810,7 @@ int picoquic_prepare_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint64_t current_t uint64_t ack_gap = 0; uint64_t lowest_acknowledged = 0; size_t num_block_index = 0; - int is_draft_14 = (picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); - uint8_t ack_type_byte = (is_draft_14) ? - ((is_ecn) ? picoquic_frame_type_ack_ecn_old : picoquic_frame_type_ack_old) : - ((is_ecn) ? picoquic_frame_type_ack_ecn : picoquic_frame_type_ack); + uint8_t ack_type_byte = ((is_ecn) ? picoquic_frame_type_ack_ecn : picoquic_frame_type_ack); /* Check that there is enough room in the packet, and something to acknowledge */ if (pkt_ctx->first_sack_item.start_of_sack_range == (uint64_t)((int64_t)-1)) { @@ -1887,13 +1841,6 @@ int picoquic_prepare_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint64_t current_t byte_index += l_delay; } - if (is_ecn && is_draft_14) { - ret = encode_ecn_block(cnx, bytes, bytes_max, &byte_index); - if (ret != 0) { - *consumed = 0; - } - } - if (ret == 0) { /* Reserve one byte for the number of blocks */ num_block_index = byte_index; @@ -1951,7 +1898,7 @@ int picoquic_prepare_ack_frame_maybe_ecn(picoquic_cnx_t* cnx, uint64_t current_t *consumed = byte_index; } - if (ret == 0 && is_ecn && !is_draft_14) { + if (ret == 0 && is_ecn) { ret = encode_ecn_block(cnx, bytes, bytes_max, &byte_index); if (ret != 0) { *consumed = 0; @@ -2464,8 +2411,6 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, uint8_ int ack_needed = 0; picoquic_packet_context_enum pc = picoquic_context_from_epoch(epoch); picoquic_packet_context_t * pkt_ctx = &cnx->pkt_ctx[pc]; - int is_draft_14 = (picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); while (bytes != NULL && bytes < bytes_max) { uint8_t first_byte = bytes[0]; @@ -2481,8 +2426,7 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, uint8_ bytes = picoquic_decode_stream_frame(cnx, bytes, bytes_max, current_time); ack_needed = 1; - } else if ((!is_draft_14 && first_byte == picoquic_frame_type_ack) || - (is_draft_14 && first_byte == picoquic_frame_type_ack_old)) { + } else if (first_byte == picoquic_frame_type_ack) { if (epoch == 1) { DBG_PRINTF("Ack frame (0x%x) not expected in 0-RTT packet", first_byte); picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_PROTOCOL_VIOLATION, first_byte); @@ -2490,8 +2434,7 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, uint8_ break; } bytes = picoquic_decode_ack_frame(cnx, bytes, bytes_max, current_time, epoch); - } else if ((!is_draft_14 && first_byte == picoquic_frame_type_ack_ecn) || - (is_draft_14 && first_byte == picoquic_frame_type_ack_ecn_old)) { + } else if (first_byte == picoquic_frame_type_ack_ecn) { if (epoch == 1) { DBG_PRINTF("Ack-ECN frame (0x%x) not expected in 0-RTT packet", first_byte); picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_PROTOCOL_VIOLATION, first_byte); @@ -2554,7 +2497,7 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, uint8_ ack_needed = 1; break; case picoquic_frame_type_new_connection_id: - bytes = picoquic_decode_new_connection_id_frame(cnx, bytes, bytes_max, is_draft_14); + bytes = picoquic_decode_new_connection_id_frame(cnx, bytes, bytes_max); ack_needed = 1; break; case picoquic_frame_type_stop_sending: @@ -2658,21 +2601,12 @@ static uint8_t* picoquic_skip_application_close_frame(uint8_t* bytes, const uint * The ACK skipping function only supports the varint format. * The old "fixed int" versions are supported by code in the skip_frame function */ -static uint8_t* picoquic_skip_ack_frame_maybe_ecn(uint8_t* bytes, const uint8_t* bytes_max, int is_ecn, int is_draft_14) +static uint8_t* picoquic_skip_ack_frame_maybe_ecn(uint8_t* bytes, const uint8_t* bytes_max, int is_ecn) { uint64_t nb_blocks; if ((bytes = picoquic_frames_varint_skip(bytes + 1, bytes_max)) != NULL && - (bytes = picoquic_frames_varint_skip(bytes, bytes_max)) != NULL) - { - if (is_ecn && is_draft_14) { - for (int i = 0; bytes != NULL && i < 3; i++) { - bytes = picoquic_frames_varint_skip(bytes, bytes_max); - } - } - } - - if (bytes != NULL && + (bytes = picoquic_frames_varint_skip(bytes, bytes_max)) != NULL && (bytes = picoquic_frames_varint_decode(bytes, bytes_max, &nb_blocks)) != NULL && (bytes = picoquic_frames_varint_skip(bytes, bytes_max)) != NULL) { @@ -2685,7 +2619,7 @@ static uint8_t* picoquic_skip_ack_frame_maybe_ecn(uint8_t* bytes, const uint8_t* } } - if (bytes != NULL && is_ecn && !is_draft_14) { + if (bytes != NULL && is_ecn) { for (int i = 0; bytes != NULL && i < 3; i++) { bytes = picoquic_frames_varint_skip(bytes, bytes_max); } @@ -2695,11 +2629,11 @@ static uint8_t* picoquic_skip_ack_frame_maybe_ecn(uint8_t* bytes, const uint8_t* } static uint8_t* picoquic_skip_ack_frame(uint8_t* bytes, const uint8_t* bytes_max) { - return picoquic_skip_ack_frame_maybe_ecn(bytes, bytes_max, 0, 0); + return picoquic_skip_ack_frame_maybe_ecn(bytes, bytes_max, 0); } -static uint8_t* picoquic_skip_ack_ecn_frame(uint8_t* bytes, const uint8_t* bytes_max, int is_draft_14) { - return picoquic_skip_ack_frame_maybe_ecn(bytes, bytes_max, 1, is_draft_14); +static uint8_t* picoquic_skip_ack_ecn_frame(uint8_t* bytes, const uint8_t* bytes_max) { + return picoquic_skip_ack_frame_maybe_ecn(bytes, bytes_max, 1); } /* Lots of simple frames... @@ -2732,8 +2666,7 @@ static uint8_t* picoquic_skip_stream_blocked_frame(uint8_t* bytes, const uint8_t } -int picoquic_skip_frame(uint8_t* bytes, size_t bytes_maxsize, size_t* consumed, - int* pure_ack, int is_draft_14) +int picoquic_skip_frame(uint8_t* bytes, size_t bytes_maxsize, size_t* consumed, int* pure_ack) { const uint8_t *bytes_max = bytes + bytes_maxsize; uint8_t first_byte = bytes[0]; @@ -2743,14 +2676,10 @@ int picoquic_skip_frame(uint8_t* bytes, size_t bytes_maxsize, size_t* consumed, if (PICOQUIC_IN_RANGE(first_byte, picoquic_frame_type_stream_range_min, picoquic_frame_type_stream_range_max)) { *pure_ack = 0; bytes = picoquic_skip_stream_frame(bytes, bytes_max); - } else if (!is_draft_14 && first_byte == picoquic_frame_type_ack) { - bytes = picoquic_skip_ack_frame(bytes, bytes_max); - } else if (!is_draft_14 && first_byte == picoquic_frame_type_ack_ecn) { - bytes = picoquic_skip_ack_ecn_frame(bytes, bytes_max, 0); - } else if (is_draft_14 && first_byte == picoquic_frame_type_ack_old) { + } else if (first_byte == picoquic_frame_type_ack) { bytes = picoquic_skip_ack_frame(bytes, bytes_max); - } else if (is_draft_14 && first_byte == picoquic_frame_type_ack_ecn_old) { - bytes = picoquic_skip_ack_ecn_frame(bytes, bytes_max, 1); + } else if (first_byte == picoquic_frame_type_ack_ecn) { + bytes = picoquic_skip_ack_ecn_frame(bytes, bytes_max); } else { switch (first_byte) { case picoquic_frame_type_padding: @@ -2799,7 +2728,7 @@ int picoquic_skip_frame(uint8_t* bytes, size_t bytes_maxsize, size_t* consumed, *pure_ack = 0; break; case picoquic_frame_type_new_connection_id: - bytes = picoquic_skip_new_connection_id_frame(bytes, bytes_max, is_draft_14); + bytes = picoquic_skip_new_connection_id_frame(bytes, bytes_max); *pure_ack = 0; break; case picoquic_frame_type_stop_sending: @@ -2841,7 +2770,7 @@ int picoquic_skip_frame(uint8_t* bytes, size_t bytes_maxsize, size_t* consumed, return bytes == NULL; } -int picoquic_decode_closing_frames(uint8_t* bytes, size_t bytes_max, int* closing_received, int is_draft_14) +int picoquic_decode_closing_frames(uint8_t* bytes, size_t bytes_max, int* closing_received) { int ret = 0; size_t byte_index = 0; @@ -2858,7 +2787,7 @@ int picoquic_decode_closing_frames(uint8_t* bytes, size_t bytes_max, int* closin int pure_ack = 0; ret = picoquic_skip_frame(bytes + byte_index, - bytes_max - byte_index, &consumed, &pure_ack, is_draft_14); + bytes_max - byte_index, &consumed, &pure_ack); byte_index += consumed; } } diff --git a/picoquic/logger.c b/picoquic/logger.c index 15fc2f10b88099595aea5da9d4fb1fd40625e001..ac35a300b9a7234153cecba09e548f5ebdb6d7e2 100644 --- a/picoquic/logger.c +++ b/picoquic/logger.c @@ -245,7 +245,7 @@ char const* picoquic_log_ptype_name(picoquic_packet_type_enum ptype) return ptype_name; } -char const* picoquic_log_frame_names(uint8_t frame_type, int is_draft_14) +char const* picoquic_log_frame_names(uint8_t frame_type) { char const * frame_name = "unknown"; @@ -290,7 +290,7 @@ char const* picoquic_log_frame_names(uint8_t frame_type, int is_draft_14) frame_name = "stop_sending"; break; case picoquic_frame_type_ack: - frame_name = (is_draft_14)?"ack_ecn":"ack"; + frame_name = "ack"; break; case picoquic_frame_type_path_challenge: frame_name = "path_challenge"; @@ -305,10 +305,10 @@ char const* picoquic_log_frame_names(uint8_t frame_type, int is_draft_14) frame_name = "new_token"; break; case picoquic_frame_type_ack_ecn: - frame_name = (is_draft_14) ? "error(0x0B)": "ack_ecn"; + frame_name = "ack_ecn"; break; case picoquic_frame_type_retire_connection_id: - frame_name = (is_draft_14) ? "ack" : "retire_connection_id"; + frame_name = "retire_connection_id"; break; default: if (PICOQUIC_IN_RANGE(frame_type, picoquic_frame_type_stream_range_min, picoquic_frame_type_stream_range_max)) { @@ -475,7 +475,7 @@ size_t picoquic_log_stream_frame(FILE* F, uint8_t* bytes, size_t bytes_max) return byte_index + data_length; } -size_t picoquic_log_ack_frame(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t bytes_max, int is_ecn, int is_draft_14) +size_t picoquic_log_ack_frame(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t bytes_max, int is_ecn) { size_t byte_index; uint64_t num_block; @@ -485,7 +485,7 @@ size_t picoquic_log_ack_frame(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t int suspended = debug_printf_reset(1); - int ret = picoquic_parse_ack_header(bytes, bytes_max, &num_block, (is_ecn && is_draft_14)? ecnx3:NULL, + int ret = picoquic_parse_ack_header(bytes, bytes_max, &num_block, NULL, &largest, &ack_delay, &byte_index, 0); (void)debug_printf_reset(suspended); @@ -580,7 +580,7 @@ size_t picoquic_log_ack_frame(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t largest -= block_to_block; } - if (ret == 0 && (is_ecn && !is_draft_14)) { + if (ret == 0 && is_ecn) { /* Decode the ecn counts */ for (int ecnx = 0; ret == 0 && ecnx < 3; ecnx++) { size_t l_ecnx = picoquic_varint_decode(bytes + byte_index, bytes_max - byte_index, &ecnx3[ecnx]); @@ -594,9 +594,7 @@ size_t picoquic_log_ack_frame(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t byte_index += l_ecnx; } } - } - if (ret == 0 && is_ecn) { fprintf(F, ", ect0=%llu, ect1=%llu, ce=%llu\n", (unsigned long long)ecnx3[0], (unsigned long long)ecnx3[1], (unsigned long long)ecnx3[2]); } else { @@ -688,14 +686,14 @@ size_t picoquic_log_generic_close_frame(FILE* F, uint8_t* bytes, size_t bytes_ma if (l1 == 0) { fprintf(F, " Malformed %s, requires %d bytes out of %d\n", - picoquic_log_frame_names(ftype, 0), + picoquic_log_frame_names(ftype), (int)(byte_index + picoquic_varint_skip(bytes + 3)), (int)bytes_max); byte_index = bytes_max; } else { byte_index += l1; - fprintf(F, " %s, Error 0x%04x, ", picoquic_log_frame_names(ftype, 0), error_code); + fprintf(F, " %s, Error 0x%04x, ", picoquic_log_frame_names(ftype), error_code); if (ftype == picoquic_frame_type_connection_close && offending_frame_type != 0) { fprintf(F, "Offending frame %llx\n", @@ -704,7 +702,7 @@ size_t picoquic_log_generic_close_frame(FILE* F, uint8_t* bytes, size_t bytes_ma fprintf(F, "Reason length %llu\n", (unsigned long long)string_length); if (byte_index + string_length > bytes_max) { fprintf(F, " Malformed %s, requires %llu bytes out of %llu\n", - picoquic_log_frame_names(ftype, 0), + picoquic_log_frame_names(ftype), (unsigned long long)(byte_index + string_length), (unsigned long long)bytes_max); byte_index = bytes_max; } @@ -852,7 +850,7 @@ size_t picoquic_log_stream_blocked_frame(FILE* F, uint8_t* bytes, size_t bytes_m return byte_index; } -size_t picoquic_log_new_connection_id_frame(FILE* F, uint8_t* bytes, size_t bytes_max, int is_draft_14) +size_t picoquic_log_new_connection_id_frame(FILE* F, uint8_t* bytes, size_t bytes_max) { size_t byte_index = 1; size_t min_size = 2 + 16; @@ -861,25 +859,15 @@ size_t picoquic_log_new_connection_id_frame(FILE* F, uint8_t* bytes, size_t byte uint8_t l_cid = 0; size_t l_seq = 0; - if (is_draft_14) { - l_seq = picoquic_varint_decode(&bytes[byte_index], bytes_max, &sequence); - min_size += l_seq; - byte_index += l_seq; - if (l_seq != 0 && byte_index < bytes_max) { - l_cid = bytes[byte_index++]; - min_size += l_cid; - } - } - else { - if (byte_index < bytes_max) { - l_cid = bytes[byte_index++]; - } - min_size += l_cid; - l_seq = picoquic_varint_decode(&bytes[byte_index], bytes_max, &sequence); - min_size += l_seq; - byte_index += l_seq; + if (byte_index < bytes_max) { + l_cid = bytes[byte_index++]; } + min_size += l_cid; + + l_seq = picoquic_varint_decode(&bytes[byte_index], bytes_max, &sequence); + min_size += l_seq; + byte_index += l_seq; if (l_seq == 0 || min_size > bytes_max) { fprintf(F, " Malformed NEW CONNECTION ID, requires %d bytes out of %d\n", (int)min_size, (int)bytes_max); @@ -962,11 +950,11 @@ size_t picoquic_log_path_frame(FILE* F, uint8_t* bytes, size_t bytes_max) if (byte_index + challenge_length > bytes_max) { fprintf(F, " Malformed %s frame, %d bytes needed, %d available\n", - picoquic_log_frame_names(bytes[0], 0), + picoquic_log_frame_names(bytes[0]), (int)(challenge_length + 1), (int)bytes_max); byte_index = bytes_max; } else { - fprintf(F, " %s: ", picoquic_log_frame_names(bytes[0], 0)); + fprintf(F, " %s: ", picoquic_log_frame_names(bytes[0])); for (size_t i = 0; i < challenge_length && i < 16; i++) { fprintf(F, "%02x", bytes[byte_index + i]); @@ -1020,7 +1008,7 @@ size_t picoquic_log_crypto_hs_frame(FILE* F, uint8_t* bytes, size_t bytes_max) return byte_index; } -void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t length, int is_draft_14) +void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t length) { size_t byte_index = 0; @@ -1038,32 +1026,13 @@ void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t leng switch (frame_id) { case picoquic_frame_type_ack: - if (is_draft_14) { - /* The old type code used the same index as the new code. */ - byte_index += picoquic_log_ack_frame(F, cnx_id64, bytes + byte_index, length - byte_index, 1, is_draft_14); - } - else { - byte_index += picoquic_log_ack_frame(F, cnx_id64, bytes + byte_index, length - byte_index, 0, 0); - } + byte_index += picoquic_log_ack_frame(F, cnx_id64, bytes + byte_index, length - byte_index, 0); break; case picoquic_frame_type_ack_ecn: - if (is_draft_14) { - fprintf(F, " Type %d unsupported in old versions.\n", frame_id); - byte_index = length; - } - else { - byte_index += picoquic_log_ack_frame(F, cnx_id64, bytes + byte_index, length - byte_index, 1, 0); - } + byte_index += picoquic_log_ack_frame(F, cnx_id64, bytes + byte_index, length - byte_index, 1); break; case picoquic_frame_type_retire_connection_id: - /* This new frame uses the same code as the old ack frame */ - if (is_draft_14) { - /* The old type code used the same index as the new code. */ - byte_index += picoquic_log_ack_frame(F, cnx_id64, bytes + byte_index, length - byte_index, 0, is_draft_14); - } - else { - byte_index += picoquic_log_retire_connection_id_frame(F, bytes + byte_index, length - byte_index); - } + byte_index += picoquic_log_retire_connection_id_frame(F, bytes + byte_index, length - byte_index); break; case picoquic_frame_type_padding: case picoquic_frame_type_ping: { @@ -1074,7 +1043,7 @@ void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t leng nb++; } - fprintf(F, " %s, %d bytes\n", picoquic_log_frame_names(frame_id, 0), nb); + fprintf(F, " %s, %d bytes\n", picoquic_log_frame_names(frame_id), nb); break; } case picoquic_frame_type_reset_stream: /* RST_STREAM */ @@ -1112,13 +1081,12 @@ void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t leng break; case picoquic_frame_type_stream_id_needed: /* STREAM_ID_NEEDED */ /* No payload */ - fprintf(F, " %s frame\n", picoquic_log_frame_names(frame_id, 0)); + fprintf(F, " %s frame\n", picoquic_log_frame_names(frame_id)); byte_index++; byte_index += picoquic_varint_skip(&bytes[byte_index]); break; case picoquic_frame_type_new_connection_id: /* NEW_CONNECTION_ID */ - byte_index += picoquic_log_new_connection_id_frame(F, bytes + byte_index, - length - byte_index, is_draft_14); + byte_index += picoquic_log_new_connection_id_frame(F, bytes + byte_index, length - byte_index); break; case picoquic_frame_type_stop_sending: /* STOP_SENDING */ byte_index += picoquic_log_stop_sending_frame(F, bytes + byte_index, @@ -1137,8 +1105,7 @@ void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t leng length - byte_index); break; case picoquic_frame_type_new_token: - byte_index += picoquic_log_new_token_frame(F, bytes + byte_index, - length - byte_index); + byte_index += picoquic_log_new_token_frame(F, bytes + byte_index, length - byte_index); break; default: { /* Not implemented yet! */ @@ -1211,10 +1178,7 @@ void picoquic_log_decrypted_segment(void* F_log, int log_cnxid, picoquic_cnx_t* } fprintf(F, " %s %d bytes\n", (receiving)?"Decrypted": "Prepared", (int)ph->payload_length); - picoquic_log_frames(F, log_cnxid64, bytes + ph->offset, - ph->payload_length, (cnx != NULL && - (picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION))); + picoquic_log_frames(F, log_cnxid64, bytes + ph->offset, ph->payload_length); } fprintf(F, "\n"); } diff --git a/picoquic/packet.c b/picoquic/packet.c index d2586e97a08749911f053ded1c30e96ef89078f2..10e3ede9c2e5c331bbe9b36c6cb041d57445c62c 100644 --- a/picoquic/packet.c +++ b/picoquic/packet.c @@ -647,7 +647,6 @@ int picoquic_prepare_version_negotiation( if (sp != NULL) { uint8_t* bytes = sp->bytes; size_t byte_index = 0; - int is_draft_14 = picoquic_tls_context_is_draft_14(quic); /* Packet type set to random value for version negotiation */ picoquic_public_random(bytes + byte_index, 1); @@ -663,16 +662,8 @@ int picoquic_prepare_version_negotiation( /* Set the payload to the list of versions */ for (size_t i = 0; i < picoquic_nb_supported_versions; i++) { - uint32_t proposed_version = picoquic_supported_versions[i].version; - if ((is_draft_14 && - (proposed_version == PICOQUIC_SEVENTH_INTEROP_VERSION || - proposed_version == PICOQUIC_EIGHT_INTEROP_VERSION)) || - (!is_draft_14 && - (proposed_version != PICOQUIC_SEVENTH_INTEROP_VERSION && - proposed_version != PICOQUIC_EIGHT_INTEROP_VERSION))) { - picoformat_32(bytes + byte_index, picoquic_supported_versions[i].version); - byte_index += 4; - } + picoformat_32(bytes + byte_index, picoquic_supported_versions[i].version); + byte_index += 4; } /* Set length and addresses, and queue. */ @@ -1415,9 +1406,7 @@ int picoquic_incoming_encrypted( int closing_received = 0; ret = picoquic_decode_closing_frames( - bytes + ph->offset, ph->payload_length, &closing_received, - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); + bytes + ph->offset, ph->payload_length, &closing_received); if (ret == 0) { if (closing_received) { diff --git a/picoquic/picoquic.vcxproj b/picoquic/picoquic.vcxproj index e48de4f8b08ecacda07dfaa54be4cd846782af79..57a8877ee4ea3323fc91842d4149bf5cb2dab284 100644 --- a/picoquic/picoquic.vcxproj +++ b/picoquic/picoquic.vcxproj @@ -137,7 +137,6 @@ <ItemGroup> <ClCompile Include="fnv1a.c" /> <ClCompile Include="frames.c" /> - <ClCompile Include="h3zero.c" /> <ClCompile Include="http0dot9.c" /> <ClCompile Include="intformat.c" /> <ClCompile Include="logger.c" /> diff --git a/picoquic/picoquic.vcxproj.filters b/picoquic/picoquic.vcxproj.filters index 7c310b207b0d52ad88781b213b777ff572972472..f2e4c9e719556eb34fa9656e8bd61a268b367977 100644 --- a/picoquic/picoquic.vcxproj.filters +++ b/picoquic/picoquic.vcxproj.filters @@ -72,9 +72,6 @@ <ClCompile Include="spinbit.c"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="h3zero.c"> - <Filter>Source Files</Filter> - </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="picoquic.h"> diff --git a/picoquic/picoquic_internal.h b/picoquic/picoquic_internal.h index ec9afab6e38bc3a2d2eb19b32fed93f27eb96465..d3db1a2a0f454d492c84449c1401d5b79b95703e 100644 --- a/picoquic/picoquic_internal.h +++ b/picoquic/picoquic_internal.h @@ -83,7 +83,6 @@ typedef enum { picoquic_frame_type_stream_id_needed = 0x0a, picoquic_frame_type_new_connection_id = 0x0b, picoquic_frame_type_stop_sending = 0x0c, - picoquic_frame_type_ack_old = 0x0d, picoquic_frame_type_retire_connection_id = 0x0d, picoquic_frame_type_path_challenge = 0x0e, picoquic_frame_type_path_response = 0x0f, @@ -91,7 +90,6 @@ typedef enum { picoquic_frame_type_stream_range_max = 0x17, picoquic_frame_type_crypto_hs = 0x18, picoquic_frame_type_new_token = 0x19, - picoquic_frame_type_ack_ecn_old = 0x1a, picoquic_frame_type_ack = 0x1a, picoquic_frame_type_ack_ecn = 0x1b } picoquic_frame_type_enum_t; @@ -986,10 +984,10 @@ int picoquic_prepare_misc_frame(picoquic_misc_frame_header_t* misc_frame, uint8_ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, uint8_t* bytes, size_t bytes_max, int epoch, uint64_t current_time); -int picoquic_skip_frame(uint8_t* bytes, size_t bytes_max, size_t* consumed, int* pure_ack, int is_draft_14); +int picoquic_skip_frame(uint8_t* bytes, size_t bytes_max, size_t* consumed, int* pure_ack); int picoquic_decode_closing_frames(uint8_t* bytes, - size_t bytes_max, int* closing_received, int is_draft_14); + size_t bytes_max, int* closing_received); int picoquic_prepare_transport_extensions(picoquic_cnx_t* cnx, int extension_mode, uint8_t* bytes, size_t bytes_max, size_t* consumed); diff --git a/picoquic/quicctx.c b/picoquic/quicctx.c index c7c8a139f1df4450dc5f4a551c915d9485e2229e..4b6e721f66ef0966daebb5e3746fd76077794754 100644 --- a/picoquic/quicctx.c +++ b/picoquic/quicctx.c @@ -159,16 +159,6 @@ const picoquic_version_parameters_t picoquic_supported_versions[] = { sizeof(picoquic_cleartext_draft_10_salt), picoquic_cleartext_draft_10_salt }, { PICOQUIC_NINTH_INTEROP_VERSION, - picoquic_version_header_13, - picoquic_spinbit_vec, - sizeof(picoquic_cleartext_draft_10_salt), - picoquic_cleartext_draft_10_salt }, - { PICOQUIC_EIGHT_INTEROP_VERSION, - picoquic_version_header_13, - picoquic_spinbit_vec, - sizeof(picoquic_cleartext_draft_10_salt), - picoquic_cleartext_draft_10_salt }, - { PICOQUIC_SEVENTH_INTEROP_VERSION, picoquic_version_header_13, picoquic_spinbit_vec, sizeof(picoquic_cleartext_draft_10_salt), @@ -1772,7 +1762,6 @@ int picoquic_reset_cnx_version(picoquic_cnx_t* cnx, uint8_t* bytes, size_t lengt size_t byte_index = 0; uint32_t proposed_version = 0; int ret = -1; - int is_draft_14 = picoquic_tls_context_is_draft_14(cnx->quic); if (cnx->cnx_state == picoquic_state_client_init || cnx->cnx_state == picoquic_state_client_init_sent) { while (cnx->cnx_state != picoquic_state_client_renegotiate && byte_index + 4 <= length) { @@ -1782,15 +1771,8 @@ int picoquic_reset_cnx_version(picoquic_cnx_t* cnx, uint8_t* bytes, size_t lengt for (size_t i = 0; i < picoquic_nb_supported_versions; i++) { if (proposed_version == picoquic_supported_versions[i].version) { - if ((is_draft_14 && - (proposed_version == PICOQUIC_SEVENTH_INTEROP_VERSION || - proposed_version == PICOQUIC_EIGHT_INTEROP_VERSION)) || - (!is_draft_14 && - (proposed_version != PICOQUIC_SEVENTH_INTEROP_VERSION && - proposed_version != PICOQUIC_EIGHT_INTEROP_VERSION))) { - cnx->version_index = (int)i; - cnx->cnx_state = picoquic_state_client_renegotiate; - } + cnx->version_index = (int)i; + cnx->cnx_state = picoquic_state_client_renegotiate; break; } } diff --git a/picoquic/sender.c b/picoquic/sender.c index fcf5c2df58dd29dd259b740d87b22cb44cdfc6b3..eafe598a56f1bdc1b7c41edcc7976feb6a7d757e 100644 --- a/picoquic/sender.c +++ b/picoquic/sender.c @@ -803,10 +803,7 @@ int picoquic_retransmit_needed(picoquic_cnx_t* cnx, break; } ret = picoquic_skip_frame(&p->bytes[byte_index], - p->length - byte_index, &frame_length, &frame_is_pure_ack, - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION - ); + p->length - byte_index, &frame_length, &frame_is_pure_ack); byte_index += frame_length; } p->contains_crypto = contains_crypto; @@ -862,9 +859,7 @@ int picoquic_retransmit_needed(picoquic_cnx_t* cnx, while (ret == 0 && byte_index < p->length) { ret = picoquic_skip_frame(&p->bytes[byte_index], - p->length - byte_index, &frame_length, &frame_is_pure_ack, - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); + p->length - byte_index, &frame_length, &frame_is_pure_ack); /* Check whether the data was already acked, which may happen in * case of spurious retransmissions */ @@ -980,9 +975,7 @@ int picoquic_is_cnx_backlog_empty(picoquic_cnx_t* cnx) while (ret == 0 && byte_index < p->length) { ret = picoquic_skip_frame(&p->bytes[byte_index], - p->length - p->offset, &frame_length, &frame_is_pure_ack, - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION); + p->length - p->offset, &frame_length, &frame_is_pure_ack); if (!frame_is_pure_ack) { backlog_empty = 0; @@ -1173,9 +1166,7 @@ int picoquic_prepare_packet_0rtt(picoquic_cnx_t* cnx, picoquic_path_t * path_x, picoquic_finalize_and_protect_packet(cnx, packet, ret, length, header_length, checksum_overhead, send_length, send_buffer, (uint32_t)send_buffer_max, - (picoquic_supported_versions[cnx->version_index].version == PICOQUIC_SEVENTH_INTEROP_VERSION || - picoquic_supported_versions[cnx->version_index].version == PICOQUIC_EIGHT_INTEROP_VERSION) ? - &path_x->remote_cnxid : &cnx->initial_cnxid, + &cnx->initial_cnxid, &path_x->local_cnxid, path_x, current_time); diff --git a/picoquic/tls_api.c b/picoquic/tls_api.c index a57d32dc8d9ae6b0d40feaf57482ec40fb526e16..73a2deb31af3169c5eb1764ae9fbeb6fbdce86d7 100644 --- a/picoquic/tls_api.c +++ b/picoquic/tls_api.c @@ -356,26 +356,21 @@ int picoquic_tls_collected_extensions_cb(ptls_t* tls, ptls_handshake_properties_ */ int picoquic_client_hello_call_back(ptls_on_client_hello_t* on_hello_cb_ctx, - ptls_t* tls, ptls_iovec_t server_name, const ptls_iovec_t* negotiated_protocols, - size_t num_negotiated_protocols, const uint16_t* signature_algorithms, size_t num_signature_algorithms) + ptls_t* tls, ptls_on_client_hello_parameters_t *params) { -#ifdef _WINDOWS - UNREFERENCED_PARAMETER(signature_algorithms); - UNREFERENCED_PARAMETER(num_signature_algorithms); -#endif int alpn_found = 0; picoquic_quic_t** ppquic = (picoquic_quic_t**)(((char*)on_hello_cb_ctx) + sizeof(ptls_on_client_hello_t)); picoquic_quic_t* quic = *ppquic; /* Save the server name */ - ptls_set_server_name(tls, (const char *)server_name.base, server_name.len); + ptls_set_server_name(tls, (const char *)params->server_name.base, params->server_name.len); /* Check if the client is proposing the expected ALPN */ if (quic->default_alpn != NULL) { size_t len = strlen(quic->default_alpn); - for (size_t i = 0; i < num_negotiated_protocols; i++) { - if (negotiated_protocols[i].len == len && memcmp(negotiated_protocols[i].base, quic->default_alpn, len) == 0) { + for (size_t i = 0; i < params->negotiated_protocols.count; i++) { + if (params->negotiated_protocols.list[i].len == len && memcmp(params->negotiated_protocols.list[i].base, quic->default_alpn, len) == 0) { alpn_found = 1; ptls_set_negotiated_protocol(tls, quic->default_alpn, len); break; @@ -388,10 +383,10 @@ int picoquic_client_hello_call_back(ptls_on_client_hello_t* on_hello_cb_ctx, */ if (alpn_found == 0) { - for (size_t i = 0; i < num_negotiated_protocols; i++) { - if (negotiated_protocols[i].len > 0) { + for (size_t i = 0; i < params->negotiated_protocols.count; i++) { + if (params->negotiated_protocols.list[i].len > 0) { ptls_set_negotiated_protocol(tls, - (char const*)negotiated_protocols[i].base, negotiated_protocols[i].len); + (char const*)params->negotiated_protocols.list[i].base, params->negotiated_protocols.list[i].len); break; } } @@ -1154,29 +1149,6 @@ int picoquic_master_tlscontext(picoquic_quic_t* quic, return ret; } -void picoquic_set_tls_context_for_draft_14(picoquic_quic_t * quic) -{ - ptls_context_t* ctx = (ptls_context_t*)quic->tls_master_ctx; - - if (ctx != NULL) { - /* Tell Picotls to require EOED messages during handshake */ - ctx->omit_end_of_early_data = 0; - } -} - -int picoquic_tls_context_is_draft_14(picoquic_quic_t * quic) -{ - int ret = 0; - ptls_context_t* ctx = (ptls_context_t*)quic->tls_master_ctx; - - if (ctx != NULL) { - /* Tell Picotls to require EOED messages during handshake */ - ret = (ctx->omit_end_of_early_data == 0); - } - - return ret; -} - static void free_certificates_list(ptls_iovec_t* certs, size_t len) { if (certs == NULL) { return; diff --git a/picoquicfirst/picoquicdemo.c b/picoquicfirst/picoquicdemo.c index 7b838495b725a285dc562e5e2a23b9600aa1e8be..c0a10b74fb7dec3034a307af87e8a4d2418efc20 100644 --- a/picoquicfirst/picoquicdemo.c +++ b/picoquicfirst/picoquicdemo.c @@ -109,9 +109,6 @@ static const char* bad_request_message = "<html><head><title>Bad Request</title> #include "../picoquic/picosocks.h" #include "../picoquic/util.h" -/* TODO: remove this declaration when removing support for draft 14 */ -void picoquic_set_tls_context_for_draft_14(picoquic_quic_t * quic); - void print_address(struct sockaddr* address, char* label, picoquic_connection_id_t cnx_id) { char hostname[256]; @@ -440,11 +437,6 @@ int quic_server(const char* server_name, int server_port, PICOQUIC_SET_LOG(qserver, stdout); picoquic_set_key_log_file_from_env(qserver); - - if (proposed_version == PICOQUIC_SEVENTH_INTEROP_VERSION || - proposed_version == PICOQUIC_EIGHT_INTEROP_VERSION) { - picoquic_set_tls_context_for_draft_14(qserver); - } } } @@ -1007,11 +999,6 @@ int quic_client(const char* ip_address_text, int server_port, const char * sni, } picoquic_set_null_verifier(qclient); } - - if (proposed_version == PICOQUIC_SEVENTH_INTEROP_VERSION || - proposed_version == PICOQUIC_EIGHT_INTEROP_VERSION) { - picoquic_set_tls_context_for_draft_14(qclient); - } } } diff --git a/picoquictest/cleartext_aead_test.c b/picoquictest/cleartext_aead_test.c index cbc66a785169eb3ae38f65c5512449a7eed6fc58..b181633e5bb06487dd8cd9f40415603ff4838b4f 100644 --- a/picoquictest/cleartext_aead_test.c +++ b/picoquictest/cleartext_aead_test.c @@ -187,7 +187,7 @@ int cleartext_aead_test() static picoquic_connection_id_t clear_test_vector_cnx_id = { { 0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51, 0x57, 0x08 }, 8 }; -static uint32_t clear_test_vector_vn = 0xff00000d; +static uint32_t clear_test_vector_vn = 0xff000010; static uint8_t clear_test_vector_client_iv[12] = { 0xab, 0x95, 0x0b, 0x01, 0x98, 0x63, 0x79, 0x78, 0xcf, 0x44, 0xaa, 0xb9 }; @@ -551,7 +551,7 @@ int cleartext_pn_vector_test() test_addr_s.sin_port = 4433; cnx_server = picoquic_create_cnx(qserver, initial_cnxid, initial_cnxid, - (struct sockaddr*)&test_addr_s, 0, PICOQUIC_SEVENTH_INTEROP_VERSION, NULL, NULL, 0); + (struct sockaddr*)&test_addr_s, 0, PICOQUIC_NINTH_INTEROP_VERSION, NULL, NULL, 0); if (cnx_server == NULL) { DBG_PRINTF("%s", "Could not create server connection context.\n"); @@ -589,9 +589,9 @@ int cleartext_pn_vector_test() * test copied from EKR test vector */ -static uint8_t draft13_test_input_packet[] = { - 0xff, 0xff, 0x00, 0x00, 0x0d, 0x50, 0x06, 0xb8, 0x58, 0xec, - 0x6f, 0x80, 0x45, 0x2b, 0x00, 0x44, 0xef, 0xa5, 0xd8, 0xd3, +static uint8_t draft15_test_input_packet[] = { + 0xff, 0xff, 0x00, 0x00, 0x0f, 0x50, 0x06, 0xb8, 0x58, 0xec, + 0x6f, 0x80, 0x45, 0x2b, 0x00, 0x40, 0x44, 0xef, 0xa5, 0xd8, 0xd3, 0x07, 0xc2, 0x97, 0x3f, 0xa0, 0xd6, 0x3f, 0xd9, 0xb0, 0x3a, 0x4e, 0x16, 0x3b, 0x99, 0x0d, 0xd7, 0x78, 0x89, 0x4a, 0x9e, 0xdc, 0x8e, 0xac, 0xfb, 0xe4, 0xaa, 0x6f, 0xbf, 0x4a, 0x22, @@ -720,7 +720,7 @@ static uint8_t draft13_test_input_packet[] = { 0xa6, 0xf9, 0x08, 0xfe, 0x2a, 0x6e, 0xe7, 0x54, 0xc8, 0x96 }; -static uint32_t draft13_test_vn = 0xff00000d; +static uint32_t draft15_test_vn = 0xff00000f; static picoquic_connection_id_t draft13_test_cnx_id = { { 0x06, 0xb8, 0x58, 0xec, 0x6f, 0x80, 0x45, 0x2b }, 8 }; @@ -793,6 +793,8 @@ static int draft13_label_expansion_test(ptls_cipher_suite_t * cipher, char const return ret; } +#if 0 +/* TODO: restore this test once we have a valid incoming message for draft-17 */ static int draft31_incoming_initial_test() { int ret = 0; @@ -809,7 +811,7 @@ static int draft31_incoming_initial_test() /* Simulate arrival of an initial packet in the server context */ picoquic_cnx_t* cnx = NULL; picoquic_packet_header ph; - uint32_t length = (uint32_t) sizeof(draft13_test_input_packet); + uint32_t length = (uint32_t) sizeof(draft15_test_input_packet); uint64_t current_time = 0; uint32_t consumed = 0; struct sockaddr_in test_addr_c; @@ -821,7 +823,7 @@ static int draft31_incoming_initial_test() test_addr_c.sin_port = 12345; /* Parse the header and decrypt the packet */ - ret = picoquic_parse_header_and_decrypt(qserver, draft13_test_input_packet, length, length, + ret = picoquic_parse_header_and_decrypt(qserver, draft15_test_input_packet, length, length, (struct sockaddr *)&test_addr_c, current_time, &ph, &cnx, &consumed, &new_context_created); if (ret != 0) { @@ -849,6 +851,8 @@ static int draft31_incoming_initial_test() return ret; } +#endif + int draft13_vector_test() { @@ -898,23 +902,23 @@ int draft13_vector_test() } /* Check the salt */ - version_index = picoquic_get_version_index(draft13_test_vn); + version_index = picoquic_get_version_index(draft15_test_vn); if (version_index < 0) { - DBG_PRINTF("Test version (%x) is not supported.\n", draft13_test_vn); + DBG_PRINTF("Test version (%x) is not supported.\n", draft15_test_vn); ret = -1; } else if (picoquic_supported_versions[version_index].version_aead_key == NULL) { - DBG_PRINTF("Test version (%x) has no salt.\n", draft13_test_vn); + DBG_PRINTF("Test version (%x) has no salt.\n", draft15_test_vn); ret = -1; } else if (picoquic_supported_versions[version_index].version_aead_key_length != sizeof(draft13_test_salt)) { - DBG_PRINTF("Test version (%x) has no salt[%d], expected [%d].\n", draft13_test_vn, + DBG_PRINTF("Test version (%x) has no salt[%d], expected [%d].\n", draft15_test_vn, (int)picoquic_supported_versions[version_index].version_aead_key_length, (int) sizeof(draft13_test_salt)); ret = -1; } else if (memcmp(picoquic_supported_versions[version_index].version_aead_key, draft13_test_salt, sizeof(draft13_test_salt)) != 0) { - DBG_PRINTF("Test version (%x) does not have matching salt.\n", draft13_test_vn); + DBG_PRINTF("Test version (%x) does not have matching salt.\n", draft15_test_vn); ret = -1; } @@ -953,12 +957,13 @@ int draft13_vector_test() ret = cleartext_aead_vector_test_one(draft13_test_cnx_id, draft13_test_client_iv, sizeof(draft13_test_client_iv), draft13_test_server_iv, sizeof(draft13_test_server_iv), "draft13_vector"); } - +#if 0 + /* TODO: reset this test once we have draft-17 samples. */ /* Final integration test: verify that the incoming packet can be decrypted */ if (ret == 0) { ret = draft31_incoming_initial_test(); } - +#endif return ret; } diff --git a/picoquictest/skip_frame_test.c b/picoquictest/skip_frame_test.c index e8816eba5390b4ba2aa0b70e045dfe7d83f1bc88..f7163294e53f08996a00c3a998bd2a6107c6f25e 100644 --- a/picoquictest/skip_frame_test.c +++ b/picoquictest/skip_frame_test.c @@ -283,7 +283,7 @@ static int skip_test_packet(uint8_t * bytes, size_t bytes_max) while (ret == 0 && byte_index < bytes_max) { size_t consumed; - ret = picoquic_skip_frame(bytes + byte_index, bytes_max - byte_index, &consumed, &pure_ack, 0); + ret = picoquic_skip_frame(bytes + byte_index, bytes_max - byte_index, &consumed, &pure_ack); if (ret == 0) { byte_index += consumed; } @@ -330,7 +330,7 @@ int skip_frame_test() byte_max += sizeof(extra_bytes); } - t_ret = picoquic_skip_frame(buffer, byte_max, &consumed, &pure_ack, 0); + t_ret = picoquic_skip_frame(buffer, byte_max, &consumed, &pure_ack); if (t_ret != 0) { DBG_PRINTF("Skip frame <%s> fails, ret = %d\n", test_skip_list[i].name, t_ret); @@ -452,7 +452,7 @@ int parse_frame_test() return ret; } -void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t length, int is_draft_14); +void picoquic_log_frames(FILE* F, uint64_t cnx_id64, uint8_t* bytes, size_t length); static char const* log_test_file = "log_test.txt"; static char const* log_fuzz_test_file = "log_fuzz_test.txt"; @@ -580,7 +580,7 @@ int logger_test() #endif for (size_t i = 0; i < nb_test_skip_list; i++) { - picoquic_log_frames(F, 0, test_skip_list[i].val, test_skip_list[i].len, 0); + picoquic_log_frames(F, 0, test_skip_list[i].val, test_skip_list[i].len); } fclose(F); @@ -609,7 +609,7 @@ int logger_test() } #endif ret &= fprintf(F, "Log packet test #%d\n", (int)i); - picoquic_log_frames(F, 0, buffer, bytes_max, 0); + picoquic_log_frames(F, 0, buffer, bytes_max); fclose(F); #ifdef _WINDOWS @@ -660,14 +660,14 @@ int logger_test() } #endif ret &= fprintf(F, "Log fuzz test #%d\n", (int)i); - picoquic_log_frames(F, 0, buffer, bytes_max, 0); + picoquic_log_frames(F, 0, buffer, bytes_max); /* Attempt to log fuzzed packets, and hope nothing crashes */ for (size_t j = 0; j < 100; j++) { ret &= fprintf(F, "Log fuzz test #%d, packet %d\n", (int)i, (int)j); fflush(F); skip_test_fuzz_packet(fuzz_buffer, buffer, bytes_max, &random_context); - picoquic_log_frames(F, 0, fuzz_buffer, bytes_max, 0); + picoquic_log_frames(F, 0, fuzz_buffer, bytes_max); } fclose(F); F = NULL; @@ -865,7 +865,7 @@ int new_cnxid_test() size_t skipped = 0; int pure_ack = 0; - ret = picoquic_skip_frame(frame_buffer, sizeof(frame_buffer), &skipped, &pure_ack, 0); + ret = picoquic_skip_frame(frame_buffer, sizeof(frame_buffer), &skipped, &pure_ack); if (ret != 0) { DBG_PRINTF("Cannot skip connection ID frame, ret = %x\n", ret); diff --git a/picoquictest/tls_api_test.c b/picoquictest/tls_api_test.c index da11584cba0820813ed77a8d22a3e71edc8435fc..9b7bb49cce2659dc173fc9124bb926370bbd8e4a 100644 --- a/picoquictest/tls_api_test.c +++ b/picoquictest/tls_api_test.c @@ -597,9 +597,6 @@ static void tls_api_delete_ctx(picoquic_test_tls_api_ctx_t* test_ctx) free(test_ctx); } -/* TODO: remove this declaration when removing support for draft 14 */ -void picoquic_set_tls_context_for_draft_14(picoquic_quic_t * quic); - static int tls_api_init_ctx(picoquic_test_tls_api_ctx_t** pctx, uint32_t proposed_version, char const* sni, char const* alpn, uint64_t* p_simulated_time, char const* ticket_file_name, int force_zero_share, int delayed_init, int use_bad_crypt) @@ -649,14 +646,6 @@ static int tls_api_init_ctx(picoquic_test_tls_api_ctx_t** pctx, uint32_t propose if (test_ctx->qclient == NULL || test_ctx->qserver == NULL) { ret = -1; } - - if (ret == 0) { - if (proposed_version == PICOQUIC_SEVENTH_INTEROP_VERSION || - proposed_version == PICOQUIC_EIGHT_INTEROP_VERSION) { - picoquic_set_tls_context_for_draft_14(test_ctx->qclient); - picoquic_set_tls_context_for_draft_14(test_ctx->qserver); - } - } /* register the links */ if (ret == 0) {