38 lines
871 B
Go
38 lines
871 B
Go
package internal
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
MinEntropyInputLength = 256 >> 3 // 最小熵阈值256比特
|
|
MaxEntropyInputLength = (1 << 35) >> 3 // 最大熵阈值2^35比特
|
|
|
|
)
|
|
|
|
// 可能返回的错误
|
|
var (
|
|
ErrNeedReseed = errors.New("[drng] - need reseed")
|
|
ErrReturnedBitsTooLong = errors.New("[drng] - requested number of bits too long")
|
|
ErrEntropyLength = errors.New("[drng] - entropy length too short or too long")
|
|
)
|
|
|
|
// 安全级别
|
|
type SecureLevel uint
|
|
|
|
const (
|
|
SecureLevel1 SecureLevel = 1 + iota
|
|
SecureLevel2
|
|
)
|
|
|
|
type DrngConfig struct {
|
|
Seedlen int
|
|
Outlen int
|
|
ReseedIntervalInTime time.Duration // 重播种时间阈值
|
|
ReseedIntervalInCounter int // 重播种计数器阈值
|
|
MinEntropy int64
|
|
MinEntropyInputLength int64
|
|
MaxEntropyInputLength int64
|
|
}
|