Skip to content

Commit e68cc75

Browse files
committed
F-5813: clarify BuildMessage sequence-number wrap comment
The sequence number 2^64-1 is itself RFC 5246 6.1-legal; only the wrap to 0 is forbidden. GetSEQIncrement reads the current counter then post-increments it, so the check refuses the final legal sequence number to avoid the wrapping post-increment. Document that this last value is deliberately sacrificed rather than implying 2^64-1 is itself unusable.
1 parent 108afdf commit e68cc75

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/internal.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24777,11 +24777,11 @@ int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
2477724777
#endif
2477824778

2477924779
#ifndef WOLFSSL_NO_TLS12
24780-
/* RFC 5246 6.1: record sequence numbers MUST NOT wrap. Refuse to emit a
24781-
* record once the write sequence number has reached its maximum value
24782-
* (2^64-1); reusing sequence number 0 with the same keys would break the
24783-
* record protection. The caller must renegotiate or close the connection
24784-
* instead. DTLS sequence numbers are epoch-scoped and handled elsewhere. */
24780+
/* RFC 5246 6.1: sequence numbers MUST NOT wrap. GetSEQIncrement post-
24781+
* increments, so refuse at hi == lo == 0xFFFFFFFF (2^64-1): that last legal
24782+
* value is deliberately sacrificed to avoid wrapping to 0 and reusing
24783+
* sequence number 0. The caller must renegotiate or close. DTLS sequence
24784+
* numbers are epoch-scoped and handled elsewhere. */
2478524785
if (!sizeOnly && !ssl->options.dtls &&
2478624786
ssl->keys.sequence_number_hi == 0xFFFFFFFFU &&
2478724787
ssl->keys.sequence_number_lo == 0xFFFFFFFFU) {

0 commit comments

Comments
 (0)