@@ -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.
@@ -258,6 +269,11 @@ type ConnectionState struct {
258
269
// (and the peer provided a certificate) or RequireAndVerifyClientCert.
259
270
VerifiedChains [][]* x509.Certificate
260
271
272
+ // VerifiedDC indicates that the Delegated Credential sent by the peer (if advertised
273
+ // and correctly processed), which has been verified against the leaf certificate,
274
+ // has been used.
275
+ VerifiedDC bool
276
+
261
277
// SignedCertificateTimestamps is a list of SCTs provided by the peer
262
278
// through the TLS handshake for the leaf certificate, if any.
263
279
SignedCertificateTimestamps [][]byte
@@ -427,6 +443,13 @@ type ClientHelloInfo struct {
427
443
// Algorithms Extension is being used (see RFC 5246, Section 7.4.1.4.1).
428
444
SignatureSchemes []SignatureScheme
429
445
446
+ // SignatureSchemesDC lists the signature schemes that the client
447
+ // is willing to verify when using Delegated Credentials.
448
+ // This is and can be different from SignatureSchemes. SignatureSchemesDC
449
+ // is set only if the DelegatedCredentials Extension is being used.
450
+ // If Delegated Credentials are supported, this list should not be nil.
451
+ SignatureSchemesDC []SignatureScheme
452
+
430
453
// SupportedProtos lists the application protocols supported by the client.
431
454
// SupportedProtos is set only if the Application-Layer Protocol
432
455
// Negotiation Extension is being used (see RFC 7301, Section 3.1).
@@ -441,6 +464,10 @@ type ClientHelloInfo struct {
441
464
// might be rejected if used.
442
465
SupportedVersions []uint16
443
466
467
+ // SupportDelegatedCredential is true if the client indicated willingness
468
+ // to negotiate the Delegated Credential extension.
469
+ SupportsDelegatedCredential bool
470
+
444
471
// Conn is the underlying net.Conn for the connection. Do not read
445
472
// from, or write to, this connection; that will cause the TLS
446
473
// connection to fail.
@@ -471,10 +498,21 @@ type CertificateRequestInfo struct {
471
498
// empty slice indicates that the server has no preference.
472
499
AcceptableCAs [][]byte
473
500
501
+ // SupportDelegatedCredential is true if the server indicated willingness
502
+ // to negotiate the Delegated Credential extension.
503
+ SupportsDelegatedCredential bool
504
+
474
505
// SignatureSchemes lists the signature schemes that the server is
475
506
// willing to verify.
476
507
SignatureSchemes []SignatureScheme
477
508
509
+ // SignatureSchemesDC lists the signature schemes that the server
510
+ // is willing to verify when using Delegated Credentials.
511
+ // This is and can be different from SignatureSchemes. SignatureSchemesDC
512
+ // is set only if the DelegatedCredentials Extension is being used.
513
+ // If Delegated Credentials are supported, this list should not be nil.
514
+ SignatureSchemesDC []SignatureScheme
515
+
478
516
// Version is the TLS version that was negotiated for this connection.
479
517
Version uint16
480
518
@@ -751,6 +789,13 @@ type Config struct {
751
789
// This feature is unstable and applications MUST NOT depend on it.
752
790
CFControl interface {}
753
791
792
+ // SupportDelegatedCredential is true if the client or server is willing
793
+ // to negotiate the delegated credential extension.
794
+ // This can only be used with TLS 1.3.
795
+ //
796
+ // See https://tools.ietf.org/html/draft-ietf-tls-subcerts.
797
+ SupportDelegatedCredential bool
798
+
754
799
// mutex protects sessionTicketKeys and autoSessionTicketKeys.
755
800
mutex sync.RWMutex
756
801
// sessionTicketKeys contains zero or more ticket keys. If set, it means the
@@ -841,6 +886,7 @@ func (c *Config) Clone() *Config {
841
886
DynamicRecordSizingDisabled : c .DynamicRecordSizingDisabled ,
842
887
Renegotiation : c .Renegotiation ,
843
888
KeyLogWriter : c .KeyLogWriter ,
889
+ SupportDelegatedCredential : c .SupportDelegatedCredential ,
844
890
CFEventHandler : c .CFEventHandler ,
845
891
CFControl : c .CFControl ,
846
892
sessionTicketKeys : c .sessionTicketKeys ,
@@ -1382,6 +1428,16 @@ func (c *Config) writeKeyLog(label string, clientRandom, secret []byte) error {
1382
1428
// and is only for debugging, so a global mutex saves space.
1383
1429
var writerMutex sync.Mutex
1384
1430
1431
+ // A DelegatedCredentialPair contains a Delegated Credential and its
1432
+ // associated private key.
1433
+ type DelegatedCredentialPair struct {
1434
+ // DC is the delegated credential.
1435
+ DC * DelegatedCredential
1436
+ // PrivateKey is the private key used to derive the public key of
1437
+ // contained in DC. PrivateKey must implement crypto.Signer.
1438
+ PrivateKey crypto.PrivateKey
1439
+ }
1440
+
1385
1441
// A Certificate is a chain of one or more certificates, leaf first.
1386
1442
type Certificate struct {
1387
1443
Certificate [][]byte
@@ -1399,6 +1455,16 @@ type Certificate struct {
1399
1455
// SignedCertificateTimestamps contains an optional list of Signed
1400
1456
// Certificate Timestamps which will be served to clients that request it.
1401
1457
SignedCertificateTimestamps [][]byte
1458
+ // DelegatedCredentials are a list of Delegated Credentials with their
1459
+ // corresponding private keys, signed by the leaf certificate.
1460
+ // If there are no delegated credentials, this field is nil.
1461
+ DelegatedCredentials []DelegatedCredentialPair
1462
+ // DelegatedCredential is the delegated credential to be used in the
1463
+ // handshake.
1464
+ // If there are no delegated credentials, this field is nil.
1465
+ // NOTE: Do not fill this field, as it will be filled depending on
1466
+ // the provided list of delegated credentials.
1467
+ DelegatedCredential []byte
1402
1468
// Leaf is the parsed form of the leaf certificate, which may be initialized
1403
1469
// using x509.ParseCertificate to reduce per-handshake processing. If nil,
1404
1470
// the leaf certificate will be parsed as needed.
0 commit comments