| author | |
| committer | |
| log | 9b0da5ccef50bf5018142dd38deaeaf91fa16429 |
| tree | 804974a6283f6742af0d1caa4110e830188b563f |
| parent | c4a1b54ebefb77122d2055b09bc0bf01bbc1d8b6 |
Per last paragraph of RFC 8446, Section 5.2, the length of the inner content of an encrypted record must not exceed 2^14 + 1, while that of the whole encrypted record must not exceed 2^14 + 256.2 files changed, 5 insertions(+), 4 deletions(-)
lib/std/crypto/tls.zig+2-1| ... | @@ -40,7 +40,8 @@ const assert = std.debug.assert; | ... | @@ -40,7 +40,8 @@ const assert = std.debug.assert; |
| 40 | pub const Client = @import("tls/Client.zig"); | 40 | pub const Client = @import("tls/Client.zig"); |
| 41 | 41 | ||
| 42 | pub const record_header_len = 5; | 42 | pub const record_header_len = 5; |
| 43 | pub const max_ciphertext_len = (1 << 14) + 256; | 43 | pub const max_cipertext_inner_record_len = 1 << 14; |
| 44 | pub const max_ciphertext_len = max_cipertext_inner_record_len + 256; | ||
| 44 | pub const max_ciphertext_record_len = max_ciphertext_len + record_header_len; | 45 | pub const max_ciphertext_record_len = max_ciphertext_len + record_header_len; |
| 45 | pub const hello_retry_request_sequence = [32]u8{ | 46 | pub const hello_retry_request_sequence = [32]u8{ |
| 46 | 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, | 47 | 0xCF, 0x21, 0xAD, 0x74, 0xE5, 0x9A, 0x61, 0x11, 0xBE, 0x1D, 0x8C, 0x02, 0x1E, 0x65, 0xB8, 0x91, |
lib/std/crypto/tls/Client.zig+3-3| ... | @@ -805,9 +805,9 @@ fn prepareCiphertextRecord( | ... | @@ -805,9 +805,9 @@ fn prepareCiphertextRecord( |
| 805 | const close_notify_alert_reserved = tls.close_notify_alert.len + overhead_len; | 805 | const close_notify_alert_reserved = tls.close_notify_alert.len + overhead_len; |
| 806 | while (true) { | 806 | while (true) { |
| 807 | const encrypted_content_len: u16 = @intCast(@min( | 807 | const encrypted_content_len: u16 = @intCast(@min( |
| 808 | @min(bytes.len - bytes_i, max_ciphertext_len - 1), | 808 | @min(bytes.len - bytes_i, tls.max_cipertext_inner_record_len), |
| 809 | ciphertext_buf.len - close_notify_alert_reserved - | 809 | ciphertext_buf.len -| |
| 810 | overhead_len - ciphertext_end, | 810 | (close_notify_alert_reserved + overhead_len + ciphertext_end), |
| 811 | )); | 811 | )); |
| 812 | if (encrypted_content_len == 0) return .{ | 812 | if (encrypted_content_len == 0) return .{ |
| 813 | .iovec_end = iovec_end, | 813 | .iovec_end = iovec_end, |