move the STK generation from the ServerConfig to a separate struct

This commit is contained in:
Marten Seemann
2017-05-13 11:47:36 +08:00
parent 6cc6d49a10
commit 9562df5838
7 changed files with 86 additions and 21 deletions

View File

@@ -58,7 +58,11 @@ const stkKeySize = 16
const stkNonceSize = 16
// NewStkSource creates a source for source address tokens
func NewStkSource(secret []byte) (StkSource, error) {
func NewStkSource() (StkSource, error) {
secret := make([]byte, 32)
if _, err := rand.Read(secret); err != nil {
return nil, err
}
key, err := deriveKey(secret)
if err != nil {
return nil, err