@@ -90,6 +90,7 @@ const (
90
90
extensionSignatureAlgorithms uint16 = 13
91
91
extensionALPN uint16 = 16
92
92
extensionSCT uint16 = 18
93
+ extensionDelegatedCredentials uint16 = 34
93
94
extensionSessionTicket uint16 = 35
94
95
extensionPreSharedKey uint16 = 41
95
96
extensionEarlyData uint16 = 42
@@ -191,6 +192,16 @@ var defaultSupportedSignatureAlgorithms = []SignatureScheme{
191
192
ECDSAWithSHA1 ,
192
193
}
193
194
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
+
194
205
// helloRetryRequestRandom is set as the Random value of a ServerHello
195
206
// to signal that the message is actually a HelloRetryRequest.
196
207
var helloRetryRequestRandom = []byte { // See RFC 8446, Section 4.1.3.
@@ -262,6 +273,11 @@ type ConnectionState struct {
262
273
// VerifiedChains and its contents should not be modified.
263
274
VerifiedChains [][]* x509.Certificate
264
275
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
+
265
281
// SignedCertificateTimestamps is a list of SCTs provided by the peer
266
282
// through the TLS handshake for the leaf certificate, if any.
267
283
SignedCertificateTimestamps [][]byte
@@ -424,6 +440,13 @@ type ClientHelloInfo struct {
424
440
// Algorithms Extension is being used (see RFC 5246, Section 7.4.1.4.1).
425
441
SignatureSchemes []SignatureScheme
426
442
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
+
427
450
// SupportedProtos lists the application protocols supported by the client.
428
451
// SupportedProtos is set only if the Application-Layer Protocol
429
452
// Negotiation Extension is being used (see RFC 7301, Section 3.1).
@@ -438,6 +461,10 @@ type ClientHelloInfo struct {
438
461
// might be rejected if used.
439
462
SupportedVersions []uint16
440
463
464
+ // SupportDelegatedCredential is true if the client indicated willingness
465
+ // to negotiate the Delegated Credential extension.
466
+ SupportsDelegatedCredential bool
467
+
441
468
// Conn is the underlying net.Conn for the connection. Do not read
442
469
// from, or write to, this connection; that will cause the TLS
443
470
// connection to fail.
@@ -468,10 +495,21 @@ type CertificateRequestInfo struct {
468
495
// empty slice indicates that the server has no preference.
469
496
AcceptableCAs [][]byte
470
497
498
+ // SupportDelegatedCredential is true if the server indicated willingness
499
+ // to negotiate the Delegated Credential extension.
500
+ SupportsDelegatedCredential bool
501
+
471
502
// SignatureSchemes lists the signature schemes that the server is
472
503
// willing to verify.
473
504
SignatureSchemes []SignatureScheme
474
505
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
+
475
513
// Version is the TLS version that was negotiated for this connection.
476
514
Version uint16
477
515
@@ -739,6 +777,13 @@ type Config struct {
739
777
// used for debugging.
740
778
KeyLogWriter io.Writer
741
779
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
+
742
787
// mutex protects sessionTicketKeys and autoSessionTicketKeys.
743
788
mutex sync.RWMutex
744
789
// sessionTicketKeys contains zero or more ticket keys. If set, it means
@@ -829,6 +874,7 @@ func (c *Config) Clone() *Config {
829
874
DynamicRecordSizingDisabled : c .DynamicRecordSizingDisabled ,
830
875
Renegotiation : c .Renegotiation ,
831
876
KeyLogWriter : c .KeyLogWriter ,
877
+ SupportDelegatedCredential : c .SupportDelegatedCredential ,
832
878
sessionTicketKeys : c .sessionTicketKeys ,
833
879
autoSessionTicketKeys : c .autoSessionTicketKeys ,
834
880
}
@@ -1368,6 +1414,16 @@ func (c *Config) writeKeyLog(label string, clientRandom, secret []byte) error {
1368
1414
// and is only for debugging, so a global mutex saves space.
1369
1415
var writerMutex sync.Mutex
1370
1416
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
+
1371
1427
// A Certificate is a chain of one or more certificates, leaf first.
1372
1428
type Certificate struct {
1373
1429
Certificate [][]byte
@@ -1385,6 +1441,16 @@ type Certificate struct {
1385
1441
// SignedCertificateTimestamps contains an optional list of Signed
1386
1442
// Certificate Timestamps which will be served to clients that request it.
1387
1443
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
1388
1454
// Leaf is the parsed form of the leaf certificate, which may be initialized
1389
1455
// using x509.ParseCertificate to reduce per-handshake processing. If nil,
1390
1456
// the leaf certificate will be parsed as needed.
0 commit comments