use fastsha256 in rpcwebsocket.go.

While this is not performance critical code, there is no need to import
another package into the final binary.
This commit is contained in:
Dave Collins 2014-05-01 10:36:41 -05:00
parent d72da506c5
commit a38f93bf06

View file

@ -9,7 +9,6 @@ import (
"code.google.com/p/go.crypto/ripemd160" "code.google.com/p/go.crypto/ripemd160"
"code.google.com/p/go.net/websocket" "code.google.com/p/go.net/websocket"
"container/list" "container/list"
"crypto/sha256"
"crypto/subtle" "crypto/subtle"
"encoding/base64" "encoding/base64"
"encoding/hex" "encoding/hex"
@ -21,6 +20,7 @@ import (
"github.com/conformal/btcutil" "github.com/conformal/btcutil"
"github.com/conformal/btcwire" "github.com/conformal/btcwire"
"github.com/conformal/btcws" "github.com/conformal/btcws"
"github.com/conformal/fastsha256"
"io" "io"
"sync" "sync"
"time" "time"
@ -942,7 +942,7 @@ func (c *wsClient) handleMessage(msg string) {
// Check credentials. // Check credentials.
login := authCmd.Username + ":" + authCmd.Passphrase login := authCmd.Username + ":" + authCmd.Passphrase
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login)) auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
authSha := sha256.Sum256([]byte(auth)) authSha := fastsha256.Sum256([]byte(auth))
cmp := subtle.ConstantTimeCompare(authSha[:], c.server.authsha[:]) cmp := subtle.ConstantTimeCompare(authSha[:], c.server.authsha[:])
if cmp != 1 { if cmp != 1 {
rpcsLog.Warnf("Auth failure.") rpcsLog.Warnf("Auth failure.")