mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 18:24:02 +03:00
Update to go 1.19
This commit is contained in:
+14
-14
@@ -20,22 +20,22 @@ const (
|
||||
type CipherSuiteType uint8
|
||||
|
||||
const (
|
||||
CipherSuiteType_TLS_AES_128_GCM_SHA256 CipherSuiteType = iota // nolint: stylecheck,golint,revive
|
||||
CipherSuiteType_TLS_AES_256_GCM_SHA384 // nolint: stylecheck,golint,revive
|
||||
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256 // nolint: stylecheck,golint,revive
|
||||
CipherSuiteType_TLS_AES_128_GCM_SHA256 CipherSuiteType = iota //nolint: stylecheck,golint,revive,nosnakecase
|
||||
CipherSuiteType_TLS_AES_256_GCM_SHA384 //nolint: stylecheck,golint,revive,nosnakecase
|
||||
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256 //nolint: stylecheck,golint,revive,nosnakecase
|
||||
)
|
||||
|
||||
func (c CipherSuiteType) Bytes() []byte {
|
||||
switch c {
|
||||
case CipherSuiteType_TLS_AES_128_GCM_SHA256:
|
||||
return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes
|
||||
case CipherSuiteType_TLS_AES_256_GCM_SHA384:
|
||||
return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes
|
||||
case CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256:
|
||||
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
|
||||
case CipherSuiteType_TLS_AES_128_GCM_SHA256: //nolint: nosnakecase
|
||||
return CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes //nolint: nosnakecase
|
||||
case CipherSuiteType_TLS_AES_256_GCM_SHA384: //nolint: nosnakecase
|
||||
return CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes //nolint: nosnakecase
|
||||
case CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256: //nolint: nosnakecase
|
||||
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes //nolint: nosnakecase
|
||||
}
|
||||
|
||||
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes
|
||||
return CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes //nolint: nosnakecase
|
||||
}
|
||||
|
||||
type Version uint8
|
||||
@@ -69,9 +69,9 @@ var (
|
||||
Version12Bytes = []byte{0x03, 0x03}
|
||||
Version13Bytes = []byte{0x03, 0x04}
|
||||
|
||||
CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes = []byte{0x13, 0x01} // nolint: stylecheck,golint,revive
|
||||
CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes = []byte{0x13, 0x02} // nolint: stylecheck,golint,revive
|
||||
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} // nolint: stylecheck,golint,revive
|
||||
CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes = []byte{0x13, 0x01} //nolint: stylecheck,golint,revive,nosnakecase
|
||||
CipherSuiteType_TLS_AES_256_GCM_SHA384_Bytes = []byte{0x13, 0x02} //nolint: stylecheck,golint,revive,nosnakecase
|
||||
CipherSuiteType_TLS_CHACHA20_POLY1305_SHA256_Bytes = []byte{0x13, 0x03} //nolint: stylecheck,golint,revive,nosnakecase
|
||||
)
|
||||
|
||||
type Byter interface {
|
||||
@@ -82,7 +82,7 @@ type Byter interface {
|
||||
type RawBytes []byte
|
||||
|
||||
func (r RawBytes) WriteBytes(writer io.Writer) {
|
||||
writer.Write(r) // nolint: errcheck
|
||||
writer.Write(r) //nolint: errcheck
|
||||
}
|
||||
|
||||
func (r RawBytes) Len() int {
|
||||
|
||||
@@ -18,7 +18,7 @@ type Handshake struct {
|
||||
func (h *Handshake) WriteBytes(writer io.Writer) {
|
||||
packetBuf := bytes.Buffer{}
|
||||
|
||||
writer.Write([]byte{byte(h.Type)}) // nolint: errcheck
|
||||
writer.Write([]byte{byte(h.Type)}) //nolint: errcheck
|
||||
|
||||
packetBuf.Write(h.Version.Bytes())
|
||||
packetBuf.Write(h.Random[:])
|
||||
@@ -30,8 +30,8 @@ func (h *Handshake) WriteBytes(writer io.Writer) {
|
||||
sizeUint24Bytes := sizeUint24[:]
|
||||
sizeUint24Bytes[0], sizeUint24Bytes[2] = sizeUint24Bytes[2], sizeUint24Bytes[0]
|
||||
|
||||
writer.Write(sizeUint24Bytes) // nolint: errcheck
|
||||
packetBuf.WriteTo(writer) // nolint: errcheck
|
||||
writer.Write(sizeUint24Bytes) //nolint: errcheck
|
||||
packetBuf.WriteTo(writer) //nolint: errcheck
|
||||
}
|
||||
|
||||
func (h *Handshake) Len() int {
|
||||
|
||||
+7
-5
@@ -16,9 +16,9 @@ type Record struct {
|
||||
}
|
||||
|
||||
func (r Record) WriteBytes(writer io.Writer) {
|
||||
writer.Write([]byte{byte(r.Type)}) // nolint: errcheck
|
||||
writer.Write(r.Version.Bytes()) // nolint: errcheck
|
||||
binary.Write(writer, binary.BigEndian, uint16(r.Data.Len())) // nolint: errcheck
|
||||
writer.Write([]byte{byte(r.Type)}) //nolint: errcheck
|
||||
writer.Write(r.Version.Bytes()) //nolint: errcheck
|
||||
binary.Write(writer, binary.BigEndian, uint16(r.Data.Len())) //nolint: errcheck
|
||||
r.Data.WriteBytes(writer)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,9 @@ func ReadRecord(reader io.Reader) (Record, error) {
|
||||
return rec, nil
|
||||
}
|
||||
|
||||
func MakeRecords(raw []byte) (arr []Record) {
|
||||
func MakeRecords(raw []byte) []Record {
|
||||
var arr []Record
|
||||
|
||||
for len(raw) > 0 {
|
||||
chunkSize := recordMaxChunkSize
|
||||
if chunkSize > len(raw) {
|
||||
@@ -80,5 +82,5 @@ func MakeRecords(raw []byte) (arr []Record) {
|
||||
raw = raw[chunkSize:]
|
||||
}
|
||||
|
||||
return
|
||||
return arr
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ func (s ServerHello) WelcomePacket() []byte {
|
||||
}
|
||||
recChangeCipher.WriteBytes(buf)
|
||||
|
||||
hostCert := make([]byte, 1024+mrand.Intn(3092)) // nolint: gosec, gomnd
|
||||
rand.Read(hostCert) // nolint: errcheck
|
||||
hostCert := make([]byte, 1024+mrand.Intn(3092)) //nolint: gosec, gomnd
|
||||
rand.Read(hostCert) //nolint: errcheck
|
||||
|
||||
recData := Record{
|
||||
Type: RecordTypeApplicationData,
|
||||
@@ -66,8 +66,8 @@ func NewServerHello(clientHello *ClientHello) *ServerHello {
|
||||
rv.SessionID = make([]byte, len(clientHello.SessionID))
|
||||
copy(rv.SessionID, clientHello.SessionID)
|
||||
|
||||
tail := bytes.NewBuffer(CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes)
|
||||
tail.WriteByte(0x00) // nolint: gomnd // no compression
|
||||
tail := bytes.NewBuffer(CipherSuiteType_TLS_AES_128_GCM_SHA256_Bytes) //nolint: nosnakecase
|
||||
tail.WriteByte(0x00) //nolint: gomnd // no compression
|
||||
makeTLSExtensions(tail)
|
||||
rv.Tail = RawBytes(tail.Bytes())
|
||||
|
||||
@@ -75,7 +75,7 @@ func NewServerHello(clientHello *ClientHello) *ServerHello {
|
||||
}
|
||||
|
||||
func makeTLSExtensions(buf io.Writer) {
|
||||
buf.Write([]byte{ // nolint: errcheck
|
||||
buf.Write([]byte{ //nolint: errcheck
|
||||
0x00, 0x2e, // 46 bytes of data
|
||||
0x00, 0x33, // Extension - Key Share
|
||||
0x00, 0x24, // 36 bytes
|
||||
@@ -85,11 +85,11 @@ func makeTLSExtensions(buf io.Writer) {
|
||||
|
||||
var scalar [32]byte
|
||||
|
||||
rand.Read(scalar[:]) // nolint: errcheck
|
||||
rand.Read(scalar[:]) //nolint: errcheck
|
||||
curve, _ := curve25519.X25519(scalar[:], curve25519.Basepoint)
|
||||
buf.Write(curve) // nolint: errcheck
|
||||
buf.Write(curve) //nolint: errcheck
|
||||
|
||||
buf.Write([]byte{ // nolint: errcheck
|
||||
buf.Write([]byte{ //nolint: errcheck
|
||||
0x00, 0x2b, // Extension - Supported Versions
|
||||
0x00, 0x02, // 2 bytes are following
|
||||
0x03, 0x04, // TLS 1.3
|
||||
|
||||
Reference in New Issue
Block a user