aboutsummaryrefslogtreecommitdiff
path: root/ssha.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-01-27 17:01:32 +0100
committerAlex Auvolat <alex@adnab.me>2020-01-27 17:01:32 +0100
commit3edaad9317db280db903a18ec85a70e6c32cabf9 (patch)
treeffca975d10b64d374168e96ffe8a7fc1e5189493 /ssha.go
parente7ded9d6b575870a17ce58f0192cc388984dfb4a (diff)
downloadbottin-3edaad9317db280db903a18ec85a70e6c32cabf9.tar.gz
bottin-3edaad9317db280db903a18ec85a70e6c32cabf9.zip
Use better randomness
Diffstat (limited to 'ssha.go')
-rw-r--r--ssha.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/ssha.go b/ssha.go
index f1c5a8b..134c058 100644
--- a/ssha.go
+++ b/ssha.go
@@ -1,11 +1,12 @@
package main
import (
+ "log"
"bytes"
"crypto/sha1"
"encoding/base64"
"fmt"
- "math/rand"
+ "crypto/rand"
)
// Encode encodes the []byte of raw password
@@ -38,7 +39,10 @@ func SSHAMatches(encodedPassPhrase string, rawPassPhrase []byte) bool {
// makeSalt make a 32 byte array containing random bytes.
func makeSalt() []byte {
sbytes := make([]byte, 32)
- rand.Read(sbytes)
+ _, err := rand.Read(sbytes)
+ if err != nil {
+ log.Panicf("Could not read random bytes: %s", err)
+ }
return sbytes
}