mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-07 09:41:37 +08:00
logic/accesskeys: math.Rand -> crypto.Rand
This replaces the usage of the non-cryptographically secure math.Rand with the system CSPRNG accessed via crypto.Rand. Signed-off-by: John Sahhar <john@gravitl.com>
This commit is contained in:
23
logic/accesskeys_test.go
Normal file
23
logic/accesskeys_test.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package logic
|
||||
|
||||
import "testing"
|
||||
|
||||
func Test_genKeyName(t *testing.T) {
|
||||
for i := 0; i < 100; i++ {
|
||||
kname := genKeyName()
|
||||
t.Log(kname)
|
||||
if len(kname) != 20 {
|
||||
t.Fatalf("improper length of key name, expected 20 got :%d", len(kname))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Test_genKey(t *testing.T) {
|
||||
for i := 0; i < 100; i++ {
|
||||
kname := genKey()
|
||||
t.Log(kname)
|
||||
if len(kname) != 16 {
|
||||
t.Fatalf("improper length of key name, expected 16 got :%d", len(kname))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user