@@ -90,6 +90,7 @@ const (
9090 extensionSignatureAlgorithms uint16 = 13
9191 extensionALPN uint16 = 16
9292 extensionSCT uint16 = 18
93+ extensionDelegatedCredentials uint16 = 34
9394 extensionSessionTicket uint16 = 35
9495 extensionPreSharedKey uint16 = 41
9596 extensionEarlyData uint16 = 42
@@ -191,6 +192,16 @@ var defaultSupportedSignatureAlgorithms = []SignatureScheme{
191192 ECDSAWithSHA1 ,
192193}
193194
195+ // supportedSignatureAlgorithmsDC contains the signature and hash algorithms that
196+ // the code advertises as supported in a TLS 1.3 ClientHello and in a TLS 1.3
197+ // CertificateRequest. This excludes 'rsa_pss_rsae_' algorithms.
198+ var supportedSignatureAlgorithmsDC = []SignatureScheme {
199+ ECDSAWithP256AndSHA256 ,
200+ Ed25519 ,
201+ ECDSAWithP384AndSHA384 ,
202+ ECDSAWithP521AndSHA512 ,
203+ }
204+
194205// helloRetryRequestRandom is set as the Random value of a ServerHello
195206// to signal that the message is actually a HelloRetryRequest.
196207var helloRetryRequestRandom = []byte { // See RFC 8446, Section 4.1.3.
@@ -262,6 +273,11 @@ type ConnectionState struct {
262273 // VerifiedChains and its contents should not be modified.
263274 VerifiedChains [][]* x509.Certificate
264275
276+ // VerifiedDC indicates that the Delegated Credential sent by the peer (if advertised
277+ // and correctly processed), which has been verified against the leaf certificate,
278+ // has been used.
279+ VerifiedDC bool
280+
265281 // SignedCertificateTimestamps is a list of SCTs provided by the peer
266282 // through the TLS handshake for the leaf certificate, if any.
267283 SignedCertificateTimestamps [][]byte
@@ -424,6 +440,13 @@ type ClientHelloInfo struct {
424440 // Algorithms Extension is being used (see RFC 5246, Section 7.4.1.4.1).
425441 SignatureSchemes []SignatureScheme
426442
443+ // SignatureSchemesDC lists the signature schemes that the client
444+ // is willing to verify when using Delegated Credentials.
445+ // This is and can be different from SignatureSchemes. SignatureSchemesDC
446+ // is set only if the DelegatedCredentials Extension is being used.
447+ // If Delegated Credentials are supported, this list should not be nil.
448+ SignatureSchemesDC []SignatureScheme
449+
427450 // SupportedProtos lists the application protocols supported by the client.
428451 // SupportedProtos is set only if the Application-Layer Protocol
429452 // Negotiation Extension is being used (see RFC 7301, Section 3.1).
@@ -438,6 +461,10 @@ type ClientHelloInfo struct {
438461 // might be rejected if used.
439462 SupportedVersions []uint16
440463
464+ // SupportDelegatedCredential is true if the client indicated willingness
465+ // to negotiate the Delegated Credential extension.
466+ SupportsDelegatedCredential bool
467+
441468 // Conn is the underlying net.Conn for the connection. Do not read
442469 // from, or write to, this connection; that will cause the TLS
443470 // connection to fail.
@@ -468,10 +495,21 @@ type CertificateRequestInfo struct {
468495 // empty slice indicates that the server has no preference.
469496 AcceptableCAs [][]byte
470497
498+ // SupportDelegatedCredential is true if the server indicated willingness
499+ // to negotiate the Delegated Credential extension.
500+ SupportsDelegatedCredential bool
501+
471502 // SignatureSchemes lists the signature schemes that the server is
472503 // willing to verify.
473504 SignatureSchemes []SignatureScheme
474505
506+ // SignatureSchemesDC lists the signature schemes that the server
507+ // is willing to verify when using Delegated Credentials.
508+ // This is and can be different from SignatureSchemes. SignatureSchemesDC
509+ // is set only if the DelegatedCredentials Extension is being used.
510+ // If Delegated Credentials are supported, this list should not be nil.
511+ SignatureSchemesDC []SignatureScheme
512+
475513 // Version is the TLS version that was negotiated for this connection.
476514 Version uint16
477515
@@ -739,6 +777,13 @@ type Config struct {
739777 // used for debugging.
740778 KeyLogWriter io.Writer
741779
780+ // SupportDelegatedCredential is true if the client or server is willing
781+ // to negotiate the delegated credential extension.
782+ // This can only be used with TLS 1.3.
783+ //
784+ // See https://tools.ietf.org/html/draft-ietf-tls-subcerts.
785+ SupportDelegatedCredential bool
786+
742787 // mutex protects sessionTicketKeys and autoSessionTicketKeys.
743788 mutex sync.RWMutex
744789 // sessionTicketKeys contains zero or more ticket keys. If set, it means
@@ -829,6 +874,7 @@ func (c *Config) Clone() *Config {
829874 DynamicRecordSizingDisabled : c .DynamicRecordSizingDisabled ,
830875 Renegotiation : c .Renegotiation ,
831876 KeyLogWriter : c .KeyLogWriter ,
877+ SupportDelegatedCredential : c .SupportDelegatedCredential ,
832878 sessionTicketKeys : c .sessionTicketKeys ,
833879 autoSessionTicketKeys : c .autoSessionTicketKeys ,
834880 }
@@ -1368,6 +1414,16 @@ func (c *Config) writeKeyLog(label string, clientRandom, secret []byte) error {
13681414// and is only for debugging, so a global mutex saves space.
13691415var writerMutex sync.Mutex
13701416
1417+ // A DelegatedCredentialPair contains a Delegated Credential and its
1418+ // associated private key.
1419+ type DelegatedCredentialPair struct {
1420+ // DC is the delegated credential.
1421+ DC * DelegatedCredential
1422+ // PrivateKey is the private key used to derive the public key of
1423+ // contained in DC. PrivateKey must implement crypto.Signer.
1424+ PrivateKey crypto.PrivateKey
1425+ }
1426+
13711427// A Certificate is a chain of one or more certificates, leaf first.
13721428type Certificate struct {
13731429 Certificate [][]byte
@@ -1385,6 +1441,16 @@ type Certificate struct {
13851441 // SignedCertificateTimestamps contains an optional list of Signed
13861442 // Certificate Timestamps which will be served to clients that request it.
13871443 SignedCertificateTimestamps [][]byte
1444+ // DelegatedCredentials are a list of Delegated Credentials with their
1445+ // corresponding private keys, signed by the leaf certificate.
1446+ // If there are no delegated credentials, this field is nil.
1447+ DelegatedCredentials []DelegatedCredentialPair
1448+ // DelegatedCredential is the delegated credential to be used in the
1449+ // handshake.
1450+ // If there are no delegated credentials, this field is nil.
1451+ // NOTE: Do not fill this field, as it will be filled depending on
1452+ // the provided list of delegated credentials.
1453+ DelegatedCredential []byte
13881454 // Leaf is the parsed form of the leaf certificate, which may be initialized
13891455 // using x509.ParseCertificate to reduce per-handshake processing. If nil,
13901456 // the leaf certificate will be parsed as needed.
0 commit comments