Add Delegate Credentials

This commit is contained in:
Noste (Erwan) 2022-04-17 18:21:32 +02:00
parent 679b869dee
commit 3f46b90e23
2 changed files with 113 additions and 1 deletions

View file

@ -284,6 +284,80 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) {
&UtlsPaddingExtension{GetPaddingLen: BoringPaddingStyle}, &UtlsPaddingExtension{GetPaddingLen: BoringPaddingStyle},
}, },
}, nil }, nil
case HelloChrome_100:
return ClientHelloSpec{
CipherSuites: []uint16{
0x3A3A,
TLS_AES_128_GCM_SHA256,
TLS_AES_256_GCM_SHA384,
TLS_CHACHA20_POLY1305_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
TLS_RSA_WITH_AES_128_GCM_SHA256,
TLS_RSA_WITH_AES_256_GCM_SHA384,
TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA,
},
CompressionMethods: []byte{
0x00, // compressionNone
},
Extensions: []TLSExtension{
&UtlsGREASEExtension{},
&SNIExtension{},
&UtlsExtendedMasterSecretExtension{},
&RenegotiationInfoExtension{Renegotiation: RenegotiateOnceAsClient},
&SupportedCurvesExtension{[]CurveID{
CurveID(0x6A6A),
X25519,
CurveP256,
CurveP384,
}},
&SupportedPointsExtension{SupportedPoints: []byte{
0x00, // pointFormatUncompressed
}},
&SessionTicketExtension{},
&ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}},
&StatusRequestExtension{},
&SignatureAlgorithmsExtension{SupportedSignatureAlgorithms: []SignatureScheme{
ECDSAWithP256AndSHA256,
PSSWithSHA256,
PKCS1WithSHA256,
ECDSAWithP384AndSHA384,
PSSWithSHA384,
PKCS1WithSHA384,
PSSWithSHA512,
PKCS1WithSHA512,
}},
&SCTExtension{},
&KeyShareExtension{[]KeyShare{
{Group: CurveID(GREASE_PLACEHOLDER), Data: []byte{0}},
{Group: X25519},
}},
&PSKKeyExchangeModesExtension{[]uint8{
PskModeDHE,
}},
&SupportedVersionsExtension{[]uint16{
GREASE_PLACEHOLDER,
VersionTLS13,
VersionTLS12,
VersionTLS11,
VersionTLS10,
}},
&FakeCertCompressionAlgsExtension{[]CertCompressionAlgo{
CertCompressionBrotli,
}},
&UtlsGREASEExtension{},
&UtlsPaddingExtension{GetPaddingLen: BoringPaddingStyle},
},
}, nil
case HelloFirefox_55, HelloFirefox_56: case HelloFirefox_55, HelloFirefox_56:
return ClientHelloSpec{ return ClientHelloSpec{
TLSVersMax: VersionTLS12, TLSVersMax: VersionTLS12,
@ -425,6 +499,7 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) {
TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384,
TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA,
TLS_RSA_WITH_3DES_EDE_CBC_SHA,
}, },
CompressionMethods: []byte{ CompressionMethods: []byte{
compressionNone, compressionNone,
@ -444,9 +519,17 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) {
&SupportedPointsExtension{SupportedPoints: []byte{ //ec_point_formats &SupportedPointsExtension{SupportedPoints: []byte{ //ec_point_formats
pointFormatUncompressed, pointFormatUncompressed,
}}, }},
&SessionTicketExtension{},
&ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}}, //application_layer_protocol_negotiation &ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}}, //application_layer_protocol_negotiation
&StatusRequestExtension{}, &StatusRequestExtension{},
//delegated_credentials &DelegatesCredentialsExtension{
AlgorithmsSignature: []int16{ //signature_algorithms
0x403,
0x503,
0x603,
0x203,
},
},
&KeyShareExtension{[]KeyShare{ &KeyShareExtension{[]KeyShare{
{Group: X25519}, {Group: X25519},
{Group: CurveP256}, //key_share {Group: CurveP256}, //key_share

View file

@ -754,3 +754,32 @@ func (e *FakeRecordSizeLimitExtension) Read(b []byte) (int, error) {
b[5] = byte(e.Limit & 0xff) b[5] = byte(e.Limit & 0xff)
return e.Len(), io.EOF return e.Len(), io.EOF
} }
type DelegatesCredentialsExtension struct {
AlgorithmsSignature []int16
}
func (e *DelegatesCredentialsExtension) writeToUConn(uc *UConn) error {
return nil
}
func (e *DelegatesCredentialsExtension) Len() int {
return 6 + 2*len(e.AlgorithmsSignature)
}
func (e *DelegatesCredentialsExtension) Read(b []byte) (int, error) {
if len(b) < e.Len() {
return 0, io.ErrShortBuffer
}
b[0] = byte(34 >> 8)
b[1] = byte(34)
b[2] = byte((2 + 2*len(e.AlgorithmsSignature)) >> 8)
b[3] = byte(2 + 2*len(e.AlgorithmsSignature))
b[4] = byte((2 * len(e.AlgorithmsSignature)) >> 8)
b[5] = byte(2 * len(e.AlgorithmsSignature))
for i, sigAndHash := range e.AlgorithmsSignature {
b[6+2*i] = byte(sigAndHash >> 8)
b[7+2*i] = byte(sigAndHash)
}
return e.Len(), io.EOF
}