0
0
mirror of https://github.com/XTLS/REALITY.git synced 2025-08-22 22:48:36 +00:00

internal/byteorder: use canonical Go casing in names

If Be and Le stand for big-endian and little-endian,
then they should be BE and LE.

Change-Id: I723e3962b8918da84791783d3c547638f1c9e8a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/627376
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
yuhan6665 2025-05-04 22:35:51 -04:00
parent 6c71b461ee
commit 0f3d0f2e71
3 changed files with 7 additions and 6 deletions

View File

@ -13,7 +13,6 @@ import (
"crypto/rsa" "crypto/rsa"
"crypto/subtle" "crypto/subtle"
"crypto/x509" "crypto/x509"
"encoding/binary"
"errors" "errors"
"fmt" "fmt"
"hash" "hash"
@ -22,6 +21,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/xtls/reality/byteorder"
"github.com/xtls/reality/hpke" "github.com/xtls/reality/hpke"
"github.com/xtls/reality/mlkem" "github.com/xtls/reality/mlkem"
"github.com/xtls/reality/tls13" "github.com/xtls/reality/tls13"
@ -707,7 +707,7 @@ func (hs *clientHandshakeState) doFullHandshake() error {
return err return err
} }
if len(skx.key) >= 3 && skx.key[0] == 3 /* named curve */ { if len(skx.key) >= 3 && skx.key[0] == 3 /* named curve */ {
c.curveID = CurveID(binary.BigEndian.Uint16(skx.key[1:])) c.curveID = CurveID(byteorder.BEUint16(skx.key[1:]))
} }
msg, err = c.readHandshake(&hs.finishedHash) msg, err = c.readHandshake(&hs.finishedHash)

View File

@ -12,12 +12,13 @@ import (
"crypto/rsa" "crypto/rsa"
"crypto/subtle" "crypto/subtle"
"crypto/x509" "crypto/x509"
"encoding/binary"
"errors" "errors"
"fmt" "fmt"
"hash" "hash"
"io" "io"
"time" "time"
"github.com/xtls/reality/byteorder"
) )
// serverHandshakeState contains details of a server handshake in progress. // serverHandshakeState contains details of a server handshake in progress.
@ -579,7 +580,7 @@ func (hs *serverHandshakeState) doFullHandshake() error {
} }
if skx != nil { if skx != nil {
if len(skx.key) >= 3 && skx.key[0] == 3 /* named curve */ { if len(skx.key) >= 3 && skx.key[0] == 3 /* named curve */ {
c.curveID = CurveID(binary.BigEndian.Uint16(skx.key[1:])) c.curveID = CurveID(byteorder.BEUint16(skx.key[1:]))
} }
if _, err := hs.c.writeHandshakeRecord(skx, &hs.finishedHash); err != nil { if _, err := hs.c.writeHandshakeRecord(skx, &hs.finishedHash); err != nil {
return err return err

View File

@ -14,7 +14,6 @@ import (
"crypto/rsa" "crypto/rsa"
"crypto/sha512" "crypto/sha512"
"crypto/x509" "crypto/x509"
"encoding/binary"
"errors" "errors"
"hash" "hash"
"io" "io"
@ -22,6 +21,7 @@ import (
"slices" "slices"
"time" "time"
"github.com/xtls/reality/byteorder"
"github.com/xtls/reality/mlkem" "github.com/xtls/reality/mlkem"
"github.com/xtls/reality/tls13" "github.com/xtls/reality/tls13"
) )
@ -953,7 +953,7 @@ func (c *Conn) sendSessionTicket(earlyData bool, extra [][]byte) error {
if _, err := c.config.rand().Read(ageAdd); err != nil { if _, err := c.config.rand().Read(ageAdd); err != nil {
return err return err
} }
m.ageAdd = binary.LittleEndian.Uint32(ageAdd) m.ageAdd = byteorder.LEUint32(ageAdd)
if earlyData { if earlyData {
// RFC 9001, Section 4.6.1 // RFC 9001, Section 4.6.1