github.com/crewjam/saml@v0.4.14/util.go (about) 1 package saml 2 3 import ( 4 "crypto/rand" 5 "io" 6 "time" 7 8 dsig "github.com/russellhaering/goxmldsig" 9 ) 10 11 // TimeNow is a function that returns the current time. The default 12 // value is time.Now, but it can be replaced for testing. 13 var TimeNow = func() time.Time { return time.Now().UTC() } 14 15 // Clock is assigned to dsig validation and signing contexts if it is 16 // not nil, otherwise the default clock is used. 17 var Clock *dsig.Clock 18 19 // RandReader is the io.Reader that produces cryptographically random 20 // bytes when they are need by the library. The default value is 21 // rand.Reader, but it can be replaced for testing. 22 var RandReader = rand.Reader 23 24 //nolint:unparam // This always receives 20, but we want the option to do more or less if needed. 25 func randomBytes(n int) []byte { 26 rv := make([]byte, n) 27 28 if _, err := io.ReadFull(RandReader, rv); err != nil { 29 panic(err) 30 } 31 return rv 32 }