|
@@ -9,6 +9,7 @@ import (
|
|
|
"crypto/rand"
|
|
"crypto/rand"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"io"
|
|
"io"
|
|
|
|
|
+ "math"
|
|
|
"sync"
|
|
"sync"
|
|
|
|
|
|
|
|
_ "crypto/sha1"
|
|
_ "crypto/sha1"
|
|
@@ -186,7 +187,7 @@ type Config struct {
|
|
|
|
|
|
|
|
// The maximum number of bytes sent or received after which a
|
|
// The maximum number of bytes sent or received after which a
|
|
|
// new key is negotiated. It must be at least 256. If
|
|
// new key is negotiated. It must be at least 256. If
|
|
|
- // unspecified, 1 gigabyte is used.
|
|
|
|
|
|
|
+ // unspecified, a size suitable for the chosen cipher is used.
|
|
|
RekeyThreshold uint64
|
|
RekeyThreshold uint64
|
|
|
|
|
|
|
|
// The allowed key exchanges algorithms. If unspecified then a
|
|
// The allowed key exchanges algorithms. If unspecified then a
|
|
@@ -230,11 +231,12 @@ func (c *Config) SetDefaults() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if c.RekeyThreshold == 0 {
|
|
if c.RekeyThreshold == 0 {
|
|
|
- // RFC 4253, section 9 suggests rekeying after 1G.
|
|
|
|
|
- c.RekeyThreshold = 1 << 30
|
|
|
|
|
- }
|
|
|
|
|
- if c.RekeyThreshold < minRekeyThreshold {
|
|
|
|
|
|
|
+ // cipher specific default
|
|
|
|
|
+ } else if c.RekeyThreshold < minRekeyThreshold {
|
|
|
c.RekeyThreshold = minRekeyThreshold
|
|
c.RekeyThreshold = minRekeyThreshold
|
|
|
|
|
+ } else if c.RekeyThreshold >= math.MaxInt64 {
|
|
|
|
|
+ // Avoid weirdness if somebody uses -1 as a threshold.
|
|
|
|
|
+ c.RekeyThreshold = math.MaxInt64
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|