Skip to content

Commit

Permalink
Add Delegate Credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Noooste committed Apr 17, 2022
1 parent 679b869 commit 3f46b90
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 1 deletion.
85 changes: 84 additions & 1 deletion u_parrots.go
Expand Up @@ -284,6 +284,80 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) {
&UtlsPaddingExtension{GetPaddingLen: BoringPaddingStyle},
},
}, 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:
return ClientHelloSpec{
TLSVersMax: VersionTLS12,
Expand Down Expand Up @@ -425,6 +499,7 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) {
TLS_RSA_WITH_AES_256_GCM_SHA384,
TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA,
TLS_RSA_WITH_3DES_EDE_CBC_SHA,
},
CompressionMethods: []byte{
compressionNone,
Expand All @@ -444,9 +519,17 @@ func utlsIdToSpec(id ClientHelloID) (ClientHelloSpec, error) {
&SupportedPointsExtension{SupportedPoints: []byte{ //ec_point_formats
pointFormatUncompressed,
}},
&SessionTicketExtension{},
&ALPNExtension{AlpnProtocols: []string{"h2", "http/1.1"}}, //application_layer_protocol_negotiation
&StatusRequestExtension{},
//delegated_credentials
&DelegatesCredentialsExtension{
AlgorithmsSignature: []int16{ //signature_algorithms
0x403,
0x503,
0x603,
0x203,
},
},
&KeyShareExtension{[]KeyShare{
{Group: X25519},
{Group: CurveP256}, //key_share
Expand Down
29 changes: 29 additions & 0 deletions u_tls_extensions.go
Expand Up @@ -754,3 +754,32 @@ func (e *FakeRecordSizeLimitExtension) Read(b []byte) (int, error) {
b[5] = byte(e.Limit & 0xff)
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
}

0 comments on commit 3f46b90

Please sign in to comment.