Skip to content

Commit

Permalink
修复错误类型
Browse files Browse the repository at this point in the history
实现了客户端Hello消息扩展的序列化和反序列
移除无效注释代码
  • Loading branch information
Trisia committed Jan 8, 2025
1 parent 1206e0a commit 61fc620
Show file tree
Hide file tree
Showing 4 changed files with 506 additions and 376 deletions.
20 changes: 15 additions & 5 deletions tlcp/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"io"
"net"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -101,10 +102,10 @@ const (

// GM/T0024-2023 A.2 Trusted CA indication受信任的CA指示
const (
IdentifierTypePreAgreed uint16 = 0 // Pre-agreed预先协商
IdentifierTypeX509Name uint16 = 2 // X.509证书名称
IdentifierTypeKeySM3Hash uint16 = 4 // 密钥SM3哈希
IdentifierTypeCertSM3Hash uint16 = 5 // 证书SM3哈希
IdentifierTypePreAgreed uint8 = 0 // Pre-agreed预先协商
IdentifierTypeX509Name uint8 = 2 // X.509证书名称
IdentifierTypeKeySM3Hash uint8 = 4 // 密钥SM3哈希
IdentifierTypeCertSM3Hash uint8 = 5 // 证书SM3哈希
)

// TrustedAuthority GM/T0024-2023 A.2 Trusted CA indication受信任的CA指示 结构
Expand All @@ -127,7 +128,7 @@ const (
// // DER-encoded X.509 DistinguishedName of the CA.
// opaque DistinguishedName<1..2^16-1>;
type TrustedAuthority struct {
IdentifierType uint16 // 证书标识类型
IdentifierType uint8 // 证书标识类型
Identifier []byte // 证书标识
}

Expand Down Expand Up @@ -159,6 +160,15 @@ const (
// enum { anonymous(0), rsa(1), dsa(2), ecdsa(3), sm2(4), (255) }
type SignatureScheme uint16

func (s SignatureScheme) String() string {
switch s {
case SM2WithSM3:
return "SM2WithSM3"
default:
return "SignatureScheme(" + strconv.FormatInt(int64(s), 10) + ")"
}
}

const (
// SM2WithSM3 指定HashAlgorithm为SM3,指定SignatureAlgorithm为SM2。 => 0x0704
SM2WithSM3 SignatureScheme = 0x0704
Expand Down
4 changes: 1 addition & 3 deletions tlcp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,7 @@ func (c *Conn) writeChangeCipherRecord() error {
return err
}

// readHandshake reads the next handshake message from
// the record layer. If transcript is non-nil, the message
// is written to the passed transcriptHash.
// readHandshake 从记录层读取下一个握手消息。如果transcript不为nil,则将消息写入传递的transcriptHash。
func (c *Conn) readHandshake(transcript transcriptHash) (interface{}, error) {
for c.hand.Len() < 4 {
if err := c.readRecord(); err != nil {
Expand Down
Loading

0 comments on commit 61fc620

Please sign in to comment.