Skip to content

Commit a4cd365

Browse files
committed
crypto/tls: avoid referencing potentially unused symbols in init
A reference to a function in a "var _ = ..." init-time initialization keeps the symbol live. Move references to Config.EncryptTicket and Config.DecryptTicket into tests. These references increase the size of an unused import of crypto/tls by about 1MiB. Change-Id: I6d62a6dcbd73e22972a217afcda7395e909b52cc Reviewed-on: https://go-review.googlesource.com/c/go/+/498595 Reviewed-by: Filippo Valsorda <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent f89d575 commit a4cd365

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/crypto/tls/ticket.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ func (c *Config) EncryptTicket(cs ConnectionState, ss *SessionState) ([]byte, er
301301
return c.encryptTicket(stateBytes, ticketKeys)
302302
}
303303

304-
var _ = &Config{WrapSession: (&Config{}).EncryptTicket}
305-
306304
func (c *Config) encryptTicket(state []byte, ticketKeys []ticketKey) ([]byte, error) {
307305
if len(ticketKeys) == 0 {
308306
return nil, errors.New("tls: internal error: session ticket keys unavailable")
@@ -348,8 +346,6 @@ func (c *Config) DecryptTicket(identity []byte, cs ConnectionState) (*SessionSta
348346
return s, nil
349347
}
350348

351-
var _ = &Config{UnwrapSession: (&Config{}).DecryptTicket}
352-
353349
func (c *Config) decryptTicket(encrypted []byte, ticketKeys []ticketKey) []byte {
354350
if len(encrypted) < aes.BlockSize+sha256.Size {
355351
return nil

src/crypto/tls/ticket_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright 2023 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package tls
6+
7+
var _ = &Config{WrapSession: (&Config{}).EncryptTicket}
8+
var _ = &Config{UnwrapSession: (&Config{}).DecryptTicket}

0 commit comments

Comments
 (0)