Kaynağa Gözat

use new time API

R=bradfitz, gri, r, dsymonds
CC=golang-dev
https://golang.org/cl/5390042
tls13
Russ Cox 13 yıl önce
ebeveyn
işleme
37bb6649e2
4 değiştirilmiş dosya ile 7 ekleme ve 6 silme
  1. +3
    -3
      common.go
  2. +1
    -1
      handshake_client.go
  3. +1
    -1
      handshake_server.go
  4. +2
    -1
      handshake_server_test.go

+ 3
- 3
common.go Dosyayı Görüntüle

@@ -121,7 +121,7 @@ type Config struct {

// Time returns the current time as the number of seconds since the epoch.
// If Time is nil, TLS uses the system time.Seconds.
Time func() int64
Time func() time.Time

// Certificates contains one or more certificate chains
// to present to the other side of the connection.
@@ -175,10 +175,10 @@ func (c *Config) rand() io.Reader {
return r
}

func (c *Config) time() int64 {
func (c *Config) time() time.Time {
t := c.Time
if t == nil {
t = time.Seconds
t = time.Now
}
return t()
}


+ 1
- 1
handshake_client.go Dosyayı Görüntüle

@@ -32,7 +32,7 @@ func (c *Conn) clientHandshake() error {
nextProtoNeg: len(c.config.NextProtos) > 0,
}

t := uint32(c.config.time())
t := uint32(c.config.time().Unix())
hello.random[0] = byte(t >> 24)
hello.random[1] = byte(t >> 16)
hello.random[2] = byte(t >> 8)


+ 1
- 1
handshake_server.go Dosyayı Görüntüle

@@ -95,7 +95,7 @@ FindCipherSuite:

hello.vers = vers
hello.cipherSuite = suite.id
t := uint32(config.time())
t := uint32(config.time().Unix())
hello.random = make([]byte, 32)
hello.random[0] = byte(t >> 24)
hello.random[1] = byte(t >> 16)


+ 2
- 1
handshake_server_test.go Dosyayı Görüntüle

@@ -15,6 +15,7 @@ import (
"strconv"
"strings"
"testing"
"time"
)

type zeroSource struct{}
@@ -31,7 +32,7 @@ var testConfig *Config

func init() {
testConfig = new(Config)
testConfig.Time = func() int64 { return 0 }
testConfig.Time = func() time.Time { return time.Unix(0, 0) }
testConfig.Rand = zeroSource{}
testConfig.Certificates = make([]Certificate, 1)
testConfig.Certificates[0].Certificate = [][]byte{testCertificate}


Yükleniyor…
İptal
Kaydet