inject a random source into the token protector

This commit is contained in:
Marten Seemann
2020-08-23 17:03:15 +07:00
parent 166d91ae0f
commit 556bf18dbf
6 changed files with 44 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ package handshake
import (
"encoding/asn1"
"fmt"
"io"
"net"
"time"
@@ -39,8 +40,8 @@ type TokenGenerator struct {
}
// NewTokenGenerator initializes a new TookenGenerator
func NewTokenGenerator() (*TokenGenerator, error) {
tokenProtector, err := newTokenProtector()
func NewTokenGenerator(rand io.Reader) (*TokenGenerator, error) {
tokenProtector, err := newTokenProtector(rand)
if err != nil {
return nil, err
}