mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Fix crypto config
This commit is contained in:
parent
6cf262aae9
commit
ab05357b51
3 changed files with 32 additions and 32 deletions
|
@ -24,7 +24,7 @@ func init() {
|
|||
DefaultValue: 256,
|
||||
ValidationRegex: "^[0-9]{3,5}$",
|
||||
})
|
||||
minFeedEntropy = config.GetAsInt("random/min_feed_entropy", 256)
|
||||
minFeedEntropy = config.Concurrent.GetAsInt("random/min_feed_entropy", 256)
|
||||
}
|
||||
|
||||
// The Feeder is used to feed entropy to the RNG.
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
package random
|
||||
|
||||
import (
|
||||
"time"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
fullFeedDuration = 1 * time.Millisecond
|
||||
fullFeedDuration = 100 * time.Millisecond
|
||||
)
|
||||
|
||||
func getFullFeedDuration() time.Duration {
|
||||
|
||||
// full feed every 5x time of reseedAfterSeconds
|
||||
secsUntilFullFeed := reseedAfterSeconds() * 5
|
||||
// full feed every 5x time of reseedAfterSeconds
|
||||
secsUntilFullFeed := reseedAfterSeconds() * 5
|
||||
|
||||
// full feed at most once per minute
|
||||
if secsUntilFullFeed < 60 {
|
||||
secsUntilFullFeed = 60
|
||||
}
|
||||
// full feed at most once per minute
|
||||
if secsUntilFullFeed < 60 {
|
||||
secsUntilFullFeed = 60
|
||||
}
|
||||
|
||||
return time.Duration(secsUntilFullFeed * int64(time.Second))
|
||||
return time.Duration(secsUntilFullFeed * int64(time.Second))
|
||||
}
|
||||
|
||||
func fullFeeder() {
|
||||
for {
|
||||
for {
|
||||
|
||||
select {
|
||||
case <-time.After(fullFeedDuration):
|
||||
select {
|
||||
case <-time.After(fullFeedDuration):
|
||||
|
||||
rngLock.Lock()
|
||||
feedAll:
|
||||
for {
|
||||
select {
|
||||
case data := <-rngFeeder:
|
||||
rng.Reseed(data)
|
||||
default:
|
||||
break feedAll
|
||||
}
|
||||
}
|
||||
rngLock.Unlock()
|
||||
rngLock.Lock()
|
||||
feedAll:
|
||||
for {
|
||||
select {
|
||||
case data := <-rngFeeder:
|
||||
rng.Reseed(data)
|
||||
default:
|
||||
break feedAll
|
||||
}
|
||||
}
|
||||
rngLock.Unlock()
|
||||
|
||||
case <-shutdownSignal:
|
||||
return
|
||||
}
|
||||
case <-shutdownSignal:
|
||||
return
|
||||
}
|
||||
|
||||
fullFeedDuration = getFullFeedDuration()
|
||||
fullFeedDuration = getFullFeedDuration()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ func init() {
|
|||
ExpertiseLevel: config.ExpertiseLevelDeveloper,
|
||||
OptType: config.OptTypeInt,
|
||||
DefaultValue: 360, // ten minutes
|
||||
ValidationRegex: "^[0-9]{2,5}$",
|
||||
ValidationRegex: "^[1-9][0-9]{1,5}$",
|
||||
})
|
||||
reseedAfterSeconds = config.GetAsInt("random/reseed_after_seconds", 360)
|
||||
reseedAfterSeconds = config.Concurrent.GetAsInt("random/reseed_after_seconds", 360)
|
||||
|
||||
config.Register(&config.Option{
|
||||
Name: "Reseed after x bytes",
|
||||
|
@ -43,7 +43,7 @@ func init() {
|
|||
ExpertiseLevel: config.ExpertiseLevelDeveloper,
|
||||
OptType: config.OptTypeInt,
|
||||
DefaultValue: 1000000, // one megabyte
|
||||
ValidationRegex: "^[0-9]{0,9}$",
|
||||
ValidationRegex: "^[1-9][0-9]{2,9}$",
|
||||
})
|
||||
reseedAfterBytes = config.GetAsInt("random/reseed_after_bytes", 1000000)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue